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

Last change on this file since 4604 was 4472, checked in by jgipsl, 5 years ago

Correct error since previous commit today [4469]

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