Skip to content

Commit

Permalink
Merge pull request ESMCI#1378 from NCAR/ejh_fortran_build
Browse files Browse the repository at this point in the history
autotools fortran build
  • Loading branch information
edhartnett authored Mar 27, 2019
2 parents b0b28e8 + 00212e5 commit 5c1fa0e
Show file tree
Hide file tree
Showing 18 changed files with 10,466 additions and 16 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ env:
script:
- autoreconf -i
- export CFLAGS='-std=c99 -fsanitize=address -fno-omit-frame-pointer'
- export FFLAGS='-std=c99 -fsanitize=address -fno-omit-frame-pointer'
- ./configure
- export FFLAGS='-fsanitize=address -fno-omit-frame-pointer'
- export FCFLAGS='-fsanitize=address -fno-omit-frame-pointer'
- export DISTCHECK_CONFIGURE_FLAGS='--enable-fortran'
- ./configure --enable-fortran
- make -j distcheck
- rm -rf build
- mkdir build
Expand Down
2 changes: 2 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ SUBDIRS = src tests examples

# Look in the m4 directory for autotools stuff.
ACLOCAL_AMFLAGS= -I m4

EXTRA_DIST = CMakeLists.txt set_flags.am
34 changes: 28 additions & 6 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ AC_CONFIG_MACRO_DIR([m4])
# Find and learn about the C compiler.
AC_PROG_CC

# Find and learn about the Fortran compiler.
AC_PROG_FC

# Libtool initialisation.
AC_PROG_LIBTOOL

Expand All @@ -38,23 +41,28 @@ if test "x$enable_logging" = xyes; then
AC_DEFINE([PIO_ENABLE_LOGGING], 1, [If true, turn on logging.])
fi


# Does the user want to enable Fortran library?
AC_MSG_CHECKING([whether Fortran library should be build])
AC_ARG_ENABLE([fortran],
[AS_HELP_STRING([--enable-fortran],
[build the PIO Fortran library.])])
test "x$enable_fortran" = xyes || enable_fortran=no
AC_MSG_RESULT([$enable_fortran])
AM_CONDITIONAL(BUILD_FORTRAN, [test "x$enable_fortran" = xyes])

# Does the user want to disable pnetcdf?
AC_MSG_CHECKING([whether pnetcdf is to be used])
AC_ARG_ENABLE([pnetcdf],
[AS_HELP_STRING([--disable-pnetcdf],
[Disable pnetcdf use.])])
test "x$enable_pnetcdf" = xno || enable_pnetcdf=yes
AC_MSG_RESULT([$enable_pnetcdf])
if test "x$enable_logging" = xyes; then
AC_DEFINE([PIO_ENABLE_LOGGING], 1, [If true, turn on logging.])
fi
AM_CONDITIONAL(BUILD_PNETCDF, [test "x$enable_pnetcdf" = xyes])

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

# Is parallel-netcdf library available?
#AC_DEFINE([_PNETCDF], [1], [parallel-netcdf library available])

# The PIO version, again.
AC_DEFINE([PIO_VERSION_MAJOR], [2], [PIO major version])
AC_DEFINE([PIO_VERSION_MINOR], [4], [PIO minor version])
Expand Down Expand Up @@ -100,6 +108,7 @@ AC_MSG_RESULT([${have_netcdf_par}])
if test x$have_netcdf_par = xyes; then
AC_DEFINE([_NETCDF4],[1],[Does netCDF library provide netCDF-4 with parallel access])
fi
AM_CONDITIONAL(BUILD_NETCDF4, [test "x$have_netcdf_par" = xyes])

