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

Last change on this file since 4641 was 4641, checked in by jgipsl, 5 years ago
  • Add option CE0L to compile ce0l from LMDZ. This is not done by default anymore. Note also that there is a problem with this compilation probably since compilation of XIOS changed by adding --use_oasis oasis3_mct
  • Add individual full options per component.
  • Corrected full option for XIOS
  • compressed lines for reading options


  • test if gcm.e executable exist and set error message if so because first error message after makelmdz_fcm does not work for all cases.
  • 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 "$2" , 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 mv $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${optmode}     ; fi
294if [ -f $nemo_root/$cfg_wrk/BLD/bin/nemo.exe ] && [ ${esmco2} == y ] ;  then mv $nemo_root/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa.esm_${optmode} ; fi
295
296
297## 2.6 Compile LMDZ for regular latlon configuration
298cd $modipsl/modeles/LMDZ
299# Compile LMDZ regular lat-lon exectuable
300echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
301echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
302
303# Check if the compilation of LMDZ was previsouly interupted prematured.
304# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
305# to ask question and wait for interactivly answer from the user.
306if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
307  echo >> $outfile
308  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
309  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
310  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
311  echo >> $outfile
312  rm -f libf/grid/dimensions.h
313  rm -f .lock
314fi
315
316echo ./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 
317     ./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
318# Test if compiling finished
319if [[ $? != 0 ]] ; then
320    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
321    exit
322fi
323
324# Move executables to modipsl/bin folder
325echo >> $outfile
326echo "Move gcm.e executable to modipsl/bin" >> $outfile
327echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
328ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
329echo >> $outfile
330suffix=_${resol_atm}_phylmd_para_mem_orch_couple.e
331echo gcm.e suffix = $suffix
332
333if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
334    mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
335else
336    echo "ERROR gcm${suffix} executable does not exist." 
337    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
338    exit
339fi 
340
341
342# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
343if [ $ce0l == y ] ; then
344    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
345    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
346   
347    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 
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_lmdz ce0l    >> $outfile 2>&1
349    # Test if compiling finished
350    if [[ $? != 0 ]] ; then
351        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
352        exit
353    fi
354
355
356    # Move executables to modipsl/bin folder
357    echo >> $outfile
358    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
359    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
360    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
361    echo >> $outfile
362    suffix=_${resol_atm}_phylmd_para_mem_orch.e
363    echo ce0l suffix = $suffix
364
365    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
366        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
367    else
368        echo "ERROR ce0l${suffix} executable does not exist." 
369        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
370        exit
371    fi 
372fi
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
382ls -lrt $modipsl/bin
383
384date
385
386exit
387
388
Note: See TracBrowser for help on using the repository browser.