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

Last change on this file was 6629, checked in by falletti, 8 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: 15.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#### 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            if [[ $( hostname -s ) != *"pp"* ]] ; then
131                echo "Warning! You MUST compile on jean-zay-pp."
132                echo "EXIT"
133                exit
134            else
135                fcm_arch=X64_JEANZAY
136            fi ;;
137        irene170|irene171|irene190|irene191|irene192|irene193)
138            fcm_arch=X64_IRENE;;
139        irene172|irene173|irene194|irene195)
140            fcm_arch=X64_IRENE-AMD;;
141        asterix*|obelix*)
142            fcm_arch=ifort_LSCE
143            if [ "${parallel}" == "mpi_omp" ] ; then
144                echo "Warning!! Currently at Obelix hybrid mode is not possible."
145                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
146                echo ""
147                parallel=mpi
148            else
149                echo "You used -parallel" $parallel
150            fi ;;
151        ciclad*|climserv*|loholt*|camelot*)
152            fcm_arch=ifort_CICLAD;;
153        *)
154            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
155            echo Exit now.
156            exit
157    esac
158fi
159
160# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
161# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
162if [ -f ARCH/arch-${fcm_arch}.env ] ; then
163    echo >> $outfile
164    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
165    echo "Note that this new environement might be kept after compilation." 
166    echo "If this is the case, source again your personal environment after compilation. "
167    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
168    module list   >> $outfile 2>&1
169    # Get initial svn version
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        # Put back initial version of svn
180        module load ${svn_version}
181    fi
182    echo >> $outfile 
183    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
184    module list   >> $outfile 2>&1
185fi
186
187#### 2 Do the compilation
188## 2.1 Compile ioipsl
189cd $modipsl/modeles/IOIPSL
190echo; echo "NOW COMPILE IOIPSL"
191echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
192
193# Check if compilation with fcm is included in IOIPSL
194if [ ! -f makeioipsl_fcm ] ; then
195  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
196  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
197  exit
198fi
199
200echo ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
201     ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
202# Test if compiling succeded
203if [[ $? != 0 ]] ; then
204    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
205    exit
206fi
207
208## 2.2 Compile xios
209cd $modipsl/modeles/XIOS
210echo; echo "NOW COMPILE XIOS"
211echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
212echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
213     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
214# Test if compiling succeded
215if [[ $? != 0 ]] ; then
216    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
217    exit
218fi
219# Move executables to modipsl/bin
220if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
221    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
222else
223    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
224    exit
225fi
226
227
228# ## 2.3 Compile orchidee
229# cd $modipsl/modeles/ORCHIDEE
230# echo; echo "NOW COMPILE ORCHIDEE"
231# echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile
232#
233#
234# # Check if the compilation of ORCHIDEE was previsouly interupted prematured.
235# # In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
236# # to ask question and wait for interactivly answer from the user.
237# if [ -f build/fcm.bld.lock ] ; then
238#     echo >> $outfile
239#     echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
240#     echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
241#     echo "           The file will now be removed. "   >> $outfile
242#     echo >> $outfile
243#     rm -f build/fcm.bld.lock
244# fi
245#
246# echo  ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver   >> $outfile
247#         ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver    >> $outfile 2>&1
248# # Test if compiling finished
249# if [[ $? != 0 ]] ; then
250#     echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
251#     exit
252# fi
253#
254# # Rename executables to contain $optmode
255# if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
256# if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
257
258
259## 2.3 Compile LMDZ for regular latlon configuration with or without REPROBUS
260cd $modipsl/modeles/LMDZ
261# Compile LMDZ regular lat-lon executable
262echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
263echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
264# Retrieve the final svn release number, needed for radiative code suffix of executable
265lmdzsvn=`svnversion . | egrep -o "[0-9]+"  | awk 'NR==1'`
266echo >> $outfile ; echo "lmdzsvn= $lmdzsvn "   >> $outfile
267
268# Check if the compilation of LMDZ was previsouly interupted prematured.
269# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
270# to ask question and wait for interactivly answer from the user.
271if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
272  echo >> $outfile
273  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
274  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
275  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
276  echo >> $outfile
277  rm -f libf/grid/dimensions.h
278  rm -f .lock
279fi
280
281# Need to define the proper option for radiative code compilation. By default, we use rrtm
282case $rad in
283    oldrad) opt_rad="" ;;
284    rrtm)   if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;;
285    ecrad)  opt_rad="-rad ecrad" ;;
286    *) echo Only oldrad rrtm ecrad for rad option ; exit
287esac
288
289if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi
290
291
292if [ $no_repr == y ] ; then
293    echo "COMPILING LMDZ ONLY (no Reprobus)"
294    echo >> $outfile ; echo "COMPILING LMDZ (no Reprobus)"   >> $outfile
295    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 
296    ./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
297else
298    echo "COMPILING LMDZ WITH REPROBUS"
299    echo >> $outfile ; echo "COMPILING LMDZ WITH REPROBUS"  >> $outfile
300    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 
301    ./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
302fi
303# Test if compiling finished
304if [[ $? != 0 ]] ; then
305    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
306    exit
307fi
308
309# Move executables to modipsl/bin folder
310echo >> $outfile
311echo "Move gcm.e executable to modipsl/bin" >> $outfile
312echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
313ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
314echo >> $outfile
315
316# Find executable suffix
317suffix=_${resol_atm}_phylmd
318if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
319if [ $parallel == seq ] || [ $parallel == none ] ; then
320    suffix=${suffix}_seq.e
321else
322    suffix=${suffix}_para_mem.e
323fi
324echo gcm suffix = $suffix
325
326if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
327    if [ $no_repr == y ] ; then
328        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_lmdz_only${custom_suffix}.e
329    else
330        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}${custom_suffix}.e
331    fi
332else
333    echo "ERROR gcm${suffix} executable does not exist." 
334    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
335    exit
336fi 
337
338
339# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
340# NOT TESTED YET!!!
341if [ $ce0l == y ] ; then
342    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
343    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
344    echo "WARNING: not tested with LMDZREPR_v6 !"
345    echo "WARNING: not tested with LMDZREPR_v6 !"  >> $outfile
346   
347    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 
348    ./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
349    # Test if compiling finished
350    if [[ $? != 0 ]] ; then
351        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
352        exit
353    fi
354
355   
356    # Move executables to modipsl/bin folder
357    echo >> $outfile
358    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
359    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
360    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
361    echo >> $outfile
362    suffix=_${resol_atm}_phylmd_seq.e
363    echo ce0l suffix = $suffix
364
365    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
366        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
367    else
368        echo "ERROR ce0l${suffix} executable does not exist." 
369        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
370        exit
371    fi 
372fi
373
374
375echo >>$outfile ; echo "ALL COMPILATION FINISHED" >> $outfile
376echo ls -lrt modipsl/bin >> $outfile
377ls -lrt $modipsl/bin >> $outfile
378
379echo; echo "ALL COMPILATIONS FINISHED" ; echo
380echo "Executables are found in modipsl/bin"
381echo "!!! Check that executable names correspond with the name set in config.card before launching the job !!!"
382echo ls -lrt modipsl/bin
383ls -lrt $modipsl/bin
384
385date
386
387exit
Note: See TracBrowser for help on using the repository browser.