/[MITgcm]/MITgcm/verification/cpl_aim+ocn/run_cpl_test
ViewVC logotype

Contents of /MITgcm/verification/cpl_aim+ocn/run_cpl_test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.24 - (show annotations) (download)
Tue Aug 8 20:21:19 2017 UTC (6 years, 7 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, HEAD
Changes since 1.23: +27 -23 lines
make it easier to modify

1 #! /usr/bin/env bash
2
3 # $Header: /u/gcmpack/MITgcm/verification/cpl_aim+ocn/run_cpl_test,v 1.23 2015/10/26 21:04:35 jmc Exp $
4 # $Name: $
5
6 bdPfx='build'; # build-dir prefix
7
8 #- default:
9 Npr=3 ; NpOc=1 ;
10 #Npr=25; NpOc=12;
11 MTH=
12 MTHo=
13 MTHa=
14 GMKopt='-devel'
15 #GMKopt='-ieee'
16 #GMKopt=
17 rnkO=1 ; rnkA=`expr $rnkO + $NpOc`
18
19 #- parse options:
20 if [ $# -ge 1 ] ; then if test $1 = '-mth' ; then
21 MTH='-omp' ; shift
22 if test -f input_ocn/eedata.mth ; then MTHo=$MTH ; fi
23 if test -f input_atm/eedata.mth ; then MTHa=$MTH ; fi
24 fi ; fi
25 #- allows more argument for building step (step=1)
26 chkArg=$# ; if [ $# -gt 1 ]; then chkArg=$1 ; fi
27 if [ $chkArg -ne 1 ]; then
28 echo 'Usage:'`basename $0`' [opt] step [bld-arg]'
29 echo ' => test coupled set-up on linux box (1.cpu)'
30 echo 'opt = -mth : compile and run (if eedata.mth) 2-threads for ocn & atm'
31 echo ' step = 0 : clean all directories'
32 echo ' step = 1 : compile the 3 executables (cpl,ocn,atm); optional arg:'
33 echo ' -of Optfile_Name : using option-file "Optfile_Name"'
34 echo ' step = 2 : copy input files and dir(s)'
35 echo " step = 3 : run with $Npr mpi processes"
36 echo ' step = 4 : check the results'
37 echo ' step = 5 : remove output files in rank_0,1,2 dir.'
38 exit
39 fi
40 kpr=$1
41 dir=`pwd`
42
43 #============================================================================
44
45 if test $kpr = 0
46 then
47 rm -f pr_group std_outp comp_res.{ocn,atm,land,sice}
48 rm -f ${bdPfx}_???/TTT.*make.* ${bdPfx}_???/TTT.mkdepend.*
49 /bin/rm -r -f rank_? rank_1? rank_2?
50 if test -f ${bdPfx}_cpl/Makefile ; then cd ${bdPfx}_cpl ; make Clean ; cd .. ; fi
51 if test -f ${bdPfx}_ocn/Makefile ; then cd ${bdPfx}_ocn ; make Clean ; cd .. ; fi
52 if test -f ${bdPfx}_atm/Makefile ; then cd ${bdPfx}_atm ; make Clean ; cd .. ; fi
53 fi
54 if test $kpr = 5
55 then
56 echo 'remove output files in rank_0,1,2 dir.'
57 rm -f pr_group std_outp comp_res.{ocn,atm,land,sice}
58 test -f rank_0/Coupler.0000.clog && rm -f rank_0/Coupler.0000.clog
59 if test -d rank_$rnkO ; then
60 ( cd rank_$rnkO ; rm -f *.data *.meta *.txt *.log STD???.00?? UV-*.00??.clog )
61 fi
62 if test -d rank_$rnkA ; then
63 ( cd rank_$rnkA ; rm -f *.data *.meta *.txt *.log STD???.00?? UV-*.00??.clog )
64 fi
65 fi
66
67 if test $kpr = 1
68 then
69
70 #- choice of the optfile:
71 # default: take a local one in dir verification with sufix '+mpi'
72 nbOpF=`ls ../linux_* | grep '+mpi' 2> /dev/null | wc -l`
73 # or take the one given as argument:
74 if [ $# -ge 3 ]; then
75 if test $2 = '-of' -a -f $3 ; then nbOpF=-1 ; OPTFILE=$3 ; fi
76 fi
77 if test $nbOpF = 1 ; then
78 OPTFILE=`ls ../linux_* | grep '+mpi'`
79 elif [ $nbOpF -ge 2 ] ; then
80 echo "pick the 1rst of these ( $nbOpF ) optfiles:"
81 ls ../linux_* | grep '+mpi'
82 OPTFILE=`ls ../linux_* | grep '+mpi' | head -1`
83 elif [ $nbOpF -ne -1 ] ; then
84 echo "Pb in finding optfile: found $nbOpF :"
85 ls ../linux_* | grep '+mpi' ; exit
86 fi
87 zz=`grep '^ *FC=' $OPTFILE | tail -1`
88 echo " Using optfile: $OPTFILE (compiler: $zz) $MTH"
89 zz=`echo $OPTFILE | grep -c '^\/'`
90 if test $zz = 0 ; then OPTFILE="../$OPTFILE" ; fi
91 #---
92 echo '==== compile coupler:'
93 cd ${bdPfx}_cpl
94 echo ' --- genmake2 (cpl):'
95 ../../../tools/genmake2 -of $OPTFILE -mpi $GMKopt > TTT.genmake.$$ 2>&1
96 RetVal=$? ; tail -5 TTT.genmake.$$
97 if test "x$RetVal" != x0 ; then
98 echo "Error in genmake2 (cpl)" ; exit 11
99 fi
100 echo ' --- make depend (cpl):'
101 make depend > TTT.mkdepend.$$ 2>&1
102 RetVal=$? ; tail -5 TTT.mkdepend.$$
103 if test "x$RetVal" != x0 ; then
104 echo "Error in mkdepend (cpl)" ; exit 12
105 fi
106 echo ' --- make (cpl):' ; touch TTT.make.$$
107 #do_make_syntax.sh obj > TTT.make.$$ 2>&1
108 make >> TTT.make.$$ 2>&1
109 RetVal=$? ; tail -10 TTT.make.$$
110 if test "x$RetVal" != x0 ; then
111 echo "Error in make (cpl)" ; exit 13
112 fi
113 echo ' ' ; cd $dir
114
115 echo '==== compile OGCM:'
116 cd ${bdPfx}_ocn
117 echo ' --- genmake2 (ocn):'
118 ../../../tools/genmake2 -of $OPTFILE -mpi $MTHo $GMKopt > TTT.genmake.$$ 2>&1
119 RetVal=$? ; tail -5 TTT.genmake.$$
120 if test "x$RetVal" != x0 ; then
121 echo "Error in genmake2 (ocn)" ; exit 21
122 fi
123 echo ' --- make depend (ocn):'
124 make depend > TTT.mkdepend.$$ 2>&1
125 RetVal=$? ; tail -10 TTT.mkdepend.$$
126 if test "x$RetVal" != x0 ; then
127 echo "Error in mkdepend (ocn)" ; exit 22
128 fi
129 echo ' --- make (ocn):' ; touch TTT.make.$$
130 #do_make_syntax.sh obj > TTT.make.$$ 2>&1
131 make >> TTT.make.$$ 2>&1
132 RetVal=$? ; tail -10 TTT.make.$$
133 if test "x$RetVal" != x0 ; then
134 echo "Error in make (ocn)" ; exit 23
135 fi
136 echo ' ' ; cd $dir
137
138 echo '==== compile AGCM:'
139 cd ${bdPfx}_atm
140 echo ' --- genmake2 (atm):'
141 ../../../tools/genmake2 -of $OPTFILE -mpi $MTHa $GMKopt > TTT.genmake.$$ 2>&1
142 RetVal=$? ; tail -5 TTT.genmake.$$
143 if test "x$RetVal" != x0 ; then
144 echo "Error in genmake2 (atm)" ; exit 31
145 fi
146 echo ' --- make depend (atm):'
147 make depend > TTT.mkdepend.$$ 2>&1
148 RetVal=$? ; tail -10 TTT.mkdepend.$$
149 if test "x$RetVal" != x0 ; then
150 echo "Error in mkdepend (atm)" ; exit 32
151 fi
152 echo ' --- make (atm):' ; touch TTT.make.$$
153 #do_make_syntax.sh obj > TTT.make.$$ 2>&1
154 make >> TTT.make.$$ 2>&1
155 RetVal=$? ; tail -10 TTT.make.$$
156 if test "x$RetVal" != x0 ; then
157 echo "Error in make (atm)" ; exit 33
158 fi
159 echo ' ' ; cd $dir
160
161 ls -l ${bdPfx}_???/mitgcmuv
162
163 fi
164
165 if test $kpr = 2
166 then
167 echo 'rm dir:' rank_? rank_1? rank_2?
168 /bin/rm -r -f rank_? rank_1? rank_2?
169 echo 'Link files from dir:' input_cpl '->' rank_0
170 mkdir rank_0
171 ( cd rank_0 ; ln -s ../input_cpl/* . )
172
173 n=$rnkO
174 echo 'Link files from dir:' input_ocn '->' rank_$n
175 mkdir rank_$n
176 cd rank_$n
177 ln -s ../input_ocn/* .
178 if test -x prepare_run ; then ./prepare_run ; fi
179 if test "x$MTHo" != x ; then
180 echo " MTH run: mv -f eedata.mth eedata"
181 if test -h eedata ; then rm -f eedata ; fi
182 mv -f eedata.mth eedata
183 fi
184 cd $dir
185 n=`expr $n + 1`
186 while [ $n -le $NpOc ] ; do
187 ln -s rank_$rnkO rank_$n
188 n=`expr $n + 1`
189 done
190
191 n=$rnkA
192 echo 'Link files from dir:' input_atm '->' rank_$n
193 mkdir rank_$n
194 cd rank_$n
195 ln -s ../input_atm/* .
196 if test -x prepare_run ; then ./prepare_run ; fi
197 if test "x$MTHa" != x ; then
198 echo " MTH run: mv -f eedata.mth eedata"
199 if test -h eedata ; then rm -f eedata ; fi
200 mv -f eedata.mth eedata
201 fi
202 cd $dir
203 n=`expr $n + 1`
204 while [ $n -lt $Npr ] ; do
205 ln -s rank_$rnkA rank_$n
206 n=`expr $n + 1`
207 done
208
209 fi
210
211 if test $kpr = 3
212 then
213 ROOTDIR=$dir
214 # rm -f rank_?/pickup*.ckptA.00?.00?.??ta
215 echo $ROOTDIR
216 tmpfil=TTT.$$
217
218 #--- running on the same node:
219 list='' ; nc=0; xx=`hostname`
220 while [ $nc -lt $Npr ] ; do list="$list $xx" ; nc=`expr $nc + 1` ; done
221 #-- On darwin cluster node (from qrsh session):
222 # JOB_ID=`qstat | sed -n '3,$ p' | grep " $USER " | awk '{print $1}'`
223 # NODEFILE="/tmp/$JOB_ID.1.darwin/machines"
224 # echo " JOB_ID = '$JOB_ID' ; NODEFILE = '$NODEFILE'"
225 #-- On ACES cluster (in PBS batch job):
226 # NODEFILE=$PBS_NODEFILE
227 #--- running on different nodes:
228 # ls -l $NODEFILE
229 # nprc=`cat $NODEFILE | uniq | wc -l`
230 # if [ $nprc -ge $Npr ] ; then
231 # list=`cat $NODEFILE | uniq | head -$Npr`
232 # else
233 # list=`cat $NODEFILE | head -$Npr`
234 # fi
235
236 nc=0; nn=0; dd1=cpl ;
237 rm -f pr_group ; touch pr_group
238 for xx in $list
239 do
240 echo $xx $nn $dir/${bdPfx}_$dd1/mitgcmuv >> pr_group
241 nc=`expr $nc + 1`
242 if [ $nc -le $NpOc ] ; then dd1=ocn ; else dd1=atm ; fi
243 nn=1
244 done
245 NpAt=`expr $Npr - 1 - $NpOc`
246 RunOpt="-np 1 ./${bdPfx}_cpl/mitgcmuv"
247 RunOpt="$RunOpt : -np $NpOc ./${bdPfx}_ocn/mitgcmuv"
248 RunOpt="$RunOpt : -np $NpAt ./${bdPfx}_atm/mitgcmuv"
249
250 cd $ROOTDIR
251 if test "x$MTH" != x ; then
252 export OMP_NUM_THREADS=2 ; export KMP_STACKSIZE=400m
253 if test "x$MTHo" != x ; then
254 echo -n " run OCN ($MTHo) with $OMP_NUM_THREADS threads ;"
255 fi
256 if test "x$MTHa" != x ; then
257 echo -n " run ATM ($MTHa) with $OMP_NUM_THREADS threads ;"
258 fi
259 echo ""
260 fi
261 mpich=`which mpirun`
262 echo $mpich | grep 'mpich-mx' > /dev/null 2>&1
263 mpichmx=$?
264 echo $mpich | grep 'mpich-1' > /dev/null 2>&1
265 mpich1=$?
266 echo $mpich | grep 'mpich2' > /dev/null 2>&1
267 mpich2=$?
268 echo $mpich | grep 'openmpi' > /dev/null 2>&1
269 opnmpi=$?
270 if test $mpich1 == 0 ; then
271 # /usr/local/pkg/mpi/mpi-1.2.4..8a-gm-1.5/pgi/bin/mpirun.ch_gm -pg pr_group -wd $ROOTDIR --gm-kill 5 -v ./${bdPfx}_cpl/mitgcmuv > std_outp 2>&1
272 #- with mpich-1 (on danton, old aces: ao, geo, itrda):
273 echo "execute 'mpirun -p4pg pr_group -v ./${bdPfx}_cpl/mitgcmuv' :"
274 mpirun -p4pg pr_group -v ./${bdPfx}_cpl/mitgcmuv > std_outp 2>&1
275 elif test $mpichmx == 0 ; then
276 #- with mpich-mx (on beagle):
277 echo "execute 'mpirun -pg pr_group -v ./${bdPfx}_cpl/mitgcmuv' :"
278 mpirun -pg pr_group -v ./${bdPfx}_cpl/mitgcmuv > std_outp 2>&1
279 elif test $mpich2 == 0 -o $opnmpi == 0 ; then
280 #- with Hydra mpich2 (on baudelaire) or with openmpi:
281 echo "execute 'mpirun $RunOpt' :"
282 mpirun $RunOpt > std_outp 2>&1
283 else
284 #- new mpich (mpich2) installation often just put in "mpich" dir
285 echo "execute 'mpirun $RunOpt' :"
286 mpirun $RunOpt > std_outp 2>&1
287 fi
288 tail -20 std_outp
289 ls -l rank_$rnkO/pickup*.ckptA.001.001.data
290 ls -l rank_$rnkA/pickup*.ckptA.001.001.data
291
292 fi
293
294 if test $kpr = 4
295 then
296 CompRes="$HOME/bin/comp_res"
297
298 if test -f rank_$rnkO/STDOUT.0000
299 then echo '==> check Ocean output:'
300 $CompRes rank_$rnkO/STDOUT.0000 results/ocnSTDOUT.0000
301 mv -f comp_res.log comp_res.ocn
302 echo ' '
303 else echo "No Ocean output file in rank_$rnkO" ; fi
304
305 if test -f rank_$rnkA/STDOUT.0000
306 then
307 echo '==> check Atmos output:'
308 $CompRes rank_$rnkA/STDOUT.0000 results/atmSTDOUT.0000
309 mv -f comp_res.log comp_res.atm
310 echo '==> check Land output:'
311 $CompRes rank_$rnkA/STDOUT.0000 results/atmSTDOUT.0000 L
312 mv -f comp_res.log comp_res.land
313 echo '==> check thSIce output:'
314 $CompRes rank_$rnkA/STDOUT.0000 results/atmSTDOUT.0000 I
315 mv -f comp_res.log comp_res.sice
316 echo ' '
317 else echo "No Atmos output file in rank_$rnkA" ; fi
318
319 fi
320
321 exit 0

  ViewVC Help
Powered by ViewVC 1.1.22