source: CONFIG/UNIFORM/v7/ICOLMDZOR_v7/compile_icolmdzor.sh @ 5878

Last change on this file since 5878 was 5878, checked in by aclsce, 3 years ago

Merged LMDZORv6.2.2 with ICOLMDZOR_v7 configuration te be able to launch LMDZOR experiment from ICOLMDZOR configuration.
Use of NPv6.2 physiq version in ICOLMDZOR experiments.

  • Property svn:executable set to *
File size: 15.2 KB
RevLine 
[4268]1#!/bin/bash
2#set -vx
3# Default options
4#
5#
6#
[4409]7date
[4268]8#### 1  Set up the compiling options
9#### Define some directories
10submitdir=$( pwd )
11modipsl=$submitdir/../..
[4275]12arch_path=$submitdir/ARCH
[4268]13export ROOT=$modipsl/modeles/DYNAMICO
14
[4278]15#### Set default options
[4268]16# Optimization mode
17# optmode=prod/dev/debug
18optmode=prod
19# Resolution if compiling LMDZ in regular mode without DYNAMICO
[4921]20# Use for example following "./compile_icolmdzor.sh -regular_latlon 144x142x79"
[4268]21regular_latlon=no
22# fcm_arch
23fcm_arch=default
24# Default values to be overritten
[4339]25parallel=mpi_omp
[4268]26export fcm_arch parallel xios
27full_flag=""
[4921]28full_xios=""
29full_lmdz=""
30full_orch=""
31full_dyna=""
32
[4391]33# Default netcdf_lib is used for XIOS but can be change by argument
34netcdf_lib=""
[4268]35
[4408]36# Output text file for compilation of each component
[4663]37datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
38outfile=$submitdir/out_compile_icolmdzor.$datestr
[4921]39echo > $outfile
[4663]40echo; echo "Text output from compilation will be stored in file out_compile_icolmdzor.$datestr"; echo 
[4408]41
[4278]42#### Read arguments
[4268]43# Loop over all arguments to modify default set up
44while (($# > 0)) ; do
[4278]45    case $1 in
[4921]46        "-h") cat <<end_help
[4268]47
48########################################################################
[4278]49# Usage of the script compile_icolmdzor.sh
[4268]50#
51########################################################################
52
53./compile_config [Options]
54
[4407]55Options: -full, -regular_latlon, -debug, -dev, -prod(default)
[4268]56
[4278]57Example 1: Default compilation of DYNAMICO-LMDZ-ORCHIDEE with XIOS and IOIPSL
58./compile_icolmdzor.sh
[4268]59
[4407]60Example 2: Compile in debug mode
61./compile_icolmdzor.sh -debug
62
63Example 3: Default compilation with full recompilation of all components
[4278]64./compile_icolmdzor.sh -full
[4268]65
[4407]66Example 4: Compilation of LMDZ in regular lat-lon for dimension 144x142x79.
[4278]67The dimension can be changed to any other 3d dimension. DYNAMICO is also compiled as default.
68./compile_icolmdzor.sh -regular_latlon 144x142x79
[4268]69
[4921]70end_help
[4278]71            exit;;
[4268]72
[4921]73        "-parallel")        parallel=$2 ; shift ; shift ;;
74        "-arch")            fcm_arch="$2" ; shift ; shift ;;
75        "-xios")            xios="$2" ; shift ; shift ;;
76        "-debug")           optmode=debug ; shift ;;
77        "-dev")             optmode=dev ; shift ;;
78        "-prod")            optmode=prod ; shift ;;
79        "-regular_latlon")  regular_latlon=yes ; resol_atm=$2 ; shift ; shift ;;
80        "-full")            full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; full_dyna="-full" ; shift ;;
81        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
82        "-full_lmdz")       full_lmdz="-full"  ; shift ;;
83        "-full_orch")       full_orch="-full"  ; shift ;;
84        "-full_dyna")       full_dyna="-full"  ; shift ;;
85        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
86        *)                  echo "unknown option "$1" , exiting..." ;  exit
[4278]87    esac
88done
[4268]89
[4921]90echo "Following options are set in current compiling:" >> $outfile 
91echo "   regular_latlon=$regular_latlon (if yes, then resol_atm=${resol_atm})" >> $outfile 
92echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
93echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch, full_dyna=$full_dyna" >> $outfile 
[4408]94echo >> $outfile
[4268]95
[4278]96### Read host dependent default values
97### These variables will not be changed if they were set as argument
[4268]98###./host.sh $host
99# Later : Following lines should be set in host.sh file
100# begin host.sh
101if [ $fcm_arch == default ] ; then
[4278]102    # Find out current host and source specific paths and commands for the host
103    case $( hostname -s ) in
[4921]104        jean-zay*)
105            fcm_arch=X64_JEANZAY;;
[5479]106        irene170|irene171|irene190|irene191|irene192|irene193)
107            fcm_arch=X64_IRENE;;
108        irene172|irene173|irene194|irene195)
109            fcm_arch=X64_IRENE-AMD;;
[4278]110        asterix*|obelix*)
[4975]111            fcm_arch=ifort_LSCE
112            if [ "${parallel}" == "mpi_omp" ] ; then
113                echo "Warning!! Currently at Obelix hybrid mode is not possible."
114                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
115                echo ""
116                parallel=mpi
117            else
118                echo "You used -parallel" $parallel
119            fi ;;
120        ciclad*|climserv*|loholt*|camelot*)
[4391]121            fcm_arch=ifort_CICLAD;;
[4278]122        *)
[4391]123            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
[4278]124            echo Exit now.
125            exit
126    esac
[4268]127fi
128
[4921]129# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
[4391]130# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
131if [ -f ARCH/arch-${fcm_arch}.env ] ; then
[4408]132    echo >> $outfile
[4921]133    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
134    echo "Note that this new environement might be kept after compilation."
135    echo "If this is the case, source again your personal environment after compilation."
[4408]136    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
137    module list   >> $outfile 2>&1
138
[4921]139    # Make a link to this file, to be used also in config.card
[4391]140    rm -f ARCH/arch.env
141    ln -s arch-${fcm_arch}.env ARCH/arch.env
[4921]142
143    # Source the file
[4408]144    source ARCH/arch.env   >> $outfile 2>&1
145
146    echo >> $outfile
147    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
148    module list   >> $outfile 2>&1
[4391]149fi
150
[4268]151#### 2 Do the compilation
152## 2.1 Compile ioipsl
153cd $modipsl/modeles/IOIPSL
[4278]154echo; echo "NOW COMPILE IOIPSL"
[4408]155echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
156
157echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
158     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
[4268]159# Test if compiling succeded
160if [[ $? != 0 ]] ; then
[4278]161    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
162    exit
[4268]163fi
164
165## 2.2 Compile xios
166cd $modipsl/modeles/XIOS
[4278]167echo; echo "NOW COMPILE XIOS"
[4408]168echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
[4921]169echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
170     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
[4268]171# Test if compiling succeded
172if [[ $? != 0 ]] ; then
[4278]173    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
174    exit
[4268]175fi
[4391]176# Move executables to modipsl/bin
[4921]177if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
178    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
[4391]179else
180    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
181    exit
182fi
[4268]183
[4391]184
[4268]185## 2.3 Compile orchidee
186cd $modipsl/modeles/ORCHIDEE
[4278]187echo; echo "NOW COMPILE ORCHIDEE"
[4408]188echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
189
[4975]190# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
191# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
192# to ask question and wait for interactivly answer from the user.
193if [ -f build/fcm.bld.lock ] ; then
194    echo >> $outfile
195    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
196    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
197    echo "           The file will now be removed. "   >> $outfile
198    echo >> $outfile
199    rm -f build/fcm.bld.lock
200fi
201
[4921]202echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 
203        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 2>&1
[4268]204# Test if compiling finished
205if [[ $? != 0 ]] ; then
206    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
207    exit
208fi
209
[4921]210# If orchide driver executables have been compiled (option -driver), then rename executables to contain $optmode
211if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
212if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
213
214
[4278]215## 2.4 Compile lmdz
[4268]216cd $modipsl/modeles/LMDZ
[4278]217# Compile LMDZ as library to couple to DYNAMICO
218echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
[4408]219echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
220
[4663]221# Check if the compilation of LMDZ was previsouly interupted prematured.
222# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
223# to ask question and wait for interactivly answer from the user.
224if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
225  echo >> $outfile
226  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
227  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
228  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
229  echo >> $outfile
230  rm -f libf/grid/dimensions.h
231  rm -f .lock
232fi
233
[4921]234echo ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 
235     ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 2>&1
[4268]236# Test if compiling finished
237if [[ $? != 0 ]] ; then
[4278]238    echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
[4268]239    exit
240fi
241
[4278]242
243## 2.5 Compile DYNAMICO
[4408]244cd $modipsl/modeles/DYNAMICO
[4278]245echo; echo "NOW COMPILE DYNAMICO "
[4408]246echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
247
[5878]248if [ -d $modipsl/config/ICOLMDZOR_v7/SOURCES/DYNAMICO ] ; then
249    cd $modipsl/config/ICOLMDZOR_v7/SOURCES/DYNAMICO
250    for dir in $( find . -mindepth 1 -maxdepth 1 -type d ); do
251        for file in $( find $dir -type f); do
252            echo cp $file $modipsl/modeles/DYNAMICO/$file >> $outfile 
253            cp $file $modipsl/modeles/DYNAMICO/$file  >> $outfile 2>&1
254        done
255    done
256    cd $modipsl/modeles/DYNAMICO
257fi
258
[4921]259echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
260     ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
[4268]261# Test if compiling finished
262if [[ $? != 0 ]] ; then
[4278]263    echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
264    exit
[4268]265fi
266
[4278]267## 2.6 Compile interface ICOSA_LMDZ
[4408]268cd $modipsl/modeles/ICOSA_LMDZ
[4278]269echo; echo "NOW COMPILE ICOSA_LMDZ "
[4408]270echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
[4268]271
[5878]272if [ -d $modipsl/config/ICOLMDZOR_v7/SOURCES/ICOSA_LMDZ ] ; then
273    cd $modipsl/config/ICOLMDZOR_v7/SOURCES/ICOSA_LMDZ
274    for dir in $( find . -mindepth 1 -maxdepth 1 -type d ); do
275        for file in $( find $dir -type f); do
276            echo cp $file $modipsl/modeles/ICOSA_LMDZ/$file >> $outfile 
277            cp $file $modipsl/modeles/ICOSA_LMDZ/$file  >> $outfile 2>&1
278        done
279    done
280    cd $modipsl/modeles/ICOSA_LMDZ
281fi
282
[4921]283echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 
284     ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 2>&1
[4268]285# Test if compiling finished
286if [[ $? != 0 ]] ; then
[4278]287    echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
288    exit
[4268]289fi
[4391]290# Move executables to modipsl/bin
291if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
[4921]292    mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${optmode}.exe
[4391]293else
294    echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
295    exit
296fi
[4268]297
298
[4359]299
[4278]300## 2.7 Compile LMDZ for regular latlon configuration
301if [ $regular_latlon = yes ] ; then
[4268]302
[4278]303    cd $modipsl/modeles/LMDZ
304    # Compile LMDZ regular lat-lon exectuable
[4921]305    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
306    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
[4408]307
[4663]308    # Check if the compilation of LMDZ was previsouly interupted prematured.
309    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
310    # to ask question and wait for interactivly answer from the user.
311    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
312        echo >> $outfile
313        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
314        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
315        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
316        echo >> $outfile
317        rm -f libf/grid/dimensions.h
318        rm -f .lock
319    fi
[4921]320    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 
321         ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 2>&1
[4278]322    # Test if compiling finished
323    if [[ $? != 0 ]] ; then
324        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
325        exit
326    fi
327
328    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
[4921]329    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
330    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
[4408]331
[4921]332    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 
333         ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 2>&1
[4278]334    # Test if compiling finished
335    if [[ $? != 0 ]] ; then
336        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
337        exit
338    fi
339
340    # Find executable suffix
341    if [ $parallel == seq ] || [ $parallel == none ] ; then
[4921]342        suffix=_${resol_atm}_phylmd_seq_orch.e
[4278]343    else
[4921]344        suffix=_${resol_atm}_phylmd_para_mem_orch.e
[4278]345    fi
[4921]346    echo gcm suffix = $suffix
[4268]347   
[4278]348    # Move executables to modipsl/bin folder
349    echo "Move gcm.e and ce0l executable to modipsl/bin"
[4921]350    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
351        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
352    else
353        echo "ERROR gcm${suffix} executable does not exist." 
354        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
355        exit
356    fi
[4268]357
[4921]358    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
359        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
360    else
361        echo "ERROR ce0l${suffix} executable does not exist." 
362        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
363        exit
364    fi
[4268]365fi
366
[4278]367
[4408]368echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
[4663]369echo ls -lrt modipsl/bin >> $outfile
370ls -lrt $modipsl/bin >> $outfile
[4278]371
[4663]372echo; echo "ALL COMPILING FINISHED" ; echo
373echo "Executables are found in modipsl/bin"
374echo "Check that executable names correspond with the name set in config.card before launching the job"
375echo ls -lrt modipsl/bin
376ls -lrt $modipsl/bin
377
[4409]378date
[4268]379exit
380
381
Note: See TracBrowser for help on using the repository browser.