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

Last change on this file since 4918 was 4707, checked in by acosce, 5 years ago

update IPSLCM6 - ESMAER experiment

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