source: CONFIG/UNIFORM/v6/IPSLCM6.5/compile_ipslcm6.sh @ 6865

Last change on this file since 6865 was 6629, checked in by falletti, 10 months ago

Adding a compilation check on Jean-Zay, to be sure that we compile on jean-za-pp (_work configurations)

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