Commit 251f0d02 authored by François Fortin's avatar François Fortin
Browse files

merge with version 3.1.0

parent 822096fd
......@@ -10,7 +10,7 @@ http://documentation.wikia.com/wiki/METRo
To run METRo, you will need the following software packages:
* python 2.3
* g77
* gfortran
* SWIG
* Package python numarray version 0.9
* libxml2 (see further for the right version)
......@@ -21,7 +21,7 @@ To run METRo, you will need the following software packages:
=== Red hat | Mandriva | Debian (Knoppix, Ubuntu and other Debian based) ===
1. Install g77;
1. Install gfortran;
2. Be sure that you have python 2.3.0 or +.
3. Be sure that you have SWIG 1.3.20 or +.
4. Download the package numarray.
......@@ -44,7 +44,7 @@ To run METRo, you will need the following software packages:
=== Gentoo linux ===
Become root and
1. Install gcc with the compiler g77
1. Install gcc with the compiler gfortran
USE="fortran" emerge sys-devel/gcc
......@@ -88,7 +88,7 @@ Become root and
4. To verify your installation, in the directory
path_to_metro/bin
path_to_metro/usr/bin
do this command
......@@ -96,6 +96,6 @@ Become root and
if the file
path_to_metro/data/roadcast/roadcast_selftest.xml
path_to_metro/usr/share/metro/data/roadcast/roadcast_selftest.xml
was created successfully, your installation is working.
METRo README file
You are currently reading the README file of the release 3.0.4 (March 2007)
You are currently reading the README file of the release 3.1.0 (September 2007)
== What is METRo ? ==
......@@ -31,11 +31,13 @@ and the fortran).
Documentation can be found online at:
http://documentation.wikia.com/wiki/METRo
== Installing METRo ==
See man page in metro/doc/ directory.
See man page in metro/usr/share/man/man1/ directory.
METRo uses needs the following software:
* python 2.3 or +
* g77
* gfortran
* SWIG
* python numarray
* libxml2 & libxslt
......
METRo Developer README file
You are currently reading the Developer README file. For general information
about METRo please read the "README" file.
========================================
== Setting up development environment ==
========================================
init_devel.sh
-------------
You need to run the 'init_devel.sh' script to prepare your working directory.
If the script complain about the environment variable "PYTHON_INCLUDE":
you need to set it to a valid value. Usualy, it will be something like:
'export PYTHON_INCLUDE=/usr/include/pythonX.X' where the X's are the
version numbers. You only need to run the 'init_devel.sh' script one time.
* From now on, we assume the 'init_devel.sh' script has been run.
=======================
== Compiling "model" ==
=======================
Fortran model
-------------
To compile the Fortran model you will need to perform the following action:
1) cd src/model/
2) ../../scripts/do_macadam
======================
== Building package ==
======================
1) Change the METRo version number in the following files:
README
scripts/do_macadam
src/frontend/metro_config.py
2) Change realease date in the following files:
README
src/frontend/metro_config.py
2) Compile model:
compile the Fortran model (see == Compiling "model" ==)
3) Build Package
cd scripts/
./make_package.py
* You need a valid gpg key to be able to sign your package
#!/bin/sh
#
# METRo : Model of the Environment and Temperature of Roads
# METRo is Free and is proudly provided by the Government of Canada
# Copyright (C) 2006 Environment Canada
# Questions or bugs report: metro@ec.gc.ca
# METRo repository: https://gna.org/projects/metro/
# Documentation: http://documentation.wikia.com/wiki/METRo
#
#
# Code contributed by:
# Francois Fortin - Canadian meteorological center
#
# $LastChangedDate$
# $LastChangedRevision$
#
########################################################################
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# prepare development environment
echo "* create logging directory ( mkdir -p var/log/ )"
if [ ! -d var/log/ ]; then
mkdir -p var/log/
fi
echo ""
echo "* link to model ( src/frontend/model -> usr/share/metro/model )"
ln -sf ../../usr/share/metro/model src/frontend/model
echo ""
echo "* Checking for PYTHON_INCLUDE environment variable"
if [ ! -n "$PYTHON_INCLUDE" ] ; then
echo "----------------------------------------------------------"
echo "WARNING!"
echo "No PYTHON_INCLUDE defined."
echo "Please set environment variable PYTHON_INCLUDE to your"
echo "python include directory."
echo "Ex: export PYTHON_INCLUDE=\"/usr/local/include/python2.3\""
echo "----------------------------------------------------------"
echo ""
else
echo "PYTHON_INCLUDE="$PYTHON_INCLUDE
fi
echo ""
......@@ -34,11 +34,11 @@
progname=`basename $0`
METRO_VERSION=3.0.4
METRO_VERSION=3.1.0
if [[ $1 = clean ]]; then
echo "Cleaning last METro model build attempt if necessary..."
echo "* Cleaning last METro model build attempt if necessary..."
rm -f _macadam.so *.o macadam.py macadam_wrap.c
exit 0
fi
......@@ -49,7 +49,7 @@ error. Correct error and restart.\n\n"
trap 'echo -e $ERRMSG; exit 1' ERR
echo "Building METRo $METRO_VERSION model"
echo "* Building METRo $METRO_VERSION model"
if [ -n "$PYTHON_INCLUDE" ] ; then
if [ ! -d $PYTHON_INCLUDE ]; then
......@@ -71,14 +71,14 @@ else
echo ""
PYTHON_INC="-I/usr/include/python2.3/"
fi
echo "Python include path = "$PYTHON_INC
echo " Python include path = "$PYTHON_INC
echo "Using SWIG"
echo 'macadam.i :'
echo " Using SWIG"
echo ' macadam.i :'
swig -python macadam.i
echo "C compilation"
echo " C compilation"
gcc -c -fPIC macadam.c macadam_wrap.c $PYTHON_INC
if [ -z $FC ]; then
......@@ -97,18 +97,18 @@ if [ -z $FC ]; then
fi
fi
echo "Fortran compilation"
echo " Fortran compilation"
$FC -Wall -Wsurprising -W -c -fPIC lib_gen.f grille.f array2matrix.f initial.f coupla.f lib_therm.f flxsurfz.f balanc.f constPhys.f
echo "Link"
echo " Link"
$FC -shared macadam.o macadam_wrap.o lib_gen.o grille.o array2matrix.o initial.o coupla.o lib_therm.o flxsurfz.o balanc.o constPhys.o -lc -o _macadam.so
echo "Copying .so in ../frontend/model"
if [ ! -d ../frontend/model ]; then
mkdir ../frontend/model
fi
touch ../frontend/model/__init__.py
cp _macadam.so ../frontend/model
cp macadam.py ../frontend/model
echo " Copying .so in usr/share/metro/model"
#if [ ! -d ../../usr/share/metro/model ]; then
# mkdir ../../usr/share/metro/model
#fi
cp _macadam.so ../../usr/lib/metro/
cp macadam.py ../../usr/share/metro/model/
......@@ -34,6 +34,15 @@
#
#
#
# Every file in the source directories is listed separatly so that we don't
# include unwanted files. This way, we are forced to consider what goes in the
# package and what doesn't each time we make modifications. We don't blindly
# add a directory with all the temporary and test files and it helps us to keep
# clean the distribution package.
#
sPackage_list = \
"""
src/frontend/metro.py
......@@ -106,10 +115,6 @@ src/frontend/external_lib/Plist_config/__init__.py
src/frontend/external_lib/Plist_config/plist_reader.py
src/frontend/external_lib/Plist_config/plist_writer.py
src/frontend/external_lib/fpconst.py
src/frontend/external_lib/_numpy.so
src/frontend/external_lib/arrayfns.so
src/frontend/locale
src/model/array2matrix.f
src/model/balanc.f
......@@ -129,15 +134,18 @@ src/model/number.h
src/model/_macadam.so.prebuilt
src/model/macadam.py.prebuilt
doc
data
scripts/check_translation.py
scripts/copy_msgid_msgstr.py
scripts/create_mo.py
scripts/do_macadam
scripts/make_package.py
usr
README
LICENSE
INSTALL
setup.sh
"""
......@@ -216,16 +224,12 @@ sPackage_list = sPackage_list + " "
sPackage_list = string.replace(sPackage_list," " + sSvn_root_dir + "/ "," ")
sPackage_list = string.replace(sPackage_list," " + sSvn_root_dir + "/ "," ")
# copy setup.sh in root of package
shutil.copy2( sRoot_path + "/" + sSvn_root_dir + "/scripts/setup.sh",
sRoot_path + "/" + sSvn_root_dir + "/")
# copy model binary to lib
shutil.copy2( sRoot_path + "/" + sSvn_root_dir + "/src/frontend/model/_macadam.so",
shutil.copy2( sRoot_path + "/" + sSvn_root_dir + "/usr/lib/metro/_macadam.so",
sRoot_path + "/" + sSvn_root_dir + "/src/model/_macadam.so.prebuilt")
shutil.copy2( sRoot_path + "/" + sSvn_root_dir + "/src/frontend/model/macadam.py",
shutil.copy2( sRoot_path + "/" + sSvn_root_dir + "/usr/share/metro/model/macadam.py",
sRoot_path + "/" + sSvn_root_dir + "/src/model/macadam.py.prebuilt")
sPackage_list = sPackage_list + sSvn_root_dir + "/setup.sh "
#tar command
sTarCommand = "tar cjvf " + sPackage_path + "/metro-" + sVersion_number + \
......@@ -247,9 +251,6 @@ os.system(sSignCommand)
# cleanup
print "\n* Cleanup *"
print "remove '%s'" % (sRoot_path + "/" + sSvn_root_dir + "/setup.sh")
os.remove(sRoot_path + "/" + sSvn_root_dir + "/setup.sh")
print ""
print
print "* Package Creation Done *\n"
......
......@@ -39,11 +39,14 @@ trap 'echo -e $ERRMSG; exit 1' ERR
progname=`basename $0`
# Making sure we are in the directory where the script resides
cd `dirname $0`
installation_dir=`pwd`
metro_dir=metro
bCompile=0
sVerbose=""
# 'getopts' processes command line args to script.
......@@ -61,11 +64,12 @@ if [ -z $1 ]
# Exit and complain if no argument(s) given.
then
echo ""
echo "Usage: $progname [-c] destination_path"
echo "Usage: $progname [OPTION] destination_path"
echo ""
echo "-c : Will compile the METRo physic model instead of using"
echo " the provided binary. Need gfortran compiler."
echo ""
echo " the provided binary. Need gfortran compiler."
echo ""
echo "-v : Verbose"
echo ""
echo "The metro directory will be created in the destination_path"
echo ""
......@@ -75,15 +79,18 @@ then
fi
while getopts "c" Option
while getopts "cv" Option
do
case $Option in
c ) bCompile=1;;
v ) sVerbose=-v;;
* ) echo ""
echo "Usage: $progname [-c] destination_path"
echo "Usage: $progname [OPTION] destination_path"
echo ""
echo "-c : Will compile the METRo physic model instead of using"
echo " the provided binary. Need gfortran compiler."
echo " the provided binary. Need gfortran compiler."
echo ""
echo "-v : Verbose"
echo ""
echo "The metro directory will be created in the destination_path"
echo ""
......@@ -122,12 +129,14 @@ if ! locate libgfortran.so.1; then
echo "Could not find gfortran library on your system."
echo "METRo model will be recompiled."
echo "----------------------------------------------------------"
echo ""
bCompile=1
fi
echo ""
mkdir -p $destination_path/usr/share/metro/model/
mkdir -p $destination_path/usr/lib/metro/
if [ $bCompile == 1 ]; then
echo "* Building physic model..."
if [ ! -n "$PYTHON_INCLUDE" ] ; then
echo "----------------------------------------------------------"
echo "WARNING!"
......@@ -145,37 +154,53 @@ if [ $bCompile == 1 ]; then
cd $installation_dir
else
echo "* Use provided binary for physic model"
if [ ! -d $installation_dir/src/frontend/model ]; then
mkdir $installation_dir/src/frontend/model
fi
touch $installation_dir/src/frontend/model/__init__.py
cp $installation_dir/src/model/_macadam.so.prebuilt $installation_dir/src/frontend/model/_macadam.so
cp $installation_dir/src/model/macadam.py.prebuilt $installation_dir/src/frontend/model/macadam.py
cp $sVerbose src/model/macadam.py.prebuilt $destination_path/usr/share/metro/model/macadam.py
cp $sVerbose src/model/_macadam.so.prebuilt $destination_path/usr/lib/metro/_macadam.so
fi
echo ""
echo "* Creating destination directory: "$destination_path
mkdir -p $destination_path
echo ""
echo "* Copying METRo files..."
echo ""
echo "* Copying METRo programs files to: "$destination_path/bin
cp -r src/frontend $destination_path/bin
echo "* Copying METRo data exemples to: "$destination_path/data
cp -r data $destination_path/
echo "* Copying METRo data files to: "$destination_path/usr
find usr -not -regex ".*\.po" | cpio -pmud --quiet $sVerbose $destination_path/
echo "* Copying METRo programs files to: "$destination_path/usr/share/metro
cp $sVerbose src/frontend/*.py $destination_path/usr/share/metro
cp $sVerbose -r src/frontend/data_module $destination_path/usr/share/metro
cp $sVerbose -r src/frontend/executable_module $destination_path/usr/share/metro
cp $sVerbose -r src/frontend/external_lib $destination_path/usr/share/metro
cp $sVerbose -r src/frontend/toolbox $destination_path/usr/share/metro
#echo "* Copying METRo model python file to: "$destination_path/usr/share/metro/model
#if [ $bCompile == 1 ]; then
# cp $sVerbose src/model/macadam.py $destination_path/usr/share/metro/model/
#else
# cp $sVerbose src/model/macadam.py.prebuilt $destination_path/usr/share/metro/model/macadam.py
#fi
#echo "* Copying METRo model to: "$destination_path/usr/lib/metro
#if [ $bCompile == 1 ]; then
# cp $sVerbose src/model/_macadam.so $destination_path/usr/lib/metro/
#else
# cp $sVerbose src/model/_macadam.so.prebuilt $destination_path/usr/lib/metro/_macadam.so
#fi
echo "* Copying METRo doc files to: "$destination_path/usr/share/doc/metro/
cp $sVerbose INSTALL LICENSE README $destination_path/usr/share/doc/metro/
#echo "* Copying METRo external lib to: "$destination_path/bin/external_lib/
#cp lib/* $destination_path/bin/external_lib/
echo "* Creating METRo log directory: "$destination_path/var/log
mkdir -p $destination_path/var/log
echo "* Copying METRo documentation to: "$destination_path/doc
cp -r doc $destination_path/
cd $installation_dir
echo "* Changing name of METRo executable:"
echo " $destination_path/bin/metro.py -> $destination_path/bin/metro"
mv $destination_path/bin/metro.py $destination_path/bin/metro
echo "* Make link to METRo executable:"
echo " $destination_path/usr/bin/metro -> $destination_path/usr/share/metro/metro.py"
ln -sf ../share/metro/metro.py $destination_path/usr/bin/metro
echo ""
echo "---------------------------------------------------"
......@@ -187,10 +212,10 @@ echo ""
echo "To test the installation of METRo"
echo "---------------------------------"
echo "Go into the METRo directory:"
echo " 'cd $destination_path/bin/'"
echo " 'cd $destination_path/usr/bin/'"
echo "Launch METRo selftest:"
echo " 'python metro --selftest'"
echo "Compare the files:"
echo " 'diff ../data/roadcast/roadcast_selftest.xml ../data/roadcast/roadcast_selftest_reference.xml'"
echo " 'diff ../share/metro/data/roadcast/roadcast_selftest.xml ../share/metro/data/roadcast/roadcast_selftest_reference.xml'"
echo "They should be identical except for the production-date."
......@@ -122,11 +122,13 @@ class Metro_postprocess_subsample_roadcast(Metro_postprocess):
return i
# Something bad hapened.
sMessage = _("Unable to determine the first time of roadcast!")
metro_logger.print_message(metro_logger.LOGGER_MSG_STOP,\
sMessage)
def __subsample_roadcast(self, roadcast, nFirstRoundTimestep):
# Get all roadcast items
......
#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
#
# METRo : Model of the Environment and Temperature of Roads
......@@ -52,8 +54,21 @@ sys.stdout = codecs.lookup('ISO-8859-1')[-1](sys.stdout)
# ajout du repertoire a la liste de repertoire
# dans lequelle on peut faire un import
pathInclude = sys.path[0] + '/external_lib' # a cause de arrayfns et _numpy
pathInclude = sys.path[0] + '/external_lib' # a cause de Plist_config/PListReader.py
sys.path.append(pathInclude)
pathInclude = sys.path[0] + '/../../lib/metro/external_lib' # a cause de arrayfns et _numpy (installed package)
sys.path.append(pathInclude)
pathInclude = sys.path[0] + '/../../usr/lib/metro/external_lib' # a cause de arrayfns et _numpy (devel)
sys.path.append(pathInclude)
pathInclude = sys.path[0] + '/../../lib/metro' # a cause de _macadam (installed package)
sys.path.append(pathInclude)
pathInclude = sys.path[0] + '/../../usr/lib/metro' # a cause de _macadam (devel)
sys.path.append(pathInclude)
pathInclude = sys.path[0] + '/executable_module'
sys.path.append(pathInclude)
......
......@@ -68,8 +68,8 @@ METRO_CONFIG_GETTEXT_PACKAGE = "metro_config"
METRO_CONFIG_GETTEXT_LOCALEDIR = "./locale"
# Constant definition
CFG_METRO_VERSION="3.0.4"
CFG_METRO_DATE="2007-03-09"
CFG_METRO_VERSION="3.1.0"
CFG_METRO_DATE="2007-09-03"
# Origin of the value (command line, config file, hardcoded value,
......@@ -344,7 +344,7 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
if o in ("-h", "--help"):
sMetro_root_path = metro_util.get_metro_root_path()
sMetro_man_path = sMetro_root_path + "/doc/metro.1"
sMetro_man_path = sMetro_root_path + "/usr/share/man/man1/metro.1"
print _("see man page: 'man %s'") % sMetro_man_path
sys.exit()
......@@ -392,16 +392,16 @@ def save_command_line_parameter( lArgv, sShort_opt, lLong_opt ):
dConf['FILE_FORECAST_IN_FILENAME'] = \
metro_util.get_metro_root_path() +\
"/data/forecast/forecast_selftest.xml"
"/usr/share/metro/data/forecast/forecast_selftest.xml"
dConf['FILE_OBSERVATION_FILENAME'] = \
metro_util.get_metro_root_path() +\
"/data/observation/observation_selftest.xml"
"/usr/share/metro/data/observation/observation_selftest.xml"
dConf['FILE_STATION_FILENAME'] = \
metro_util.get_metro_root_path() +\
"/data/station/station_selftest.xml"
"/usr/share/metro/data/station/station_selftest.xml"
dConf['FILE_ROADCAST_FILENAME'] = \
metro_util.get_metro_root_path() +\
"/data/roadcast/roadcast_selftest.xml"
"/usr/share/metro/data/roadcast/roadcast_selftest.xml"
dConf['INIT_LOGGER_VERBOSE_LEVEL'] = \
metro_logger.LOGGER_VERBOSE_LEVEL_DEBUG
......@@ -532,7 +532,7 @@ def set_default_value( ):
'COMMENTS':_("current version for METRo configuration file")}
dConfig['FILE_LOGGER_FILENAME'] = \
{'VALUE' :"log_metro",
{'VALUE' :metro_util.get_metro_root_path() + "/var/log/metro.log",
'FROM' :CFG_HARDCODED,
'COMMENTS':_("logger filename")}
......
......@@ -57,7 +57,7 @@ lCloudsNight2 = [214.7, 226.2, 234.8, 243.4, 250.7, 259.2, 270.9, 280.9, 298.4]
# QA & QC for observation
nRoadTemperatureMin = -40
nRoadTemperatureHigh = 80
nSubSurRoadTmpHigh = 40
nSubSurRoadTmpHigh = 80
nSubSurRoadTmpMin = -40
nAirTempHigh = 50
nAirTempMin = -60
......@@ -87,4 +87,3 @@ nNL = 11520
# METRo output
# Indicates at what will be the time interval between 2 field in the roadcast
nMinutesForOutput = 20
......@@ -85,9 +85,12 @@ def get_metro_root_path( ):
sRoot_path = string.join(lPath[:-2],"/")
elif lPath[len(lPath)-1] == "bin":
sRoot_path = string.join(lPath[:-1],"/")
elif lPath[len(lPath)-1] == "metro":
sRoot_path = string.join(lPath[:-3],"/")
else:
sError = _("The executable 'metro.py' must be in one of the following directory:\n") +\
_("metro_directory/src/frontend' or 'metro_directory/bin'.\n") +\
_("metro_directory/src/frontend' or 'metro_directory/usr/lib/metro'.\n") +\
_("The following path is not valid: '%s'.\n\n") % (sys.path[0]) +\
_("Aborting execution of METRo.\n")
print sError
......@@ -102,8 +105,8 @@ def get_exec_root_path( ):
# Passe pas belle pour pouvoir utiliser la fonction get_metro_root_path
# Ca permet de definir le underscore pour la traduction avec gettext.
#########
t = gettext.translation('metro_util', get_exec_root_path() +\
'/locale')
t = gettext.translation('metro_util', get_metro_root_path() +\
'/usr/share/locale')
_ = t.gettext
......@@ -631,8 +634,8 @@ def validate_version_number(sVersion, sMin_version, sMax_version ):
# Miguel Tremblay November 8th 2004
#####################################################
def init_translation(sFilename):
t = gettext.translation(sFilename, get_exec_root_path() +\
'/locale')
t = gettext.translation(sFilename, get_metro_root_path() +\
'/usr/share/locale')
_t_ = t.gettext
return _t_
......
......@@ -89,7 +89,7 @@ def generate_dtd_catalog( ):
sCatalog += "\n"
sMetro_root_path = metro_util.get_metro_root_path()
sMetro_catalog_path = sMetro_root_path + "/data/DTD/"
sMetro_catalog_path = sMetro_root_path + "/usr/share/metro/data/DTD/"
sCatalog += genxml_public_catalog_entry(
"-//Apple Computer//DTD PLIST 1.0//EN",
......