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

Last change on this file since 6849 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: 13.0 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
15#### Set default options
16# Optimization mode
17# optmode=prod/dev/debug
18optmode=prod
19# Resolution of LMDZ in regular mode
20regular_latlon=yes
21resol_atm_3d=144x142x79
22# Also compile ce0l subprogram to LMDZ (y/n)
23ce0l=n
24
25optchimie=NMHC_AER_S
26#recompilation de inca seul ou de tous les modeles
27clean_inca=""
28full_flag=""
29
30# choose radiative code compilation option
31rad=rrtm
32opt_rad=""
33
34
35# fcm_arch
36fcm_arch=default
37# Default values to be overritten
38parallel=mpi_omp
39export fcm_arch parallel xios
40
41# Default netcdf_lib is used for XIOS but can be change by argument
42netcdf_lib=""
43
44# Output text file for compilation of each component
45datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
46outfile=$submitdir/out_compile_lmdzorinca.$datestr
47echo > $outfile
48echo; echo "Text output from compilation will be stored in file out_compile_lmdzorinca.$datestr"; echo 
49
50#### Read arguments
51# Loop over all arguments to modify default set up
52while (($# > 0)) ; do
53    case $1 in
54        "-h") cat <<fin
55
56########################################################################
57# Usage of the script compile_lmdzorinca.sh
58#
59########################################################################
60
61./compile_config [Options]
62
63Options: -full, -regular_latlon, -chimie, -clean_inca, -debug, -dev, -prod(default)
64
65Example 1: Default compilation of LMDZ-ORCHIDEE-INCA  with XIOS and IOIPSL - NMHC_AER_S / 96x95x39
66./compile_lmdzorinca.sh
67
68Example 2: Compilation with a chosen chemistry, for example DUSS  (default: NMHC_AER_S)
69./compile_lmdzorinca.sh -chimie DUSS
70
71Example 3: Compile in debug mode  - in this case you need to modify Optmode in config.card
72./compile_lmdzorinca.sh -debug
73
74Example 4: Default compilation with full recompilation of all components
75./compile_lmdzorinca.sh -full
76
77Example 5: Default compilation with recompilation of inca model only
78./compile_lmdzorinca.sh -clean_inca
79
80Example 6: Compilation of LMDZ in regular lat-lon for other dimensions (default: 96x95x39)
81The dimension can be changed to any other 3d dimension.
82./compile_lmdzorinca.sh -regular_latlon 144x142x79
83
84Example 7: choose radiative schema for LMDZ (oldrad/rrtm/ecrad). Default is rrtm
85./compile_lmdzorinca.sh -rad ecrad
86
87
88fin
89            exit;;
90
91        "-parallel")
92            parallel=$2 ; shift ; shift ;;
93       
94        "-arch")
95            fcm_arch="$2" ; shift ; shift ;;
96       
97        "-xios")
98            xios="$2" ; shift ; shift ;;
99       
100        "-optmode")
101            optmode=$2 ; shift ; shift ;;
102
103        "-debug")
104            optmode=debug ; shift ;;
105
106        "-dev")
107            optmode=dev ; shift ;;
108
109        "-prod")
110            optmode=prod ; shift ;;
111
112        "-ce0l")             
113            ce0l=y ; shift ;;
114
115        "-rad")       
116            rad=$2; shift ; shift;;
117
118        "-regular_latlon")
119            regular_latlon=yes ;
120            resol_atm_3d=$2 ; shift ; shift ;;
121       
122        "-full")
123            full_flag="-full"; shift ;;
124
125        "-clean_inca")
126            clean_inca="-clean"; shift ;;
127       
128        "-netcdf_lib_seq")
129            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
130
131        "-chimie") 
132            echo $2;
133            optchimie=$2; shift ; shift;;
134
135        *)
136            echo "unknown option "$2" , exiting..."
137            exit
138    esac
139done
140
141echo "Following arguments are set in current compiling:" >> $outfile 
142echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile 
143echo "   ce0l=${ce0l}" >> $outfile 
144echo "   chimie = $optchimie, clean_inca = ${clean_inca}" 
145echo >> $outfile
146
147### Read host dependent default values
148### These variables will not be changed if they were set as argument
149###./host.sh $host
150# Later : Following lines should be set in host.sh file
151# begin host.sh
152if [ $fcm_arch == default ] ; then
153    # Find out current host and source specific paths and commands for the host
154    case $( hostname -s ) in
155        jean-zay*)
156            if [[ $( hostname -s ) != *"pp"* ]] ; then
157                echo "Warning! You MUST compile on jean-zay-pp."
158                echo "EXIT"
159                exit
160            else
161                fcm_arch=X64_JEANZAY
162            fi ;;
163        irene170|irene171|irene190|irene191|irene192|irene193)
164            fcm_arch=X64_IRENE;;
165        irene172|irene173|irene194|irene195)
166            fcm_arch=X64_IRENE-AMD;;
167        asterix*|obelix*)
168            fcm_arch=ifort_LSCE;;
169        ciclad*|climserv*)
170            fcm_arch=ifort_CICLAD;;
171        *)
172            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
173            echo Exit now.
174            exit
175    esac
176fi
177
178# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
179# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
180if [ -f ARCH/arch-${fcm_arch}.env ] ; then
181    echo >> $outfile
182    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
183    echo "Note that this new environement might be kept after compilation." 
184    echo "If this is the case, source again your personal environment after compilation. "
185    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
186    module list   >> $outfile 2>&1
187   
188    # Make a link to this file, to be used also in config.card
189    rm -f ARCH/arch.env
190    ln -s arch-${fcm_arch}.env ARCH/arch.env
191
192    # Source the file
193    source ARCH/arch.env   >> $outfile 2>&1
194
195    echo >> $outfile 
196    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
197    module list   >> $outfile 2>&1
198fi
199
200#### 2 Do the compilation
201## 2.1 Compile ioipsl
202cd $modipsl/modeles/IOIPSL
203echo; echo "NOW COMPILE IOIPSL"
204echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
205
206# Check if compilation with fcm is included in IOIPSL
207if [ ! -f makeioipsl_fcm ] ; then
208  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
209  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
210  exit
211fi
212
213echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
214     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
215# Test if compiling succeded
216if [[ $? != 0 ]] ; then
217    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
218    exit
219fi
220
221## 2.2 Compile xios
222cd $modipsl/modeles/XIOS
223echo; echo "NOW COMPILE XIOS"
224echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
225echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
226     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
227# Test if compiling succeded
228if [[ $? != 0 ]] ; then
229    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
230    exit
231fi
232# Move executables to modipsl/bin
233if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
234    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
235else
236    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
237    exit
238fi
239
240
241## 2.3 Compile orchidee
242cd $modipsl/modeles/ORCHIDEE
243echo; echo "NOW COMPILE ORCHIDEE"
244echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
245
246echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
247        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
248# Test if compiling finished
249if [[ $? != 0 ]] ; then
250    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
251    exit
252fi
253
254
255## 2.4 Compile LMDZ and INCA for regular latlon configuration
256if [ $regular_latlon = yes ] ; then
257
258    cd $modipsl/modeles/INCA
259    #compile INCA regulat lat_lon chimie librairy
260    echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}"
261    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp  -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_flag $clean_inca >> $outfile 
262         ./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
263
264    # Test if compiling finished
265    if [[ $? != 0 ]] ; then
266        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
267        exit
268    fi
269
270    echo "Move inca.dat modipsl/bin"
271    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ;  then 
272        mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${optchimie}.dat ;
273    else
274        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
275        exit   
276    fi
277
278
279    echo "Move tracer.def to  modipsl/bin"
280    if [[ -f $modipsl/modeles/INCA/tracer.def ]] ;  then
281        mv $modipsl/modeles/INCA/tracer.def $modipsl/bin/tracer_${optchimie}.def ;
282    fi
283
284   
285
286    cd $modipsl/modeles/LMDZ
287    # Compile LMDZ regular lat-lon exectuable
288    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"
289    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"   >> $outfile 
290
291
292    # Check if the compilation of LMDZ was previsouly interupted prematured.
293    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
294    # to ask question and wait for interactivly answer from the user.
295    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
296        echo >> $outfile
297        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
298        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
299        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
300        echo >> $outfile
301        rm -f libf/grid/dimensions.h
302        rm -f .lock
303    fi
304
305    # Need to define the proper option for radiative code compilation. By default, we use rrtm
306    case $rad in
307        oldrad) opt_rad="" ;;
308        rrtm)   opt_rad="-rad rrtm" ;;
309        ecrad)  opt_rad="-rad ecrad" ;;
310        *) echo Only oldrad rrtm ecrad for rad option ; exit
311    esac
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    suffix=${suffix}_${rad} 
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.