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
RevLine 
[4268]1#!/bin/bash
2#set -vx
3# Default options
4#
5#
6#
[4409]7date
[4268]8#### 1  Set up the compiling options
9#### Define some directories
10submitdir=$( pwd )
11modipsl=$submitdir/../..
[4275]12arch_path=$submitdir/ARCH
[4611]13mysrc_path=$submitdir/SOURCES
[4268]14
[4278]15#### Set default options
[4471]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
[4611]21icemodel=lim3
22# Coupled with ocean biogeochemistry (y/n)
23oceanbio=y
[4471]24# Version ESM CO2: CO2 interactif ocean/atmosphere (y/n)
25esmco2=n
26
[4268]27# Optimization mode
28# optmode=prod/dev/debug
29optmode=prod
30# fcm_arch
31fcm_arch=default
32# Default values to be overritten
[4339]33parallel=mpi_omp
[4268]34export fcm_arch parallel xios
35full_flag=""
[4611]36full_nemo=n
[4391]37# Default netcdf_lib is used for XIOS but can be change by argument
38netcdf_lib=""
[4268]39
[4408]40# Output text file for compilation of each component
[4471]41outfile=$submitdir/out_compile_ipslcm6
[4408]42rm -f $outfile; echo > $outfile
[4471]43echo; echo "Text output from compilation will be stored in file out_compile_ipslcm6"; echo 
[4408]44
[4278]45#### Read arguments
[4268]46# Loop over all arguments to modify default set up
47while (($# > 0)) ; do
[4278]48    case $1 in
49        "-h") cat <<fin
[4268]50
51########################################################################
[4471]52# Usage of the script compile_ipslcm6.sh
[4268]53#
54########################################################################
55
[4471]56./compile_ipslcm6.sh [Options]
[4268]57
58
[4611]59Options: [LR / VLR / MR1 / MR025] Model resolution, choose only one. Default: LR.
[4471]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.
[4611]62         [-cleannemo] Full recompilation of NEMO component  only.
[4471]63         [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod.
[4268]64
[4407]65
[4471]66Example 1: Default compilation of IPSLCM6 for resoltion LR
67          (Resolution atmos: 144x142x79, ocean: ORCA1)
68./compile_ipslcm6.sh
[4268]69
[4471]70Example 2: Compilation of IPSLCM6 for resolution MR025
71           (atmos: 256x256x79, ocean: ORCA025, NOPISCES)
72./compile_ipslcm6.sh MR025
[4268]73
[4471]74Example 3: Compilation of IPSLCM6 for ESM CO2
[4611]75./compile_ipslcm6.sh ESMCO2 -cleannemo
[4471]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
[4278]86fin
87            exit;;
[4268]88
[4611]89   "VLR")
90        resol_atm=96x95x39; resol_oce=ORCA2 ; icemodel=lim2; oceanbio=y; shift ;;
[4471]91
[4611]92    "LR")
93        resol_atm=144x142x79; resol_oce=ORCA1 ; icemodel=lim3; oceanbio=y; shift ;;
[4471]94
[4611]95    "MR1")
96        resol_atm=256x256x79; resol_oce=ORCA1 ; icemodel=lim3; oceanbio=y; shift ;;
[4471]97
[4611]98    "MR025")
99        resol_atm=256x256x79; resol_oce=ORCA025 ; icemodel=lim3; oceanbio=n;   shift ;;
100
101    "ESMCO2")
[4471]102            esmco2=y;  shift ;;
103
[4278]104        "-parallel")
105            parallel=$2 ; shift ; shift ;;
106       
107        "-arch")
108            fcm_arch="$2" ; shift ; shift ;;
109       
[4407]110        "-debug")
111            optmode=debug ; shift ;;
112
113        "-dev")
114            optmode=dev ; shift ;;
115
116        "-prod")
117            optmode=prod ; shift ;;
118
[4611]119    "-full")
120        full_flag="-full"; full_nemo=y ; shift ;;
121
122    "-cleannemo")
123        full_nemo=y ; shift ;;
[4278]124       
[4391]125        "-netcdf_lib_seq")
126            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
127
[4278]128        *)
129            echo "unknown option "$2" , exiting..."
130            exit
131    esac
132done
[4268]133
[4471]134echo "Following options are set in current compiling:" >> $outfile 
[4611]135echo "   resol_atm=${resol_atm}, resol_oce=${resol_oce}, icemodel=${icemodel}, withpisces=${pisces}" >> $outfile 
[4471]136echo "   esmco2=${esmco2}" >> $outfile 
137echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag" >> $outfile 
[4408]138echo >> $outfile
[4268]139
[4278]140### Read host dependent default values
141### These variables will not be changed if they were set as argument
[4268]142###./host.sh $host
143# Later : Following lines should be set in host.sh file
144# begin host.sh
145if [ $fcm_arch == default ] ; then
[4278]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*)
[4391]151            fcm_arch=X64_IRENE;;
[4278]152        asterix*|obelix*)
153            fcm_arch=ifort_LSCE;;
[4391]154        ciclad*|climserv*)
155            fcm_arch=ifort_CICLAD;;
[4278]156        *)
[4391]157            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
[4278]158            echo Exit now.
159            exit
160    esac
[4268]161fi
162
[4452]163# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
[4391]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
[4408]166    echo >> $outfile
[4470]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
[4391]174    rm -f ARCH/arch.env
175    ln -s arch-${fcm_arch}.env ARCH/arch.env
[4470]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
[4391]182fi
183
[4268]184#### 2 Do the compilation
185## 2.1 Compile ioipsl
186cd $modipsl/modeles/IOIPSL
[4278]187echo; echo "NOW COMPILE IOIPSL"
[4408]188echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
189
[4411]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
[4408]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
[4268]199# Test if compiling succeded
200if [[ $? != 0 ]] ; then
[4278]201    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
202    exit
[4268]203fi
204
[4611]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
[4268]212cd $modipsl/modeles/XIOS
[4278]213echo; echo "NOW COMPILE XIOS"
[4408]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
[4268]217# Test if compiling succeded
218if [[ $? != 0 ]] ; then
[4278]219    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
220    exit
[4268]221fi
[4391]222# Move executables to modipsl/bin
[4457]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
[4391]225else
226    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
227    exit
228fi
[4268]229
[4391]230
[4611]231## 2.4 Compile orchidee
[4268]232cd $modipsl/modeles/ORCHIDEE
[4278]233echo; echo "NOW COMPILE ORCHIDEE"
[4408]234echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
235
[4452]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
[4268]238# Test if compiling finished
239if [[ $? != 0 ]] ; then
240    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
241    exit
242fi
243
[4408]244
[4611]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
[4469]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 
[4268]313
[4469]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
[4408]321
[4469]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
[4278]333
[4469]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
[4408]341
[4469]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
[4278]346
[4268]347
[4408]348echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
349echo; echo "ALL COMPILING FINISHED"
[4278]350
[4409]351date
[4268]352exit
353
354
Note: See TracBrowser for help on using the repository browser.