source: CONFIG/UNIFORM/v7/IPSLCM7/compile_ipslcm7.sh @ 6834

Last change on this file since 6834 was 6828, checked in by jgipsl, 2 months ago

Check if LMDZ/libo exists before compression. Needed when compiling ORCHIDEE offline only.

  • Property svn:executable set to *
File size: 31.3 KB
RevLine 
[5479]1#!/bin/bash
2# Default options
3#
4#
5#
6date
7#### 1  Set up the compiling options
8#### Define some directories
9submitdir=$( pwd )
10modipsl=$submitdir/../..
11arch_path=$submitdir/ARCH
12mysrc_path=$submitdir/SOURCES
[6722]13export ROOT=$modipsl/modeles/IOIPSL
[6641]14#### Set default options
15# Activate compilation of LMDZ for regular latlon grid without DYNAMICO
[6677]16regular_latlon=y
17# Atmospheric resolution for regular grid for LMDZ/ORCHIDEE, if regular_latlon=y
[5479]18resol_atm=144x142x79
19# Coupled with ocean biogeochemistry (y/n)
[6346]20nemotop=y
[5479]21# Optimization mode
22# optmode=prod/dev/debug
23optmode=prod
24# fcm_arch
25fcm_arch=default
26# Default values to be overritten
27parallel=mpi_omp
28export fcm_arch parallel xios
29full_flag=""
30full_nemo=n
31full_inca=""
32full_xios=""
33full_lmdz=""
34full_orch=""
35full_dyna=""
[6648]36full_oasis=n
[6296]37# choose radiative code compilation option
38rad=rrtm
39opt_rad=""
[6544]40#choose chemistry inca configuration
41optchimie=GES
[6462]42
[6638]43# subconfig : which sub-configuration to compile. By default, the full extracted configuration is compiled.
44subconfig=default
45
[6707]46# orchversion tells if ORCHIDEE_2_2 or ORCHIDEE_4 is compiled. This is used as argument and also in the suffix of the executables.
[6462]47orchversion=orch22
[6691]48# orchdriver : Permet to compile the ORCHIDEE offline drivers. This option is activated by setting -orchdriver as argument.
[6705]49# Drivers are now compiled by default
50orchdriver="-driver"
[6462]51
[5479]52# Default netcdf_lib is used for XIOS but can be change by argument
53netcdf_lib=""
54
[6827]55## Arguments in order to compress temporary files after compilation
56tar=no
57comp_tar=yes
58
[5479]59# Output text file for compilation of each component
60datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
61outfile=$submitdir/out_compile_ipslcm7.$datestr
62echo > $outfile
63echo; echo "Text output from compilation will be stored in file out_compile_ipslcm7.$datestr"; echo
64
[6538]65
66rm -f out_compile_ipslcm7
67ln -s ${outfile} out_compile_ipslcm7
68
69
[5479]70#### Read arguments
71# Loop over all arguments to modify default set up
72while (($# > 0)) ; do
73    case $1 in
[6677]74        "-h"|"-help") cat <<end_help
[5479]75########################################################################
76# Usage of the script compile_ipslcm7.sh
77#
78########################################################################
79
80./compile_ipslcm7.sh [Options]
81
[6677]82Description of all options:
[5479]83
[6677]84[-full] Full recompilation of all components. This option can be added to all other options.
85[-cleannemo] Full recompilation of NEMO component only.
86[-regular_latlon yes/no] Activate or deactivate compilation of LMDZ dynamics for regular latlon grid.
87                         Default resol_atm size is used. This option is set in addition to the compilation of the icosahedric grid.
88[-resol_atm XXXxYYYxZZ] Define which regular grid to compile. A default grid is set if this option is not used.
89[-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod.
90[-subconfig X] Set this option if you want to compile a sub-configuration. X can be one of following sub-configurations :
91               ICOLMDZORINCA, ICOLMDZOR, LMDZORINCA, LMDZOR, IPSLCM-reg or IPSLCM
92               By default, all available components are compiled.
[6707]93[-orch4 / -orch22] Choice of ORCHIDEE version. The source code are found in modeles/ORCHIDEE_4 or modeles/ORCHIDEE_2_2
[6677]94                   and a link will be set to the choosen model version. Default version is currently ORCHIDEE_2_2 (-orch22).
[6691]95[-orchdriver]   Activate compilation of orchidee offline drivers
[6827]96[-tar]: option to compress XIOS repository that takes many inodes without compilation
97[-comp_tar]: option to compile and compress XIOS repository if compilation succed
98[-notar]: do not compress XIOS repository
[5479]99
[6827]100
[6677]101Example 1: Default compilation of IPSLCM7
[5479]102./compile_ipslcm7.sh
103
[6677]104Example 2: Default compilation in debug mode
[5479]105./compile_ipslcm7.sh -debug
106
107Example 3: Default compilation with full recompilation of all components. No clean is needed.
108./compile_ipslcm7.sh -full
109
[6677]110Example 4: Compilation in addition of LMDZ in regular lat-lon for a specific resolution :
[6641]111./compile_ipslcm7.sh -resol_atm 144x142x95
[5479]112
[6677]113Example 5: Compilation without regular grid (only icosaedric grid)
114./compile_ipslcm7.sh -regular_latlon no
115
[6707]116Example 5: Compilation of ORCHIDEE_4 version
[6462]117./compile_ipslcm7.sh -orch4
118
[6544]119Example 6: compilation of a specific chemistry for INCA (default is GES)
120./compile_ipslcm7.sh -chimie NMHC_AER_S
121
[6677]122Example 7: Compilation of sub-configuration LMDZOR :
123./compile_ipslcm7.sh -subconfig LMDZOR
124
[6827]125Example 5: Compile without compressing XIOS and LMDZ/libo in tar files
126./compile_ipslcm7.sh -notar
127
[5479]128end_help
129            exit;;
130
131        "-parallel")   parallel=$2 ; shift ; shift ;;
132        "-arch")       fcm_arch="$2" ; shift ; shift ;;
133        "-debug")      optmode=debug ; shift ;;
134        "-dev")        optmode=dev ; shift ;;
135        "-prod")       optmode=prod ; shift ;;
[6677]136        "-regular_latlon")  regular_latlon=$2 ; shift ; shift ;;
137        "-resol_atm")  regular_latlon=y ; resol_atm=$2 ; shift ; shift ;;
[6638]138        "-subconfig")  subconfig=$2 ; shift ; shift ;;
[6649]139        "-full")       full_flag="-full"; full_nemo=y ; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; full_oasis=y ; full_inca="-clean" ; full_dyna="-full" ; shift ;;
[5479]140        "-full_xios")  full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
141        "-full_lmdz")  full_lmdz="-full"  ; shift ;;
142        "-full_orch")  full_orch="-full"  ; shift ;;
143        "-full_nemo")  full_nemo=y ; shift ;;
144        "-full_inca")  full_inca="-clean"; shift ;;
[6648]145        "-full_dyna")  full_dyna="-full" ; shift ;;
146        "-full_oasis") full_oasis=y ; shift ;;
[5479]147        "-cleannemo")  full_nemo=y ; shift ;;
[6296]148        "-rad")        rad=$2; shift ; shift ;;
[6640]149        "-orch22")     orchversion="orch22"; shift ;;
150        "-orch4")      orchversion="orch4"shift ;;
[6691]151        "-orchdriver") orchdriver="-driver"shift ;;
[6544]152        "-chimie")     optchimie=$2; shift ; shift;;
[6827]153        "-tar")             tar=yes ; shift ;;
154        "-comp_tar")        comp_tar=yes ; shift ;;
155        "-notar")           comp_tar=no ; shift ;;
[5479]156        *)             echo "unknown option "$1" , exiting..." ; exit
157    esac
158done
159
[6638]160
161# Define which sub-configuration to compile. By default all extracted source components are compiled.
162source define_config.sh
163
[5479]164echo "Following options are set in current compiling:" >> $outfile
165echo "   regular_latlon=$regular_latlon (if yes, then resol_atm=${resol_atm})" >> $outfile 
[6641]166echo "   resol_atm=${resol_atm}, nemotop=${nemotop}" >> $outfile 
[5479]167echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
[6648]168echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch, full_nemo=$full_nemo, full_dyna=$full_dyna, full_oasis=$full_oasis" >> $outfile 
[6827]169echo "   tar=$tar, comp_tar=$comp_tar" >> $outfile
[6638]170echo "   compinca=$compinca compnemo=$compnemo compoasis=$compoasis compdyna=$compdyna complmdz=y comporch=y compxios=y" >> $outfile
[5479]171echo >> $outfile
[6640]172### Verification of argument
173# Set argorch depeinding on the version of ORCHIDEE. This is argument needed for the compilation of LMDZ to consider coherent interface.
174if [ $orchversion == orch22 ] ; then
175    argorch=orchidee2.1
176elif [ $orchversion == orch4 ] ; then
177    argorch=orchideetrunk
178else
179    echo "ERROR in version of ORCHIDEE. It is only possible to have orch22 or orch4 for now"
180fi
[6638]181
[6827]182# Compress XIOS and LMDZ/libo without compiling if tar=yes
183if [ $tar == yes ] ; then
184    echo "Option tar activated to compress XIOS and LMDZ/libo. No compilation will be done."
185    echo >> $outfile
186    echo "Option tar activated to compress XIOS and LMDZ/libo. No compilation will be done." >> $outfile
187    if [[ -d $modipsl/modeles/XIOS ]] ; then
188        echo " Now tar XIOS repository"
189        echo " Now tar XIOS repository" >> $outfile
190        tar -cf $modipsl/modeles/XIOS.tar $modipsl/modeles/XIOS
191        rm -rf $modipsl/modeles/XIOS
192    else
193        echo " No XIOS repository to compress"
194        echo " No XIOS repository to compress" >> $outfile
195    fi
196
197    if [[ -d $modipsl/modeles/LMDZ/libo ]] ; then
198        echo "Now tar LMDZ/libo repository"
199        echo "Now tar LMDZ/libo repository" >> $outfile
200        tar -cf $modipsl/modeles/LMDZ/libo.tar $modipsl/modeles/LMDZ/libo
201        rm -rf $modipsl/modeles/LMDZ/libo
202    else
203        echo " No LMDZ/libo repository to compress"
204        echo " No LMDZ/libo repository to compress" >> $outfile
205    fi
206
207    echo "END OF SCRIPT"
208    echo "END OF SCRIPT" >> $outfile
209    exit
210fi
211
[5479]212### Read host dependent default values
213### These variables will not be changed if they were set as argument
214###./host.sh $host
215# Later : Following lines should be set in host.sh file
216# begin host.sh
217if [ $fcm_arch == default ] ; then
218    # Find out current host and source specific paths and commands for the host
219    case $( hostname -s ) in
220        jean-zay*)
[6629]221            if [[ $( hostname -s ) != *"pp"* ]] ; then
222                echo "Warning! You MUST compile on jean-zay-pp."
223                echo "EXIT"
224                exit
225            else
226                fcm_arch=X64_JEANZAY
227            fi ;;
[5479]228        irene170|irene171|irene190|irene191|irene192|irene193)
229            fcm_arch=X64_IRENE;;
230        irene172|irene173|irene194|irene195)
231            fcm_arch=X64_IRENE-AMD;;
232        asterix*|obelix*)
233            fcm_arch=ifort_LSCE
234            if [ "${parallel}" == "mpi_omp" ] ; then
235                echo "Warning!! Currently at Obelix hybrid mode is not possible."
236                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
237                echo ""
238                parallel=mpi
239            else
240                echo "You used -parallel" $parallel
241            fi ;;
[6296]242        spirit*)
243            fcm_arch=ifort_MESOIPSL;;
[5479]244        ciclad*|climserv*|loholt*|camelot*)
245            fcm_arch=ifort_CICLAD;;
246        *)
247            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
248            echo Exit now.
249            exit
250    esac
251fi
252
253# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
254# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
255if [ -f ARCH/arch-${fcm_arch}.env ] ; then
256    echo >> $outfile
257    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
[6296]258    echo "Note that this new environement might be kept after compilation."
259    echo "If this is the case, source again your personal environment after compilation."
260    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
261    module list   >> $outfile 2>&1
[6808]262    svn_version=$(module -t list | grep subversion)
[6296]263       
[5479]264    # Make a link to this file, to be used also in config.card
265    rm -f ARCH/arch.env
266    ln -s arch-${fcm_arch}.env ARCH/arch.env
267
268    # Source the file
[6296]269    source ARCH/arch.env   >> $outfile 2>&1
270    if [ X$svn_version != X ] ; then
271        module load ${svn_version}
272    fi
273    echo >> $outfile
274    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
275    module list   >> $outfile 2>&1
[5479]276fi
277
[6462]278
279#### Clean if full_orch
280# If full recompilation of ORCHIDEE then first clean modipsl/lib folder
281if [ X${full_orch} == X"-full" ] ; then
282   rm -f $modipsl/lib/*
283fi
284
[5479]285#### 2 Do the compilation
286## 2.1 Compile ioipsl
287cd $modipsl/modeles/IOIPSL
288echo; echo "NOW COMPILE IOIPSL"
289echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
290
291echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
292     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
293# Test if compiling succeded
294if [[ $? != 0 ]] ; then
295    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
296    exit
297fi
298
[6638]299if [ $compoasis == y ] ; then
[5479]300## 2.2 Compile oasis3-mct
[6648]301if [ $full_oasis == y ] ; then
302    rm -rf $modipsl/oasis3-mct/BLD
303fi
[5479]304cd $modipsl/oasis3-mct/util/make_dir
305echo; echo "NOW COMPILE OASIS3-MCT"
306echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT"   >> $outfile
307cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc
308
309echo make -f TopMakefileOasis3 >> $outfile
310     make -f TopMakefileOasis3 >> $outfile 2>&1
[6686]311if [[ $? != 0 ]] ; then
312    echo "THERE IS A PROBLEM IN OASIS COMPILATION - STOP"
313    exit
314fi
315 
[5479]316
[6638]317else
318echo ; echo No compilation of OASIS
319fi
[5479]320
321## 2.3 Compile xios
[6827]322echo; echo "NOW DECOMPRESS XIOS IF NEEDED"
323# First check if XIOS needs to be decompressed
324# In priority search for modeles/XIOS_${optmode}.tar but if it doesn't exist take
325# the first which is found.
326if [[ -d $modipsl/modeles/XIOS ]] ; then
327    echo "Found XIOS -> no decompress needs to be do";  >> $outfile
328elif [[ -f $modipsl/modeles/XIOS_${optmode}.tar ]]; then
329    echo >> $outfile
330    echo "Found XIOS_${optmode}.tar -> decompress repository" >> $outfile
331    # Do not write "tar -xf ... -C $modipsl/modeles because it's modeles/XIOS that is compressed, not only XIOS/
332    tar -xf $modipsl/modeles/XIOS_${optmode}.tar -C $modipsl/ >> $outfile 2>&1
333elif [[ -f $modipsl/modeles/XIOS_prod.tar ]]; then
334    echo >> $outfile
335    echo "Found XIOS_prod.tar -> decompress repository" >> $outfile
336    tar -xf $modipsl/modeles/XIOS_prod.tar -C $modipsl/ >> $outfile 2>&1
337elif [[ -f $modipsl/modeles/XIOS_debug.tar ]]; then
338    echo >> $outfile
339    echo "Found XIOS_debug.tar -> decompress repository" >> $outfile
340    tar -xf $modipsl/modeles/XIOS_debug.tar -C $modipsl/ >> $outfile 2>&1
341elif [[ -f $modipsl/modeles/XIOS_dev.tar ]]; then
342    echo >> $outfile
343    echo "Found XIOS_dev.tar -> decompress repository" >> $outfile
344    tar -xf $modipsl/modeles/XIOS_dev.tar -C $modipsl/ >> $outfile 2>&1
345elif [[ -f $modipsl/modeles/XIOS.tar ]]; then
346    echo >> $outfile
347    echo "Found XIOS.tar -> decompress repository" >> $outfile
348    tar -xf $modipsl/modeles/XIOS.tar -C $modipsl/ >> $outfile 2>&1
349else
350    echo "XIOS source code was not found. Exit"
351    echo "XIOS source code was not found. Exit" >> $outfile
352    exit
353fi
354
[5479]355cd $modipsl/modeles/XIOS
356echo; echo "NOW COMPILE XIOS"
357echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
[6638]358if [ $compoasis == y ] ; then
359argoasis="--use_oasis oasis3_mct "
360else
361argoasis=" "
362fi
363echo ./make_xios $argoasis --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
364     ./make_xios $argoasis --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
[5479]365# Test if compiling succeded
366if [[ $? != 0 ]] ; then
367    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
368    exit
369fi
370# Move executables to modipsl/bin
371if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
372    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
373else
374    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
375    exit
376fi
377
378
[6462]379## 2.4 Compile ORCHIDEE
380# Choose ORCHIDEE version to compile and create a link to generic folder name ORCHIDEE.
381# This link is needed for the compilation of ICOSA_LMDZ for it to find the orchidee librarie.
382cd $modipsl/modeles
383rm -f ORCHIDEE
384if [ $orchversion == orch22 ] ; then
385    ln -s ORCHIDEE_2_2 ORCHIDEE
386    cd $modipsl/modeles/ORCHIDEE_2_2
387    echo; echo "NOW COMPILE ORCHIDEE_2_2"
388    echo >> $outfile ; echo " NOW COMPILE ORCHIDEE_2_2"   >> $outfile 
389else
[6707]390    ln -s ORCHIDEE_4 ORCHIDEE
391    cd $modipsl/modeles/ORCHIDEE_4
392    echo; echo "NOW COMPILE ORCHIDEE_4 (trunk)"
393    echo >> $outfile ; echo " NOW COMPILE ORCHIDEE_4 (trunk)"   >> $outfile 
[6462]394fi
[5479]395
396# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
397# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
398# to ask question and wait for interactivly answer from the user.
399if [ -f build/fcm.bld.lock ] ; then
400    echo >> $outfile
401    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
402    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
403    echo "           The file will now be removed. "   >> $outfile
404    echo >> $outfile
405    rm -f build/fcm.bld.lock
406fi
407
[6725]408if [ $compoasis == y ] ; then
409    # For this case, XIOS library needs to be linked with OASIS library
410    argoasis="-linkwithoasis"
411else
412    argoasis=""
413fi
414
415echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path ${argoasis} $full_orch $orchdriver >> $outfile 
416        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path ${argoasis} $full_orch $orchdriver >> $outfile 2>&1
[5479]417# Test if compiling finished
418if [[ $? != 0 ]] ; then
419    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
420    exit
421fi
422
[6462]423# Rename exetubles for ORCHIDEE offline driver with suffix version
424cd $modipsl/bin
[6705]425if [ -f orchideedriver ] ; then
426    mv orchideedriver orchideedriver.${orchversion}_$optmode
427    ln -sf orchideedriver.${orchversion}_$optmode orchideedriver_$optmode
428fi
429if [ -f orchidee_ol ] ; then
430    mv orchidee_ol orchidee_ol.${orchversion}_$optmode
431    ln -sf orchidee_ol.${orchversion}_$optmode orchidee_ol_$optmode
432fi
[5479]433
[6639]434## 2.5 Compile NEMO
[6638]435if [ $compnemo == y ] ; then
[6639]436    nemo_root=$modipsl/modeles/NEMO
437    cfg_ref=ORCA2_ICE_PISCES
438    cfg_wrk=ORCA_ICE_TRC
439    addkeys="key_oasis3 key_top key_si3 key_isf"
440    delkeys=""
441   
442    if [ ${nemotop} == n ] ; then
443        cfg_wrk=ORCA_ICE
444        delkeys="key_top"
445    fi
446   
447    if [ ${nemotop} == n ] ; then
448        echo; echo "NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"
449        echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"   >> $outfile
450    else
451        echo; echo "NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"
452        echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"   >> $outfile
453    fi
454   
455    echo >> $outfile ; echo cd $nemo_root  >> $outfile
456    echo >> $outfile ; echo cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.   >> $outfile
457    echo >> $outfile
458   
459    cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.
460   
461    # creation of config
462    echo >> $outfile ; echo cd $nemo_root  >> $outfile
463    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
464    echo >> $outfile
465    cd $nemo_root
466    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0  add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
467   
468   
469    # Copy of specfic source files
470    echo >> $outfile ; echo cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
471    echo >> $outfile
472    cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
473   
474   
475    if [ $full_nemo == y ] ; then
476        # To make a full compilation, first make a clean to remove all files produced during previous compilation
477        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean   >> $outfile
478        echo >> $outfile
479        ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean  >> $outfile 2>&1
480    fi
481    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile
482    echo >> $outfile
483    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile 2>&1
484   
485    echo >> $outfile
486    echo "Move nemo executable to modipsl/bin" >> $outfile
487    echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin   >> $outfile
488    ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin  >> $outfile
489    echo >> $outfile
490   
491    if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then
492        mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${optmode}.exe
493    else
494        echo "ERROR nemo.exe executable does not exist."
495        echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
496        exit
497    fi
498   
[5479]499else
[6639]500    echo ; echo No compilation of NEMO
[5479]501fi
[6346]502
[6639]503##2.6  Compile INCA
[6638]504if [ $compinca == y ] ; then
[6544]505    cd $modipsl/modeles/INCA
[6639]506   
[6544]507    echo; echo "NOW COMPILE INCA ${optchimie}"
[6588]508    echo >> $outfile ; echo " NOW COMPILE INCA ${optchimie}"   >> $outfile 
509   
[6649]510    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_inca  >> $outfile
511    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_inca >> $outfile 2>&1
[6639]512   
[6544]513    # Test if compiling finished
514    if [[ $? != 0 ]] ; then
515        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
516        echo "ALL INFORMATION IN FILE $outfile"
517        exit
518    fi
[6639]519   
[6544]520    echo "Move inca.dat modipsl/bin"
521    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
522        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${optchimie}.dat ;
523    else
524        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
525        echo "ALL INFORMATION IN FILE $outfile"
526        exit   
527    fi
[6639]528   
[6544]529    echo "Move tracer.def to  modipsl/bin"
530    if [[ -f $modipsl/modeles/INCA/tracer.def ]] ;  then
531        mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optchimie}.def ;
532    fi
[6639]533   
[6638]534else
[6639]535    echo ; echo No compilation of INCA
[6638]536fi
[6544]537
538## 2.7 Compile LMDZ
[5479]539cd $modipsl/modeles/LMDZ
[6703]540
[6827]541# First check if LMDZ/libo exist or if it could be decompressed
542# If neither LMDZ/libo or LMDZ/libo_${optmode}.tar exists, nothing is done. It'll be created
543# during the compilation.
544echo; echo "NOW DECOMPRESS LMDZ/libo IF NEEDED"
545if [[ -d $modipsl/modeles/LMDZ/libo ]] ; then
546    echo "Found LMDZ/libo -> no decompress needs to be done"; >> $outfile
547elif [[ -f $modipsl/modeles/LMDZ/libo_${optmode}.tar ]]; then
548    echo "Found LMDZ/libo_${optmode}.tar -> decompress repository"; >> $outfile
549    echo >> $outfile
550    tar -xf $modipsl/modeles/LMDZ/libo_${optmode}.tar -C $modipsl/ >> $outfile 2>&1
551fi
552
553
[6791]554# Temporary use of SOURCES/LMDZ to handle modifications needed by IPSLCM7 for LMDZ 4876
555# To be removed for newer versions of LMDZ
556ln -sf $mysrc_path/LMDZ/phylmd/*.*90  libf/phylmd/.
[6703]557
[5479]558# Compile LMDZ as library to couple to DYNAMICO
[6639]559if [ $compdyna == y ] ; then
560    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
561    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
562   
563   
564    # Check if the compilation of LMDZ was previsouly interupted prematured.
565    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
566    # to ask question and wait for interactivly answer from the user.
567    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
568        echo >> $outfile
569        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
570        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
571        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
572        echo >> $outfile
573        rm -f libf/grid/dimensions.h
574        rm -f .lock
575    fi
576   
577    # Need to define the proper option for radiative code compilation. By default, we use rrtm
578    case $rad in
579        oldrad) opt_rad="" ;;
[6692]580        rrtm)    opt_rad="-rad rrtm" ;;
[6639]581        ecrad)  opt_rad="-rad ecrad" ;;
582        *) echo Only oldrad rrtm ecrad for rad option ; exit
583    esac
584   
585   
586    if [ $compinca == y ] ; then
587        arginca="-chimie INCA "
588    else
589        arginca=" "
590    fi
591   
592    if [ $compoasis == y ] ; then
593        argoasis="-c OMCT "
594    else
595        argoasis=" "
596    fi
[6640]597
598    echo ./makelmdz_fcm -p lmd $argoasis $opt_rad -$optmode -mem -parallel $parallel -libphy -v $argorch $arginca  -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz    >> $outfile 
599    ./makelmdz_fcm -p lmd $argoasis $opt_rad -$optmode -mem -parallel $parallel -libphy -v $argorch $arginca  -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz    >> $outfile 2>&1
[6639]600   
601   
602    # Test if compiling finished
603    if [[ $? != 0 ]] ; then
604        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
605        exit
606    fi
[5479]607fi
608
609
[6544]610## 2.8 Compile DYNAMICO
[6639]611if [ $compdyna == y ] ; then
612    cd $modipsl/modeles/DYNAMICO
613    echo; echo "NOW COMPILE DYNAMICO "
614    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
615   
616    if [ $compoasis == y ] ; then
617        argoasis="-with_oasis "
618    else
619        argoasis=" "
620    fi
621    if [ $compinca == y ] ; then
622        arginca="-with_inca "
623    else
624        arginca=" "
625    fi
626   
627   
[6789]628    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
629    ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
[6639]630    # Test if compiling finished
631    if [[ $? != 0 ]] ; then
632        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
633        exit
634    fi
[6638]635fi
[6639]636   
[6544]637## 2.9 Compile interface ICOSA_LMDZ
[6642]638if [ $compdyna == y ] ; then
[6639]639    cd $modipsl/modeles/ICOSA_LMDZ
640    echo; echo "NOW COMPILE ICOSA_LMDZ "
641    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
642   
643    echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel $argoasis -with_orchidee $arginca -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 
644    ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel $argoasis -with_orchidee $arginca -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 2>&1
645    # Test if compiling finished
646    if [[ $? != 0 ]] ; then
647        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
648        exit
649    fi
650    # Move executables to modipsl/bin
651    if [ -f $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
652        if [ $compinca == y ] ; then
653            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe
654            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
655            cd  $modipsl/bin
656            rm -f icosa_lmdz_${orchversion}_${optmode}.exe
657            ln -s icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe icosa_lmdz_${orchversion}_${optmode}.exe
658        else
659            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}.exe
660        fi
[6638]661    else
[6639]662        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
663        exit
[6638]664    fi
[5479]665fi
666
667
[6544]668## 2.10 Compile LMDZ for regular latlon configuration
[6727]669if [ $regular_latlon = y ] && [ $complmdz = y ] ; then
[5479]670
671    cd $modipsl/modeles/LMDZ
672    # Compile LMDZ regular lat-lon exectuable
673    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
674    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
675    # Check if the compilation of LMDZ was previsouly interupted prematured.
676    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
677    # to ask question and wait for interactivly answer from the user.
678    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
679        echo >> $outfile
680        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
681        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
682        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
683        echo >> $outfile
684        rm -f libf/grid/dimensions.h
685        rm -f .lock
686    fi
[6638]687
[6692]688    # Need to define the proper option for radiative code compilation. By default, we use rrtm
689    case $rad in
690        oldrad) opt_rad="" ;;
691        rrtm)    opt_rad="-rad rrtm" ;;
692        ecrad)  opt_rad="-rad ecrad" ;;
693        *) echo Only oldrad rrtm ecrad for rad option ; exit
694    esac
695   
[6638]696    if [ $compinca == y ] ; then
697        arginca="-chimie INCA"
698    else
699        arginca=""
700    fi
701   
702    if [ $compoasis == y ] ; then
703        argoasis="-c OMCT"
704    else
705        argoasis=""
706    fi
[6640]707    echo ./makelmdz_fcm -d ${resol_atm} $argoasis -p lmd $opt_rad -$optmode -mem -parallel $parallel $arginca  -io xios -v $argorch -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 
708         ./makelmdz_fcm -d ${resol_atm} $argoasis -p lmd $opt_rad -$optmode -mem -parallel $parallel $arginca  -io xios -v $argorch -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 2>&1
[5479]709    # Test if compiling finished
710    if [[ $? != 0 ]] ; then
711        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
712        exit
713    fi
714
[6457]715    # Find executable suffix
716    suffix=_${resol_atm}_phylmd
[6692]717    suffix=${suffix}_${rad} 
[6457]718    if [ $parallel == seq ] || [ $parallel == none ] ; then
[6544]719        suffix=${suffix}_seq_orch_inca.e
[6457]720    else
[6638]721        if [ $compoasis == y ] ; then
722            suffix=${suffix}_para_mem_orch_couple
723        else
724            suffix=${suffix}_para_mem_orch
725        fi
726        if [ $compinca == y ] ; then
727            suffix=${suffix}_inca.e
728        else
729            suffix=${suffix}.e
730        fi
[6457]731    fi
732    echo gcm suffix = $suffix
733   
[6462]734    # Move executables to modipsl/bin folder
[6457]735    echo "Move gcm.e executable to modipsl/bin"
736    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
[6638]737        if [ $compinca == y ] ; then
738            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e
739            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
740            cd $modipsl/bin
741            rm -f gcm_${resol_atm}_${orchversion}_${optmode}.e
742            ln -s gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e gcm_${resol_atm}_${orchversion}_${optmode}.e
743        else
744            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}.e
745        fi
[6457]746    else
747        echo "ERROR gcm${suffix} executable does not exist." 
748        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
749        exit
[6462]750    fi   
751
[6588]752    # Find executable suffix
753    suffix=_${resol_atm}_phylmd
[6692]754    suffix=${suffix}_${rad} 
[6588]755    if [ $parallel == seq ] || [ $parallel == none ] ; then
756        suffix=${suffix}_seq_orch.e
757    else
[6638]758        if [ $compoasis == y ] ; then
759            suffix=${suffix}_para_mem_orch_couple.e
760        else
761            suffix=${suffix}_para_mem_orch.e
762        fi
[6588]763    fi
764    echo ce0l suffix = $suffix
[6638]765
[5479]766    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
[6544]767    cd $modipsl/modeles/LMDZ
[5479]768    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
769    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
770
[6640]771    echo ./makelmdz_fcm -d ${resol_atm} $argoasis -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v $argorch -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
772         ./makelmdz_fcm -d ${resol_atm} $argoasis -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v $argorch -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 2>&1
[5479]773    # Test if compiling finished
774    if [[ $? != 0 ]] ; then
775        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
776        exit
777    fi
[6462]778   
779 
[6457]780    # Move executable ce0l to modipsl/bin folder
781    echo "Move ce0l executable to modipsl/bin"
[5479]782    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
783        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
784    else
785        echo "ERROR ce0l${suffix} executable does not exist." 
786        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
787        exit
788    fi
789fi
790
[6827]791# Compress XIOS and LMDZ/libo
792if [ $comp_tar == yes ] && [ -d $modipsl/modeles/XIOS ] ; then
[6828]793    echo "Option comp_tar activated, now compress XIOS"
794    echo "Option comp_tar activated, now compress XIOS" >> $outfile
[6827]795    tar -cf $modipsl/modeles/XIOS_${optmode}.tar $modipsl/modeles/XIOS
796    rm -rf $modipsl/modeles/XIOS
[6828]797fi
798if [ $comp_tar == yes ] && [ -d $modipsl/modeles/LMDZ/libo ] ; then
799    echo "Option comp_tar activated, now compress LMDZ/libo"
800    echo "Option comp_tar activated, now compress LMDZ/libo" >> $outfile
[6827]801    tar -cf $modipsl/modeles/LMDZ/libo_${optmode}.tar $modipsl/modeles/LMDZ/libo
802    rm -rf $modipsl/modeles/LMDZ/libo
803fi
804
[5479]805echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
806echo ls -lrt modipsl/bin >> $outfile
807ls -lrt $modipsl/bin >> $outfile
808
809echo; echo "ALL COMPILING FINISHED" ; echo
810echo "Executables are found in modipsl/bin"
811echo "Check that executable names correspond with the name set in config.card before launching the job"
812echo ls -lrt modipsl/bin
813ls -lrt $modipsl/bin
814
815date
816
817exit
818
819
Note: See TracBrowser for help on using the repository browser.