Skip to content

Commit bca248c

Browse files
author
Jordan S Read
authored
Merge pull request #225 from jread-usgs/master
update for hanging line parser error
2 parents 4b47372 + ef75ffb commit bca248c

File tree

4 files changed

+374
-1
lines changed

4 files changed

+374
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: glmtools
22
Type: Package
33
Title: glmtools
4-
Version: 0.14.4
4+
Version: 0.14.5
55
Date: 2017-01-11
66
Authors@R: c( person("Jordan", "Read", role = c("aut","cre"),
77
email = "[email protected]"),

R/nml_helpers.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ buildVal <- function(textLine, lineNum, blckName){
1717
# can be: string, number, comma-sep-numbers, or boolean
1818

1919
# special case for date:
20+
if (is.na(parVl)){
21+
stop('Empty values after "', textLine, '" on line ', lineNum,
22+
'. \nPerhaps the values are on the next line?', call. = FALSE)
23+
}
2024
if (nchar(parVl>17) & substr(parVl,14,14)==':' & substr(parVl,17,17)==':'){
2125
parVl<-paste(c(substr(parVl,1,11),' ',substr(parVl,12,nchar(parVl))),collapse='')
2226
}

inst/extdata/hanging_line.nml

Lines changed: 365 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,365 @@
1+
!-------------------------------------------------------------------------------
2+
! general model setup
3+
!-------------------------------------------------------------------------------
4+
!
5+
! sim_name [string] title of simulation
6+
! max_layers [integer] maximum number of layers
7+
! min_layer_vol [real] minimum layer volume (m3 * 1000)
8+
! min_layer_thick [real] minimum layer thickness (m)
9+
! max_layer_thick [real] maximum layer thickness (m)
10+
! Kw [real] background light attenuation (m**-1)
11+
! coef_mix_conv [real] mixing efficiency - convective overturn
12+
! coef_wind_stir [real] mixing efficiency - wind stirring
13+
! coef_mix_turb [real] mixing efficiency - unsteady turbulence effects
14+
! coef_mix_shear [real] mixing efficiency - shear production !sensitive to hypolimnetic temperature
15+
! coef_mix_KH [real] mixing efficiency - hypolimnetic Kelvin-Helmholtz turbulent billows
16+
! coef_mix_hyp [real] mixing efficiency - hypolimnetic turbulence
17+
! deep_mixing [bool] flag to disable deep-mixing
18+
!
19+
!-------------------------------------------------------------------------------
20+
&glm_setup
21+
sim_name = 'GLM Simulation'
22+
max_layers = 500
23+
min_layer_vol = 0.025
24+
min_layer_thick = 0.05
25+
!min_layer_thick = 0.350
26+
max_layer_thick = 0.500
27+
!max_layer_thick = 0.900
28+
!-- Light Parameters
29+
Kw = 0.85
30+
!-- Mixing Parameters
31+
coef_mix_conv = 0.125 ! 0.05,0.2 , 0.35 , 0.12
32+
coef_wind_stir = 0.23 ! 0.1,0.3, 0.3, 0.1
33+
coef_mix_shear = 0.2 ! 0.018,0.4, 0.2, 0.13
34+
coef_mix_turb = 0.51 ! 0.51, 0.51, 0.51, 0.51
35+
coef_mix_KH = 0.33 !0.015, 0.4, 0.18, 0.33
36+
coef_mix_hyp = 0.5 !0.05, 0.6, 0.25, 0.8
37+
! non_avg = .true.
38+
! deep_mixing = .true.
39+
/
40+
41+
!-------------------------------------------------------------------------------
42+
! wq setup
43+
! if this block is read, water quality functionality will be enabled
44+
!-------------------------------------------------------------------------------
45+
! wq_lib [string]
46+
! Select which WQ library to use;
47+
! valid options are 'aed2' or 'fabm' [default is 'aed2']
48+
! ode_method [integer]
49+
! ODE numerical scheme for source and sink dynamics
50+
! 1: first-order explicit (not positive)
51+
! 2: second-order explicit Runge-Kutta (not positive)
52+
! 3: fourth-order explicit Runge-Kutta (not positive)
53+
! 4: Patankar (first-order, not conservative)
54+
! 5: Patankar-RK (second-order, not conservative)
55+
! 6: Patankar-RK (does not work, not conservative)
56+
! 7: Modified Patankar (1st-order, conservat., posit.)
57+
! 8: Modified Patankar-RK (2nd-order, conservat., posit.)
58+
! 9: Modified Patankar-RK (does not work, conservat.,
59+
! posit.)
60+
! 10: Extended Modified Patankar (1st-order, conservat.,
61+
! posit.)
62+
! 11: Extended Modified Patankar-RK (2nd-order, conservat.,
63+
! posit.)
64+
! This variable is used only if bio_calc = True
65+
! split_factor [integer, minimum = 1]
66+
! number of biogeochemical time steps per physical time step
67+
! bioshade_feedback [bool]
68+
! feedback of bio-turbidity to temperature equation
69+
! repair_state [bool]
70+
! FABM option to repeair state variables that have -ve's
71+
! wq_nml_file [string]
72+
! name of .nml file to be passed to WQ library;
73+
! the default is {wq_lib}.nml (eg aed2.nml)
74+
! mobility_off [bool]
75+
! flag to turn off settling/rising
76+
! multi_ben [bool]
77+
! GLM specific option for FABM to do benthic fluxes only
78+
! in bottom layer, or on flanks of all layers (.true.)
79+
!-------------------------------------------------------------------------------
80+
&wq_setup
81+
wq_lib = 'aed2'
82+
wq_nml_file = 'aed2.nml'
83+
ode_method = 1
84+
split_factor = 1
85+
!bioshade_feedback = .true.
86+
bioshade_feedback = .false.
87+
repair_state = .true.
88+
! mobility_off = .false.
89+
multi_ben = .true.
90+
/
91+
92+
!-------------------------------------------------------------------------------
93+
! lake details
94+
!-------------------------------------------------------------------------------
95+
!
96+
! name [string]
97+
! name of the lake
98+
! latitude [float, minimum = -90, maximum = 90, unit = deg North]
99+
! latitude
100+
! longitude [float, minimum = -360, maximum = 360, unit = deg East]
101+
! longitude
102+
! base_elev [float]
103+
! base elevation (m)
104+
! crest_elev [float]
105+
! crest elevation (m)
106+
! bsn_len [float]
107+
! basin length at crest (m)
108+
! bsn_wid [float]
109+
! basin width at crest (m)
110+
! bsn_vals [integer]
111+
! number of depth points on height-area relationship
112+
! H [float]
113+
! elevations (m) (comma separated list, len=bsn_vals)
114+
! A [float]
115+
! area (m2) (comma separated list, len=bsn_vals)
116+
!
117+
!-------------------------------------------------------------------------------
118+
&morphometry
119+
lake_name = 'Falling Creek'
120+
latitude = 37.307681
121+
longitude = -79.837068
122+
bsn_len = 711.699
123+
bsn_wid = 226.030
124+
bsn_vals = 31
125+
! H(m) A(m2) V(m3)
126+
H = 497.683,497.983,498.283,498.683,498.983,499.283,499.583,499.883,500.183,500.483,500.783,501.083,501.383,501.683,501.983,502.283,502.583,502.883,503.183,503.483,503.783,504.083,504.383,504.683,505.083,505.383,505.683,505.983,506.283,506.583,506.983
127+
A = 0,61.408883,494.615572,1201.23579,2179.597283,3239.620513,4358.358439,5637.911458,6929.077352,8228.697419,9469.324081,10811.30792,12399.67051,14484.22802,16834.20941,19631.05422,22583.1399,25790.70893,28442.99667,31155.95008,36269.3312,42851.13714,51179.89109,59666.85885,68146.39437,76424.14457,85430.25429,95068.47603,103030.4489,111302.1604,119880.9164
128+
/
129+
130+
!-------------------------------------------------------------------------------
131+
! duration of run
132+
!-------------------------------------------------------------------------------
133+
!
134+
! timefmt [integer]
135+
! method to specify start and duration of model run
136+
! 1: duration computed from number of time steps, MaxN (bogus start
137+
! date used) [no longer implemented!!]
138+
! 2: duration computed from given start and stop dates (number of time
139+
! steps MaxN computed)
140+
! 3: duration computed from number of time steps, MaxN (start date as
141+
! specified, stop date computed)
142+
! start [string, format = "yyyy-mm-dd hh:mm:ss"]
143+
! nominal start date
144+
! This variable is used only if timefmt != 1
145+
! stop [string, format = "yyyy-mm-dd hh:mm:ss"]
146+
! nominal stop date
147+
! This variable is used only if timefmt = 2
148+
! dt [float, minimum = 0.001, maximum = 86400, unit = s]
149+
! Time step for integration
150+
! numb_days [number of days to run the simulation ]
151+
! This variable is used only if timefmt != 2
152+
!
153+
!-------------------------------------------------------------------------------
154+
&time
155+
timefmt = 2
156+
start = '2015-03-31 11:00:00'
157+
stop = '2015-09-30 00:00:00'
158+
dt = 3600.0
159+
!num_days = 3288
160+
timezone = -5.0
161+
/
162+
163+
!-------------------------------------------------------------------------------
164+
! format for output and filename(s)
165+
!-------------------------------------------------------------------------------
166+
!
167+
! out_dir [string]
168+
! path to output directory (set permissions)
169+
! out_fn [string]
170+
! name of output netcdf file
171+
! nsave [integer, minimum = 1, maximum = 86400]
172+
! save results every 'nsave' timesteps
173+
! csv_lake_fname [string]
174+
! name of lake.csv lake simulation daily summary information
175+
! csv_point_nlevs [integer]
176+
! number of depths at which to dump a csv time-series file
177+
! csv_point_at [real]
178+
! height from bottom for point csv file(s) (comma separated list)
179+
! csv_point_fname [string]
180+
! name of csv output file(s) (comma separated list)
181+
! csv_point_nvars [integer]
182+
! number of variables to output into csv
183+
! csv_point_vars [string]
184+
! list of names of variables to output, - order IS important
185+
! csv_outlet_allinone [bool]
186+
! put all outflow data into the same csv file
187+
! csv_outlet_fname [string]
188+
! name of csv output file(s) (comma separated list)
189+
! csv_outlet_nvars [integer]
190+
! number of variables to output into outlet csv
191+
! csv_outlet_vars [string]
192+
! list of names of variables to output
193+
! csv_ovrflw_fname [string]
194+
! name of csv file to record amount and quality of overflow
195+
!
196+
!-------------------------------------------------------------------------------! simulation number 1
197+
&output
198+
out_dir = '.'
199+
out_fn = 'output'
200+
nsave = 24
201+
csv_point_nlevs = 2
202+
csv_point_fname = 'WQ_'
203+
csv_point_at = 20,22
204+
csv_point_nvars = 6
205+
csv_lake_fname = 'Physics'
206+
csv_point_vars = 'temp','OXY_oxy','PHY_CYANOPCH1','PHY_CYANONPCH2','PHY_CHLOROPCH3','PHY_DIATOMPCH4'
207+
/
208+
!-------------------------------------------------------------------------------
209+
! initial condition profiles
210+
!-------------------------------------------------------------------------------
211+
!
212+
! lake_depth [float] initial lake depth (m)
213+
! num_depths [integer] number of depths provided for initial profiles
214+
! the_depths [float] the depths of the initial profile points (m)
215+
! the_temps [float] the temperature of the initial profile points (C)
216+
! the_sals [float] the salinity of the initial profile points (psu)
217+
! num_wq_vars [integer] number of non GLM (ie FABM) vars to be initialised
218+
! wq_names [string] names of non GLM (ie FABM) vars to be initialised
219+
! wq_init_vals [float] array of FABM vars (rows = vars; cols = depths)
220+
!
221+
!-------------------------------------------------------------------------------
222+
&init_profiles
223+
num_depths = 30
224+
lake_depth = 9.3
225+
the_depths = 0.0, 0.80, 1.11, 1.41, 1.71, 2.02, 2.32, 2.62, 2.93, 3.23, 3.53, 3.84, 4.14, 4.44, 4.75, 5.05, 5.36, 5.66, 5.96, 6.27, 6.57, 6.87, 7.18, 7.48, 7.78, 8.09, 8.39, 8.69, 9.00, 9.30,
226+
the_temps = 5.80, 5.82, 5.89, 5.95, 6.02, 6.09, 6.18, 6.25, 6.36, 6.45, 6.59, 6.73, 6.83, 6.91, 7.00, 7.08, 7.14, 7.23, 7.32, 7.42, 7.55, 7.69, 7.81, 8.01, 8.38, 8.66, 8.88, 8.93, 8.97, 9.12,
227+
the_sals = 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50, 0.50
228+
num_wq_vars = 7
229+
wq_names =
230+
'OGM_doc',
231+
'OXY_oxy',
232+
'CAR_dic',
233+
'NIT_amm',
234+
'NIT_nit',
235+
'PHS_frp',
236+
'CAR_ch4'
237+
wq_init_vals = 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.09, 0.09, 0.09, 0.09, 0.09, 0.09, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08, 0.08,
238+
300.62, 300.41, 300.19, 300.98, 300.76, 300.55, 300.33, 300.12, 300.90, 300.69, 300.47, 300.25, 300.04, 300.82, 300.61, 300.39, 300.18, 300.96, 300.75, 300.53, 300.31, 300.10, 250.88, 250.67, 250.45, 250.24, 250.02, 250.81, 250.59, 250.38,
239+
0.11, 0.11, 0.11, 0.11, 0.11, 0.13, 0.13, 0.13, 0.13, 0.13, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.13, 0.13, 0.13,
240+
0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.22, 0.25, 0.25, 0.25, 0.25, 0.25, 0.22, 0.22, 0.22, 0.22, 0.23, 0.23, 0.23, 0.23, 0.23, 0.26, 0.26, 0.26, 0.37, 0.37,
241+
0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.19, 0.17, 0.17, 0.17, 0.17, 0.17, 0.12, 0.12, 0.12, 0.12, 0.15, 0.15, 0.15, 0.15, 0.15, 0.20, 0.20, 0.20, 0.21, 0.21,
242+
0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.61, 0.63, 0.63, 0.63, 0.63, 0.63, 0.63, 0.53, 0.53, 0.53, 0.53, 0.53, 0.47, 0.47, 0.47, 0.47, 0.47, 0.53, 0.53, 0.51, 0.51, 0.51, 0.51,
243+
0.58, 0.58, 0.59, 0.59, 0.60, 0.60, 0.61, 0.61, 0.62, 0.62, 0.62, 0.63, 0.63, 0.64, 0.64, 0.65, 0.65, 0.66, 0.66, 0.67, 0.67, 0.67, 0.68, 0.68, 0.69, 0.69, 0.70, 0.70, 0.71, 0.71
244+
/
245+
!-------------------------------------------------------------------------------
246+
! meteorology
247+
!-------------------------------------------------------------------------------
248+
!
249+
! met_sw [bool] switch to include surface meteorological forcing
250+
! lw_type [string] type of longwave data supplied (LW_IN/LW_CC/LW_NET)
251+
! rain_sw [bool] include rainfall nutrient composition
252+
! snow_sw [bool] include snowfall (m/d)
253+
! atm_stab [bool] account for non-neutral atmospheric stability
254+
! catchrain [bool] flag that enables runoff from exposed banks of lake area
255+
! rad_mode [integer] short and long wave radation model configuration (see manual)
256+
! albedo_mode [integer] shortwave albedo calculation method
257+
! cloud_mode [integer] atmospheric emmisivity calculation method
258+
!
259+
! meteo_fl [string] name of file with meteorology input data
260+
! wind_factor [float] wind multiplication factor (-)
261+
! wind_factor [float] wind multiplication factor (-)
262+
! rain_factor [float] wind multiplication factor (-)
263+
! sw_factor [float] wind multiplication factor (-)
264+
! lw_factor [float] wind multiplication factor (-)
265+
! at_factor [float] wind multiplication factor (-)
266+
! rh_factor [float] wind multiplication factor (-)
267+
!
268+
! ce [float] bulk aerodynamic coefficient for latent heat transfer
269+
! ch [float] bulk aerodynamic coefficient for sensible heat transfer
270+
! cd [float] bulk aerodynamic coefficient for transfer of momentum
271+
! rain_threshold [float] rainfall amount (m) required before runoff from exposed banks
272+
! runoff_coef [float] conversion of rainfall to runoff in exposed lake banks
273+
!
274+
!-------------------------------------------------------------------------------
275+
&meteorology
276+
met_sw = .true.
277+
lw_type = 'LW_IN'
278+
rain_sw = .false.
279+
snow_sw = .false.
280+
atm_stab = .false.
281+
catchrain = .false.
282+
rad_mode = 1
283+
albedo_mode = 1
284+
cloud_mode = 4
285+
!-- BC file details
286+
meteo_fl = 'glm_met_2015_FCR_adjusted_tillDec.csv'
287+
!meteo_fl = 'glm_met_2015_FCR_adjusted_wind.csv'
288+
subdaily = .true.
289+
wind_factor = 1.0
290+
sw_factor = 1.0
291+
lw_factor = 1.0
292+
at_factor = 1.0
293+
rh_factor = 1.0
294+
rain_factor = 1.0
295+
cd = 0.001
296+
ce = 0.0013
297+
ch = 0.0013
298+
rain_threshold = 0.01
299+
runoff_coef = 0.3
300+
time_fmt = 'YYYY-MM-DD hh:mm:ss'
301+
/
302+
!-------------------------------------------------------------------------------
303+
! inflows
304+
!-------------------------------------------------------------------------------
305+
!
306+
! num_inflows [integer] number of inflowing streams (0+)
307+
! names_of_strms [string] names of streams (comma separated list)
308+
! strm_hf_angle [float] stream half angle (degrees)
309+
! strmbd_slope [float] streambed slope (degrees)
310+
! strmbd_drag [float] streambed drag coefficient (-)
311+
! inflow_factor [float] inflow flow rate multiplier (-)
312+
! inflow_fl [string] inflow data filename(s) (comma separated list)
313+
! inflow_varnum [integer] number of columns (excluding date) to be read
314+
! inflow_vars [string] variable names of inflow file columns
315+
! This should be a comma separated list, and must
316+
! include FLOW, SALT & TEMP (for GLM), and
317+
! optionally can include FABM var names.
318+
! coef_inf_entrain [real] entrainment coefficient for inflows
319+
!
320+
!-------------------------------------------------------------------------------
321+
&inflow
322+
num_inflows = 2
323+
names_of_strms = 'river1','SSS'
324+
subm_flag = .false.,.true.
325+
strm_hf_angle = 100.0,35.0 !Degree of channelization
326+
strmbd_slope = 0.573,0.1 !0.03-0.05 FCR inflow 0.03 SSS
327+
strmbd_drag = 0.0160,0.0160
328+
inflow_factor = 1,0.00314 !SSS 0.00314
329+
inflow_fl = 'FCR_GLM_iof_2015_modified_9Jan17.csv','FCR_GLM_SSSin_2015_004.csv'
330+
inflow_varnum = 10
331+
inflow_vars = 'FLOW',
332+
'TEMP',
333+
'SALT',
334+
'OGM_doc',
335+
'NIT_amm',
336+
'OXY_oxy',
337+
'NIT_nit',
338+
'PHS_frp',
339+
'TOT_tn',
340+
'TOT_tp'
341+
/
342+
!-------------------------------------------------------------------------------
343+
! outflows
344+
!-------------------------------------------------------------------------------
345+
!
346+
! num_outlet [integer] no. of outlets
347+
! flt_off_sw [bool] floating offtake switches
348+
! outl_elvs [float] outlet elevations (comma separated list)
349+
! bsn_len_outl [float] basin length at outlets (m)
350+
! bsn_wid_outl [float] basin width at outlets (m)
351+
! outflow_fl [string] outflow data file
352+
! outflow_factor [float] outflow flow rate multiplier (-)
353+
! seepage [bool] do seepage processing [default is off - ie no seepage]
354+
! seepage_rate [float] seepage rate of water (m/day) from bottom layer
355+
!
356+
!-------------------------------------------------------------------------------
357+
&outflow
358+
num_outlet = 4
359+
flt_off_sw = .false.,.false.,.false.,.false.
360+
outl_elvs = 506.9,498,506.9,506.9
361+
bsn_len_outl = 711.699,100,711.699,711.699 !711.699
362+
bsn_wid_outl = 226.030,10,226.030,226.030 !226.030
363+
outflow_fl = 'FCR_GLM_out1_2015.csv','FCR_GLM_SSSin_2015_004.csv','FCR_glm_out2_extra_2015.csv','FCR_glm_out_WTP_2015.csv'
364+
outflow_factor = 1,0.00314,1,1 ! inflow 0.3
365+
/

tests/testthat/test-get_outputNC.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ test_that("get_wind", {
1717
expect_true(all(t_out == df[,1]))
1818
})
1919

20+
test_that("check hanging nml", {
21+
expect_error(read_nml(system.file(package='glmtools', 'extdata', 'hanging_line.nml')), "Empty values after")
22+
})
23+
2024
context("get_surface_height")
2125

2226
test_that("get_surface_height", {

0 commit comments

Comments
 (0)