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

Last change on this file since 4802 was 4706, checked in by acosce, 5 years ago

Add comments in compile_lmdzorinca.sh script

  • Property svn:executable set to *
File size: 10.1 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 >> $outfile
131
132### Read host dependent default values
133### These variables will not be changed if they were set as argument
134###./host.sh $host
135# Later : Following lines should be set in host.sh file
136# begin host.sh
137if [ $fcm_arch == default ] ; then
138    # Find out current host and source specific paths and commands for the host
139    case $( hostname -s ) in
140        ada*)
141            fcm_arch=X64_ADA;;
142        irene*)
143            fcm_arch=X64_IRENE;;
144        asterix*|obelix*)
145            fcm_arch=ifort_LSCE;;
146        ciclad*|climserv*)
147            fcm_arch=ifort_CICLAD;;
148        *)
149            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
150            echo Exit now.
151            exit
152    esac
153fi
154
155# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
156# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
157if [ -f ARCH/arch-${fcm_arch}.env ] ; then
158    echo >> $outfile
159    echo "The file ARCH/arch-${fcm_arch}.env will be used for the compilation of each component"
160    rm -f ARCH/arch.env
161    ln -s arch-${fcm_arch}.env ARCH/arch.env
162fi
163
164#### 2 Do the compilation
165## 2.1 Compile ioipsl
166cd $modipsl/modeles/IOIPSL
167echo; echo "NOW COMPILE IOIPSL"
168echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
169
170# Check if compilation with fcm is included in IOIPSL
171if [ ! -f makeioipsl_fcm ] ; then
172  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
173  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
174  exit
175fi
176
177echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
178     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
179# Test if compiling succeded
180if [[ $? != 0 ]] ; then
181    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
182    exit
183fi
184
185## 2.2 Compile xios
186cd $modipsl/modeles/XIOS
187echo; echo "NOW COMPILE XIOS"
188echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
189echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
190     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
191# Test if compiling succeded
192if [[ $? != 0 ]] ; then
193    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
194    exit
195fi
196# Move executables to modipsl/bin
197if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
198    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
199else
200    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
201    exit
202fi
203
204
205## 2.3 Compile orchidee
206cd $modipsl/modeles/ORCHIDEE
207echo; echo "NOW COMPILE ORCHIDEE"
208echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
209
210echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
211        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
212# Test if compiling finished
213if [[ $? != 0 ]] ; then
214    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
215    exit
216fi
217
218
219## 2.4 Compile LMDZ and INCA for regular latlon configuration
220if [ $regular_latlon = yes ] ; then
221
222    cd $modipsl/modeles/INCA
223    #compile INCA regulat lat_lon chimie librairy
224    echo; echo "NOW COMPILE INCA ${optchimie} on resolution = ${resol_atm_3d}"
225    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 
226    ./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
227
228    # Test if compiling finished
229    if [[ $? != 0 ]] ; then
230        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
231        exit
232    fi
233
234    echo "Move inca.dat modipsl/bin"
235    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat ]] ;  then 
236        mv $modipsl/modeles/INCA/SIMULATIONS/$optchimie/inca.dat $modipsl/bin/inca_${resol_atm_3d}_${optmode}_${optchimie}.dat ;
237#       cp $modipsl/bin/inca_${resol_atm_3d}.dat inca.dat;
238    else
239        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
240        exit   
241    fi
242
243
244    cd $modipsl/modeles/LMDZ
245    # Compile LMDZ regular lat-lon exectuable
246    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"
247    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm_3d}"   >> $outfile 
248
249    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 
250         ./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
251    # Test if compiling finished
252    if [[ $? != 0 ]] ; then
253        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
254        exit
255    fi
256
257#    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
258#    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"
259#    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm_3d}"   >> $outfile
260#
261#    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
262#         ./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
263#    # Test if compiling finished
264#    if [[ $? != 0 ]] ; then
265#       echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
266#       exit
267#    fi
268#
269    # Find executable suffix
270    if [ $parallel == seq ] || [ $parallel == none ] ; then
271        suffix=_${resol_atm_3d}_phylmd_seq_orch_inca
272    else
273        suffix=_${resol_atm_3d}_phylmd_para_mem_orch_inca
274    fi
275    echo suffix = $suffix
276   
277    # Move executables to modipsl/bin folder
278    echo "Move gcm.e and ce0l executable to modipsl/bin"
279    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
280    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
281
282fi
283
284
285echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
286echo; echo "ALL COMPILING FINISHED"
287
288date
289exit
290
291
Note: See TracBrowser for help on using the repository browser.