source: CONFIG/UNIFORM/v6/IPSLCM5A2CHT.2/compile_ipslcm5a2cht.sh @ 6200

Last change on this file since 6200 was 6200, checked in by acosce, 22 months ago

add option OMCT for ce0l compilation (to link with XIOS compile with oasis)

File size: 17.4 KB
Line 
1#!/bin/bash
2#set -vx
3# Default options
4#
5#
6#
7date
8#### 1  Set up the compiling options
9#### Define some directories
10submitdir=$( pwd )
11modipsl=$submitdir/../..
12arch_path=$submitdir/ARCH
13mysrc_path=$submitdir/SOURCES
14
15#### Set default options
16# Atmospheric resolution, for LMDZ/ORCHIDEE in regular mode
17resol_atm=96x95x39
18#chemistry option
19optchimie=NMHC_AER_S
20# Oceanic resolution, for NEMO (ORCA2/ORCA1/ORCA025)
21resol_oce=ORCA2
22# Version of ice model lim2/lim3
23icemodel=lim2
24# paleo version  (y/n)
25paleo=n
26# Also compile ce0l subprogram to LMDZ (y/n)
27ce0l=n
28
29# Optimization mode
30# optmode=prod/dev/debug
31optmode=prod
32# fcm_arch
33fcm_arch=default
34# Default values to be overritten
35parallel=mpi_omp
36export fcm_arch parallel xios
37full_flag=""
38full_nemo=n
39full_inca=""
40full_xios=""
41full_lmdz=""
42full_orch=""
43
44
45
46# Output text file for compilation of each component
47datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
48outfile=$submitdir/out_compile_ipslcm5a2cht.$datestr
49echo > $outfile
50echo; echo "Text output from compilation will be stored in file out_compile_ipslcm5a2cht.$datestr"; echo 
51
52#### Read arguments
53# Loop over all arguments to modify default set up
54while (($# > 0)) ; do
55    case $1 in
56        "-h") cat <<end_help
57########################################################################
58# Usage of the script compile_ipslcm5a2cht.sh
59#
60########################################################################
61
62./compile_ipslcm5a2cht.sh [Options]
63
64
65Options: [VLR ] Model resolution, choose only one. Default: VLR.
66         [-full] Full recompilation of all components. This option can be added to all other options.
67         [-cleannemo] Full recompilation of NEMO component  only.
68         [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod.
69
70
71Example 1: Default compilation of IPSLCM5A2CHT for resolution VLR and chemistry NMHC_AER_S with present version (no paleo)
72          (Resolution atmos: 96x95x39, ocean: ORCA2)
73./compile_ipslcm5a2cht.sh
74
75Example 2: Default resolution with chemistry DUSS with present version (no paleo)
76./compile_ipslcm5a2cht.sh -chimie DUSS
77
78Example 3 : compilation with ce0l
79./compile_ipslcm5a2cht.sh -chimie DUSS CE0L
80
81
82Example 4: Default resoltuion (VLR) compiled in debug mode and chemistry NMHC_AER_S
83./compile_ipslcm5a2cht.sh -debug -chimie NMHC_AER_S
84
85Example 5: Default compilation with full recompilation of all components. No clean is needed. chemistry is DUSS
86./compile_ipslcm5a2cht.sh -full -chimie DUSS
87
88Example 6: Default resolution with chemistry DUSS with paleo version
89./compile_ipslcm5a2cht.sh -chimie DUSS -paleo
90
91
92
93end_help
94exit;;
95        "VLR")         resol_atm=96x95x39; resol_oce=ORCA2 ; icemodel=lim2; oceanbio=y; shift ;;
96        "CE0L")        ce0l=y ; shift ;;
97        "-chimie")     optchimie=$2; shift ; shift;;
98        "-parallel")   parallel=$2 ; shift ; shift ;;
99        "-arch")       fcm_arch="$2" ; shift ; shift ;;
100        "-debug")      optmode=debug ; shift ;;
101        "-dev")        optmode=dev ; shift ;;
102        "-prod")       optmode=prod ; shift ;;
103        "-paleo")     paleo=y ; shift ;;
104        "-full")       full_flag="-full"; full_nemo=y ; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; shift ;;
105        "-full_xios")  full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
106        "-full_lmdz")  full_lmdz="-full"  ; shift ;;
107        "-full_orch")  full_orch="-full"  ; shift ;;
108        "-full_nemo")  full_nemo=y ; shift ;;
109        "-full_inca")  full_inca="-clean"; shift ;;
110        "-cleannemo")  full_nemo=y ; shift ;;
111        *)             echo "unknown option "$1" , exiting..." ; exit
112    esac
113done
114
115echo "Following options are set in current compiling:" >> $outfile
116echo "   resol_atm=${resol_atm}, resol_oce=${resol_oce}, icemodel=${icemodel}, ocean paleo=${paleo}" >> $outfile 
117echo "   ce0l=${ce0l}" >> $outfile 
118echo "   chemistry=${optchimie}" >> $outfile 
119echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
120echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch, full_nemo=$full_nemo," >> $outfile 
121echo >> $outfile
122
123### Read host dependent default values
124### These variables will not be changed if they were set as argument
125###./host.sh $host
126# Later : Following lines should be set in host.sh file
127# begin host.sh
128if [ $fcm_arch == default ] ; then
129    # Find out current host and source specific paths and commands for the host
130    case $( hostname -s ) in
131        jean-zay*)
132            fcm_arch=X64_JEANZAY;;
133        irene170|irene171|irene190|irene191|irene192|irene193)
134            fcm_arch=X64_IRENE;;
135        irene172|irene173|irene194|irene195)
136            fcm_arch=X64_IRENE-AMD;;
137        asterix*|obelix*)
138            fcm_arch=ifort_LSCE
139            if [ "${parallel}" == "mpi_omp" ] ; then
140                echo "Warning!! Currently at Obelix hybrid mode is not possible."
141                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
142                echo ""
143                parallel=mpi
144            else
145                echo "You used -parallel" $parallel
146            fi ;;
147        ciclad*|climserv*|loholt*|camelot*)
148            fcm_arch=ifort_CICLAD;;
149        *)
150            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
151            echo Exit now.
152            exit
153    esac
154fi
155
156# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
157# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
158if [ -f ARCH/arch-${fcm_arch}.env ] ; then
159    echo >> $outfile
160    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
161    echo "Note that this new environement might be kept after compilation." 
162    echo "If this is the case, source again your personal environment after compilation. "
163    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
164    module list   >> $outfile 2>&1
165
166    # Make a link to this file, to be used also in config.card
167    rm -f ARCH/arch.env
168    ln -s arch-${fcm_arch}.env ARCH/arch.env
169
170    # Source the file
171    source ARCH/arch.env   >> $outfile 2>&1
172    echo >> $outfile 
173    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
174    module list   >> $outfile 2>&1
175fi
176
177#### 2 Do the compilation
178## 2.1 Compile ioipsl
179cd $modipsl/modeles/IOIPSL
180echo; echo "NOW COMPILE IOIPSL"
181echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
182
183# Check if compilation with fcm is included in IOIPSL
184if [ ! -f makeioipsl_fcm ] ; then
185  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
186  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
187  exit
188fi
189
190echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
191     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
192# Test if compiling succeded
193if [[ $? != 0 ]] ; then
194    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
195    exit
196fi
197
198## 2.2 Compile oasis3-mct
199cd $modipsl/oasis3-mct/util/make_dir
200echo; echo "NOW COMPILE OASIS3-MCT"
201echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT"   >> $outfile
202cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc
203
204echo make -f TopMakefileOasis3 >> $outfile
205     make -f TopMakefileOasis3 >> $outfile 2>&1
206
207
208## 2.3 Compile xios
209cd $modipsl/modeles/XIOS
210echo; echo "NOW COMPILE XIOS"
211echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
212echo ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 
213     ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 2>&1
214# Test if compiling succeded
215if [[ $? != 0 ]] ; then
216    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
217    exit
218fi
219# Move executables to modipsl/bin
220if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
221    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
222else
223    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
224    exit
225fi
226
227
228## 2.4 Compile orchidee
229cd $modipsl/modeles/ORCHIDEE
230echo; echo "NOW COMPILE ORCHIDEE"
231echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
232
233# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
234# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
235# to ask question and wait for interactivly answer from the user.
236if [ -f build/fcm.bld.lock ] ; then
237    echo >> $outfile
238    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
239    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
240    echo "           The file will now be removed. "   >> $outfile
241    echo >> $outfile
242    rm -f build/fcm.bld.lock
243fi
244
245echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch   >> $outfile 
246        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch   >> $outfile 2>&1
247# Test if compiling finished
248if [[ $? != 0 ]] ; then
249    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
250    exit
251fi
252
253
254## 2.5 Compile NEMO
255nemo_root=$modipsl/modeles/NEMOGCM/CONFIG
256
257addkeys="key_lim2_vp key_oasis3 key_diahth key_diaar5 key_xios2"
258delkeys="key_nosignedzero"
259
260if [ ${paleo} == n ] ; then
261   echo; echo "NOW COMPILE NEMO on NO paleo version. Resolution = ${resol_oce} with icemodel ${icemodel} and  PISCES"
262   echo >> $outfile ; echo " NOW COMPILE NEMO on NO paleo version. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"   >> $outfile
263else
264   echo; echo "NOW COMPILE NEMO on paleao version. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"
265   echo >> $outfile ; echo " NOW COMPILE NEMO on paleao version. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"   >> $outfile
266fi
267
268echo >> $outfile ; echo cd $nemo_root  >> $outfile
269echo >> $outfile ; echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/arch-${fcm_arch}.fcm ../ARCH/.   >> $outfile
270echo >> $outfile
271
272cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm ../ARCH/.
273
274if [ ${resol_oce} == ORCA2 ]   ; then  cfg_wrk=ORCA2_LIM_PISCES    ; fi
275
276
277if [ ${paleo} == n ] ; then
278
279    echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/STANDARD/*.*90 $nemo_root/$cfg_wrk/MY_SRC/   >> $outfile
280    echo >> $outfile
281    cp $mysrc_path/NEMO/STANDARD/*.*90  $nemo_root/$cfg_wrk/MY_SRC/
282
283    if [ $full_nemo == y ] ; then
284        # To make a full compilation, first make a clean to remove all files produced during previous compilation
285        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk clean   >> $outfile
286        echo >> $outfile
287        ./makenemo -m ${fcm_arch} -n $cfg_wrk clean  >> $outfile 2>&1
288    fi
289    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
290    echo >> $outfile
291    ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
292
293else
294    echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/PALEO/*.*90 $nemo_root/$cfg_wrk/MY_SRC/   >> $outfile
295    echo >> $outfile
296    cp $mysrc_path/NEMO/PALEO/*.*90  $nemo_root/$cfg_wrk/MY_SRC/
297
298    if [ $full_nemo == y ] ; then
299        # To make a full compilation, first make a clean to remove all files produced during previous compilation
300        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk clean   >> $outfile
301        echo >> $outfile
302        ./makenemo -m ${fcm_arch} -n $cfg_wrk clean  >> $outfile 2>&1
303    fi
304    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
305    echo >> $outfile
306    ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
307
308fi 
309
310
311# Test if compiling finished
312if [[ $? != 0 ]] ; then
313    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
314    exit
315fi
316
317echo >> $outfile
318echo "Move nemo executable to modipsl/bin" >> $outfile
319echo ls -lrt $nemo_root/$cfg_wrk/BLD/bin   >> $outfile
320ls -lrt $nemo_root/$cfg_wrk/BLD/bin  >> $outfile
321echo >> $outfile
322
323if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ] ; then
324    if [ ${paleo} == n ]; then
325        mv $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${resol_oce}_${optmode}
326    else
327        mv $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${resol_oce}_${optmode}_paleo
328    fi
329else
330    echo "ERROR $nemo_root/$cfg_wrk/BLD/bin/nemo.exe does not exist" 
331    echo "THERE IS A PROBLEM IN  NEMO COMPILATION - STOP"
332    exit
333fi
334
335
336
337
338## 2.6 Compile LMDZ for regular latlon configuration
339## 2.6.1 Compile INCA for regular latlon configuration
340
341    cd $modipsl/modeles/INCA
342    #compile INCA regulat lat_lon chimie librairy
343    echo; echo "NOW COMPILE INCA ${chimie} on resolution = ${resol_atm}"
344    echo >> $outfile ; echo "NOW COMPILE INCA ${chimie} on resolution = ${resol_atm}"   >> $outfile
345
346    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm} -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_flag $full_inca >> $outfile 
347    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm} -j 8 -arch ${fcm_arch} -arch_path $arch_path  $full_flag $full_inca >> $outfile 2>&1
348
349    # Test if compiling finished
350    if [[ $? != 0 ]] ; then
351        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
352        exit
353    fi
354
355    echo "Move inca.dat modipsl/bin"
356    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
357        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${resol_atm}_${optmode}_${optchimie}.dat ;
358    else
359        echo "ERROR $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat does not exist"
360        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
361        exit   
362    fi
363
364
365# Compile LMDZ regular lat-lon executable
366cd $modipsl/modeles/LMDZ
367echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
368echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
369
370# Check if the compilation of LMDZ was previsouly interupted prematured.
371# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
372# to ask question and wait for interactivly answer from the user.
373if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
374  echo >> $outfile
375  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
376  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
377  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
378  echo >> $outfile
379  rm -f libf/grid/dimensions.h
380  rm -f .lock
381fi
382
383echo ./makelmdz_fcm -d ${resol_atm} -c OMCT -cosp false -rrtm true -$optmode -mem -parallel $parallel -chimie INCA -io xios -v true -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile
384./makelmdz_fcm -d ${resol_atm} -c OMCT -cosp false -rrtm true -$optmode -mem -parallel $parallel -chimie INCA -io xios -v true -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 2>&1
385
386# Test if compiling finished
387if [[ $? != 0 ]] ; then
388    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
389    exit
390fi
391
392# Move executables to modipsl/bin folder
393echo >> $outfile
394echo "Move gcm.e executable to modipsl/bin" >> $outfile
395echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
396ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
397echo >> $outfile
398    suffix=_${resol_atm}_phylmd_para_mem_orch_couple_inca.e
399echo gcm suffix = $suffix
400
401if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
402    mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_${optchimie}.e
403else
404    echo "ERROR gcm${suffix} executable does not exist." 
405    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
406    exit
407fi 
408
409
410# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
411if [ $ce0l == y ] ; then
412    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
413    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
414   
415    echo ./makelmdz_fcm -c OMCT -d ${resol_atm} -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
416    ./makelmdz_fcm -c OMCT -d ${resol_atm} -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 2>&1
417    # Test if compiling finished
418    if [[ $? != 0 ]] ; then
419        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
420        exit
421    fi
422
423
424    # Move executables to modipsl/bin folder
425    echo >> $outfile
426    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
427    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
428    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
429    echo >> $outfile
430    suffix=_${resol_atm}_phylmd_seq_couple.e
431    echo ce0l suffix = $suffix
432
433    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
434        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
435    else
436        echo "ERROR ce0l${suffix} executable does not exist." 
437        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
438        exit
439    fi 
440fi
441
442echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
443echo ls -lrt modipsl/bin >> $outfile
444ls -lrt $modipsl/bin >> $outfile
445
446echo; echo "ALL COMPILING FINISHED" ; echo
447echo "Executables are found in modipsl/bin"
448echo "Check that executable names correspond with the name set in config.card before launching the job"
449echo ls -lrt modipsl/bin
450ls -lrt $modipsl/bin
451
452date
453
454exit
455
456
Note: See TracBrowser for help on using the repository browser.