Skip to content

Commit 93234b4

Browse files
committed
Adding some comments
Adding source code comments. No code change
1 parent 6ac8803 commit 93234b4

File tree

6 files changed

+145
-2
lines changed

6 files changed

+145
-2
lines changed

examples/cxx/e3sm_f.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "e3sm_fgi_utils.hpp"
22
#include "e3sm_fgi_data.hpp"
33

4+
/* Create a unique name for the test output */
45
static inline std::string get_fcase_test_fname(int iotype, int rearr)
56
{
67
const std::string FNAME_PREFIX = "spio_e3sm_fgi_f";
@@ -13,6 +14,7 @@ static inline std::string get_fcase_test_fname(int iotype, int rearr)
1314
+ FNAME_SUFFIX;
1415
}
1516

17+
/* Pseudo E3SM F case */
1618
static int test_fcase(MPI_Comm comm, int iosysid, const std::string &fname, int iotype)
1719
{
1820
int comm_rank = 0, comm_sz = 0;
@@ -37,6 +39,7 @@ static int test_fcase(MPI_Comm comm, int iosysid, const std::string &fname, int
3739
double dlev = 0;
3840
std::function<double(void )> gen_levels = [dlev] (void ) mutable { double d = dlev; dlev += 0.2; return d; };
3941

42+
/* Generates dates starting from date 15/06/21 */
4043
int start_date = 15;
4144
std::function<std::string(void )> gen_dates = [start_date] (void ) mutable {
4245
static const std::string month("06");
@@ -48,6 +51,7 @@ static int test_fcase(MPI_Comm comm, int iosysid, const std::string &fname, int
4851
return month + SEP + std::to_string(start_date++) + SEP + year;
4952
};
5053

54+
/* Generator for a simple 1D I/O decomposition */
5155
std::function<PIO_Offset(void )> decomp_1d_gen =
5256
[comm_rank, NCOL, NCOL_PER_PROC](void ){
5357
static const PIO_Offset INIT_IDX = 0;
@@ -62,6 +66,7 @@ static int test_fcase(MPI_Comm comm, int iosysid, const std::string &fname, int
6266
E3SM_FGI::SPIO_decomp decomp_1d("decomp_1d_ncol", iosysid, PIO_DOUBLE,
6367
std::vector<int>({static_cast<int>(NCOL)}), NCOL_PER_PROC, decomp_1d_gen);
6468

69+
/* 2D Decompisition generator : NCOL s are divided evenly among processes */
6570
std::function<PIO_Offset(void ) > decomp_2d_gen =
6671
[comm_rank, is_last_proc, NCOL, NCOL_PER_PROC, NLEV, idx, ilev](void ) mutable {
6772

@@ -83,6 +88,8 @@ static int test_fcase(MPI_Comm comm, int iosysid, const std::string &fname, int
8388
};
8489

8590
int lsz = NLEV * ((!is_last_proc) ? NCOL_PER_PROC : (NCOL - comm_rank * NCOL_PER_PROC));
91+
92+
/* Create 2D I/O decomposition for unlimited vars */
8693
E3SM_FGI::SPIO_decomp decomp_2d("decomp_2d_lev_ncol", iosysid, PIO_DOUBLE,
8794
std::vector<int>({NLEV, static_cast<int>(NCOL)}),
8895
lsz, decomp_2d_gen);
@@ -91,6 +98,7 @@ static int test_fcase(MPI_Comm comm, int iosysid, const std::string &fname, int
9198

9299
E3SM_FGI::SPIO_file fh(iosysid, fname, iotype, false);
93100

101+
/* Define dims/atts/vars */
94102
ret = fh.def({
95103
/* Global Attributes */
96104
std::make_shared<E3SM_FGI::SPIO_att>("ne", NE),
@@ -117,6 +125,7 @@ static int test_fcase(MPI_Comm comm, int iosysid, const std::string &fname, int
117125
return ret;
118126
}
119127

128+
/* Write variables/atts */
120129
ret = fh.put();
121130
if(ret != PIO_NOERR){
122131
Util::GVars::logger->log(Util::Logging::LogLevel::ERROR, "Putting file objects failed");
@@ -137,6 +146,7 @@ int E3SM_FGI::test_e3sm_fcase(MPI_Comm comm, const std::vector<int> &iotypes,
137146

138147
int io_stride = comm_sz / nioprocs;
139148

149+
/* Test F case for each combination of I/O type and I/O rearranger */
140150
Util::zip_for_each(iotypes.cbegin(), iotypes.cend(), rearrs.cbegin(), rearrs.cend(),
141151
[comm, nioprocs, io_stride](int iotype, int rearr){
142152
const int IOSYS_START_PROC = 0;

examples/cxx/e3sm_fgi.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
namespace Util{
77
namespace GVars{
8+
/* Types used for parsing user input */
9+
/* Available I/O types */
810
std::unordered_map<std::string, int> iotypes = {
911
{"PNETCDF", PIO_IOTYPE_PNETCDF},
1012
{"NETCDF", PIO_IOTYPE_NETCDF},
@@ -15,29 +17,34 @@ namespace Util{
1517
{"HDF5C", PIO_IOTYPE_HDF5C}
1618
};
1719

20+
/* Available I/O rearrangers */
1821
std::unordered_map<std::string, int> rearrs = {
1922
{"SUBSET", PIO_REARR_SUBSET},
2023
{"BOX", PIO_REARR_BOX},
2124
{"ANY", PIO_REARR_ANY}
2225
};
2326

27+
/* E3SM pseudo test cases */
2428
std::unordered_map<std::string, E3SM_FGI::Case_Type> cases = {
2529
{"F", E3SM_FGI::Case_Type::E3SM_F_CASE},
2630
{"G", E3SM_FGI::Case_Type::E3SM_G_CASE},
2731
{"I", E3SM_FGI::Case_Type::E3SM_I_CASE}
2832
};
2933

34+
/* Log levels */
3035
std::unordered_map<std::string, Util::Logging::LogLevel> llevels = {
3136
{"STATUS", Util::Logging::LogLevel::STATUS},
3237
{"VERBOSE", Util::Logging::LogLevel::VERBOSE},
3338
{"WARNING", Util::Logging::LogLevel::WARNING},
3439
{"ERROR", Util::Logging::LogLevel::ERROR}
3540
};
3641

42+
/* The global logger */
3743
std::shared_ptr<Util::Logging::Logger> logger;
3844
}
3945
}
4046

47+
/* Initialize the argparser options - specify the available user opts */
4148
static void init_user_options(spio_tool_utils::ArgParser &ap)
4249
{
4350
ap.add_opt("pio-format", "SCORPIO I/O type (for output data). Supported iotypes: " + Util::GVars::iotypes2str())
@@ -48,6 +55,7 @@ static void init_user_options(spio_tool_utils::ArgParser &ap)
4855
.add_opt("help", "Print help");
4956
}
5057

58+
/* Parse the user options */
5159
static int get_user_options(
5260
spio_tool_utils::ArgParser &ap,
5361
int argc, char *argv[],
@@ -172,6 +180,7 @@ int main(int argc, char *argv[])
172180
return ret;
173181
}
174182

183+
/* Only log from rank 0 */
175184
Util::GVars::logger->set_log_rank(0);
176185
Util::GVars::logger->set_log_level(log_lvl);
177186

0 commit comments

Comments
 (0)