/usr/lib/x86_64-linux-gnu/metview/mv_scm_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 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | #!/bin/bash
# **************************** LICENSE START ***********************************
#
# Copyright 2013 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 SCM from within Metview
# ---------------------------------------------------------
set -x
print_err()
{
echo ${text_ERR} $* >> "${f_LOG}"
}
text_ERR="Script `basename $0` FAILED> "
#Get args
if [ $# -ne 9 ] ; then
echo "Invalid number of arguments specified for script $0 ! (" $# " instead of 9)"
exit 1
fi
d_WORK=$1
f_EXE=$2
NLEV=$3
f_INPUT=$4
f_NAMELIST=$5
f_VTABLE=$6
d_RCLIM=$7
f_LOG=$8
f_RES=$9
if [ "$f_EXE" = "_UNDEF_" ] ; then
exe_SCM=${MV_SCM_EXE}
else
exe_SCM=${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 [ x"$exe_SCM" = "x" ] ; then
print_err "No SCM executable is defined. Please define it via env variable MV_SCM_EXE."
exit 1
fi
if [ ! -f "$exe_SCM" ] ; then
print_err "No SCM executable found: " $exe_SCM
exit 1
fi
if [ ! -x "$exe_SCM" ] ; then
print_err "SCM executable cannot be run! Permission is missing. " $exe_SCM
exit 1
fi
if [ ! -f "$f_INPUT" ] ; then
print_err "No SCM input profile file is found: " $f_INPUT
exit 1
fi
if [ ! -r "$f_INPUT" ] ; then
print_err "SCM input profile file cannot be read! Permission is missing. " $f_INPUT
exit 1
fi
if [ ! -f "$f_NAMELIST" ] ; then
print_err "No SCM namelist file is found: " $f_NAMELIST
exit 1
fi
if [ ! -r "$f_NAMELIST" ] ; then
print_err "SCM namelist file cannot be read! Permission is missing. " $f_NAMELIST
exit 1
fi
if [ "$f_VTABLE" = "_UNDEF_" ] ; then
SCM_VTABLE_FILES_PATH="${SCM_VTABLE_FILES_PATH:=/home/graphics/cgx/model_files/scm}"
f_VTABLE="${SCM_VTABLE_FILES_PATH}/vtable_L${NLEV}"
fi
if [ ! -f "$f_VTABLE" ] ; then
print_err "No SCM vtable file is found: " $f_VTABLE
exit 1
fi
if [ ! -r "$f_VTABLE" ] ; then
print_err "SCM vtable file cannot be read! Permission is missing. " $f_VTABLE
exit 1
fi
if [ "$d_RCLIM" = "_UNDEF_" ] ; then
SCM_RCLIM_FILES_PATH="${SCM_RCLIM_FILES_PATH:=/home/graphics/cgx/model_files/scm}"
d_RCLIM=${SCM_RCLIM_FILES_PATH}
fi
if [ ! -d "$d_RCLIM" ] ; then
print_err "No directory of SCM climatology data is found: " $d_RCLIM
exit 1
fi
if [ ! -r "$d_RCLIM" ] ; then
print_err "Directory of SCM climatology data cannot be read! Permission is missing. " $d_RCLIM
exit 1
fi
#-------------------------------
# Prepare input profile
#-------------------------------
ln -sf "${f_INPUT}" scm_in.nc
#-------------------------------
# Prepare namelist
#-------------------------------
ln -sf "${f_NAMELIST}" namelist
ln -fs "${f_VTABLE}" vtable
cpp -P -Dnew_NFLEVG=${NLEV} -Dnew_NCEXTR=${NLEV} namelist > fort.4
#-------------------------------
# Prepare climatology data
#-------------------------------
for cf in `ls "$d_RCLIM"` ; do
f_cf="${d_RCLIM}"/$cf
if [ -r "${f_cf}" -a x`echo $cf | cut -c 1-8` != x"vtable_L" ] ; then
ln -sf "${f_cf}" .
fi
done
#-------------------------------
#Run SCM
#-------------------------------
# temporary fix (April 2015) until the classroom machines are upgraded
if [ ${OS_VERSION} = "opensuse113" ] ; then
LD_LIBRARY_PATH="/home/rd/openifs/software/grib_api/1.11.0/grib_api-gcc-4.8.1-opt/lib:${LD_LIBRARY_PATH}"
fi
$exe_SCM > "${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
#-----------------------------------
# Check results
#-----------------------------------
if [ ! -f progvar.nc ] ; then
print_err "SCM ouput file \"progvar.nc\" was not generated!"
exit 1
fi
if [ ! -f diagvar.nc ] ; then
print_err "SCM ouput file \"diagvar.nc\" was not generated!"
exit 1
fi
if [ ! -f diagvar2.nc ] ; then
print_err "SCM ouput file \"diagvar2.nc\" was not generated!"
exit 1
fi
cp -f progvar.nc "${f_RES}"
exit $outCode
|