Skip to content

Commit b698ef2

Browse files
committed
fix netcdf4 read
1 parent 9a56514 commit b698ef2

6 files changed

Lines changed: 12 additions & 19 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ option(PIO_USE_MPIIO "Enable support for MPI-IO auto detect" ON)
121121
option(PIO_USE_MPISERIAL "Enable mpi-serial support (instead of MPI)" OFF)
122122
option(PIO_USE_PNETCDF_VARD "Use pnetcdf put_vard" OFF)
123123
option(WITH_PNETCDF "Require the use of PnetCDF" ON)
124-
option(PIO_USE_GDAL "Enable support for Geospatial Data Abstraction Library" ON)
124+
option(PIO_USE_GDAL "Enable support for Geospatial Data Abstraction Library" OFF)
125125
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
126126

127127
if(APPLE)

src/clib/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ set (src topology.c pio_file.c pioc_support.c pio_lists.c
2828
if (NETCDF_INTEGRATION)
2929
set (src ${src} ../ncint/nc_get_vard.c ../ncint/ncintdispatch.c ../ncint/ncint_pio.c ../ncint/nc_put_vard.c)
3030
endif ()
31-
# This needs to be in an IF statement. using GDAL_INTEGRATION. But haven't figured that out yet.
31+
3232
if (PIO_USE_GDAL)
3333
set (src ${src} pio_gdal.c)
3434
endif()

src/clib/pio_darray_int.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,8 @@ recv_and_write_data(file_desc_t *file, const int *varids, const int *frame,
999999
#ifdef PIO_ENABLE_GDAL
10001000
if (file->iotype == PIO_IOTYPE_GDAL)
10011001
ierr = GDALc_shp_write_float_field(file->pio_ncid, varids[nv], start, count, bufptr);
1002+
else
10021003
#endif
1003-
if (file->iotype == PIO_IOTYPE_NETCDF)
10041004
if ((ierr = nc_put_vara(file->fh, varids[nv], start, count, bufptr)))
10051005
return check_netcdf2(ios, NULL, ierr, __FILE__, __LINE__);
10061006
}

tests/cunit/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,11 @@ else ()
361361
add_custom_target(link_target ALL
362362
COMMAND ${CMAKE_COMMAND} -E create_symlink
363363
${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data)
364+
add_dependencies(tests link_target)
364365
add_mpi_test(test_gdal
365366
EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/test_gdal
366367
NUMPROCS ${EXACTLY_FOUR_TASKS}
367368
TIMEOUT ${DEFAULT_TEST_TIMEOUT})
368-
set_tests_properties(test_gdal PROPERTIES DEPENDS link_target)
369-
370369
endif()
371370
endif ()
372371
MESSAGE("CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}")

tests/cunit/test_gdal.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ int test_gdal(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank,
154154
{
155155
sprintf(filename, "data/cb_2018_us_region_20m.shp");
156156

157+
assert(filename);
158+
157159
test_data_in = test_data_float_in;
158160
/* Open the file. */
159161
if ((ret = GDALc_openfile(iosysid, &ncid2, &hDSp, &iotype, filename, PIO_NOWRITE)))

tests/cunit/test_pioc.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,17 @@ int check_darray_file(int iosysid, int ntasks, int my_rank, char *filename)
170170
if ((ret = PIOc_read_darray(ncid, 0, ioid, arraylen, &data_in)))
171171
ERR(ret);
172172

173-
/* Check data. */
174-
printf("my_rank %d data_in %f\n",my_rank, data_in);
175-
if (data_in != my_rank * 10)
176-
ERR(ERR_WRONG);
177-
178173
/* Try to write, but this will fail because file was opened with
179174
* NOWRITE. */
180175
float fillvalue = 0.0;
181176
float test_data = my_rank * 10;
182177
if (PIOc_write_darray(ncid, 0, ioid, arraylen, &test_data, &fillvalue) != PIO_EPERM)
183178
ERR(ret);
184179

180+
/* Check data. */
181+
if (data_in != my_rank * 10)
182+
ERR(ERR_WRONG);
183+
185184
/* Close the file. */
186185
if ((ret = PIOc_closefile(ncid)))
187186
ERR(ret);
@@ -210,7 +209,7 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank
210209
{
211210
/* Create the filename. */
212211
sprintf(filename, "%s_flavor_%d_fv_%d.nc", TEST_NAME, flavor[fmt], fv);
213-
printf("Creating file %s\n",filename);
212+
214213
/* Create the netCDF output file. */
215214
if ((ret = PIOc_createfile(iosysid, &ncid, &(flavor[fmt]), filename, PIO_CLOBBER)))
216215
ERR(ret);
@@ -238,17 +237,10 @@ int test_darray(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank
238237
float fillvalue = PIO_FILL_FLOAT;
239238
float *fillvaluep = fv ? &fillvalue : NULL;
240239
float test_data[arraylen];
241-
for (int f = 0; f < arraylen; f++){
240+
for (int f = 0; f < arraylen; f++)
242241
test_data[f] = my_rank * 10 + f;
243-
if (flavor[fmt] == 3)
244-
printf("my_rank %d test_data[%d]%f\n",my_rank, f, test_data[f]);
245-
}
246-
if (flavor[fmt] == 3)
247-
PIOc_set_log_level(3);
248242
if ((ret = PIOc_write_darray(ncid, varid, ioid, arraylen, test_data, fillvaluep)))
249243
ERR(ret);
250-
if (flavor[fmt] == 3)
251-
PIOc_set_log_level(0);
252244

253245
/* Close the netCDF file. */
254246
if ((ret = PIOc_closefile(ncid)))

0 commit comments

Comments
 (0)