Skip to content

Commit ae0ba19

Browse files
authored
Merge pull request #1 from jedwards4b/GDAL_jpe2
Gdal jpe2
2 parents 83907b5 + 6c5612a commit ae0ba19

8 files changed

Lines changed: 68 additions & 36 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ option (PIO_USE_MPIIO "Enable support for MPI-IO auto detect" ON)
9595
option (PIO_USE_MPISERIAL "Enable mpi-serial support (instead of MPI)" OFF)
9696
option (PIO_USE_PNETCDF_VARD "Use pnetcdf put_vard " OFF)
9797
option (WITH_PNETCDF "Require the use of PnetCDF" ON)
98+
option (PIO_USE_GDAL "Enable support for Geospatial Data Abstraction Library ON")
9899
option (BUILD_SHARED_LIBS "Build shared libraries" OFF)
99100

100101
if(APPLE)
@@ -110,6 +111,14 @@ else()
110111
set(USE_VARD 0)
111112
endif()
112113

114+
# Set a variable that appears in the config.h.in file.
115+
if(PIO_USE_GDAL)
116+
set(USE_GDAL 1)
117+
else()
118+
set(USE_GDAL 0)
119+
endif()
120+
121+
113122
# Set a variable that appears in the config.h.in file.
114123
if(PIO_ENABLE_LOGGING)
115124
set(ENABLE_LOGGING 1)

cmake_config.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,6 @@
4646
/* Does PIO support using pnetcdf for I/O? */
4747
#cmakedefine _PNETCDF
4848

49+
#cmakedefine USE_GDAL
50+
4951
#endif /* _PIO_CONFIG_ */

src/clib/CMakeLists.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ 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 ()
3131
# This needs to be in an IF statement. using GDAL_INTEGRATION. But haven't figured that out yet.
32-
set (src ${src} pio_gdal.c)
32+
if (USE_GDAL)
33+
set (src ${src} pio_gdal.c)
34+
endif()
3335

3436
add_library (pioc ${src})
3537

@@ -176,12 +178,12 @@ if (PIO_USE_MPISERIAL)
176178
endif ()
177179

178180
#===== GDAL ===== <M.Long>
179-
#if (GDAL_Found)
181+
if (USE_GDAL)
180182
target_include_directories (pioc
181183
PUBLIC ${GDAL_INCLUDE_DIR})
182184
target_link_libraries (pioc
183-
PUBLIC ${GDAL_LIBRARY})
184-
#endif ()
185+
PUBLIC "-L${GDAL_LIBRARY_PATH} -lgdal")
186+
endif ()
185187

186188
include(CheckTypeSize)
187189
check_type_size("size_t" SIZEOF_SIZE_T)

src/clib/pio_darray.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,10 +949,12 @@ PIOc_read_darray(int ncid, int varid, int ioid, PIO_Offset arraylen,
949949
if ((ierr = pio_read_darray_nc(file, iodesc, varid, iobuf)))
950950
return pio_err(ios, file, ierr, __FILE__, __LINE__);
951951
break;
952+
#ifdef USE_GDAL
952953
case PIO_IOTYPE_GDAL:
953954
if ((ierr = pio_read_darray_shp(file, iodesc, varid, iobuf)))
954955
return pio_err(ios, file, ierr, __FILE__, __LINE__);
955956
break;
957+
#endif
956958
default:
957959
return pio_err(NULL, NULL, PIO_EBADIOTYPE, __FILE__, __LINE__);
958960
}

src/clib/pio_gdal.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <config.h>
22
#include <pio.h>
33
#include <pio_internal.h>
4+
#ifdef USE_GDAL
45
#include <ogr_api.h>
56

67
/**
@@ -457,11 +458,6 @@ int GDALc_inq_timeid(int fileid, int *timeid) { // Is there a field of type OFTD
457458
for (int i=0;i<(file->nvars)-1;i++) {
458459
OGRFieldDefnH hFlD = OGR_FD_GetFieldDefn(hFD,i);
459460
OGRFieldType Fld = OGR_Fld_GetType(hFlD);
460-
if (Fld == NULL)
461-
return pio_err(NULL, NULL, ierr, __FILE__, __LINE__);
462-
463-
// const char* FldTyp = OGR_GetFieldTypeName(Fld);
464-
// PRINTMSG("Field type: " << FldTyp);
465461
}
466462

467463
// OGR_FD_Destroy(hFD);
@@ -816,3 +812,4 @@ GDALc_shp_get_float_field(int fileid, int varid, const size_t *startp,
816812
/**
817813
* @}
818814
*/
815+
#endif

src/clib/pio_internal.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@
9191

9292
#define PIO_DATATYPE_NULL MPI_CHAR
9393

94+
#ifdef USE_GDAL
95+
int
96+
pio_read_darray_shp(file_desc_t *file, io_desc_t *iodesc, int vid,
97+
void *iobuf);
98+
#endif
9499

95100
#if PIO_ENABLE_LOGGING
96101
void pio_log(int severity, const char *fmt, ...);

