(file) Return to doinvert CVS log (file) (dir) Up to [Development] / JSOC / proj / globalhs / scripts

File: [Development] / JSOC / proj / globalhs / scripts / doinvert (download)
Revision: 1.3, Tue Jan 17 19:51:18 2017 UTC (21 months ago) by tplarson
Branch: MAIN
CVS Tags: Ver_9-1, Ver_9-0
Changes since 1.2: +55 -24 lines
update series structure, invert of na=6,18,36

#! /bin/tcsh -f

setenv PATH $JSOCROOT/bin/$JSOC_MACHINE':'$JSOCROOT/proj/globalhs/scripts':'$JSOCROOT/proj/globalhs/scripts/pkbgn':'$PATH
set pbdir=$JSOCROOT/proj/globalhs/scripts/pkbgn

@ i = 1
while ($i <= $#argv )
  set $argv[$i]
@ i++
end

if (! $?starttime) then
  echo must specify parameter starttime
  exit 1
endif

if (! $?totaltime) then
  echo must specify parameter totaltime
  exit 1
endif

set totalsecs = `durcon $totaltime`
if ($status) then
  echo incorrect format for parameter totaltime
  exit 1
endif

set timecheck = `echo "$totalsecs % 86400" | bc`
if ($timecheck) then
  echo totaltime must be an integer number of days
  exit 1
endif

set ndays = `echo "$totalsecs / 86400" | bc`

if (! $?lmin) set lmin = 0
if (! $?lmax) set lmax = 300
if (! $?rexp) set rexp = -6
if (! $?lexp) set lexp = -2

echo `date` on $HOST
echo $PWD
echo $0 $argv

if (! -es inv.parms.blank) then
  echo parameter file blank missing: inv.parms.blank is required
  exit 1
endif

grep -v '^[[:space:]]*$' inv.parms.blank | grep "^[[:space:]]*##" | awk -F '##' '{print $2}' | sed s@"[[:space:]]"@"\n"@g | grep -v '^[[:space:]]*$' > script.parms

set nonomatch
set vars = `cat script.parms`
@ i = 1
while ($i <= $#vars )
  set $vars[$i]
@ i++
end

# TAG may have been defined in script.parms 
if ($?TAG) then
  set tagclause = "TAG=$TAG"
else
  set tagclause = `cat inv.parms.blank | grep '^[[:space:]]*##' | awk -F '##' '{print $2}' | sed s@"[[:space:]]"@"\n"@g | grep ^input= | cut -d= -f2- | sed s@"\["@"\n"@g | sed s@]@"\n"@g | grep TAG`
endif

set in = `echo $input | sed s/\'//g | sed s/\"//g | cut -d[ -f1`
set epoch = `show_info -j $in | grep -i '^keyword:t_start_epoch' | cut -d, -f5`
set epochsecs = `time_convert o=jsoc time=$epoch`
set tstartstep = `show_info -j $in | grep -i '^keyword:t_start_step' | cut -d, -f5`
set cadence = `show_info -j $in | grep -i '^keyword:t_step' | cut -d, -f5`
set ndt   = `echo "$totalsecs / $cadence" | bc`

durcon $starttime >& /dev/null
if ($status) then
  set startsecs = `time_convert o=jsoc time=$starttime`
  set firstday  = `echo "($startsecs - $epochsecs)/86400" | bc` 
else
  set startsecs = `durcon $starttime` 
  set firstday = `echo "$startsecs / 86400" | bc`
  set startsecs = `echo "$startsecs + $epochsecs" | bc`
endif

set tstart = `time_convert s=$startsecs zone=TAI`
set stopsecs = `echo "$startsecs + $totalsecs" | bc`
set tstop = `time_convert s=$stopsecs zone=TAI`
set midsecs = `echo "$startsecs + ($totalsecs / 2)" | bc`
set tobs = `time_convert s=$midsecs zone=TAI`

set inds = $in
set in = `echo $input | sed s/\'//g | sed s/\"//g | sed s/XXXX/$starttime/g | sed s/NNNN/$lmin/g | sed s/MMMM/$lmax/g | sed s/TTTT/$ndt/g`
set versionin = `show_info -q "$in" key=version`
set recnumin  = `show_info -qr "$in"`

# VERSION may have been (re)defined in script.parms 
if ($?VERSION) then
  set verclause = "VERSION=$VERSION"
else if ($versionin != InvalidKeyname) then
  set verclause = "VERSION=$versionin"
else
  set verclause = ""
endif

set quality = `show_info -q "$in" key=quality`
set calver = `show_info -q "$in" key=calver64`
if ($calver == InvalidKeyname) then
  set calverclause=""
else
  set calverclause="CALVER64=$calver"
endif

set efuncfile = `show_info -q "$efuncs" -AP`
cat $pbdir/efunc.in.blank | sed s@FFFF@$efuncfile@g > efunc.in
cat inv.parms.blank | sed s/XXXX/$firstday/g | sed s/RRRR/$rexp/g | sed s/LLLL/$lexp/g > inv2d.AA

# invseries should be defined in script.parms above
set historyseries = `show_info -j $invseries | grep -i '^link: history' | cut -d, -f2`
set modname='inv2d.x'
set modpath=`which inv2d.x`

foreach na (6 18 36)

  if ($na == 6) then
    set suff=''
  else
    set suff=.$na
  endif

  cat inv2d.AA | sed s/AAAA/$suff/g > inv2d.in
  inv2d.x < inv2d.in > inv2d.out
  if ($?) then
      echo failure of inv2d.x for na = $na, nonzero return status
      exit 1
  endif

  if (! -es splittings.out || ! -es rot.2d) then
    echo error in output for na = $na, one of splittings.out or rot.2d file either does not exist or is empty
    exit 1
  endif
  echo inversion done for na=$na, rotation profiles made

  set cvstag=`cat cvstag.log`
  set now = `date -u  +%Y.%m.%d_%T`
  set_info -cv ds=$historyseries MODNAME=$modname MODPATH=$modpath CVSTAG=$cvstag DATE=$now >& setinfo.log

  set recnum = `grep recnum= setinfo.log`
  set $recnum

  set now = `date -u  +%Y.%m.%d_%T`

  set_info -c ds=$invseries $tagclause $verclause $calverclause HISTORY=$historyseries\[:'#'$recnum] SRCDATA=$inds\[:'#'$recnumin] NACOEFF=$na NDT=$ndt LMIN=$lmin LMAX=$lmax RADEXP=$rexp LATEXP=$lexp T_START=$tstart T_STOP=$tstop T_OBS=$tobs QUALITY=$quality DATE=$now split=splittings.out rot=rot.2d err=err.2d mesh=rmesh.orig parms=inv2d.in log=inv2d.out
  if ($?) then
      echo failure to ingest inversion results for starttime = $starttime, totaltime = $totaltime, na = $na
      exit 1
  endif

end

rm script.parms
echo successful completion
exit 0

Karen Tian
Powered by
ViewCVS 0.9.4