@@ -1266,7 +1266,7 @@ ifeq "$(OPENACC)" "true"
1266
1266
endif # OPENACC eq true
1267
1267
1268
1268
1269
- pio_test : openmp_test openacc_test
1269
+ pio_test : openmp_test openacc_test pnetcdf_test
1270
1270
@#
1271
1271
@# PIO_VERS will be set to:
1272
1272
@# 0 if no working PIO library was detected (and .piotest.log will contain error messages)
@@ -1374,11 +1374,52 @@ mpi_f08_test:
1374
1374
$(if $(findstring 1,$(MPAS_MPI_F08 ) ) , $(eval MPI_F08_MESSAGE = "Using the mpi_f08 module.") , )
1375
1375
$(if $(findstring 1,$(MPAS_MPI_F08 ) ) , $(info mpi_f08 module detected.) )
1376
1376
1377
+
1378
+ pnetcdf_test :
1379
+ @#
1380
+ @# Create test C programs that look for PNetCDF header file and some symbols in it
1381
+ @#
1382
+ ifneq "$(PNETCDF ) " ""
1383
+ @echo "Checking for a working PnetCDF library..."
1384
+ @printf "# include \"pnetcdf.h\"\n\
1385
+ &#include \"mpi.h\"\n\
1386
+ &int main(){\n\
1387
+ & int err, ncid;\n\
1388
+ & err = ncmpi_create(MPI_COMM_WORLD, \"foo.nc\", NC_NOCLOBBER, MPI_INFO_NULL, &ncid);\n\
1389
+ & return 0;\n\
1390
+ &}\n" | sed 's/&/ /' > pnetcdf.c
1391
+ @( $(CC) pnetcdf.c $(CPPINCLUDES) $(CFLAGS) $(LDFLAGS) -L$(PNETCDF)/$(PNETCDFLIBLOC) -lpnetcdf -o pnetcdf.out > pnetcdf.log 2>&1; \
1392
+ if [ $$? -eq 0 ] ; then \
1393
+ echo "$(CC) can compile test PnetCDF C program."; \
1394
+ else \
1395
+ echo "*********************************************************"; \
1396
+ echo "ERROR: Test PnetCDF C program could not be compiled by $(CC)."; \
1397
+ echo "Please ensure you have a working PnetCDF library installed."; \
1398
+ echo ""; \
1399
+ echo "The following compilation command failed with errors:" ; \
1400
+ echo "$(CC) pnetcdf.c $(CPPINCLUDES) $(CFLAGS) $(LDFLAGS) -L$(PNETCDF)/$(PNETCDFLIBLOC) -lpnetcdf -o pnetcdf.out"; \
1401
+ echo ""; \
1402
+ echo "Test program pnetcdf.c and output pnetcdf.log have been left"; \
1403
+ echo "in the top-level MPAS directory for further debugging"; \
1404
+ echo "*********************************************************"; \
1405
+ rm -f pnetcdf.out; exit 1; \
1406
+ fi )
1407
+
1408
+ @rm -f pnetcdf.c pnetcdf.out pnetcdf.log
1409
+ else
1410
+ @echo "*********************************************************"; \
1411
+ echo "ERROR: The PNETCDF environment variable isn't set."; \
1412
+ echo "Please set this variable to where PnetCDF is installed."; \
1413
+ echo "*********************************************************"; \
1414
+ exit 1
1415
+ endif
1416
+
1417
+
1377
1418
ifneq "$(PIO ) " ""
1378
- MAIN_DEPS = rebuild_check openmp_test openacc_test pio_test mpi_f08_test
1419
+ MAIN_DEPS = rebuild_check openmp_test openacc_test pnetcdf_test pio_test mpi_f08_test
1379
1420
override CPPFLAGS += "-DMPAS_PIO_SUPPORT"
1380
1421
else
1381
- MAIN_DEPS = rebuild_check openmp_test openacc_test mpi_f08_test
1422
+ MAIN_DEPS = rebuild_check openmp_test openacc_test pnetcdf_test mpi_f08_test
1382
1423
IO_MESSAGE = "Using the SMIOL library."
1383
1424
override CPPFLAGS += "-DMPAS_SMIOL_SUPPORT"
1384
1425
endif
0 commit comments