|
| 1 | +# Copyright (c) 2018 The University of Notre Dame |
| 2 | +# Copyright (c) 2018 The Regents of the University of California |
| 3 | +# |
| 4 | +# Redistribution and use in source and binary forms, with or without modification, |
| 5 | +# are permitted provided that the following conditions are met: |
| 6 | +# |
| 7 | +# 1. Redistributions of source code must retain the above copyright notice, this |
| 8 | +# list of conditions and the following disclaimer. |
| 9 | +# |
| 10 | +# 2. Redistributions in binary form must reproduce the above copyright notice, this |
| 11 | +# list of conditions and the following disclaimer in the documentation and/or other |
| 12 | +# materials provided with the distribution. |
| 13 | + |
| 14 | +# 3. Neither the name of the copyright holder nor the names of its contributors may |
| 15 | +# be used to endorse or promote products derived from this software without specific |
| 16 | +# prior written permission. |
| 17 | + |
| 18 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 19 | +# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 20 | +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT |
| 21 | +# SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 22 | +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED |
| 23 | +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | +# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 25 | +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 26 | +# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 27 | +# SUCH DAMAGE. |
| 28 | + |
| 29 | +# Contributors: |
| 30 | +# Written by Peter Sempolinski, for the Natural Hazard Modeling Laboratory, director: Ahsan Kareem, at Notre Dame |
| 31 | + |
| 32 | +set -x |
| 33 | + |
| 34 | +${AGAVE_JOB_CALLBACK_RUNNING} |
| 35 | + |
| 36 | +export STARTINGDIR=`pwd` |
| 37 | + |
| 38 | +export PYTHONDIR=$STARTINGDIR/python/CFDexec |
| 39 | +export PYTHONPATH=$PYTHONPATH:$STARTINGDIR/python |
| 40 | + |
| 41 | +unzip templates.zip |
| 42 | +export TEMPLATER_FOLDER=$STARTINGDIR/templates |
| 43 | + |
| 44 | +PARENTDIR="${directory}" |
| 45 | +TASKSTAGE="${stage}" |
| 46 | +export EXTRAFILE="${file_input}" |
| 47 | + |
| 48 | +function dump_logs { |
| 49 | + echo "Starting cwe cleanup" |
| 50 | + |
| 51 | + cd $STARTINGDIR |
| 52 | + mkdir logs |
| 53 | + |
| 54 | + mv .agave.log logs |
| 55 | + mv *.err logs/cwe-serial.err |
| 56 | + mv *.out logs/cwe-serial.out |
| 57 | + mv *.log logs |
| 58 | + |
| 59 | + if [ -f $EXTRAFILE ] |
| 60 | + then |
| 61 | + rm -rf $EXTRAFILE |
| 62 | + fi |
| 63 | + |
| 64 | + rm -rf $TEMPLATER_FOLDER |
| 65 | + echo "$1" > .exit |
| 66 | + exit $1 |
| 67 | +} |
| 68 | + |
| 69 | +#Debug: output all inputs |
| 70 | +echo "dest is $PARENTDIR" |
| 71 | +echo "stage is $TASKSTAGE" |
| 72 | + |
| 73 | +cp -f ${directory}/.caseParams .varStore |
| 74 | + |
| 75 | +export DATA_FOLDER=`python $PYTHONDIR/Templater.py getdatafolder` |
| 76 | +STOP=$? |
| 77 | +if [ $STOP -ne 0 ] |
| 78 | +then |
| 79 | + echo "Unable to retrive data folder path" |
| 80 | + dump_logs $STOP |
| 81 | +fi |
| 82 | + |
| 83 | +SCRIPT_FILE=`python $PYTHONDIR/Templater.py getscript $TASKSTAGE` |
| 84 | + |
| 85 | +STOP=$? |
| 86 | +if [ $STOP -ne 0 ] |
| 87 | +then |
| 88 | + echo "Unable to retrive script name." |
| 89 | + dump_logs $STOP |
| 90 | +fi |
| 91 | + |
| 92 | +LAST_STAGE=`python $PYTHONDIR/Templater.py getlaststage $TASKSTAGE` |
| 93 | + |
| 94 | +STOP=$? |
| 95 | +if [ $STOP -ne 0 ] |
| 96 | +then |
| 97 | + echo "Unable to retrive last stage name." |
| 98 | + dump_logs $STOP |
| 99 | +fi |
| 100 | + |
| 101 | +echo $LAST_STAGE |
| 102 | + |
| 103 | +if [ $LAST_STAGE != "None" ] |
| 104 | +then |
| 105 | + mv ${directory}/$LAST_STAGE/* . |
| 106 | + mv -f ${directory}/.caseParams .varStore |
| 107 | + rm -rf logs |
| 108 | + rm -f .exit |
| 109 | +fi |
| 110 | + |
| 111 | +rm -rf ${directory} |
| 112 | +if [ -d "stats" ] |
| 113 | +then |
| 114 | + python $PYTHONDIR/Templater.py paramset -s stats |
| 115 | +else |
| 116 | + python $PYTHONDIR/Templater.py paramset |
| 117 | +fi |
| 118 | + |
| 119 | +chmod 700 $SCRIPT_FILE |
| 120 | + |
| 121 | +$SCRIPT_FILE |
| 122 | + |
| 123 | +STOP=$? |
| 124 | +if [ $STOP -ne 0 ] |
| 125 | +then |
| 126 | + echo "Error in cwe task process" |
| 127 | + dump_logs $STOP |
| 128 | +fi |
| 129 | + |
| 130 | +if [ -d "stats" ] |
| 131 | +then |
| 132 | + python $PYTHONDIR/Templater.py paramset -s stats |
| 133 | +fi |
| 134 | + |
| 135 | +STOP=$? |
| 136 | +if [ $STOP -ne 0 ] |
| 137 | +then |
| 138 | + echo "Error in cwe task process" |
| 139 | + dump_logs $STOP |
| 140 | +fi |
| 141 | + |
| 142 | +echo "CWE task process complete." |
| 143 | +dump_logs 0 |
| 144 | + |
0 commit comments