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

Last change on this file since 6032 was 6032, checked in by acosce, 2 years ago

create new configuration for IPSLCM5A2CHT model :

1- this configuration will allow to done paleo experiment (need to be done)
2- compilation will be done with script like v6.2 configurations

File size: 17.2 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
329fi
330
331
332
333
334## 2.6 Compile LMDZ for regular latlon configuration
335## 2.6.1 Compile INCA for regular latlon configuration
336
337    cd $modipsl/modeles/INCA
338    #compile INCA regulat lat_lon chimie librairy
339    echo; echo "NOW COMPILE INCA ${chimie} on resolution = ${resol_atm}"
340    echo >> $outfile ; echo "NOW COMPILE INCA ${chimie} on resolution = ${resol_atm}"   >> $outfile
341
342    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 
343    ./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
344
345    # Test if compiling finished
346    if [[ $? != 0 ]] ; then
347        echo "1- THERE IS A PROBLEM IN INCA COMPILATION - STOP"
348        exit
349    fi
350
351    echo "Move inca.dat modipsl/bin"
352    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
353        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${resol_atm}_${optmode}_${optchimie}.dat ;
354    else
355        echo "2- THERE IS A PROBLEM IN INCA COMPILATION - STOP"
356        exit   
357    fi
358
359
360# Compile LMDZ regular lat-lon executable
361cd $modipsl/modeles/LMDZ
362echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
363echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
364
365# Check if the compilation of LMDZ was previsouly interupted prematured.
366# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
367# to ask question and wait for interactivly answer from the user.
368if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
369  echo >> $outfile
370  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
371  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
372  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
373  echo >> $outfile
374  rm -f libf/grid/dimensions.h
375  rm -f .lock
376fi
377
378echo ./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
379./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
380
381# Test if compiling finished
382if [[ $? != 0 ]] ; then
383    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
384    exit
385fi
386
387# Move executables to modipsl/bin folder
388echo >> $outfile
389echo "Move gcm.e executable to modipsl/bin" >> $outfile
390echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
391ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
392echo >> $outfile
393    suffix=_${resol_atm}_phylmd_para_mem_orch_couple_inca.e
394echo gcm suffix = $suffix
395
396if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
397    mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_${optchimie}.e
398else
399    echo "ERROR gcm${suffix} executable does not exist." 
400    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
401    exit
402fi 
403
404
405# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
406if [ $ce0l == y ] ; then
407    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
408    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
409   
410    echo ./makelmdz_fcm -d ${resol_atm} -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
411    ./makelmdz_fcm -d ${resol_atm} -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 2>&1
412    # Test if compiling finished
413    if [[ $? != 0 ]] ; then
414        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
415        exit
416    fi
417
418
419    # Move executables to modipsl/bin folder
420    echo >> $outfile
421    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
422    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
423    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
424    echo >> $outfile
425#    suffix=_${resol_atm}_phylmd_para_mem_orch_couple.e
426    suffix=_${resol_atm}_phylmd_seq.e
427    echo ce0l suffix = $suffix
428
429    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
430        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
431    else
432        echo "ERROR ce0l${suffix} executable does not exist." 
433        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
434        exit
435    fi 
436fi
437
438echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
439echo ls -lrt modipsl/bin >> $outfile
440ls -lrt $modipsl/bin >> $outfile
441
442echo; echo "ALL COMPILING FINISHED" ; echo
443echo "Executables are found in modipsl/bin"
444echo "Check that executable names correspond with the name set in config.card before launching the job"
445echo ls -lrt modipsl/bin
446ls -lrt $modipsl/bin
447
448date
449
450exit
451
452
Note: See TracBrowser for help on using the repository browser.