Skip to content

Commit d91d284

Browse files
committed
minor fixes: docs typos, output writer closing, FrequencyBasedCallback
1 parent 014debf commit d91d284

File tree

8 files changed

+18
-20
lines changed

8 files changed

+18
-20
lines changed

docs/src/tutorials/integrated/snowy_land_fluxnet_tutorial.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# # Fluxnet simulations with the full land model: snow, soil, canopy
22

33
# In the
4-
# [SoilCanopyModel tutorial](docs/src/tutorials/integrated/soil_canopy_fluxnet_tutorial.md),
4+
# [SoilCanopyModel tutorial](docs/src/tutorials/integrated/soil_canopy_fluxnet_tutorial.jl),
55
# we demonstrated how to run the an integrated model with a soil and
66
# canopy component at the US-MOz fluxnet site.
77
# Here we add in a snow component, and run the site at the Niwot Ridge site instead.
88
# The forcing data was obtained from
99
# AmeriFlux FLUXNET: https://doi.org/10.17190/AMF/1871141
10+
1011
# Citation: Peter D. Blanken, Russel K. Monson, Sean P. Burns,
1112
# David R. Bowling, Andrew A. Turnipseed (2022),
1213
# AmeriFlux FLUXNET-1F US-NR1 Niwot Ridge Forest (LTER NWT1),
@@ -15,7 +16,8 @@
1516
# The focus of this tutorial is to learn the steps towards setting up and
1617
# running an integrated simulation, and less on the parameterization
1718
# choices. As such, the default parameters are implicitly set.
18-
# To experiment with modularity in the parameters and parameterizations, please see the [canopy parameterizations tutorial](docs/src/tutorials/standalone/Canopy/changing_canopy_parameterizations.md) or the [soiil parameterizations tutorial](docs/src/tutorials/standalone/Soil/changing_soil_parameterizations.md).
19+
# To experiment with modularity in the parameters and parameterizations, please see the [canopy parameterizations tutorial](docs/src/tutorials/standalone/Canopy/changing_canopy_parameterizations.jl)
20+
# or the [soil parameterizations tutorial](docs/src/tutorials/standalone/Soil/changing_soil_parameterizations.jl).
1921

2022
# # Preliminary Setup
2123
using Dates
@@ -40,7 +42,7 @@ earth_param_set = LP.LandParameters(FT);
4042
# US-NR1 tower. We also
4143
# read in the MODIS LAI and let that vary in time in a prescribed manner.
4244
site_ID = "US-NR1";
43-
site_ID_val = FluxnetSimulations.replace_hyphen(site_ID)
45+
site_ID_val = FluxnetSimulations.replace_hyphen(site_ID);
4446
# Get the latitude and longitude in degrees, as well as the
4547
# time offset in hours of local time from UTC
4648
(; time_offset, lat, long) =
@@ -106,7 +108,7 @@ diagnostics = ClimaLand.default_diagnostics(
106108
average_period = :hourly,
107109
);
108110

109-
# How often we want to update the forcing.
111+
# Choose how often we want to update the forcing.
110112
data_dt = Second(FluxnetSimulations.get_data_dt(site_ID));
111113
updateat = Array(start_date:data_dt:stop_date);
112114

docs/src/tutorials/integrated/soil_canopy_fluxnet_tutorial.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# # Fluxnet simulations with an integrated soil and canopy model
22

33
# In the
4-
# [standalone canopy tutorial](docs/src/tutorials/standalone/Canopy/canopy_tutorial.md),
4+
# [standalone canopy tutorial](docs/src/tutorials/standalone/Canopy/canopy_tutorial.jl),
55
# we demonstrated how to run the canopy model in
66
# standalone mode using a prescribed soil moisture
77
# and ground temperature. ClimaLand can also
@@ -14,13 +14,15 @@
1414
# located within an oak-hickory forest in Ozark, Missouri, USA.
1515
# The forcing data was obtained from
1616
# AmeriFlux FLUXNET: https://doi.org/10.17190/AMF/1854370
17+
1718
# Citation: Jeffrey Wood, Lianhong Gu (2025), AmeriFlux FLUXNET-1F US-MOz Missouri Ozark
1819
# Site, Ver. 5-7, AmeriFlux AMP, (Dataset). https://doi.org/10.17190/AMF/1854370
1920

2021
# The focus of this tutorial is to learn the steps towards setting up and
2122
# running an integrated simulation, and less on the parameterization
2223
# choices. As such, the default parameters are implicitly set.
23-
# To experiment with modularity in the parameters and parameterizations, please see the [canopy parameterizations tutorial](docs/src/tutorials/standalone/Canopy/changing_canopy_parameterizations.md) or the [soiil parameterizations tutorial](docs/src/tutorials/standalone/Soil/changing_soil_parameterizations.md).
24+
# To experiment with modularity in the parameters and parameterizations, please see the [canopy parameterizations tutorial](docs/src/tutorials/standalone/Canopy/changing_canopy_parameterizations.jl)
25+
# or the [soil parameterizations tutorial](docs/src/tutorials/standalone/Soil/changing_soil_parameterizations.jl).
2426

