#!/bin/tcsh -f # # Wrap around 'dojsa_nl' - splits swid.list up into bits with identical instMod/response # # The jemx_science_analysis runs are organized in 'projects' (with name such as p002) # Attributed files : p002/swid.list # p002/template # # 2005-09-09/NJW # 2007-01-18/NJW updated for OSA6.0 # 2007-01-26/NJW version with 2-in-1 # 2007-11-08/NJW updated for OSA7.0 # 2008-12-22/NJW updated with 'ndir' for tesla/maxwell shell versions # 2009-01-09/NJW updated with free choice of working directory top # if ( $2 == "" ) then echo Syntax: SJLdo_project jemxNum proj_name echo proj_name is the analysis subdirectory name such as gbJ1_s exit 0 endif # # Updating the executable version of j_ima_iros # source $2/define_exe # # If present then copy the relevant 'dojsa'. There may be special # parameter settings not already defined in 'template' # if( -e $2/dojsa_sjl_104 ) then cp $2/dojsa_sjl_104 ./dojsa_nl else cp dojsa_sjl_104 ./dojsa_nl endif chmod +x dojsa_nl # # # Define the working directory (used to be '..') # as well as the current directory # set WORKDIR = /scratch/jemx/$USER if( ! -d $WORKDIR ) mkdir -p $WORKDIR set CURDIR = $PWD # # # Get a list of instance numbers to use for # IMOD in 'tmpimod' and for RMF in 'tmprmf' # if ( 0 == `wclines $2/swid.list` ) then echo 'do_project': $2/swid.list is empty ... exit endif if ( -e tmpimod$2 ) /bin/rm tmpimod$2 if ( -e tmprmf$2 ) /bin/rm tmprmf$2 foreach swid ( `cat ${2}/swid.list` ) get_insta_swijd -swid $swid $1 imod $ICVERSION >> tmpimod$2 get_insta_swijd -swid $swid $1 rmf $ICVERSION >> tmprmf$2 end # # Define number of processors available # set nprocs = 0 if ( $HOST == "lehmann" ) set nprocs = 30 if ( $HOST == "brahe" ) set nprocs = 30 if ( $HOST == "hansteen" ) set nprocs = 30 if ( $HOST == "faraday" ) set nprocs = 30 if ( $nprocs == 0 ) then echo This application does not work on your HOST: $HOST exit endif # # Test for error messages # grep get_insta_swijd tmpimod$2 > tmperrortest$2 if ( `wcchar tmperrortest$2` > 0 ) then echo Error detected when assigning instance numbers: cat tmperrortest$2 exit endif # # Make list with both SWIDs and instance numbers # falign ${2}/swid.list tmpimod$2 "_" > tmpswidimod$2 falign tmpswidimod$2 tmprmf$2 "_" > tmpcombi$2 # # Get rid of old blocks in project directory # /bin/rm $2/block_* # # Now split up into blocks # The processing is divided into blocks where each of them has a # single IMOD and RMF instance number. # set nlines = `wclines tmpcombi$2` @ limit = ( $nlines - 1 ) / $nprocs + 1 set nblock = 1 set nline = 0 set reference = `head -1 tmpcombi$2 | cut -c 14-22` #echo Reference: $reference # # Loop over all lines in tmpcombiq123 (or the like) # and start a new block if one of two happens: # 1) The instance numbers change # 2) The number of SWIDs in a block exceeds the chosen limit # foreach line ( `cat tmpcombi$2` ) set part = `echo $line | cut -c 14-22` #echo $part if ( $part == $reference && $nline < $limit ) then if ( $nblock < 10 ) then echo $line >> $2/block_0$nblock else echo $line >> $2/block_$nblock endif @ nline = ( $nline + 1 ) else @ nblock = ( $nblock + 1 ) set reference = `echo $line | cut -c 14-22` if ( $nblock < 10 ) then echo $line >> $2/block_0$nblock else echo $line >> $2/block_$nblock endif set nline = 1 endif end # # Remove all proj_name_xx directories # cd $WORKDIR foreach anadir ( `/bin/ls -F | grep $2_ | rm_char 47` ) /bin/rm -r $anadir end # # Issue report # if ( $nblock > 1 ) then echo $nblock blocks have been defined in $2 else echo $nblock block has been defined in $2 endif echo and the maximum length is $limit echo " " echo Now you are entering the actual run cd $CURDIR if ( ! -e ../log_version_number_$2 ) then echo 0 > ../log_version_number_$2 endif set version = `cat ../log_version_number_$2` @ version = $version + 1 echo $version > ../log_version_number_$2 set zeros = "" if ( $version < 1000 ) set zeros = 0 if ( $version < 100 ) set zeros = 00 if ( $version < 10 ) set zeros = 000 set version = ${zeros}$version # # Set up a directory for each block and then # run each block # set ndir = 1 set nndir = $ndir foreach block ( `/bin/ls $2/block_*` ) # # operating from $CURDIR (analysis7) # if ( $ndir < 10 ) set nndir = 0$nndir echo p1 $block ndir = $nndir # /bin/rm -r $WORKDIR/${2}_$nndir mkdir $WORKDIR/${2}_$nndir cp dojsa_nl $WORKDIR/${2}_$nndir cp dojsa_nl.par $WORKDIR/${2}_$nndir cp setup_env_prod $WORKDIR/${2}_$nndir/setup_env cp setup_links_jarc $WORKDIR/${2}_$nndir cp setup_links_nrt $WORKDIR/${2}_$nndir cp ${2}/template $WORKDIR/${2}_$nndir/command cp ${2}/ebin.list $WORKDIR/${2}_$nndir/ebin.list cp $block $WORKDIR/${2}_$nndir set lblock = `basename $block` # save a copy of the block file cp $block blockfiles/${2}_${lblock}_$version # # operating from new ${2}_nndir # cd $WORKDIR/${2}_$nndir echo now in ./${2}_$nndir echo p2 lblock = $lblock strrep jemxnum $1 command strrep block $lblock command strrep proj_name $2 command echo next is getting instances # get instance number of IMOD set instance = `head -1 $lblock | cut -c 14-17` strrep zzzz $instance command # get instance number of RMF set instance = `head -1 $lblock | cut -c 19-22` strrep qqqq $instance command cut -c 1-12 $lblock > swid.list echo Going to run the following command in $PWD : cat command echo " " set snumw = `wclines swid.list` echo on the following $snumw SWIDs: head -10 swid.list echo There may be more ... # # Calling dojsa_nl via 'command' # source command # @ ndir = ( $ndir + 1 ) set nndir = $ndir cd $CURDIR end