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

Last change on this file since 6942 was 6942, checked in by acosce, 4 months ago

modify name of xios_server.exe in case of compilation with oasis option

in previous mode if we compiled in first coupled model, then forced one. The executable xios_server.exe wasn't
adapted for coupled model after compilation of forced model.

  • Property svn:executable set to *
File size: 32.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
375    if [ $compoasis == y ] ; then
376        cp $modipsl/bin/xios_server_${optmode}.exe $modipsl/bin/xios_server_oasis_${optmode}.exe
377    fi
378else
379    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
380    exit
381fi
382
383
384## 2.4 Compile ORCHIDEE
385# Choose ORCHIDEE version to compile and create a link to generic folder name ORCHIDEE.
386# This link is needed for the compilation of ICOSA_LMDZ for it to find the orchidee librarie.
387cd $modipsl/modeles
388rm -f ORCHIDEE
389if [ $orchversion == orch22 ] ; then
390    ln -s ORCHIDEE_2_2 ORCHIDEE
391    cd $modipsl/modeles/ORCHIDEE_2_2
392    echo; echo "NOW COMPILE ORCHIDEE_2_2"
393    echo >> $outfile ; echo " NOW COMPILE ORCHIDEE_2_2"   >> $outfile 
394else
395    ln -s ORCHIDEE_4 ORCHIDEE
396    cd $modipsl/modeles/ORCHIDEE_4
397    echo; echo "NOW COMPILE ORCHIDEE_4 (trunk)"
398    echo >> $outfile ; echo " NOW COMPILE ORCHIDEE_4 (trunk)"   >> $outfile 
399fi
400
401# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
402# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
403# to ask question and wait for interactivly answer from the user.
404if [ -f build/fcm.bld.lock ] ; then
405    echo >> $outfile
406    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
407    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
408    echo "           The file will now be removed. "   >> $outfile
409    echo >> $outfile
410    rm -f build/fcm.bld.lock
411fi
412
413if [ $compoasis == y ] ; then
414    # For this case, XIOS library needs to be linked with OASIS library
415    argoasis="-linkwithoasis"
416else
417    argoasis=""
418fi
419
420echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path ${argoasis} $full_orch $orchdriver >> $outfile 
421        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path ${argoasis} $full_orch $orchdriver >> $outfile 2>&1
422# Test if compiling finished
423if [[ $? != 0 ]] ; then
424    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
425    exit
426fi
427
428# Rename exetubles for ORCHIDEE offline driver with suffix version
429cd $modipsl/bin
430if [ -f orchideedriver ] ; then
431    mv orchideedriver orchideedriver.${orchversion}_$optmode
432    ln -sf orchideedriver.${orchversion}_$optmode orchideedriver_$optmode
433fi
434if [ -f orchidee_ol ] ; then
435    mv orchidee_ol orchidee_ol.${orchversion}_$optmode
436    ln -sf orchidee_ol.${orchversion}_$optmode orchidee_ol_$optmode
437fi
438
439## 2.5 Compile NEMO
440if [ $compnemo == y ] ; then
441    nemo_root=$modipsl/modeles/NEMO
442    cfg_ref=ORCA2_ICE_PISCES
443    cfg_wrk=ORCA_ICE_TRC
444    addkeys="key_oasis3 key_top key_si3 key_isf"
445    delkeys=""
446   
447    if [ ${nemotop} == n ] ; then
448        cfg_wrk=ORCA_ICE
449        delkeys="key_top"
450    fi
451   
452    if [ ${nemotop} == n ] ; then
453        echo; echo "NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"
454        echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"   >> $outfile
455    else
456        echo; echo "NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"
457        echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"   >> $outfile
458    fi
459
460    # Compilation management
461    # Nemo debug ?
462    cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm   $mysrc_path/NEMO/arch-nemo.fcm
463    if [ $optmode == debug ] ; then
464       if (! grep -q "^%DEBUG_FCFLAGS"  $mysrc_path/NEMO/arch-nemo.fcm); then
465          echo "ERROR: You must defined '%DEBUG_FCFLAGS' in your arch file if you want to compile Nemo in debug mode using '-d' option"
466          exit 1
467       fi
468       # duplicate the lines starting with %DEBUG_XXX and replace, in the duplicated line, %DEBUG_XXX by %XXX
469       # sed -i'' -e "/^%DEBUG_/{p;s/^%DEBUG_\([^ ]*\)/%\1/;}" $mysrc_path/NEMO/arch-nemo.fcm
470      sed -i'' -e "/^%PROD_/{p;s/^%PROD_\([^ ]*\)/%\1/;}" $mysrc_path/NEMO/arch-nemo.fcm
471    else
472       if (! grep -q "^%PROD_FCFLAGS" $mysrc_path/NEMO/arch-nemo.fcm ); then
473          echo "WARNING: '%PROD_FCFLAGS' not defined in your arch file, makenemo will use '%FCFLAGS' instead"
474       fi
475       # duplicate the lines starting with %PROD_XXX and replace, in the duplicated line, %PROD_XXX by %XXX
476      sed -i'' -e "/^%PROD_/{p;s/^%PROD_\([^ ]*\)/%\1/;}" $mysrc_path/NEMO/arch-nemo.fcm
477    fi
478
479    echo >> $outfile ; echo cd $nemo_root  >> $outfile
480    echo >> $outfile ; echo cp $mysrc_path/NEMO/arch-nemo.fcm arch/CNRS/arch-${fcm_arch}.fcm   >> $outfile
481    echo >> $outfile
482
483    cd $nemo_root ; mv $mysrc_path/NEMO/arch-nemo.fcm   arch/CNRS/arch-${fcm_arch}.fcm
484
485    # creation of config
486    echo >> $outfile ; echo cd $nemo_root  >> $outfile
487    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
488    echo >> $outfile
489    cd $nemo_root
490    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0  add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
491
492   # Copy of additional source files from another configuration if needed ( i.e PISCES-GAS )
493   if [ ${nemotop} == y ]  ;  then
494      echo >> $outfile ; echo cp $nemo_root/cfgs/ORCA_ICE_PISCES_GAS/MY_SRC/*  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
495      echo >> $outfile
496      cp $nemo_root/cfgs/ORCA_ICE_PISCES_GAS/MY_SRC/*                       $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
497      cp $nemo_root/cfgs/ORCA_ICE_PISCES_GAS/EXPREF/field_def_nemo-gas.xml  $nemo_root/cfgs/SHARED/.
498   fi   
499   
500    # Copy of specfic source files
501    echo >> $outfile ; echo cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
502    echo >> $outfile
503    cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
504   
505   
506    # Copy of specific xml files
507    echo >> $outfile ; echo cp $mysrc_path/NEMO/field*.xml  $nemo_root/cfgs/SHARED/.   >> $outfile
508    echo >> $outfile
509    cp $mysrc_path/NEMO/field*.xml   $nemo_root/cfgs/SHARED/.
510    #
511    #
512    if [ $full_nemo == y ] ; then
513        # To make a full compilation, first make a clean to remove all files produced during previous compilation
514        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean   >> $outfile
515        echo >> $outfile
516        ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean  >> $outfile 2>&1
517    fi
518    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile
519    echo >> $outfile
520    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile 2>&1
521   
522    echo >> $outfile
523    echo "Move nemo executable to modipsl/bin" >> $outfile
524    echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin   >> $outfile
525    ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin  >> $outfile
526    echo >> $outfile
527   
528    if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then
529        mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${optmode}.exe
530    else
531        echo "ERROR nemo.exe executable does not exist."
532        echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
533        exit
534    fi
535   
536else
537    echo ; echo No compilation of NEMO
538fi
539
540##2.6  Compile INCA
541if [ $compinca == y ] ; then
542    cd $modipsl/modeles/INCA
543   
544    echo; echo "NOW COMPILE INCA ${optchimie}"
545    echo >> $outfile ; echo " NOW COMPILE INCA ${optchimie}"   >> $outfile 
546   
547    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_inca  >> $outfile
548    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_inca >> $outfile 2>&1
549   
550    # Test if compiling finished
551    if [[ $? != 0 ]] ; then
552        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
553        echo "ALL INFORMATION IN FILE $outfile"
554        exit
555    fi
556   
557    echo "Move inca.dat modipsl/bin"
558    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
559        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${optchimie}.dat ;
560    else
561        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
562        echo "ALL INFORMATION IN FILE $outfile"
563        exit   
564    fi
565   
566    echo "Move tracer.def to  modipsl/bin"
567    if [[ -f $modipsl/modeles/INCA/tracer.def ]] ;  then
568        mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optchimie}.def ;
569    fi
570   
571else
572    echo ; echo No compilation of INCA
573fi
574
575## 2.7 Compile LMDZ
576
577# First check if LMDZ/libo exist or if it could be decompressed
578# If neither LMDZ/libo or LMDZ/libo_${optmode}.tar exists, nothing is done. It'll be created
579# during the compilation.
580echo; echo "NOW DECOMPRESS LMDZ/libo IF NEEDED"
581if [[ -d $modipsl/modeles/LMDZ/libo ]] ; then
582    echo "Found LMDZ/libo -> no decompress needs to be done"; >> $outfile
583elif [[ -f $modipsl/modeles/LMDZ/libo_${optmode}.tar ]]; then
584    echo "Found LMDZ/libo_${optmode}.tar -> decompress repository"; >> $outfile
585    echo >> $outfile
586    cd $modipsl/modeles/LMDZ
587    tar -xf libo_${optmode}.tar >> $outfile 2>&1
588fi
589
590
591# Compile LMDZ as library to couple to DYNAMICO
592if [ $compdyna == y ] ; then
593    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
594    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
595    cd $modipsl/modeles/LMDZ   
596   
597    # Check if the compilation of LMDZ was previsouly interupted prematured.
598    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
599    # to ask question and wait for interactivly answer from the user.
600    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
601        echo >> $outfile
602        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
603        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
604        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
605        echo >> $outfile
606        rm -f libf/grid/dimensions.h
607        rm -f .lock
608    fi
609   
610    # Need to define the proper option for radiative code compilation. By default, we use rrtm
611    case $rad in
612        oldrad) opt_rad="" ;;
613        rrtm)    opt_rad="-rad rrtm" ;;
614        ecrad)  opt_rad="-rad ecrad" ;;
615        *) echo Only oldrad rrtm ecrad for rad option ; exit
616    esac
617   
618   
619    if [ $compinca == y ] ; then
620        arginca="-chimie INCA "
621    else
622        arginca=" "
623    fi
624   
625    if [ $compoasis == y ] ; then
626        argoasis="-c OMCT "
627    else
628        argoasis=" "
629    fi
630
631    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 
632    ./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
633   
634   
635    # Test if compiling finished
636    if [[ $? != 0 ]] ; then
637        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
638        exit
639    fi
640fi
641
642
643## 2.8 Compile DYNAMICO
644if [ $compdyna == y ] ; then
645    cd $modipsl/modeles/DYNAMICO
646    echo; echo "NOW COMPILE DYNAMICO "
647    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
648   
649    if [ $compoasis == y ] ; then
650        argoasis="-with_oasis "
651    else
652        argoasis=" "
653    fi
654    if [ $compinca == y ] ; then
655        arginca="-with_inca "
656    else
657        arginca=" "
658    fi
659   
660   
661    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
662    ./make_icosa -$optmode -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
663    # Test if compiling finished
664    if [[ $? != 0 ]] ; then
665        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
666        exit
667    fi
668fi
669   
670## 2.9 Compile interface ICOSA_LMDZ
671if [ $compdyna == y ] ; then
672    cd $modipsl/modeles/ICOSA_LMDZ
673    echo; echo "NOW COMPILE ICOSA_LMDZ "
674    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
675   
676    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 
677    ./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
678    # Test if compiling finished
679    if [[ $? != 0 ]] ; then
680        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
681        exit
682    fi
683    # Move executables to modipsl/bin
684    if [ -f $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
685        if [ $compinca == y ] ; then
686            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe
687            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
688            cd  $modipsl/bin
689            rm -f icosa_lmdz_${orchversion}_${optmode}.exe
690            ln -s icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe icosa_lmdz_${orchversion}_${optmode}.exe
691        else
692            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}.exe
693        fi
694    else
695        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
696        exit
697    fi
698fi
699
700
701## 2.10 Compile LMDZ for regular latlon configuration
702if [ $regular_latlon = y ] && [ $complmdz = y ] ; then
703
704    cd $modipsl/modeles/LMDZ
705
706    # Compile LMDZ regular lat-lon exectuable
707    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
708    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
709    # Check if the compilation of LMDZ was previsouly interupted prematured.
710    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
711    # to ask question and wait for interactivly answer from the user.
712    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
713        echo >> $outfile
714        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
715        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
716        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
717        echo >> $outfile
718        rm -f libf/grid/dimensions.h
719        rm -f .lock
720    fi
721
722    # Need to define the proper option for radiative code compilation. By default, we use rrtm
723    case $rad in
724        oldrad) opt_rad="" ;;
725        rrtm)    opt_rad="-rad rrtm" ;;
726        ecrad)  opt_rad="-rad ecrad" ;;
727        *) echo Only oldrad rrtm ecrad for rad option ; exit
728    esac
729   
730    if [ $compinca == y ] ; then
731        arginca="-chimie INCA"
732    else
733        arginca=""
734    fi
735   
736    if [ $compoasis == y ] ; then
737        argoasis="-c OMCT"
738    else
739        argoasis=""
740    fi
741    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 
742         ./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
743    # Test if compiling finished
744    if [[ $? != 0 ]] ; then
745        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
746        exit
747    fi
748
749    # Find executable suffix
750    suffix=_${resol_atm}_phylmd
751    suffix=${suffix}_${rad} 
752    if [ $parallel == seq ] || [ $parallel == none ] ; then
753        suffix=${suffix}_seq_orch_inca.e
754    else
755        if [ $compoasis == y ] ; then
756            suffix=${suffix}_para_mem_orch_couple
757        else
758            suffix=${suffix}_para_mem_orch
759        fi
760        if [ $compinca == y ] ; then
761            suffix=${suffix}_inca.e
762        else
763            suffix=${suffix}.e
764        fi
765    fi
766    echo gcm suffix = $suffix
767   
768    # Move executables to modipsl/bin folder
769    echo "Move gcm.e executable to modipsl/bin"
770    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
771        if [ $compinca == y ] ; then
772            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e
773            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
774            cd $modipsl/bin
775            rm -f gcm_${resol_atm}_${orchversion}_${optmode}.e
776            ln -s gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e gcm_${resol_atm}_${orchversion}_${optmode}.e
777        else
778            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}.e
779        fi
780    else
781        echo "ERROR gcm${suffix} executable does not exist." 
782        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
783        exit
784    fi   
785
786    # Find executable suffix
787    suffix=_${resol_atm}_phylmd
788    suffix=${suffix}_${rad} 
789    if [ $parallel == seq ] || [ $parallel == none ] ; then
790        suffix=${suffix}_seq_orch.e
791    else
792        if [ $compoasis == y ] ; then
793            suffix=${suffix}_para_mem_orch_couple.e
794        else
795            suffix=${suffix}_para_mem_orch.e
796        fi
797    fi
798    echo ce0l suffix = $suffix
799
800    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
801    cd $modipsl/modeles/LMDZ
802    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
803    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
804
805    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 
806         ./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
807    # Test if compiling finished
808    if [[ $? != 0 ]] ; then
809        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
810        exit
811    fi
812   
813 
814    # Move executable ce0l to modipsl/bin folder
815    echo "Move ce0l executable to modipsl/bin"
816    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
817        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
818    else
819        echo "ERROR ce0l${suffix} executable does not exist." 
820        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
821        exit
822    fi
823fi
824
825# Compress XIOS and LMDZ/libo
826if [ $comp_tar == yes ] && [ -d $modipsl/modeles/XIOS ] ; then
827    echo "Option comp_tar activated, now compress XIOS"
828    echo "Option comp_tar activated, now compress XIOS" >> $outfile
829    cd $modipsl/modeles
830    tar -cf XIOS_${optmode}.tar XIOS
831    rm -rf XIOS
832fi
833
834if [ $comp_tar == yes ] && [ -d $modipsl/modeles/LMDZ/libo ] ; then
835    echo "Option comp_tar activated, now compress LMDZ/libo"
836    echo "Option comp_tar activated, now compress LMDZ/libo" >> $outfile
837    cd $modipsl/modeles/LMDZ
838    tar -cf libo_${optmode}.tar libo
839    rm -rf libo
840fi
841 
842echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
843echo ls -lrt modipsl/bin >> $outfile
844ls -lrt $modipsl/bin >> $outfile
845
846echo; echo "ALL COMPILING FINISHED" ; echo
847echo "Executables are found in modipsl/bin"
848echo "Check that executable names correspond with the name set in config.card before launching the job"
849echo ls -lrt modipsl/bin
850ls -lrt $modipsl/bin
851
852date
853
854exit
855
856
Note: See TracBrowser for help on using the repository browser.