#### UNIX Script Documentation Block # . . . # Script name: satdump Dump job-1B (HIRS,MSU,AMSU-A/B),SBUV DATA # # JIF contact: Katz, Bert Org: w/np2 Date: 1998-09-29 # # Abstract: The satdump script is a dump utility for time windowing and # eliminating duplicates for 1B (HIRS, MSU, AMSU-A/B), and SBUV # satellite data. The script is driven by parameters which specify # the time window and list of data to dump. Data to dump is # indicated by mnemonic references to individual data types. The # list of data types is given in the remarks section. Several script # variables determine other characteristics of the dump. Each data # type requested as a parameter, and generates a thread which dumps # one data type. The script is set up so all the process threads # from all the data types are spun off into background shells to # execute in parallel. The more background shells generated, the # larger the memory requirement for the job becomes. Something to # keep in mind if a job fails for lack of memory. # # Script history log: # 1998-03-27 Bert Katz -- original version # 1998-05-12 Bert Katz -- changes for y2k compliance # 1998-09-29 Bert Katz -- added NOAA-15 1b data handling # 1999-02-02 D. Keyser -- update for Y2K compliance # 1999-12-21 Bert Katz -- added NOAA-11 SBUV data handling # 2000-01-19 D. Keyser -- converted to IBM-SP # 2000-10-18 D. Keyser -- added NOAA-16 1b data handling # 2001-03-20 X. Su -- added NOAA-16 sbuv data handling # # Usage: satdump yyyymmddhh<.hh> hh<.hh> dtyp1 dtyp2 dtyp3 ... dtypN # # Script parameters: # yyyymmddhh<.hh> - center of time window for dump # hh<.hh> - radius of time window for dump # dtyp1 - data type 1 - see list of data types below # dtyp2 - data type 2 # dtyp3 - data type 3 # ... ... # dtypN - data type N # # Modules and files referenced: # scripts : $DUSCsat/bufr_window_orbits # executables: $DUEXsat/bufr_extrtv1b # $SBUVXdr/bufr_extrsbuv # $DUEXsat/bufr_extrat1b # parm cards : $TBLSsat/bufr_ozone.pseudo_tableb.tbl # ($SBUVXdr/bufr_extrsbuv) # $TBLSsat/bufr_ozone.tabled.tbl ($SBUVXdr/bufr_extrsbuv) # # Remarks: # Condition codes (for c.code < 254, the highest return code from the # individual data type dumps is returned here): # 00 - no problem encountered # 11 - all data types in input list valid, and data dumped from all # data types in list, however at least one type contained data # records that could not be processed # 22 - all data types in input list valid, however at least one data # type in list had no data dumped # 254 - bad instrument identifier in one or more of the data types # in input list - no data types are dumped # 255 - bad satellite identifier in one or more of the data types # in input list - no data types are dumped # # Valid current and past(*) data types are as follows : # # * h1bn11 : NOAA-11 HIRS 1b data with remapped MSU 1b data # * m1bn11 : NOAA-11 MSU 1b data (original, not remapped) # * h1bn12 : NOAA-12 HIRS 1b data with remapped MSU 1b data # * m1bn12 : NOAA-12 MSU 1b data (original, not remapped) # h1bn14 : NOAA-14 HIRS 1b data with remapped MSU 1b data # m1bn14 : NOAA-14 MSU 1b data (original, not remapped) # h1bn15 : NOAA-15 HIRS 1b data # a1bn15 : NOAA-15 AMSU/A 1b data # b1bn15 : NOAA-15 AMSU/B 1b data # h1bn16 : NOAA-16 HIRS 1b data # a1bn16 : NOAA-16 AMSU/A 1b data # b1bn16 : NOAA-16 AMSU/B 1b data # * sbvn09 : NOAA-09 SBUV data # * sbvn11 : NOAA-11 SBUV data # * sbvn14 : NOAA-14 SBUV data # sbvn16 : NOAA-16 SBUV data # # * - Must allow this script to process obsolete data types, since # historical reruns may occur!!!! # # The following script variables are user controllable with # operational defaults defined in the script. If a user exports # non-null values for any of these variables, the user value will # override the default. # # envir - environment under which job runs ('prod' or 'test') # DUEXsat - directory path to satellite dump executables # default:/nw${envir}/exec # SBUVXdr - directory path to sbuv dump executable (bufr_extrsbuv) # default:$DUEXsat # DUSCsat - directory path to satellite scripts # default:/nw${envir}/ush # TANKsat - directory path to satellite database home directory # default:/dcom/us007003 # TBLSsat - directory path to BUFR table database # default:/nw${envir}/parm # LOUDsat - turns on script trace (set -x) # default:off # BACKsat - turns off background shells # default:on # # Attributes: # # Language: UNIX script # Machine: IBM-SP #### envir=${envir:-prod} DUEXsat=${DUEXsat:-/nw${envir}/exec} SBUVXdr=${SBUVXdr:-$DUEXsat} DUSCsat=${DUSCsat:-/nw${envir}/ush} TANKsat=${TANKsat:-/dcom/us007003} TBLSsat=${TBLSsat:-/nw${envir}/parm} LOUDsat=${LOUDsat:-off} BACKsat=${BACKsat:-on} export LOUDsat if [[ $LOUDsat != off ]] ; then set -x fi rm fileinfo 2> /dev/null echo '** 1B (HIRS, MSU, AMSU-A/B) and SBUV satellite data extraction **' echo '** From IBM ingested data **' cdate10=`echo $1 | cut -c1-10` echo "$1 $2" | awk ' { center=$1; iymdh=int(center); cenfrac=center-iymdh; radius=$2; irad=int(radius) radfrac=radius-irad; begfrac=cenfrac-radfrac; endfrac=cenfrac+radfrac; if(begfrac>=0.0) ibegrad=irad else { ibegrad=irad+1; begfrac=begfrac+1.0; } if(endfrac<1.0) iendrad=irad else { iendrad=irad+1; endfrac=endfrac-1.0 } ibegmin=int(60.0*begfrac); iendmin=int(60.0*endfrac); print iymdh,ibegrad,ibegmin,iendrad,iendmin }' | read DATE BEGRAD imimin ENDRAD imimax if (( $imimin < 10 )) ; then imimin=0$imimin fi if (( $imimax < 10 )) ; then imimax=0$imimax fi echo "Date is: $DATE" nhours=/nwprod/util/exec/ndate ymdhmin=$($nhours -$BEGRAD $DATE) ymdhmax=$($nhours +$ENDRAD $DATE) echo $ymdhmin # SAG: The next dozen (or so) lines contain changes for frost/snow # to eliminate arithmetic operations with leading zeros, # since they are now treated as octal numbers. #typeset -LZ4 iyrmin iyrmax #typeset -LZ2 imomin imomax idymin idymax ihrmin ihrmax #iyrmin=$(echo "$ymdhmin/1000000 \n quit" | bc) iyrmin=$(echo $ymdhmin | cut -c1-4) #mdhmin=$(echo "$ymdhmin-1000000*$iyrmin \n quit" | bc) #imomin=$(($mdhmin/10000)) imomin=$(echo $ymdhmin | cut -c5-6) #dhmin=$(($mdhmin-10000*$imomin)) #idymin=$(($dhmin/100)) idymin=$(echo $ymdhmin | cut -c7-8) #ihrmin=$(($dhmin-100*$idymin)) ihrmin=$(echo $ymdhmin | cut -c9-10) echo 'initial time stamp :' echo $iyrmin $imomin $idymin $ihrmin $imimin echo $ymdhmax # SAG: The next ten (or so) lines contain changes for frost/snow # to eliminate arithmetic operations with leading zeros, # since they are now treated as octal numbers. #iyrmax=$(echo "$ymdhmax/1000000 \n quit" | bc) iyrmax=$(echo $ymdhmax | cut -c1-4) #mdhmax=$(echo "$ymdhmax-1000000*$iyrmax \n quit" | bc) #imomax=$(($mdhmax/10000)) imomax=$(echo $ymdhmax | cut -c5-6) #dhmax=$(($mdhmax-10000*$imomax)) #idymax=$(($dhmax/100)) idymax=$(echo $ymdhmax | cut -c7-8) #ihrmax=$(($dhmax-100*$idymax)) ihrmax=$(echo $ymdhmax | cut -c9-10) echo 'final time stamp :' echo $iyrmax $imomax $idymax $ihrmax $imimax shift 2 echo "\n $*\n" for dmptyp ; do noaasat=$(echo $dmptyp | cut -c5-6) hirsmsu=$(echo $dmptyp | cut -c1) echo "\n dmptyp = $dmptyp noaasat = $noaasat hirsmsu = $hirsmsu\n" if [[ $hirsmsu = "h" ]] ; then if (( $noaasat != 11 && $noaasat != 12 && $noaasat != 14 && \ $noaasat != 15 && $noaasat != 16 )) ; then echo "Invalid HIRS 1B data type : bad satellite id." exit 255 fi elif [[ $hirsmsu = "m" ]] ; then if (( $noaasat != 11 && $noaasat != 12 && $noaasat != 14 )) ; then echo "Invalid MSU 1B data type : bad satellite id." exit 255 fi elif [[ $hirsmsu = "a" || $hirsmsu = "b" ]] ; then if (( $noaasat != 15 && $noaasat != 16 )) ; then echo "Invalid AMSU-A/B 1B data type : bad satellite id." exit 255 fi elif [[ $hirsmsu = "s" ]] ; then if (( $noaasat != 09 && $noaasat != 11 && $noaasat != 14 && $noaasat != 16)) ; then echo "Invalid SBUV data type : bad satellite id." exit 255 fi else echo "Invalid 1B (HIRS, MSU, AMSU-A/B) or SBUV data type : bad instrument id." exit 254 fi done rm rclist.satdump.$$ 2> /dev/null for dmptyp ; do noaasat=$(echo $dmptyp | cut -c5-6) hirsmsu=$(echo $dmptyp | cut -c1) echo "\n dmptyp = $dmptyp noaasat = $noaasat hirsmsu = $hirsmsu\n" if [[ $hirsmsu = "h" ]] ; then filehead=NSS linesamp=2 spotsamp=2 if (( $noaasat == 11 || $noaasat == 12 || $noaasat == 14 )) ; then datatype=HIRS1B fileid=TOVX1B. elif (( $noaasat == 15 || $noaasat == 16 )) ; then datatype=HIRS3 fileid=HIRX. fi elif [[ $hirsmsu = "m" ]] ; then filehead=NSS fileid=UMSX1B. linesamp=1 spotsamp=1 datatype=MSU1B elif [[ $hirsmsu = "a" ]] ; then filehead=NSS fileid=AMAX. linesamp=1 spotsamp=1 datatype=AMSUA elif [[ $hirsmsu = "b" ]] ; then filehead=NSS fileid=AMBX. linesamp=2 spotsamp=2 datatype=AMSUB elif [[ $hirsmsu = "s" ]] ; then filehead=PRD fileid=OZONE.PMF datatype=SBUV fi echo " CHECKPOINT 1 dmptyp = $dmptyp" if [[ $datatype = HIRS1B || $datatype = HIRS3 || $datatype = MSU1B \ || $datatype = AMSUA || $datatype = AMSUB ]] ; then if (( $noaasat == 11 )) ; then nx=NH executable=bufr_extrtv1b elif (( $noaasat == 12 )) ; then nx=ND executable=bufr_extrtv1b elif (( $noaasat == 14 )) ; then nx=NJ executable=bufr_extrtv1b elif (( $noaasat == 15 )) ; then nx=NK executable=bufr_extrat1b elif (( $noaasat == 16 )) ; then nx=NL executable=bufr_extrat1b fi echo " CHECKPOINT 2 dmptyp = $dmptyp" xchk=0 if [ xchk -eq 0 ]; then echo "\n CREATE NAMELIST FILE noaa.data.${dmptyp}.$$" cat > noaa.data.$dmptyp.$$ < 2001030100)) ; then nx=1. elif (( $noaasat == 11 )) ; then nx=2. elif (( $noaasat == 14 )) ; then nx=3. fi cat > noaa.data.$dmptyp.$$ <> fileinfo ####### sh $DUSCsat/bufr_window_orbits $TANKsat $filehead.$fileid$nx \ $iyrmin$imomin$idymin $ihrmin$imimin $iyrmax$imomax$idymax $ihrmax$imimax \ >noaa.orbits.$dmptyp.$$ 2> errfile.window_orbits if [ "$LOUDsat" != 'off' ];then set +x echo echo "vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv" echo "------------------------------------------------------------------------" echo " LOUDsat != off - below is script trace for this run of window_orbits" echo "------------------------------------------------------------------------" echo cat errfile.window_orbits echo echo "------------------------------------------------------------------------" echo " end of script trace for this run of window_orbits" echo "------------------------------------------------------------------------" echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" echo set -x fi ##rm errfile.window_orbits numorb=$(cat noaa.orbits.$dmptyp.$$ | wc -l) echo "\n numorb = $numorb in noaa.orbits.$dmptyp.$$\n" if (( ${#datatype} > 5 )) ; then datatyprt=$datatype else datatyprt=$(echo "$datatype " | cut -c1-6) fi if (( $numorb == 0 )) ; then echo "Dump Status: $dmptyp : RC=22" echo 22 >> rclist.satdump.$$ echo "--> $datatyprt type $dmptyp for \ $iyrmin$imomin$idymin$ihrmin$imimin-$iyrmax$imomax$idymax$ihrmax$imimax \ HAS 0 REPORTS" else multitask=$dmptyp.sh ######################################################################### # VVVVVVVVVVV Herefile to run in background starts here VVVVVVVVVVVVVVV ######################################################################### cat > $multitask <> filenames.$dmptyp.$$ done if [[ $datatype = HIRS1B || $datatype = HIRS3 || $datatype = AMSUA \ || $datatype = AMSUB || $datatype = MSU1B ]] ; then export XLFUNIT_61=/dev/null exec=$DUEXsat/$executable elif [[ $datatype = SBUV ]] ; then export XLFUNIT_20=$TBLSsat/bufr_ozone.pseudo_tableb.tbl export XLFUNIT_25=$TBLSsat/bufr_ozone.tabled.tbl export XLFUNIT_30=filenames.$dmptyp.$$ export XLFUNIT_80=true_tabled_o.$dmptyp.wrk.$$ export XLFUNIT_81=true_tabled_n.$dmptyp.wrk.$$ exec=$SBUVXdr/$executable fi echo " &input \n nfile=$numorb," | \ cat - noaa.data.$dmptyp.$$ noaa.orbits.$dmptyp.$$ | \ timex \$exec 2> $dmptyp.stderr | tee -a $dmptyp.OUT err=\$? cat $dmptyp.stderr grep -e "total written so far" $dmptyp.OUT > grep1.out.$dmptyp errG1=\$? if (( \$errG1 == 0 )) ; then tail -n1 grep1.out.$dmptyp | grep -e "total written so far" \ > grep2.out.$dmptyp num=\$(cut -f2 -d= grep2.out.$dmptyp) if (( \$num == 0 && \$err == 0 )) ; then err=22 fi if (( \$num < 1000000 )) ; then typeset -R6 num fi else if (( \$err == 0 )) ; then err=22 fi num=" 0" fi } > $dmptyp.out 2>&1 echo "--> $datatyprt type $dmptyp for \ $iyrmin$imomin$idymin$ihrmin$imimin-$iyrmax$imomax$idymax$ihrmax$imimax \ HAS \$num REPORTS" rm grep*.out.$dmptyp echo "Dump Status: $dmptyp : RC=\$err" echo \$err >> rclist.satdump.$$ ### rm noaa.orbits.$dmptyp.$$ noaa.data.$dmptyp.$$ { echo echo echo "********************************************************************" echo Script $multitask echo Finished executing on node \`hostname -s\` echo Ending time : \`date\` echo "********************************************************************" echo } >> $dmptyp.out 2>&1 EOFmulti ######################################################################### # AAAAAAAAAAA Herefile to run in background ends here AAAAAAAAAAAAAAAAA ######################################################################### chmod 755 $multitask ###echo "%%%%% Script $multitask fired off at" `date` if [[ $BACKsat = on ]] ; then $multitask& else $multitask fi ###echo "%%%%% Moving on after firing off $multitask at" `date` fi done wait errout=0 for err in $(cat rclist.satdump.$$) ; do if (( $err > $errout )) ; then errout=$err fi done exit $errout