# Not working for some reason, so I will just set it...
AC_CHECK_TYPE([MPI_Offset], [], [], [#include <mpi.h>])
Expand All @@ -112,14 +121,27 @@ fi
#AC_CHECK_SIZEOF([MPI_Offset], [], [[#include <mpi.h>]])
#AC_DEFINE([SIZEOF_MPI_OFFSET], [8], [netCDF classic library available])

AC_CONFIG_FILES(src/flib/piodarray.F90:src/flib/piodarray.F90.in2)
AC_CONFIG_FILES(src/flib/pionfatt_mod.F90:src/flib/pionfatt_mod.F90.in2)
AC_CONFIG_FILES(src/flib/pionfget_mod.F90:src/flib/pionfget_mod.F90.in2)
AC_CONFIG_FILES(src/flib/pionfput_mod.F90:src/flib/pionfput_mod.F90.in2)

AC_CONFIG_FILES([tests/general/pio_tutil.F90:tests/general/util/pio_tutil.F90])

AC_CONFIG_LINKS([tests/unit/input.nl:tests/unit/input.nl])

# Create the config.h file.
AC_CONFIG_HEADERS([config.h])

# Create the makefiles.
AC_OUTPUT(Makefile
src/Makefile
src/clib/Makefile
src/flib/Makefile
tests/Makefile
tests/cunit/Makefile
tests/unit/Makefile
tests/general/Makefile
tests/general/util/Makefile
examples/Makefile
examples/c/Makefile)
18 changes: 18 additions & 0 deletions set_flags.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This is part of the PIO package.
#
# Assemble the CPPFLAGS and for PIO Fortran tests.
#
# Ed Hartnett 3/26/19

# Set the CPPFLAGS.
AM_CPPFLAGS = -I$(top_srcdir)/src/flib -D_NETCDF

# Is the user building with pnetcdf?
if BUILD_PNETCDF
AM_CPPFLAGS += -D_PETCDF
endif

# Is the user building with netCDF-4 parallel I/O?
if BUILD_NETCDF4
AM_CPPFLAGS += -D_NETCDF4
endif
9 changes: 8 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,11 @@

# Ed Hartnett

SUBDIRS = clib
# Does the user want to build fortran?
if BUILD_FORTRAN
FLIB = flib
endif

SUBDIRS = clib $(FLIB)

EXTRA_DIST = CMakeLists.txt
2 changes: 2 additions & 0 deletions src/clib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ libpio_la_SOURCES = bget.c pioc_sc.c pio_darray.c pio_file.c \
pio_getput_int.c pio_msg.c pio_nc.c pio_rearrange.c pioc.c \
pioc_support.c pio_darray_int.c pio_get_nc.c pio_lists.c pio_nc4.c \
pio_put_nc.c pio_spmd.c pio_internal.h bget.h uthash.h

EXTRA_DIST = CMakeLists.txt
62 changes: 62 additions & 0 deletions src/flib/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
## This is the automake file to build the PIO Fortran library.
# Ed Hartnett 3/19/19

# Turn off parallel builds in this directory.
.NOTPARALLEL:

# The library we are building.
lib_LTLIBRARIES = libpiof.la

AM_CPPFLAGS = -D_NETCDF -D_NETCDF4 -D_PETCDF

# These linker flags specify libtool version info.
# See http://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
# for information regarding incrementing `-version-info`.
libpiof_la_LDFLAGS = -version-info 1:0:0

# The library soure files.
libpiof_la_LIBADD = libpio_nf.la libpio_kinds.la \
libpio_support.la libpiodarray.la libpionfatt.la libpionfget.la \
libpionfput.la libpiolib_mod.la libpio.la

libpiof_la_SOURCES = pio_types.F90

# Build these uninstalled convenience libraries.
noinst_LTLIBRARIES = libpio_kinds.la libpio_types.la \
libpio_support.la libpio_nf.la libpiodarray.la libpionfatt.la \
libpionfget.la libpionfput.la libpiolib_mod.la libpio.la

# The convenience libraries depends on their source.
libpio_kinds_la_SOURCES = pio_kinds.F90
libpio_types_la_SOURCES = pio_types.F90
libpio_support_la_SOURCES = pio_support.F90
libpio_nf_la_SOURCES = pio_nf.F90
libpiodarray_la_SOURCES = piodarray.F90
libpionfatt_la_SOURCES = pionfatt_mod.F90
libpionfget_la_SOURCES = pionfget_mod.F90
libpionfput_la_SOURCES = pionfput_mod.F90
libpiolib_mod_la_SOURCES = piolib_mod.F90
libpio_la_SOURCES = pio.F90

# Each mod file depends on the .o file.
pio_kinds.mod: pio_kinds.$(OBJEXT)
pio_types.mod: pio_types.$(OBJEXT)
pio_support.mod: pio_support.$(OBJEXT)
pio_nf.mod: pio_nf.$(OBJEXT)
piodarray.mod: piodarray.$(OBJEXT)
pionfatt_mod.mod: pionfatt_mod.$(OBJEXT)
pionfget_mod.mod: pionfget_mod.$(OBJEXT)
pionfput_mod.mod: pionfput_mod.$(OBJEXT)
piolib_mod.mod: piolib_mod.$(OBJEXT)
pio.mod: pio.$(OBJEXT)

# Mod files are built and then installed as headers.
MODFILES = pio_kinds.mod pio_types.mod pio_support.mod pio_nf.mod \
piodarray.mod pionfatt_mod.mod pionfget_mod.mod pionfput_mod.mod \
piolib_mod.mod pio.mod
BUILT_SOURCES = $(MODFILES)
include_HEADERS = $(MODFILES)

CLEANFILES = *.mod

EXTRA_DIST = CMakeLists.txt
Loading

0 comments on commit 5c1fa0e

Please sign in to comment.