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

Last change on this file since 6238 was 6238, checked in by acosce, 20 months ago

fixed 2 bug in IPSLCM5A2CHT.2 configuration

  • add a "mkdir" command in compilation script
  • ConfExp? wasn't known by driver card, correct its syntax
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    mkdir -p $nemo_root/$cfg_wrk/MY_SRC/
282    cp $mysrc_path/NEMO/STANDARD/*.*90  $nemo_root/$cfg_wrk/MY_SRC/
283
284    if [ $full_nemo == y ] ; then
285        # To make a full compilation, first make a clean to remove all files produced during previous compilation
286        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk clean   >> $outfile
287        echo >> $outfile
288        ./makenemo -m ${fcm_arch} -n $cfg_wrk clean  >> $outfile 2>&1
289    fi
290    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
291    echo >> $outfile
292    ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
293
294else
295    echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/PALEO/*.*90 $nemo_root/$cfg_wrk/MY_SRC/   >> $outfile
296    echo >> $outfile
297    cp $mysrc_path/NEMO/PALEO/*.*90  $nemo_root/$cfg_wrk/MY_SRC/
298
299    if [ $full_nemo == y ] ; then
300        # To make a full compilation, first make a clean to remove all files produced during previous compilation
301        echo ./makenemo -m ${fcm_arch} -n $cfg_wrk clean   >> $outfile
302        echo >> $outfile
303        ./makenemo -m ${fcm_arch} -n $cfg_wrk clean  >> $outfile 2>&1
304    fi
305    echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
306    echo >> $outfile
307    ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
308
309fi 
310
311
312# Test if compiling finished
313if [[ $? != 0 ]] ; then
314    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
315    exit
316fi
317
318echo >> $outfile
319echo "Move nemo executable to modipsl/bin" >> $outfile
320echo ls -lrt $nemo_root/$cfg_wrk/BLD/bin   >> $outfile
321ls -lrt $nemo_root/$cfg_wrk/BLD/bin  >> $outfile
322echo >> $outfile
323
324if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ] ; then
325    if [ ${paleo} == n ]; then
326        mv $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${resol_oce}_${optmode}
327    else
328        mv $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${resol_oce}_${optmode}_paleo
329    fi
330else
331    echo "ERROR $nemo_root/$cfg_wrk/BLD/bin/nemo.exe does not exist" 
332    echo "THERE IS A PROBLEM IN  NEMO COMPILATION - STOP"
333    exit
334fi
335
336
337
338
339## 2.6 Compile LMDZ for regular latlon configuration
340## 2.6.1 Compile INCA for regular latlon configuration
341
342    cd $modipsl/modeles/INCA
343    #compile INCA regulat lat_lon chimie librairy
344    echo; echo "NOW COMPILE INCA ${chimie} on resolution = ${resol_atm}"
345    echo >> $outfile ; echo "NOW COMPILE INCA ${chimie} on resolution = ${resol_atm}"   >> $outfile
346
347    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 
348    ./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
349
350    # Test if compiling finished
351    if [[ $? != 0 ]] ; then
352        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
353        exit
354    fi
355
356    echo "Move inca.dat modipsl/bin"
357    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
358        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${resol_atm}_${optmode}_${optchimie}.dat ;
359    else
360        echo "ERROR $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat does not exist"
361        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
362        exit   
363    fi
364
365
366# Compile LMDZ regular lat-lon executable
367cd $modipsl/modeles/LMDZ
368echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
369echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
370
371# Check if the compilation of LMDZ was previsouly interupted prematured.
372# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
373# to ask question and wait for interactivly answer from the user.
374if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
375  echo >> $outfile
376  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
377  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
378  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
379  echo >> $outfile
380  rm -f libf/grid/dimensions.h
381  rm -f .lock
382fi
383
384echo ./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
385./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
386
387# Test if compiling finished
388if [[ $? != 0 ]] ; then
389    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
390    exit
391fi
392
393# Move executables to modipsl/bin folder
394echo >> $outfile
395echo "Move gcm.e executable to modipsl/bin" >> $outfile
396echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
397ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
398echo >> $outfile
399    suffix=_${resol_atm}_phylmd_para_mem_orch_couple_inca.e
400echo gcm suffix = $suffix
401
402if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
403    mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_${optchimie}.e
404else
405    echo "ERROR gcm${suffix} executable does not exist." 
406    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
407    exit
408fi 
409
410
411# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
412if [ $ce0l == y ] ; then
413    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
414    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
415   
416    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 
417    ./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
418    # Test if compiling finished
419    if [[ $? != 0 ]] ; then
420        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
421        exit
422    fi
423
424
425    # Move executables to modipsl/bin folder
426    echo >> $outfile
427    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
428    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
429    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
430    echo >> $outfile
431    suffix=_${resol_atm}_phylmd_seq_couple.e
432    echo ce0l suffix = $suffix
433
434    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
435        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
436    else
437        echo "ERROR ce0l${suffix} executable does not exist." 
438        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
439        exit
440    fi 
441fi
442
443echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
444echo ls -lrt modipsl/bin >> $outfile
445ls -lrt $modipsl/bin >> $outfile
446
447echo; echo "ALL COMPILING FINISHED" ; echo
448echo "Executables are found in modipsl/bin"
449echo "Check that executable names correspond with the name set in config.card before launching the job"
450echo ls -lrt modipsl/bin
451ls -lrt $modipsl/bin
452
453date
454
455exit
456
457
Note: See TracBrowser for help on using the repository browser.