1
1
#include " diagnostics/histogram.hpp"
2
2
3
3
#include < ekat_team_policy_utils.hpp>
4
+ #include < ekat_string_utils.hpp>
4
5
5
6
6
7
namespace scream {
@@ -34,13 +35,8 @@ void HistogramDiag::initialize_impl(const RunType /*run_type*/) {
34
35
field_layout.to_string () + " \n " );
35
36
36
37
// extract bin values from configuration
37
- std::istringstream stream (m_bin_configuration);
38
- std::string token;
39
- std::vector<Real> bin_values;
40
- while (std::getline (stream, token, ' _' )) {
41
- bin_values.push_back (std::stod (token));
42
- }
43
- const int num_bins = bin_values.size ()-1 ;
38
+ std::vector<std::string> bin_strings = ekat::split (m_bin_configuration, " _" );
39
+ const int num_bins = bin_strings.size ()-1 ;
44
40
45
41
// allocate histogram field
46
42
FieldLayout diagnostic_layout ({CMP}, {num_bins}, {" bin" });
@@ -60,7 +56,7 @@ void HistogramDiag::initialize_impl(const RunType /*run_type*/) {
60
56
using RangePolicy = Kokkos::RangePolicy<Field::device_t ::execution_space>;
61
57
Kokkos::parallel_for (" store_histogram_bin_values_" + field.name (),
62
58
RangePolicy (0 , bin_values_layout.dim (0 )), [&] (int i) {
63
- bin_values_view (i) = bin_values [i];
59
+ bin_values_view (i) = std::stod (bin_strings [i]) ;
64
60
});
65
61
}
66
62
0 commit comments