source: CONFIG/UNIFORM/v6/IPSLCM5A2CHT.2/compile_ipslcm5a2cht.sh @ 6470

Last change on this file since 6470 was 6470, checked in by acosce, 12 months ago

Update config IPSLCM5A2CHT.2 to compile and run on redhat8

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