HWRF  trunk@4391
nml.py
1 #!/usr/bin/python
2 
3 #from collections import OrderedDict
4 from util import makenwrap
5 
6 ##@namespace pom.nml
7 # Generates the POM namelist.
8 #
9 # @note Please report bugs/questions/comments to bijuthomas(at)mail(dot)uri(dot)edu.
10 # @author Biju Thomas, GSO, University of Rhode Island.
11 # @date June 9, 2014
12 #
13 # Arguments:
14 # * @c title --- run's title
15 #
16 # * @c netcdf_file --- netCDF output file (rund ID)
17 #
18 # * @c mode --- calculation mode. Description:
19 # * @c 2 --- 2-D calculation (bottom stress calculated in advave)
20 # * @c 3 --- 3-D calculation (bottom stress calculated in profu,v)
21 # * @c 4 --- 3-D calculation with t and s held fixed
22 #
23 # * @c nadv --- advection scheme. Options:
24 # * @c 1 --- Centred scheme, as originally provide in POM
25 # * @c 2 --- Smolarkiewicz iterative upstream scheme, based on
26 # subroutines provided by Gianmaia Sannino and Vincenzo
27 # Artale
28 #
29 # Constants for Smolarkiewicz iterative upstream scheme:
30 #
31 # * @c nitera --- number of iterations. This should be in the range 1 - 4. 1 is
32 # standard upstream differencing; 3 adds 50% CPU time to POM
33 #
34 # * @c sw --- smoothing parameter. This should preferably be 1, but 0 < sw < 1
35 # gives smoother solutions with less overshoot when nitera > 1
36 #
37 # * @c npg --- pressure gradient scheme. Options:
38 # * @c 1 --- Second order scheme, as originally provide in POM
39 # * @c 2 --- Fourth order scheme using the McCalpin method (Berntsen and
40 # Oey, Ocean Dynamics, 2010)
41 #
42 # * @c dte --- external (2-D) time step (secs.) according to CFL
43 #
44 # * @c isplit --- Ratio: (Internal (3-D) time step)/(External (2-D) time step)
45 # (dti/dte; dimensionless)
46 #
47 # * @c time_start --- date and time of start of initial run of model in format
48 # (i.e. UDUNITS convention)
49 # "YYYY-MM-DD HH:MM:SS <+/->HH:MM"
50 # where "<+/->HH:MM" is the time zone (positive eastwards
51 # from Coordinated Universal Time). NOTE that the
52 # climatological time axis (i.e. beginning of year zero,
53 # which does not exist in the real-world calendar) is used
54 #
55 # Restart options:
56 #
57 # * @c nread_rst --- index to indicate whether run to start from restart file
58 # (nread_rst=0: no restart input file; nread_rst=1: restart
59 # input file)
60 # * @c read_rst_file --- restart input file name
61 # * @c write_rst --- interval (days) to write a restart file
62 # * @c write_rst_file --- restart output file name
63 #
64 # Additional options:
65 #
66 # * @c days --- run duration (days)
67 #
68 # * @c prtd1 --- initial print interval (days)
69 #
70 # * @c prtd2 --- final print interval (days)
71 #
72 # * @c swtch --- time to switch from prtd1 to prtd2
73 #
74 # * @c nbct --- surface temperature boundary condition (see initialize.f)
75 #
76 # * @c ifplane --- f-plane option. Valid values:
77 # * @c 0 --- Grid is not an f-plane, as originally provided in POM
78 # * @c 1 --- Grid is an f-plane, calculated at latitude cnorth_e
79 #
80 # * @c cnorth_e --- Constant for f-plane option: latitude for Coriolis
81 # calculation when using an f-plane
82 #
83 # * @c ismoth --- smoothing/desmoothing option
84 # * @c 0 --- do not use 3D U V T S smoothing
85 # * @c 1 --- use 3D U V T S smoothing
86 #
87 # * @c smh --- Constant for smoothing/desmoothing option: smoothing time
88 # step frequency. This has traditionally been 3.
89 #
90 # * @c tnowindd --- no prescribed wind after tnowindd (days)
91 #
92 # * @c igeovel --- initial geostrophic velocity option. Valid values:
93 # * 0 --- No calculation of initial geostrophic velocity
94 # * 1 --- Calculate initial geostrophic velocity
95 #
96 # * @c nl --- number of z-levels in initial condition file(s)
97 #
98 # * @c ionedim --- 3D (full) vs. 1D (vertical-only) physics option. Valid values:
99 # * @c 0 --- use full 3D physics
100 # * @c 1 --- use vertical-only 1D phsyics
101 #
102 # * @c ipwave --- wave-induced mixing option
103 # * @c 0 --- do not use wave-induced mixing
104 # * @c 1 --- use wave-induced mixing
105 #
106 
107 
108 class nml(object):
109  """!Class that generates the namelist for POM."""
110  def __init__(self):
111  """!nml constructor. Generates the namelist."""
112  self.namelist = {'title' : "'MPIPOM-TC: stormenv'" ,
113  'netcdf_file' : "'stormenv'" ,
114  'mode' : 3 ,
115  'nadv' : 1 ,
116  'nitera' : 1 ,
117  'sw' : 0.5 ,
118  'npg' : 1 ,
119  'dte' : 6 ,
120  'isplit' : 45 ,
121  'time_start' : "'yyyy-mm-dd-hh:00:00 +00:00'" ,
122  'nread_rst' : 0 ,
123  'read_rst_file' : "'restart.phaseN.nc'" ,
124  'write_rst' : 2.0 ,
125  'write_rst_file': "'restart'" ,
126  'days' : 2.0 ,
127  'prtd1' : 1.0 ,
128  'prtd2' : 1.0 ,
129  'swtch' : 9999. ,
130  'nbct' : 3 ,
131  'ifplane' : 0 ,
132  'cnorth_e' : 22.4 ,
133  'ismoth' : 1 ,
134  'smh' : 3. ,
135  'tnowindd' : 0. ,
136  'igeovel' : 1 ,
137  'nl' : 33 ,
138  'ionedim' : 0 ,
139  'ipwave' : 0}
140  self.keys = ['title','netcdf_file','mode','nadv','nitera','sw','npg', \
141  'dte','isplit','time_start','nread_rst','read_rst_file', \
142  'write_rst','write_rst_file','days','prtd1','prtd2','swtch',\
143  'nbct','ifplane','cnorth_e','ismoth','smh','tnowindd', \
144  'igeovel','nl','ionedim','ipwave']
145 
146  ##@var namelist
147  # a dict mapping from namelist variable name to value.
148 
149  ## @var keys
150  # A list of namelist variables.
151 
152  def __call__(self,title,netcdf_file,time_start,nread_rst,read_rst_file, \
153  write_rst,days,prtd1,nbct,tnowindd,igeovel,nl):
154  """!Updates the namelist values
155 
156  @param title Runs' title.
157  @param netcdf_file POM NetCDF output file (run ID)
158  @param time_start Model analysis time in format "YYYY-MM-DD HH:MM:SS <+/->HH:MM"
159  where the "<+/->HH:MM" is the timezone.
160  @param nread_rst index index to indicate whether run to start from restart file
161  (nread_rst=0: no restart input file; nread_rst=1: restart
162  input file)
163  @param read_rst_file restart input filename
164  @param write_rst Restart interval.
165  @param days Run duration (days)
166  @param prtd1 Initial print interval (days)
167  @param nbct Surface temperature boundary condition (see initialize.f)
168  @param tnowindd No prescribed wind after tnowindd (days)
169  @param igeovel Initial geostrophic velocity option. 0=no, 1=yes
170  @param nl Number of Z levels in initial condition files."""
171  self.namelist['title'] = title
172  self.namelist['netcdf_file'] = '"'+netcdf_file+'"'
173  self.namelist['time_start'] = time_start
174  self.namelist['nread_rst'] = nread_rst
175  self.namelist['read_rst_file'] = read_rst_file
176  self.namelist['write_rst'] = write_rst
177  self.namelist['days'] = days
178  self.namelist['prtd1'] = prtd1
179  self.namelist['nbct'] = nbct
180  self.namelist['tnowindd'] = tnowindd
181  self.namelist['igeovel'] = igeovel
182  self.namelist['nl' ] = nl
183 
184  @makenwrap
185  def make(self,DEST):
186  """!Writes the POM namelist pom.nml in the destination directory.
187  @param DEST destination directory"""
188  pass
Class that generates the namelist for POM.
Definition: nml.py:108
namelist
a dict mapping from namelist variable name to value.
Definition: nml.py:112
def __call__(self, title, netcdf_file, time_start, nread_rst, read_rst_file, write_rst, days, prtd1, nbct, tnowindd, igeovel, nl)
Updates the namelist values.
Definition: nml.py:153
keys
A list of namelist variables.
Definition: nml.py:140
def __init__(self)
nml constructor.
Definition: nml.py:110
def make(self, DEST)
Writes the POM namelist pom.nml in the destination directory.
Definition: nml.py:185