#!/bin/ksh # # tcvitals-devel-para.ksh # # Ver 1.0 created 23 Apr 2014 by M. DeMaria # # Copies all the .com files from a specified directory (comdir) # and runs the ncepdata-devel-para.f program on each case that has a # matching date/time group. # # The results are copied to a specified directories (tvcdir and tcidir) # # Set itest=1 for testing with a specified date/time group. Otherwise # set itest=0 to get date/time group from system clock for real time runs itest=0 # Specify common path for directories commonp="/nhc/save/guidance/" # Specify the directory where the script will run rundir=$commonp"prgms/test/ncepdata-devel-para/run/" # Specify the directory containing the .com input files comdir=$commonp"storm-data/zcom/" # Specify the directory with the ncepdata-dev executable #xdir=$commonp"prgms/exec/" xdir=$commonp"prgms/test/ncepdata-devel-para/bin/" # Specify the directory to put the cumulative tcvitals file tvcdir=$commonp"prgms/test/ncepdata-devel-para/dat/" # Specify the directory to put the individual tcvitals file tvidir=$commonp"prgms/test/ncepdata-devel-para/dat/ind/" #Specify the name of the cumulative tcvitals file and the generic name for # the individual files tvcfile="tcvitals-devel-cum.dat" tvifile="tcvitals-devel.dat" # Specify the log file names lfile="tcvitals-devel-para.log" nfile="ncepdata-devel-para.log" #Specify file name that will be created by the fortran code # Note: The name is specified in the fortran code, not here. ffile="tcvitals-devel-para.dat" cd $rundir rm $nfile touch $nfile echo "Begin tcvitals-devel-para.ksh at " `date` > $lfile # Copy .com files to process rm *.com cp $comdir*".com" . # Get current date and synoptic time if [ $itest -eq 1 ] then # Specify date/time variables for testing # Note: Leading zeros are needed for 1 digit numbers (eg. 7 should be 07) cyear=2014 cmon=04 cday=23 ctimes=06 else # Get date/time variables from system clock cyear=`date -u +%Y` cmon=`date -u +%m` cday=`date -u +%d` ctime=`date -u +%H` cmin=`date -u +%M` # # Adjust hour to the nearest syntopic hour ctimes=18 if [ $ctime -lt 18 ] then ctimes=12 fi if [ $ctime -lt 12 ] then ctimes=06 fi if [ $ctime -lt 6 ] then ctimes=00 fi fi # Build date/time group variable let cdtg=$((1000000*$cyear + 10000*$cmon + 100*$cday + $ctimes)) echo " " >> $lfile echo "Process cases for "$cyear" "$cmon$cday" "$ctimes" UTC" >> $lfile for line0 in `ls -1 *.com` do echo " " >> $lfile echo "Check" $line0 "for requested date/time" >> $lfile grep CARQ $line0 | grep $cdtg > carq.dat if [ -s carq.dat ] then echo "Date/Time group found, create tcvitals" >> $lfile rm -f $ffile $xdir"ncepdata-devel-para.x" $line0 ntemp.dat >> $nfile if [ -s $ffile ] then # Extract storm ID from com file name strmid=`echo $line0 | cut -c1-8` # Write tcvital line to log file cat $ffile >> $lfile # Add tcvital line to cumulative file # # ++Make local version of cumulative file and add current line to that cp $tvcdir$tvcfile tvctemp.dat cat $ffile >> tvctemp.dat # ++Check for duplicate lines in local cumulative file, eliminate those, # and copy result back to storage location awk '!x[$0]++' tvctemp.dat > $tvcdir$tvcfile # Save individual tcvital file cp $ffile $tvidir$strmid"_"$cdtg"_"$tvifile fi else echo "Date/Time group not found, do not create tcvitals" >> $lfile fi done # Clean up rm -f carq.dat rm -f ntemp.dat rm -f ncepdata.dat rm -f *.com rm -f tvctemp.dat echo " " >> $lfile echo "tcvitals-devel-para.ksh completed at " `date` >> $lfile exit