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

Last change on this file since 6840 was 6840, checked in by jgipsl, 5 months ago

Enhencement on compression option by tar. Now do not keep the modeles folder in the tar file. Done by Karine Laurent.

  • Property svn:executable set to *
File size: 30.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=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        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    echo >> $outfile ; echo cd $nemo_root  >> $outfile
458    echo >> $outfile ; echo cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.   >> $outfile
459    echo >> $outfile
460   
461    cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.
462   
463    # creation of config
464    echo >> $outfile ; echo cd $nemo_root  >> $outfile
465    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
466    echo >> $outfile
467    cd $nemo_root
468    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0  add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
469   
470   
471    # Copy of specfic source files
472    echo >> $outfile ; echo cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
473    echo >> $outfile
474    cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
475   
476   
477    if [ $full_nemo == y ] ; then
478        # To make a full compilation, first make a clean to remove all files produced during previous compilation
479        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean   >> $outfile
480        echo >> $outfile
481        ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean  >> $outfile 2>&1
482    fi
483    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile
484    echo >> $outfile
485    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile 2>&1
486   
487    echo >> $outfile
488    echo "Move nemo executable to modipsl/bin" >> $outfile
489    echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin   >> $outfile
490    ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin  >> $outfile
491    echo >> $outfile
492   
493    if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then
494        mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${optmode}.exe
495    else
496        echo "ERROR nemo.exe executable does not exist."
497        echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
498        exit
499    fi
500   
501else
502    echo ; echo No compilation of NEMO
503fi
504
505##2.6  Compile INCA
506if [ $compinca == y ] ; then
507    cd $modipsl/modeles/INCA
508   
509    echo; echo "NOW COMPILE INCA ${optchimie}"
510    echo >> $outfile ; echo " NOW COMPILE INCA ${optchimie}"   >> $outfile 
511   
512    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_inca  >> $outfile
513    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_inca >> $outfile 2>&1
514   
515    # Test if compiling finished
516    if [[ $? != 0 ]] ; then
517        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
518        echo "ALL INFORMATION IN FILE $outfile"
519        exit
520    fi
521   
522    echo "Move inca.dat modipsl/bin"
523    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
524        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${optchimie}.dat ;
525    else
526        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
527        echo "ALL INFORMATION IN FILE $outfile"
528        exit   
529    fi
530   
531    echo "Move tracer.def to  modipsl/bin"
532    if [[ -f $modipsl/modeles/INCA/tracer.def ]] ;  then
533        mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optchimie}.def ;
534    fi
535   
536else
537    echo ; echo No compilation of INCA
538fi
539
540## 2.7 Compile LMDZ
541
542# First check if LMDZ/libo exist or if it could be decompressed
543# If neither LMDZ/libo or LMDZ/libo_${optmode}.tar exists, nothing is done. It'll be created
544# during the compilation.
545echo; echo "NOW DECOMPRESS LMDZ/libo IF NEEDED"
546if [[ -d $modipsl/modeles/LMDZ/libo ]] ; then
547    echo "Found LMDZ/libo -> no decompress needs to be done"; >> $outfile
548elif [[ -f $modipsl/modeles/LMDZ/libo_${optmode}.tar ]]; then
549    echo "Found LMDZ/libo_${optmode}.tar -> decompress repository"; >> $outfile
550    echo >> $outfile
551    cd $modipsl/modeles/LMDZ
552    tar -xf libo_${optmode}.tar >> $outfile 2>&1
553fi
554
555
556# Compile LMDZ as library to couple to DYNAMICO
557if [ $compdyna == y ] ; then
558    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
559    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
560    cd $modipsl/modeles/LMDZ   
561   
562    # Check if the compilation of LMDZ was previsouly interupted prematured.
563    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
564    # to ask question and wait for interactivly answer from the user.
565    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
566        echo >> $outfile
567        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
568        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
569        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
570        echo >> $outfile
571        rm -f libf/grid/dimensions.h
572        rm -f .lock
573    fi
574   
575    # Need to define the proper option for radiative code compilation. By default, we use rrtm
576    case $rad in
577        oldrad) opt_rad="" ;;
578        rrtm)    opt_rad="-rad rrtm" ;;
579        ecrad)  opt_rad="-rad ecrad" ;;
580        *) echo Only oldrad rrtm ecrad for rad option ; exit
581    esac
582   
583   
584    if [ $compinca == y ] ; then
585        arginca="-chimie INCA "
586    else
587        arginca=" "
588    fi
589   
590    if [ $compoasis == y ] ; then
591        argoasis="-c OMCT "
592    else
593        argoasis=" "
594    fi
595
596    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 
597    ./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
598   
599   
600    # Test if compiling finished
601    if [[ $? != 0 ]] ; then
602        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
603        exit
604    fi
605fi
606
607
608## 2.8 Compile DYNAMICO
609if [ $compdyna == y ] ; then
610    cd $modipsl/modeles/DYNAMICO
611    echo; echo "NOW COMPILE DYNAMICO "
612    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
613   
614    if [ $compoasis == y ] ; then
615        argoasis="-with_oasis "
616    else
617        argoasis=" "
618    fi
619    if [ $compinca == y ] ; then
620        arginca="-with_inca "
621    else
622        arginca=" "
623    fi
624   
625   
626    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
627    ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
628    # Test if compiling finished
629    if [[ $? != 0 ]] ; then
630        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
631        exit
632    fi
633fi
634   
635## 2.9 Compile interface ICOSA_LMDZ
636if [ $compdyna == y ] ; then
637    cd $modipsl/modeles/ICOSA_LMDZ
638    echo; echo "NOW COMPILE ICOSA_LMDZ "
639    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
640   
641    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 
642    ./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
643    # Test if compiling finished
644    if [[ $? != 0 ]] ; then
645        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
646        exit
647    fi
648    # Move executables to modipsl/bin
649    if [ -f $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
650        if [ $compinca == y ] ; then
651            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe
652            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
653            cd  $modipsl/bin
654            rm -f icosa_lmdz_${orchversion}_${optmode}.exe
655            ln -s icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe icosa_lmdz_${orchversion}_${optmode}.exe
656        else
657            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}.exe
658        fi
659    else
660        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
661        exit
662    fi
663fi
664
665
666## 2.10 Compile LMDZ for regular latlon configuration
667if [ $regular_latlon = y ] && [ $complmdz = y ] ; then
668
669    cd $modipsl/modeles/LMDZ
670
671    # Compile LMDZ regular lat-lon exectuable
672    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
673    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
674    # Check if the compilation of LMDZ was previsouly interupted prematured.
675    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
676    # to ask question and wait for interactivly answer from the user.
677    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
678        echo >> $outfile
679        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
680        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
681        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
682        echo >> $outfile
683        rm -f libf/grid/dimensions.h
684        rm -f .lock
685    fi
686
687    # Need to define the proper option for radiative code compilation. By default, we use rrtm
688    case $rad in
689        oldrad) opt_rad="" ;;
690        rrtm)    opt_rad="-rad rrtm" ;;
691        ecrad)  opt_rad="-rad ecrad" ;;
692        *) echo Only oldrad rrtm ecrad for rad option ; exit
693    esac
694   
695    if [ $compinca == y ] ; then
696        arginca="-chimie INCA"
697    else
698        arginca=""
699    fi
700   
701    if [ $compoasis == y ] ; then
702        argoasis="-c OMCT"
703    else
704        argoasis=""
705    fi
706    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 
707         ./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
708    # Test if compiling finished
709    if [[ $? != 0 ]] ; then
710        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
711        exit
712    fi
713
714    # Find executable suffix
715    suffix=_${resol_atm}_phylmd
716    suffix=${suffix}_${rad} 
717    if [ $parallel == seq ] || [ $parallel == none ] ; then
718        suffix=${suffix}_seq_orch_inca.e
719    else
720        if [ $compoasis == y ] ; then
721            suffix=${suffix}_para_mem_orch_couple
722        else
723            suffix=${suffix}_para_mem_orch
724        fi
725        if [ $compinca == y ] ; then
726            suffix=${suffix}_inca.e
727        else
728            suffix=${suffix}.e
729        fi
730    fi
731    echo gcm suffix = $suffix
732   
733    # Move executables to modipsl/bin folder
734    echo "Move gcm.e executable to modipsl/bin"
735    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
736        if [ $compinca == y ] ; then
737            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e
738            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
739            cd $modipsl/bin
740            rm -f gcm_${resol_atm}_${orchversion}_${optmode}.e
741            ln -s gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e gcm_${resol_atm}_${orchversion}_${optmode}.e
742        else
743            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}.e
744        fi
745    else
746        echo "ERROR gcm${suffix} executable does not exist." 
747        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
748        exit
749    fi   
750
751    # Find executable suffix
752    suffix=_${resol_atm}_phylmd
753    suffix=${suffix}_${rad} 
754    if [ $parallel == seq ] || [ $parallel == none ] ; then
755        suffix=${suffix}_seq_orch.e
756    else
757        if [ $compoasis == y ] ; then
758            suffix=${suffix}_para_mem_orch_couple.e
759        else
760            suffix=${suffix}_para_mem_orch.e
761        fi
762    fi
763    echo ce0l suffix = $suffix
764
765    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
766    cd $modipsl/modeles/LMDZ
767    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
768    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
769
770    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 
771         ./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
772    # Test if compiling finished
773    if [[ $? != 0 ]] ; then
774        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
775        exit
776    fi
777   
778 
779    # Move executable ce0l to modipsl/bin folder
780    echo "Move ce0l executable to modipsl/bin"
781    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
782        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
783    else
784        echo "ERROR ce0l${suffix} executable does not exist." 
785        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
786        exit
787    fi
788fi
789
790# Compress XIOS and LMDZ/libo
791if [ $comp_tar == yes ] && [ -d $modipsl/modeles/XIOS ] ; then
792    echo "Option comp_tar activated, now compress XIOS"
793    echo "Option comp_tar activated, now compress XIOS" >> $outfile
794    cd $modipsl/modeles
795    tar -cf XIOS_${optmode}.tar XIOS
796    rm -rf XIOS
797fi
798
799if [ $comp_tar == yes ] && [ -d $modipsl/modeles/LMDZ/libo ] ; then
800    echo "Option comp_tar activated, now compress LMDZ/libo"
801    echo "Option comp_tar activated, now compress LMDZ/libo" >> $outfile
802    cd $modipsl/modeles/LMDZ
803    tar -cf libo_${optmode}.tar libo
804    rm -rf libo
805fi
806 
807echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
808echo ls -lrt modipsl/bin >> $outfile
809ls -lrt $modipsl/bin >> $outfile
810
811echo; echo "ALL COMPILING FINISHED" ; echo
812echo "Executables are found in modipsl/bin"
813echo "Check that executable names correspond with the name set in config.card before launching the job"
814echo ls -lrt modipsl/bin
815ls -lrt $modipsl/bin
816
817date
818
819exit
820
821
Note: See TracBrowser for help on using the repository browser.