#! /bin/tcsh -f # ----------------------------------------------------------------------------- # # Name : merge_svx.tcsh # # Purpose : Merge the PROD_PHYSICS_SVX used_set # into the PROD_PHYSICS_CDF used_set with the matching run number. # # Usage : merge_svx.tcsh # # Options : None. # # Arguements : None. # # Created : RMS20020304 Copied from merge_stage0.tcsh # Updated : RMS20020430 Remove replication, and fill passcalibs (Dustin McGivern). # Updated : RMS20020723 Immediate exit if # a) script already running. # b) ping of cdfonprd (=b0dau35) fails. # Updated : RMS20020904 Remove all unnecessary version of PROD_PHYSICS_CDF. # Updated : RMS20021119 Output date. # Updated : RMS20030610 Use cdfcalib account, check for numeric runnumber. # # ----------------------------------------------------------------------------- ps -fN -p $$ | grep $USER | grep $0 | grep -v grep && exit 5 source ~cdfsoft/cdf2.cshrc setup cdfsoft2 5.3.1 setup cdfdb dbPing -dcdfonprd -s > /dev/null || exit 6 #cd ~snihur/used_sets/svx_auto cd /data1/cdfcalib/cron_scripts/svx_merge @ last_date = `grep . date_runs.lst | tail -1 | awk '{print int($1)}'` # Get the last processed run number. if ( $last_date == 0 ) then # If run number is invalid. echo "file date_runs.lst:"; echo "============"; cat date_runs.lst; exit 2 # Print file, and exit. endif # if ( $last_date == 0 ) then # Find new runs with SVX calibs. sqlplus -s cdf_reader/reader@cdfonprd @runs.sql $last_date || exit 3 # Get the last SVX run. # # Print out exe info. # if (! -z date_runs.lst) then # If new data-taking runs. set dat = `date` echo " Script ran at $dat " ls -lrt DBSetMerge # Show date and size of exe. ls -Llrt DBSetMerge # Dereferenced info, but link name. rm date.lst >& /dev/null # Clear file for safety. rm runs.lst >& /dev/null # Clear file for safety. cut -d" " -f2 date_runs.lst >! date.lst # Put the date into one list. cut -d" " -f3- date_runs.lst >! runs.lst # Put the runs in another list. # Check that all runs in list are numeric. foreach r ( `grep . runs.lst` ) # Loop over runs. @ n = 0 # Default. @ n = `echo $r | awk '{print int($1)}'` # Numeric run. if ( $n == 0 ) then # If non-numeric run translated to zero. echo "Error: Exit because of non-numeric run $r" echo "Will not process any runs." echo "file date_runs.lst:"; echo "============"; cat date_runs.lst # Print file. echo $last_date >! date_runs.lst # Put the last processed run in there. exit 4 # Exit. endif # if ( $n == 0 ) end # foreach r ( `grep . runs.txt` ) foreach r ( `grep . runs.lst` ) # Loop over runs. echo DBSetMerge TESTMODE OTL /@cdfonprd used $r PROD_PHYSICS_CDF PROD_PHYSICS_CDF PROD_PHYSICS_SVX ./DBSetMerge TESTMODE OTL /@cdfonprd used $r PROD_PHYSICS_CDF PROD_PHYSICS_CDF PROD_PHYSICS_SVX echo DBSetMerge OTL /@cdfonprd used $r PROD_PHYSICS_CDF PROD_PHYSICS_CDF PROD_PHYSICS_SVX ./DBSetMerge OTL /@cdfonprd used $r PROD_PHYSICS_CDF PROD_PHYSICS_CDF PROD_PHYSICS_SVX end # foreach r ( `grep . runs.lst` ) echo "==============================end run====================================" else # No new runs detected. echo $last_date >> date_runs.lst # Put the last processed run in there. endif # if (-z date_runs.lst) then rm core >& /dev/null # Remove core file, if it exists.