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

Last change on this file since 6618 was 6443, checked in by cetlod, 13 months ago

merge useless IPSLCM6.5.1 into IPSLCM6.5 CONFIG & restructuration of PARAM sub-directory

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