source: CONFIG/UNIFORM/v7/ICOLMDZORINCA_v7/compile_lmdzorinca.sh @ 5545

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

Add irene amd for compilation

  • Property svn:executable set to *
File size: 10.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# 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
36outfile=$submitdir/out_compile_lmdzorinca
37rm -f $outfile; echo > $outfile
38echo; echo "Text output from compilation will be stored in file out_compile_lmdzorinca"; echo 
39
40#### Read arguments
41# Loop over all arguments to modify default set up
42while (($# > 0)) ; do
43    case $1 in
44        "-h") cat <<fin
45
46########################################################################
47# Usage of the script compile_lmdzorinca.sh
48#
49########################################################################
50
51./compile_config [Options]
52
53Options: -full, -regular_latlon, -chimie, -clean_inca, -debug, -dev, -prod(default)
54
55Example 1: Default compilation of LMDZ-ORCHIDEE-INCA  with XIOS and IOIPSL - NMHC_AER_S / 96x95x39
56./compile_lmdzorinca.sh
57
58Example 2: Compilation with a chosen chemistry, for example DUSS  (default: NMHC_AER_S)
59./compile_lmdzorinca.sh -chimie DUSS
60
61Example 3: Compile in debug mode  - in this case you need to modify Optmode in config.card
62./compile_lmdzorinca.sh -debug
63
64Example 4: Default compilation with full recompilation of all components
65./compile_lmdzorinca.sh -full
66
67Example 5: Default compilation with recompilation of inca model only
68./compile_lmdzorinca.sh -clean_inca
69
70Example 6: Compilation of LMDZ in regular lat-lon for other dimensions (default: 96x95x39)
71The dimension can be changed to any other 3d dimension.
72./compile_lmdzorinca.sh -regular_latlon 144x142x79
73
74fin
75            exit;;
76
77        "-parallel")
78            parallel=$2 ; shift ; shift ;;
79       
80        "-arch")
81            fcm_arch="$2" ; shift ; shift ;;
82       
83        "-xios")
84            xios="$2" ; shift ; shift ;;
85       
86        "-optmode")
87            optmode=$2 ; shift ; shift ;;
88
89        "-debug")
90            optmode=debug ; shift ;;
91
92        "-dev")
93            optmode=dev ; shift ;;
94
95        "-prod")
96            optmode=prod ; shift ;;
97
98        "-regular_latlon")
99            regular_latlon=yes ;
100            resol_atm_3d=$2 ; shift ; shift ;;
101       
102        "-full")
103            full_flag="-full"; shift ;;
104
105        "-clean_inca")
106            clean_inca="-clean"; shift ;;
107       
108        "-netcdf_lib_seq")
109            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
110
111        "-chimie") 
112            echo $2;
113            optchimie=$2; shift ; shift;;
114
115        *)
116            echo "unknown option "$2" , exiting..."
117            exit
118    esac
119done
120echo; echo "********************* WARNING **********************"
121echo; echo "********************* WARNING **********************"
122echo; echo " if you are working with an lmdz version before rev 3563 (check it with command svn info) "
123echo "you need to modify phylmd/physiq_mod.F90 file " 
124echo "add ! to comment lines if/endif before and after the call to AEROSOL_METEO_CALC"
125echo; echo "********************* WARNING **********************"
126echo; echo "********************* WARNING **********************"
127
128echo "Following arguments are set in current compiling:" >> $outfile 
129echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag regular_latlon=$regular_latlon" >> $outfile 
130echo "   chimie = $optchimie, clean_inca = ${clean_inca}" 
131echo >> $outfile
132
133### Read host dependent default values
134### These variables will not be changed if they were set as argument
135###./host.sh $host
136# Later : Following lines should be set in host.sh file
137# begin host.sh
138if [ $fcm_arch == default ] ; then
139    # Find out current host and source specific paths and commands for the host
140    case $( hostname -s ) in
141        ada*)
142            fcm_arch=X64_ADA;;
143        irene170|irene171|irene190|irene191|irene192|irene193)
144            fcm_arch=X64_IRENE;;
145        irene172|irene173|irene194|irene195)
146            fcm_arch=X64_IRENE-AMD;;
147        asterix*|obelix*)
148            fcm_arch=ifort_LSCE;;
149        ciclad*|climserv*)
150            fcm_arch=ifort_CICLAD;;
151        *)
152            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
153            echo Exit now.
154            exit
155    esac
156fi
157
158# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
159# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
160if [ -f ARCH/arch-${fcm_arch}.env ] ; then
161    echo >> $outfile
162    echo "The file ARCH/arch-${fcm_arch}.env will be used for the compilation of each component"
163    rm -f ARCH/arch.env
164    ln -s arch-${fcm_arch}.env ARCH/arch.env
165fi
166
167#### 2 Do the compilation
168## 2.1 Compile ioipsl
169cd $modipsl/modeles/IOIPSL
170echo; echo "NOW COMPILE IOIPSL"
171echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
172
173# Check if compilation with fcm is included in IOIPSL
174if [ ! -f makeioipsl_fcm ] ; then
175  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
176  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
177  exit
178fi
179
180echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
181     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
182# Test if compiling succeded
183if [[ $? != 0 ]] ; then
184    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
185    exit
186fi
187
188## 2.2 Compile xios
189cd $modipsl/modeles/XIOS
190echo; echo "NOW COMPILE XIOS"
191echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
192echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
193     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
194# Test if compiling succeded
195if [[ $? != 0 ]] ; then
196    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
197    exit
198fi
199# Move executables to modipsl/bin
200if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
201    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
202else
203    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
204    exit
205fi
206
207
208## 2.3 Compile orchidee
209cd $modipsl/modeles/ORCHIDEE
210echo; echo "NOW COMPILE ORCHIDEE"
211echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
212
213echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
214        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
215# Test if compiling finished
216if [[ $? != 0 ]] ; then
217    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
218    exit
219fi
220
221
222## 2.4 Compile LMDZ and INCA for regular latlon configuration
223if [ $regular_latlon = yes ] ; then
224
225    cd $modipsl/modeles/INCA
226    #compile INCA regulat lat_lon chimie librairy
227    echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}"
228    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 
229    ./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
230
231    # Test if compiling finished
232    if [[ $? != 0 ]] ; then
233        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
234        exit
235    fi
236
237    echo "Move inca.dat modipsl/bin"
238    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ;  then 
239        mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${resol_atm_3d}_${optmode}_${optchimie}.dat ;
240#       cp $modipsl/bin/inca_${resol_atm_3d}.dat inca.dat;
241    else
242        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
243        exit   
244    fi
245
246
247    cd $modipsl/modeles/LMDZ
248    # Compile LMDZ regular lat-lon exectuable
249    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"
250    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"   >> $outfile 
251
252    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 
253         ./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
254    # Test if compiling finished
255    if [[ $? != 0 ]] ; then
256        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
257        exit
258    fi
259
260#    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
261#    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"
262#    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"   >> $outfile
263#
264#    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
265#         ./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
266#    # Test if compiling finished
267#    if [[ $? != 0 ]] ; then
268#       echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
269#       exit
270#    fi
271#
272    # Find executable suffix
273    if [ $parallel == seq ] || [ $parallel == none ] ; then
274        suffix=_${resol_atm_3d}_phylmd_seq_orch_inca
275    else
276        suffix=_${resol_atm_3d}_phylmd_para_mem_orch_inca
277    fi
278    echo suffix = $suffix
279   
280    # Move executables to modipsl/bin folder
281    echo "Move gcm.e and ce0l executable to modipsl/bin"
282    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ; then
283        mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}_${optmode}_${optchimie}.e ;
284    else
285        echo "THERE IS A PROBLEM IN EXECUTABLE CREATION - STOP"
286        exit
287    fi
288#    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
289
290fi
291
292
293echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
294echo; echo "ALL COMPILING FINISHED"
295
296if [ $optmode == 'debug' ] || [ $optmode == 'dev' ]; then
297    echo; echo "===================================================="
298    echo; echo "DON'\T FORGET TO MODIFY Optmode IN cconfig.card" 
299    echo; echo "Optmode="$optmode
300    echo; echo "===================================================="
301fi
302
303date
304exit
305
306
Note: See TracBrowser for help on using the repository browser.