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

Last change on this file since 4920 was 4920, checked in by jgipsl, 4 years ago

Correct error for -full option

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