source: branches/ORCHIDEE_2_2/ORCHIDEE_OL/compile_orchidee_ol.sh @ 7759

Last change on this file since 7759 was 7759, checked in by josefine.ghattas, 21 months ago

Added compilation environnement for Spirit and Spiritx at IPSL MESO cluster

  • Property svn:executable set to *
  • Property svn:keywords set to Date Revision HeadURL
File size: 11.2 KB
Line 
1#!/bin/bash
2#set -vx
3# ================================================================================================================================
4#  compile_orchidee_ol.sh
5#
6#  CONTACT      : orchidee-help _at_ listes.ipsl.fr
7#
8#  LICENCE      : IPSL (2006)
9#  This software is governed by the CeCILL licence see ORCHIDEE/ORCHIDEE_CeCILL.LIC
10#
11#  DESCRIPTION  : This script is used to compile all components needed for the ORCHIDEE offline drivers. The following components
12#                 will be compiled: IOIPSL, XIOS and ORCHIDEE.
13#                 Default compilation is set up for the machines irene/TGCC, jean-zay/IDRIS, obelix/LSCE and ciclad and
14#                 climserv/IPSL. For other machines compiling option needs to be specified for each of the components.
15#                 The script first sources a arch.env file, from folder ARCH, containing modules needed for the current machine.
16#                 This means that the modules do not need to be sourced before starting the compilation. Output from compilation
17#                 are stored in a separate file out_compile_orchidee.date.
18#                 For help about the script, use: ./compile_orchidee_ol.sh -h
19#
20# $HeadURL$
21# $Date$
22# $Revision$
23# ================================================================================================================================
24
25date
26
27#### 1  Set up the compiling options
28#### Define some directories
29submitdir=$( pwd )
30modipsl=$submitdir/../..
31arch_path=$submitdir/ARCH
32
33#### Set default options
34# Optimization mode
35# optmode=prod/dev/debug
36optmode=prod
37
38# fcm_arch
39fcm_arch=default
40
41# parallel: mpi or seq
42parallel=mpi
43
44export fcm_arch parallel xios
45full_flag=""
46full_xios=""
47full_orch=""
48
49# Compile with linking to XIOS: xios=xios (default)
50# Use argument -without_xios for compilation without linking to XIOS: xios=noxios
51xios=xios
52
53# Compile other executables: if otherexec="-otherexec", then
54otherexec=""
55
56# Default netcdf_lib is used for XIOS but can be change by argument
57netcdf_lib=""
58
59
60#### Read arguments
61# Loop over all arguments to modify default set up
62while (($# > 0)) ; do
63    case $1 in
64        "-h") cat <<end_help
65########################################################################
66# Usage of the script compile_orchidee_ol.sh
67#
68########################################################################
69
70./compile_orchidee_ol.sh [Options]
71
72Options:
73  [-full]: full recompilation of all components
74  [-full_orch], [-full_xios]: recompile only orchidee or xios component
75  [-arch XXX]: Force to use arch-XXX.fcm and arch-XXX.path files with specific compilation options for current platform. The files must be
76   available in modles/ORCHIDEE/arch, modeles/XIOS/arch and modeles/IOIPSL/arch folders. If the file config/ORCHIDEE_OL/ARCH/arch-XXX.env
77   exist, it'll be sourced in the beginning of this compilation script.
78  [-debug], [-dev], [-prod](default): use compilation options for debug, dev or production mode, only one option can be used
79  [-all_exec]: also compile other exectables than the drivers (testrouting, forcesoil and teststomate)
80  [-without_xios]: no compilation or linking to XIOS. Default compilation is done with XIOS
81  [-parallel seq] / [-parallel mpi](default): compile without MPI for use in sequential mode / with MPI (default).
82   When using [-parallel seq], [-without_xios] must as well be set.
83  [-netcdf_lib_seq]: option to tell XIOS that linking with netcdf4 sequential library will be used instead of default netcdf4 parallel library
84
85
86Example 1: Default compilation of ORCHIDEE with XIOS and IOIPSL
87./compile_orchidee_ol.sh
88
89Example 2: Compile in debug mode
90./compile_orchidee_ol.sh -debug
91
92Example 3: Default compilation with full recompilation of all components
93./compile_orchidee_ol.sh -full
94
95Example 4: No compilation or linking to XIOS
96./compile_orchidee_ol.sh -without_xios
97
98Example 5: Compilation without MPI for sequential use only. Note that XIOS must be deactivated as well.
99./compile_orchidee_ol.sh -parallel seq -without_xios
100
101
102end_help
103exit;;
104        "-parallel")        parallel="$2" ; shift ; shift ;;
105        "-arch")            fcm_arch="$2" ; shift ; shift ;;
106        "-without_xios")    xios=noxios ; shift ;;
107        "-debug")           optmode=debug ; shift ;;
108        "-dev")             optmode=dev ; shift ;;
109        "-prod")            optmode=prod ; shift ;;
110        "-full")            full_flag="-full"; full_xios="--full" ; full_orch="-full" ; shift ;;
111        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
112        "-full_orch")       full_orch="-full"  ; shift ;;
113        "-all_exec")        otherexec="-otherexec" ; shift ;;
114        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
115        *)                  echo "unknown option "$1" , exiting..." ; exit
116    esac
117done
118
119
120# Create text output file
121datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
122outfile=$submitdir/out_compile_orchidee.$datestr
123echo > $outfile
124echo; echo "Text output from compilation will be stored in file out_compile_orchidee.$datestr"; echo
125
126
127echo "Following options are set in current compiling:" >> $outfile 
128echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
129echo "   full_flag=$full_flag, full_xios=$full_xios, full_orch=$full_orch" >> $outfile 
130echo >> $outfile
131
132if [ $parallel = seq ] && [ $xios = y ] ; then
133    echo "It is not possible to compile ORCHIDEE in sequential mode using XIOS."
134    echo "Option -without_xios must be set if option [-parallel seq] is set"
135    echo "Option -without_xios must be set if option [-parallel seq] is set" >> $outfile 
136    exit
137fi
138
139### Read host dependent default values
140### These variables will not be changed if they were set as argument
141###./host.sh $host
142# Later : Following lines should be set in host.sh file
143# begin host.sh
144if [ $fcm_arch == default ] ; then
145    # Find out current host and source specific paths and commands for the host
146    case $( hostname -s ) in
147        jean-zay*)
148            fcm_arch=X64_JEANZAY;;
149        irene170|irene171|irene190|irene191|irene192|irene193)
150            fcm_arch=X64_IRENE;;
151        irene172|irene173|irene194|irene195)
152            fcm_arch=X64_IRENE-AMD;;
153        asterix*|obelix*)
154            fcm_arch=ifort_LSCE;;
155        ciclad*|climserv*|loholt*|camelot*|merlin*)
156            fcm_arch=ifort_CICLAD;;
157        spirit*)
158            fcm_arch=ifort_MESOIPSL;;
159        *)
160            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
161            echo Exit now.
162            exit
163    esac
164fi
165
166echo "The fcm_arch has been changed to: $fcm_arch" >> $outfile 
167
168# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
169# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
170if [ -f ARCH/arch-${fcm_arch}.env ] ; then
171    echo >> $outfile
172    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
173    echo "Note that this new environement might be kept after compilation." 
174    echo "If this is the case, source again your personal environment after compilation. "
175
176    # Make a link to this file, to be used also in config.card
177    rm -f ARCH/arch.env
178    ln -s arch-${fcm_arch}.env ARCH/arch.env
179
180    # Source the file
181    source ARCH/arch.env   >> $outfile 2>&1
182    echo >> $outfile 
183    echo "New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
184    module list   >> $outfile 2>&1
185else
186    echo "No specific ARCH/arch-${fcm_arch}.env have been found. No change in environnement will be done."
187    echo "Previous loaded module modules will be used."    >> $outfile 
188    module list   >> $outfile 2>&1
189fi
190
191
192#### 2 Do the compilation component by component
193## 2.1 Compile ioipsl
194cd $modipsl/modeles/IOIPSL
195echo; echo "NOW COMPILE IOIPSL"
196echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
197
198# Check if compilation with fcm is included in IOIPSL
199if [ ! -f makeioipsl_fcm ] ; then
200  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
201  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
202  exit
203fi
204
205echo ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
206     ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
207# Test if compiling succeded
208if [[ $? != 0 ]] ; then
209    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
210    exit
211fi
212
213## 2.2 Compile xios
214if [ $xios == xios ] ; then
215    cd $modipsl/modeles/XIOS
216    echo; echo "NOW COMPILE XIOS"
217    echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
218    echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
219    ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
220    # Test if compiling succeded
221    if [[ $? != 0 ]] ; then
222        echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
223        exit
224    fi
225    # Move executables to modipsl/bin
226    if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
227        mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
228    else
229        echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
230        exit
231    fi
232fi
233
234
235## 2.3 Compile orchidee
236cd $modipsl/modeles/ORCHIDEE
237echo; echo "NOW COMPILE ORCHIDEE"
238echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
239
240# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
241# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
242# to ask question and wait for interactivly answer from the user.
243if [ -f build/fcm.bld.lock ] ; then
244    echo >> $outfile
245    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
246    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
247    echo "           The file will now be removed. "   >> $outfile
248    echo >> $outfile
249    rm -f build/fcm.bld.lock
250fi
251
252echo    ./makeorchidee_fcm -j 8 -$xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver $otherexec   >> $outfile 
253        ./makeorchidee_fcm -j 8 -$xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver $otherexec   >> $outfile 2>&1
254# Test if compiling finished
255if [[ $? != 0 ]] ; then
256    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
257    exit
258fi
259
260# Rename executables to contain $optmode
261if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
262if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
263if [ -f $modipsl/bin/testrouting ] ; then mv $modipsl/bin/testrouting  $modipsl/bin/testrouting_${optmode} ; fi
264if [ -f $modipsl/bin/forcesoil ] ; then mv $modipsl/bin/forcesoil  $modipsl/bin/forcesoil_${optmode} ; fi
265if [ -f $modipsl/bin/teststomate ] ; then mv $modipsl/bin/teststomate  $modipsl/bin/teststomate_${optmode} ; fi
266
267
268
269echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
270echo ls -lrt modipsl/bin >> $outfile
271ls -lrt $modipsl/bin >> $outfile
272
273echo; echo "ALL COMPILING FINISHED" ; echo
274echo "Executables are found in modipsl/bin"
275echo ls -lrt modipsl/bin
276ls -lrt $modipsl/bin
277
278date
279
280exit
281
Note: See TracBrowser for help on using the repository browser.