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

Last change on this file since 5122 was 5122, checked in by lfairhead, 4 years ago

Switching ce0l compilation to sequential, there is a problem with the parallel version
LF

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