Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some warnings in tests #140

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 0 additions & 8 deletions cxx4/test_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,17 +409,9 @@ try
dummyFill.mem3[1]=97;
dummyFill.mem3[2]=98;

struct3 dummyStruct2[2];
dummyStruct2[0].mem1=1;
dummyStruct2[0].mem2=-1.23456;
dummyStruct2[0].mem3[0]=1;
dummyStruct2[0].mem3[1]=-6;
dummyStruct2[0].mem3[2]=20;

var_3.setFill(true,dummyFill);

vector<size_t> index(1);index[0]=1;
//var_3.putVar(&dummyStruct2);
var_3.putVar(index,&dummyStruct);

NcVar var_4(ncFile.getVar("var_3"));
Expand Down
4 changes: 2 additions & 2 deletions examples/pres_temp_4D_plugin_rd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ int main()
for (int lat = 0; lat < NLAT; lat++)
for (int lon = 0; lon < NLON; lon++)
{
if(pres_in[lvl][lat][lon] != (float) (SAMPLE_PRESSURE + i)) return NC_ERR;
if(temp_in[lvl][lat][lon] != (float)(SAMPLE_TEMP + i++)) return NC_ERR;
if(pres_in[lvl][lat][lon] != SAMPLE_PRESSURE + static_cast<float>(i)) return NC_ERR;
if(temp_in[lvl][lat][lon] != SAMPLE_TEMP + static_cast<float>(i++)) return NC_ERR;
}

} // next record
Expand Down
36 changes: 19 additions & 17 deletions examples/pres_temp_4D_plugin_wr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ unsigned int idp = BZIP2_ID;
size_t nparamsp = BZIP2_NPARAMS;

// Names of things.
#define LVL_NAME "level"
#define LAT_NAME "latitude"
#define LON_NAME "longitude"
#define REC_NAME "time"
#define PRES_NAME "pressure"
#define TEMP_NAME "temperature"
#define MAX_ATT_LEN 80
constexpr auto LVL_NAME = "level";
constexpr auto LAT_NAME = "latitude";
constexpr auto LON_NAME = "longitude";
constexpr auto REC_NAME = "time";
constexpr auto PRES_NAME = "pressure";
constexpr auto TEMP_NAME = "temperature";
constexpr auto MAX_ATT_LEN = 80;
// These are used to construct some example data.
#define SAMPLE_PRESSURE 900
#define SAMPLE_TEMP 9.0
#define START_LAT 25.0
#define START_LON -125.0
constexpr float SAMPLE_PRESSURE = 900;
constexpr float SAMPLE_TEMP = 9.0;
constexpr float START_LAT = 25.0;
constexpr float START_LON = -125.0;


string UNITS = "units";
Expand Down Expand Up @@ -84,17 +84,19 @@ int main()

// create some pretend data. If this wasn't an example program, we
// would have some real data to write for example, model output.
for (int lat = 0; lat < NLAT; lat++)
lats[lat] = START_LAT + 5. * lat;
for (int lon = 0; lon < NLON; lon++)
lons[lon] = START_LON + 5. * lon;
for (int lat = 0; lat < NLAT; lat++) {
lats[lat] = START_LAT + 5.f * static_cast<float>(lat);
}
for (int lon = 0; lon < NLON; lon++) {
lons[lon] = START_LON + 5.f * static_cast<float>(lon);
}

for (int lvl = 0; lvl < NLVL; lvl++)
for (int lat = 0; lat < NLAT; lat++)
for (int lon = 0; lon < NLON; lon++)
{
pres_out[lvl][lat][lon] =(float) (SAMPLE_PRESSURE + i);
temp_out[lvl][lat][lon] = (float)(SAMPLE_TEMP + i++);
pres_out[lvl][lat][lon] = SAMPLE_PRESSURE + static_cast<float>(i);
temp_out[lvl][lat][lon] = SAMPLE_TEMP + static_cast<float>(i++);
}

