#!/bin/sh # $Header: /home/ubuntu/mnt/e9_copy/MITgcm_contrib/jmc_script/tst_2+2_cpl,v 1.5 2007/11/26 23:46:21 jmc Exp $ # $Name: $ rnp_loc() { # rnp_loc arg_1 arg_2 # rename files with prefix = 'arg_1' to files with prefix = 'arg_2' echo 'rnp_loc:' $1 $2 # rnp -s $1 $2 listY=`ls -1 $1*` for yy in $listY do zz=`echo $yy | sed "s/^$1/$2/"` mv $yy $zz done } dif_tiles() { # dif_data_loc dd1 dd2 file # for all tiles ==> do diff dd1/file dd2/file' dd1=$1 ; dd2=$2 ; zz=$3 chkmeta='Y' listY=`(cd $dd1 ; ls $zz.*.data | sed "s/$zz\.//" | sed "s/\.data//")` echo '--> file='$zz', listY='$listY for yy in $listY do echo diff $dd1/$zz.$yy.data $dd2 diff $dd1/$zz.$yy.data $dd2 out=$? if test $out != 0 then echo 'Diff outp=' $out ' ==> stop' exit ; fi if test $chkmeta = 'Y' then echo diff $dd1/$zz.$yy.meta $dd2 diff $dd1/$zz.$yy.meta $dd2 out=$? if test $out != 0 then echo 'Diff outp=' $out ' ==> stop' exit ; fi fi done } if test -f input_ocn/data.tst then noc0=`sed -n 's/nIter0=//p' input_ocn/data.tst | sed 's/,//g' | sed 's/ //g'` Dbl=`sed -n 's/nTimeSteps=//p' input_ocn/data.tst | sed 's/,//g'` NiOc=`expr $Dbl / 2` Nit=$NiOc else echo " file: 'input_ocn/data.tst' not found" NiOc=0 ; Nit=2 fi if test -f input_atm/data.tst then nat0=`sed -n 's/nIter0=//p' input_atm/data.tst | sed 's/,//g' | sed 's/ //g'` Dbl=`sed -n 's/nTimeSteps=//p' input_atm/data.tst | sed 's/,//g'` NiAt=`expr $Dbl / 2` else echo " file: 'input_atm/data.tst' not found" NiAt=0 fi case $# in 1) ;; *) echo "Usage: `basename $0` flag" echo " Check restart of coupled set-up: compare 1 run of 2 x $Nit it long" echo " with 2 consecutive runs of $Nit it long each" echo " where: flag = 0 -> prepare for 1rst run" echo " flag = 1 -> move res. after 1rst run & prepare for 2nd" echo " flag = 2 -> move res. after 2nd run & prepare for 3rd" echo " flag = 3 -> move res. after 3rd run" echo " flag = 4 -> compare Ocean results" echo " flag = 5 -> compare Atmos results" echo " flag = 6 -> diff pickup files" exit ;; esac if test $NiAt = 0 -o $NiOc = 0 then echo " needs 2 data files: 'input_ocn/data.tst' & 'input_atm/data.tst'" echo " (corresponding to 1rst run) to continue" exit fi ksel=$1 #make sure that local dir & ~jmc/bin is in the path: #export PATH=${PATH}:. Nit=$NiOc Dbl=`expr $Nit + $Nit` noc1=`expr $noc0 + $Nit` noc2=`expr $noc0 + $Dbl` noc0c=`printf "%10.10i\n" $noc0` noc1c=`printf "%10.10i\n" $noc1` noc2c=`printf "%10.10i\n" $noc2` echo 'Oce (rank_1):' $noc0 $noc1 $noc2 echo $noc0c $noc1c $noc2c Nit=$NiAt Dbl=`expr $Nit + $Nit` nat1=`expr $nat0 + $Nit` nat2=`expr $nat0 + $Dbl` nat0c=`printf "%10.10i\n" $nat0` nat1c=`printf "%10.10i\n" $nat1` nat2c=`printf "%10.10i\n" $nat2` echo 'Atm (rank_2):' $nat0 $nat1 $nat2 echo $nat0c $nat1c $nat2c listOc="pickup pickup_cpl" listAt="pickup pickup_cpl pickup_ic pickup_land" #- dir where to put the results : dir1=res_2it dir2=res_1iA dir3=res_1iB #-- after a run, rename pickup file to restart if test $ksel = 0 then echo ' ' cd rank_1 for xx in $listOc do rnp_loc $xx.ckptA $xx.$noc0c done cd ../rank_2 for xx in $listAt do rnp_loc $xx.ckptA $xx.$nat0c done cd .. #-- prepare for running Dbl echo ' prepare for running Dbl:' Dbl=`expr $NiOc + $NiOc` sed "1 s/[0-9]*/$Dbl/" input_cpl/data > rank_0/data cp -p input_ocn/data.tst rank_1/data cp -p input_atm/data.tst rank_2/data echo 'rank_0/data:' `head -1 rank_0/data` egrep 'nIter0|nTimeSteps' rank_?/data fi #-- after running Dbl: if test $ksel = 1 then rm -rf $dir1 mkdir $dir1 echo ' ' ; echo 'move STDOUT to' $dir1 mv rank_1/STDOUT* $dir1/ocnSTDOUT.2it mv rank_2/STDOUT* $dir1/atmSTDOUT.2it mkdir $dir1/ocn cd rank_1 for xx in $listOc do rnp_loc $xx.ckptA $xx.$noc2c done echo 'move pickups to' $dir1/ocn mv pickup*.$noc2c.* ../$dir1/ocn cd .. mkdir $dir1/atm cd rank_2 for xx in $listAt do rnp_loc $xx.ckptA $xx.$nat2c done echo 'move pickups to' $dir1/atm mv pickup*.$nat2c.* ../$dir1/atm cd .. #-- prepare for running 1iA echo ' prepare for running 1iA:' Nit=$NiOc Dbl=`expr $Nit + $Nit` sed "1 s/[0-9]*/$Nit/" input_cpl/data > rank_0/data sed "s/^ nTimeSteps=$Dbl/ nTimeSteps=$Nit/g" input_ocn/data.tst > rank_1/data Nit=$NiAt Dbl=`expr $Nit + $Nit` sed "s/^ nTimeSteps=$Dbl/ nTimeSteps=$Nit/g" input_atm/data.tst > rank_2/data echo 'rank_0/data:' `head -1 rank_0/data` egrep 'nIter0|nTimeSteps' rank_?/data fi #-- after running 1iA if test $ksel = 2 then rm -rf $dir2 mkdir $dir2 echo ' ' ; echo 'move STDOUT to' $dir2 mv rank_1/STDOUT* $dir2/ocnSTDOUT.1iA mv rank_2/STDOUT* $dir2/atmSTDOUT.1iA mkdir $dir2/ocn cd rank_1 for xx in $listOc do rnp_loc $xx.ckptA $xx.$noc1c done echo 'move pickups to' $dir2/ocn mv pickup*.$noc1c.* ../$dir2/ocn cd .. mkdir $dir2/atm cd rank_2 for xx in $listAt do rnp_loc $xx.ckptA $xx.$nat1c done echo 'move pickups to' $dir2/atm mv pickup*.$nat1c.* ../$dir2/atm cd .. #-- prepare for running 1iB echo ' prepare for running 1iB:' cd rank_1 sed "s/^ nIter0=$noc0/ nIter0=$noc1/g" data > data.tmp mv -f data.tmp data ln -s ../$dir2/ocn/* . cd ../rank_2 sed "s/^ nIter0=$nat0/ nIter0=$nat1/g" data > data.tmp mv -f data.tmp data ln -s ../$dir2/atm/* . cd .. echo 'rank_0/data:' `head -1 rank_0/data` egrep 'nIter0|nTimeSteps' rank_?/data fi #-- after running 1iB if test $ksel = 3 then rm -rf $dir3 mkdir $dir3 echo ' ' ; echo 'move STDOUT to' $dir3 mv rank_1/STDOUT* $dir3/ocnSTDOUT.1iB mv rank_2/STDOUT* $dir3/atmSTDOUT.1iB mkdir $dir3/ocn cd rank_1 for xx in $listOc do rnp_loc $xx.ckptA $xx.$noc2c done echo 'move pickups to' $dir3/ocn mv pickup*.$noc2c.* ../$dir3/ocn rm -f pickup*.$noc1c.* cd .. mkdir $dir3/atm cd rank_2 for xx in $listAt do rnp_loc $xx.ckptA $xx.$nat2c done echo 'move pickups to' $dir3/atm mv pickup*.$nat2c.* ../$dir3/atm rm -f pickup*.$nat1c.* cd .. echo 'restore std data files' cp -p input_cpl/data rank_0 cp -p input_ocn/data rank_1 cp -p input_atm/data rank_2 fi #-- compare output: if test $ksel = 4 then rm -f ocn.txt echo ' run 2it: ---------- ' > tmp1.txt grep "cg2d_init_res" $dir1/ocnSTDOUT.2it \ | sed 's/.* cg2d_init_res =//' >> tmp1.txt Nit=`expr $NiOc + 2` sed "$Nit i \ ... 2it continue ..." tmp1.txt > tmp2.txt rm -f tmp1.txt echo ' run 1iA: ---------- ' > tmp1.txt grep "cg2d_init_res" $dir2/ocnSTDOUT.1iA \ | sed 's/.* cg2d_init_res =//' >> tmp1.txt echo ' run 1iB: ---------- ' >> tmp1.txt grep "cg2d_init_res" $dir3/ocnSTDOUT.1iB \ | sed 's/.* cg2d_init_res =//' >> tmp1.txt nl tmp1.txt > tmp1.ttt nl tmp2.txt > tmp2.ttt join tmp1.ttt tmp2.ttt | sed 's/[0-9]*//' > ocn.txt rm -f tmp1.ttt tmp2.ttt tmp1.txt tmp2.txt echo ' ' ; echo '-- compare cg2d_init_res (Ocean):' cat ocn.txt exit fi if test $ksel = 5 then rm -f atm.txt echo ' run 2it: ---------- ' > tmp1.txt grep "cg2d_init_res" $dir1/atmSTDOUT.2it \ | sed 's/.* cg2d_init_res =//' >> tmp1.txt Nit=`expr $NiAt + 2` sed "$Nit i \ ... 2it continue ..." tmp1.txt > tmp2.txt rm -f tmp1.txt echo ' run 1iA: ---------- ' > tmp1.txt grep "cg2d_init_res" $dir2/atmSTDOUT.1iA \ | sed 's/.* cg2d_init_res =//' >> tmp1.txt echo ' run 1iB: ---------- ' >> tmp1.txt grep "cg2d_init_res" $dir3/atmSTDOUT.1iB \ | sed 's/.* cg2d_init_res =//' >> tmp1.txt nl tmp1.txt > tmp1.ttt nl tmp2.txt > tmp2.ttt join tmp1.ttt tmp2.ttt | sed 's/[0-9]*//' > atm.txt rm -f tmp1.ttt tmp2.ttt tmp1.txt tmp2.txt echo ' ' ; echo '-- compare cg2d_init_res (Atmos):' cat atm.txt exit fi #- compare pickup file: if test $ksel = 6 then echo ' ' ; echo '=== compare Ocn pickups: ==============' for xx in $listOc do dif_tiles $dir1/ocn $dir3/ocn $xx.$noc2c done echo ' ' ; echo '=== compare Atm pickups: ==============' for xx in $listAt do dif_tiles $dir1/atm $dir3/atm $xx.$nat2c done exit fi