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

Last change on this file since 5944 was 5944, checked in by falletti, 3 years ago

Add experiment for lmdzrepr cmip6

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