/[MITgcm]/MITgcm_contrib/jmc_script/extract_StD
ViewVC logotype

Contents of /MITgcm_contrib/jmc_script/extract_StD

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


Revision 1.1 - (show annotations) (download)
Sat Jan 7 16:23:29 2006 UTC (18 years, 3 months ago) by jmc
Branch: MAIN
add a short script (extract_StD) to split the ASCII Diagnostics-Stats output
   file into separated files (one per field) that are easy to read/load.

1 #!/bin/sh
2 case $# in
3 0|1) echo "Usage: `basename $0` input_fil outp_sufix [field_name_list]"
4 echo " from ASCII Diagnostics-Stats file (=input_fil) and for each field"
5 echo " (in field_name_list), extract the associated numerical values and"
6 echo " put them in a separated file: stDiag_{VAR}.{outp_sufix}"
7 exit 9 ;;
8 2) listV='T' ;;
9 *) ;;
10 esac
11
12 inpFil=$1
13 #outFil=$2
14 sufx=$2
15 tmpFil='TTT.'$$
16 if test $# = '2'
17 then listV='T'
18 else
19 shift; shift; listV=$*
20 fi
21 echo $inpFil $sufx $listV $tmpFil
22 grep '^# Fields ' $inpFil
23
24 for vv in $listV
25 do
26 outFil='stDiag_'$vv.$sufx
27 case $vv in
28 'Eta') var='ETAN';;
29 'Et2') var='ETANSQ';;
30 'T') var='THETA';;
31 'S') var='SALT' ;;
32 'U') var='UVEL' ;;
33 'V') var='VVEL' ;;
34 'W') var='WVEL' ;;
35 'U2') var='UVELSQ' ;;
36 'V2') var='VVELSQ' ;;
37 *) var=$vv ;;
38 esac
39 #echo 'grep -m 1' "^ field : ${var} " $inpFil
40 #grep -m 1 "^ field : ${var} " $inpFil
41 nLev=`grep -m 1 "^ field : ${var} " $inpFil | sed 's/.*=//'`
42 if test ${nLev}'xx' = 'xx'
43 then
44 echo 'WARNING variable:' $var 'not found in file' $inpFil
45 else
46 echo 'extract variable:' $var ', outFil=' $outFil
47 #echo 'nLev=' $nLev
48 #- echo set of sed instruction to file sedFil :
49 sedFil=$tmpFil.$vv
50 rm -f $sedFil
51 echo "/^ field : $var /{" > $sedFil
52 if test $nLev = 1 ; then k=0 ; else k=-1 ; fi
53 while [ $k -le $nLev ]
54 do
55 echo "N" >> $sedFil
56 k=`expr $k + 1`
57 done
58 echo "p" >> $sedFil
59 echo "}" >> $sedFil
60 #- extract records of variable "var" using sed command & sedFil
61 sed -n -f $sedFil $inpFil > $tmpFil
62 head -1 $tmpFil
63 sed '/^ k /d' $tmpFil | sed '/^ field /d' > $outFil
64 rm -f $sedFil $tmpFil
65 fi
66 done
67 exit

  ViewVC Help
Powered by ViewVC 1.1.22