2527
# # Preliminary Setup
2628
using Dates
@@ -44,7 +46,7 @@ earth_param_set = LP.LandParameters(FT);
4446
# We will use prescribed atmospheric and radiative forcing from the
4547
# US-MOz tower.
4648
site_ID = "US-MOz";
47-
site_ID_val = FluxnetSimulations.replace_hyphen(site_ID)
49+
site_ID_val = FluxnetSimulations.replace_hyphen(site_ID);
4850
# Get the latitude and longitude in degrees, as well as the
4951
# time offset in hours of local time from UTC
5052
(; time_offset, lat, long) =
@@ -110,10 +112,11 @@ diagnostics = ClimaLand.default_diagnostics(
110112
average_period = :hourly,
111113
);
112114

113-
# How often we want to update the forcing.
115+
# Choose how often we want to update the forcing.
114116
data_dt = Second(FluxnetSimulations.get_data_dt(site_ID));
115117
updateat = Array(start_date:data_dt:stop_date);
116118

119+
# Now we can construct the simulation object and solve it.
117120
simulation = Simulations.LandSimulation(
118121
start_date,
119122
stop_date,

experiments/integrated/fluxnet/ozark_pft.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ simulation = LandSimulation(
347347
)
348348
sol = solve!(simulation)
349349

350-
ClimaLand.Diagnostics.close_output_writers(diags)
351350
comparison_data = FluxnetSimulations.get_comparison_data(site_ID, time_offset)
352351
savedir =
353352
joinpath(pkgdir(ClimaLand), "experiments/integrated/fluxnet/US-MOz/pft/out")

experiments/integrated/fluxnet/run_fluxnet.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ simulation = LandSimulation(
313313
)
314314
@time sol = solve!(simulation)
315315

316-
ClimaLand.Diagnostics.close_output_writers(diags)
317316
comparison_data = FluxnetSimulations.get_comparison_data(site_ID, time_offset)
318317
savedir =
319318
joinpath(pkgdir(ClimaLand), "experiments/integrated/fluxnet/$(site_ID)/out")

experiments/integrated/global/global_soil_canopy.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ simulation = LandSimulation(
146146
user_callbacks = (),
147147
)
148148
ClimaLand.Simulations.solve!(simulation)
149-
ClimaLand.Diagnostics.close_output_writers(diags)
150149

151150
# ClimaAnalysis
152151
if ClimaComms.iamroot(context)

experiments/standalone/Bucket/bucket_era5.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ sol = ClimaComms.@time ClimaComms.device() ClimaLand.Simulations.solve!(
204204
simulation,
205205
);
206206

207-
ClimaLand.Diagnostics.close_output_writers(diags)
208207

209208
simdir = ClimaAnalysis.SimDir(output_dir)
210209
short_names = ["rn", "tsfc", "qsfc", "lhf", "shf", "wsoil", "wsfc", "ssfc"]

experiments/standalone/Bucket/global_bucket_temporalmap.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ simulation, saved_values, nc_writer =
213213
sol = ClimaComms.@time ClimaComms.device() ClimaLand.Simulations.solve!(
214214
simulation,
215215
);
216-
close(nc_writer)
217216
output_dir = nc_writer.output_dir
218217

219218
simdir = ClimaAnalysis.SimDir(output_dir)
@@ -246,7 +245,6 @@ if PROFILING
246245
flame_file = joinpath(outdir, "flame_$device_suffix.html")
247246
ProfileCanvas.html_file(flame_file, results)
248247
@info "Save compute flame to $flame_file"
249-
close(nc_writer)
250248

251249
simulation, saved_values, nc_writer =
252250
setup_prob(start_date, start_date + Second(tf), Δt, outdir)
@@ -258,7 +256,6 @@ if PROFILING
258256
alloc_flame_file = joinpath(outdir, "alloc_flame_$device_suffix.html")
259257
ProfileCanvas.html_file(alloc_flame_file, profile)
260258
@info "Save allocation flame to $alloc_flame_file"
261-
close(nc_writer)
262259
end
263260

264261
# Interpolate to grid

src/shared_utilities/utils.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ function NaNCheckCallback(
684684
end
685685
affect! = (integrator) -> call_count_nans_state(integrator.u; mask)
686686

687-
SciMLBase.DiscreteCallback(cond, affect!)
687+
return SciMLBase.DiscreteCallback(cond, affect!)
688688
end
689689

690690
# no date version
@@ -730,10 +730,10 @@ arguments at a specified frequency in simulation time.
730730
integrator as its first argument and kwargs specified in
731731
`func_args`. Typically, such a function will look something like:
732732
(integrator; func_args) -> do_some_update(integrator.p, integrator.u, ...)
733-
Note that func_args can be empty.
733+
Note that func_args can be empty.
734734
735735
The callback uses `ClimaDiagnostics.EveryCalendarDtSchedule` to determine when to
736-
call the function based on the `frequency`.
736+
call the function based on the `frequency`.
737737
"""
738738
function FrequencyBasedCallback(
739739
frequency::Union{AbstractFloat, Dates.Period},
@@ -766,8 +766,8 @@ function FrequencyBasedCallback(
766766
cond = let schedule = schedule
767767
(u, t, integrator) -> schedule(integrator)
768768
end
769-
affect! = (integrator) -> call_count_nans_state(integrator.u; mask)
770-
SciMLBase.DiscreteCallback(cond, affect!)
769+
affect! = (integrator) -> func(integrator; func_args...)
770+
return SciMLBase.DiscreteCallback(cond, affect!)
771771
end
772772

773773
"""

0 commit comments

Comments
 (0)