Skip to content

Commit

Permalink
Merge pull request ESMCI#1719 from NCAR/ejh_next_5
Browse files Browse the repository at this point in the history
removed unneeded pre-processor flag _NETCDF (because netCDF is always present)
  • Loading branch information
edwardhartnett authored Aug 17, 2020
2 parents c99eb28 + b258478 commit 9b942c5
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 99 deletions.
14 changes: 2 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ test "x$enable_timing" = xyes || enable_timing=no
AC_MSG_RESULT([$enable_timing])
if test "x$enable_timing" = xyes; then
AC_DEFINE([TIMING], 1, [If true, use GPTL timing library.])
AC_DEFINE([HAVE_MPI], [1], [required by GPTL timing library])
fi
AM_CONDITIONAL(USE_GPTL, [test "x$enable_timing" = xyes])

Expand Down Expand Up @@ -224,18 +225,7 @@ if test "x$enable_docs" = xyes; then
AC_CONFIG_FILES([doc/Doxyfile])
fi

AC_MSG_NOTICE([setting flags])
# NetCDF (at least classic) is required for PIO to build.
AC_DEFINE([_NETCDF], [1], [netCDF classic library available])

# We must have MPI to build PIO.
AC_DEFINE([HAVE_MPI], [1], [defined by CMake build])

# All builds are on LINUX.
AC_DEFINE([LINUX], [1], [defined by CMake build])

# Define to solve intel compiler warning.
AC_DEFINE([_GNU_SOURCE], [1], [solve strnlen declared implicitly warning on intel compiler])
AC_MSG_NOTICE([finding libraries])

