source: CONFIG/UNIFORM/v7/ICOLMDZOR_v7/compile_icolmdzor.sh @ 5148

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

Update as done in LMDZOR_v6.3 in changeset [4973]:

  • Change automatiquement -parallel mpi_omp vers -parallel mpi sur obelix
  • Ajoute test si le fichier fcm.bld.lock dans la compilatiation d'ORCHIDEE et efface le s'il existe
  • Also add more names for machines at Climserv (loholt|camelot)

v7/ICOLMDZOR_v7/ARCH/arch-X64_IRENE.env : as done in v6.2 configurations to avoid error message from makelmdz_fcm when doing module purge.

  • Property svn:executable set to *
File size: 14.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
13export ROOT=$modipsl/modeles/DYNAMICO
14
15#### Set default options
16# Optimization mode
17# optmode=prod/dev/debug
18optmode=prod
19# Resolution if compiling LMDZ in regular mode without DYNAMICO
20# Use for example following "./compile_icolmdzor.sh -regular_latlon 144x142x79"
21regular_latlon=no
22# fcm_arch
23fcm_arch=default
24# Default values to be overritten
25parallel=mpi_omp
26export fcm_arch parallel xios
27full_flag=""
28full_xios=""
29full_lmdz=""
30full_orch=""
31full_dyna=""
32
33# Default netcdf_lib is used for XIOS but can be change by argument
34netcdf_lib=""
35
36# Output text file for compilation of each component
37datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
38outfile=$submitdir/out_compile_icolmdzor.$datestr
39echo > $outfile
40echo; echo "Text output from compilation will be stored in file out_compile_icolmdzor.$datestr"; echo 
41
42#### Read arguments
43# Loop over all arguments to modify default set up
44while (($# > 0)) ; do
45    case $1 in
46        "-h") cat <<end_help
47
48########################################################################
49# Usage of the script compile_icolmdzor.sh
50#
51########################################################################
52
53./compile_config [Options]
54
55Options: -full, -regular_latlon, -debug, -dev, -prod(default)
56
57Example 1: Default compilation of DYNAMICO-LMDZ-ORCHIDEE with XIOS and IOIPSL
58./compile_icolmdzor.sh
59
60Example 2: Compile in debug mode
61./compile_icolmdzor.sh -debug
62
63Example 3: Default compilation with full recompilation of all components
64./compile_icolmdzor.sh -full
65
66Example 4: Compilation of LMDZ in regular lat-lon for dimension 144x142x79.
67The dimension can be changed to any other 3d dimension. DYNAMICO is also compiled as default.
68./compile_icolmdzor.sh -regular_latlon 144x142x79
69
70end_help
71            exit;;
72
73        "-parallel")        parallel=$2 ; shift ; shift ;;
74        "-arch")            fcm_arch="$2" ; shift ; shift ;;
75        "-xios")            xios="$2" ; shift ; shift ;;
76        "-debug")           optmode=debug ; shift ;;
77        "-dev")             optmode=dev ; shift ;;
78        "-prod")            optmode=prod ; shift ;;
79        "-regular_latlon")  regular_latlon=yes ; resol_atm=$2 ; shift ; shift ;;
80        "-full")            full_flag="-full"; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; full_dyna="-full" ; shift ;;
81        "-full_xios")       full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
82        "-full_lmdz")       full_lmdz="-full"  ; shift ;;
83        "-full_orch")       full_orch="-full"  ; shift ;;
84        "-full_dyna")       full_dyna="-full"  ; shift ;;
85        "-netcdf_lib_seq")  netcdf_lib="--netcdf_lib netcdf4_seq"; shift ;;
86        *)                  echo "unknown option "$1" , exiting..." ;  exit
87    esac
88done
89
90echo "Following options are set in current compiling:" >> $outfile 
91echo "   regular_latlon=$regular_latlon (if yes, then resol_atm=${resol_atm})" >> $outfile 
92echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
93echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch, full_dyna=$full_dyna" >> $outfile 
94echo >> $outfile
95
96### Read host dependent default values
97### These variables will not be changed if they were set as argument
98###./host.sh $host
99# Later : Following lines should be set in host.sh file
100# begin host.sh
101if [ $fcm_arch == default ] ; then
102    # Find out current host and source specific paths and commands for the host
103    case $( hostname -s ) in
104        jean-zay*)
105            fcm_arch=X64_JEANZAY;;
106        irene*)
107            fcm_arch=X64_IRENE;;
108        asterix*|obelix*)
109            fcm_arch=ifort_LSCE
110            if [ "${parallel}" == "mpi_omp" ] ; then
111                echo "Warning!! Currently at Obelix hybrid mode is not possible."
112                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
113                echo ""
114                parallel=mpi
115            else
116                echo "You used -parallel" $parallel
117            fi ;;
118        ciclad*|climserv*|loholt*|camelot*)
119            fcm_arch=ifort_CICLAD;;
120        *)
121            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
122            echo Exit now.
123            exit
124    esac
125fi
126
127# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
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
130    echo >> $outfile
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
138    rm -f ARCH/arch.env
139    ln -s arch-${fcm_arch}.env ARCH/arch.env
140
141    # Source the file
142    source ARCH/arch.env   >> $outfile 2>&1
143
144    echo >> $outfile
145    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
146    module list   >> $outfile 2>&1
147fi
148
149#### 2 Do the compilation
150## 2.1 Compile ioipsl
151cd $modipsl/modeles/IOIPSL
152echo; echo "NOW COMPILE IOIPSL"
153echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
154
155echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
156     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
157# Test if compiling succeded
158if [[ $? != 0 ]] ; then
159    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
160    exit
161fi
162
163## 2.2 Compile xios
164cd $modipsl/modeles/XIOS
165echo; echo "NOW COMPILE XIOS"
166echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
167echo ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 
168     ./make_xios --$optmode --arch $fcm_arch --arch_path $arch_path ${netcdf_lib} --job 4 $full_xios   >> $outfile 2>&1
169# Test if compiling succeded
170if [[ $? != 0 ]] ; then
171    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
172    exit
173fi
174# Move executables to modipsl/bin
175if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
176    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
177else
178    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
179    exit
180fi
181
182
183## 2.3 Compile orchidee
184cd $modipsl/modeles/ORCHIDEE
185echo; echo "NOW COMPILE ORCHIDEE"
186echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
187
188# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
189# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
190# to ask question and wait for interactivly answer from the user.
191if [ -f build/fcm.bld.lock ] ; then
192    echo >> $outfile
193    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
194    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
195    echo "           The file will now be removed. "   >> $outfile
196    echo >> $outfile
197    rm -f build/fcm.bld.lock
198fi
199
200echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 
201        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch    >> $outfile 2>&1
202# Test if compiling finished
203if [[ $? != 0 ]] ; then
204    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
205    exit
206fi
207
208# If orchide driver executables have been compiled (option -driver), then rename executables to contain $optmode
209if [ -f $modipsl/bin/orchidee_ol ] ; then mv $modipsl/bin/orchidee_ol  $modipsl/bin/orchidee_ol_${optmode} ; fi
210if [ -f $modipsl/bin/orchideedriver ] ; then mv $modipsl/bin/orchideedriver  $modipsl/bin/orchideedriver_${optmode} ; fi
211
212
213## 2.4 Compile lmdz
214cd $modipsl/modeles/LMDZ
215# Compile LMDZ as library to couple to DYNAMICO
216echo; echo "NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"
217echo >> $outfile ; echo " NOW COMPILE LMDZ FOR COUPLING TO DYNAMICO"   >> $outfile 
218
219# Check if the compilation of LMDZ was previsouly interupted prematured.
220# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
221# to ask question and wait for interactivly answer from the user.
222if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
223  echo >> $outfile
224  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
225  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
226  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
227  echo >> $outfile
228  rm -f libf/grid/dimensions.h
229  rm -f .lock
230fi
231
232echo ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 
233     ./makelmdz_fcm -p lmd -rrtm true -cosp true -$optmode -mem -parallel $parallel -libphy -v orchidee2.1 -io xios -arch $fcm_arch -j 8 $full_lmdz    >> $outfile 2>&1
234# Test if compiling finished
235if [[ $? != 0 ]] ; then
236    echo "THERE IS A PROBLEM IN LMDZ PHYSICS COMPILATION - STOP"
237    exit
238fi
239
240
241## 2.5 Compile DYNAMICO
242cd $modipsl/modeles/DYNAMICO
243echo; echo "NOW COMPILE DYNAMICO "
244echo >> $outfile ; echo " NOW COMPILE DYNAMICO"   >> $outfile 
245
246echo ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 
247     ./make_icosa -$optmode -parallel $parallel -external_ioipsl -with_xios -arch $fcm_arch -arch_path $arch_path -job 8 $full_dyna    >> $outfile 2>&1
248# Test if compiling finished
249if [[ $? != 0 ]] ; then
250    echo "THERE IS A PROBLEM IN DYNAMICO COMPILATION - STOP"
251    exit
252fi
253
254## 2.6 Compile interface ICOSA_LMDZ
255cd $modipsl/modeles/ICOSA_LMDZ
256echo; echo "NOW COMPILE ICOSA_LMDZ "
257echo >> $outfile ; echo " NOW COMPILE ICOSA_LMDZ"   >> $outfile 
258
259echo ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 
260     ./make_icosa_lmdz -nodeps -p lmd -$optmode -parallel $parallel -with_orchidee -arch ${fcm_arch} -arch_path ${arch_path} -job 8 $full_dyna    >> $outfile 2>&1
261# Test if compiling finished
262if [[ $? != 0 ]] ; then
263    echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION - STOP"
264    exit
265fi
266# Move executables to modipsl/bin
267if [ $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe ] ; then
268    mv $modipsl/modeles/ICOSA_LMDZ/bin/icosa_lmdz.exe $modipsl/bin/icosa_lmdz_${optmode}.exe
269else
270    echo "THERE IS A PROBLEM IN ICOSA_LMDZ COMPILATION EXECUTABLE MISSING - STOP"
271    exit
272fi
273
274
275
276## 2.7 Compile LMDZ for regular latlon configuration
277if [ $regular_latlon = yes ] ; then
278
279    cd $modipsl/modeles/LMDZ
280    # Compile LMDZ regular lat-lon exectuable
281    echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
282    echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
283
284    # Check if the compilation of LMDZ was previsouly interupted prematured.
285    # In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
286    # to ask question and wait for interactivly answer from the user.
287    if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
288        echo >> $outfile
289        echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
290        echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
291        echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
292        echo >> $outfile
293        rm -f libf/grid/dimensions.h
294        rm -f .lock
295    fi
296    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 
297         ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz gcm    >> $outfile 2>&1
298    # Test if compiling finished
299    if [[ $? != 0 ]] ; then
300        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
301        exit
302    fi
303
304    # Compile ce0l initialization program for LMDZ regular lat-lon exectuable
305    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
306    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
307
308    echo ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 
309         ./makelmdz_fcm -d ${resol_atm} -p lmd -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -j 8 $full_lmdz ce0l    >> $outfile 2>&1
310    # Test if compiling finished
311    if [[ $? != 0 ]] ; then
312        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
313        exit
314    fi
315
316    # Find executable suffix
317    if [ $parallel == seq ] || [ $parallel == none ] ; then
318        suffix=_${resol_atm}_phylmd_seq_orch.e
319    else
320        suffix=_${resol_atm}_phylmd_para_mem_orch.e
321    fi
322    echo gcm suffix = $suffix
323   
324    # Move executables to modipsl/bin folder
325    echo "Move gcm.e and ce0l executable to modipsl/bin"
326    if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
327        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
328    else
329        echo "ERROR gcm${suffix} executable does not exist." 
330        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
331        exit
332    fi
333
334    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
335        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
336    else
337        echo "ERROR ce0l${suffix} executable does not exist." 
338        echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
339        exit
340    fi
341fi
342
343
344echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
345echo ls -lrt modipsl/bin >> $outfile
346ls -lrt $modipsl/bin >> $outfile
347
348echo; echo "ALL COMPILING FINISHED" ; echo
349echo "Executables are found in modipsl/bin"
350echo "Check that executable names correspond with the name set in config.card before launching the job"
351echo ls -lrt modipsl/bin
352ls -lrt $modipsl/bin
353
354date
355exit
356
357
Note: See TracBrowser for help on using the repository browser.