try
Expand Down
4 changes: 2 additions & 2 deletions examples/pres_temp_4D_rd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ int main()
for (int lat = 0; lat < NLAT; lat++)
for (int lon = 0; lon < NLON; lon++)
{
if(pres_in[lvl][lat][lon] != (float) (SAMPLE_PRESSURE + i)) return NC_ERR;
if(temp_in[lvl][lat][lon] != (float)(SAMPLE_TEMP + i++)) return NC_ERR;
if(pres_in[lvl][lat][lon] != SAMPLE_PRESSURE + static_cast<float>(i)) return NC_ERR;
if(temp_in[lvl][lat][lon] != SAMPLE_TEMP + static_cast<float>(i++)) return NC_ERR;
}

} // next record
Expand Down
53 changes: 28 additions & 25 deletions examples/pres_temp_4D_wr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ using namespace netCDF::exceptions;

// We are writing 4D data, a 2 x 6 x 12 lvl-lat-lon grid, with 2
// timesteps of data.
#define NDIMS 4
#define NLVL 2
#define NLAT 6
#define NLON 12
#define NREC 2
constexpr int NDIMS = 4;
constexpr int NLVL = 2;
constexpr int NLAT = 6;
constexpr int NLON = 12;
constexpr int NREC = 2;

// Names of things.
#define LVL_NAME "level"
#define LAT_NAME "latitude"
#define LON_NAME "longitude"
#define REC_NAME "time"
#define PRES_NAME "pressure"
#define TEMP_NAME "temperature"
#define MAX_ATT_LEN 80
constexpr auto LVL_NAME = "level";
constexpr auto LAT_NAME = "latitude";
constexpr auto LON_NAME = "longitude";
constexpr auto REC_NAME = "time";
constexpr auto PRES_NAME = "pressure";
constexpr auto TEMP_NAME = "temperature";
constexpr auto MAX_ATT_LEN = 80;
// These are used to construct some example data.
#define SAMPLE_PRESSURE 900
#define SAMPLE_TEMP 9.0
#define START_LAT 25.0
#define START_LON -125.0
constexpr float SAMPLE_PRESSURE = 900;
constexpr float SAMPLE_TEMP = 9.0;
constexpr float START_LAT = 25.0;
constexpr float START_LON = -125.0;


