source: CONFIG/UNIFORM/v6/LMDZOR_v6.2/compile_lmdzor.sh @ 6161

Last change on this file since 6161 was 6112, checked in by jgipsl, 2 years ago

Added choice of radiation scheme and version of cosp for LMDZ in the main compilation script for LMDZOR configurations. Done by Abderrahmane Idelkadi, LMD

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