source: CONFIG/UNIFORM/v6/LMDZREPR_v6/compile_lmdzrepr.sh @ 6252

Last change on this file since 6252 was 6252, checked in by falletti, 19 months ago

LMDZREPR_v6: update compile.sh to use the new option -rad (based on what was done in IPSLCM6.2/compile_ipslcm6.sh)

  • Property svn:executable set to *
File size: 14.6 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# Default resolution of LMDZ in regular mode
19resol_atm=144x142x79
20# Also compile ce0l subprogram to LMDZ (y/n)
21ce0l=n
22# choose radiative code compilation option
23rad=rrtm
24opt_rad=""
25# Without REPROBUS (y/n)
26no_repr=n
27
28# fcm_arch
29fcm_arch=default
30# Default values to be overritten
31parallel=mpi_omp
32export fcm_arch parallel xios
33full_flag=""
34full_xios=""
35full_lmdz=""
36# If you want a custom suffix at the end of the executable's name
37custom_suffix=""
38
39# Default netcdf_lib is used for XIOS but can be change by argument
40netcdf_lib=""
41
42# Output text file for compilation of each component
43datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
44outfile=$submitdir/out_compile_lmdzor.$datestr
45echo > $outfile
46echo; echo "Text output from compilation will be stored in file out_compile_lmdzor.$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_lmdzrepr.sh
55#
56########################################################################
57
58./compile_config [Options]
59
60Options: -full, -full_xios, -full_lmdz,
61         -resol_atm,
62         -debug, -dev, -prod(default),
63         -custom_suffix
64
65Default parameters: optmode=prod ; resol_atm=144x142x79 ; parallel=mpi_omp, no_repr=n
66   
67
68Example 1: Default compilation of LMDZ-REPROBUS with XIOS and IOIPSL
69./compile_lmdzrepr.sh
70
71Example 2: Compile without REPROBUS (LMDZ only)
72./compile_lmdzrepr.sh -no_repr
73
74Example 3: Compile in debug mode
75./compile_lmdzrepr.sh -debug
76
77Example 4: Default compilation with full recompilation of all components
78./compile_lmdzrepr.sh -full
79
80Example 5: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79).
81The dimension can be changed to any other 3d dimension.
82Warning: LMDZREPR_v6 was only tested with 144x142x79.
83./compile_lmdzrepr.sh -resol_atm 96x95x79
84
85Example 6: Compile with a custom suffix at the end of the executable's name
86./compile_lmdzrepr.sh -custom_suffix my_suffix
87
88Example 7: choose radiative schema for LMDZ (oldrad/rrtm/ecrad). Default is rrtm
89./compile_lmdzrepr.sh -rad ecrad
90
91end_help
92exit;;
93        "-parallel")        parallel=$2 ; shift ; shift ;;
94        "-arch")                fcm_arch="$2" ; shift ; shift ;;
95        "-xios")                xios="$2" ; shift ; shift ;;
96        "-debug")               optmode=debug ; shift ;;
97        "-dev")                 optmode=dev ; shift ;;
98        "-prod")                optmode=prod ; shift ;;
99        "-resol_atm")       resol_atm=$2 ; shift ; shift ;;
100        "CE0L")             ce0l=y ; shift ;;
101    "-rad")             rad=$2; shift ; shift;;
102        "-full")            full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; shift ;;
103        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
104        "-full_lmdz")       full_lmdz="-full"  ; shift ;;
105        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
106    "-no_repr")         no_repr=y ; shift ;;
107    "-custom_suffix")   custom_suffix=_$2 ; shift ; 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}" >> $outfile 
114echo "   ce0l=${ce0l}" >> $outfile 
115echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
116echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz " >> $outfile
117echo "   no_repr=$no_repr "  >> $outfile 
118echo "   custom_suffix=$custom_suffix "  >> $outfile
119echo >> $outfile
120
121### Read host dependent default values
122### These variables will not be changed if they were set as argument
123###./host.sh $host
124# Later : Following lines should be set in host.sh file
125# begin host.sh
126if [ $fcm_arch == default ] ; then
127    # Find out current host and source specific paths and commands for the host
128    case $( hostname -s ) in
129        jean-zay*)
130            fcm_arch=X64_JEANZAY;;
131        irene170|irene171|irene190|irene191|irene192|irene193)
132            fcm_arch=X64_IRENE;;
133        irene172|irene173|irene194|irene195)
134            fcm_arch=X64_IRENE-AMD;;
135        asterix*|obelix*)
136            fcm_arch=ifort_LSCE
137            if [ "${parallel}" == "mpi_omp" ] ; then
138                echo "Warning!! Currently at Obelix hybrid mode is not possible."
139                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
140                echo ""
141                parallel=mpi
142            else
143                echo "You used -parallel" $parallel
144            fi ;;
145        ciclad*|climserv*|loholt*|camelot*)
146            fcm_arch=ifort_CICLAD;;
147        *)
148            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
149            echo Exit now.
150            exit
151    esac
152fi
153
154# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
155# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
156if [ -f ARCH/arch-${fcm_arch}.env ] ; then
157    echo >> $outfile
158    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
159    echo "Note that this new environement might be kept after compilation." 
160    echo "If this is the case, source again your personal environment after compilation. "
161    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
162    module list   >> $outfile 2>&1
163
164    # Make a link to this file, to be used also in config.card
165    rm -f ARCH/arch.env
166    ln -s arch-${fcm_arch}.env ARCH/arch.env
167
168    # Source the file
169    source ARCH/arch.env   >> $outfile 2>&1
170    echo >> $outfile 
171    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
172    module list   >> $outfile 2>&1
173fi
174
175#### 2 Do the compilation
176## 2.1 Compile ioipsl
177cd $modipsl/modeles/IOIPSL
178echo; echo "NOW COMPILE IOIPSL"
179echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
180
181# Check if compilation with fcm is included in IOIPSL
182if [ ! -f makeioipsl_fcm ] ; then
183  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
184  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
185  exit
186fi
187
188echo ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
189     ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
190# Test if compiling succeded
191if [[ $? != 0 ]] ; then
192    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
193    exit
194fi
195
196## 2.2 Compile xios
197cd $modipsl/modeles/XIOS
198echo; echo "NOW COMPILE XIOS"
199echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
200echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
201     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
202# Test if compiling succeded
203if [[ $? != 0 ]] ; then
204    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
205    exit
206fi
207# Move executables to modipsl/bin
208if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
209    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
210else
211    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
212    exit
213fi
214
215
216# ## 2.3 Compile orchidee
217# cd $modipsl/modeles/ORCHIDEE
218# echo; echo "NOW COMPILE ORCHIDEE"
219# echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile
220#
221#
222# # Check if the compilation of ORCHIDEE was previsouly interupted prematured.
223# # In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
224# # to ask question and wait for interactivly answer from the user.
225# if [ -f build/fcm.bld.lock ] ; then
226#     echo >> $outfile
227#     echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
228#     echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
229#     echo "           The file will now be removed. "   >> $outfile
230#     echo >> $outfile
231#     rm -f build/fcm.bld.lock
232# fi
233#
234# echo  ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver   >> $outfile
235#         ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver    >> $outfile 2>&1
236# # Test if compiling finished
237# if [[ $? != 0 ]] ; then
238#     echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
239#     exit
240# fi
241#
242# # Rename executables to contain $optmode
243# if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
244# if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
245
246
247## 2.3 Compile LMDZ for regular latlon configuration with or without REPROBUS
248cd $modipsl/modeles/LMDZ
249# Compile LMDZ regular lat-lon executable
250echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
251echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
252# Retrieve the final svn release number, needed for radiative code suffix of executable
253lmdzsvn=`svnversion . | egrep -o "[0-9]+"  | awk 'NR==1'`
254
255# Check if the compilation of LMDZ was previsouly interupted prematured.
256# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
257# to ask question and wait for interactivly answer from the user.
258if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
259  echo >> $outfile
260  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
261  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
262  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
263  echo >> $outfile
264  rm -f libf/grid/dimensions.h
265  rm -f .lock
266fi
267
268# Need to define the proper option for radiative code compilation. By default, we use rrtm
269case $rad in
270    oldrad) opt_rad="" ;;
271    rrtm)   if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;;
272    ecrad)  opt_rad="-rad ecrad" ;;
273    *) echo Only oldrad rrtm ecrad for rad option ; exit
274esac
275
276if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi
277
278
279if [ $no_repr == y ] ; then
280    echo "COMPILING LMDZ ONLY (no Reprobus)"
281    echo >> $outfile ; echo "COMPILING LMDZ (no Reprobus)"   >> $outfile
282    echo ./makelmdz_fcm -d ${resol_atm} -p lmd $opt_rad -$optmode -mem -parallel $parallel -io xios -cosp true -v false -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 
283    ./makelmdz_fcm -d ${resol_atm} -p lmd $opt_rad -$optmode -mem -parallel $parallel -io xios -cosp true -v false -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 2>&1
284else
285    echo "COMPILING LMDZ WITH REPROBUS"
286    echo >> $outfile ; echo "COMPILING LMDZ WITH REPROBUS"  >> $outfile
287    echo ./makelmdz_fcm -ext_src ../REPROBUS -cpp REPROBUS -d ${resol_atm} -p lmd $opt_rad -$optmode -mem -parallel $parallel -io xios -cosp true -v false -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 
288    ./makelmdz_fcm -ext_src ../REPROBUS -cpp REPROBUS -d ${resol_atm} -p lmd $opt_rad -$optmode -mem -parallel $parallel -io xios -cosp true -v false -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 2>&1
289fi
290# Test if compiling finished
291if [[ $? != 0 ]] ; then
292    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
293    exit
294fi
295
296# Move executables to modipsl/bin folder
297echo >> $outfile
298echo "Move gcm.e executable to modipsl/bin" >> $outfile
299echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
300ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
301echo >> $outfile
302
303# Find executable suffix
304suffix=_${resol_atm}_phylmd
305if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
306if [ $parallel == seq ] || [ $parallel == none ] ; then
307    suffix=${suffix}_seq.e
308else
309    suffix=${suffix}_para_mem.e
310fi
311echo gcm suffix = $suffix
312
313if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
314    if [ $no_repr == y ] ; then
315        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_lmdz_only${custom_suffix}.e
316    else
317        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}${custom_suffix}.e
318    fi
319else
320    echo "ERROR gcm${suffix} executable does not exist." 
321    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
322    exit
323fi 
324
325
326# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
327# NOT TESTED YET!!!
328if [ $ce0l == y ] ; then
329    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
330    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
331    echo "WARNING: not tested with LMDZREPR_v6 !"
332    echo "WARNING: not tested with LMDZREPR_v6 !"  >> $outfile
333   
334    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
335    ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 2>&1
336    # Test if compiling finished
337    if [[ $? != 0 ]] ; then
338        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
339        exit
340    fi
341
342   
343    # Move executables to modipsl/bin folder
344    echo >> $outfile
345    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
346    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
347    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
348    echo >> $outfile
349    suffix=_${resol_atm}_phylmd_seq.e
350    echo ce0l suffix = $suffix
351
352    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
353        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
354    else
355        echo "ERROR ce0l${suffix} executable does not exist." 
356        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
357        exit
358    fi 
359fi
360
361
362echo >>$outfile ; echo "ALL COMPILATION FINISHED" >> $outfile
363echo ls -lrt modipsl/bin >> $outfile
364ls -lrt $modipsl/bin >> $outfile
365
366echo; echo "ALL COMPILATIONS FINISHED" ; echo
367echo "Executables are found in modipsl/bin"
368echo "!!! Check that executable names correspond with the name set in config.card before launching the job !!!"
369echo ls -lrt modipsl/bin
370ls -lrt $modipsl/bin
371
372date
373
374exit
Note: See TracBrowser for help on using the repository browser.