source: CONFIG/UNIFORM/v6/LMDZOR_v6.2/compile_lmdzor.sh @ 4625

Last change on this file since 4625 was 4622, checked in by jgipsl, 5 years ago
  • Add date on the output text file to avoid deleating preivously file if recompilation
  • Check and remove dimensions.h and .lock in LMDZ to avoid makelmdz_fcm interupt the compilation with the question:

"WARNING: you are probably already compiling the model somewhere else.
Wait until the first compilation is finished before launching this one.
If you are sure that you are not compiling elsewhere, just answer
yes (or 'oui') to the question below to proceed.
Do you wish to continue?"

  • Property svn:executable set to *
File size: 9.0 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
19resol_atm=144x142x79
20
21# fcm_arch
22fcm_arch=default
23# Default values to be overritten
24parallel=mpi_omp
25export fcm_arch parallel xios
26full_flag=""
27# Default netcdf_lib is used for XIOS but can be change by argument
28netcdf_lib=""
29
30# Output text file for compilation of each component
31datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
32outfile=$submitdir/out_compile_lmdzor.$datestr
33echo > $outfile
34echo; echo "Text output from compilation will be stored in file out_compile_lmdzor"; echo 
35
36#### Read arguments
37# Loop over all arguments to modify default set up
38while (($# > 0)) ; do
39    case $1 in
40        "-h") cat <<fin
41
42########################################################################
43# Usage of the script compile_lmdzor.sh
44#
45########################################################################
46
47./compile_config [Options]
48
49Options: -full, -resol_atm, -debug, -dev, -prod(default)
50
51Example 1: Default compilation of LMDZ-ORCHIDEE with XIOS and IOIPSL
52./compile_lmdzor.sh
53
54Example 2: Compile in debug mode
55./compile_lmdzor.sh -debug
56
57Example 3: Default compilation with full recompilation of all components
58./compile_lmdzor.sh -full
59
60Example 4: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79)
61The dimension can be changed to any other 3d dimension.
62./compile_lmdzor.sh -resol_atm 96x95x79
63
64fin
65            exit;;
66
67        "-parallel")
68            parallel=$2 ; shift ; shift ;;
69       
70        "-arch")
71            fcm_arch="$2" ; shift ; shift ;;
72       
73        "-xios")
74            xios="$2" ; shift ; shift ;;
75       
76        "-debug")
77            optmode=debug ; shift ;;
78
79        "-dev")
80            optmode=dev ; shift ;;
81
82        "-prod")
83            optmode=prod ; shift ;;
84
85        "-resol_atm")
86            resol_atm=$2 ; shift ; shift ;;
87       
88        "-full")
89            full_flag="-full"; shift ;;
90       
91        "-netcdf_lib_seq")
92            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
93
94        *)
95            echo "unknown option "$2" , exiting..."
96            exit
97    esac
98done
99
100echo "Following arguments are set in current compiling:" >> $outfile 
101echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag resol_atm=${resol_atm}" >> $outfile 
102echo >> $outfile
103
104### Read host dependent default values
105### These variables will not be changed if they were set as argument
106###./host.sh $host
107# Later : Following lines should be set in host.sh file
108# begin host.sh
109if [ $fcm_arch == default ] ; then
110    # Find out current host and source specific paths and commands for the host
111    case $( hostname -s ) in
112        ada*)
113            fcm_arch=X64_ADA;;
114        irene*)
115            fcm_arch=X64_IRENE;;
116        asterix*|obelix*)
117            fcm_arch=ifort_LSCE;;
118        ciclad*|climserv*)
119            fcm_arch=ifort_CICLAD;;
120        *)
121            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
122            echo Exit now.
123            exit
124    esac
125fi
126
127# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
128# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
129if [ -f ARCH/arch-${fcm_arch}.env ] ; then
130    echo >> $outfile
131    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components"
132    echo "Note that this new environement might be kept after compilation." 
133    echo "If this is the case, source again your personal environment after compilation. "
134    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
135    module list   >> $outfile 2>&1
136
137    # Make a link to this file, to be used also in config.card
138    rm -f ARCH/arch.env
139    ln -s arch-${fcm_arch}.env ARCH/arch.env
140
141    # Source the file
142    source ARCH/arch.env   >> $outfile 2>&1
143    echo >> $outfile 
144    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
145    module list   >> $outfile 2>&1
146fi
147
148#### 2 Do the compilation
149## 2.1 Compile ioipsl
150cd $modipsl/modeles/IOIPSL
151echo; echo "NOW COMPILE IOIPSL"
152echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
153
154# Check if compilation with fcm is included in IOIPSL
155if [ ! -f makeioipsl_fcm ] ; then
156  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
157  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
158  exit
159fi
160
161echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
162     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
163# Test if compiling succeded
164if [[ $? != 0 ]] ; then
165    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
166    exit
167fi
168
169## 2.2 Compile xios
170cd $modipsl/modeles/XIOS
171echo; echo "NOW COMPILE XIOS"
172echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
173echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 
174     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_flag   >> $outfile 2>&1
175# Test if compiling succeded
176if [[ $? != 0 ]] ; then
177    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
178    exit
179fi
180# Move executables to modipsl/bin
181if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
182    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
183else
184    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
185    exit
186fi
187
188
189## 2.3 Compile orchidee
190cd $modipsl/modeles/ORCHIDEE
191echo; echo "NOW COMPILE ORCHIDEE"
192echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
193
194echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver   >> $outfile 
195        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_flag -driver    >> $outfile 2>&1
196# Test if compiling finished
197if [[ $? != 0 ]] ; then
198    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
199    exit
200fi
201
202
203## 2.4 Compile LMDZ for regular latlon configuration
204cd $modipsl/modeles/LMDZ
205# Compile LMDZ regular lat-lon exectuable
206echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
207echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
208
209# Check if the compilation of LMDZ was previsouly interupted prematured.
210# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
211# to ask question and wait for interactivly answer from the user.
212if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
213  echo >> $outfile
214  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
215  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
216  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
217  echo >> $outfile
218  rm -f libf/grid/dimensions.h
219  rm -f .lock
220fi
221
222echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 
223./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_flag gcm    >> $outfile 2>&1
224# Test if compiling finished
225if [[ $? != 0 ]] ; then
226    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
227    exit
228fi
229
230# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
231echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
232echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
233   
234echo ./makelmdz_fcm -d ${resol_atm} -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 
235./makelmdz_fcm -d ${resol_atm} -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
236# Test if compiling finished
237if [[ $? != 0 ]] ; then
238    echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
239    exit
240fi
241
242# Find executable suffix
243if [ $parallel == seq ] || [ $parallel == none ] ; then
244    suffix=_${resol_atm}_phylmd_seq_orch
245else
246    suffix=_${resol_atm}_phylmd_para_mem_orch
247fi
248echo suffix = $suffix
249
250# Move executables to modipsl/bin folder
251echo "Move gcm.e and ce0l executable to modipsl/bin"
252if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/gcm${suffix}.e $modipsl/bin/gcm_${resol_atm}_${optmode}.e ; fi
253if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e ] ;  then mv $modipsl/modeles/LMDZ/bin/ce0l${suffix}.e $modipsl/bin/ce0l_${resol_atm}_${optmode}.e ; fi
254
255
256echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
257echo; echo "ALL COMPILING FINISHED"
258
259date
260exit
261
262
Note: See TracBrowser for help on using the repository browser.