tests/cunit/CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ endif()
2222
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0")
2323
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0")
2424

25+
26+
set(CMAKE_MACOSX_RPATH 1)
27+
if(USE_GDAL)
28+
set(CMAKE_BUILD_RPATH ${GDAL_LIBRARY_PATH})
29+
endif()
2530
#==============================================================================
2631
# PREPARE FOR TESTING
2732
#==============================================================================
@@ -344,9 +349,16 @@ else ()
344349
# EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/test_async_perf
345350
# NUMPROCS ${EXACTLY_FOUR_TASKS}
346351
# TIMEOUT ${DEFAULT_TEST_TIMEOUT})
347-
add_mpi_test(test_gdal
348-
EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/test_gdal
349-
NUMPROCS ${EXACTLY_FOUR_TASKS}
350-
TIMEOUT ${DEFAULT_TEST_TIMEOUT})
352+
if(USE_GDAL)
353+
add_custom_target(link_target ALL
354+
COMMAND ${CMAKE_COMMAND} -E create_symlink
355+
${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_CURRENT_BINARY_DIR}/data)
356+
add_mpi_test(test_gdal
357+
EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/test_gdal
358+
NUMPROCS ${EXACTLY_FOUR_TASKS}
359+
TIMEOUT ${DEFAULT_TEST_TIMEOUT})
360+
set_tests_properties(test_gdal PROPERTIES DEPENDS link_target)
361+
362+
endif()
351363
endif ()
352364
MESSAGE("CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}")

tests/cunit/test_gdal.c

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -167,27 +167,26 @@ int test_gdal(int iosysid, int ioid, int num_flavors, int *flavor, int my_rank,
167167
ERR(ret);
168168

169169
/* Check the results. */
170-
// TEMPORARILY DISABLED UNTIL A SEGFAULT IS DIAGNOSED
171-
// for (int f = 0; f < arraylen; f++)
172-
// {
173-
// switch (pio_type)
174-
// {
175-
// case PIO_INT:
176-
// if (test_data_int_in[f] != test_data_int[f])
177-
// return ERR_WRONG;
178-
// break;
179-
// case PIO_FLOAT:
180-
// if (test_data_float_in[f] != test_data_float[f])
181-
// return ERR_WRONG;
182-
// break;
183-
// case PIO_DOUBLE:
184-
// if (test_data_double_in[f] != test_data_double[f])
185-
// return ERR_WRONG;
186-
// break;
187-
// default:
188-
// ERR(ERR_WRONG);
189-
// }
190-
// }
170+
for (int f = 0; f < arraylen; f++)
171+
{
172+
switch (pio_type)
173+
{
174+
case PIO_INT:
175+
if (test_data_int_in[f] != test_data_int[f])
176+
return ERR_WRONG;
177+
break;
178+
case PIO_FLOAT:
179+
if (test_data_float_in[f] != test_data_float[f])
180+
return ERR_WRONG;
181+
break;
182+
case PIO_DOUBLE:
183+
if (test_data_double_in[f] != test_data_double[f])
184+
return ERR_WRONG;
185+
break;
186+
default:
187+
ERR(ERR_WRONG);
188+
}
189+
}
191190

192191
/* Close the netCDF file. */
193192
if ((ret = PIOc_closefile(ncid2)))
@@ -247,7 +246,7 @@ int test_all_gdal(int iosysid, int num_flavors, int *flavor, int my_rank,
247246
int main(int argc, char **argv)
248247
{
249248
#define NUM_REARRANGERS_TO_TEST 2
250-
int rearranger[NUM_REARRANGERS_TO_TEST] = {PIO_REARR_BOX, PIO_REARR_SUBSET};
249+
int rearranger[NUM_REARRANGERS_TO_TEST] = {PIO_REARR_SUBSET, PIO_REARR_BOX};
251250
int my_rank;
252251
int ntasks;
253252
int num_flavors; /* Number of PIO netCDF flavors in this build. */
@@ -283,10 +282,14 @@ int main(int argc, char **argv)
283282
{
284283
/* Initialize the PIO IO system. This specifies how
285284
* many and which processors are involved in I/O. */
286-
if ((ret = PIOc_Init_Intracomm(test_comm, TARGET_NTASKS, ioproc_stride,
285+
if ((ret = PIOc_Init_Intracomm(test_comm, NUM_IO_PROCS, ioproc_stride,
287286
ioproc_start, rearranger[r], &iosysid)))
288287
return ret;
289288

289+
/* if ((ret = PIOc_set_rearr_opts(iosysid, PIO_REARR_COMM_P2P, PIO_REARR_COMM_FC_2D_DISABLE, false, false, PIO_REARR_COMM_UNLIMITED_PEND_REQ, false, false, PIO_REARR_COMM_UNLIMITED_PEND_REQ)))
290+
return ret;
291+
*/
292+
290293
/* Run tests. */
291294
if ((ret = test_all_gdal(iosysid, num_flavors, flavor, my_rank, test_comm)))
292295
return ret;

0 commit comments

Comments
 (0)