string UNITS = "units";
Expand All @@ -64,7 +64,8 @@ string LON_UNITS = "degrees_east";
int main()
{
// We will write latitude and longitude fields.
float lats[NLAT],lons[NLON];
float lats[NLAT];
float lons[NLON];

// Program variables to hold the data we will write out. We will
// only need enough space to hold one timestep of data; one record.
Expand All @@ -75,18 +76,20 @@ int main()

// create some pretend data. If this wasn't an example program, we
// would have some real data to write for example, model output.
for (int lat = 0; lat < NLAT; lat++)
lats[lat] = START_LAT + 5. * lat;
for (int lon = 0; lon < NLON; lon++)
lons[lon] = START_LON + 5. * lon;
for (int lat = 0; lat < NLAT; lat++) {
lats[lat] = START_LAT + 5.f * static_cast<float>(lat);
}
for (int lon = 0; lon < NLON; lon++) {
lons[lon] = START_LON + 5.f * static_cast<float>(lon);
}

for (int lvl = 0; lvl < NLVL; lvl++)
for (int lat = 0; lat < NLAT; lat++)
for (int lon = 0; lon < NLON; lon++)
{
pres_out[lvl][lat][lon] =(float) (SAMPLE_PRESSURE + i);
temp_out[lvl][lat][lon] = (float)(SAMPLE_TEMP + i++);
}
{
pres_out[lvl][lat][lon] = SAMPLE_PRESSURE + static_cast<float>(i);
temp_out[lvl][lat][lon] = SAMPLE_TEMP + static_cast<float>(i++);
}

try
{
Expand Down
4 changes: 2 additions & 2 deletions examples/sfc_pres_temp_rd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ int main(void)
// Check the data.
for (int lat = 0; lat < NLAT; lat++)
for (int lon = 0; lon < NLON; lon++)
if (presIn[lat][lon] != SAMPLE_PRESSURE + (lon * NLAT + lat)
|| tempIn[lat][lon] != SAMPLE_TEMP + .25 * (lon * NLAT + lat))
if (presIn[lat][lon] != SAMPLE_PRESSURE + static_cast<float>(lon * NLAT + lat)
|| tempIn[lat][lon] != SAMPLE_TEMP + .25f * static_cast<float>(lon * NLAT + lat))
return NC_ERR;

// Each of the netCDF variables has a "units" attribute. Let's read
Expand Down
22 changes: 12 additions & 10 deletions examples/sfc_pres_temp_wr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ string LAT_NAME = "latitude";
string LON_NAME ="longitude";

// These are used to construct some example data.
#define SAMPLE_PRESSURE 900
#define SAMPLE_TEMP 9.0
#define START_LAT 25.0
#define START_LON -125.0
constexpr float SAMPLE_PRESSURE = 900;
constexpr float SAMPLE_TEMP = 9.0;
constexpr float START_LAT = 25.0;
constexpr float START_LON = -125.0;

// Return this to OS if there is a failure.
#define NC_ERR 2
Expand All @@ -62,20 +62,22 @@ int main(void)
// hold the actual latitudes and longitudes. Since they hold data
// about the coordinate system, the netCDF term for these is:
// "coordinate variables."
for(int lat = 0;lat < NLAT; lat++)
lats[lat] = START_LAT + 5.*lat;
for(int lat = 0;lat < NLAT; lat++) {
lats[lat] = START_LAT + 5.f*static_cast<float>(lat);
}

for(int lon = 0; lon < NLON; lon++)
lons[lon] = START_LON + 5.*lon;
for(int lon = 0; lon < NLON; lon++) {
lons[lon] = START_LON + 5.f*static_cast<float>(lon);
}

// Create some pretend data. If this wasn't an example program, we
// would have some real data to write, for example, model
// output.
for (int lat = 0; lat < NLAT; lat++)
for(int lon = 0;lon < NLON; lon++)
{
presOut[lat][lon] = SAMPLE_PRESSURE + (lon * NLAT + lat);
tempOut[lat][lon] = SAMPLE_TEMP + .25 * (lon * NLAT +lat);
presOut[lat][lon] = SAMPLE_PRESSURE + static_cast<float>(lon * NLAT + lat);
tempOut[lat][lon] = SAMPLE_TEMP + .25f * static_cast<float>(lon * NLAT +lat);
}

try
Expand Down
20 changes: 12 additions & 8 deletions examples/simple_xy_wr_formats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,24 @@ int create_file(string filename, NcFile::FileFormat format) {
int main()
{
int ret;
if(ret = create_file("simple_xy_nc4.nc", NcFile::nc4))
return ret;
if ((ret = create_file("simple_xy_nc4.nc", NcFile::nc4))) {
return ret;
}
cout << "*** SUCCESS creating nc4 file" << endl;

if(ret = create_file("simple_xy_nc4classic.nc", NcFile::nc4classic))
return ret;
if ((ret = create_file("simple_xy_nc4classic.nc", NcFile::nc4classic))) {
return ret;
}
cout << "*** SUCCESS creating nc4classic file" << endl;

if(ret = create_file("simple_xy_classic.nc", NcFile::classic))
return ret;
if ((ret = create_file("simple_xy_classic.nc", NcFile::classic))) {
return ret;
}
cout << "*** SUCCESS creating classic file" << endl;

if(ret = create_file("simple_xy_classic64.nc", NcFile::classic64))
return ret;
if ((ret = create_file("simple_xy_classic64.nc", NcFile::classic64))) {
return ret;
}
cout << "*** SUCCESS creating classic64 file" << endl;

return 0;
Expand Down