1 |
#! /bin/sh |
2 |
|
3 |
# $Header: /u/gcmpack/MITgcm/verification/cpl_aim+ocn/run_cpl_test,v 1.15 2010/01/13 00:25:37 jmc Exp $ |
4 |
# $Name: $ |
5 |
|
6 |
#- default: |
7 |
Np=3 |
8 |
MTH= |
9 |
MTHo= |
10 |
MTHa= |
11 |
GMKopt='-ieee' |
12 |
|
13 |
#- parse options: |
14 |
if [ $# -ge 1 ] ; then if test $1 = '-mth' ; then |
15 |
MTH='-omp' ; shift |
16 |
if test -f input_ocn/eedata.mth ; then MTHo=$MTH ; fi |
17 |
if test -f input_atm/eedata.mth ; then MTHa=$MTH ; fi |
18 |
fi ; fi |
19 |
if [ $# -ne 1 ] |
20 |
then |
21 |
echo 'Usage:'`basename $0`' [opt] step' |
22 |
echo ' => test coupled set-up on linux box (1.cpu)' |
23 |
echo 'opt = -mth : compile and run (if eedata.mth) 2-threads for ocn & atm' |
24 |
echo ' step = 0 : clean all directories' |
25 |
echo ' step = 1 : compile the 3 executables (cpl,ocn,atm)' |
26 |
echo ' step = 2 : copy input files and dir(s)' |
27 |
echo " step = 3 : run with $Np mpi processes" |
28 |
echo ' step = 4 : check the results' |
29 |
echo ' step = 5 : remove output files in rank_0,1,2 dir.' |
30 |
exit |
31 |
fi |
32 |
kpr=$1 |
33 |
dir=`pwd` |
34 |
|
35 |
#============================================================================ |
36 |
|
37 |
if test $kpr = 0 |
38 |
then |
39 |
rm -f pr_group std_outp comp_res.{ocn,atm,land,sice} |
40 |
rm -f build_???/TTT.*make.* build_???/TTT.mkdepend.* |
41 |
/bin/rm -r -f rank_0 rank_1 rank_2 |
42 |
if test -f build_cpl/Makefile ; then cd build_cpl ; make CLEAN ; cd .. ; fi |
43 |
if test -f build_ocn/Makefile ; then cd build_ocn ; make CLEAN ; cd .. ; fi |
44 |
if test -f build_atm/Makefile ; then cd build_atm ; make CLEAN ; cd .. ; fi |
45 |
fi |
46 |
if test $kpr = 5 |
47 |
then |
48 |
echo 'remove output files in rank_0,1,2 dir.' |
49 |
rm -f pr_group std_outp comp_res.{ocn,atm,land,sice} |
50 |
if test -d rank_0 ; then cd rank_0 ; rm -f Coupler.0000.clog ; cd .. ; fi |
51 |
if test -d rank_1 |
52 |
then cd rank_1 ; rm -f *.data *.meta STD???.0000 UV-*.0001.clog ; cd .. ; fi |
53 |
if test -d rank_2 |
54 |
then cd rank_2 ; rm -f *.data *.meta STD???.0000 UV-*.0001.clog ; cd .. ; fi |
55 |
fi |
56 |
|
57 |
if test $kpr = 1 |
58 |
then |
59 |
|
60 |
#- choice of the optfile: take a local one in dir verification with sufix '+mpi' |
61 |
nbOpF=`ls ../linux_* | grep '+mpi' 2> /dev/null | wc -l` |
62 |
if test $nbOpF = 1 |
63 |
then |
64 |
OPTFILE=`ls ../linux_* | grep '+mpi'` |
65 |
zz=`grep '^FC=' $OPTFILE` |
66 |
echo " Using optfile: $OPTFILE (compiler=$zz) $MTH" |
67 |
else |
68 |
echo "Pb in finding optfile: found $nbOpF :" |
69 |
ls ../linux_* | grep '+mpi' ; exit |
70 |
fi |
71 |
zz=`echo $OPTFILE | grep -c '^\/'` |
72 |
if test $zz = 0 ; then OPTFILE="../$OPTFILE" ; fi |
73 |
#--- |
74 |
echo '==== compile coupler:' |
75 |
cd build_cpl |
76 |
echo ' --- genmake2 (cpl):' |
77 |
../../../tools/genmake2 -of $OPTFILE -mpi $GMKopt > TTT.genmake.$$ |
78 |
tail -5 TTT.genmake.$$ |
79 |
echo ' --- make depend (cpl):' |
80 |
make depend > TTT.mkdepend.$$ |
81 |
tail -5 TTT.mkdepend.$$ |
82 |
echo ' --- make (cpl):' |
83 |
make > TTT.make.$$ 2>&1 |
84 |
tail -10 TTT.make.$$ |
85 |
echo ' ' ; cd $dir |
86 |
|
87 |
echo '==== compile OGCM:' |
88 |
cd build_ocn |
89 |
echo ' --- genmake2 (ocn):' |
90 |
../../../tools/genmake2 -of $OPTFILE -mpi $MTHo $GMKopt > TTT.genmake.$$ |
91 |
tail -5 TTT.genmake.$$ |
92 |
echo ' --- make depend (ocn):' |
93 |
make depend > TTT.mkdepend.$$ |
94 |
tail -10 TTT.mkdepend.$$ |
95 |
echo ' --- make (ocn):' |
96 |
make > TTT.make.$$ 2>&1 |
97 |
tail -10 TTT.make.$$ |
98 |
echo ' ' ; cd $dir |
99 |
|
100 |
echo '==== compile AGCM:' |
101 |
cd build_atm |
102 |
echo ' --- genmake2 (atm):' |
103 |
../../../tools/genmake2 -of $OPTFILE -mpi $MTHa $GMKopt > TTT.genmake.$$ |
104 |
tail -5 TTT.genmake.$$ |
105 |
echo ' --- make depend (atm):' |
106 |
make depend > TTT.mkdepend.$$ |
107 |
tail -10 TTT.mkdepend.$$ |
108 |
echo ' --- make (atm):' |
109 |
make > TTT.make.$$ 2>&1 |
110 |
tail -10 TTT.make.$$ |
111 |
echo ' ' ; cd $dir |
112 |
|
113 |
ls -l build_???/mitgcmuv |
114 |
|
115 |
fi |
116 |
|
117 |
if test $kpr = 2 |
118 |
then |
119 |
/bin/rm -r -f rank_0 rank_1 rank_2 |
120 |
echo 'CP dir:' input_cpl '->' rank_0 |
121 |
cp -p -r input_cpl rank_0 |
122 |
|
123 |
echo 'CP dir:' input_ocn '->' rank_1 |
124 |
cp -p -r input_ocn rank_1 |
125 |
cd rank_1 |
126 |
./prepare_run |
127 |
if test "x$MTHo" != x ; then |
128 |
echo " MTH run: mv -f eedata.mth eedata" |
129 |
mv -f eedata.mth eedata |
130 |
fi |
131 |
cd $dir |
132 |
|
133 |
echo 'CP dir:' input_atm '->' rank_2 |
134 |
cp -p -r input_atm rank_2 |
135 |
cd rank_2 |
136 |
./prepare_run |
137 |
if test "x$MTHa" != x ; then |
138 |
echo " MTH run: mv -f eedata.mth eedata" |
139 |
mv -f eedata.mth eedata |
140 |
fi |
141 |
cd $dir |
142 |
|
143 |
fi |
144 |
|
145 |
if test $kpr = 3 |
146 |
then |
147 |
ROOTDIR=$dir |
148 |
rm -f rank_?/pickup*.ckptA.00?.00?.??ta |
149 |
echo $ROOTDIR |
150 |
tmpfil=TTT.$$ |
151 |
|
152 |
rm -f pr_group ; touch pr_group |
153 |
nc=0; xx=`hostname` |
154 |
for dd1 in cpl ocn atm |
155 |
do |
156 |
echo $xx $nc $dir/build_$dd1/mitgcmuv >> pr_group |
157 |
nc=1 |
158 |
done |
159 |
|
160 |
cd $ROOTDIR |
161 |
if test "x$MTH" != x ; then |
162 |
export OMP_NUM_THREADS=2 ; export KMP_STACKSIZE=400m |
163 |
if test "x$MTHo" != x ; then |
164 |
echo -n " run OCN ($MTHo) with $OMP_NUM_THREADS threads ;" |
165 |
fi |
166 |
if test "x$MTHa" != x ; then |
167 |
echo -n " run ATM ($MTHa) with $OMP_NUM_THREADS threads ;" |
168 |
fi |
169 |
echo "" |
170 |
fi |
171 |
# /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 |
172 |
#- on danton (mpich-1): |
173 |
mpirun -p4pg pr_group -v ./build_cpl/mitgcmuv > std_outp 2>&1 |
174 |
#- on beagle: |
175 |
#mpirun -pg pr_group -v ./build_cpl/mitgcmuv > std_outp 2>&1 |
176 |
tail -20 std_outp |
177 |
ls -l rank_?/pickup*.ckptA.001.001.data |
178 |
|
179 |
fi |
180 |
|
181 |
if test $kpr = 4 |
182 |
then |
183 |
|
184 |
if test -f rank_1/STDOUT.0000 |
185 |
then echo '==> check Ocean output:' |
186 |
/home/jmc/bin/comp_res rank_1/STDOUT.0000 results/ocnSTDOUT.0000 |
187 |
mv -f comp_res.log comp_res.ocn |
188 |
echo ' ' |
189 |
else echo 'No Ocean output file in rank_1' ; fi |
190 |
|
191 |
if test -f rank_2/STDOUT.0000 |
192 |
then |
193 |
echo '==> check Atmos output:' |
194 |
/home/jmc/bin/comp_res rank_2/STDOUT.0000 results/atmSTDOUT.0000 |
195 |
mv -f comp_res.log comp_res.atm |
196 |
echo '==> check Land output:' |
197 |
/home/jmc/bin/comp_res rank_2/STDOUT.0000 results/atmSTDOUT.0000 L |
198 |
mv -f comp_res.log comp_res.land |
199 |
echo '==> check thSIce output:' |
200 |
/home/jmc/bin/comp_res rank_2/STDOUT.0000 results/atmSTDOUT.0000 I |
201 |
mv -f comp_res.log comp_res.sice |
202 |
echo ' ' |
203 |
else echo 'No Atmos output file in rank_2' ; fi |
204 |
|
205 |
fi |
206 |
|
207 |
exit 0 |