# Check for netCDF library.
AC_CHECK_LIB([netcdf], [nc_create], [], [AC_MSG_ERROR([Can't find or link to the netcdf library.])])
Expand Down
4 changes: 0 additions & 4 deletions examples/basic/gdecomp_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -300,9 +300,7 @@ end subroutine gdecomp_print
!==================================================================
subroutine gdecomp_DOF(gdecomp,my_task,DOF,start,count,write_decomp,test)

#ifdef _NETCDF
use netcdf ! _EXTERNAL
#endif

implicit none

Expand Down Expand Up @@ -712,7 +710,6 @@ subroutine gdecomp_DOF(gdecomp,my_task,DOF,start,count,write_decomp,test)

! --- write out arrays ---

#ifdef _NETCDF
if (wdecomp) then
write(6,*) ' '
write(6,*) trim(subname),' writing decomp info to file ',trim(ncname)
Expand All @@ -738,7 +735,6 @@ subroutine gdecomp_DOF(gdecomp,my_task,DOF,start,count,write_decomp,test)
rcode = nf90_put_var(ncid,varid(2),tskid)
rcode = nf90_close(ncid)
endif
#endif

endif ! testonly

Expand Down
4 changes: 0 additions & 4 deletions examples/basic/testpio.F90
Original file line number Diff line number Diff line change
Expand Up @@ -770,11 +770,7 @@ program testpio
! print *, __FILE__,__LINE__,'>',fname_r8,'<'
! print *, __FILE__,__LINE__,'>',fname_i4,'<'
! print *, __FILE__,__LINE__,'>',fname_r4,'<'
#if defined(_NETCDF) || defined(_PNETCDF)
mode = pio_64bit_offset
#else
mode = 0
#endif

if(writePhase) then
if(TestCombo) then
Expand Down
2 changes: 1 addition & 1 deletion src/flib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# The library we are building.
lib_LTLIBRARIES = libpiof.la

AM_CPPFLAGS = -D_NETCDF -D_NETCDF4 -D_PNETCDF
AM_CPPFLAGS = -D_NETCDF4 -D_PNETCDF

# These linker flags specify libtool version info.
# See http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
Expand Down
2 changes: 0 additions & 2 deletions src/flib/pio.F90
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ module pio
pio_iotype_pnetcdf,pio_iotype_netcdf, &
pio_global, pio_char, pio_write, pio_nowrite, pio_clobber, pio_noclobber, &
pio_max_name, pio_max_var_dims, pio_rearr_subset, pio_rearr_box, &
#if defined(_NETCDF) || defined(_PNETCDF)
pio_nofill, pio_unlimited, pio_fill_int, pio_fill_double, pio_fill_float, &
#endif
pio_64bit_offset, pio_64bit_data, &
pio_internal_error, pio_bcast_error, pio_return_error, pio_default

Expand Down
3 changes: 1 addition & 2 deletions tests/cunit/test_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,9 @@ get_iotypes(int *num_flavors, int *flavors)
num++;
format[fmtidx++] = PIO_IOTYPE_PNETCDF;
#endif
#ifdef _NETCDF
/* NetCDF is always present. */
num++;
format[fmtidx++] = PIO_IOTYPE_NETCDF;
#endif
#ifdef _NETCDF4
num += 2;
format[fmtidx++] = PIO_IOTYPE_NETCDF4C;
Expand Down
6 changes: 3 additions & 3 deletions tests/cunit/test_iosystem3.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int create_file(MPI_Comm comm, int iosysid, int format, char *filename,
return ret;

/* Write an attribute. */
if ((ret = PIOc_put_att_text(ncid, varid, attname, strnlen(filename, PIO_TF_MAX_STR_LEN),
if ((ret = PIOc_put_att_text(ncid, varid, attname, strlen(filename),
filename)))
return ret;

Expand Down Expand Up @@ -94,11 +94,11 @@ int check_file(MPI_Comm comm, int iosysid, int format, int ncid, char *filename,

/* Check the attribute. Null terminating byte deliberately ignored
* to match fortran code. */
if (!(att_data = malloc(strnlen(filename, PIO_TF_MAX_STR_LEN) * sizeof(char))))
if (!(att_data = malloc(strlen(filename) * sizeof(char))))
return PIO_ENOMEM;
if ((ret = PIOc_get_att(ncid, varid, attname, att_data)))
return ret;
if (strncmp(att_data, filename, strnlen(filename, PIO_TF_MAX_STR_LEN)))
if (strncmp(att_data, filename, strlen(filename)))
return ERR_WRONG;
free(att_data);

Expand Down
68 changes: 4 additions & 64 deletions tests/general/util/pio_tutil.F90
Original file line number Diff line number Diff line change
Expand Up @@ -295,11 +295,9 @@ SUBROUTINE PIO_TF_Get_nc_iotypes(iotypes, iotype_descs, num_iotypes)
! netcdf, netcdf4p, netcdf4c
num_iotypes = num_iotypes + 3
#else
#ifdef _NETCDF
! netcdf
! netcdf is always present.
num_iotypes = num_iotypes + 1
#endif
#endif
#ifdef _PNETCDF
! pnetcdf
num_iotypes = num_iotypes + 1
Expand Down Expand Up @@ -328,12 +326,10 @@ SUBROUTINE PIO_TF_Get_nc_iotypes(iotypes, iotype_descs, num_iotypes)
iotype_descs(i) = "NETCDF4P"
i = i + 1
#else
#ifdef _NETCDF
! netcdf
! netcdf is always present.
iotypes(i) = PIO_iotype_netcdf
iotype_descs(i) = "NETCDF"
i = i + 1
#endif
#endif
END SUBROUTINE

Expand All @@ -355,14 +351,6 @@ SUBROUTINE PIO_TF_Get_undef_nc_iotypes(iotypes, iotype_descs, num_iotypes)

num_iotypes = 0
! First find the number of io types
#ifndef _NETCDF
! netcdf
num_iotypes = num_iotypes + 1
#ifndef _NETCDF4
! netcdf4p, netcdf4c
num_iotypes = num_iotypes + 2
#endif
#endif
#ifndef _PNETCDF
! pnetcdf
num_iotypes = num_iotypes + 1
Expand All @@ -378,21 +366,6 @@ SUBROUTINE PIO_TF_Get_undef_nc_iotypes(iotypes, iotype_descs, num_iotypes)
iotypes(i) = PIO_iotype_pnetcdf
iotype_descs(i) = "PNETCDF"
i = i + 1
#endif
#ifndef _NETCDF
! netcdf
iotypes(i) = PIO_iotype_netcdf
iotype_descs(i) = "NETCDF"
i = i + 1
#ifndef _NETCDF4
! netcdf4p, netcdf4c
iotypes(i) = PIO_iotype_netcdf4c
iotype_descs(i) = "NETCDF4C"
i = i + 1
iotypes(i) = PIO_iotype_netcdf4p
iotype_descs(i) = "NETCDF4P"
i = i + 1
#endif
#endif
END SUBROUTINE

Expand All @@ -416,11 +389,9 @@ SUBROUTINE PIO_TF_Get_iotypes(iotypes, iotype_descs, num_iotypes)
! netcdf, netcdf4p, netcdf4c
num_iotypes = num_iotypes + 3
#else
#ifdef _NETCDF
! netcdf
! netcdf is always present.
num_iotypes = num_iotypes + 1
#endif
#endif
#ifdef _PNETCDF
! pnetcdf
num_iotypes = num_iotypes + 1
Expand Down Expand Up @@ -449,12 +420,10 @@ SUBROUTINE PIO_TF_Get_iotypes(iotypes, iotype_descs, num_iotypes)
iotype_descs(i) = "NETCDF4P"
i = i + 1
#else
#ifdef _NETCDF
! netcdf
! netcdf is always present.
iotypes(i) = PIO_iotype_netcdf
iotype_descs(i) = "NETCDF"
i = i + 1
#endif
#endif
END SUBROUTINE

Expand All @@ -476,14 +445,6 @@ SUBROUTINE PIO_TF_Get_undef_iotypes(iotypes, iotype_descs, num_iotypes)

! First find the number of io types
num_iotypes = 0
#ifndef _NETCDF
! netcdf
num_iotypes = num_iotypes + 1
#ifndef _NETCDF4
! netcdf4p, netcdf4c
num_iotypes = num_iotypes + 2
#endif
#endif
#ifndef _PNETCDF
! pnetcdf
num_iotypes = num_iotypes + 1
Expand All @@ -494,27 +455,6 @@ SUBROUTINE PIO_TF_Get_undef_iotypes(iotypes, iotype_descs, num_iotypes)
ALLOCATE(iotype_descs(num_iotypes))

i = 1
#ifndef _NETCDF
! netcdf
iotypes(i) = PIO_iotype_netcdf
iotype_descs(i) = "NETCDF"
i = i + 1
#ifndef _PNETCDF
! pnetcdf
iotypes(i) = PIO_iotype_pnetcdf
iotype_descs(i) = "PNETCDF"
i = i + 1
#endif
#ifndef _NETCDF4
! netcdf4p, netcdf4c
iotypes(i) = PIO_iotype_netcdf4c
iotype_descs(i) = "NETCDF4C"
i = i + 1
iotypes(i) = PIO_iotype_netcdf4p
iotype_descs(i) = "NETCDF4P"
i = i + 1
#endif
#endif
END SUBROUTINE

! Returns a list of PIO base types
Expand Down
7 changes: 0 additions & 7 deletions tests/unit/driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ Program pio_unit_test_driver
! Ignore namelist values if PIO not built with correct options
! (i.e. don't test pnetcdf if not built with pnetcdf)

#ifndef _NETCDF
if (ltest_netcdf) then
write(*,"(A,1x,A)") "WARNING: can not test netcdf files because PIO", &
"was not compiled with -D_NETCDF"
ltest_netcdf = .false.
end if
#endif
#ifndef _NETCDF4
if (ltest_netcdf4p) then
write(*,"(A,1x,A)") "WARNING: can not test netcdf4p files because PIO", &
Expand Down

0 comments on commit 9b942c5

Please sign in to comment.