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

Last change on this file since 5110 was 5110, checked in by acosce, 4 years ago

add more write in compile_lmdzorinca script to help to understand the compilation

  • Property svn:executable set to *
File size: 11.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
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        irene*)
144            fcm_arch=X64_IRENE;;
145        asterix*|obelix*)
146            fcm_arch=ifort_LSCE;;
147        ciclad*|climserv*)
148            fcm_arch=ifort_CICLAD;;
149        *)
150            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
151            echo Exit now.
152            exit
153    esac
154fi
155
156# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
157# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
158if [ -f ARCH/arch-${fcm_arch}.env ] ; then
159    echo >> $outfile
160    echo "The file ARCH/arch-${fcm_arch}.env will be used for the compilation of each component"
161    rm -f ARCH/arch.env
162    ln -s arch-${fcm_arch}.env ARCH/arch.env
163fi
164
165#### 2 Do the compilation
166## 2.1 Compile ioipsl
167cd $modipsl/modeles/IOIPSL
168echo; echo "NOW COMPILE IOIPSL"
169echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
170
171# Check if compilation with fcm is included in IOIPSL
172if [ ! -f makeioipsl_fcm ] ; then
173  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
174  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
175  exit
176fi
177
178echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
179     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
180# Test if compiling succeded
181if [[ $? != 0 ]] ; then
182    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
183    exit
184fi
185
186## 2.2 Compile xios
187cd $modipsl/modeles/XIOS
188echo; echo "NOW COMPILE XIOS"
189echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
190echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
191     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
192# Test if compiling succeded
193if [[ $? != 0 ]] ; then
194    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
195    exit
196fi
197# Move executables to modipsl/bin
198if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
199    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
200else
201    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
202    exit
203fi
204
205
206## 2.3 Compile orchidee
207cd $modipsl/modeles/ORCHIDEE
208echo; echo "NOW COMPILE ORCHIDEE"
209echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
210
211echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
212        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
213# Test if compiling finished
214if [[ $? != 0 ]] ; then
215    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
216    exit
217fi
218
219
220## 2.4 Compile LMDZ and INCA for regular latlon configuration
221if [ $regular_latlon = yes ] ; then
222
223    cd $modipsl/modeles/INCA
224    #compile INCA regulat lat_lon chimie librairy
225    echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}"
226    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 
227    ./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
228
229    # Test if compiling finished
230    if [[ $? != 0 ]] ; then
231        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
232        exit
233    fi
234
235    echo "Move inca.dat modipsl/bin"
236    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ;  then 
237        mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${resol_atm_3d}_${optmode}_${optchimie}.dat ;
238#       cp $modipsl/bin/inca_${resol_atm_3d}.dat inca.dat;
239    else
240        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
241        exit   
242    fi
243
244
245    cd $modipsl/modeles/LMDZ
246    # Compile LMDZ regular lat-lon exectuable
247    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"
248    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"   >> $outfile 
249
250
251    # Check if the compilation of LMDZ was previsouly interupted prematured.
252    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
253    # to ask question and wait for interactivly answer from the user.
254    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
255        echo >> $outfile
256        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
257        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
258        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
259        echo >> $outfile
260        rm -f libf/grid/dimensions.h
261        rm -f .lock
262    fi
263
264
265
266
267
268    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 
269         ./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
270    # Test if compiling finished
271    if [[ $? != 0 ]] ; then
272        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
273        exit
274    fi
275
276#    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
277#    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"
278#    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"   >> $outfile
279#
280#    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
281#         ./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
282#    # Test if compiling finished
283#    if [[ $? != 0 ]] ; then
284#       echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
285#       exit
286#    fi
287#
288    # Find executable suffix
289    if [ $parallel == seq ] || [ $parallel == none ] ; then
290        suffix=_${resol_atm_3d}_phylmd_seq_orch_inca
291    else
292        suffix=_${resol_atm_3d}_phylmd_para_mem_orch_inca
293    fi
294    echo suffix = $suffix
295   
296    # Move executables to modipsl/bin folder
297    echo "Move gcm.e and ce0l executable to modipsl/bin"
298    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm_3d}_${optmode}_${optchimie}.e ; fi
299    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
300
301fi
302
303
304echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
305echo; echo "ALL COMPILING FINISHED"
306
307if [ $optmode == 'debug' ] || [ $optmode == 'dev' ]; then
308    echo; echo "===================================================="
309    echo; echo "DON'\T FORGET TO MODIFY Optmode IN cconfig.card" 
310    echo; echo "Optmode="$optmode
311    echo; echo "===================================================="
312fi
313
314date
315exit
316
317
Note: See TracBrowser for help on using the repository browser.