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

Diff of /MITgcm_contrib/jmc_script/extract_StD

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

revision 1.3 by jmc, Thu May 29 23:47:13 2008 UTC revision 1.4 by jmc, Tue Feb 11 22:17:43 2020 UTC
# Line 1  Line 1 
1  #!/bin/sh  #! /usr/bin/env bash
2    
3  # $Header$  # $Header$
4  # $Name$  # $Name$
5    
6  add=0 ; mut=0 ;  add=0 ; mut=0 ;
7  if [ $# -ge 3 ]  if [ $# -ge 3 ]
8  then  then
9   if test $1 = '-a' ; then add=1; shift; fi   if test $1 = '-a' ; then add=1; shift; fi
10   if test $1 = '-s' ; then mut=1; shift; fi   if test $1 = '-s' ; then mut=1; shift; fi
# Line 36  then listV=`sed -n '/^# Fields /s/# Fiel Line 36  then listV=`sed -n '/^# Fields /s/# Fiel
36  else  else
37   shift; shift; shift; listV=$*   shift; shift; shift; listV=$*
38  fi  fi
39  if test $mut = 0 ; then  if test $mut = 0 ; then
40   grep '^# Fields ' $inpFil   grep '^# Fields ' $inpFil
41   echo 'selected var:' $listV   echo 'selected var:' $listV
42  #echo 'sufx, tmpFil:' $sufx $tmpFil  #echo 'sufx, tmpFil:' $sufx $tmpFil
# Line 87  do Line 87  do
87    then flag=0    then flag=0
88      outFil=${prfx}'_head'.$sufx      outFil=${prfx}'_head'.$sufx
89      nLin=`sed -n "/^# end of header/=" $inpFil`      nLin=`sed -n "/^# end of header/=" $inpFil`
90      head -$nLin $inpFil > $tmpFil      head -$nLin $inpFil > $tmpFil
91      if test -f $outFil -a $add = 0 ; then rm -f $outFil ; fi      if test -f $outFil -a $add = 0 ; then rm -f $outFil ; fi
92      if test -f $outFil      if test -f $outFil
93      then      then
# Line 121  do Line 121  do
121    echo "/^ field : $var /{" > $sedFil    echo "/^ field : $var /{" > $sedFil
122    if test $nLev = 1 ; then k=0 ; else k=-1 ; fi    if test $nLev = 1 ; then k=0 ; else k=-1 ; fi
123    while [ $k -le $nLev ]    while [ $k -le $nLev ]
124    do    do
125     echo "N" >> $sedFil     echo "N" >> $sedFil
126     k=`expr $k + 1`     k=`expr $k + 1`
127    done    done
# Line 132  do Line 132  do
132    if test $mut = 0 ; then head -1 $tmpFil ; fi    if test $mut = 0 ; then head -1 $tmpFil ; fi
133    if test -f $outFil -a $add = 0 ; then rm -f $outFil ; fi    if test -f $outFil -a $add = 0 ; then rm -f $outFil ; fi
134    touch $outFil    touch $outFil
135    sed '/^ k /d' $tmpFil | sed '/^ field /d' >> $outFil    sed '/^ k /d' $tmpFil | sed '/^ field /d' >> $outFil
136    rm -f $sedFil $tmpFil    rm -f $sedFil $tmpFil
137   fi   fi
138  done  done

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.22