ehratm APIs
syspaths.py
Go to the documentation of this file.
1 
2 
3 import os
4 
5 VALID_SYSTEMS = ['ehratmvm', 'devlan']
6 #CONFIGURED_SYSTEM = 'devlan'
7 CONFIGURED_SYSTEM = 'ehratmvm'
8 
9 class SysSpecificPaths(object):
10 
11  def __init__(self):
12 
13  # Don Morton's development CentOS 7 VM for EHRATM
14  if CONFIGURED_SYSTEM == 'ehratmvm':
15 
16  # These are system-specific values
17  self._WPSWRF_DISTRO_PATH = '/scratch/WRFV4.3-Distribution'
18  self._WPS_GEOG_DATA_DIR = '/home/ctbtuser/tempgeog'
19  #self._FLEXWRF_DISTRO_PATH = \
20  # '/scratch/FLEXWRFv3.3-gnu-Distirbution-2022-02-03'
22  '/scratch/FLEXWRFv3.3-gnu-Distribution-2023-05-08'
23  self._SRM_FLEXPART2CTBT_PATH = os.path.join(
24  self._FLEXWRF_DISTRO_PATH, 'srm/flexpart2ctbt',
25  'flexpart2ctbt'
26  )
27 
28 
29 
30  self._MPIRUN_PATH = '/usr/lib64/openmpi/bin/mpirun'
31 
32  # Eventually I want to have a cleaner way of packaging these custom
33  # files, but for now I'm just listing their full hardcoded paths
34  self._VTABLE_ECMWF_ML = '/home/ctbtuser/git/high-res-atm'
35  self._VTABLE_ECMWF_ML += '/packages/nwpservice/tests/testcase_data'
36  self._VTABLE_ECMWF_ML += '/ecmwf_anne_2014_eu/WPS/Vtable.ECMWF.ml'
37 
38  self._VTABLE_ECMWF_SFC = '/home/ctbtuser/git/high-res-atm'
39  self._VTABLE_ECMWF_SFC += '/packages/nwpservice/tests/testcase_data'
40  self._VTABLE_ECMWF_SFC += '/ecmwf_anne_2014_eu/WPS/Vtable.ECMWF.sfc'
41 
42  # For ECMWF model-to-pressure level processing
43  self._ECMWF_COEFFS = '/home/ctbtuser/git/high-res-atm'
44  self._ECMWF_COEFFS += '/packages/nwpservice/tests/testcase_data'
45  self._ECMWF_COEFFS += '/ecmwf_anne_2014_eu/WPS/ecmwf_coeffs'
46 
47  self._ECMWF_METGRID_TBL = '/home/ctbtuser/git/high-res-atm'
48  self._ECMWF_METGRID_TBL += '/packages/nwpservice/tests/testcase_data'
49  self._ECMWF_METGRID_TBL += '/ecmwf_anne_2014_eu/WPS/METGRID.TBL'
50 
51 
53 
54  self._WORKFLOW_ROOTDIR = '/tmp'
55 
56  # Don Morton's experimental setup on devlan
57  elif CONFIGURED_SYSTEM == 'devlan':
58 
59  REPOSITORY_ROOTDIR = '/dvlscratch/ATM/morton/git/high-res-atm'
60  DISTRIBUTIONS_ROOTDIR = '/dvlscratch/ATM/morton/EHRATM-develop-freeze-v1.0'
61 
62  self._MPIRUN_PATH = '/usr/lib64/openmpi/bin/mpirun'
63 
64  # These are system-specific values for devlan
65  self._WPSWRF_DISTRO_PATH = DISTRIBUTIONS_ROOTDIR
66  self._WPSWRF_DISTRO_PATH += '/WRFDistributions/WRFV4.3'
67 
68  self._WPS_GEOG_DATA_DIR = DISTRIBUTIONS_ROOTDIR
69  self._WPS_GEOG_DATA_DIR += '/WRFDistributions/GEOG_DATA'
70 
71  self._FLEXWRF_DISTRO_PATH = DISTRIBUTIONS_ROOTDIR
72  self._FLEXWRF_DISTRO_PATH += '/FlexWRFDistributions/flexwrfv3.3'
73 
74  self._SRM_FLEXPART2CTBT_PATH = os.path.join(
75  self._FLEXWRF_DISTRO_PATH, 'srm/flexpart2ctbt',
76  'flexpart2ctbt')
77 
78 
79 
80  # Eventually I want to have a cleaner way of packaging these custom
81  # files, but for now I'm just listing their full hardcoded paths
82 
83 
84  self._VTABLE_ECMWF_ML = REPOSITORY_ROOTDIR
85  self._VTABLE_ECMWF_ML += '/packages/nwpservice/tests/testcase_data'
86  self._VTABLE_ECMWF_ML += '/ecmwf_anne_2014_eu/WPS/Vtable.ECMWF.ml'
87 
88  self._VTABLE_ECMWF_SFC = REPOSITORY_ROOTDIR
89  self._VTABLE_ECMWF_SFC += '/packages/nwpservice/tests/testcase_data'
90  self._VTABLE_ECMWF_SFC += '/ecmwf_anne_2014_eu/WPS/Vtable.ECMWF.sfc'
91 
92  # For ECMWF model-to-pressure level processing
93  self._ECMWF_COEFFS = REPOSITORY_ROOTDIR
94  self._ECMWF_COEFFS += '/packages/nwpservice/tests/testcase_data'
95  self._ECMWF_COEFFS += '/ecmwf_anne_2014_eu/WPS/ecmwf_coeffs'
96 
97  self._ECMWF_METGRID_TBL = REPOSITORY_ROOTDIR
98  self._ECMWF_METGRID_TBL += '/packages/nwpservice/tests/testcase_data'
99  self._ECMWF_METGRID_TBL += '/ecmwf_anne_2014_eu/WPS/METGRID.TBL'
100 
101 
102 
103  #self._WORKING_SCRATCH_ROOTDIR = '/dvlscratch/ATM/morton/tmp'
104  self._WORKING_SCRATCH_ROOTDIR = '/tmp'
105 
106  #self._WORKFLOW_ROOTDIR = '/dvlscratch/ATM/morton/tmp'
107  self._WORKFLOW_ROOTDIR = '/tmp'
108 
109  else:
110  raise ValueError('Invalid CONFIGURED_SYSTEM: %s' %s)
111 
112 
113 
114 
115 
116 
117 
118 
119  # Check that the paths are good
120  if not os.path.isdir(self._WPSWRF_DISTRO_PATH):
121  msg = 'WPSWRF_DISTRO_PATH dir not found: %s' % \
123  raise FileNotFoundError(msg)
124 
125  if not os.path.isdir(self._WPS_GEOG_DATA_DIR):
126  msg = 'WPS_GEOG_DATA_DIR dir not found: %s' % \
127  self._WPS_GEOG_DATA_DIR
128  raise FileNotFoundError(msg)
129 
130  if not os.path.isdir(self._FLEXWRF_DISTRO_PATH):
131  msg = 'FLEXWRF_DISTRO_PATH dir not found: %s' % \
133  raise FileNotFoundError(msg)
134 
135 
136  if not os.path.isfile(self._SRM_FLEXPART2CTBT_PATH):
137  msg = 'SRM_FLEXPART2CTBT_PATH not found: %s' % \
139  raise FileNotFoundError(msg)
140  # Also make sure it's executable
141  if not os.access(self._SRM_FLEXPART2CTBT_PATH, os.X_OK):
142  msg = 'flexpart2ctbt not executable: %s' % \
144  raise FileNotFoundError(msg)
145 
146 
147  if not os.path.isfile(self._MPIRUN_PATH):
148  msg = 'MPIRUN_PATH dir found: %s' % \
149  self._MPIRUN_PATH
150  raise FileNotFoundError(msg)
151 
152  if not os.path.isfile(self._VTABLE_ECMWF_ML):
153  msg = 'VTABLE_ECMWF_SFC not found: %s' % \
154  self._VTABLE_ECMWF_ML
155  raise FileNotFoundError(msg)
156 
157  if not os.path.isfile(self._VTABLE_ECMWF_SFC):
158  msg = 'VTABLE_ECMWF_SFC not found: %s' % \
159  self._VTABLE_ECMWF_SFC
160  raise FileNotFoundError(msg)
161 
162  if not os.path.isfile(self._ECMWF_METGRID_TBL):
163  msg = 'ECMWF_METGRID_TBL not found: %s' % \
164  self._ECMWF_METGRID_TBL
165  raise FileNotFoundError(msg)
166 
167  if not os.access(self._WORKING_SCRATCH_ROOTDIR, os.W_OK):
168  msg = 'WORKING_SCRATCH_ROOTDIR dir not writable: %s' % \
170  raise OSError(msg)
171 
172 
173 
174 
177 
178  def log_level(self):
179  return self._LOG_LEVEL
180 
182  return self._WPSWRF_DISTRO_PATH
183 
184  def wps_geog_data_dir(self):
185  return self._WPS_GEOG_DATA_DIR
186 
188  return self._FLEXWRF_DISTRO_PATH
189 
191  return self._SRM_FLEXPART2CTBT_PATH
192 
193  def mpirun_path(self):
194  return self._MPIRUN_PATH
195 
196 
198  return self._WORKING_SCRATCH_ROOTDIR
199 
200  def workflow_rootdir(self):
201  return self._WORKFLOW_ROOTDIR
202 
203 
204 
205  def vtable_ecmwf_ml(self):
206  return self._VTABLE_ECMWF_ML
207 
208  def vtable_ecmwf_sfc(self):
209  return self._VTABLE_ECMWF_SFC
210 
211  def ecmwf_coeffs(self):
212  return self._ECMWF_COEFFS
213 
214  def ecmwf_metgrid_tbl(self):
215  return self._ECMWF_METGRID_TBL
ehratm.syspaths.SysSpecificPaths._ECMWF_METGRID_TBL
_ECMWF_METGRID_TBL
Definition: syspaths.py:47
ehratm.syspaths.SysSpecificPaths._WPSWRF_DISTRO_PATH
_WPSWRF_DISTRO_PATH
Definition: syspaths.py:17
ehratm.syspaths.SysSpecificPaths.ecmwf_metgrid_tbl
def ecmwf_metgrid_tbl(self)
Definition: syspaths.py:214
ehratm.syspaths.SysSpecificPaths.vtable_ecmwf_ml
def vtable_ecmwf_ml(self)
Definition: syspaths.py:205
ehratm.syspaths.SysSpecificPaths.flexwrf_distro_path
def flexwrf_distro_path(self)
Definition: syspaths.py:187
ehratm.syspaths.SysSpecificPaths._WORKING_SCRATCH_ROOTDIR
_WORKING_SCRATCH_ROOTDIR
Definition: syspaths.py:52
ehratm.syspaths.SysSpecificPaths._WPS_GEOG_DATA_DIR
_WPS_GEOG_DATA_DIR
Definition: syspaths.py:18
ehratm.syspaths.SysSpecificPaths._SRM_FLEXPART2CTBT_PATH
_SRM_FLEXPART2CTBT_PATH
Definition: syspaths.py:23
ehratm.syspaths.SysSpecificPaths.workflow_rootdir
def workflow_rootdir(self)
Definition: syspaths.py:200
ehratm.syspaths.SysSpecificPaths._ECMWF_COEFFS
_ECMWF_COEFFS
Definition: syspaths.py:43
ehratm.syspaths.SysSpecificPaths.__init__
def __init__(self)
Definition: syspaths.py:11
ehratm.syspaths.SysSpecificPaths.log_level
def log_level(self)
All default values "should" be available through the following methods.
Definition: syspaths.py:178
ehratm.syspaths.SysSpecificPaths.ecmwf_coeffs
def ecmwf_coeffs(self)
Definition: syspaths.py:211
ehratm.syspaths.SysSpecificPaths
Definition: syspaths.py:9
ehratm.syspaths.SysSpecificPaths._VTABLE_ECMWF_ML
_VTABLE_ECMWF_ML
Definition: syspaths.py:34
ehratm.syspaths.SysSpecificPaths.mpirun_path
def mpirun_path(self)
Definition: syspaths.py:193
ehratm.syspaths.SysSpecificPaths.wpswrf_distro_path
def wpswrf_distro_path(self)
Definition: syspaths.py:181
ehratm.syspaths.SysSpecificPaths.srm_flexpart2ctbt_path
def srm_flexpart2ctbt_path(self)
Definition: syspaths.py:190
ehratm.syspaths.SysSpecificPaths._FLEXWRF_DISTRO_PATH
_FLEXWRF_DISTRO_PATH
Definition: syspaths.py:21
ehratm.syspaths.SysSpecificPaths.wps_geog_data_dir
def wps_geog_data_dir(self)
Definition: syspaths.py:184
ehratm.syspaths.SysSpecificPaths.working_scratch_rootdir
def working_scratch_rootdir(self)
Definition: syspaths.py:197
ehratm.syspaths.SysSpecificPaths._MPIRUN_PATH
_MPIRUN_PATH
Definition: syspaths.py:30
ehratm.syspaths.SysSpecificPaths._VTABLE_ECMWF_SFC
_VTABLE_ECMWF_SFC
Definition: syspaths.py:38
ehratm.syspaths.SysSpecificPaths._WORKFLOW_ROOTDIR
_WORKFLOW_ROOTDIR
Definition: syspaths.py:54
ehratm.syspaths.SysSpecificPaths.vtable_ecmwf_sfc
def vtable_ecmwf_sfc(self)
Definition: syspaths.py:208