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

Last change on this file since 6677 was 6677, checked in by jgipsl, 6 months ago

Add possible sub configuration to compile : IPSLCM (without INCA), IPSLCM-reg(without INCA and DYNAMICO).
Correction in compilation of subconfig.
Some more comments in the help.

  • Property svn:executable set to *
File size: 26.2 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/DYNAMICO
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_trunk is compiled. This is used as argument and also in the suffix of the executables.
47orchversion=orch22
48
49# Default netcdf_lib is used for XIOS but can be change by argument
50netcdf_lib=""
51
52# Output text file for compilation of each component
53datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
54outfile=$submitdir/out_compile_ipslcm7.$datestr
55echo > $outfile
56echo; echo "Text output from compilation will be stored in file out_compile_ipslcm7.$datestr"; echo
57
58
59rm -f out_compile_ipslcm7
60ln -s ${outfile} out_compile_ipslcm7
61
62
63#### Read arguments
64# Loop over all arguments to modify default set up
65while (($# > 0)) ; do
66    case $1 in
67        "-h"|"-help") cat <<end_help
68########################################################################
69# Usage of the script compile_ipslcm7.sh
70#
71########################################################################
72
73./compile_ipslcm7.sh [Options]
74
75Description of all options:
76
77[-full] Full recompilation of all components. This option can be added to all other options.
78[-cleannemo] Full recompilation of NEMO component only.
79[-regular_latlon yes/no] Activate or deactivate compilation of LMDZ dynamics for regular latlon grid.
80                         Default resol_atm size is used. This option is set in addition to the compilation of the icosahedric grid.
81[-resol_atm XXXxYYYxZZ] Define which regular grid to compile. A default grid is set if this option is not used.
82[-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod.
83[-subconfig X] Set this option if you want to compile a sub-configuration. X can be one of following sub-configurations :
84               ICOLMDZORINCA, ICOLMDZOR, LMDZORINCA, LMDZOR, IPSLCM-reg or IPSLCM
85               By default, all available components are compiled.
86[-orch4 / -orch22] Choice of ORCHIDEE version. The source code are found in modeles/ORCHIDEE_trunk or modeles/ORCHIDEE_2_2
87                   and a link will be set to the choosen model version. Default version is currently ORCHIDEE_2_2 (-orch22).
88
89
90Example 1: Default compilation of IPSLCM7
91./compile_ipslcm7.sh
92
93Example 2: Default compilation in debug mode
94./compile_ipslcm7.sh -debug
95
96Example 3: Default compilation with full recompilation of all components. No clean is needed.
97./compile_ipslcm7.sh -full
98
99Example 4: Compilation in addition of LMDZ in regular lat-lon for a specific resolution :
100./compile_ipslcm7.sh -resol_atm 144x142x95
101
102Example 5: Compilation without regular grid (only icosaedric grid)
103./compile_ipslcm7.sh -regular_latlon no
104
105Example 5: Compiltion of ORCHIDEE_trunk version
106./compile_ipslcm7.sh -orch4
107
108Example 6: compilation of a specific chemistry for INCA (default is GES)
109./compile_ipslcm7.sh -chimie NMHC_AER_S
110
111Example 7: Compilation of sub-configuration LMDZOR :
112./compile_ipslcm7.sh -subconfig LMDZOR
113
114end_help
115            exit;;
116
117        "-parallel")   parallel=$2 ; shift ; shift ;;
118        "-arch")       fcm_arch="$2" ; shift ; shift ;;
119        "-debug")      optmode=debug ; shift ;;
120        "-dev")        optmode=dev ; shift ;;
121        "-prod")       optmode=prod ; shift ;;
122        "-regular_latlon")  regular_latlon=$2 ; shift ; shift ;;
123        "-resol_atm")  regular_latlon=y ; resol_atm=$2 ; shift ; shift ;;
124        "-subconfig")  subconfig=$2 ; shift ; shift ;;
125        "-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 ;;
126        "-full_xios")  full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
127        "-full_lmdz")  full_lmdz="-full"  ; shift ;;
128        "-full_orch")  full_orch="-full"  ; shift ;;
129        "-full_nemo")  full_nemo=y ; shift ;;
130        "-full_inca")  full_inca="-clean"; shift ;;
131        "-full_dyna")  full_dyna="-full" ; shift ;;
132        "-full_oasis") full_oasis=y ; shift ;;
133        "-cleannemo")  full_nemo=y ; shift ;;
134        "-rad")        rad=$2; shift ; shift ;;
135        "-orch22")     orchversion="orch22"; shift ;;
136        "-orch4")      orchversion="orch4"shift ;;
137        "-chimie")     optchimie=$2; shift ; shift;;
138        *)             echo "unknown option "$1" , exiting..." ; exit
139    esac
140done
141
142
143# Define which sub-configuration to compile. By default all extracted source components are compiled.
144source define_config.sh
145
146echo "Following options are set in current compiling:" >> $outfile
147echo "   regular_latlon=$regular_latlon (if yes, then resol_atm=${resol_atm})" >> $outfile 
148echo "   resol_atm=${resol_atm}, nemotop=${nemotop}" >> $outfile 
149echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
150echo "   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 
151echo "   compinca=$compinca compnemo=$compnemo compoasis=$compoasis compdyna=$compdyna complmdz=y comporch=y compxios=y" >> $outfile
152echo >> $outfile
153### Verification of argument
154# Set argorch depeinding on the version of ORCHIDEE. This is argument needed for the compilation of LMDZ to consider coherent interface.
155if [ $orchversion == orch22 ] ; then
156    argorch=orchidee2.1
157elif [ $orchversion == orch4 ] ; then
158    argorch=orchideetrunk
159else
160    echo "ERROR in version of ORCHIDEE. It is only possible to have orch22 or orch4 for now"
161fi
162
163### Read host dependent default values
164### These variables will not be changed if they were set as argument
165###./host.sh $host
166# Later : Following lines should be set in host.sh file
167# begin host.sh
168if [ $fcm_arch == default ] ; then
169    # Find out current host and source specific paths and commands for the host
170    case $( hostname -s ) in
171        jean-zay*)
172            if [[ $( hostname -s ) != *"pp"* ]] ; then
173                echo "Warning! You MUST compile on jean-zay-pp."
174                echo "EXIT"
175                exit
176            else
177                fcm_arch=X64_JEANZAY
178            fi ;;
179        irene170|irene171|irene190|irene191|irene192|irene193)
180            fcm_arch=X64_IRENE;;
181        irene172|irene173|irene194|irene195)
182            fcm_arch=X64_IRENE-AMD;;
183        asterix*|obelix*)
184            fcm_arch=ifort_LSCE
185            if [ "${parallel}" == "mpi_omp" ] ; then
186                echo "Warning!! Currently at Obelix hybrid mode is not possible."
187                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
188                echo ""
189                parallel=mpi
190            else
191                echo "You used -parallel" $parallel
192            fi ;;
193        spirit*)
194            fcm_arch=ifort_MESOIPSL;;
195        ciclad*|climserv*|loholt*|camelot*)
196            fcm_arch=ifort_CICLAD;;
197        *)
198            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
199            echo Exit now.
200            exit
201    esac
202fi
203
204# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
205# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
206if [ -f ARCH/arch-${fcm_arch}.env ] ; then
207    echo >> $outfile
208    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
209    echo "Note that this new environement might be kept after compilation."
210    echo "If this is the case, source again your personal environment after compilation."
211    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
212    module list   >> $outfile 2>&1
213    svn_version=$(module list -t | grep subversion)
214       
215    # Make a link to this file, to be used also in config.card
216    rm -f ARCH/arch.env
217    ln -s arch-${fcm_arch}.env ARCH/arch.env
218
219    # Source the file
220    source ARCH/arch.env   >> $outfile 2>&1
221    if [ X$svn_version != X ] ; then
222        module load ${svn_version}
223    fi
224    echo >> $outfile
225    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
226    module list   >> $outfile 2>&1
227fi
228
229
230#### Clean if full_orch
231# If full recompilation of ORCHIDEE then first clean modipsl/lib folder
232if [ X${full_orch} == X"-full" ] ; then
233   rm -f $modipsl/lib/*
234fi
235
236#### 2 Do the compilation
237## 2.1 Compile ioipsl
238cd $modipsl/modeles/IOIPSL
239echo; echo "NOW COMPILE IOIPSL"
240echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
241
242echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
243     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
244# Test if compiling succeded
245if [[ $? != 0 ]] ; then
246    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
247    exit
248fi
249
250if [ $compoasis == y ] ; then
251## 2.2 Compile oasis3-mct
252if [ $full_oasis == y ] ; then
253    rm -rf $modipsl/oasis3-mct/BLD
254fi
255cd $modipsl/oasis3-mct/util/make_dir
256echo; echo "NOW COMPILE OASIS3-MCT"
257echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT"   >> $outfile
258cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc
259
260echo make -f TopMakefileOasis3 >> $outfile
261     make -f TopMakefileOasis3 >> $outfile 2>&1
262
263else
264echo ; echo No compilation of OASIS
265fi
266
267## 2.3 Compile xios
268cd $modipsl/modeles/XIOS
269echo; echo "NOW COMPILE XIOS"
270echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
271if [ $compoasis == y ] ; then
272argoasis="--use_oasis oasis3_mct "
273else
274argoasis=" "
275fi
276echo ./make_xios $argoasis --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
277     ./make_xios $argoasis --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
278# Test if compiling succeded
279if [[ $? != 0 ]] ; then
280    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
281    exit
282fi
283# Move executables to modipsl/bin
284if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
285    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
286else
287    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
288    exit
289fi
290
291
292## 2.4 Compile ORCHIDEE
293# Choose ORCHIDEE version to compile and create a link to generic folder name ORCHIDEE.
294# This link is needed for the compilation of ICOSA_LMDZ for it to find the orchidee librarie.
295cd $modipsl/modeles
296rm -f ORCHIDEE
297if [ $orchversion == orch22 ] ; then
298    ln -s ORCHIDEE_2_2 ORCHIDEE
299    cd $modipsl/modeles/ORCHIDEE_2_2
300    echo; echo "NOW COMPILE ORCHIDEE_2_2"
301    echo >> $outfile ; echo " NOW COMPILE ORCHIDEE_2_2"   >> $outfile 
302else
303    ln -s ORCHIDEE_trunk ORCHIDEE
304    cd $modipsl/modeles/ORCHIDEE_trunk
305    echo; echo "NOW COMPILE ORCHIDEE_trunk v4"
306    echo >> $outfile ; echo " NOW COMPILE ORCHIDEE_trunk v4"   >> $outfile 
307fi
308
309# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
310# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
311# to ask question and wait for interactivly answer from the user.
312if [ -f build/fcm.bld.lock ] ; then
313    echo >> $outfile
314    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
315    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
316    echo "           The file will now be removed. "   >> $outfile
317    echo >> $outfile
318    rm -f build/fcm.bld.lock
319fi
320
321echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch  >> $outfile 
322        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch  >> $outfile 2>&1
323# Test if compiling finished
324if [[ $? != 0 ]] ; then
325    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
326    exit
327fi
328
329# Rename exetubles for ORCHIDEE offline driver with suffix version
330cd $modipsl/bin
331if [ -f orchideedriver ] ; then mv orchideedriver orchideedriver.$orchversion ; fi
332if [ -f orchidee_ol ] ; then mv orchidee_ol orchidee_ol.$orchversion ; fi
333
334
335## 2.5 Compile NEMO
336if [ $compnemo == y ] ; then
337    nemo_root=$modipsl/modeles/NEMO
338    cfg_ref=ORCA2_ICE_PISCES
339    cfg_wrk=ORCA_ICE_TRC
340    addkeys="key_oasis3 key_top key_si3 key_isf"
341    delkeys=""
342   
343    if [ ${nemotop} == n ] ; then
344        cfg_wrk=ORCA_ICE
345        delkeys="key_top"
346    fi
347   
348    if [ ${nemotop} == n ] ; then
349        echo; echo "NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"
350        echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"   >> $outfile
351    else
352        echo; echo "NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"
353        echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"   >> $outfile
354    fi
355   
356    echo >> $outfile ; echo cd $nemo_root  >> $outfile
357    echo >> $outfile ; echo cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.   >> $outfile
358    echo >> $outfile
359   
360    cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.
361   
362    # creation of config
363    echo >> $outfile ; echo cd $nemo_root  >> $outfile
364    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
365    echo >> $outfile
366    cd $nemo_root
367    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0  add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
368   
369   
370    # Copy of specfic source files
371    echo >> $outfile ; echo cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
372    echo >> $outfile
373    cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
374   
375   
376    if [ $full_nemo == y ] ; then
377        # To make a full compilation, first make a clean to remove all files produced during previous compilation
378        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean   >> $outfile
379        echo >> $outfile
380        ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean  >> $outfile 2>&1
381    fi
382    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile
383    echo >> $outfile
384    ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile 2>&1
385   
386    echo >> $outfile
387    echo "Move nemo executable to modipsl/bin" >> $outfile
388    echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin   >> $outfile
389    ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin  >> $outfile
390    echo >> $outfile
391   
392    if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then
393        mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${optmode}.exe
394    else
395        echo "ERROR nemo.exe executable does not exist."
396        echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
397        exit
398    fi
399   
400else
401    echo ; echo No compilation of NEMO
402fi
403
404##2.6  Compile INCA
405if [ $compinca == y ] ; then
406    cd $modipsl/modeles/INCA
407   
408    echo; echo "NOW COMPILE INCA ${optchimie}"
409    echo >> $outfile ; echo " NOW COMPILE INCA ${optchimie}"   >> $outfile 
410   
411    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_inca  >> $outfile
412    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path $full_inca >> $outfile 2>&1
413   
414    # Test if compiling finished
415    if [[ $? != 0 ]] ; then
416        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
417        echo "ALL INFORMATION IN FILE $outfile"
418        exit
419    fi
420   
421    echo "Move inca.dat modipsl/bin"
422    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
423        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${optchimie}.dat ;
424    else
425        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
426        echo "ALL INFORMATION IN FILE $outfile"
427        exit   
428    fi
429   
430    echo "Move tracer.def to  modipsl/bin"
431    if [[ -f $modipsl/modeles/INCA/tracer.def ]] ;  then
432        mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optchimie}.def ;
433    fi
434   
435else
436    echo ; echo No compilation of INCA
437fi
438
439## 2.7 Compile LMDZ
440cd $modipsl/modeles/LMDZ
441# Compile LMDZ as library to couple to DYNAMICO
442if [ $compdyna == y ] ; then
443    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
444    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
445   
446    # Retrieve the final svn release number, needed for radiative code suffix of executable
447    lmdzsvn=`svnversion . | egrep -o "[0-9]+"  | awk 'NR==1'`
448    # Temporary use of SOURCES/LMDZ to handle modifications needed by IPSLCM7
449    cp $mysrc_path/LMDZ/phylmd/*.*90  libf/phylmd/.
450    cp $mysrc_path/LMDZ/dyn3d_common/*.*90  libf/dyn3d_common/.
451   
452    # Check if the compilation of LMDZ was previsouly interupted prematured.
453    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
454    # to ask question and wait for interactivly answer from the user.
455    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
456        echo >> $outfile
457        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
458        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
459        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
460        echo >> $outfile
461        rm -f libf/grid/dimensions.h
462        rm -f .lock
463    fi
464   
465    # Need to define the proper option for radiative code compilation. By default, we use rrtm
466    case $rad in
467        oldrad) opt_rad="" ;;
468        rrtm)   if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;;
469        ecrad)  opt_rad="-rad ecrad" ;;
470        *) echo Only oldrad rrtm ecrad for rad option ; exit
471    esac
472   
473    if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi
474   
475    if [ $compinca == y ] ; then
476        arginca="-chimie INCA "
477    else
478        arginca=" "
479    fi
480   
481    if [ $compoasis == y ] ; then
482        argoasis="-c OMCT "
483    else
484        argoasis=" "
485    fi
486
487    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 
488    ./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
489   
490   
491    # Test if compiling finished
492    if [[ $? != 0 ]] ; then
493        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
494        exit
495    fi
496fi
497
498
499## 2.8 Compile DYNAMICO
500if [ $compdyna == y ] ; then
501    cd $modipsl/modeles/DYNAMICO
502    echo; echo "NOW COMPILE DYNAMICO "
503    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
504   
505    if [ $compoasis == y ] ; then
506        argoasis="-with_oasis "
507    else
508        argoasis=" "
509    fi
510    if [ $compinca == y ] ; then
511        arginca="-with_inca "
512    else
513        arginca=" "
514    fi
515   
516   
517    echo ./make_icosa -$optmode -with_fcm1 -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
518    ./make_icosa -$optmode -with_fcm1 -parallel $parallel -external_ioipsl $argoasis -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
519    # Test if compiling finished
520    if [[ $? != 0 ]] ; then
521        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
522        exit
523    fi
524fi
525   
526## 2.9 Compile interface ICOSA_LMDZ
527if [ $compdyna == y ] ; then
528    cd $modipsl/modeles/ICOSA_LMDZ
529    echo; echo "NOW COMPILE ICOSA_LMDZ "
530    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
531   
532    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 
533    ./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
534    # Test if compiling finished
535    if [[ $? != 0 ]] ; then
536        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
537        exit
538    fi
539    # Move executables to modipsl/bin
540    if [ -f $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
541        if [ $compinca == y ] ; then
542            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe
543            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
544            cd  $modipsl/bin
545            rm -f icosa_lmdz_${orchversion}_${optmode}.exe
546            ln -s icosa_lmdz_${orchversion}_${optmode}_${optchimie}.exe icosa_lmdz_${orchversion}_${optmode}.exe
547        else
548            mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${orchversion}_${optmode}.exe
549        fi
550    else
551        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
552        exit
553    fi
554fi
555
556
557## 2.10 Compile LMDZ for regular latlon configuration
558if [ $regular_latlon = y ] ; then
559
560    cd $modipsl/modeles/LMDZ
561    # Compile LMDZ regular lat-lon exectuable
562    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
563    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
564    # Check if the compilation of LMDZ was previsouly interupted prematured.
565    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
566    # to ask question and wait for interactivly answer from the user.
567    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
568        echo >> $outfile
569        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
570        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
571        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
572        echo >> $outfile
573        rm -f libf/grid/dimensions.h
574        rm -f .lock
575    fi
576
577    if [ $compinca == y ] ; then
578        arginca="-chimie INCA"
579    else
580        arginca=""
581    fi
582   
583    if [ $compoasis == y ] ; then
584        argoasis="-c OMCT"
585    else
586        argoasis=""
587    fi
588    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 
589         ./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
590    # Test if compiling finished
591    if [[ $? != 0 ]] ; then
592        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
593        exit
594    fi
595
596    # Find executable suffix
597    suffix=_${resol_atm}_phylmd
598    if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
599    if [ $parallel == seq ] || [ $parallel == none ] ; then
600        suffix=${suffix}_seq_orch_inca.e
601    else
602        if [ $compoasis == y ] ; then
603            suffix=${suffix}_para_mem_orch_couple
604        else
605            suffix=${suffix}_para_mem_orch
606        fi
607        if [ $compinca == y ] ; then
608            suffix=${suffix}_inca.e
609        else
610            suffix=${suffix}.e
611        fi
612    fi
613    echo gcm suffix = $suffix
614   
615    # Move executables to modipsl/bin folder
616    echo "Move gcm.e executable to modipsl/bin"
617    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
618        if [ $compinca == y ] ; then
619            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e
620            # Create link to be use by IPSLCM and LMDZOR without any change in the executable name
621            cd $modipsl/bin
622            rm -f gcm_${resol_atm}_${orchversion}_${optmode}.e
623            ln -s gcm_${resol_atm}_${orchversion}_${optmode}_${optchimie}.e gcm_${resol_atm}_${orchversion}_${optmode}.e
624        else
625            mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${orchversion}_${optmode}.e
626        fi
627    else
628        echo "ERROR gcm${suffix} executable does not exist." 
629        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
630        exit
631    fi   
632
633    # Find executable suffix
634    suffix=_${resol_atm}_phylmd
635    if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
636    if [ $parallel == seq ] || [ $parallel == none ] ; then
637        suffix=${suffix}_seq_orch.e
638    else
639        if [ $compoasis == y ] ; then
640            suffix=${suffix}_para_mem_orch_couple.e
641        else
642            suffix=${suffix}_para_mem_orch.e
643        fi
644    fi
645    echo ce0l suffix = $suffix
646
647    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
648    cd $modipsl/modeles/LMDZ
649    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
650    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
651
652    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 
653         ./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
654    # Test if compiling finished
655    if [[ $? != 0 ]] ; then
656        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
657        exit
658    fi
659   
660 
661    # Move executable ce0l to modipsl/bin folder
662    echo "Move ce0l executable to modipsl/bin"
663    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
664        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
665    else
666        echo "ERROR ce0l${suffix} executable does not exist." 
667        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
668        exit
669    fi
670fi
671
672echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
673echo ls -lrt modipsl/bin >> $outfile
674ls -lrt $modipsl/bin >> $outfile
675
676echo; echo "ALL COMPILING FINISHED" ; echo
677echo "Executables are found in modipsl/bin"
678echo "Check that executable names correspond with the name set in config.card before launching the job"
679echo ls -lrt modipsl/bin
680ls -lrt $modipsl/bin
681
682date
683
684exit
685
686
Note: See TracBrowser for help on using the repository browser.