#! /bin/sh -v # # <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>> # <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>> # << FSL_map.run 12 Sep 06 >> # << >> # << Multi-Agency Profiler (MAP) dataset QC stage 1 and 2 program >> # <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>> # <<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>><<>> # # # # # It is called with Arguments: # Arg 1: the run directory # Arg 2: the directory containing raw wind netCDF obs # Arg 3: the directory containing raw temperature netCDF obs # Arg 4: the directory containing QC'ed netCDF obs # Arg 5: the filename of the cdl for the QC'ed netCDF obs # Arg 6: the time in YYJJJHHMM format (eg 930691200) # Arg 7: the current hour in HH format (eg 08) # Arg 8: the current minute in MM format (eg 08) # Arg 9: the current YYJJJ of the timing log file (eg 93069) # # Mods: # Sep 12, 2006/LAB Changed temp met directories name to JJJHH from HH # ############################################################################### # ASSIGN THE ARGUMENTS ############################################################################### START=`date -u +%y" "%j" "%T` RUN=$1 BIN=${RUN}/bin LOG=${RUN}/output ERR=${RUN}/errors WINDDIR=$2 TEMPDIR=$3 QCDIR=$4 QCCDL=$5 ATIME=$6 HH=$7 MIN=$8 YYDDD=$9 ############################################################################### # Link in the data directories & files # # Note that we copy the raw files to a temporary directory. This is done # because they can change on any schedule on the input NFS-mounted disk, # and that could cause trouble... ############################################################################### /bin/rm -f WIND_DIR /bin/rm -f TEMP_DIR /bin/rm -f QC_DIR /bin/rm -f QC_CDL /bin/rm -f CSV_DIR /bin/rm -f PARMS # TBD Where is TMP for map? Was /tmp TMP=/tmp/${RUN} CURRHR=`echo $ATIME | cut -c3-7` # JJJHH mkdir -p ${TMP}/map_files/wind mkdir -p ${TMP}/map_files/temp mkdir -p ${TMP}/map_files/${CURRHR}/curr mkdir -p ${TMP}/map_files/${CURRHR}/prev /bin/rm -f ${TMP}/map_files/wind/* /bin/rm -f ${TMP}/map_files/temp/* /bin/rm -f ${TMP}/map_files/${CURRHR}/curr/* YYDDDHH=`echo $ATIME | cut -c1-7` YYDDDHH1=`$RUN/prevhour $ATIME 1` #previous hour cp ${WINDDIR}/${YYDDDHH}* ${TMP}/map_files/wind cp ${TEMPDIR}/${YYDDDHH}* ${TMP}/map_files/temp cp ${WINDDIR}/${YYDDDHH1}* ${TMP}/map_files/wind cp ${TEMPDIR}/${YYDDDHH1}* ${TMP}/map_files/temp ln -s ${TMP}/map_files/wind WIND_DIR ln -s ${TMP}/map_files/temp TEMP_DIR ln -s ${TMP}/map_files/${CURRHR}/curr CSV_DIR ln -s ${QCDIR} QC_DIR ln -s ${QCCDL} QC_CDL ln -s $RUN/parms PARMS ############################################################################### # Figure QCTIME ############################################################################### /bin/rm -f ./QCTIME echo $ATIME >QCTIME #create the QCTIME file ############################################################################### # Input files ############################################################################### /bin/rm -f MAP.INI /bin/rm -f ACCEPTIN /bin/rm -f REJECTIN /bin/rm -f MAPVARS ln -s PARMS/map.ini MAP.INI ln -s PARMS/accept.map ACCEPTIN ln -s PARMS/reject.map REJECTIN ln -s PARMS/mapvars.txt MAPVARS ############################################################################### # Output files ############################################################################## /bin/rm -f MAP.OUT /bin/rm -f MAP.ERR ln -s ${LOG}/map.out.${ATIME}_${HH}${MIN} MAP.OUT ln -s ${ERR}/map.err.${ATIME}_${HH}${MIN} MAP.ERR ############################################################################### # Do the work: # # - Run the program. # - Send the output netCDF file into LDM. # - Accumulate new LDAD sfc CSV files into the MAP.dat file that will be # send into LDAD by our calling script. # # Note that we track the timing separately for each of these three steps. ############################################################################## # Run the program. $BIN/map.exe FINISH=`date -u +%y" "%j" "%T` echo ${ATIME}" "${START}" "${FINISH}" map" >> ${LOG}/times.out.${YYDDD} # Send netCDF file into LDM. START=`date -u +%y" "%j" "%T` WFNAME=`$RUN/f2a $ATIME` ${RUN}/moveTmpDataFiles -f $QCDIR/$WFNAME -t /rtmadis/madis_data -p /public/data/madis -M MMXX56 -K storeMadisData.FSL.NetCDF.MADIS.FSL.NetCDF.MADIS.map & $RUN/SendFile2LDM -l $RUN/ldm -k FSL.CompressedNetCDF.MADIS.map -f $QCDIR/$WFNAME -t FSL2 -z & FINISH=`date -u +%y" "%j" "%T` echo ${ATIME}" "${START}" "${FINISH}" ldm map" >> ${LOG}/times.out.${YYDDD} # Accumulate new LDAD sfc CSV files. START=`date -u +%y" "%j" "%T` CURR=${TMP}/map_files/${CURRHR}/curr PREV=${TMP}/map_files/${CURRHR}/prev cd $CURR # For each file in the current scratch directory, if # it doesn't exist in the previous scratch directory, or # if it has changed from the previous file, add it to # the master file to be processed by LDAD (MAP.dat). LIST=`ls *` for i in ${LIST} do if [ -f $PREV/${i} ] ; then d=`diff ${i} $PREV/${i} | wc -l` if [ $d -ne 0 ] ; then cat ${i} >> ${RUN}/map/MAP.dat fi elif [ -f ${i} ] ; then cat ${i} >> ${RUN}/map/MAP.dat fi done # Update the PREV directory for the CURR files (for the next time we're # here for the same time). mv -f ${CURR}/* ${PREV} FINISH=`date -u +%y" "%j" "%T` echo ${ATIME}" "${START}" "${FINISH}" ldad map" >> ${LOG}/times.out.${YYDDD} cd ${RUN}/map