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

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

add a warning on lmdz revision number

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