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

Last change on this file since 6838 was 6838, checked in by aclsce, 8 weeks ago

Modified IPSLCM7 configuration as follows :

  • added DYNAMICO_XML in DYNAMICO path for xml files
  • removed SOURCES/LMDZ not needed anymore (commited in LMDZ repository)
  • commented creation of file_def_dynamico.xml by using python script (now file_def_dynamico.xml exists in DYNAMICO_XML directory).
  • Property svn:executable set to *
File size: 31.1 KB
Line 
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
13export ROOT=$modipsl/modeles/IOIPSL
14#### Set default options
15# Activate compilation of LMDZ for regular latlon grid without DYNAMICO
16regular_latlon=y
17# Atmospheric resolution for regular grid for LMDZ/ORCHIDEE, if regular_latlon=y
18resol_atm=144x142x79
19# Coupled with ocean biogeochemistry (y/n)
20nemotop=y
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=""
36full_oasis=n
37# choose radiative code compilation option
38rad=rrtm
39opt_rad=""
40#choose chemistry inca configuration
41optchimie=GES
42
43# subconfig : which sub-configuration to compile. By default, the full extracted configuration is compiled.
44subconfig=default
45
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.
47orchversion=orch22
48# orchdriver : Permet to compile the ORCHIDEE offline drivers. This option is activated by setting -orchdriver as argument.
49# Drivers are now compiled by default
50orchdriver="-driver"
51
52# Default netcdf_lib is used for XIOS but can be change by argument
53netcdf_lib=""
54
55## Arguments in order to compress temporary files after compilation
56tar=no
57comp_tar=yes
58
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
65
66rm -f out_compile_ipslcm7
67ln -s ${outfile} out_compile_ipslcm7
68
69
70#### Read arguments
71# Loop over all arguments to modify default set up
72while (($# > 0)) ; do
73    case $1 in
74        "-h"|"-help") cat <<end_help
75########################################################################
76# Usage of the script compile_ipslcm7.sh
77#
78########################################################################
79
80./compile_ipslcm7.sh [Options]
81
82Description of all options:
83
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.
93[-orch4 / -orch22] Choice of ORCHIDEE version. The source code are found in modeles/ORCHIDEE_4 or modeles/ORCHIDEE_2_2
94                   and a link will be set to the choosen model version. Default version is currently ORCHIDEE_2_2 (-orch22).
95[-orchdriver]   Activate compilation of orchidee offline drivers
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
99
100
101Example 1: Default compilation of IPSLCM7
102./compile_ipslcm7.sh
103
104Example 2: Default compilation in debug mode
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
110Example 4: Compilation in addition of LMDZ in regular lat-lon for a specific resolution :
111./compile_ipslcm7.sh -resol_atm 144x142x95
112
113Example 5: Compilation without regular grid (only icosaedric grid)
114./compile_ipslcm7.sh -regular_latlon no
115
116Example 5: Compilation of ORCHIDEE_4 version
117./compile_ipslcm7.sh -orch4
118
119Example 6: compilation of a specific chemistry for INCA (default is GES)
120./compile_ipslcm7.sh -chimie NMHC_AER_S
121
122Example 7: Compilation of sub-configuration LMDZOR :
123./compile_ipslcm7.sh -subconfig LMDZOR
124
125Example 5: Compile without compressing XIOS and LMDZ/libo in tar files
126./compile_ipslcm7.sh -notar
127
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 ;;
136        "-regular_latlon")  regular_latlon=$2 ; shift ; shift ;;
137        "-resol_atm")  regular_latlon=y ; resol_atm=$2 ; shift ; shift ;;
138        "-subconfig")  subconfig=$2 ; shift ; shift ;;
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 ;;
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 ;;
145        "-full_dyna")  full_dyna="-full" ; shift ;;
146        "-full_oasis") full_oasis=y ; shift ;;
147        "-cleannemo")  full_nemo=y ; shift ;;
148        "-rad")        rad=$2; shift ; shift ;;
149        "-orch22")     orchversion="orch22"; shift ;;
150        "-orch4")      orchversion="orch4"shift ;;
151        "-orchdriver") orchdriver="-driver"shift ;;
152        "-chimie")     optchimie=$2; shift ; shift;;
153        "-tar")             tar=yes ; shift ;;
154        "-comp_tar")        comp_tar=yes ; shift ;;
155        "-notar")           comp_tar=no ; shift ;;
156        *)             echo "unknown option "$1" , exiting..." ; exit
157    esac
158done
159
160
161# Define which sub-configuration to compile. By default all extracted source components are compiled.
162source define_config.sh
163
164echo "Following options are set in current compiling:" >> $outfile
165echo "   regular_latlon=$regular_latlon (if yes, then resol_atm=${resol_atm})" >> $outfile 
166echo "   resol_atm=${resol_atm}, nemotop=${nemotop}" >> $outfile 
167echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
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 
169echo "   tar=$tar, comp_tar=$comp_tar" >> $outfile
170echo "   compinca=$compinca compnemo=$compnemo compoasis=$compoasis compdyna=$compdyna complmdz=y comporch=y compxios=y" >> $outfile
171echo >> $outfile
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
181
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
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*)
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 ;;
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 ;;
242        spirit*)
243            fcm_arch=ifort_MESOIPSL;;
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."
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
262    svn_version=$(module -t list | grep subversion)
263       
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
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
276fi
277
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
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
299if [ $compoasis == y ] ; then
300## 2.2 Compile oasis3-mct
301if [ $full_oasis == y ] ; then
302    rm -rf $modipsl/oasis3-mct/BLD
303fi
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
311if [[ $? != 0 ]] ; then
312    echo "THERE IS A PROBLEM IN OASIS COMPILATION - STOP"
313    exit
314fi
315 
316
317else
318echo ; echo No compilation of OASIS
319fi
320
321## 2.3 Compile xios
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
355cd $modipsl/modeles/XIOS
356echo; echo "NOW COMPILE XIOS"
357echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
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
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
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
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 
394fi
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
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
417# Test if compiling finished
418if [[ $? != 0 ]] ; then
419    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
420    exit
421fi
422
423# Rename exetubles for ORCHIDEE offline driver with suffix version
424cd $modipsl/bin
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
433
434## 2.5 Compile NEMO
435if [ $compnemo == y ] ; then
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   
499else
500    echo ; echo No compilation of NEMO
501fi
502
503##2.6  Compile INCA
504if [ $compinca == y ] ; then
505    cd $modipsl/modeles/INCA
506   
507    echo; echo "NOW COMPILE INCA ${optchimie}"
508    echo >> $outfile ; echo " NOW COMPILE INCA ${optchimie}"   >> $outfile 
509   
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
512   
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
519   
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
528   
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
533   
534else
535    echo ; echo No compilation of INCA
536fi
537
538## 2.7 Compile LMDZ
539cd $modipsl/modeles/LMDZ
540
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
554# Compile LMDZ as library to couple to DYNAMICO
555if [ $compdyna == y ] ; then
556    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
557    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
558   
559   
560    # Check if the compilation of LMDZ was previsouly interupted prematured.
561    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
562    # to ask question and wait for interactivly answer from the user.
563    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
564        echo >> $outfile
565        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
566        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
567        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
568        echo >> $outfile
569        rm -f libf/grid/dimensions.h
570        rm -f .lock
571    fi
572   
573    # Need to define the proper option for radiative code compilation. By default, we use rrtm
574    case $rad in
575        oldrad) opt_rad="" ;;
576        rrtm)    opt_rad="-rad rrtm" ;;
577        ecrad)  opt_rad="-rad ecrad" ;;
578        *) echo Only oldrad rrtm ecrad for rad option ; exit
579    esac
580   
581   
582    if [ $compinca == y ] ; then
583        arginca="-chimie INCA "
584    else
585        arginca=" "
586    fi
587   
588    if [ $compoasis == y ] ; then
589        argoasis="-c OMCT "
590    else
591        argoasis=" "
592    fi
593
594    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 
595    ./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
596   
597   
598    # Test if compiling finished
599    if [[ $? != 0 ]] ; then
600        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
601        exit
602    fi
603fi
604
605
606## 2.8 Compile DYNAMICO
607if [ $compdyna == y ] ; then
608    cd $modipsl/modeles/DYNAMICO
609    echo; echo "NOW COMPILE DYNAMICO "
610    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
611   
612    if [ $compoasis == y ] ; then
613        argoasis="-with_oasis "
614    else
615        argoasis=" "
616    fi
617    if [ $compinca == y ] ; then
618        arginca="-with_inca "
619    else
620        arginca=" "
621    fi
622   
623   
624    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
625    ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
626    # Test if compiling finished
627    if [[ $? != 0 ]] ; then
628        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
629        exit
630    fi
631fi
632   
633## 2.9 Compile interface ICOSA_LMDZ
634if [ $compdyna == y ] ; then
635    cd $modipsl/modeles/ICOSA_LMDZ
636    echo; echo "NOW COMPILE ICOSA_LMDZ "
637    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
638   
639    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 
640    ./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
641    # Test if compiling finished
642    if [[ $? != 0 ]] ; then
643        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
644        exit
645    fi
646    # Move executables to modipsl/bin
647    if [ -f $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
648        if [ $compinca == y ] ; then
649            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe
650            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
651            cd  $modipsl/bin
652            rm -f icosa_lmdz_${orchversion}_${optmode}.exe
653            ln -s icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe icosa_lmdz_${orchversion}_${optmode}.exe
654        else
655            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}.exe
656        fi
657    else
658        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
659        exit
660    fi
661fi
662
663
664## 2.10 Compile LMDZ for regular latlon configuration
665if [ $regular_latlon = y ] && [ $complmdz = y ] ; then
666
667    cd $modipsl/modeles/LMDZ
668    # Compile LMDZ regular lat-lon exectuable
669    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
670    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
671    # Check if the compilation of LMDZ was previsouly interupted prematured.
672    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
673    # to ask question and wait for interactivly answer from the user.
674    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
675        echo >> $outfile
676        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
677        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
678        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
679        echo >> $outfile
680        rm -f libf/grid/dimensions.h
681        rm -f .lock
682    fi
683
684    # Need to define the proper option for radiative code compilation. By default, we use rrtm
685    case $rad in
686        oldrad) opt_rad="" ;;
687        rrtm)    opt_rad="-rad rrtm" ;;
688        ecrad)  opt_rad="-rad ecrad" ;;
689        *) echo Only oldrad rrtm ecrad for rad option ; exit
690    esac
691   
692    if [ $compinca == y ] ; then
693        arginca="-chimie INCA"
694    else
695        arginca=""
696    fi
697   
698    if [ $compoasis == y ] ; then
699        argoasis="-c OMCT"
700    else
701        argoasis=""
702    fi
703    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 
704         ./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
705    # Test if compiling finished
706    if [[ $? != 0 ]] ; then
707        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
708        exit
709    fi
710
711    # Find executable suffix
712    suffix=_${resol_atm}_phylmd
713    suffix=${suffix}_${rad} 
714    if [ $parallel == seq ] || [ $parallel == none ] ; then
715        suffix=${suffix}_seq_orch_inca.e
716    else
717        if [ $compoasis == y ] ; then
718            suffix=${suffix}_para_mem_orch_couple
719        else
720            suffix=${suffix}_para_mem_orch
721        fi
722        if [ $compinca == y ] ; then
723            suffix=${suffix}_inca.e
724        else
725            suffix=${suffix}.e
726        fi
727    fi
728    echo gcm suffix = $suffix
729   
730    # Move executables to modipsl/bin folder
731    echo "Move gcm.e executable to modipsl/bin"
732    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
733        if [ $compinca == y ] ; then
734            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e
735            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
736            cd $modipsl/bin
737            rm -f gcm_${resol_atm}_${orchversion}_${optmode}.e
738            ln -s gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e gcm_${resol_atm}_${orchversion}_${optmode}.e
739        else
740            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}.e
741        fi
742    else
743        echo "ERROR gcm${suffix} executable does not exist." 
744        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
745        exit
746    fi   
747
748    # Find executable suffix
749    suffix=_${resol_atm}_phylmd
750    suffix=${suffix}_${rad} 
751    if [ $parallel == seq ] || [ $parallel == none ] ; then
752        suffix=${suffix}_seq_orch.e
753    else
754        if [ $compoasis == y ] ; then
755            suffix=${suffix}_para_mem_orch_couple.e
756        else
757            suffix=${suffix}_para_mem_orch.e
758        fi
759    fi
760    echo ce0l suffix = $suffix
761
762    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
763    cd $modipsl/modeles/LMDZ
764    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
765    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
766
767    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 
768         ./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
769    # Test if compiling finished
770    if [[ $? != 0 ]] ; then
771        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
772        exit
773    fi
774   
775 
776    # Move executable ce0l to modipsl/bin folder
777    echo "Move ce0l executable to modipsl/bin"
778    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
779        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
780    else
781        echo "ERROR ce0l${suffix} executable does not exist." 
782        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
783        exit
784    fi
785fi
786
787# Compress XIOS and LMDZ/libo
788if [ $comp_tar == yes ] && [ -d $modipsl/modeles/XIOS ] ; then
789    echo "Option comp_tar activated, now compress XIOS"
790    echo "Option comp_tar activated, now compress XIOS" >> $outfile
791    tar -cf $modipsl/modeles/XIOS_${optmode}.tar $modipsl/modeles/XIOS
792    rm -rf $modipsl/modeles/XIOS
793fi
794if [ $comp_tar == yes ] && [ -d $modipsl/modeles/LMDZ/libo ] ; then
795    echo "Option comp_tar activated, now compress LMDZ/libo"
796    echo "Option comp_tar activated, now compress LMDZ/libo" >> $outfile
797    tar -cf $modipsl/modeles/LMDZ/libo_${optmode}.tar $modipsl/modeles/LMDZ/libo
798    rm -rf $modipsl/modeles/LMDZ/libo
799fi
800
801echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
802echo ls -lrt modipsl/bin >> $outfile
803ls -lrt $modipsl/bin >> $outfile
804
805echo; echo "ALL COMPILING FINISHED" ; echo
806echo "Executables are found in modipsl/bin"
807echo "Check that executable names correspond with the name set in config.card before launching the job"
808echo ls -lrt modipsl/bin
809ls -lrt $modipsl/bin
810
811date
812
813exit
814
815
Note: See TracBrowser for help on using the repository browser.