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

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