UM/MesoscaleModelling: get_dump

File get_dump, 1.9 KB (added by willie, 8 months ago)

Script to get start dumps on MONSooN

Line 
1#!/bin/bash
2#
3# W. McGinty
4# 4 Apr 2018
5#
6# Unified script for getting start dumps
7#
8set -u
9
10# Check if MASS is up
11moo ls moose:/opfc > /dev/null 2>&1
12RC=$?
13if [[ $RC -ne 0 ]] ; then
14 echo "MASS is down" 2>&1
15 exit 1
16fi
17
18if [[ $# -ne 1 ]]; then
19  echo "Usage: get_dump <date>" 2>&1
20  echo "dates in the form yyyymmddhh" 2>&1
21  exit 1
22fi
23
24startdate=$1
25if [[ ${#startdate} -ne 10 ]]; then
26 echo "Start date must be 10 chars e.g. 2011050112" 2>&1
27 exit 1
28fi
29
30# Split the date
31  YRMON=${startdate:0:6}
32  Date=${startdate:0:8}
33  hr=${startdate:8:2}
34
35# Decide which extraction method to use
36
37if   [[ $startdate > 2015082606 ]] ; then
38  moo get moose:/opfc/atm/global/rerun/${YRMON}.file/${Date}T${hr}00Z_glm_t+0 .
39elif [[ $startdate > 2014020406 ]] ; then
40  moo get moose:/opfc/atm/global/rerun/${YRMON}.file/${Date}${hr}_glm_t+0 .
41elif [[ $startdate > 2009123118 ]] ; then
42  moo get moose:/opfc/atm/global/rerun/${YRMON}.file/${Date}_qwqg${hr}.T+0 .
43elif [[ $startdate > 2009062006 ]] ; then
44  moo get moose:/opfc/atm/global/rerun/${YRMON}.file/${Date}_qwqu${hr}.T+3 .
45elif [[ $startdate > 2006010100 ]] ; then
46# It's really old, in packed archive file format ...
47
48# Force hour to 06 as that's all that's available
49  hr=06
50  PAXFILE=coprr.udQU${hr}.${Date}.pax
51
52  moo get moose:/opfc/atm/global/rerun/${YRMON}.file/${PAXFILE} .
53
54  if [[ $? -ne 0 ]]; then
55   echo "No such file for date $startdate" 2>&1
56   exit 1
57  fi
58
59  pax -rf $PAXFILE                     # unpack it
60
61  if [[ -e op ]]; then
62    ROOTDIR=op/daily/datawgl
63  else
64    ROOTDIR=opdaily/datawgl
65  fi
66
67  for j in $ROOTDIR/*
68  do
69    fn=${j##*/}                        # remove the directory part
70    mv $ROOTDIR/$fn ${Date}_$fn # Stamp it with the date
71  done
72
73  rm $PAXFILE
74  rm -rf ${ROOTDIR%%/*}
75else
76  echo "This is prehistoric.  Earliest Met Office date is 2006-01-01"
77  echo "You'll need to get a GRIB start dump from ECMWF"
78fi
79
80
81
82