awips2/nativeLib/ohd.var/scripts/run_SSHP_var
root a02aeb236c Initial revision of AWIPS2 11.9.0-7p5
Former-commit-id: 06a8b51d6d [formerly 64fa9254b946eae7e61bbc3f513b7c3696c4f54f]
Former-commit-id: 9f19e3f712
2012-01-06 08:55:05 -06:00

69 lines
2.2 KiB
Bash

#!/bin/ksh
# File name: run_var_controller
# Author : Varalakshmi Rajaram
# This allows you to run this script from outside of ./bin
RUN_FROM_DIR=`dirname $0`
# set up SOME environment variables for WHFS applications
. $RUN_FROM_DIR/../../set_hydro_env
# set java classpath
export CLASSPATH=$DB_DRIVER_PATH:$WHFS_BIN_DIR/sshp_var.jar:$CLASSPATH
DATA_DIR=$WHFS_LOCAL_DATA_DIR
if [[ $# -lt 1 ]]
then
CUR_TIME=CURRENT_TIME
else
CUR_TIME=$1
fi
#set the various directory and log file names
VARCONTROLLER_LOG_DIR=$DATA_DIR/log/var
VARCONTROLLER_LOG=VarAssimilationController.log
VAR_INPUT_DIR=$DATA_DIR/var/input/
VAR_OUTPUT_DIR=$DATA_DIR/var/output
#VAR_LOG is the hard-coded name for the output for the FORTRAN code
VAR_LOG=$VAR_OUTPUT_DIR/log_var
VAR_PARAM_DIR=$VAR_INPUT_DIR/param/
VAR_SEGMENTS_FILE=list_of_segments
VAR_RUNSCRIPT=$WHFS_BIN_DIR/run_var_assimilator
VAR_STDOUT_LOG=$VARCONTROLLER_LOG_DIR/VAR_stdout_stderr.log
#set a particular log file as the main log file to be trimmed.
#all the rest get deleted and cleaned up in other ways
LOGFILE=$VARCONTROLLER_LOG_DIR/$VARCONTROLLER_LOG
# ensure that only 1 instance of this script runs on a machine
AMIRUNNING_DIR=$VARCONTROLLER_LOG_DIR
. /awips/hydroapps/public/bin/amirunning
if [[ $AmIRunning = "yes" ]]
then
messageDate=`date -u '+%Y/%m/%d %k:%M:%S.XXX'`
echo $messageDate: Startup cancelled because of prior running instance >> $LOGFILE
exit 1
fi
# trim the regular log file
TEMP_TRIM_FILE=$LOGFILE.trimmed
tail -50000 $LOGFILE > $TEMP_TRIM_FILE
mv $TEMP_TRIM_FILE $LOGFILE
#trim the stdout/stderr log file
TEMP_TRIM_FILE=$VAR_STDOUT_LOG.trimmed
tail -50000 $VAR_STDOUT_LOG > $TEMP_TRIM_FILE
mv $TEMP_TRIM_FILE $VAR_STDOUT_LOG
# we don't need this to be kept
rm -f $VARCONTROLLER_LOG_DIR/stdout_fortran_var.log
#Execute the Var Controller
$SYS_JAVA_DIR/bin/java ohd.hseb.sshp.var.VarController $JDBCURL "$CUR_TIME" $VARCONTROLLER_LOG_DIR $VARCONTROLLER_LOG $VAR_INPUT_DIR $VAR_OUTPUT_DIR $VAR_RUNSCRIPT $VAR_SEGMENTS_FILE $VAR_LOG >> $VAR_STDOUT_LOG 2>&1
#$SYS_JAVA_DIR/bin/java ohd.hseb.sshp.var.VarController $JDBCURL "$CUR_TIME" $VARCONTROLLER_LOG_DIR $VARCONTROLLER_LOG $VAR_INPUT_DIR $VAR_OUTPUT_DIR $VAR_RUNSCRIPT $VAR_SEGMENTS_FILE $VAR_LOG
exit