/usr/lib/x86_64-linux-gnu/metview/mv_flextra_run is in metview 5.0.0~beta.1-1build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | #!/bin/bash
# **************************** LICENSE START ***********************************
#
# Copyright 2012 ECMWF and INPE. This software is distributed under the terms
# of the Apache License version 2.0. In applying this license, ECMWF does not
# waive the privileges and immunities granted to it by virtue of its status as
# an Intergovernmental Organization or submit itself to any jurisdiction.
#
# ***************************** LICENSE END ************************************
# ---------------------------------------------------------
# Script to run FLEXTRA from within Metview
# ---------------------------------------------------------
set -x
print_err()
{
echo ${text_ERR} $* >> "${f_LOG}"
}
text_ERR="Script `basename $0` FAILED> "
#Get args
if [ $# -ne 5 ] ; then
echo "Invalid number of arguments specified for script $0! (" $# " instead of 5)"
exit 1
fi
d_WORK=$1
f_EXE=$2
type_FLEXTRA=$3
f_OUTPUT=$4
f_LOG=$5
#Define executable
if [ "$f_EXE" = "_UNDEF_" ] ; then
exe_FLEXTRA=${MV_FLEXTRA_EXE}
else
exe_FLEXTRA=${f_EXE}
fi
#-------------------------------
# Go to working directory
#-------------------------------
if [ ! -d $d_WORK ] ; then
print_err "No working directory found: " $d_WORK
exit 1
fi
cd $d_WORK
#-------------------------------
# Checks
#-------------------------------
if [ $type_FLEXTRA != "NORMAL" -a $type_FLEXTRA != "CET" -a $type_FLEXTRA != "FLIGHT" ] ; then
print_err "Invalid type specified:" $type_FLEXTRA
print_err "Type must be: NORMAL, CET or FLIGHT!"
exit 1
fi
if [ x$exe_FLEXTRA = "x" ] ; then
print_err "No FLEXTRA executable is defined. Please define it via env variable MV_FLEXTRA_EXE."
exit 1
fi
if [ ! -f $exe_FLEXTRA ] ; then
print_err "No FLEXTRA executable found: " $exe_FLEXTRA
exit 1
fi
if [ ! -x $exe_FLEXTRA ] ; then
print_err "FLEXTRA executable cannot be run! Permission is missing. " $exe_FLEXTRA
exit 1
fi
f_PATHNAMES=pathnames
if [ ! -r $f_PATHNAMES ] ; then
print_err "FLEXTRA pathnames file does not exist or cannot be read!"
exit 1
fi
echo "Content of pathnames file:"
cat $f_PATHNAMES
#-------------------------------
#Run flextra
#-------------------------------
$exe_FLEXTRA >${f_LOG} 2>&1
outCode=$?
#-----------------------------------
# Check log
#-----------------------------------
if [ -f ${f_LOG} ] ; then
if [ `grep -c -i WARNING $f_LOG` -ne 0 ] ; then
outCode=255
elif [ `grep -c -i ERROR $f_LOG` -ne 0 ] ; then
outCode=1
elif [ $outCode -ne 0 ] ; then
outCode=$outCode
fi
fi
#-----------------------------------
# Concatenate the resulting files
#-----------------------------------
touch $f_OUTPUT
resCnt=0
if [ ${type_FLEXTRA} = "NORMAL" ] ; then
for f in `ls` ; do
if [ `echo $f | cut -c 1-3` = "TI_" ] ; then
cat $f >> $f_OUTPUT
resCnt=$(($resCnt+1))
fi
done
for f in `ls` ; do
if [ `echo $f | cut -c 1-2` = "T_" ] ; then
cat $f >> $f_OUTPUT
resCnt=$(($resCnt+1))
fi
done
elif [ ${type_FLEXTRA} = "CET" ] ; then
for f in `ls` ; do
if [ `echo $f | cut -c 1-5` = "CETI_" ] ; then
cat $f >> $f_OUTPUT
resCnt=$(($resCnt+1))
fi
done
for f in `ls` ; do
if [ `echo $f | cut -c 1-4` = "CET_" ] ; then
cat $f >> $f_OUTPUT
resCnt=$(($resCnt+1))
fi
done
elif [ ${type_FLEXTRA} = "FLIGHT" ] ; then
for f in `ls` ; do
if [ `echo $f | cut -c 1-8` = "FLIGHTI_" ] ; then
cat $f >> $f_OUTPUT
resCnt=$(($resCnt+1))
fi
done
for f in `ls` ; do
if [ `echo $f | cut -c 1-7` = "FLIGHT_" ] ; then
cat $f >> $f_OUTPUT
resCnt=$(($resCnt+1))
fi
done
fi
if [ $resCnt -gt 1 ] ; then
cat $resCnt > "multipleRes"
fi
exit $outCode
|