ClimaCoupler.jl
ClimaCoupler.jl copied to clipboard
BCReader bugs
Bug 1
In the BCReader module's bcfile_info_init
function, we set a default parameter value date0 = nothing
. However, this fails later in the function when we try to call datetime_to_strdate(date0)
, which isn't defined to work on nothing
. See the issue here: https://github.com/CliMA/ClimaCoupler.jl/blob/main/src/BCReader.jl#L148
- This can be fixed by adding a line
date0 == nothing ? date0 = data_dates[1] : nothing
before settingsegment_idx0
Bug 2
A related issue is the use of a magic number in a BCReader test here. I'm not sure why this value is hardcoded, but I believe it isn't necessary if we make the change to bcfile_info_init
above.
- This can be fixed by making the
date0
fix inbcfile_info_init
and not passingsegment_idx0
to the constructor.
Bug 3
This module's update_midmonth_data!
function also fails when the date passed in (date
) is the same as the first date in the datafile. This should fall under the first case of if statements, but since the second comparison uses <
instead of <=
, it doesn't enter any of the cases.
- This can be fixed by changing
<
to<=
here.
Note Since the BCReader module had to be copied to ClimaLSM as of https://github.com/CliMA/ClimaLSM.jl/issues/243, these fixes are all implemented there and can be copied here.