Skip to content

Commit b275068

Browse files
authored
Report error if no values in array (fake_spec_file) (#196)
1 parent 1b09467 commit b275068

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/fake_spec_file.F90

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ subroutine spec_file_read_timed_real_array(file, name, times, vals)
232232
times(1), size(times), &
233233
vals(1), size(vals) &
234234
)
235+
if (size(times) < 1) then
236+
print*, 'must have at least one data poin in file ' // trim(file%name) // '::' // name
237+
call pmc_stop(925956383)
238+
end if
235239
end subroutine
236240

237241
subroutine spec_file_open(filename, file)

tests/test_scenario.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Authors: https://github.com/open-atmos/PyPartMC/graphs/contributors #
55
####################################################################################################
66

7+
import copy
78
import gc
89
import json
910

@@ -133,12 +134,25 @@ def test_init_env_state():
133134
# act
134135
sut.init_env_state(env_state, time)
135136

137+
@staticmethod
138+
@pytest.mark.xfail(strict=True)
139+
@pytest.mark.skipif("sys.platform != 'linux'")
140+
def test_ctor_fails_with_no_values_in_time_array():
141+
# arrange
142+
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
143+
gas_data = ppmc.GasData(GAS_DATA_CTOR_ARG_MINIMAL)
144+
ctor_arg = copy.deepcopy(SCENARIO_CTOR_ARG_MINIMAL)
145+
ctor_arg["temp_profile"][0]["time"] = []
146+
147+
# act
148+
_ = ppmc.Scenario(gas_data, aero_data, ctor_arg)
149+
136150
@staticmethod
137151
def test_multi_mode():
138152
# arrange
139153
aero_data = ppmc.AeroData(AERO_DATA_CTOR_ARG_MINIMAL)
140154
gas_data = ppmc.GasData(GAS_DATA_CTOR_ARG_MINIMAL)
141-
scenario_ctor_arg = SCENARIO_CTOR_ARG_MINIMAL
155+
scenario_ctor_arg = copy.deepcopy(SCENARIO_CTOR_ARG_MINIMAL)
142156
for entry in ("aero_emissions", "aero_background"):
143157
scenario_ctor_arg[entry][-1]["dist"] = [
144158
{"A": AERO_MODE_CTOR_LOG_NORMAL["test_mode"]},

0 commit comments

Comments
 (0)