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

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