Commit 5736026c authored by Agrineer.org's avatar Agrineer.org

Initial commit

parents
# Dockerfile for Agrineer.org's WRF_container image
# Copyright (C) 2018-2019 IndieCompLabs, LLC.
#
# 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 3 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
# or visit https://www.gnu.org/licenses/gpl-3.0-standalone.htm
# get base Mint image
FROM linuxmintd/mint19-amd64
MAINTAINER Scott L. Williams
# get preliminary goodies
# requests may be redundant but they get sorted out
RUN apt-get -y update \
&& apt-get -y dist-upgrade \
&& apt-get -y install \
apt-utils \
bash-completion \
cron \
curl \
emacs \
iputils-ping \
net-tools \
time \
tzdata \
unzip \
wget \
vim-common \
vim-tiny \
zip \
&& apt-get -y autoremove
# get WRF dependencies
RUN apt-get -y install \
build-essential \
csh \
gfortran \
h5utils \
hdf5-helpers \
hdf5-tools \
hdfview \
libhdf5-dev \
libhdf5-mpich-dev \
libnetcdf-dev \
libnetcdff-dev \
libpng-dev \
mpich \
ncview \
ncl-ncarg \
netcdf-bin \
python3-gdal \
python3-netcdf4 \
wget \
zlib1g-dev
# *** ADJUST TIME ZONE ***
# *** ENTER YOUR TIME ZONE HERE ***
RUN rm /etc/localtime && ln -s /usr/share/zoneinfo/America/Denver /etc/localtime
# compile and install libjasper from source since
# it appears to no longer be available as a package from Debian/Ubuntu
WORKDIR /usr/local/src
RUN curl -SL http://www.ece.uvic.ca/~frodo/jasper/software/jasper-1.900.2.tar.gz | tar zx
WORKDIR /usr/local/src/jasper-1.900.2
RUN ./configure \
&& make \
&& make install
# create agrineer user and start to populate directory
RUN useradd -d /home/agrineer -m agrineer -s /bin/bash
RUN rm -rf /home/agrineer
ADD agrineer /home/agrineer
WORKDIR /home/agrineer/wrf
# get UCAR-BSD License and place in /home/agrineer/wrf
RUN curl -SL https://ral.ucar.edu/sites/default/files/public/projects/ncar-docker-wrf/ucar-bsd-3-clause-license.pdf > UCAR-BSD-3-Clause-License.pdf
# get WRF and WPS sources
RUN curl -SL http://www2.mmm.ucar.edu/wrf/src/WRFV4.0.TAR.gz | tar zx
RUN curl -SL http://www2.mmm.ucar.edu/wrf/src/WPSV4.0.TAR.gz | tar zx
# build WRF first
WORKDIR WRF
# modify ./Registry/Registry.EM_COMMON for
# additional data on ET and soil moisture
# not used for our calculation but for comparisons
RUN sed -i 's/state real potevp ij dyn_em 1 - r /state real potevp ij dyn_em 1 - rh/' ./Registry/Registry.EM_COMMON
RUN sed -i 's/state real MAVAIL ij misc 1 - r /state real MAVAIL ij misc 1 - rh/' ./Registry/Registry.EM_COMMON
RUN sed -i 's/state real SFCEVP ij misc 1 - r /state real SFCEVP ij misc 1 - rh/' ./Registry/Registry.EM_COMMON
RUN cp ../run_wrf_configure .
# set up environment variables and build WRF
RUN export NETCDF=/usr \
&& export NETCDF_classic=1 \
&& export JASPERINC=/usr/local/include \
&& export JASPERLIB=/usr/local/lib \
&& ./clean -a \
&& ./run_wrf_configure \
&& sed -i 's/$I_really_want_to_output_grib2_from_WRF = "FALSE"/$I_really_want_to_output_grib2_from_WRF = "TRUE"/' ./arch\/Config.pl \
&& sed -i 's/-L$(WRF_SRC_ROOT_DIR)\/external\/io_netcdf -lwrfio_nf -L\/usr\/lib/-L$(WRF_SRC_ROOT_DIR)\/external\/io_netcdf -lwrfio_nf -L\/usr\/lib -lnetcdff -lnetcdf /' ./configure.wrf \
&& ./compile em_real
# next build WPS
WORKDIR ../WPS
RUN cp ../run_wps_configure .
RUN export NETCDF=/usr \
&& export NETCDF_classic=1 \
&& export NCARG_ROOT=/usr \
&& export JASPERINC=/usr/local/include \
&& export JASPERLIB=/usr/local/lib \
&& ./clean -a \
&& ./run_wps_configure \
&& sed -i 's/-L$(NETCDF)\/lib /-L$(NETCDF)\/lib -lnetcdff /' ./configure.wps \
&& ./compile
# populate geo directories
WORKDIR /home/agrineer/wrf
RUN curl -SL http://www2.mmm.ucar.edu/wrf/src/wps_files/geog_high_res_mandatory.tar.gz | tar zx
# populate sector geos
RUN ./sector_geos
# change agrineer files ownership to agrineer
# takes a really long time
RUN chown -R agrineer.agrineer /home/agrineer
# These programs are free software; you can redistribute then and/or modify
# them under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# These programs are distributed in the hope that they 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
# or visit https://www.gnu.org/licenses/gpl-3.0-standalone.html
This diff is collapsed.
#!/bin/bash
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
export PATH=/home/agrineer/bin:$PATH
#!/bin/bash
source ~/.bash_profile
#!/bin/sh
# bourne shell script to run wrf cron jobs
HOME=/home/agrineer/wrf
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
export NCARG_ROOT=/usr/local/ncarg
export MP_STACK_SIZE=64000000
ulimit -s unlimited
# run with today's date
if [ $# -eq 1 ];
then
$HOME/scripts/run_wrfgfs.py -s $1 -b 06 -d $HOME/gfs_0.25 > $HOME/log/$1.log 2>&1 &
fi
# run with given date
if [ $# -eq 2 ];
then
$HOME/scripts/run_wrfgfs.py -s $1 -b 06 -d $HOME/gfs_0.25 -r $2 > $HOME/log/$1.log 2>&1 &
fi
45 03 * * * (export LD_LIBRARY_PATH=/usr/lib; /home/agrineer/wrf/scripts/getdata_gfs.py)
45 04 * * * ( /home/agrineer/bin/run_wrf WCONUS_B1 )
48 04 * * * ( /home/agrineer/bin/run_wrf WCONUS_B2 )
30 09 * * * ( /home/agrineer/bin/run_wrf WCONUS_C1 )
33 09 * * * ( /home/agrineer/bin/run_wrf WCONUS_C2 )
15 14 * * * ( /home/agrineer/bin/run_wrf WCONUS_B3 )
18 14 * * * ( /home/agrineer/bin/run_wrf WCONUS_B4 )
30 19 * * * ( /home/agrineer/bin/run_wrf WCONUS_D1 )
33 19 * * * ( /home/agrineer/bin/run_wrf WCONUS_D2 )
45 23 * * * ( /home/agrineer/bin/run_wrf WCONUS_D3 )
48 23 * * * ( /home/agrineer/bin/run_wrf WCONUS_E2 )
#!/bin/sh
./configure << EOF
1
EOF
#!/bin/sh
./configure << EOF
34
1
EOF
# These programs are free software; you can redistribute then and/or modify
# them under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# These programs are distributed in the hope that they 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
# or visit https://www.gnu.org/licenses/gpl-3.0-standalone.html
This diff is collapsed.
#!/usr/bin/python3
# getdata_gfs.py
#
# Copyright (C) 2016-2018 Scott L. Williams.
#
# 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 3 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
copyright = 'getdata_gfs.py Copyright (c) 2016-2018 Scott L. Williams ' + \
'released under GNU GPL V3.0'
import os
import sys
import time
import glob
import string
import datetime
gfshome = '/home/agrineer/wrf/gfs_0.25'
# print fuctions to reduce clutter and to flush
def eprint( *args ):
print( *args, file=sys.stderr, flush=True)
def oprint( *args ):
print( *args, file=sys.stdout, flush=True)
def get_analysis_data( datedir ):
eprint("getting data for ", datedir)
stat = os.system( 'wget -nv -nc ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.' +
datedir + '00' + '/gfs.t00z.pgrb2.0p25.f000' )
eprint(stat)
stat = os.system( 'wget -nv -nc ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.' +
datedir + '06' + '/gfs.t06z.pgrb2.0p25.f000' )
eprint(stat)
stat = os.system( 'wget -nv -nc ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.' +
datedir + '12' + '/gfs.t12z.pgrb2.0p25.f000' )
eprint(stat)
stat = os.system( 'wget -nv -nc ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/gfs/prod/gfs.' +
datedir + '18' + '/gfs.t18z.pgrb2.0p25.f000' )
eprint(stat)
########################################################
# set up date strings
ac = len(sys.argv)
if ac < 2:
# run with current data
today = datetime.datetime.now()
yesterday = today - datetime.timedelta(days = 1)
else:
# get rundate from command line
ystdir = sys.argv[1]
yr = int( ystdir[:4] )
mn = int( ystdir[4:6] )
dy = int( ystdir[6:8] )
yesterday = datetime.date(yr,mn,dy)
today = yesterday + datetime.timedelta(days = 1)
ystdir = yesterday.strftime( '%Y%m%d' )
tdydir = today.strftime( '%Y%m%d' )
# get yesterday's data
os.chdir( gfshome )
if os.path.exists(ystdir):
os.chdir(ystdir) # cd into yesterday's dir
else:
os.mkdir(ystdir)
os.chdir(ystdir)
# get data for yesterday; overwrites previous first sets
get_analysis_data( ystdir )
# get today's data
os.chdir( gfshome )
if os.path.exists( tdydir ):
os.chdir( tdydir ) # cd into today's dir
else:
os.mkdir( tdydir )
os.chdir( tdydir )
# get today's available data sets
get_analysis_data( tdydir )
This diff is collapsed.
#!/bin/sh
# bourne shell script to run wrf cron jobs
HOME = /home/agrineer/wrf
SCRIPTS = $HOME/scripts
GFSHOME = $HOME/gfs_0.25
LOGDIR = $HOME/log
export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib
export NCARG_ROOT=/usr/local/ncarg
export MP_STACK_SIZE=64000000
ulimit -s unlimited
# run with today's date
if [ $# -eq 1 ];
then
$SCRIPTS/run_wrfgfs.py -s $1 -b 06 -d $GFSHOME > $LOGDIR/$1.log 2>&1 &
fi
# run with given date
if [ $# -eq 2 ];
then
$SCIPTS/run_wrfgfs.py -s $1 -b 06 -d $GFSHOME -r $2 > $LOGDIR/$1.log 2>&1 &
fi
#!/usr/bin/python3
# run_wrfgfs.py
#
# Copyright (C) 2016-2018 Scott L. Williams.
#
# 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 3 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
#
copyright = 'run_wrfgfs.py Copyright (c) 2016-2018 Scott L. Williams ' + \
'released under GNU GPL V3.0'
import os
import sys
import glob
import time
import getopt
import shutil
import datetime
# set dirs
# FIXME: implement environment variable?
outdir = '/home/agrineer/wrf/output/'
script_dir = '/home/agrineer/wrf/scripts/'
# print fuctions to reduce clutter and to flush
def eprint( *args ):
print( *args, file=sys.stderr, flush=True)
def oprint( *args ):
print( *args, file=sys.stdout, flush=True)
# command line options
def usage():
eprint('usage: run_wrfgfs.py -h -b hour -s sector -d datapath <-r date>')
eprint(' run_wrfgfs.py --help --begin=hour --sector=sector --datadir=datapath <--rundate=date>')
eprint(' omitting rundate defaults to yesterday data')
eprint(' begin hour is in UTC')
# end usage
def read_args( argv ):
sector = None
rundate = None
begin = None
datadir = None
try:
opts, args = getopt.getopt( argv, 'hb:s:d:r:',
['help','begin=','sector=','datadir=',
'rundate='] )
except getopt.GetoptError:
eprint('unkown command arguments')
usage()
sys.exit(2)
for opt, arg in opts:
if opt in ( '-h', '--help' ):
usage()
sys.exit(0)
elif opt in ( '-s', '--sector' ):
sector = arg
elif opt in ( '-d', '--datadir' ):
datadir = arg
elif opt in ( '-r', '--rundate' ):
rundate = arg
elif opt in ( '-b', '--begin' ): # REVIEW: this is not general enough
begin = int(arg)
if begin < 0 or begin > 23:
eprint('begin hour must be [0-23],')
usage()
sys.exit( 2 )
if sector == None: