source: CONFIG/UNIFORM/v6/LMDZOR_v6.4/compile_lmdzor.sh @ 6758

Last change on this file since 6758 was 6758, checked in by jgipsl, 4 months ago

Use new arch file at obelix. This file ifort_LSCE_2023 is needed when interpolating using XIOS which is now the default on the trunk ORCHIDEE in offline mode.

  • Property svn:executable set to *
File size: 13.7 KB
RevLine 
[5036]1#!/bin/bash
[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
[6112]27# Compilation with rrtm or ecrad radiative code (default rad=rrtm)
28rad=rrtm
[6243]29opt_rad=""
[6112]30# Compilation with Cosp (cosp=NONE/v1/v2 ; default=NONE)
31cosp=NONE
32
[6684]33# Compilation with flag StratAer (option -strataer)
34opt_strataer=""
35
[4268]36export fcm_arch parallel xios
37full_flag=""
[4643]38full_xios=""
39full_lmdz=""
40full_orch=""
41
[4391]42# Default netcdf_lib is used for XIOS but can be change by argument
43netcdf_lib=""
[4268]44
[4408]45# Output text file for compilation of each component
[4622]46datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
47outfile=$submitdir/out_compile_lmdzor.$datestr
48echo > $outfile
[4643]49echo; echo "Text output from compilation will be stored in file out_compile_lmdzor.$datestr"; echo 
[4408]50
[4278]51#### Read arguments
[4268]52# Loop over all arguments to modify default set up
53while (($# > 0)) ; do
[4278]54    case $1 in
[4643]55        "-h") cat <<end_help
[4268]56########################################################################
[4411]57# Usage of the script compile_lmdzor.sh
[4268]58#
59########################################################################
60
61./compile_config [Options]
62
[4469]63Options: -full, -resol_atm, -debug, -dev, -prod(default)
[4268]64
[4411]65Example 1: Default compilation of LMDZ-ORCHIDEE with XIOS and IOIPSL
66./compile_lmdzor.sh
[4268]67
[4407]68Example 2: Compile in debug mode
[4411]69./compile_lmdzor.sh -debug
[4407]70
71Example 3: Default compilation with full recompilation of all components
[4411]72./compile_lmdzor.sh -full
[4268]73
[4411]74Example 4: Compilation of LMDZ in regular lat-lon for other dimensions (default: 144x142x79)
75The dimension can be changed to any other 3d dimension.
[4469]76./compile_lmdzor.sh -resol_atm 96x95x79
[4268]77
[4643]78end_help
79exit;;
80        "-parallel")        parallel=$2 ; shift ; shift ;;
[6112]81        "-rad")             rad=$2 ; shift ; shift ;;
82        "-cosp")            cosp=$2 ; shift ; shift ;;
[6684]83        "-strataer")        opt_strataer="-strataer true" ; shift ; shift ;;
[4643]84        "-arch")            fcm_arch="$2" ; shift ; shift ;;
85        "-xios")            xios="$2" ; shift ; shift ;;
86        "-debug")           optmode=debug ; shift ;;
87        "-dev")             optmode=dev ; shift ;;
88        "-prod")            optmode=prod ; shift ;;
89        "-resol_atm")       resol_atm=$2 ; shift ; shift ;;
90        "CE0L")             ce0l=y ; shift ;;
91        "-full")            full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; shift ;;
92        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
93        "-full_lmdz")       full_lmdz="-full"  ; shift ;;
94        "-full_orch")       full_orch="-full"  ; shift ;;
95        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
[4644]96        *)                  echo "unknown option "$1" , exiting..." ; exit
[4278]97    esac
98done
[4268]99
[4643]100echo "Following options are set in current compiling:" >> $outfile 
101echo "   resol_atm=${resol_atm}" >> $outfile 
102echo "   ce0l=${ce0l}" >> $outfile 
103echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
104echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch" >> $outfile 
[4408]105echo >> $outfile
[4268]106
[6112]107if [ $cosp = v1 ] ; then
108    opt_cosp="-cosp true"
109elif [ $cosp = v2 ] ; then
110    opt_cosp="-cospv2 true"
111else
112    opt_cosp=""
113fi
[4278]114### Read host dependent default values
115### These variables will not be changed if they were set as argument
[4268]116###./host.sh $host
117# Later : Following lines should be set in host.sh file
118# begin host.sh
119if [ $fcm_arch == default ] ; then
[4278]120    # Find out current host and source specific paths and commands for the host
121    case $( hostname -s ) in
[4744]122        jean-zay*)
[6629]123            if [[ $( hostname -s ) != *"pp"* ]] ; then
124                echo "Warning! You MUST compile on jean-zay-pp."
125                echo "EXIT"
126                exit
127            else
128                fcm_arch=X64_JEANZAY
129            fi ;;
[5030]130        irene170|irene171|irene190|irene191|irene192|irene193)
131            fcm_arch=X64_IRENE;;
132        irene172|irene173|irene194|irene195)
133            fcm_arch=X64_IRENE-AMD;;
[4278]134        asterix*|obelix*)
[6758]135            fcm_arch=ifort_LSCE_2023
[4973]136            if [ "${parallel}" == "mpi_omp" ] ; then
[6112]137                echo "Warning!! Currently at Obelix hybrid mode is not possible."
138                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
139                echo ""
140                parallel=mpi
[4973]141            else
[6112]142                echo "You used -parallel" $parallel
[4973]143            fi ;;
[6261]144        spirit*)
145            fcm_arch=ifort_MESOIPSL;;
[4973]146        ciclad*|climserv*|loholt*|camelot*)
[4391]147            fcm_arch=ifort_CICLAD;;
[4278]148        *)
[4391]149            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
[4278]150            echo Exit now.
151            exit
152    esac
[4268]153fi
154
[4452]155# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
[4391]156# The link arch.env is also set in config.card and will be used by libIGCM to ensure the same running environnement.
157if [ -f ARCH/arch-${fcm_arch}.env ] ; then
[4408]158    echo >> $outfile
[4932]159    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
[4470]160    echo "Note that this new environement might be kept after compilation." 
161    echo "If this is the case, source again your personal environment after compilation. "
162    echo " Personal module list before sourcing of ARCH/arch.env file:"    >> $outfile 
163    module list   >> $outfile 2>&1
[6299]164    # Get initial svn version
165    svn_version=$(module list -t | grep subversion)
166   
[4470]167    # Make a link to this file, to be used also in config.card
[4391]168    rm -f ARCH/arch.env
169    ln -s arch-${fcm_arch}.env ARCH/arch.env
[4470]170
171    # Source the file
172    source ARCH/arch.env   >> $outfile 2>&1
[6299]173    if [ X$svn_version != X ] ; then
174        # Put back initial version of svn
175        module load ${svn_version}
176    fi
177
[4470]178    echo >> $outfile 
179    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
180    module list   >> $outfile 2>&1
[4391]181fi
182
[4268]183#### 2 Do the compilation
184## 2.1 Compile ioipsl
185cd $modipsl/modeles/IOIPSL
[4278]186echo; echo "NOW COMPILE IOIPSL"
[4408]187echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
188
[4411]189# Check if compilation with fcm is included in IOIPSL
190if [ ! -f makeioipsl_fcm ] ; then
191  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
192  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
193  exit
194fi
195
[4940]196echo ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
197     ./makeioipsl_fcm -$optmode -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
[4268]198# Test if compiling succeded
199if [[ $? != 0 ]] ; then
[4278]200    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
201    exit
[4268]202fi
203
204## 2.2 Compile xios
205cd $modipsl/modeles/XIOS
[4278]206echo; echo "NOW COMPILE XIOS"
[4408]207echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
[4643]208echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
209     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
[4268]210# Test if compiling succeded
211if [[ $? != 0 ]] ; then
[4278]212    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
213    exit
[4268]214fi
[4391]215# Move executables to modipsl/bin
[4457]216if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
217    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
[4391]218else
219    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
220    exit
221fi
[4268]222
[4391]223
[4268]224## 2.3 Compile orchidee
225cd $modipsl/modeles/ORCHIDEE
[4278]226echo; echo "NOW COMPILE ORCHIDEE"
[4408]227echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
228
[6112]229
[4973]230# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
231# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
232# to ask question and wait for interactivly answer from the user.
233if [ -f build/fcm.bld.lock ] ; then
234    echo >> $outfile
235    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
236    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
237    echo "           The file will now be removed. "   >> $outfile
238    echo >> $outfile
239    rm -f build/fcm.bld.lock
240fi
241
[4643]242echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver   >> $outfile 
243        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch -driver    >> $outfile 2>&1
[4268]244# Test if compiling finished
245if [[ $? != 0 ]] ; then
246    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
247    exit
248fi
249
[4643]250# Rename executables to contain $optmode
251if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
252if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
[4408]253
[4643]254
[4411]255## 2.4 Compile LMDZ for regular latlon configuration
[4469]256cd $modipsl/modeles/LMDZ
[4932]257# Compile LMDZ regular lat-lon executable
[4469]258echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
259echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
[6243]260# Retrieve the final svn release number, needed for radiative code suffix of executable
261lmdzsvn=`svnversion . | egrep -o "[0-9]+"  | awk 'NR==1'`
[6299]262echo >> $outfile ; echo "lmdzsvn= $lmdzsvn "   >> $outfile
[4268]263
[4622]264# Check if the compilation of LMDZ was previsouly interupted prematured.
265# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
266# to ask question and wait for interactivly answer from the user.
267if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
268  echo >> $outfile
269  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
270  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
271  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
272  echo >> $outfile
273  rm -f libf/grid/dimensions.h
274  rm -f .lock
275fi
276
[6243]277# Need to define the proper option for radiative code compilation. By default, we use rrtm
278case $rad in
279    oldrad) opt_rad="" ;;
280    rrtm)   if [ $lmdzsvn -le 4185 ] ; then opt_rad="-rrtm true" ; else opt_rad="-rad rrtm" ; fi ;;
281    ecrad)  opt_rad="-rad ecrad" ;;
282    *) echo Only oldrad rrtm ecrad for rad option ; exit
283esac
284
285if [ $lmdzsvn -le 4185 -a $rad = "ecrad" ] ; then echo "ecrad only available for LMDZ rev starting with 4186 " ; exit ; fi
286
287
[6684]288echo ./makelmdz_fcm -d ${resol_atm} -p lmd  $opt_rad $opt_cosp $opt_strataer -$optmode -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 
289./makelmdz_fcm -d ${resol_atm} -p lmd  $opt_rad $opt_strataer -$optmode -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 2>&1
[4469]290# Test if compiling finished
291if [[ $? != 0 ]] ; then
292    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
293    exit
294fi
[4408]295
[4643]296# Move executables to modipsl/bin folder
297echo >> $outfile
298echo "Move gcm.e executable to modipsl/bin" >> $outfile
299echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
300ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
301echo >> $outfile
[4278]302
[6243]303suffix=${resol_atm}_phylmd
304if [ $lmdzsvn -ge 4186 ] ; then suffix=${suffix}_${rad} ; fi
[4469]305if [ $parallel == seq ] || [ $parallel == none ] ; then
[6243]306    suffix=_${suffix}_seq_orch.e
[4469]307else
[6243]308    suffix=_${suffix}_para_mem_orch.e
[4469]309fi
[4643]310echo gcm suffix = $suffix
[4408]311
[4643]312if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
313    mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
314else
315    echo "ERROR gcm${suffix} executable does not exist." 
316    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
317    exit
318fi 
[4278]319
[4268]320
[4643]321# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
322if [ $ce0l == y ] ; then
323    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
324    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
325   
[6243]326    echo ./makelmdz_fcm -d ${resol_atm} -p lmd  $opt_rad -$optmode -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
327    ./makelmdz_fcm -d ${resol_atm} -p lmd  $opt_rad -$optmode -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 2>&1
[4643]328    # Test if compiling finished
329    if [[ $? != 0 ]] ; then
330        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
331        exit
332    fi
333
334   
335    # Move executables to modipsl/bin folder
336    echo >> $outfile
337    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
338    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
339    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
340    echo >> $outfile
[5122]341    suffix=_${resol_atm}_phylmd_seq.e
[6243]342    if [ $lmdzsvn -ge 4186 ] ; then suffix=_${resol_atm}_phylmd_${rad}_seq.e ; fi
[4643]343    echo ce0l suffix = $suffix
344
345    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
346        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
347    else
348        echo "ERROR ce0l${suffix} executable does not exist." 
349        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
350        exit
351    fi 
352fi
353
354
[4408]355echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
[4643]356echo ls -lrt modipsl/bin >> $outfile
357ls -lrt $modipsl/bin >> $outfile
[4278]358
[4643]359echo; echo "ALL COMPILING FINISHED" ; echo
360echo "Executables are found in modipsl/bin"
361echo "Check that executable names correspond with the name set in config.card before launching the job"
362echo ls -lrt modipsl/bin
363ls -lrt $modipsl/bin
364
[4409]365date
[4643]366
[4268]367exit
Note: See TracBrowser for help on using the repository browser.