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

Last change on this file was 6886, checked in by cetlod, 7 days ago

Being able to compile NEMO in debug mode without changing arch file

  • Property svn:executable set to *
File size: 31.8 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=n
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/y/no/n] 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 4b: Add compilation of LMDZ in regular grid with default resolution.
114./compile_ipslcm7.sh -regular_latlon yes
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        cd $modipsl/modeles
191        tar -cf XIOS.tar XIOS
192        rm -rf XIOS
193    else
194        echo " No XIOS repository to compress"
195        echo " No XIOS repository to compress" >> $outfile
196    fi
197
198    if [[ -d $modipsl/modeles/LMDZ/libo ]] ; then
199        echo "Now tar LMDZ/libo repository"
200        echo "Now tar LMDZ/libo repository" >> $outfile
201        cd $modipsl/modeles/LMDZ
202        tar -cf libo.tar libo
203        rm -rf libo
204    else
205        echo " No LMDZ/libo repository to compress"
206        echo " No LMDZ/libo repository to compress" >> $outfile
207    fi
208
209    echo "END OF SCRIPT"
210    echo "END OF SCRIPT" >> $outfile
211    exit
212fi
213
214### Read host dependent default values
215### These variables will not be changed if they were set as argument
216###./host.sh $host
217# Later : Following lines should be set in host.sh file
218# begin host.sh
219if [ $fcm_arch == default ] ; then
220    # Find out current host and source specific paths and commands for the host
221    case $( hostname -s ) in
222        jean-zay*)
223            if [[ $( hostname -s ) != *"pp"* ]] ; then
224                echo "Warning! You MUST compile on jean-zay-pp."
225                echo "EXIT"
226                exit
227            else
228                fcm_arch=X64_JEANZAY
229            fi ;;
230        irene170|irene171|irene190|irene191|irene192|irene193)
231            fcm_arch=X64_IRENE;;
232        irene172|irene173|irene194|irene195)
233            fcm_arch=X64_IRENE-AMD;;
234        asterix*|obelix*)
235            fcm_arch=ifort_LSCE
236            if [ "${parallel}" == "mpi_omp" ] ; then
237                echo "Warning!! Currently at Obelix hybrid mode is not possible."
238                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
239                echo ""
240                parallel=mpi
241            else
242                echo "You used -parallel" $parallel
243            fi ;;
244        spirit*)
245            fcm_arch=ifort_MESOIPSL;;
246        ciclad*|climserv*|loholt*|camelot*)
247            fcm_arch=ifort_CICLAD;;
248        *)
249            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
250            echo Exit now.
251            exit
252    esac
253fi
254
255# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
256# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
257if [ -f ARCH/arch-${fcm_arch}.env ] ; then
258    echo >> $outfile
259    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
260    echo "Note that this new environement might be kept after compilation."
261    echo "If this is the case, source again your personal environment after compilation."
262    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
263    module list   >> $outfile 2>&1
264    svn_version=$(module -t list | grep subversion)
265       
266    # Make a link to this file, to be used also in config.card
267    rm -f ARCH/arch.env
268    ln -s arch-${fcm_arch}.env ARCH/arch.env
269
270    # Source the file
271    source ARCH/arch.env   >> $outfile 2>&1
272    if [ X$svn_version != X ] ; then
273        module load ${svn_version}
274    fi
275    echo >> $outfile
276    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
277    module list   >> $outfile 2>&1
278fi
279
280
281#### Clean if full_orch
282# If full recompilation of ORCHIDEE then first clean modipsl/lib folder
283if [ X${full_orch} == X"-full" ] ; then
284   rm -f $modipsl/lib/*
285fi
286
287#### 2 Do the compilation
288## 2.1 Compile ioipsl
289cd $modipsl/modeles/IOIPSL
290echo; echo "NOW COMPILE IOIPSL"
291echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
292
293echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
294     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
295# Test if compiling succeded
296if [[ $? != 0 ]] ; then
297    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
298    exit
299fi
300
301if [ $compoasis == y ] ; then
302## 2.2 Compile oasis3-mct
303if [ $full_oasis == y ] ; then
304    rm -rf $modipsl/oasis3-mct/BLD
305fi
306cd $modipsl/oasis3-mct/util/make_dir
307echo; echo "NOW COMPILE OASIS3-MCT"
308echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT"   >> $outfile
309cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc
310
311echo make -f TopMakefileOasis3 >> $outfile
312     make -f TopMakefileOasis3 >> $outfile 2>&1
313if [[ $? != 0 ]] ; then
314    echo "THERE IS A PROBLEM IN OASIS COMPILATION - STOP"
315    exit
316fi
317 
318
319else
320echo ; echo No compilation of OASIS
321fi
322
323## 2.3 Compile xios
324cd $modipsl/modeles
325echo; echo "NOW DECOMPRESS XIOS IF NEEDED"
326# First check if XIOS needs to be decompressed
327# In priority search for modeles/XIOS_${optmode}.tar but if it doesn't exist take
328# the first which is found.
329if [[ -d $modipsl/modeles/XIOS ]] ; then
330    echo "Found XIOS -> no decompress needs to be do";  >> $outfile
331elif [[ -f $modipsl/modeles/XIOS_${optmode}.tar ]]; then
332    echo >> $outfile
333    echo "Found XIOS_${optmode}.tar -> decompress repository" >> $outfile
334    tar -xf XIOS_${optmode}.tar >> $outfile 2>&1
335elif [[ -f $modipsl/modeles/XIOS_prod.tar ]]; then
336    echo >> $outfile
337    echo "Found XIOS_prod.tar -> decompress repository" >> $outfile
338    tar -xf $modipsl/modeles/XIOS_prod.tar >> $outfile 2>&1
339elif [[ -f $modipsl/modeles/XIOS_debug.tar ]]; then
340    echo >> $outfile
341    echo "Found XIOS_debug.tar -> decompress repository" >> $outfile
342    tar -xf $modipsl/modeles/XIOS_debug.tar >> $outfile 2>&1
343elif [[ -f $modipsl/modeles/XIOS_dev.tar ]]; then
344    echo >> $outfile
345    echo "Found XIOS_dev.tar -> decompress repository" >> $outfile
346    tar -xf $modipsl/modeles/XIOS_dev.tar >> $outfile 2>&1
347elif [[ -f $modipsl/modeles/XIOS.tar ]]; then
348    echo >> $outfile
349    echo "Found XIOS.tar -> decompress repository" >> $outfile
350    tar -xf $modipsl/modeles/XIOS.tar >> $outfile 2>&1
351else
352    echo "XIOS source code was not found. Exit"
353    echo "XIOS source code was not found. Exit" >> $outfile
354    exit
355fi
356
357cd $modipsl/modeles/XIOS
358echo; echo "NOW COMPILE XIOS"
359echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
360if [ $compoasis == y ] ; then
361argoasis="--use_oasis oasis3_mct "
362else
363argoasis=" "
364fi
365echo ./make_xios $argoasis --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
366     ./make_xios $argoasis --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
367# Test if compiling succeded
368if [[ $? != 0 ]] ; then
369    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
370    exit
371fi
372# Move executables to modipsl/bin
373if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
374    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
375else
376    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
377    exit
378fi
379
380
381## 2.4 Compile ORCHIDEE
382# Choose ORCHIDEE version to compile and create a link to generic folder name ORCHIDEE.
383# This link is needed for the compilation of ICOSA_LMDZ for it to find the orchidee librarie.
384cd $modipsl/modeles
385rm -f ORCHIDEE
386if [ $orchversion == orch22 ] ; then
387    ln -s ORCHIDEE_2_2 ORCHIDEE
388    cd $modipsl/modeles/ORCHIDEE_2_2
389    echo; echo "NOW COMPILE ORCHIDEE_2_2"
390    echo >> $outfile ; echo " NOW COMPILE ORCHIDEE_2_2"   >> $outfile 
391else
392    ln -s ORCHIDEE_4 ORCHIDEE
393    cd $modipsl/modeles/ORCHIDEE_4
394    echo; echo "NOW COMPILE ORCHIDEE_4 (trunk)"
395    echo >> $outfile ; echo " NOW COMPILE ORCHIDEE_4 (trunk)"   >> $outfile 
396fi
397
398# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
399# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
400# to ask question and wait for interactivly answer from the user.
401if [ -f build/fcm.bld.lock ] ; then
402    echo >> $outfile
403    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
404    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
405    echo "           The file will now be removed. "   >> $outfile
406    echo >> $outfile
407    rm -f build/fcm.bld.lock
408fi
409
410if [ $compoasis == y ] ; then
411    # For this case, XIOS library needs to be linked with OASIS library
412    argoasis="-linkwithoasis"
413else
414    argoasis=""
415fi
416
417echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path ${argoasis} $full_orch $orchdriver >> $outfile 
418        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path ${argoasis} $full_orch $orchdriver >> $outfile 2>&1
419# Test if compiling finished
420if [[ $? != 0 ]] ; then
421    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
422    exit
423fi
424
425# Rename exetubles for ORCHIDEE offline driver with suffix version
426cd $modipsl/bin
427if [ -f orchideedriver ] ; then
428    mv orchideedriver orchideedriver.${orchversion}_$optmode
429    ln -sf orchideedriver.${orchversion}_$optmode orchideedriver_$optmode
430fi
431if [ -f orchidee_ol ] ; then
432    mv orchidee_ol orchidee_ol.${orchversion}_$optmode
433    ln -sf orchidee_ol.${orchversion}_$optmode orchidee_ol_$optmode
434fi
435
436## 2.5 Compile NEMO
437if [ $compnemo == y ] ; then
438    nemo_root=$modipsl/modeles/NEMO
439    cfg_ref=ORCA2_ICE_PISCES
440    cfg_wrk=ORCA_ICE_TRC
441    addkeys="key_oasis3 key_top key_si3 key_isf"
442    delkeys=""
443   
444    if [ ${nemotop} == n ] ; then
445        cfg_wrk=ORCA_ICE
446        delkeys="key_top"
447    fi
448   
449    if [ ${nemotop} == n ] ; then
450        echo; echo "NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"
451        echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"   >> $outfile
452    else
453        echo; echo "NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"
454        echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"   >> $outfile
455    fi
456
457    # Compilation management
458    # Nemo debug ?
459    cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm   $mysrc_path/NEMO/arch-nemo.fcm
460    if [ $optmode == debug ] ; then
461       if (! grep -q "^%DEBUG_FCFLAGS"  $mysrc_path/NEMO/arch-nemo.fcm); then
462          echo "ERROR: You must defined '%DEBUG_FCFLAGS' in your arch file if you want to compile Nemo in debug mode using '-d' option"
463          exit 1
464       fi
465       # duplicate the lines starting with %DEBUG_XXX and replace, in the duplicated line, %DEBUG_XXX by %XXX
466       sed -i'' -e "/^%DEBUG_/{p;s/^%DEBUG_\([^ ]*\)/%\1/;}" $mysrc_path/NEMO/arch-nemo.fcm
467    else
468       if (! grep -q "^%PROD_FCFLAGS" $mysrc_path/NEMO/arch-nemo.fcm ); then
469          echo "WARNING: '%PROD_FCFLAGS' not defined in your arch file, makenemo will use '%FCFLAGS' instead"
470       fi
471       # duplicate the lines starting with %PROD_XXX and replace, in the duplicated line, %PROD_XXX by %XXX
472      sed -i'' -e "/^%PROD_/{p;s/^%PROD_\([^ ]*\)/%\1/;}" $mysrc_path/NEMO/arch-nemo.fcm
473    fi
474
475    echo >> $outfile ; echo cd $nemo_root  >> $outfile
476    echo >> $outfile ; echo cp $mysrc_path/NEMO/arch-nemo.fcm arch/CNRS/arch-${fcm_arch}.fcm   >> $outfile
477    echo >> $outfile
478
479    cd $nemo_root ; mv $mysrc_path/NEMO/arch-nemo.fcm   arch/CNRS/arch-${fcm_arch}.fcm
480
481    # creation of config
482    echo >> $outfile ; echo cd $nemo_root  >> $outfile
483    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
484    echo >> $outfile
485    cd $nemo_root
486    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0  add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
487   
488   
489    # Copy of specfic source files
490    echo >> $outfile ; echo cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
491    echo >> $outfile
492    cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
493   
494   
495    if [ $full_nemo == y ] ; then
496        # To make a full compilation, first make a clean to remove all files produced during previous compilation
497        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean   >> $outfile
498        echo >> $outfile
499        ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean  >> $outfile 2>&1
500    fi
501    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile
502    echo >> $outfile
503    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile 2>&1
504   
505    echo >> $outfile
506    echo "Move nemo executable to modipsl/bin" >> $outfile
507    echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin   >> $outfile
508    ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin  >> $outfile
509    echo >> $outfile
510   
511    if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then
512        mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${optmode}.exe
513    else
514        echo "ERROR nemo.exe executable does not exist."
515        echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
516        exit
517    fi
518   
519else
520    echo ; echo No compilation of NEMO
521fi
522
523##2.6  Compile INCA
524if [ $compinca == y ] ; then
525    cd $modipsl/modeles/INCA
526   
527    echo; echo "NOW COMPILE INCA ${optchimie}"
528    echo >> $outfile ; echo " NOW COMPILE INCA ${optchimie}"   >> $outfile 
529   
530    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_inca  >> $outfile
531    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_inca >> $outfile 2>&1
532   
533    # Test if compiling finished
534    if [[ $? != 0 ]] ; then
535        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
536        echo "ALL INFORMATION IN FILE $outfile"
537        exit
538    fi
539   
540    echo "Move inca.dat modipsl/bin"
541    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
542        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${optchimie}.dat ;
543    else
544        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
545        echo "ALL INFORMATION IN FILE $outfile"
546        exit   
547    fi
548   
549    echo "Move tracer.def to  modipsl/bin"
550    if [[ -f $modipsl/modeles/INCA/tracer.def ]] ;  then
551        mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optchimie}.def ;
552    fi
553   
554else
555    echo ; echo No compilation of INCA
556fi
557
558## 2.7 Compile LMDZ
559
560# First check if LMDZ/libo exist or if it could be decompressed
561# If neither LMDZ/libo or LMDZ/libo_${optmode}.tar exists, nothing is done. It'll be created
562# during the compilation.
563echo; echo "NOW DECOMPRESS LMDZ/libo IF NEEDED"
564if [[ -d $modipsl/modeles/LMDZ/libo ]] ; then
565    echo "Found LMDZ/libo -> no decompress needs to be done"; >> $outfile
566elif [[ -f $modipsl/modeles/LMDZ/libo_${optmode}.tar ]]; then
567    echo "Found LMDZ/libo_${optmode}.tar -> decompress repository"; >> $outfile
568    echo >> $outfile
569    cd $modipsl/modeles/LMDZ
570    tar -xf libo_${optmode}.tar >> $outfile 2>&1
571fi
572
573
574# Compile LMDZ as library to couple to DYNAMICO
575if [ $compdyna == y ] ; then
576    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
577    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
578    cd $modipsl/modeles/LMDZ   
579   
580    # Check if the compilation of LMDZ was previsouly interupted prematured.
581    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
582    # to ask question and wait for interactivly answer from the user.
583    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
584        echo >> $outfile
585        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
586        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
587        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
588        echo >> $outfile
589        rm -f libf/grid/dimensions.h
590        rm -f .lock
591    fi
592   
593    # Need to define the proper option for radiative code compilation. By default, we use rrtm
594    case $rad in
595        oldrad) opt_rad="" ;;
596        rrtm)    opt_rad="-rad rrtm" ;;
597        ecrad)  opt_rad="-rad ecrad" ;;
598        *) echo Only oldrad rrtm ecrad for rad option ; exit
599    esac
600   
601   
602    if [ $compinca == y ] ; then
603        arginca="-chimie INCA "
604    else
605        arginca=" "
606    fi
607   
608    if [ $compoasis == y ] ; then
609        argoasis="-c OMCT "
610    else
611        argoasis=" "
612    fi
613
614    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 
615    ./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
616   
617   
618    # Test if compiling finished
619    if [[ $? != 0 ]] ; then
620        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
621        exit
622    fi
623fi
624
625
626## 2.8 Compile DYNAMICO
627if [ $compdyna == y ] ; then
628    cd $modipsl/modeles/DYNAMICO
629    echo; echo "NOW COMPILE DYNAMICO "
630    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
631   
632    if [ $compoasis == y ] ; then
633        argoasis="-with_oasis "
634    else
635        argoasis=" "
636    fi
637    if [ $compinca == y ] ; then
638        arginca="-with_inca "
639    else
640        arginca=" "
641    fi
642   
643   
644    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
645    ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
646    # Test if compiling finished
647    if [[ $? != 0 ]] ; then
648        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
649        exit
650    fi
651fi
652   
653## 2.9 Compile interface ICOSA_LMDZ
654if [ $compdyna == y ] ; then
655    cd $modipsl/modeles/ICOSA_LMDZ
656    echo; echo "NOW COMPILE ICOSA_LMDZ "
657    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
658   
659    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 
660    ./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
661    # Test if compiling finished
662    if [[ $? != 0 ]] ; then
663        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
664        exit
665    fi
666    # Move executables to modipsl/bin
667    if [ -f $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
668        if [ $compinca == y ] ; then
669            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe
670            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
671            cd  $modipsl/bin
672            rm -f icosa_lmdz_${orchversion}_${optmode}.exe
673            ln -s icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe icosa_lmdz_${orchversion}_${optmode}.exe
674        else
675            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}.exe
676        fi
677    else
678        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
679        exit
680    fi
681fi
682
683
684## 2.10 Compile LMDZ for regular latlon configuration
685if [ $regular_latlon = y ] && [ $complmdz = y ] ; then
686
687    cd $modipsl/modeles/LMDZ
688
689    # Compile LMDZ regular lat-lon exectuable
690    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
691    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
692    # Check if the compilation of LMDZ was previsouly interupted prematured.
693    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
694    # to ask question and wait for interactivly answer from the user.
695    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
696        echo >> $outfile
697        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
698        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
699        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
700        echo >> $outfile
701        rm -f libf/grid/dimensions.h
702        rm -f .lock
703    fi
704
705    # Need to define the proper option for radiative code compilation. By default, we use rrtm
706    case $rad in
707        oldrad) opt_rad="" ;;
708        rrtm)    opt_rad="-rad rrtm" ;;
709        ecrad)  opt_rad="-rad ecrad" ;;
710        *) echo Only oldrad rrtm ecrad for rad option ; exit
711    esac
712   
713    if [ $compinca == y ] ; then
714        arginca="-chimie INCA"
715    else
716        arginca=""
717    fi
718   
719    if [ $compoasis == y ] ; then
720        argoasis="-c OMCT"
721    else
722        argoasis=""
723    fi
724    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 
725         ./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
726    # Test if compiling finished
727    if [[ $? != 0 ]] ; then
728        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
729        exit
730    fi
731
732    # Find executable suffix
733    suffix=_${resol_atm}_phylmd
734    suffix=${suffix}_${rad} 
735    if [ $parallel == seq ] || [ $parallel == none ] ; then
736        suffix=${suffix}_seq_orch_inca.e
737    else
738        if [ $compoasis == y ] ; then
739            suffix=${suffix}_para_mem_orch_couple
740        else
741            suffix=${suffix}_para_mem_orch
742        fi
743        if [ $compinca == y ] ; then
744            suffix=${suffix}_inca.e
745        else
746            suffix=${suffix}.e
747        fi
748    fi
749    echo gcm suffix = $suffix
750   
751    # Move executables to modipsl/bin folder
752    echo "Move gcm.e executable to modipsl/bin"
753    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
754        if [ $compinca == y ] ; then
755            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e
756            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
757            cd $modipsl/bin
758            rm -f gcm_${resol_atm}_${orchversion}_${optmode}.e
759            ln -s gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e gcm_${resol_atm}_${orchversion}_${optmode}.e
760        else
761            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}.e
762        fi
763    else
764        echo "ERROR gcm${suffix} executable does not exist." 
765        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
766        exit
767    fi   
768
769    # Find executable suffix
770    suffix=_${resol_atm}_phylmd
771    suffix=${suffix}_${rad} 
772    if [ $parallel == seq ] || [ $parallel == none ] ; then
773        suffix=${suffix}_seq_orch.e
774    else
775        if [ $compoasis == y ] ; then
776            suffix=${suffix}_para_mem_orch_couple.e
777        else
778            suffix=${suffix}_para_mem_orch.e
779        fi
780    fi
781    echo ce0l suffix = $suffix
782
783    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
784    cd $modipsl/modeles/LMDZ
785    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
786    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
787
788    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 
789         ./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
790    # Test if compiling finished
791    if [[ $? != 0 ]] ; then
792        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
793        exit
794    fi
795   
796 
797    # Move executable ce0l to modipsl/bin folder
798    echo "Move ce0l executable to modipsl/bin"
799    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
800        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
801    else
802        echo "ERROR ce0l${suffix} executable does not exist." 
803        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
804        exit
805    fi
806fi
807
808# Compress XIOS and LMDZ/libo
809if [ $comp_tar == yes ] && [ -d $modipsl/modeles/XIOS ] ; then
810    echo "Option comp_tar activated, now compress XIOS"
811    echo "Option comp_tar activated, now compress XIOS" >> $outfile
812    cd $modipsl/modeles
813    tar -cf XIOS_${optmode}.tar XIOS
814    rm -rf XIOS
815fi
816
817if [ $comp_tar == yes ] && [ -d $modipsl/modeles/LMDZ/libo ] ; then
818    echo "Option comp_tar activated, now compress LMDZ/libo"
819    echo "Option comp_tar activated, now compress LMDZ/libo" >> $outfile
820    cd $modipsl/modeles/LMDZ
821    tar -cf libo_${optmode}.tar libo
822    rm -rf libo
823fi
824 
825echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
826echo ls -lrt modipsl/bin >> $outfile
827ls -lrt $modipsl/bin >> $outfile
828
829echo; echo "ALL COMPILING FINISHED" ; echo
830echo "Executables are found in modipsl/bin"
831echo "Check that executable names correspond with the name set in config.card before launching the job"
832echo ls -lrt modipsl/bin
833ls -lrt $modipsl/bin
834
835date
836
837exit
838
839
Note: See TracBrowser for help on using the repository browser.