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

Last change on this file since 6642 was 6642, checked in by jgipsl, 9 months ago

Correct error

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