/[MITgcm]/MITgcm_contrib/verification_other/cpl_gray+ocn/run_cpl_test
ViewVC logotype

Annotation of /MITgcm_contrib/verification_other/cpl_gray+ocn/run_cpl_test

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


Revision 1.6 - (hide annotations) (download)
Tue Aug 8 20:20:56 2017 UTC (7 years, 11 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint66o, checkpoint66n, checkpoint66m, checkpoint66l, checkpoint66k, checkpoint66j, checkpoint67a, checkpoint67b, checkpoint67d, HEAD
Changes since 1.5: +37 -25 lines
make it easier to modify

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

  ViewVC Help
Powered by ViewVC 1.1.22