source: CONFIG/UNIFORM/v6/NEMO_v6.5.1/compile_nemo.sh

Last change on this file was 6629, checked in by falletti, 9 months ago

Adding a compilation check on Jean-Zay, to be sure that we compile on jean-za-pp (_work configurations)

  • Property svn:executable set to *
File size: 8.1 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
15#### Set default options
16# Coupled with ocean biogeochemistry (y/n)
17cpltop=WithTOP
18# Coupled with ocean biogeochemistry (y/n)
19cplmode=online
20
21# Optimization mode
22# optmode=prod/dev/debug
23optmode=prod
24# fcm_arch
25fcm_arch=default
26export fcm_arch xios
27full_nemo=n
28full_xios=""
29
30
31# Output text file for compilation of each component
32datestr=`LC_ALL=C date +"%Y%m%dT%H%M"`
33outfile=$submitdir/out_compile_nemo.$datestr
34echo > $outfile
35echo; echo "Text output from compilation will be stored in file out_compile_nemo.$datestr"; echo 
36
37#### Read arguments
38# Loop over all arguments to modify default set up
39while (($# > 0)) ; do
40    case $1 in
41        "-h") cat <<end_help
42########################################################################
43# Usage of the script compile_nemo.sh
44#
45########################################################################
46
47./compile_nemo.sh [Options]
48
49
50Options: [ORCA1 / ORCA2 / ORCA025 ] Model resolution, choose only one. Default: ORCA2
51         [OFFLINE] Compile Coupled NEMO-TOP in offline mode
52         [-full] Full recompilation of all components. This option can be added to all other options.
53         [-cleannemo] Full recompilation of NEMO component  only.
54         [-debug / -dev / -prod] Level of optimization. One of these can be added to all other compile options. Default: -prod.
55
56
57Example 1: Default compilation of ORCA_ICE_TOP
58./compile_nemo.sh
59
60Example 2: Compilation of TOP offline
61./compile_nemo.sh OFFLINE
62
63Example 3: Compilation of ORCA_ICE without passive tracers
64./compile_nemo.sh  NOTOP -cleannemo
65
66
67Example 4: Default resoltuion (LR) compiled in debug mode
68./compile_nemo.sh -debug
69
70Example 5: Default compilation with full recompilation of NEMO and XIOS. No clean is needed.
71./compile_nemo.sh -full
72
73Example 6: Full recompilation in debug mode
74./compile_nemo.sh OFFLINE -debug -full
75
76end_help
77exit;;
78        "NOTOP")       cpltop=WithoutTOP; shift ;;
79        "OFFLINE")     cplmode=offline; shift ;;
80        "-arch")       fcm_arch="$2" ; shift ; shift ;;
81        "-debug")      optmode=debug ; shift ;;
82        "-dev")        optmode=dev ; shift ;;
83        "-prod")       optmode=prod ; shift ;;
84        "-full")       full_nemo=y ; full_xios="--full" ; shift ;;
85        "-full_xios")  full_xios="--full" ; shift ;;  # Note only full_xios is using double dash: --full
86        "-full_nemo")  full_nemo=y ; shift ;;
87        "-cleannemo")  full_nemo=y ; shift ;;
88        *)             echo "unknown option "$1" , exiting..." ; exit
89    esac
90done
91
92echo "Following options are set in current compiling:" >> $outfile
93echo "   WithTracer=${cpltop}, coupled_mode=${cplmode}" >> $outfile 
94echo "   optmode = $optmode, fcm_arch = $fcm_arch " >> $outfile 
95echo "   full_xios=$full_xios, full_nemo=$full_nemo," >> $outfile 
96echo >> $outfile
97
98### Read host dependent default values
99### These variables will not be changed if they were set as argument
100###./host.sh $host
101# Later : Following lines should be set in host.sh file
102# begin host.sh
103if [ $fcm_arch == default ] ; then
104    # Find out current host and source specific paths and commands for the host
105    case $( hostname -s ) in
106        jean-zay*)
107            if [[ $( hostname -s ) != *"pp"* ]] ; then
108                echo "Warning! You MUST compile on jean-zay-pp."
109                echo "EXIT"
110                exit
111            else
112                fcm_arch=X64_JEANZAY
113            fi ;;
114        irene170|irene171|irene190|irene191|irene192|irene193)
115            fcm_arch=X64_IRENE;;
116        irene172|irene173|irene194|irene195)
117            fcm_arch=X64_IRENE-AMD;;
118        ciclad*|climserv*)
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    echo >> $outfile 
144    echo " New module list after sourcing of ARCH/arch.env file:"    >> $outfile 
145    module list   >> $outfile 2>&1
146fi
147
148#### 2 Do the compilation
149
150## 2.3 Compile xios
151cd $modipsl/modeles/XIOS
152echo; echo "NOW COMPILE XIOS"
153echo >> $outfile ; echo " NOW COMPILE XIOS"   >> $outfile 
154echo ./make_xios  --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 
155     ./make_xios  --$optmode --arch $fcm_arch --arch_path $arch_path --job 4 $full_xios   >> $outfile 2>&1
156# Test if compiling succeded
157if [[ $? != 0 ]] ; then
158    echo "THERE IS A PROBLEM IN XIOS COMPILATION - STOP"
159    exit
160fi
161# Move executables to modipsl/bin
162if [ -f $modipsl/modeles/XIOS/bin/xios_server.exe ] ; then
163    mv $modipsl/modeles/XIOS/bin/xios_server.exe $modipsl/bin/xios_server_${optmode}.exe
164else
165    echo "THERE IS A PROBLEM IN XIOS COMPILATION EXECUTABLE MISSING - STOP"
166    exit
167fi
168
169
170## 2.5 Compile NEMO
171nemo_root=$modipsl/modeles/NEMO
172cfg_ref=ORCA2_ICE_PISCES
173cfg_wrk=ORCA_ICE_TRC
174addkeys="key_isf"
175
176if [ ${cplmode} == offline ]  ;  then
177   cfg_ref=ORCA2_OFF_TRC
178   cfg_wrk=ORCA_OFF_TRC
179   delkeys="key_si3 key_qco key_isf"
180fi
181if [ ${cpltop} == WithoutTOP ]  ;  then
182   cfg_wrk=ORCA_ICE
183   delkeys="key_top"
184fi
185
186echo >> $outfile ; echo cd $nemo_root  >> $outfile
187echo >> $outfile ; echo cp $mysrc_path/arch-${fcm_arch}.fcm arch/CNRS/.   >> $outfile
188echo >> $outfile
189
190cd $nemo_root ; cp $mysrc_path/arch-${fcm_arch}.fcm arch/CNRS/.
191
192echo >> $outfile
193# creation of config
194echo >> $outfile ; echo cd $nemo_root  >> $outfile
195echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0 add_key "$addkeys"  del_key "$delkeys"   >> $outfile
196echo >> $outfile
197cd $nemo_root
198./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j0  add_key "$addkeys"  del_key "$delkeys"  >> $outfile 2>&1
199
200
201# Copy of specfic source files
202echo >> $outfile ; echo cp $mysrc_path/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.   >> $outfile
203echo >> $outfile
204cp $mysrc_path/*.*90  $nemo_root/cfgs/$cfg_wrk/MY_SRC/.
205
206if [ $full_nemo == y ] ; then
207   # To make a full compilation, first make a clean to remove all files produced during previous compilation
208   echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean   >> $outfile
209   echo >> $outfile
210   ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref clean  >> $outfile 2>&1
211fi
212echo ./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile
213echo >> $outfile
214./makenemo -m ${fcm_arch} -n $cfg_wrk -r $cfg_ref -j8  >> $outfile 2>&1
215
216
217# Test if compiling finished
218if [[ $? != 0 ]] ; then
219    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
220    exit
221fi
222
223echo >> $outfile
224echo "Move nemo executable to modipsl/bin" >> $outfile
225echo ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin   >> $outfile
226ls -lrt $nemo_root/cfgs/$cfg_wrk/BLD/bin  >> $outfile
227echo >> $outfile
228
229if [ -f $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe ] ; then
230   mv $nemo_root/cfgs/$cfg_wrk/BLD/bin/nemo.exe $modipsl/bin/opa_${cplmode}_${optmode}.exe
231else
232    echo "ERROR gcm${suffix} executable does not exist."
233    echo "THERE IS A PROBLEM IN NEMO COMPILATION - STOP"
234    exit
235fi
236
237
238echo >>$outfile ; echo "ALL COMPILING FINISHED" >> $outfile
239echo ls -lrt modipsl/bin >> $outfile
240ls -lrt $modipsl/bin >> $outfile
241
242echo; echo "ALL COMPILING FINISHED" ; echo
243echo "Executables are found in modipsl/bin"
244echo "Check that executable names correspond with the name set in config.card before launching the job"
245echo ls -lrt modipsl/bin
246ls -lrt $modipsl/bin
247
248date
249
250exit
251
252
Note: See TracBrowser for help on using the repository browser.