source: CONFIG/UNIFORM/v7/ICOLMDZORINCA_v7/compile_icolmdzorinca.sh @ 6083

Last change on this file since 6083 was 6083, checked in by acosce, 2 years ago

update compile_icolmdzorinca.sh to follow modifications done on compile_icolmdzor.sh script rev [6080]

  • Property svn:executable set to *
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
13export ROOT=$modipsl/modeles/DYNAMICO
14
15#### Set default options
16# Optimization mode
17# optmode=prod/dev/debug
18optmode=prod
19# Resolution if compiling LMDZ in regular mode without DYNAMICO
20# Use for example following "./compile_icolmdzorinca.sh -regular_latlon 144x142x79"
21resol_atm="144x142x79"
22# fcm_arch
23fcm_arch=default
24# Default values to be overritten
25parallel=mpi_omp
26export fcm_arch parallel xios
27full_flag=""
28full_xios=""
29full_lmdz=""
30full_orch=""
31full_dyna=""
32#choose if we want to compile only grid ico, grid reg. If no for both of them, we will compile the two grids
33ico_only=no
34reg_only=no
35#choose if we want to compile only create_etat0_limit
36ce0l_only=no
37#choose chemistry inca configuration
38optchimie=GES
39
40# Default netcdf_lib is used for XIOS but can be change by argument
41netcdf_lib=""
42
43# Output text file for compilation of each component
44datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
45outfile=$submitdir/out_compile_icolmdzorinca.$datestr
46echo > $outfile
47echo; echo "Text output from compilation will be stored in file out_compile_icolmdzorinca.$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########################################################################
56# Usage of the script compile_icolmdzorinca.sh
57#
58########################################################################
59
60./compile_config [Options]
61
62Options: -full, -regular_latlon, -debug, -dev, -prod(default)
63
64Example 1: Default compilation of [DYNAMICO-LMDZ-ORCHIDEE-INCA GES with XIOS and IOIPSL] and [LMDZ(144x142x79)-ORCHIDEE-INCA GES with XIOS and IOIPSL] and [create_etat0_limit]
65./compile_icolmdzorinca.sh
66
67Example 2: Compile in debug mode
68./compile_icolmdzorinca.sh -debug
69
70Example 3: Default compilation with full recompilation of all components
71./compile_icolmdzorinca.sh -full
72
73Example 4: Define dimension for regular grid (default one is  144x142x79)
74The dimension can be changed to any other 3d dimension - in this example DYNAMICO is also compiled as default.
75./compile_icolmdzorinca.sh -regular_latlon 256x256x79
76
77Example 5: Compilation with a chosen chemistry, for example DUSS  (default: GES)
78./compile_icolmdzorinca.sh -chimie DUSS
79
80Example 6: Compile only ico grid
81./compile_icolmdzorinca.sh -ico_only
82
83Example 7: Compile only reg grid
84./compile_icolmdzorinca.sh -reg_only
85
86Example 8: compile only create_etat0_limit
87./compile_icolmdzorinca.sh -ce0l_only
88
89end_help
90            exit;;
91
92        "-parallel")        parallel=$2 ; shift ; shift ;;
93        "-arch")            fcm_arch="$2" ; shift ; shift ;;
94        "-xios")            xios="$2" ; shift ; shift ;;
95        "-debug")           optmode=debug ; shift ;;
96        "-dev")             optmode=dev ; shift ;;
97        "-prod")            optmode=prod ; shift ;;
98        "-regular_latlon")  regular_latlon=yes ; resol_atm=$2 ; shift ; shift ;;
99        "-full")            full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; full_dyna="-full" ; shift ;;
100        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
101        "-full_lmdz")       full_lmdz="-full"  ; shift ;;
102        "-full_orch")       full_orch="-full"  ; shift ;;
103        "-full_dyna")       full_dyna="-full"  ; shift ;;
104        "-ico_only")        ico_only=yes  ; shift ;;
105        "-reg_only")        reg_only=yes  ; shift ;;
106        "-ce0l_only")       ce0l=yes  ; shift ;;
107        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
108        "-chimie")          optchimie=$2; shift ; shift;;
109
110        *)                  echo "unknown option "$1" , exiting..." ;  exit
111    esac
112done
113
114echo "Following options are set in current compiling:" >> $outfile 
115echo "   chemistry=${optchimie}">> $outfile
116echo "   ico_only=${ico_only}, reg_only=${reg_only}, ce0l_only=${ce0l_only}" >> $outfile
117echo "   regular_latlon=${resol_atm} (use to create executable on regular grid)" >> $outfile 
118echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
119echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch, full_dyna=$full_dyna" >> $outfile 
120echo >> $outfile
121
122
123### Read host dependent default values
124### These variables will not be changed if they were set as argument
125###./host.sh $host
126# Later : Following lines should be set in host.sh file
127# begin host.sh
128if [ $fcm_arch == default ] ; then
129    # Find out current host and source specific paths and commands for the host
130    case $( hostname -s ) in
131        jean-zay*)
132            fcm_arch=X64_JEANZAY;;
133        irene170|irene171|irene190|irene191|irene192|irene193)
134            fcm_arch=X64_IRENE;;
135        irene172|irene173|irene194|irene195)
136            fcm_arch=X64_IRENE-AMD;;
137        asterix*|obelix*)
138            fcm_arch=ifort_LSCE
139            if [ "${parallel}" == "mpi_omp" ] ; then
140                echo "Warning!! Currently at Obelix hybrid mode is not possible."
141                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
142                echo ""
143                parallel=mpi
144            else
145                echo "You used -parallel" $parallel
146            fi ;;
147        ciclad*|climserv*|loholt*|camelot*)
148            fcm_arch=ifort_CICLAD;;
149        *)
150            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
151            echo Exit now.
152            exit
153    esac
154fi
155
156# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
157# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
158if [ -f ARCH/arch-${fcm_arch}.env ] ; then
159    echo >> $outfile
160    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
161    echo "Note that this new environement might be kept after compilation."
162    echo "If this is the case, source again your personal environment after compilation."
163    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
164    module list   >> $outfile 2>&1
165
166    # Make a link to this file, to be used also in config.card
167    rm -f ARCH/arch.env
168    ln -s arch-${fcm_arch}.env ARCH/arch.env
169
170    # Source the file
171    source ARCH/arch.env   >> $outfile 2>&1
172
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
184echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
185     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
186# Test if compiling succeded
187if [[ $? != 0 ]] ; then
188    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
189    echo "ALL INFORMATION IN FILE $outfile"
190    exit
191fi
192
193## 2.2 Compile xios
194cd $modipsl/modeles/XIOS
195echo; echo "NOW COMPILE XIOS"
196echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
197echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
198     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
199# Test if compiling succeded
200if [[ $? != 0 ]] ; then
201    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
202    echo "ALL INFORMATION IN FILE $outfile"
203    exit
204fi
205# Move executables to modipsl/bin
206if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
207    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
208else
209    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
210    echo "ALL INFORMATION IN FILE $outfile"
211    exit
212fi
213
214
215## 2.3 Compile orchidee
216cd $modipsl/modeles/ORCHIDEE
217echo; echo "NOW COMPILE ORCHIDEE"
218echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
219
220# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
221# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
222# to ask question and wait for interactivly answer from the user.
223if [ -f build/fcm.bld.lock ] ; then
224    echo >> $outfile
225    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
226    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
227    echo "           The file will now be removed. "   >> $outfile
228    echo >> $outfile
229    rm -f build/fcm.bld.lock
230fi
231
232echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 
233        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 2>&1
234# Test if compiling finished
235if [[ $? != 0 ]] ; then
236    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
237    echo "ALL INFORMATION IN FILE $outfile"
238    exit
239fi
240
241# If orchide driver executables have been compiled (option -driver), then rename executables to contain $optmode
242if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
243if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
244
245
246## ajout compile inca Anne
247    cd $modipsl/modeles/INCA
248
249    echo; echo "NOW COMPILE INCA ${optchimie}"
250    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_flag  >> $outfile
251    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path  $full_flag >> $outfile 2>&1
252
253    # Test if compiling finished
254    if [[ $? != 0 ]] ; then
255        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
256        echo "ALL INFORMATION IN FILE $outfile"
257        exit
258    fi
259
260
261
262    echo "Move inca.dat modipsl/bin"
263    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat ]] ;  then 
264        mv $modipsl/modeles/INCA/SIMULATIONS/${optchimie}/inca.dat $modipsl/bin/inca_${optmode}_${optchimie}.dat ;
265    else
266        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
267        echo "ALL INFORMATION IN FILE $outfile"
268        exit   
269    fi
270
271    echo "Move tracer.def to  modipsl/bin"
272    if [[ -f $modipsl/modeles/INCA/tracer.def ]] ;  then
273        mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optmode}_${optchimie}.def ;
274    fi
275
276
277## 2.4 Compile lmdz
278
279if [ $reg_only = no ] && [ $ce0l_only = no ]; then
280
281    cd $modipsl/modeles/LMDZ
282
283    # Compile LMDZ as library to couple to DYNAMICO
284    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
285    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
286
287    # Check if the compilation of LMDZ was previsouly interupted prematured.
288    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
289    # to ask question and wait for interactivly answer from the user.
290    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
291        echo >> $outfile
292        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
293        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
294        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
295        echo >> $outfile
296        rm -f libf/grid/dimensions.h
297        rm -f .lock
298    fi
299
300    echo ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -chimie INCA -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 
301    ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -chimie INCA -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 2>&1
302    # Test if compiling finished
303    if [[ $? != 0 ]] ; then
304        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
305        echo "ALL INFORMATION IN FILE $outfile"
306        exit
307    fi
308
309
310## 2.5 Compile DYNAMICO
311    cd $modipsl/modeles/DYNAMICO
312    echo; echo "NOW COMPILE DYNAMICO "
313    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
314
315    echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
316    ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
317    # Test if compiling finished
318    if [[ $? != 0 ]] ; then
319        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
320        echo "ALL INFORMATION IN FILE $outfile"
321        exit
322    fi
323
324    ## 2.6 Compile interface ICOSA_LMDZ
325    cd $modipsl/modeles/ICOSA_LMDZ
326    echo; echo "NOW COMPILE ICOSA_LMDZ "
327    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
328
329    echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -with_inca -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 
330    ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -with_inca -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 2>&1
331    # Test if compiling finished
332    if [[ $? != 0 ]] ; then
333        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
334        echo "ALL INFORMATION IN FILE $outfile"
335        exit
336    fi
337    # Move executables to modipsl/bin
338    if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
339        mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${optmode}_${optchimie}.exe
340    else
341        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
342        echo "ALL INFORMATION IN FILE $outfile"
343        exit
344    fi
345fi 
346
347
348## 2.7 Compile LMDZ for regular latlon configuration
349
350# Find executable suffix
351if [ $parallel == seq ] || [ $parallel == none ] ; then
352    suffix=_${resol_atm}_phylmd_seq_orch_inca.e
353else
354    suffix=_${resol_atm}_phylmd_para_mem_orch_inca.e
355fi
356echo gcm suffix = $suffix
357
358if [ $ico_only = no ] && [ $ce0l_only = no ]; then
359
360    cd $modipsl/modeles/LMDZ
361    # Compile LMDZ regular lat-lon exectuable
362    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
363    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
364   
365    # Check if the compilation of LMDZ was previsouly interupted prematured.
366    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
367    # to ask question and wait for interactivly answer from the user.
368    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
369        echo >> $outfile
370        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
371        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
372        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
373        echo >> $outfile
374        rm -f libf/grid/dimensions.h
375        rm -f .lock
376    fi
377    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 
378    ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 2>&1
379    # Test if compiling finished
380    if [[ $? != 0 ]] ; then
381        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
382        echo "ALL INFORMATION IN FILE $outfile"
383        exit
384    fi
385
386
387    # Move executables to modipsl/bin folder
388    echo "Move gcm.e and ce0l executable to modipsl/bin"
389    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
390        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_${optchimie}.e
391    else
392        echo "ERROR gcm${suffix} executable does not exist." 
393        echo "THERE IS A PROBLEM TO MOVE LMDZ REGULAR LATLON EXECUTABLE - STOP"
394        echo "ALL INFORMATION IN FILE $outfile"
395        exit
396    fi
397
398fi
399
400
401if [ $ce0l = yes ] || [ $ico_only = no ] && [ $reg_only = no ] ; then
402
403    cd $modipsl/modeles/LMDZ
404
405    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
406    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
407    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
408   
409    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 
410    ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 2>&1
411    # Test if compiling finished
412    if [[ $? != 0 ]] ; then
413        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
414        echo "ALL INFORMATION IN FILE $outfile"
415        exit
416    fi
417
418    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
419        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}_${optchimie}.e
420    else
421        echo "ERROR ce0l${suffix} executable does not exist." 
422        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
423        echo "ALL INFORMATION IN FILE $outfile"
424        exit
425    fi
426
427
428fi
429
430echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
431echo ls -lrt modipsl/bin >> $outfile
432ls -lrt $modipsl/bin >> $outfile
433
434echo; echo "ALL COMPILING FINISHED" ; echo
435echo "Executables are found in modipsl/bin"
436echo "Check that executable names correspond with the name set in config.card before launching the job"
437echo ls -lrt modipsl/bin
438ls -lrt $modipsl/bin
439
440date
441exit
442
443
Note: See TracBrowser for help on using the repository browser.