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

Last change on this file since 5025 was 5020, checked in by jgipsl, 4 years ago

Correction to compile ce0l: it is necessary to keep the option -c OMCT also for ce0l

  • Property svn:executable set to *
File size: 17.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}, esmaer=${esmaer}" >> $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        jean-zay*)
137            fcm_arch=X64_JEANZAY;;
138        irene*)
139            fcm_arch=X64_IRENE;;
140        asterix*|obelix*)
141            fcm_arch=ifort_LSCE
142            if [ "${parallel}" == "mpi_omp" ] ; then
143                echo "Warning!! Currently at Obelix hybrid mode is not possible."
144                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
145                echo ""
146                parallel=mpi
147            else
148                echo "You used -parallel" $parallel
149            fi ;;
150        ciclad*|climserv*|loholt*|camelot*)
151            fcm_arch=ifort_CICLAD;;
152        *)
153            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
154            echo Exit now.
155            exit
156    esac
157fi
158
159# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
160# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
161if [ -f ARCH/arch-${fcm_arch}.env ] ; then
162    echo >> $outfile
163    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
164    echo "Note that this new environement might be kept after compilation." 
165    echo "If this is the case, source again your personal environment after compilation. "
166    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
167    module list   >> $outfile 2>&1
168
169    # Make a link to this file, to be used also in config.card
170    rm -f ARCH/arch.env
171    ln -s arch-${fcm_arch}.env ARCH/arch.env
172
173    # Source the file
174    source ARCH/arch.env   >> $outfile 2>&1
175    echo >> $outfile 
176    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
177    module list   >> $outfile 2>&1
178fi
179
180#### 2 Do the compilation
181## 2.1 Compile ioipsl
182cd $modipsl/modeles/IOIPSL
183echo; echo "NOW COMPILE IOIPSL"
184echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
185
186# Check if compilation with fcm is included in IOIPSL
187if [ ! -f makeioipsl_fcm ] ; then
188  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
189  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
190  exit
191fi
192
193echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
194     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
195# Test if compiling succeded
196if [[ $? != 0 ]] ; then
197    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
198    exit
199fi
200
201## 2.2 Compile oasis3-mct
202cd $modipsl/oasis3-mct/util/make_dir
203echo; echo "NOW COMPILE OASIS3-MCT"
204echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT"   >> $outfile
205cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc
206
207echo make -f TopMakefileOasis3 >> $outfile
208     make -f TopMakefileOasis3 >> $outfile 2>&1
209
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 --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 
216     ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $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
236# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
237# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
238# to ask question and wait for interactivly answer from the user.
239if [ -f build/fcm.bld.lock ] ; then
240    echo >> $outfile
241    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
242    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
243    echo "           The file will now be removed. "   >> $outfile
244    echo >> $outfile
245    rm -f build/fcm.bld.lock
246fi
247
248echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch   >> $outfile 
249        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch   >> $outfile 2>&1
250# Test if compiling finished
251if [[ $? != 0 ]] ; then
252    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
253    exit
254fi
255
256
257## 2.5 Compile NEMO
258nemo_root=$modipsl/modeles/NEMOGCM/CONFIG
259if [ ${icemodel} == lim2 ] ; then
260   addkeys="key_lim2_vp key_diahth key_oasis3"
261   delkeys="key_nosignedzero key_mpp_rep"
262else
263   addkeys="key_top key_pisces key_age key_cfc key_cpl_carbon_cycle key_gas key_oasis3"
264   if [ ${oceanbio} == y ] ; then
265      if [ ${esmco2} == y ] ; then
266         delkeys="key_nosignedzero key_mpp_rep"
267      else
268         delkeys="key_nosignedzero key_mpp_rep key_cpl_carbon_cycle key_gas"
269      fi
270   else
271      delkeys="key_nosignedzero key_mpp_rep key_top key_pisces key_cfc key_age key_cpl_carbon_cycle key_gas"
272   fi
273fi
274
275if [ ${oceanbio} == n ] ; then
276   echo; echo "NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and without PISCES"
277   echo >> $outfile ; echo " NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and without PISCES"   >> $outfile
278else
279   echo; echo "NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"
280   echo >> $outfile ; echo " NOW COMPILE NEMO. Resolution = ${resol_oce} with icemodel ${icemodel} and PISCES"   >> $outfile
281fi
282echo >> $outfile ; echo cd $nemo_root  >> $outfile
283echo >> $outfile ; echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/arch-${fcm_arch}.fcm ../ARCH/.   >> $outfile
284echo >> $outfile
285
286cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm ../ARCH/.
287
288if [ ${resol_oce} == ORCA2 ]   ; then  cfg_wrk=ORCA2_LIM_PISCES    ; fi
289if [ ${resol_oce} == ORCA1 ]   ; then  cfg_wrk=ORCA1_LIM3_PISCES    ; fi
290if [ ${resol_oce} == ORCA025 ] ; then  cfg_wrk=ORCA025_LIM3_PISCES  ; fi
291
292echo cp $modipsl/config/IPSLCM6/SOURCES/NEMO/*.*90 $nemo_root/$cfg_wrk/MY_SRC/   >> $outfile
293echo >> $outfile
294cp $mysrc_path/NEMO/*.*90  $nemo_root/$cfg_wrk/MY_SRC/
295
296if [ $full_nemo == y ] ; then
297   # To make a full compilation, first make a clean to remove all files produced during previous compilation
298   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk clean   >> $outfile
299   echo >> $outfile
300   ./makenemo -m ${fcm_arch} -n $cfg_wrk clean  >> $outfile 2>&1
301fi
302echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
303echo >> $outfile
304./makenemo -m ${fcm_arch} -n $cfg_wrk -j16 add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
305
306
307# Test if compiling finished
308if [[ $? != 0 ]] ; then
309    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
310    exit
311fi
312
313echo >> $outfile
314echo "Move nemo executable to modipsl/bin" >> $outfile
315echo ls -lrt $nemo_root/$cfg_wrk/BLD/bin   >> $outfile
316ls -lrt $nemo_root/$cfg_wrk/BLD/bin  >> $outfile
317echo >> $outfile
318
319if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ] ; then
320    if [ ${esmco2} == y ] ;  then
321        mv $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa.ESMCO2_${resol_oce}_${optmode}
322    else
323        mv $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${resol_oce}_${optmode}
324    fi
325fi
326
327
328## 2.6 Compile LMDZ for regular latlon configuration
329# If necessary compile INCA modele with AER configuration
330if [ ${esmaer} == y ] ;  then
331    cd $modipsl/modeles/INCA
332    #compile INCA regulat lat_lon chimie librairy
333    echo; echo "NOW COMPILE INCA AER on resolution = ${resol_atm}"
334    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 
335    ./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
336
337    # Test if compiling finished
338    if [[ $? != 0 ]] ; then
339        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
340        exit
341    fi
342
343    echo "Move inca.dat modipsl/bin"
344    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/AER/inca.dat ]] ;  then 
345        mv $modipsl/modeles/INCA/SIMULATIONS/AER/inca.dat $modipsl/bin/inca_${resol_atm}_${optmode}_AER.dat ;
346    else
347        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
348        exit   
349    fi
350       
351fi 
352
353
354# Compile LMDZ regular lat-lon executable
355cd $modipsl/modeles/LMDZ
356echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
357echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
358
359# Check if the compilation of LMDZ was previsouly interupted prematured.
360# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
361# to ask question and wait for interactivly answer from the user.
362if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
363  echo >> $outfile
364  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
365  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
366  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
367  echo >> $outfile
368  rm -f libf/grid/dimensions.h
369  rm -f .lock
370fi
371
372if [ ${esmaer} == n ] ;  then
373    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 
374    ./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
375else
376    #in esm aer case add chemistry option to lmdz compilation
377    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 
378    ./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
379fi 
380# Test if compiling finished
381if [[ $? != 0 ]] ; then
382    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
383    exit
384fi
385
386# Move executables to modipsl/bin folder
387echo >> $outfile
388echo "Move gcm.e executable to modipsl/bin" >> $outfile
389echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
390ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
391echo >> $outfile
392if [ ${esmaer} == n ] ;  then
393    suffix=_${resol_atm}_phylmd_para_mem_orch_couple.e
394else
395    suffix=_${resol_atm}_phylmd_para_mem_orch_couple_inca.e
396fi
397echo gcm suffix = $suffix
398
399if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
400    if [ ${esmaer} == n ] ;  then
401        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
402    else
403        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_AER.e
404    fi
405else
406    echo "ERROR gcm${suffix} executable does not exist." 
407    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
408    exit
409fi 
410
411
412# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
413if [ $ce0l == y ] ; then
414    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
415    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
416   
417    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 ce0l    >> $outfile 
418    ./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 ce0l    >> $outfile 2>&1
419    # Test if compiling finished
420    if [[ $? != 0 ]] ; then
421        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
422        exit
423    fi
424
425
426    # Move executables to modipsl/bin folder
427    echo >> $outfile
428    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
429    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
430    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
431    echo >> $outfile
432    suffix=_${resol_atm}_phylmd_para_mem_orch_couple.e
433    echo ce0l suffix = $suffix
434
435    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
436        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
437    else
438        echo "ERROR ce0l${suffix} executable does not exist." 
439        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
440        exit
441    fi 
442fi
443
444echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
445echo ls -lrt modipsl/bin >> $outfile
446ls -lrt $modipsl/bin >> $outfile
447
448echo; echo "ALL COMPILING FINISHED" ; echo
449echo "Executables are found in modipsl/bin"
450echo "Check that executable names correspond with the name set in config.card before launching the job"
451echo ls -lrt modipsl/bin
452ls -lrt $modipsl/bin
453
454date
455
456exit
457
458
Note: See TracBrowser for help on using the repository browser.