source: CONFIG/UNIFORM/v6/IPSLCM6.2/compile_ipslcm6.sh @ 4616

Last change on this file since 4616 was 4611, checked in by cetlod, 5 years ago

Improvment of compilation script : Add NEMO configurations & OASIS-MCT. Still a preliminary version

  • Property svn:executable set to *
File size: 12.7 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=144x142x79
18# Oceanic resolution, for NEMO (ORCA2/ORCA1/ORCA025)
19resol_oce=ORCA1
20# Version of ice model lim2/lim3
21icemodel=lim3
22# Coupled with ocean biogeochemistry (y/n)
23oceanbio=y
24# Version ESM CO2: CO2 interactif ocean/atmosphere (y/n)
25esmco2=n
26
27# Optimization mode
28# optmode=prod/dev/debug
29optmode=prod
30# fcm_arch
31fcm_arch=default
32# Default values to be overritten
33parallel=mpi_omp
34export fcm_arch parallel xios
35full_flag=""
36full_nemo=n
37# Default netcdf_lib is used for XIOS but can be change by argument
38netcdf_lib=""
39
40# Output text file for compilation of each component
41outfile=$submitdir/out_compile_ipslcm6
42rm -f $outfile; echo > $outfile
43echo; echo "Text output from compilation will be stored in file out_compile_ipslcm6"; echo 
44
45#### Read arguments
46# Loop over all arguments to modify default set up
47while (($# > 0)) ; do
48    case $1 in
49        "-h") cat <<fin
50
51########################################################################
52# Usage of the script compile_ipslcm6.sh
53#
54########################################################################
55
56./compile_ipslcm6.sh [Options]
57
58
59Options: [LR / VLR / MR1 / MR025] Model resolution, choose only one. Default: LR.
60         [ESMCO2] Compile IPSLCM6 for CO2 interactif ocean/atmosphere.
61         [-full] Full recompilation of all components. This option can be added to all other options.
62         [-cleannemo] Full recompilation of NEMO component  only.
63         [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod.
64
65
66Example 1: Default compilation of IPSLCM6 for resoltion LR
67          (Resolution atmos: 144x142x79, ocean: ORCA1)
68./compile_ipslcm6.sh
69
70Example 2: Compilation of IPSLCM6 for resolution MR025
71           (atmos: 256x256x79, ocean: ORCA025, NOPISCES)
72./compile_ipslcm6.sh MR025
73
74Example 3: Compilation of IPSLCM6 for ESM CO2
75./compile_ipslcm6.sh ESMCO2 -cleannemo
76
77Example 4: Default resoltuion (LR) compiled in debug mode
78./compile_ipslcm6.sh -debug
79
80Example 5: Default compilation with full recompilation of all components. No clean is needed.
81./compile_ipslcm6.sh -full
82
83Example 6: Full recompilation of resolution MR05 in debug mode
84./compile_ipslcm6.sh MR025 -debug -full
85
86fin
87            exit;;
88
89   "VLR")
90        resol_atm=96x95x39; resol_oce=ORCA2 ; icemodel=lim2; oceanbio=y; shift ;;
91
92    "LR")
93        resol_atm=144x142x79; resol_oce=ORCA1 ; icemodel=lim3; oceanbio=y; shift ;;
94
95    "MR1")
96        resol_atm=256x256x79; resol_oce=ORCA1 ; icemodel=lim3; oceanbio=y; shift ;;
97
98    "MR025")
99        resol_atm=256x256x79; resol_oce=ORCA025 ; icemodel=lim3; oceanbio=n;   shift ;;
100
101    "ESMCO2")
102            esmco2=y;  shift ;;
103
104        "-parallel")
105            parallel=$2 ; shift ; shift ;;
106       
107        "-arch")
108            fcm_arch="$2" ; shift ; shift ;;
109       
110        "-debug")
111            optmode=debug ; shift ;;
112
113        "-dev")
114            optmode=dev ; shift ;;
115
116        "-prod")
117            optmode=prod ; shift ;;
118
119    "-full")
120        full_flag="-full"; full_nemo=y ; shift ;;
121
122    "-cleannemo")
123        full_nemo=y ; shift ;;
124       
125        "-netcdf_lib_seq")
126            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
127
128        *)
129            echo "unknown option "$2" , exiting..."
130            exit
131    esac
132done
133
134echo "Following options are set in current compiling:" >> $outfile 
135echo "   resol_atm=${resol_atm}, resol_oce=${resol_oce}, icemodel=${icemodel}, withpisces=${pisces}" >> $outfile 
136echo "   esmco2=${esmco2}" >> $outfile 
137echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag" >> $outfile 
138echo >> $outfile
139
140### Read host dependent default values
141### These variables will not be changed if they were set as argument
142###./host.sh $host
143# Later : Following lines should be set in host.sh file
144# begin host.sh
145if [ $fcm_arch == default ] ; then
146    # Find out current host and source specific paths and commands for the host
147    case $( hostname -s ) in
148        ada*)
149            fcm_arch=X64_ADA;;
150        irene*)
151            fcm_arch=X64_IRENE;;
152        asterix*|obelix*)
153            fcm_arch=ifort_LSCE;;
154        ciclad*|climserv*)
155            fcm_arch=ifort_CICLAD;;
156        *)
157            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
158            echo Exit now.
159            exit
160    esac
161fi
162
163# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
164# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
165if [ -f ARCH/arch-${fcm_arch}.env ] ; then
166    echo >> $outfile
167    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components"
168    echo "Note that this new environement might be kept after compilation." 
169    echo "If this is the case, source again your personal environment after compilation. "
170    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
171    module list   >> $outfile 2>&1
172
173    # Make a link to this file, to be used also in config.card
174    rm -f ARCH/arch.env
175    ln -s arch-${fcm_arch}.env ARCH/arch.env
176
177    # Source the file
178    source ARCH/arch.env   >> $outfile 2>&1
179    echo >> $outfile 
180    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
181    module list   >> $outfile 2>&1
182fi
183
184#### 2 Do the compilation
185## 2.1 Compile ioipsl
186cd $modipsl/modeles/IOIPSL
187echo; echo "NOW COMPILE IOIPSL"
188echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
189
190# Check if compilation with fcm is included in IOIPSL
191if [ ! -f makeioipsl_fcm ] ; then
192  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
193  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
194  exit
195fi
196
197echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
198     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
199# Test if compiling succeded
200if [[ $? != 0 ]] ; then
201    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
202    exit
203fi
204
205## 2.2 Compile oasis3-mct
206oasis_dir=$modipsl/oasis3-mct
207echo; echo "NOW COMPILE OASIS3-MCT"
208echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT"   >> $outfile
209cd $oasis_dir/util/make_dir  ; cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc  ; make -f TopMakefileOasis3 ;
210
211## 2.3 Compile xios
212cd $modipsl/modeles/XIOS
213echo; echo "NOW COMPILE XIOS"
214echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
215echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
216     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
217# Test if compiling succeded
218if [[ $? != 0 ]] ; then
219    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
220    exit
221fi
222# Move executables to modipsl/bin
223if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
224    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
225else
226    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
227    exit
228fi
229
230
231## 2.4 Compile orchidee
232cd $modipsl/modeles/ORCHIDEE
233echo; echo "NOW COMPILE ORCHIDEE"
234echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
235
236echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
237        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
238# Test if compiling finished
239if [[ $? != 0 ]] ; then
240    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
241    exit
242fi
243
244
245## 2.5 Compile NEMO
246nemo_root=$modipsl/modeles/NEMOGCM/CONFIG
247if [ ${icemodel} == lim2 ] ; then
248   addkeys="key_lim2_vp key_diahth key_oasis3"
249   delkeys="key_nosignedzero key_mpp_rep"
250else
251   addkeys="key_top key_pisces key_age key_cfc key_cpl_carbon_cycle key_gas key_oasis"
252   if [ ${oceanbio} == y ] ; then
253      if [ ${esmco2} == y ] ; then
254         delkeys="key_nosignedzero key_mpp_rep"
255      else
256         delkeys="key_nosignedzero key_mpp_rep key_cpl_carbon_cycle key_gas"
257      fi
258   else
259      delkeys="key_nosignedzero key_mpp_rep key_top key_pisces key_cfc key_age key_cpl_carbon_cycle key_gas"
260   fi
261fi
262
263if [ ${oceanbio} == n ] ; then
264   echo; echo "NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and without PISCES"
265   echo >> $outfile ; echo " NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and without PISCES"   >> $outfile
266else
267   echo; echo "NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"
268   echo >> $outfile ; echo " NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"   >> $outfile
269fi
270echo >> $outfile ; echo cd $nemo_root  >> $outfile
271echo >> $outfile ; echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/arch-${fcm_arch}.fcm ../ARCH/.   >> $outfile
272echo >> $outfile
273
274cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm ../ARCH/.
275
276if [ ${resol_oce} == ORCA2 ]   ; then  cfg_wrk=ORCA2_LIM_PISCES    ; fi
277if [ ${resol_oce} == ORCA1 ]   ; then  cfg_wrk=ORCA1_LIM3_PISCES    ; fi
278if [ ${resol_oce} == ORCA025 ] ; then  cfg_wrk=ORCA025_LIM3_PISCES  ; fi
279
280echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/*.*90 $nemo_root/$cfg_wrk/MY_SRC/   >> $outfile
281echo >> $outfile
282cp $mysrc_path/NEMO/*.*90  $nemo_root/$cfg_wrk/MY_SRC/
283
284if [ $full_nemo == y ] ; then
285   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk clean   >> $outfile
286   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
287   echo >> $outfile
288   ./makenemo -m ${fcm_arch} -n $cfg_wrk clean  >> $outfile 2>&1
289   ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
290else
291   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
292   echo >> $outfile
293   ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
294fi
295
296# Test if compiling finished
297if [[ $? != 0 ]] ; then
298    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
299    exit
300fi
301
302echo
303echo "copy nemo executable to modipsl/bin"
304if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ]                       ;  then cp $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa     ; fi
305if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ] && [ ${esmco2} == y ] ;  then cp $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa.esm ; fi
306
307
308## 2.6 Compile LMDZ for regular latlon configuration
309cd $modipsl/modeles/LMDZ
310# Compile LMDZ regular lat-lon exectuable
311echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
312echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
313
314echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 
315./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 2>&1
316# Test if compiling finished
317if [[ $? != 0 ]] ; then
318    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
319    exit
320fi
321
322# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
323echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
324echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
325   
326echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l    >> $outfile 
327./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l    >> $outfile 2>&1
328# Test if compiling finished
329if [[ $? != 0 ]] ; then
330    echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
331    exit
332fi
333
334# Find executable suffix
335if [ $parallel == seq ] || [ $parallel == none ] ; then
336    suffix=_${resol_atm}_phylmd_seq_orch
337else
338    suffix=_${resol_atm}_phylmd_para_mem_orch
339fi
340echo suffix = $suffix
341
342# Move executables to modipsl/bin folder
343echo "Move gcm.e and ce0l executable to modipsl/bin"
344if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm}_${optmode}.e ; fi
345if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm}_${optmode}.e ; fi
346
347
348echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
349echo; echo "ALL COMPILING FINISHED"
350
351date
352exit
353
354
Note: See TracBrowser for help on using the repository browser.