#!/bin/ksh set -o xtrace # # This command file runs the CONTEMPT28 code. # # # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # # PARAMETERS # # P1 (required) = Input data file. If no file extension is # specified, .inp is assumed. # P2 (optional) = DRXE1 input file. Takes file name from P1 if # not specified and replaces file extension w/ .RXI # This "RXI" file must exist. # P3 (optional) = HX1 input file. Takes file name from P1 if not # specified and replaces file extension w/ .HXI # This "HXI" file must exist. # P4 (obsolete) = Ignored, retained for compatability # P5 (optional) = Length of X-axis for HP7550 plots (default=8 inches) # P6 (optional) = Length of Y-axis for HP7550 plots (default=6 inches) # P7 (optional) = Delete flag for binary and PGPLOT files (default=yes) # # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # function TypeCheck { if [[ $1 = *([0-9]) ]] ; then TYPE=INTEGER else TYPE=STRING fi export TYPE } #set +o xtrace # # Check for the existence of the input file. # P1=${1:?input data file must be specified} EXT=${P1##*.} if [[ $EXT = $P1 ]] ; then P1=${P1}.inp fi if ! [[ -a $P1 ]] ; then print print File $P1 not found! print ps -l exit else if [[ $(dirname $P1) = "." ]] ; then P1=${PWD}/$P1 fi fi # # Construct name variables # JOBDIR=${P1%/*}/ JOBNAM=${P1##*/} JOBNAM=${JOBNAM%.*} TEMPJOB=${JOBDIR}${JOBNAM} # # Allocate a scratch disk/directory. # (Delete it at the end of this script.) # CD to the new directory. This makes sure # that spurious files will be placed in a # spurious place. It also makes sure that # any "core" file will go here. In that # case, the script will not delete the new # directory, in order to save as much debugging # information as possible. # PID=$$ SCRAT=/tmp/ SYS_SCRATCH=${SCRAT}contempt28$$/ mkdir ${SYS_SCRATCH} cd ${SYS_SCRATCH} # # Name various files # CONTEMPT=/rxe/test/images/contempt28_v21_cp03 AXIS=${SYS_SCRATCH}${JOBNAM}.axis.temp STEAM=/rxe/test/images/STH2OT_v21_cp03 HPGL=${SYS_SCRATCH}${JOBNAM}.hpgl PGD=${SYS_SCRATCH}${JOBNAM}.pgd OUT=${SYS_SCRATCH}${JOBNAM}.out BANNER=/rxe/util/scripts/banner $BANNER CONTEMPT28 TEST 09/26/2017 TYPE2=STRING P2=$2 if [[ -z $P2 ]] ; then P2=${TEMPJOB}.rxi else # # Check to see if the DRXE1 input file exists. # The logic says: if there's no file type, append .rxi # if the obvious file location doesn't work, replace the file # type with .rxi and look in the JOBDIR directory. # if the file is still not found, complain and exit. # otherwise use this file. # if [[ -z ${P2##*.} ]] ; then P2=${P2}.rxi fi if ! [[ -a $P2 ]] ; then T=${P2##*/} P2=${T%.*}.rxi if ! [[ -a ${JOBDIR}${P2} ]] ; then print print File $P2 not found! print ps -l exit else P2=${JOBDIR}${P2} fi fi fi TYPE3=STRING P3=$3 if [[ -z $P3 ]] ; then P3=${TEMPJOB}.hxi else # # Check to see if the DRXE1 input file exists. # The logic says: if there's no file type, append .hxi # if the obvious file location doesn't work, replace the file # type with .hxi and look in the JOBDIR directory. # if the file is still not found, complain and exit. # otherwise use this file. # if [[ -z ${P3##*.} ]] ; then P3=${P3}.hxi fi if ! [[ -a $P3 ]] ; then T=${P3##*/} P3=${T%.*}.hxi if ! [[ -a ${JOBDIR}${P3} ]] ; then print print File $P3 not found! print ps -l exit else P3=${JOBDIR}${P3} fi fi fi # # Create temporary file to hold plot axis lengths. # P5=${5:-8.0D0} P6=${6:-6.0D0} TypeCheck $P5 if [[ $TYPE = INTEGER ]] ; then P5=${P5}.0D0 fi TypeCheck $P6 if [[ $TYPE = INTEGER ]] ; then P6=${P6}.0D0 fi let IP5=${P5%%.*} let IP6=${P6%%.*} if [[ $IP5 > 8 || $IP5 < 1 ]] ; then P5=8.0D0 fi if [[ $IP6 > 6 || $IP6 < 1 ]] ; then P6=6.0D0 fi print "$P5 $P6" > $AXIS P7=${7:-YES} print << EOF Input file is: EOF ls -l ${P1} print P2FLAG=NO if [[ -a $P2 ]] ; then P2FLAG=YES fi if [[ $P2FLAG = YES ]] ; then print print DRXE1 Input file is: print ls -l $P2 print RXONAM=${P2##*/} RXONAM=${RXONAM%%.*}.rxo fi P3FLAG=NO if [[ -a $P3 ]] ; then P3FLAG=YES fi if [[ $P3FLAG = YES ]] ; then print print HX1 Input file is: print ls -l $P3 print HXONAM=${P3##*/} HXONAM=${HXONAM%%.*}.hxo fi print << EOF Steam Table: EOF ls -l $STEAM print print << EOF Running the code: EOF #set -o xtrace ls -l $CONTEMPT cksum $CONTEMPT #set +o xtrace print #set -o xtrace # # Run and time the CONTEMPT28 code. # # command line parameters: # 1: steam table input file # 2: HPGL output file # 3: PGD output file # 4: DRXE1 input file # 5: RXO file # 6: HXO file # 7: HX1 input file # 8: axis lengths scratch input file (*.AXIS.TEMP) # 9: scratch file location # stdin: $P1 input file # stdout: output file # # time ${CONTEMPT} \ ${STEAM} \ ${HPGL} \ ${PGD} \ ${P2} \ ${RXONAM} \ ${HXONAM} \ ${P3} \ ${AXIS} \ ${SYS_SCRATCH} < ${P1} > ${OUT} # # Type and delete temporary files. # BIGOUT=${OLDPWD}/${JOBNAM}.out if [[ -a ${OUT} ]] ; then cp ${OUT} $BIGOUT fi if [[ $P3FLAG = YES && -a ${HXONAM} ]] ; then echo "HXONAM"${HXONAM} print 1 >> $BIGOUT print >> $BIGOUT print HX1 OUTPUT FOLLOWS >> $BIGOUT print >> $BIGOUT cat ${HXONAM} >> $BIGOUT # rm ${HXONAM} fi if [[ $P2FLAG = YES && -a ${RXONAM} ]] ; then print 1 >> $BIGOUT print >> $BIGOUT print DRXE1 OUTPUT FOLLOWS >> $BIGOUT print >> $BIGOUT cat ${RXONAM} >> $BIGOUT # rm ${RXONAM} fi # # If there was HPGL output, copy it to the original working dir. # if [[ -a ${HPGL} ]] ; then cp ${HPGL} ${OLDPWD}/${JOBNAM}.hpgl # rm ${HPGL} fi # # Time to implement P7. If the delete flag is not set, copy # the files to the home directory. Otherwise, delete them. # [this strikes me as strange] # if [[ $P7 != YES ]] ; then if (( $IBAT = 0 )) ; then ps -l exit fi if [[ -a ${PGD} ]] ; then cp ${PGD} ${OLDPWD}/${JOBNAM}.pgd fi else if [[ -a ${PGD} ]] ; then # rm ${PGD} fi fi # # Miscellaneous cleanup. # Delete the SYS_SCRATCH directory completely. We created it # in this script, so we must remove it as well. It will go away # occasionally by order of the sysmgr anyway, but it's better to # not require the sysmgr to act. # # If there's a "core" file, say so, show it, and do not remove # anything. # OPWD=$OLDPWD if [[ -a core ]] ; then #set +o xtrace print Uh oh, a "core" file! Run away! ls -l core #set -o xtrace else cd ${SCRAT} # rm -r contempt28$$ fi # # Go back to the original default directory. # cd $OPWD exit