source: CONFIG/UNIFORM/v7/ICOLMDZOR_LAM_v7/compile_icolmdzor.sh @ 6629

Last change on this file since 6629 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)

  • Property svn:executable set to *
File size: 16.9 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_icolmdzor.sh -regular_latlon 144x142x79"
21resol_atm=144x142x79
22#choose if we want to compile only grid ico, grid reg. If no for both of them, we will compile the two grids
23ico_only=yes
24reg_only=no
25#choose if we want to compile only create_etat0_limit
26ce0l_only=no
27# fcm_arch
28fcm_arch=default
29# Default values to be overritten
30parallel=mpi_omp
31export fcm_arch parallel xios
32full_flag=""
33full_xios=""
34full_lmdz=""
35full_orch=""
36full_dyna=""
37# choose radiative code compilation option
38rad=rrtm
39opt_rad=""
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_icolmdzor.$datestr
46echo > $outfile
47echo; echo "Text output from compilation will be stored in file out_compile_icolmdzor.$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_icolmdzor.sh
57#
58########################################################################
59
60./compile_config [Options]
61
62Options: -ico_only, -reg_only, -ce0_only, -full, -regular_latlon, -debug, -dev, -prod(default)
63
64Example 1: Default compilation of [DYNAMICO-LMDZ-ORCHIDEE with XIOS and IOIPSL] and [LMDZ(144x142x79)-ORCHIDEE with XIOS and IOIPSL] and [create_etat0_limit]
65./compile_icolmdzor.sh
66
67Example 2: Compile in debug mode
68./compile_icolmdzor.sh -debug
69
70Example 3: Default compilation with full recompilation of all components
71./compile_icolmdzor.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_icolmdzor.sh -regular_latlon 256x256x79
76
77Example 5: Compile only ico grid
78./compile_icolmdzor.sh -ico_only
79
80Example 6: Compile only regular grid with default resolution (144x142x79)
81./compile_icolmdzor.sh -reg_only
82
83Example 7: compile only create_etat0_limt for reg
84./compile_icolmdzor.sh -ce0l_only
85
86Example 8: choose radiative schema for LMDZ (oldrad/rrtm/ecrad). Default is rrtm
87./compile_icolmdzor.sh -rad ecrad
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_only=yes  ; shift ;;
107        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
108        "-rad")        rad=$2; shift ; shift ;;
109        *)                  echo "unknown option "$1" , exiting..." ;  exit
110    esac
111done
112
113echo "Following options are set in current compiling:" >> $outfile 
114echo "   ico_only=${ico_only}, reg_only=${reg_only}, ce0l_only=${ce0l_only}" >> $outfile
115echo "   regular_latlon=${resol_atm} (use to create executable on regular grid)" >> $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_dyna=$full_dyna" >> $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            if [[ $( hostname -s ) != *"pp"* ]] ; then
130                echo "Warning! You MUST compile on jean-zay-pp."
131                echo "EXIT"
132                exit
133            else
134                fcm_arch=X64_JEANZAY
135            fi ;;
136        irene170|irene171|irene190|irene191|irene192|irene193)
137            fcm_arch=X64_IRENE;;
138        irene172|irene173|irene194|irene195)
139            fcm_arch=X64_IRENE-AMD;;
140        asterix*|obelix*)
141            fcm_arch=ifort_LSCE
142            if [ "${parallel}" == "mpi_omp" ] ; then
143                echo "Warning!! Currently at Obelix hybrid mode is not possible."
144                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
145                echo ""
146                parallel=mpi
147            else
148                echo "You used -parallel" $parallel
149            fi ;;
150        spirit*)
151            fcm_arch=ifort_MESOIPSL;;
152        ciclad*|climserv*|loholt*|camelot*)
153            fcm_arch=ifort_CICLAD;;
154        *)
155            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
156            echo Exit now.
157            exit
158    esac
159fi
160
161# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
162# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
163if [ -f ARCH/arch-${fcm_arch}.env ] ; then
164    echo >> $outfile
165    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
166    echo "Note that this new environement might be kept after compilation."
167    echo "If this is the case, source again your personal environment after compilation."
168    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
169    module list   >> $outfile 2>&1
170    svn_version=$(module list -t | grep subversion)
171       
172    # Make a link to this file, to be used also in config.card
173    rm -f ARCH/arch.env
174    ln -s arch-${fcm_arch}.env ARCH/arch.env
175
176    # Source the file
177    source ARCH/arch.env   >> $outfile 2>&1
178    if [ X$svn_version != X ] ; then
179        module load ${svn_version}
180    fi
181    echo >> $outfile
182    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
183    module list   >> $outfile 2>&1
184fi
185
186#### 2 Do the compilation
187## 2.1 Compile ioipsl
188cd $modipsl/modeles/IOIPSL
189echo; echo "NOW COMPILE IOIPSL"
190echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
191
192echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
193     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
194# Test if compiling succeded
195if [[ $? != 0 ]] ; then
196    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
197    exit
198fi
199
200## 2.2 Compile xios
201cd $modipsl/modeles/XIOS
202echo; echo "NOW COMPILE XIOS"
203echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
204echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
205     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
206# Test if compiling succeded
207if [[ $? != 0 ]] ; then
208    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
209    exit
210fi
211# Move executables to modipsl/bin
212if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
213    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
214else
215    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
216    exit
217fi
218
219
220## 2.3 Compile orchidee
221cd $modipsl/modeles/ORCHIDEE
222echo; echo "NOW COMPILE ORCHIDEE"
223echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
224
225# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
226# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
227# to ask question and wait for interactivly answer from the user.
228if [ -f build/fcm.bld.lock ] ; then
229    echo >> $outfile
230    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
231    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
232    echo "           The file will now be removed. "   >> $outfile
233    echo >> $outfile
234    rm -f build/fcm.bld.lock
235fi
236
237echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 
238        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 2>&1
239# Test if compiling finished
240if [[ $? != 0 ]] ; then
241    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
242    exit
243fi
244
245# If orchide driver executables have been compiled (option -driver), then rename executables to contain $optmode
246if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
247if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
248
249
250## 2.4 Compile lmdz
251
252if [ $reg_only = no ] && [ $ce0l_only = no ]; then
253
254    cd $modipsl/modeles/LMDZ
255
256    # Compile LMDZ as library to couple to DYNAMICO
257    echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
258    echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
259    # Retrieve the final svn release number, needed for radiative code suffix of executable
260    lmdzsvn=`svnversion . | egrep -o "[0-9]+"  | awk 'NR==1'`
261    # Check if the compilation of LMDZ was previsouly interupted prematured.
262    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
263    # to ask question and wait for interactivly answer from the user.
264    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
265        echo >> $outfile
266        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
267        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
268        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
269        echo >> $outfile
270        rm -f libf/grid/dimensions.h
271        rm -f .lock
272    fi
273
274# Need to define the proper option for radiative code compilation. By default, we use rrtm
275case $rad in
276    oldrad) opt_rad="" ;;
277    rrtm)   if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;;
278    ecrad)  opt_rad="-rad ecrad" ;;
279    *) echo Only oldrad rrtm ecrad for rad option ; exit
280esac
281
282if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi
283
284
285    echo ./makelmdz_fcm -p lmd -cosp true $opt_rad -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 
286    ./makelmdz_fcm -p lmd -cosp true $opt_rad -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 2>&1
287    # Test if compiling finished
288    if [[ $? != 0 ]] ; then
289        echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
290        exit
291    fi
292
293
294    ## 2.5 Compile DYNAMICO
295    cd $modipsl/modeles/DYNAMICO
296    echo; echo "NOW COMPILE DYNAMICO "
297    echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
298   
299
300    echo ./make_icosa -$optmode -with_fcm1 -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
301    ./make_icosa -$optmode -with_fcm1 -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
302    # Test if compiling finished
303    if [[ $? != 0 ]] ; then
304        echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
305        exit
306    fi
307
308    ## 2.6 Compile interface ICOSA_LMDZ
309    cd $modipsl/modeles/ICOSA_LMDZ
310    echo; echo "NOW COMPILE ICOSA_LMDZ "
311    echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
312   
313    echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 
314    ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 2>&1
315    # Test if compiling finished
316    if [[ $? != 0 ]] ; then
317        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
318        exit
319    fi
320    # Move executables to modipsl/bin
321    if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
322        mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${optmode}.exe
323    else
324        echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
325        exit
326    fi
327   
328fi 
329
330## 2.7 Compile LMDZ for regular latlon configuration
331
332# Find executable suffix
333suffix=_${resol_atm}_phylmd
334if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
335if [ $parallel == seq ] || [ $parallel == none ] ; then
336    suffix=${suffix}_seq_orch.e
337else
338    suffix=${suffix}_para_mem_orch.e
339fi
340echo gcm suffix = $suffix
341
342
343if [ $ico_only = no ] && [ $ce0l_only = no ]; then
344
345    cd $modipsl/modeles/LMDZ
346    # Compile LMDZ regular lat-lon exectuable
347    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
348    echo >> $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.
353    if [ -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
361    fi
362    echo ./makelmdz_fcm -d ${resol_atm} -p lmd $opt_rad -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 
363         ./makelmdz_fcm -d ${resol_atm} -p lmd $opt_rad -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 2>&1
364    # Test if compiling finished
365    if [[ $? != 0 ]] ; then
366        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
367        exit
368    fi
369
370
371    # Move executables to modipsl/bin folder
372    echo "Move gcm.e  executable to modipsl/bin"
373    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
374        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
375    else
376        echo "ERROR gcm${suffix} executable does not exist." 
377        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
378        exit
379    fi
380
381fi
382
383
384if [ $ce0l_only = yes ] || [ $ico_only = no ] && [ $reg_only = no ] ; then
385
386    cd $modipsl/modeles/LMDZ
387
388    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
389    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
390    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
391
392    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 
393         ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 2>&1
394    # Test if compiling finished
395    if [[ $? != 0 ]] ; then
396        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
397        exit
398    fi
399
400    # Move executables to modipsl/bin folder
401    echo "Move ce0l.e  executable to modipsl/bin"
402    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
403        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
404    else
405        echo "ERROR ce0l${suffix} executable does not exist." 
406        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
407        exit
408    fi
409
410fi
411
412
413
414echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
415echo ls -lrt modipsl/bin >> $outfile
416ls -lrt $modipsl/bin >> $outfile
417
418echo; echo "ALL COMPILING FINISHED" ; echo
419echo "Executables are found in modipsl/bin"
420echo "Check that executable names correspond with the name set in config.card before launching the job"
421echo ls -lrt modipsl/bin
422ls -lrt $modipsl/bin
423
424date
425exit
426
427
Note: See TracBrowser for help on using the repository browser.