source: CONFIG/UNIFORM/v6/LMDZORINCA_v6.2/compile_lmdzorinca.sh @ 6161

Last change on this file since 6161 was 5698, checked in by acosce, 3 years ago

add date at the end of the compilation log file's name for LMDZORINCA_v6.2 configuration

  • Property svn:executable set to *
File size: 11.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# Resolution of LMDZ in regular mode
19regular_latlon=yes
20resol_atm_3d=96x95x39
21optchimie=NMHC_AER_S
22#recompilation de inca seul ou de tous les modeles
23clean_inca=""
24full_flag=""
25
26# fcm_arch
27fcm_arch=default
28# Default values to be overritten
29parallel=mpi_omp
30export fcm_arch parallel xios
31
32# Default netcdf_lib is used for XIOS but can be change by argument
33netcdf_lib=""
34
35# Output text file for compilation of each component
36datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
37outfile=$submitdir/out_compile_lmdzorinca.$datestr
38echo > $outfile
39echo; echo "Text output from compilation will be stored in file out_compile_lmdzor.$datestr"; echo 
40
41#### Read arguments
42# Loop over all arguments to modify default set up
43while (($# > 0)) ; do
44    case $1 in
45        "-h") cat <<fin
46
47########################################################################
48# Usage of the script compile_lmdzorinca.sh
49#
50########################################################################
51
52./compile_config [Options]
53
54Options: -full, -regular_latlon, -chimie, -clean_inca, -debug, -dev, -prod(default)
55
56Example 1: Default compilation of LMDZ-ORCHIDEE-INCA  with XIOS and IOIPSL - NMHC_AER_S / 96x95x39
57./compile_lmdzorinca.sh
58
59Example 2: Compilation with a chosen chemistry, for example DUSS  (default: NMHC_AER_S)
60./compile_lmdzorinca.sh -chimie DUSS
61
62Example 3: Compile in debug mode  - in this case you need to modify Optmode in config.card
63./compile_lmdzorinca.sh -debug
64
65Example 4: Default compilation with full recompilation of all components
66./compile_lmdzorinca.sh -full
67
68Example 5: Default compilation with recompilation of inca model only
69./compile_lmdzorinca.sh -clean_inca
70
71Example 6: Compilation of LMDZ in regular lat-lon for other dimensions (default: 96x95x39)
72The dimension can be changed to any other 3d dimension.
73./compile_lmdzorinca.sh -regular_latlon 144x142x79
74
75fin
76            exit;;
77
78        "-parallel")
79            parallel=$2 ; shift ; shift ;;
80       
81        "-arch")
82            fcm_arch="$2" ; shift ; shift ;;
83       
84        "-xios")
85            xios="$2" ; shift ; shift ;;
86       
87        "-optmode")
88            optmode=$2 ; shift ; shift ;;
89
90        "-debug")
91            optmode=debug ; shift ;;
92
93        "-dev")
94            optmode=dev ; shift ;;
95
96        "-prod")
97            optmode=prod ; shift ;;
98
99        "-regular_latlon")
100            regular_latlon=yes ;
101            resol_atm_3d=$2 ; shift ; shift ;;
102       
103        "-full")
104            full_flag="-full"; shift ;;
105
106        "-clean_inca")
107            clean_inca="-clean"; shift ;;
108       
109        "-netcdf_lib_seq")
110            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
111
112        "-chimie") 
113            echo $2;
114            optchimie=$2; shift ; shift;;
115
116        *)
117            echo "unknown option "$2" , exiting..."
118            exit
119    esac
120done
121echo; echo "********************* WARNING **********************"
122echo; echo "********************* WARNING **********************"
123echo; echo " if you are working with an lmdz version before rev 3563 (check it with command svn info) "
124echo "you need to modify phylmd/physiq_mod.F90 file " 
125echo "add ! to comment lines if/endif before and after the call to AEROSOL_METEO_CALC"
126echo; echo "********************* WARNING **********************"
127echo; echo "********************* WARNING **********************"
128
129echo "Following arguments are set in current compiling:" >> $outfile 
130echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile 
131echo "   chimie = $optchimie, clean_inca = ${clean_inca}" 
132echo >> $outfile
133
134### Read host dependent default values
135### These variables will not be changed if they were set as argument
136###./host.sh $host
137# Later : Following lines should be set in host.sh file
138# begin host.sh
139if [ $fcm_arch == default ] ; then
140    # Find out current host and source specific paths and commands for the host
141    case $( hostname -s ) in
142        jean-zay*)
143            fcm_arch=X64_JEANZAY;;
144        irene170|irene171|irene190|irene191|irene192|irene193)
145            fcm_arch=X64_IRENE;;
146        irene172|irene173|irene194|irene195)
147            fcm_arch=X64_IRENE-AMD;;
148        asterix*|obelix*)
149            fcm_arch=ifort_LSCE;;
150        ciclad*|climserv*)
151            fcm_arch=ifort_CICLAD;;
152        *)
153            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
154            echo Exit now.
155            exit
156    esac
157fi
158
159# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
160# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
161if [ -f ARCH/arch-${fcm_arch}.env ] ; then
162    echo >> $outfile
163    echo "The file ARCH/arch-${fcm_arch}.env will be used for the compilation of each component"
164    rm -f ARCH/arch.env
165    ln -s arch-${fcm_arch}.env ARCH/arch.env
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 -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
182     ./makeioipsl_fcm -$optmode -parallel -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_flag   >> $outfile 
194     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $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
210cd $modipsl/modeles/ORCHIDEE
211echo; echo "NOW COMPILE ORCHIDEE"
212echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
213
214echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
215        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
216# Test if compiling finished
217if [[ $? != 0 ]] ; then
218    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
219    exit
220fi
221
222
223## 2.4 Compile LMDZ and INCA for regular latlon configuration
224if [ $regular_latlon = yes ] ; then
225
226    cd $modipsl/modeles/INCA
227    #compile INCA regulat lat_lon chimie librairy
228    echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}"
229    echo ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm_3d} -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_flag $clean_inca >> $outfile 
230    ./makeinca_fcm -chimie ${optchimie} -$optmode -xios -parallel mpi_omp -resol ${resol_atm_3d} -j 8 -arch ${fcm_arch} -arch_path $arch_path  $full_flag $clean_inca >> $outfile 2>&1
231
232    # Test if compiling finished
233    if [[ $? != 0 ]] ; then
234        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
235        exit
236    fi
237
238    echo "Move inca.dat modipsl/bin"
239    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ;  then 
240        mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${resol_atm_3d}_${optmode}_${optchimie}.dat ;
241#       cp $modipsl/bin/inca_${resol_atm_3d}.dat inca.dat;
242    else
243        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
244        exit   
245    fi
246
247
248    cd $modipsl/modeles/LMDZ
249    # Compile LMDZ regular lat-lon exectuable
250    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"
251    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"   >> $outfile 
252
253
254    # Check if the compilation of LMDZ was previsouly interupted prematured.
255    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
256    # to ask question and wait for interactivly answer from the user.
257    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
258        echo >> $outfile
259        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
260        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
261        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
262        echo >> $outfile
263        rm -f libf/grid/dimensions.h
264        rm -f .lock
265    fi
266
267
268
269
270
271    echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 
272         ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -chimie INCA -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 2>&1
273    # Test if compiling finished
274    if [[ $? != 0 ]] ; then
275        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
276        exit
277    fi
278
279#    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
280#    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"
281#    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"   >> $outfile
282#
283#    echo ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l    >> $outfile
284#         ./makelmdz_fcm -d ${resol_atm_3d} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag ce0l    >> $outfile 2>&1
285#    # Test if compiling finished
286#    if [[ $? != 0 ]] ; then
287#       echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
288#       exit
289#    fi
290#
291    # Find executable suffix
292    if [ $parallel == seq ] || [ $parallel == none ] ; then
293        suffix=_${resol_atm_3d}_phylmd_seq_orch_inca
294    else
295        suffix=_${resol_atm_3d}_phylmd_para_mem_orch_inca
296    fi
297    echo suffix = $suffix
298   
299    # Move executables to modipsl/bin folder
300    echo "Move gcm.e and ce0l executable to modipsl/bin"
301    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ;  then
302         mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}_${optmode}_${optchimie}.e ;
303   
304    else
305        echo "THERE IS A PROBLEM IN EXECUTABLE CREATION - STOP"
306        exit
307
308    fi
309#    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm_3d}_${optmode}_${optchimie}.e ; fi
310
311fi
312
313
314echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
315echo; echo "ALL COMPILING FINISHED"
316
317if [ $optmode == 'debug' ] || [ $optmode == 'dev' ]; then
318    echo; echo "===================================================="
319    echo; echo "DON'\T FORGET TO MODIFY Optmode IN cconfig.card" 
320    echo; echo "Optmode="$optmode
321    echo; echo "===================================================="
322fi
323
324date
325exit
326
327
Note: See TracBrowser for help on using the repository browser.