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

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

Adaptation for compilation at obelix/LSCE:

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