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

Last change on this file since 4642 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
RevLine 
[4268]1#!/bin/bash
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
[4411]20
[4268]21# fcm_arch
22fcm_arch=default
23# Default values to be overritten
[4339]24parallel=mpi_omp
[4268]25export fcm_arch parallel xios
26full_flag=""
[4391]27# Default netcdf_lib is used for XIOS but can be change by argument
28netcdf_lib=""
[4268]29
[4408]30# Output text file for compilation of each component
[4622]31datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
32outfile=$submitdir/out_compile_lmdzor.$datestr
33echo > $outfile
[4411]34echo; echo "Text output from compilation will be stored in file out_compile_lmdzor"; echo 
[4408]35
[4278]36#### Read arguments
[4268]37# Loop over all arguments to modify default set up
38while (($# > 0)) ; do
[4278]39    case $1 in
40        "-h") cat <<fin
[4268]41
42########################################################################
[4411]43# Usage of the script compile_lmdzor.sh
[4268]44#
45########################################################################
46
47./compile_config [Options]
48
[4469]49Options: -full, -resol_atm, -debug, -dev, -prod(default)
[4268]50
[4411]51Example 1: Default compilation of LMDZ-ORCHIDEE with XIOS and IOIPSL
52./compile_lmdzor.sh
[4268]53
[4407]54Example 2: Compile in debug mode
[4411]55./compile_lmdzor.sh -debug
[4407]56
57Example 3: Default compilation with full recompilation of all components
[4411]58./compile_lmdzor.sh -full
[4268]59
[4411]60Example 4: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79)
61The dimension can be changed to any other 3d dimension.
[4469]62./compile_lmdzor.sh -resol_atm 96x95x79
[4268]63
[4278]64fin
65            exit;;
[4268]66
[4278]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       
[4407]76        "-debug")
77            optmode=debug ; shift ;;
78
79        "-dev")
80            optmode=dev ; shift ;;
81
82        "-prod")
83            optmode=prod ; shift ;;
84
[4469]85        "-resol_atm")
86            resol_atm=$2 ; shift ; shift ;;
[4278]87       
88        "-full")
89            full_flag="-full"; shift ;;
90       
[4391]91        "-netcdf_lib_seq")
92            netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
93
[4278]94        *)
95            echo "unknown option "$2" , exiting..."
96            exit
97    esac
98done
[4268]99
[4408]100echo "Following arguments are set in current compiling:" >> $outfile 
[4469]101echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch, full_flag=$full_flag resol_atm=${resol_atm}" >> $outfile 
[4408]102echo >> $outfile
[4268]103
[4278]104### Read host dependent default values
105### These variables will not be changed if they were set as argument
[4268]106###./host.sh $host
107# Later : Following lines should be set in host.sh file
108# begin host.sh
109if [ $fcm_arch == default ] ; then
[4278]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*)
[4391]115            fcm_arch=X64_IRENE;;
[4278]116        asterix*|obelix*)
117            fcm_arch=ifort_LSCE;;
[4391]118        ciclad*|climserv*)
119            fcm_arch=ifort_CICLAD;;
[4278]120        *)
[4391]121            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
[4278]122            echo Exit now.
123            exit
124    esac
[4268]125fi
126
[4452]127# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
[4391]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
[4408]130    echo >> $outfile
[4470]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
[4391]138    rm -f ARCH/arch.env
139    ln -s arch-${fcm_arch}.env ARCH/arch.env
[4470]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
[4391]146fi
147
[4268]148#### 2 Do the compilation
149## 2.1 Compile ioipsl
150cd $modipsl/modeles/IOIPSL
[4278]151echo; echo "NOW COMPILE IOIPSL"
[4408]152echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
153
[4411]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
[4408]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
[4268]163# Test if compiling succeded
164if [[ $? != 0 ]] ; then
[4278]165    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
166    exit
[4268]167fi
168
169## 2.2 Compile xios
170cd $modipsl/modeles/XIOS
[4278]171echo; echo "NOW COMPILE XIOS"
[4408]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
[4268]175# Test if compiling succeded
176if [[ $? != 0 ]] ; then
[4278]177    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
178    exit
[4268]179fi
[4391]180# Move executables to modipsl/bin
[4457]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
[4391]183else
184    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
185    exit
186fi
[4268]187
[4391]188
[4268]189## 2.3 Compile orchidee
190cd $modipsl/modeles/ORCHIDEE
[4278]191echo; echo "NOW COMPILE ORCHIDEE"
[4408]192echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
193
[4452]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
[4268]196# Test if compiling finished
197if [[ $? != 0 ]] ; then
198    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
199    exit
200fi
201
[4408]202
[4411]203## 2.4 Compile LMDZ for regular latlon configuration
[4469]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 
[4268]208
[4622]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
[4469]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
[4408]229
[4469]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
[4278]241
[4469]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
[4408]249
[4469]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
[4278]254
[4268]255
[4408]256echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
257echo; echo "ALL COMPILING FINISHED"
[4278]258
[4409]259date
[4268]260exit
261
262
Note: See TracBrowser for help on using the repository browser.