/[MITgcm]/MITgcm_contrib/jmc_script/tst_2+2_cpl
ViewVC logotype

Diff of /MITgcm_contrib/jmc_script/tst_2+2_cpl

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

revision 1.5 by jmc, Mon Nov 26 23:46:21 2007 UTC revision 1.8 by jmc, Fri Oct 22 03:10:56 2010 UTC
# Line 1  Line 1 
1  #!/bin/sh  #! /usr/bin/env bash
2    
3  # $Header$  # $Header$
4  # $Name$  # $Name$
# Line 65  else Line 65  else
65   NiAt=0   NiAt=0
66  fi  fi
67    
68  case $# in  #- parse options:
69    1) ;;  CMD='run_cpl_test'
70     *) echo "Usage: `basename $0` flag"  MTH=
71        echo " Check restart of coupled set-up: compare 1 run of 2 x $Nit it long"  argList=$*
72        echo "                       with 2 consecutive runs of $Nit it long each"  for xx in $argList
73        echo " where: flag = 0 -> prepare for 1rst run"  do
74        echo "        flag = 1 -> move res. after 1rst run & prepare for 2nd"   if test $xx = '-mth' ; then MTH=$xx ; shift ; continue ; fi
75        echo "        flag = 2 -> move res. after 2nd  run & prepare for 3rd"   if test -x ${CMD}_$xx ; then CMD="${CMD}_$xx" ; shift ; continue ; fi
76        echo "        flag = 3 -> move res. after 3rd  run"  done
77        echo "        flag = 4 -> compare Ocean results"  
78        echo "        flag = 5 -> compare Atmos results"  if [ $# -ne 1 ]
79        echo "        flag = 6 -> diff pickup files"  then
80        exit ;;     echo "Usage: `basename $0` [opt] flag"
81  esac     echo " Check restart of coupled set-up: compare 1 run of 2 x $Nit it long"
82       echo "                       with 2 consecutive runs of $Nit it long each"
83       echo "opt = -mth : run script '$CMD' with option '-mth'"
84       echo "opt = sufx : run script 'run_cpl_test_{sufx}'"
85       echo " where: flag = 0  -> prepare for 1rst run"
86       echo "        flag = r1 -> do 1rst run and step 1"
87       echo "        flag =  1 -> move res. after 1rst run & prepare for 2nd"
88       echo "        flag = r2 -> do 2nd  run and step 2"
89       echo "        flag =  2 -> move res. after 2nd  run & prepare for 3rd"
90       echo "        flag = r3 -> do 3rd  run and step 3"
91       echo "        flag =  3 -> move res. after 3rd  run"
92       echo "        flag=(r)N+ , N=1,2,3 => do steps (+run) from: (r)N to 3"
93       echo "        flag = 4  -> compare Ocean results"
94       echo "        flag = 5  -> compare Atmos results"
95       echo "        flag = 6  -> diff pickup files"
96       echo "        flag = 7  -> clean-up output files"
97       exit
98    fi
99  if test $NiAt = 0 -o $NiOc = 0  if test $NiAt = 0 -o $NiOc = 0
100  then  then
101      echo " needs 2 data files: 'input_ocn/data.tst' & 'input_atm/data.tst'"      echo " needs 2 data files: 'input_ocn/data.tst' & 'input_atm/data.tst'"
102      echo "  (corresponding to 1rst run) to continue"      echo "  (corresponding to 1rst run) to continue"
103    exit    exit
104  fi  fi
105  ksel=$1  arg1=$1
106    xx=`echo $arg1 | sed 's/\+$//'`
107    if test $xx != $arg1
108    then kUp=`echo $xx | sed 's/^r//'` ; arg1=$xx
109    else kUp=9 ; fi
110    xx=`echo $arg1 | sed 's/^r//'`
111    if test $xx != $arg1 ; then doRun=1 ; arg1=$xx ; else doRun=0 ; fi
112    ksel=$arg1
113    
114    CMD="./${CMD} $MTH 3"
115    echo " doRun='$doRun' ; ksel='$ksel' ; kUp='$kUp' ; command='$CMD'"
116    
117  #make sure that local dir & ~jmc/bin is in the path:  #make sure that local dir & ~jmc/bin is in the path:
118  #export PATH=${PATH}:.  #export PATH=${PATH}:.
# Line 97  noc2=`expr $noc0 + $Dbl` Line 124  noc2=`expr $noc0 + $Dbl`
124  noc0c=`printf "%10.10i\n" $noc0`  noc0c=`printf "%10.10i\n" $noc0`
125  noc1c=`printf "%10.10i\n" $noc1`  noc1c=`printf "%10.10i\n" $noc1`
126  noc2c=`printf "%10.10i\n" $noc2`  noc2c=`printf "%10.10i\n" $noc2`
127  echo 'Oce (rank_1):' $noc0  $noc1  $noc2  echo ' Oce (rank_1):' $noc0  $noc1  $noc2
128  echo $noc0c $noc1c $noc2c  echo ' ' $noc0c $noc1c $noc2c
129    
130  Nit=$NiAt  Nit=$NiAt
131  Dbl=`expr $Nit + $Nit`  Dbl=`expr $Nit + $Nit`
# Line 107  nat2=`expr $nat0 + $Dbl` Line 134  nat2=`expr $nat0 + $Dbl`
134  nat0c=`printf "%10.10i\n" $nat0`  nat0c=`printf "%10.10i\n" $nat0`
135  nat1c=`printf "%10.10i\n" $nat1`  nat1c=`printf "%10.10i\n" $nat1`
136  nat2c=`printf "%10.10i\n" $nat2`  nat2c=`printf "%10.10i\n" $nat2`
137  echo 'Atm (rank_2):' $nat0  $nat1  $nat2  echo ' Atm (rank_2):' $nat0  $nat1  $nat2
138  echo $nat0c $nat1c $nat2c  echo ' ' $nat0c $nat1c $nat2c
139    
140  listOc="pickup pickup_cpl"  listOc="pickup"
141  listAt="pickup pickup_cpl pickup_ic pickup_land"  listAt="pickup pickup_cpl pickup_ic pickup_land"
142    
143  #- dir where to put the results :  #- dir where to put the results :
# Line 132  then Line 159  then
159   done   done
160   cd ..   cd ..
161  #-- prepare for running Dbl  #-- prepare for running Dbl
162   echo ' prepare for running Dbl:'   echo '=> prepare for running Dbl:'
163   Dbl=`expr $NiOc + $NiOc`   Dbl=`expr $NiOc + $NiOc`
164   sed "1 s/[0-9]*/$Dbl/" input_cpl/data > rank_0/data   sed "1 s/[0-9]*/$Dbl/" input_cpl/data > rank_0/data
165   cp -p input_ocn/data.tst rank_1/data   cp -p input_ocn/data.tst rank_1/data
# Line 141  then Line 168  then
168   egrep 'nIter0|nTimeSteps' rank_?/data   egrep 'nIter0|nTimeSteps' rank_?/data
169  fi  fi
170    
171  #-- after running Dbl:  #-- run & post-process Dbl:
172  if test $ksel = 1  if [ $ksel -eq 1 -o $kUp -le 1 ]
173  then  then
174     echo ' '
175    #-- run coupled test (Dbl):
176     if [ $doRun -eq 1 -o $kUp -lt 1 ]
177     then
178       echo "=> run (Dbl): $CMD"
179       $CMD
180     fi
181    #-- after running Dbl:
182   rm -rf $dir1   rm -rf $dir1
183   mkdir $dir1   mkdir $dir1
184   echo ' ' ; echo 'move STDOUT to' $dir1   echo '=> move STDOUT to' $dir1
185   mv rank_1/STDOUT* $dir1/ocnSTDOUT.2it   mv rank_1/STDOUT* $dir1/ocnSTDOUT.2it
186   mv rank_2/STDOUT* $dir1/atmSTDOUT.2it   mv rank_2/STDOUT* $dir1/atmSTDOUT.2it
187    
# Line 171  then Line 206  then
206   cd ..   cd ..
207    
208  #-- prepare for running 1iA  #-- prepare for running 1iA
209   echo ' prepare for running 1iA:'   echo '=> prepare for running 1iA:'
210   Nit=$NiOc   Nit=$NiOc
211   Dbl=`expr $Nit + $Nit`   Dbl=`expr $Nit + $Nit`
212   sed "1 s/[0-9]*/$Nit/" input_cpl/data > rank_0/data   sed "1 s/[0-9]*/$Nit/" input_cpl/data > rank_0/data
# Line 183  then Line 218  then
218   egrep 'nIter0|nTimeSteps' rank_?/data   egrep 'nIter0|nTimeSteps' rank_?/data
219  fi  fi
220    
221  #-- after running 1iA  #-- run & post-process 1iA:
222  if test $ksel = 2  if [ $ksel -eq 2 -o $kUp -le 2 ]
223  then  then
224     echo ' '
225    #-- run coupled test (1iA):
226     if [ $doRun -eq 1 -o $kUp -lt 2 ]
227     then
228       echo "=> run (1iA): $CMD"
229       $CMD
230     fi
231    #-- after running 1iA
232   rm -rf $dir2   rm -rf $dir2
233   mkdir $dir2   mkdir $dir2
234   echo ' ' ; echo 'move STDOUT to' $dir2   echo '=> move STDOUT to' $dir2
235   mv rank_1/STDOUT* $dir2/ocnSTDOUT.1iA   mv rank_1/STDOUT* $dir2/ocnSTDOUT.1iA
236   mv rank_2/STDOUT* $dir2/atmSTDOUT.1iA   mv rank_2/STDOUT* $dir2/atmSTDOUT.1iA
237    
# Line 213  then Line 256  then
256   cd ..   cd ..
257    
258  #-- prepare for running 1iB  #-- prepare for running 1iB
259   echo ' prepare for running 1iB:'   echo '=> prepare for running 1iB:'
260   cd rank_1   cd rank_1
261   sed "s/^ nIter0=$noc0/ nIter0=$noc1/g" data > data.tmp   sed "s/^ nIter0=$noc0/ nIter0=$noc1/g" data > data.tmp
262   mv -f data.tmp data   mv -f data.tmp data
# Line 227  then Line 270  then
270   egrep 'nIter0|nTimeSteps' rank_?/data   egrep 'nIter0|nTimeSteps' rank_?/data
271  fi  fi
272    
273  #-- after running 1iB  #-- run & post-process 1iB:
274  if test $ksel = 3  if [ $ksel -eq 3 -o $kUp -le 3 ]
275  then  then
276     echo ' '
277    #-- run coupled test (1iB):
278     if [ $doRun -eq 1 -o $kUp -lt 3 ]
279     then
280       echo "=> run (1iB): $CMD"
281       $CMD
282     fi
283    #-- after running 1iB
284   rm -rf $dir3   rm -rf $dir3
285   mkdir $dir3   mkdir $dir3
286   echo ' ' ; echo 'move STDOUT to' $dir3   echo '=> move STDOUT to' $dir3
287   mv rank_1/STDOUT* $dir3/ocnSTDOUT.1iB   mv rank_1/STDOUT* $dir3/ocnSTDOUT.1iB
288   mv rank_2/STDOUT* $dir3/atmSTDOUT.1iB   mv rank_2/STDOUT* $dir3/atmSTDOUT.1iB
289    
# Line 255  then Line 306  then
306   mv pickup*.$nat2c.* ../$dir3/atm   mv pickup*.$nat2c.* ../$dir3/atm
307   rm -f pickup*.$nat1c.*   rm -f pickup*.$nat1c.*
308   cd ..   cd ..
309   echo 'restore std data files'   echo '=> restore std data files'
310   cp -p input_cpl/data rank_0   cp -p input_cpl/data rank_0
311   cp -p input_ocn/data rank_1   cp -p input_ocn/data rank_1
312   cp -p input_atm/data rank_2   cp -p input_atm/data rank_2
# Line 325  then Line 376  then
376   done   done
377   exit   exit
378  fi  fi
379    
380    #- clean-up and reset:
381    if test $ksel = 7
382    then
383     echo "== clean-up and reset :"
384    # echo '--> remove pickup*.'$noc0c'* sym-links:'
385    # cd rank_1
386    #   listS=`find . ! -name . -prune -type l -name 'pickup*.'${noc0c}'*'`
387    #   if [ $prt -ge 2 ] ; then echo ' in rank_1: rm' $listS ; fi
388    #   rm -f $listS
389    # echo '--> remove pickup*.'$nat0c'* sym-links:'
390    # cd ../rank_2
391    #   listS=`find . ! -name . -prune -type l -name 'pickup*.'${nat0c}'*'`
392    #   if [ $prt -ge 2 ] ; then echo ' in rank_2: rm' $listS ; fi
393    #   rm -f $listS
394    # cd ..
395     echo '--> remove output dir and output files:'
396     echo ' rm -rf' $dir1 $dir2 $dir3
397     rm -rf $dir1 $dir2 $dir3
398     rm -f atm.txt ocn.txt
399    #- move back files from temp_tst dir:
400    #if test -d $tmpDir ; then
401    # echo "--> move back files from 'temp_tst' dir."
402    # cd $tmpDir ; mv -f * .. ; cd ..
403    # rmdir $tmpDir
404    #fi
405     exit
406    fi

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.22