/[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.20 - (show annotations) (download)
Wed Jan 16 13:40:04 2013 UTC (11 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64q, checkpoint64p, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64c, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f
Changes since 1.19: +18 -13 lines
improve optfile specification

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

  ViewVC Help
Powered by ViewVC 1.1.22