#!/bin/csh #-x #+ # (c-shell) script which will process the list of calibration # tests in a given a cmdb ("see-me-dee-be") file in order to # run simulations of each test. The tasks performed are as follows: # # (1) Determine the number of lines in the cmdb file (wc -l . . .) # The following are done in a loop; i.e. each line in the cmdb file is processed # (2) call the C-program cmdb_trw_line to convert line # --> trw id # (3) call the C-program cmdb_to_marx to creat a .par file for the trw id # (4) run marx (csim) with the given .par file # # Notes: # - The .par file is name .par # - The .par files are stuck under the directory parfiles #- set num=$#argv # Check to see if arguments were used # argument #1 is the cmdb filename #################################### switch($num) case 0: echo " cmdb_simulate usage:" echo " cmdb_simulate cmdb-filename" exit 1 breaksw case 1: set CMDB_FILE=$1 set ALL_LINES=1 breaksw default: set CMDB_FILE=$1 set pairs=`echo $argv[2-]` set ALL_LINES=0 endsw #################################### # Make a directory to contain the parameter files if !(-e parfiles && -d parfiles) then echo Making parfiles directory mkdir parfiles endif if ($ALL_LINES) then set wc_output=`wc -l $CMDB_FILE` set start_lines=1 set stop_lines=$wc_output[1] else get_line_numbers $pairs set start_lines=`cat start.lines` set stop_lines=`cat stop.lines` endif ##################################### # Now create the parameter files set j=1 foreach istart ($start_lines) set istop=$stop_lines[$j] set PARDIR="parfiles/" set i=$istart while ($i <= $istop) set TRW_ID=`cmdb_trw_line -cmdb $CMDB_FILE -line $i` echo Creating parameter file for $TRW_ID now . . . set PARFILE=`echo $PARDIR$TRW_ID`.par cmdb_to_marx -cmdb $CMDB_FILE -line $i -par $PARFILE @ i++ end @ j++ end # Now run csim on the parameter files #################################### set j=1 set SPECDIR=/spectra/d7/phase1real/spectfiles/ foreach istart ($start_lines) set istop=$stop_lines[$j] set i=$istart while ($i <= $istop) set TRW_ID=`cmdb_trw_line -cmdb $CMDB_FILE -line $i ` set PARFILE=`echo $PARDIR$TRW_ID`.par echo " " echo Running csim on $TRW_ID now echo " " csim @@$PARFILE NumRays=3000000 SpectrumFile=$SPECDIR`echo $TRW_ID`.spec @ i++ end @ j++ end ####################################