source: CONFIG_DEVT/IPSLCM6.5_work_ENSEMBLES/config/IPSLCM6/compile_ipslcm6.sh @ 5502

Last change on this file since 5502 was 5502, checked in by aclsce, 20 months ago
  • Modified to do the ins_make through compile script.
  • Property svn:executable set to *
File size: 16.9 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
13mysrc_path=$submitdir/SOURCES
14
15cd ../../util ; ./ins_make ; cd $submitdir
16
17#### Set default options
18# Atmospheric resolution, for LMDZ/ORCHIDEE in regular mode
19resol_atm=96x95x59
20# Coupled with ocean biogeochemistry (y/n)
21nemotop=y
22# Version AER : Aer interactif chemistry / atmosphere (y/n)
23aer=n
24# Also compile ce0l subprogram to LMDZ (y/n)
25ce0l=n
26
27# Optimization mode
28# optmode=prod/dev/debug
29optmode=prod
30# fcm_arch
31fcm_arch=default
32# Default values to be overritten
33parallel=mpi_omp
34export fcm_arch parallel xios
35full_flag=""
36full_nemo=n
37full_inca=""
38full_xios=""
39full_lmdz=""
40full_orch=""
41
42
43
44# Output text file for compilation of each component
45datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
46outfile=$submitdir/out_compile_ipslcm6.$datestr
47echo > $outfile
48echo; echo "Text output from compilation will be stored in file out_compile_ipslcm6.$datestr"; echo 
49
50#### Read arguments
51# Loop over all arguments to modify default set up
52while (($# > 0)) ; do
53    case $1 in
54        "-h") cat <<end_help
55########################################################################
56# Usage of the script compile_ipslcm6.sh
57#
58########################################################################
59
60./compile_ipslcm6.sh [Options]
61
62
63Options: [LR / VLR / MR] Model resolution, choose only one. Default: LR.
64         [AER] Compile IPSLCM6 for AER interactif on atmosphere
65         [-full] Full recompilation of all components. This option can be added to all other options.
66         [-cleannemo] Full recompilation of NEMO component  only.
67         [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod.
68
69
70Example 1: Default compilation of IPSLCM6 for resoltion LR
71          (Resolution atmos: 144x142x79)
72./compile_ipslcm6.sh
73
74Example 2: Compilation of IPSLCM6 for resolution VLR
75           (atmos: 96x95x39)
76./compile_ipslcm6.sh VLR
77
78Example 3: Compilation of IPSLCM6 for resolution MR
79           (atmos: 256x256x79)
80./compile_ipslcm6.sh MR
81
82Example 4: Default resoltuion (LR) compiled in debug mode
83./compile_ipslcm6.sh -debug
84
85Example 5: Default compilation with full recompilation of all components. No clean is needed.
86./compile_ipslcm6.sh -full
87
88Example 6: Full recompilation of resolution MR in debug mode
89./compile_ipslcm6.sh MR -debug -full
90
91end_help
92exit;;
93        "VLR")         resol_atm=96x95x39;  nemotop=y; shift ;;
94        "LR")          resol_atm=144x142x79; nemotop=y; shift ;;
95        "MR")          resol_atm=256x256x79;  nemotop=y; shift ;;
96        "AER")         aer=y; shift ;;
97        "CE0L")        ce0l=y ; shift ;;
98        "-parallel")   parallel=$2 ; shift ; shift ;;
99        "-arch")       fcm_arch="$2" ; shift ; shift ;;
100        "-debug")      optmode=debug ; shift ;;
101        "-dev")        optmode=dev ; shift ;;
102        "-prod")       optmode=prod ; shift ;;
103        "-full")       full_flag="-full"; full_nemo=y ; full_xios="--full" ; full_lmdz="-full" ; full_orch="-full" ; shift ;;
104        "-full_xios")  full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
105        "-full_lmdz")  full_lmdz="-full"  ; shift ;;
106        "-full_orch")  full_orch="-full"  ; shift ;;
107        "-full_nemo")  full_nemo=y ; shift ;;
108        "-full_inca")  full_inca="-clean"; shift ;;
109        "-cleannemo")  full_nemo=y ; shift ;;
110        *)             echo "unknown option "$1" , exiting..." ; exit
111    esac
112done
113
114echo "Following options are set in current compiling:" >> $outfile
115echo "   resol_atm=${resol_atm}, nemotop=${nemotop}" >> $outfile 
116echo "   aer=${aer}" >> $outfile 
117echo "   ce0l=${ce0l}" >> $outfile 
118echo "   optmode = $optmode, parallel = $parallel, fcm_arch = $fcm_arch " >> $outfile 
119echo "   full_flag=$full_flag, full_xios=$full_xios, full_lmdz=$full_lmdz, full_orch=$full_orch, full_nemo=$full_nemo," >> $outfile 
120echo >> $outfile
121
122### Read host dependent default values
123### These variables will not be changed if they were set as argument
124###./host.sh $host
125# Later : Following lines should be set in host.sh file
126# begin host.sh
127if [ $fcm_arch == default ] ; then
128    # Find out current host and source specific paths and commands for the host
129    case $( hostname -s ) in
130        jean-zay*)
131            fcm_arch=X64_JEANZAY;;
132        irene170|irene171|irene190|irene191|irene192|irene193)
133            fcm_arch=X64_IRENE;;
134        irene172|irene173|irene194|irene195)
135            fcm_arch=X64_IRENE-AMD;;
136        asterix*|obelix*)
137            fcm_arch=ifort_LSCE
138            if [ "${parallel}" == "mpi_omp" ] ; then
139                echo "Warning!! Currently at Obelix hybrid mode is not possible."
140                echo "          Option -parallel mpi_omp is now changed to -parallel mpi"
141                echo ""
142                parallel=mpi
143            else
144                echo "You used -parallel" $parallel
145            fi ;;
146        ciclad*|climserv*|loholt*|camelot*)
147            fcm_arch=ifort_CICLAD;;
148        *)
149            echo Current host is not known. You must use option -arch to specify which architecuture files to use.
150            echo Exit now.
151            exit
152    esac
153fi
154
155# Set a link to arch.env if arch-${fcm_arch}.env file exist for current fcm_arch.
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
158    echo >> $outfile
159    echo "The file ARCH/arch-${fcm_arch}.env will now be sourced with modules needed for compilation for all components."
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
164
165    # Make a link to this file, to be used also in config.card
166    rm -f ARCH/arch.env
167    ln -s arch-${fcm_arch}.env ARCH/arch.env
168
169    # Source the file
170    source ARCH/arch.env   >> $outfile 2>&1
171    echo >> $outfile 
172    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
173    module list   >> $outfile 2>&1
174fi
175
176#### 2 Do the compilation
177## 2.1 Compile ioipsl
178cd $modipsl/modeles/IOIPSL
179echo; echo "NOW COMPILE IOIPSL"
180echo >> $outfile ; echo " NOW COMPILE IOIPSL"   >> $outfile 
181
182# Check if compilation with fcm is included in IOIPSL
183if [ ! -f makeioipsl_fcm ] ; then
184  echo "The file makeiopsl_fcm do not exist. Probably this is not the right version of IOIPSL."
185  echo "Version of IOIPSL with fcm compilation is needed to compile with this script. Stop now."
186  exit
187fi
188
189echo ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 
190     ./makeioipsl_fcm -$optmode -parallel -arch ${fcm_arch} -arch_path $arch_path -j 8 $full_flag   >> $outfile 2>&1
191# Test if compiling succeded
192if [[ $? != 0 ]] ; then
193    echo "THERE IS A PROBLEM IN IOIPSL COMPILATION - STOP"
194    exit
195fi
196
197## 2.2 Compile oasis3-mct
198echo; echo "NOW COMPILE OASIS3-MCT"
199echo >> $outfile ; echo " NOW COMPILE OASIS3-MCT"   >> $outfile
200cd $modipsl/oasis3-mct/lib/mct/mct
201cp $mysrc_path/OASIS3-MCT/*.F90  .
202cd $modipsl/oasis3-mct/util/make_dir
203cp $mysrc_path/OASIS3-MCT/make_${fcm_arch} make.inc
204
205echo make -f TopMakefileOasis3 >> $outfile
206     make -f TopMakefileOasis3 >> $outfile 2>&1
207
208
209## 2.3 Compile xios
210cd $modipsl/modeles/XIOS
211echo; echo "NOW COMPILE XIOS"
212echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
213echo ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 
214     ./make_xios --use_oasis oasis3_mct --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 2>&1
215# Test if compiling succeded
216if [[ $? != 0 ]] ; then
217    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
218    exit
219fi
220# Move executables to modipsl/bin
221if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
222    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
223else
224    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
225    exit
226fi
227
228
229## 2.4 Compile orchidee
230cd $modipsl/modeles/ORCHIDEE
231echo; echo "NOW COMPILE ORCHIDEE"
232echo >> $outfile ; echo " NOW COMPILE ORCHIDEE"   >> $outfile 
233
234# Check if the compilation of ORCHIDEE was previsouly interupted prematured.
235# In that case, the files fcm.bld.lock exist. If the file exist, it is here removed to avoid makeorchidee_fcm
236# to ask question and wait for interactivly answer from the user.
237if [ -f build/fcm.bld.lock ] ; then
238    echo >> $outfile
239    echo " WARNING!! The file ORCHIDEE/build/fcm.bld.lock exist. "   >> $outfile
240    echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
241    echo "           The file will now be removed. "   >> $outfile
242    echo >> $outfile
243    rm -f build/fcm.bld.lock
244fi
245
246echo    ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch   >> $outfile 
247        ./makeorchidee_fcm -j 8 -xios -parallel $parallel -$optmode -arch ${fcm_arch} -arch_path $arch_path $full_orch   >> $outfile 2>&1
248# Test if compiling finished
249if [[ $? != 0 ]] ; then
250    echo "THERE IS A PROBLEM IN ORCHIDEE COMPILATION - STOP"
251    exit
252fi
253
254
255## 2.5 Compile NEMO
256nemo_root=$modipsl/modeles/NEMO
257cfg_ref=ORCA2_ICE_PISCES
258cfg_wrk=ORCA_ICE_TRC
259addkeys="key_oasis3 key_top key_si3"
260delkeys=""
261
262if [ ${nemotop} == n ] ; then
263   cfg_wrk=ORCA_ICE
264   delkeys="key_top"
265fi
266
267if [ ${nemotop} == n ] ; then
268   echo; echo "NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"
269   echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 without passive tracer model TOP"   >> $outfile
270else
271   echo; echo "NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"
272   echo >> $outfile ; echo " NOW COMPILE NEMO with ice model SI3 and passive tracer model TOP"   >> $outfile
273fi
274
275echo >> $outfile ; echo cd $nemo_root  >> $outfile
276echo >> $outfile ; echo cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.   >> $outfile
277echo >> $outfile
278
279cd $nemo_root ; cp $mysrc_path/NEMO/arch-${fcm_arch}.fcm arch/CNRS/.
280
281# creation of config
282echo >> $outfile ; echo cd $nemo_root  >> $outfile
283echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
284echo >> $outfile
285cd $nemo_root
286./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0  add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
287
288
289# Copy of specfic source files
290echo >> $outfile ; echo cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
291echo >> $outfile
292cp $mysrc_path/NEMO/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
293
294
295if [ $full_nemo == y ] ; then
296   # To make a full compilation, first make a clean to remove all files produced during previous compilation
297   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean   >> $outfile
298   echo >> $outfile
299   ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean  >> $outfile 2>&1
300fi
301echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile
302echo >> $outfile
303./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile 2>&1
304
305echo >> $outfile
306echo "Move nemo executable to modipsl/bin" >> $outfile
307echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin   >> $outfile
308ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin  >> $outfile
309echo >> $outfile
310
311if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then
312   mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${optmode}.exe
313else
314    echo "ERROR nemo.exe executable does not exist."
315    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
316    exit
317fi
318
319
320## 2.6 Compile LMDZ for regular latlon configuration
321# If necessary compile INCA modele with AER configuration
322if [ ${aer} == y ] ;  then
323    cd $modipsl/modeles/INCA
324    #compile INCA regulat lat_lon chimie librairy
325    echo; echo "NOW COMPILE INCA AER on resolution = ${resol_atm}"
326    echo ./makeinca_fcm -chimie AER -$optmode -xios -parallel mpi_omp -resol ${resol_atm} -j 8 -arch ${fcm_arch}  -arch_path $arch_path $full_flag $full_inca >> $outfile 
327    ./makeinca_fcm -chimie AER -$optmode -xios -parallel mpi_omp -resol ${resol_atm} -j 8 -arch ${fcm_arch} -arch_path $arch_path  $full_flag $full_inca >> $outfile 2>&1
328
329    # Test if compiling finished
330    if [[ $? != 0 ]] ; then
331        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
332        exit
333    fi
334
335    echo "Move inca.dat modipsl/bin"
336    if [[ -f $modipsl/modeles/INCA/SIMULATIONS/AER/inca.dat ]] ;  then 
337        mv $modipsl/modeles/INCA/SIMULATIONS/AER/inca.dat $modipsl/bin/inca_${resol_atm}_${optmode}_AER.dat ;
338    else
339        echo "THERE IS A PROBLEM IN INCA COMPILATION - STOP"
340        exit   
341    fi
342       
343fi 
344
345
346# Compile LMDZ regular lat-lon executable
347cd $modipsl/modeles/LMDZ
348echo; echo "NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"
349echo >> $outfile ; echo " NOW COMPILE LMDZ REGULAR LAT-LON MODE. Resolution = ${resol_atm}"   >> $outfile 
350
351# Check if the compilation of LMDZ was previsouly interupted prematured.
352# In that case, the files dimension.h and .lock exist. If the files exist, they are here removed to avoid makelmdz_fcm
353# to ask question and wait for interactivly answer from the user.
354if [ -f libf/grid/dimensions.h ] || [ -f .lock ] ; then
355  echo >> $outfile
356  echo " WARNING!! The file LMDZ/libf/grid/dimension.h and/or the LMDZ/.lock exist. "   >> $outfile
357  echo "           This means that the compilation is either currently on going in another terminal was previous interupted before the end."   >> $outfile
358  echo "           The files dimension.h and .lock will now be removed. "   >> $outfile
359  echo >> $outfile
360  rm -f libf/grid/dimensions.h
361  rm -f .lock
362fi
363
364if [ ${aer} == n ] ;  then
365    echo ./makelmdz_fcm -d ${resol_atm} -c OMCT -rrtm true -$optmode -mem -parallel $parallel -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 
366    ./makelmdz_fcm -d ${resol_atm} -c OMCT -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
367else
368    #in aer case add chemistry option to lmdz compilation
369    echo ./makelmdz_fcm -d ${resol_atm} -c OMCT -rrtm true -$optmode -mem -parallel $parallel -chimie INCA -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 
370    ./makelmdz_fcm -d ${resol_atm} -c OMCT -rrtm true -$optmode -mem -parallel $parallel -chimie INCA -io xios -v orchidee2.1 -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz gcm    >> $outfile 2>&1
371fi 
372# Test if compiling finished
373if [[ $? != 0 ]] ; then
374    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
375    exit
376fi
377
378# Move executables to modipsl/bin folder
379echo >> $outfile
380echo "Move gcm.e executable to modipsl/bin" >> $outfile
381echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
382ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
383echo >> $outfile
384if [ ${aer} == n ] ;  then
385    suffix=_${resol_atm}_phylmd_para_mem_orch_couple.e
386else
387    suffix=_${resol_atm}_phylmd_para_mem_orch_couple_inca.e
388fi
389echo gcm suffix = $suffix
390
391if [ -f $modipsl/modeles/LMDZ/bin/gcm${suffix} ] ;  then
392    if [ ${aer} == n ] ;  then
393        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}.e
394    else
395        mv $modipsl/modeles/LMDZ/bin/gcm${suffix} $modipsl/bin/gcm_${resol_atm}_${optmode}_AER.e
396    fi
397else
398    echo "ERROR gcm${suffix} executable does not exist." 
399    echo "THERE IS A PROBLEM IN LMDZ REGULAR LATLON COMPILATION - STOP"
400    exit
401fi 
402
403
404# Compile ce0l initialization program for LMDZ regular lat-lon exectuable
405if [ $ce0l == y ] ; then
406    echo; echo "NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"
407    echo >> $outfile ; echo " NOW COMPILE CE0L OF LMDZ. Resolution = ${resol_atm}"   >> $outfile 
408   
409    echo ./makelmdz_fcm -d ${resol_atm} -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 
410    ./makelmdz_fcm -d ${resol_atm} -rrtm true -$optmode -io xios -arch $fcm_arch -arch_path $arch_path -j 8 $full_lmdz ce0l    >> $outfile 2>&1
411    # Test if compiling finished
412    if [[ $? != 0 ]] ; then
413        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
414        exit
415    fi
416
417
418    # Move executables to modipsl/bin folder
419    echo >> $outfile
420    echo "Move ce0l.e executable to modipsl/bin" >> $outfile
421    echo ls -lrt $modipsl/modeles/LMDZ/bin   >> $outfile
422    ls -lrt $modipsl/modeles/LMDZ/bin  >> $outfile
423    echo >> $outfile
424    suffix=_${resol_atm}_phylmd_seq.e
425    echo ce0l suffix = $suffix
426
427    if [ -f $modipsl/modeles/LMDZ/bin/ce0l${suffix} ] ;  then
428        mv $modipsl/modeles/LMDZ/bin/ce0l${suffix} $modipsl/bin/ce0l_${resol_atm}_${optmode}.e
429    else
430        echo "ERROR ce0l${suffix} executable does not exist." 
431        echo "THERE IS A PROBLEM IN CE0L (LMDZ) REGULAR LATLON COMPILATION - STOP"
432        exit
433    fi 
434fi
435
436echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
437echo ls -lrt modipsl/bin >> $outfile
438ls -lrt $modipsl/bin >> $outfile
439
440echo; echo "ALL COMPILING FINISHED" ; echo
441echo "Executables are found in modipsl/bin"
442echo "Check that executable names correspond with the name set in config.card before launching the job"
443echo ls -lrt modipsl/bin
444ls -lrt $modipsl/bin
445
446date
447
448exit
449
450
Note: See TracBrowser for help on using the repository browser.