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

Last change on this file since 4626 was 4626, checked in by jgipsl, 5 years ago

Corrections to compile for coupled mode.

  • Property svn:executable set to *
File size: 13.6 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
207oasis_dir=$modipsl/oasis3-mct
208echo; echo "NOW COMPILE OASIS3-MCT"
209echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT"   >> $outfile
210cd $oasis_dir/util/make_dir  ; cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc  ; make -f TopMakefileOasis3 ;
211
212## 2.3 Compile xios
213cd $modipsl/modeles/XIOS
214echo; echo "NOW COMPILE XIOS"
215echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
216echo ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
217     ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
218# Test if compiling succeded
219if [[ $? != 0 ]] ; then
220    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
221    exit
222fi
223# Move executables to modipsl/bin
224if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
225    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
226else
227    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
228    exit
229fi
230
231
232## 2.4 Compile orchidee
233cd $modipsl/modeles/ORCHIDEE
234echo; echo "NOW COMPILE ORCHIDEE"
235echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
236
237echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
238        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
239# Test if compiling finished
240if [[ $? != 0 ]] ; then
241    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
242    exit
243fi
244
245
246## 2.5 Compile NEMO
247nemo_root=$modipsl/modeles/NEMOGCM/CONFIG
248if [ ${icemodel} == lim2 ] ; then
249   addkeys="key_lim2_vp key_diahth key_oasis3"
250   delkeys="key_nosignedzero key_mpp_rep"
251else
252   addkeys="key_top key_pisces key_age key_cfc key_cpl_carbon_cycle key_gas key_oasis3"
253   if [ ${oceanbio} == y ] ; then
254      if [ ${esmco2} == y ] ; then
255         delkeys="key_nosignedzero key_mpp_rep"
256      else
257         delkeys="key_nosignedzero key_mpp_rep key_cpl_carbon_cycle key_gas"
258      fi
259   else
260      delkeys="key_nosignedzero key_mpp_rep key_top key_pisces key_cfc key_age key_cpl_carbon_cycle key_gas"
261   fi
262fi
263
264if [ ${oceanbio} == n ] ; then
265   echo; echo "NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and without PISCES"
266   echo >> $outfile ; echo " NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and without PISCES"   >> $outfile
267else
268   echo; echo "NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"
269   echo >> $outfile ; echo " NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"   >> $outfile
270fi
271echo >> $outfile ; echo cd $nemo_root  >> $outfile
272echo >> $outfile ; echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/arch-${fcm_arch}.fcm ../ARCH/.   >> $outfile
273echo >> $outfile
274
275cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm ../ARCH/.
276
277if [ ${resol_oce} == ORCA2 ]   ; then  cfg_wrk=ORCA2_LIM_PISCES    ; fi
278if [ ${resol_oce} == ORCA1 ]   ; then  cfg_wrk=ORCA1_LIM3_PISCES    ; fi
279if [ ${resol_oce} == ORCA025 ] ; then  cfg_wrk=ORCA025_LIM3_PISCES  ; fi
280
281echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/*.*90 $nemo_root/$cfg_wrk/MY_SRC/   >> $outfile
282echo >> $outfile
283cp $mysrc_path/NEMO/*.*90  $nemo_root/$cfg_wrk/MY_SRC/
284
285if [ $full_nemo == y ] ; then
286   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk clean   >> $outfile
287   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
288   echo >> $outfile
289   ./makenemo -m ${fcm_arch} -n $cfg_wrk clean  >> $outfile 2>&1
290   ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
291else
292   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
293   echo >> $outfile
294   ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
295fi
296
297# Test if compiling finished
298if [[ $? != 0 ]] ; then
299    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
300    exit
301fi
302
303echo
304echo "copy nemo executable to modipsl/bin"
305if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ]                       ;  then cp $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa     ; fi
306if [ -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
307
308
309## 2.6 Compile LMDZ for regular latlon configuration
310cd $modipsl/modeles/LMDZ
311# Compile LMDZ regular lat-lon exectuable
312echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
313echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
314
315# Check if the compilation of LMDZ was previsouly interupted prematured.
316# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
317# to ask question and wait for interactivly answer from the user.
318if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
319  echo >> $outfile
320  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
321  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
322  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
323  echo >> $outfile
324  rm -f libf/grid/dimensions.h
325  rm -f .lock
326fi
327
328echo ./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 
329     ./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
330# Test if compiling finished
331if [[ $? != 0 ]] ; then
332    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
333    exit
334fi
335
336# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
337echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
338echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
339   
340echo ./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 
341./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
342# Test if compiling finished
343if [[ $? != 0 ]] ; then
344    echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
345    exit
346fi
347
348# Find executable suffix
349if [ $parallel == seq ] || [ $parallel == none ] ; then
350    suffix=_${resol_atm}_phylmd_seq_orch
351else
352    suffix=_${resol_atm}_phylmd_para_mem_orch
353fi
354echo suffix = $suffix
355
356# Move executables to modipsl/bin folder
357echo "Move gcm.e and ce0l executable to modipsl/bin"
358if [ -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
359if [ -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
360
361
362echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
363echo; echo "ALL COMPILING FINISHED"
364
365date
366exit
367
368
Note: See TracBrowser for help on using the repository browser.