source: CONFIG/UNIFORM/v6/LMDZORINCA_v6.2/compile_lmdzorinca.sh @ 6307

Last change on this file since 6307 was 6307, checked in by acosce, 18 months ago

Add source of arch environment before modeles compilation

  • Property svn:executable set to *
File size: 13.3 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
13
14#### Set default options
15# Optimization mode
16# optmode=prod/dev/debug
17optmode=prod
18# Resolution of LMDZ in regular mode
19regular_latlon=yes
20resol_atm_3d=144x142x79
21# Also compile ce0l subprogram to LMDZ (y/n)
22ce0l=n
23
24optchimie=NMHC_AER_S
25#recompilation de inca seul ou de tous les modeles
26clean_inca=""
27full_flag=""
28
29# choose radiative code compilation option
30rad=rrtm
31opt_rad=""
32
33
34# fcm_arch
35fcm_arch=default
36# Default values to be overritten
37parallel=mpi_omp
38export fcm_arch parallel xios
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_lmdzorinca.$datestr
46echo > $outfile
47echo; echo "Text output from compilation will be stored in file out_compile_lmdzorinca.$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 <<fin
54
55########################################################################
56# Usage of the script compile_lmdzorinca.sh
57#
58########################################################################
59
60./compile_config [Options]
61
62Options: -full, -regular_latlon, -chimie, -clean_inca, -debug, -dev, -prod(default)
63
64Example 1: Default compilation of LMDZ-ORCHIDEE-INCA  with XIOS and IOIPSL - NMHC_AER_S / 96x95x39
65./compile_lmdzorinca.sh
66
67Example 2: Compilation with a chosen chemistry, for example DUSS  (default: NMHC_AER_S)
68./compile_lmdzorinca.sh -chimie DUSS
69
70Example 3: Compile in debug mode  - in this case you need to modify Optmode in config.card
71./compile_lmdzorinca.sh -debug
72
73Example 4: Default compilation with full recompilation of all components
74./compile_lmdzorinca.sh -full
75
76Example 5: Default compilation with recompilation of inca model only
77./compile_lmdzorinca.sh -clean_inca
78
79Example 6: Compilation of LMDZ in regular lat-lon for other dimensions (default: 96x95x39)
80The dimension can be changed to any other 3d dimension.
81./compile_lmdzorinca.sh -regular_latlon 144x142x79
82
83Example 7: choose radiative schema for LMDZ (oldrad/rrtm/ecrad). Default is rrtm
84./compile_lmdzorinca.sh -rad ecrad
85
86
87fin
88            exit;;
89
90        "-parallel")
91            parallel=$2 ; shift ; shift ;;
92       
93        "-arch")
94            fcm_arch="$2" ; shift ; shift ;;
95       
96        "-xios")
97            xios="$2" ; shift ; shift ;;
98       
99        "-optmode")
100            optmode=$2 ; shift ; shift ;;
101
102        "-debug")
103            optmode=debug ; shift ;;
104
105        "-dev")
106            optmode=dev ; shift ;;
107
108        "-prod")
109            optmode=prod ; shift ;;
110
111        "-ce0l")             
112            ce0l=y ; shift ;;
113
114        "-rad")       
115            rad=$2; shift ; shift;;
116
117        "-regular_latlon")
118            regular_latlon=yes ;
119            resol_atm_3d=$2 ; shift ; shift ;;
120       
121        "-full")
122            full_flag="-full"; shift ;;
123
124        "-clean_inca")
125            clean_inca="-clean"; shift ;;
126       
127        "-netcdf_lib_seq")
128            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
129
130        "-chimie") 
131            echo $2;
132            optchimie=$2; shift ; shift;;
133
134        *)
135            echo "unknown option "$2" , exiting..."
136            exit
137    esac
138done
139
140echo "Following arguments are set in current compiling:" >> $outfile 
141echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile 
142echo "   ce0l=${ce0l}" >> $outfile 
143echo "   chimie = $optchimie, clean_inca = ${clean_inca}" 
144echo >> $outfile
145
146### Read host dependent default values
147### These variables will not be changed if they were set as argument
148###./host.sh $host
149# Later : Following lines should be set in host.sh file
150# begin host.sh
151if [ $fcm_arch == default ] ; then
152    # Find out current host and source specific paths and commands for the host
153    case $( hostname -s ) in
154        jean-zay*)
155            fcm_arch=X64_JEANZAY;;
156        irene170|irene171|irene190|irene191|irene192|irene193)
157            fcm_arch=X64_IRENE;;
158        irene172|irene173|irene194|irene195)
159            fcm_arch=X64_IRENE-AMD;;
160        asterix*|obelix*)
161            fcm_arch=ifort_LSCE;;
162        ciclad*|climserv*)
163            fcm_arch=ifort_CICLAD;;
164        *)
165            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
166            echo Exit now.
167            exit
168    esac
169fi
170
171# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
172# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
173if [ -f ARCH/arch-${fcm_arch}.env ] ; then
174    echo >> $outfile
175    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
176    echo "Note that this new environement might be kept after compilation." 
177    echo "If this is the case, source again your personal environment after compilation. "
178    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
179    module list   >> $outfile 2>&1
180    # Get initial svn version
181    svn_version=$(module list -t | grep subversion)
182   
183    # Make a link to this file, to be used also in config.card
184    rm -f ARCH/arch.env
185    ln -s arch-${fcm_arch}.env ARCH/arch.env
186
187    # Source the file
188    source ARCH/arch.env   >> $outfile 2>&1
189    if [ X$svn_version != X ] ; then
190        # Put back initial version of svn
191        module load ${svn_version}
192    fi
193
194    echo >> $outfile 
195    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
196    module list   >> $outfile 2>&1
197fi
198
199#### 2 Do the compilation
200## 2.1 Compile ioipsl
201cd $modipsl/modeles/IOIPSL
202echo; echo "NOW COMPILE IOIPSL"
203echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
204
205# Check if compilation with fcm is included in IOIPSL
206if [ ! -f makeioipsl_fcm ] ; then
207  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
208  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
209  exit
210fi
211
212echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
213     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
214# Test if compiling succeded
215if [[ $? != 0 ]] ; then
216    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
217    exit
218fi
219
220## 2.2 Compile xios
221cd $modipsl/modeles/XIOS
222echo; echo "NOW COMPILE XIOS"
223echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
224echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
225     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
226# Test if compiling succeded
227if [[ $? != 0 ]] ; then
228    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
229    exit
230fi
231# Move executables to modipsl/bin
232if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
233    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
234else
235    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
236    exit
237fi
238
239
240## 2.3 Compile orchidee
241cd $modipsl/modeles/ORCHIDEE
242echo; echo "NOW COMPILE ORCHIDEE"
243echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
244
245echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
246        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $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.4 Compile LMDZ and INCA for regular latlon configuration
255if [ $regular_latlon = yes ] ; then
256
257    cd $modipsl/modeles/INCA
258    #compile INCA regulat lat_lon chimie librairy
259    echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}"
260    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_flag $clean_inca >> $outfile 
261         ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch} -arch_path $arch_path  $full_flag $clean_inca >> $outfile 2>&1
262
263    # Test if compiling finished
264    if [[ $? != 0 ]] ; then
265        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
266        exit
267    fi
268
269    echo "Move inca.dat modipsl/bin"
270    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ;  then 
271        mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${resol_atm_3d}_${optmode}_${optchimie}.dat ;
272#       cp $modipsl/bin/inca_${resol_atm_3d}.dat inca.dat;
273    else
274        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
275        exit   
276    fi
277
278
279    cd $modipsl/modeles/LMDZ
280    # Compile LMDZ regular lat-lon exectuable
281    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"
282    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"   >> $outfile 
283
284    # Retrieve the final svn release number, needed for radiative code suffix of executable
285    lmdzsvn=`svnversion . | egrep -o "[0-9]+"  | awk 'NR==1'`
286    echo >> $outfile ; echo "lmdzsvn= $lmdzsvn "   >> $outfile
287
288    # Check if the compilation of LMDZ was previsouly interupted prematured.
289    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
290    # to ask question and wait for interactivly answer from the user.
291    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
292        echo >> $outfile
293        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
294        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
295        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
296        echo >> $outfile
297        rm -f libf/grid/dimensions.h
298        rm -f .lock
299    fi
300
301    # Need to define the proper option for radiative code compilation. By default, we use rrtm
302    case $rad in
303        oldrad) opt_rad="" ;;
304        rrtm)   if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;;
305        ecrad)  opt_rad="-rad ecrad" ;;
306        *) echo Only oldrad rrtm ecrad for rad option ; exit
307    esac
308
309    if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi
310
311
312
313
314    echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd ${opt_rad} -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 
315         ./makelmdz_fcm -d ${resol_atm_3d} -p lmd ${opt_rad} -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 2>&1
316    # Test if compiling finished
317    if [[ $? != 0 ]] ; then
318        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
319        exit
320    fi
321
322
323    suffix=_${resol_atm_3d}_phylmd
324    if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
325
326    # Find executable suffix
327    if [ $parallel == seq ] || [ $parallel == none ] ; then
328        suffix=${suffix}_seq_orch_inca
329    else
330        suffix=${suffix}_para_mem_orch_inca
331    fi
332    echo suffix = $suffix
333   
334    # Move executables to modipsl/bin folder
335    echo "Move gcm.e and ce0l executable to modipsl/bin"
336    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ;  then
337         mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}_${optmode}_${optchimie}.e ;
338   
339    else
340        echo "THERE IS A PROBLEM IN EXECUTABLE CREATION - STOP"
341        exit
342
343    fi
344
345# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
346if [ $ce0l == y ] ; then
347    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
348    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
349   
350
351    echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd ${opt_rad} -$optmode  -arch $fcm_arch -chimie INCA -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
352         ./makelmdz_fcm -d ${resol_atm_3d} -p lmd ${opt_rad} -$optmode  -arch $fcm_arch -chimie INCA -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 2>&1
353    # Test if compiling finished
354    if [[ $? != 0 ]] ; then
355        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
356        exit
357    fi
358
359   
360    # Move executables to modipsl/bin folder
361    echo >> $outfile
362    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
363    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
364    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
365    echo >> $outfile
366    suffix=_${resol_atm_3d}_phylmd_seq.e
367    echo ce0l suffix = $suffix
368
369    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
370        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}_${optchimie}.e
371    else
372        echo "ERROR ce0l${suffix} executable does not exist." 
373        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
374        exit
375    fi 
376fi
377
378
379
380fi
381
382
383echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
384echo; echo "ALL COMPILING FINISHED"
385
386if [ $optmode == 'debug' ] || [ $optmode == 'dev' ]; then
387    echo; echo "===================================================="
388    echo; echo "DON'\T FORGET TO MODIFY Optmode IN cconfig.card" 
389    echo; echo "Optmode="$optmode
390    echo; echo "===================================================="
391fi
392
393date
394exit
395
396
Note: See TracBrowser for help on using the repository browser.