source: CONFIG/UNIFORM/v7/ICOLMDZOR_v7/compile_icolmdzor.sh @ 4896

Last change on this file since 4896 was 4663, checked in by jgipsl, 5 years ago

As done in compilat_ipslcm6.sh [4622]:

  • Add date on the output text file to avoid deleating preivously file if recompilation
  • Check and remove dimensions.h and .lock in LMDZ to avoid makelmdz_fcm interupt the compilation with the question:

"WARNING: you are probably already compiling the model somewhere else.
Wait until the first compilation is finished before launching this one.
If you are sure that you are not compiling elsewhere, just answer
yes (or 'oui') to the question below to proceed.
Do you wish to continue?"

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