source: CONFIG/UNIFORM/v6/IPSLCM6.5.1/compile_ipslcm6.sh @ 6390

Last change on this file since 6390 was 6390, checked in by cetlod, 14 months ago

CM6.5 : compile script must an exe file

  • Property svn:executable set to *
File size: 16.8 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
209cd $modipsl/modeles/XIOS
210echo; echo "NOW COMPILE XIOS"
211echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
212echo ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 
213     ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 2>&1
214# Test if compiling succeded
215if [[ $? != 0 ]] ; then
216    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
217    exit
218fi
219# Move executables to modipsl/bin
220if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
221    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
222else
223    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
224    exit
225fi
226
227
228## 2.4 Compile orchidee
229cd $modipsl/modeles/ORCHIDEE
230echo; echo "NOW COMPILE ORCHIDEE"
231echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
232
233# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
234# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
235# to ask question and wait for interactivly answer from the user.
236if [ -f build/fcm.bld.lock ] ; then
237    echo >> $outfile
238    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
239    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
240    echo "           The file will now be removed. "   >> $outfile
241    echo >> $outfile
242    rm -f build/fcm.bld.lock
243fi
244
245echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch   >> $outfile 
246        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch   >> $outfile 2>&1
247# Test if compiling finished
248if [[ $? != 0 ]] ; then
249    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
250    exit
251fi
252
253
254#### 2.5 Compile NEMO
255nemo_root=$modipsl/modeles/NEMO
256cfg_ref=ORCA2_ICE_PISCES
257cfg_wrk=ORCA_ICE_TRC
258addkeys="key_oasis3 key_top key_si3 key_isf"
259delkeys=""
260
261if [ ${nemotop} == n ] ; then
262   cfg_wrk=ORCA_ICE
263   delkeys="key_top"
264fi
265
266if [ ${nemotop} == n ] ; then
267   echo; echo "NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"
268   echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"   >> $outfile
269else
270   echo; echo "NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"
271   echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"   >> $outfile
272fi
273
274echo >> $outfile ; echo cd $nemo_root  >> $outfile
275echo >> $outfile ; echo cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.   >> $outfile
276echo >> $outfile
277
278cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.
279
280# creation of config
281echo >> $outfile ; echo cd $nemo_root  >> $outfile
282echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
283echo >> $outfile
284cd $nemo_root
285./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0  add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
286
287
288# Copy of specfic source files
289echo >> $outfile ; echo cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
290echo >> $outfile
291cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
292
293
294if [ $full_nemo == y ] ; then
295   # To make a full compilation, first make a clean to remove all files produced during previous compilation
296   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean   >> $outfile
297   echo >> $outfile
298   ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean  >> $outfile 2>&1
299fi
300echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile
301echo >> $outfile
302./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile 2>&1
303
304echo >> $outfile
305echo "Move nemo executable to modipsl/bin" >> $outfile
306echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin   >> $outfile
307ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin  >> $outfile
308echo >> $outfile
309
310if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then
311   mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${optmode}.exe
312else
313    echo "ERROR nemo.exe executable does not exist."
314    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
315    exit
316fi
317
318
319## 2.6 Compile LMDZ for regular latlon configuration
320# If necessary compile INCA modele with AER configuration
321if [ ${aer} == y ] ;  then
322    cd $modipsl/modeles/INCA
323    #compile INCA regulat lat_lon chimie librairy
324    echo; echo "NOW COMPILE INCA AER on resolution = ${resol_atm}"
325    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 
326    ./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
327
328    # Test if compiling finished
329    if [[ $? != 0 ]] ; then
330        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
331        exit
332    fi
333
334    echo "Move inca.dat modipsl/bin"
335    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/AER/inca.dat ]] ;  then 
336        mv $modipsl/modeles/INCA/SIMULATIONS/AER/inca.dat $modipsl/bin/inca_${resol_atm}_${optmode}_AER.dat ;
337    else
338        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
339        exit   
340    fi
341       
342fi 
343
344
345# Compile LMDZ regular lat-lon executable
346cd $modipsl/modeles/LMDZ
347echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
348echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
349
350# Check if the compilation of LMDZ was previsouly interupted prematured.
351# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
352# to ask question and wait for interactivly answer from the user.
353if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
354  echo >> $outfile
355  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
356  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
357  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
358  echo >> $outfile
359  rm -f libf/grid/dimensions.h
360  rm -f .lock
361fi
362
363if [ ${aer} == n ] ;  then
364    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 
365    ./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
366else
367    #in aer case add chemistry option to lmdz compilation
368    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 
369    ./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
370fi 
371# Test if compiling finished
372if [[ $? != 0 ]] ; then
373    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
374    exit
375fi
376
377# Move executables to modipsl/bin folder
378echo >> $outfile
379echo "Move gcm.e executable to modipsl/bin" >> $outfile
380echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
381ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
382echo >> $outfile
383if [ ${aer} == n ] ;  then
384    suffix=_${resol_atm}_phylmd_para_mem_orch_couple.e
385else
386    suffix=_${resol_atm}_phylmd_para_mem_orch_couple_inca.e
387fi
388echo gcm suffix = $suffix
389
390if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
391    if [ ${aer} == n ] ;  then
392        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
393    else
394        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_AER.e
395    fi
396else
397    echo "ERROR gcm${suffix} executable does not exist." 
398    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
399    exit
400fi 
401
402
403# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
404if [ $ce0l == y ] ; then
405    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
406    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
407   
408    echo ./makelmdz_fcm -d ${resol_atm} -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
409    ./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
410    # Test if compiling finished
411    if [[ $? != 0 ]] ; then
412        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
413        exit
414    fi
415
416
417    # Move executables to modipsl/bin folder
418    echo >> $outfile
419    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
420    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
421    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
422    echo >> $outfile
423    suffix=_${resol_atm}_phylmd_seq.e
424    echo ce0l suffix = $suffix
425
426    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
427        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
428    else
429        echo "ERROR ce0l${suffix} executable does not exist." 
430        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
431        exit
432    fi 
433fi
434
435echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
436echo ls -lrt modipsl/bin >> $outfile
437ls -lrt $modipsl/bin >> $outfile
438
439echo; echo "ALL COMPILING FINISHED" ; echo
440echo "Executables are found in modipsl/bin"
441echo "Check that executable names correspond with the name set in config.card before launching the job"
442echo ls -lrt modipsl/bin
443ls -lrt $modipsl/bin
444
445date
446
447exit
448
449
Note: See TracBrowser for help on using the repository browser.