Skip to content

Commit

Permalink
Merge pull request #178 from NetCDF-World-Domination-Council/ejh_mod_…
Browse files Browse the repository at this point in the history
…files

fix dependency tracking in fortran directory, enabling parallel (make -j) builds
  • Loading branch information
WardF authored Apr 29, 2019
2 parents 0a4d529 + de9c724 commit 9b4265e
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 74 deletions.
172 changes: 101 additions & 71 deletions fortran/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

# Ed Hartnett, Russ Rew, Dennis Heimbigner, Ward Fisher

# Turn off parallel builds in this directory.
.NOTPARALLEL:
AM_FCFLAGS = -I.

# This is what we are building: the netCDF fortran library, containing
# the F77 and the F90 APIs.
Expand All @@ -17,15 +16,6 @@ lib_LTLIBRARIES = libnetcdff.la
# for information regarding incrementing `-version-info`.
libnetcdff_la_LDFLAGS = -version-info 6:1:1

# This, plus either netcdf4.f90 or netcdf.f90, is the main source.
libnetcdff_la_SOURCES = typeSizes.f90

if USE_NETCDF4
NETCDF_O = netcdf4.$(OBJEXT)
else
NETCDF_O = netcdf.$(OBJEXT)
endif

# These f90 codes are used for either netCDF classic or netCDF-4 F90
# API.
COMMON_CODES = netcdf_constants.f90 netcdf_externals.f90 \
Expand All @@ -38,82 +28,122 @@ NETCDF4_CODES = netcdf4_externals.f90 netcdf4_visibility.f90 \
netcdf4_func.f90 netcdf4_overloads.f90 netcdf4_file.f90 \
netcdf4_eightbyte.f90 netcdf4_variables.f90

# Add dependencies for source files included in "meta" source files,
# so the meta source is rebuilt properly when an included file is
# modified.
netcdf.$(OBJEXT): $(COMMON_CODES) netcdf3_file.f90
netcdf4.$(OBJEXT): $(COMMON_CODES) $(NETCDF4_CODES)

# Modules and source for the F77 API.
libnetcdff_la_SOURCES += module_netcdf_nc_data.F90 \
module_netcdf_nc_interfaces.f90 module_netcdf_nf_data.F90 \
module_netcdf_nf_interfaces.F90 module_netcdf_f03.f90 nf_attio.F90 \
nf_control.F90 nf_dim.f90 nf_misc.f90 nf_genatt.f90 nf_geninq.f90 \
nf_genvar.f90 nf_vario.F90 nf_var1io.F90 nf_varaio.F90 nf_varmio.F90 \
nf_varsio.F90

# Add netCDF-4 to F77 API if needed.
if USE_NETCDF4
libnetcdff_la_SOURCES += module_netcdf4_nc_interfaces.f90 \
module_netcdf4_nf_interfaces.F90 module_netcdf4_f03.f90 nf_lib.c \
nf_nc4.f90
endif USE_NETCDF4
# Build these uninstalled convenience libraries.
noinst_LTLIBRARIES = libtypeSizes.la libnetcdf_nc_data.la \
libnetcdf_nf_data.la libnetcdf_nc_interfaces.la \
libnetcdf_nf_interfaces.la libnetcdfm.la libnetcdf_f03.la

# Add nf_logging to F77 API if needed.
if USE_LOGGING
libnetcdff_la_SOURCES += nf_logging.F90
endif USE_LOGGING

# The file netcdf.f90 includes all these code files.
libnetcdff_la_DEPENDENCIES = $(COMMON_CODES)
# These are the ource for the F77 API.
libnetcdff_la_SOURCES = nf_attio.F90 nf_control.F90 nf_dim.f90 \
nf_misc.f90 nf_genatt.f90 nf_geninq.f90 nf_genvar.f90 nf_vario.F90 \
nf_var1io.F90 nf_varaio.F90 nf_varmio.F90 nf_varsio.F90

# Different source for the netcdf.mod is used for netcdf classic
# vs. netcdf4.
if USE_NETCDF4
libnetcdff_la_SOURCES += netcdf4.f90
libnetcdff_la_DEPENDENCIES += $(NETCDF4_CODES)
else !USE_NETCDF4
libnetcdff_la_SOURCES += netcdf.f90 netcdf3_file.f90
endif !USE_NETCDF4

# Add the V2 F77 API.
if BUILD_V2
libnetcdff_la_SOURCES += nf_v2compat.c \
module_netcdf_fortv2_c_interfaces.f90 nf_fortv2.f90
endif

# These mod files for the F77 API are always built.
MODFILES = typesizes.mod netcdf.mod netcdf_nc_data.mod \
netcdf_nc_interfaces.mod netcdf_nf_data.mod netcdf_nf_interfaces.mod \
netcdf_f03.mod

# Mod files are dependant on their source.
netcdf.mod: $(NETCDF_O)
libnetcdfm_la_SOURCES = netcdf4.f90
netcdf4.$(OBJECT): typesizes.mod
netcdf.mod: netcdf4.$(OBJEXT)
EXTRA_libnetcdfm_la_DEPENDENCIES = $(COMMON_CODES)
else # classic-only build
libnetcdfm_la_SOURCES = netcdf.f90
netcdf.$(OBJECT): typesizes.mod
netcdf.mod: netcdf.$(OBJEXT)
EXTRA_libnetcdfm_la_DEPENDENCIES = $(COMMON_CODES) $(NETCDF4_CODES)
libnetcdff_la_SOURCES += netcdf3_file.f90
endif # USE_NETCDF4

# Each convenience library depends on its source.
libtypeSizes_la_SOURCES = typeSizes.f90
libnetcdf_nc_data_la_SOURCES = module_netcdf_nc_data.F90
libnetcdf_nf_data_la_SOURCES = module_netcdf_nf_data.F90
libnetcdf_nc_interfaces_la_SOURCES = module_netcdf_nc_interfaces.f90
libnetcdf_nf_interfaces_la_SOURCES = module_netcdf_nf_interfaces.F90
libnetcdf_f03_la_SOURCES = module_netcdf_f03.f90

# Each mod file depends on the .o file.
typesizes.mod: typeSizes.$(OBJEXT)
netcdf_nc_data.mod: module_netcdf_nc_data.$(OBJEXT)
netcdf_nc_interfaces.mod: module_netcdf_nc_interfaces.$(OBJEXT)
netcdf_nf_data.mod: module_netcdf_nf_data.$(OBJEXT)
netcdf_nc_interfaces.mod: module_netcdf_nc_interfaces.$(OBJEXT)
netcdf_nf_interfaces.mod: module_netcdf_nf_interfaces.$(OBJEXT)
netcdf_f03.mod: module_netcdf_f03.$(OBJEXT)

# If v2 API is being built, build v2 F77 API mod file.
# Some mods are dependant on other mods in this dir.
module_netcdf_nf_data.$(OBJEXT): netcdf_nc_data.mod
module_netcdf_nc_interfaces.$(OBJEXT): netcdf_nc_data.mod
module_netcdf_nf_interfaces.$(OBJEXT): netcdf_nf_data.mod
module_netcdf_f03.$(OBJEXT): netcdf_nf_data.mod netcdf_nf_interfaces.mod

# Mod files are built and then installed as headers. Order is
# significant in this list of modfiles.
MODFILES = typesizes.mod netcdf_nc_data.mod netcdf_nf_data.mod \
netcdf_nc_interfaces.mod netcdf_nf_interfaces.mod

# Add our convenience libraries to the netCDF fortran library.
libnetcdff_la_LIBADD = libtypeSizes.la libnetcdf_nc_data.la \
libnetcdf_nf_data.la libnetcdf_nc_interfaces.la \
libnetcdf_nf_interfaces.la libnetcdfm.la libnetcdf_f03.la

# Add the V2 F77 API.
if BUILD_V2
noinst_LTLIBRARIES += libnetcdf_fortv2_c_interfaces.la
libnetcdf_fortv2_c_interfaces_la_SOURCES = module_netcdf_fortv2_c_interfaces.f90
netcdf_fortv2_c_interfaces.mod: module_netcdf_fortv2_c_interfaces.$(OBJEXT)
module_netcdf_fortv2_c_interfaces.$(OBJEXT): netcdf_nc_interfaces.mod
MODFILES += netcdf_fortv2_c_interfaces.mod
netcdf_fortv2_c_interfaces.mod: module_netcdf_fortv2_c_interfaces.$(OBJEXT) netcdf_nc_interfaces.mod
endif BUILD_V2
libnetcdff_la_SOURCES += nf_v2compat.c nf_fortv2.f90
libnetcdff_la_LIBADD += libnetcdf_fortv2_c_interfaces.la
endif # BUILD_V2

# If netCDF-4 is being build, build the netCDF-4 F77 API mod files.
# Are we building netCDF-4?
if USE_NETCDF4
MODFILES += netcdf4_nc_interfaces.mod netcdf4_nf_interfaces.mod \
netcdf4_f03.mod
netcdf4_nc_interfaces.mod: module_netcdf4_nc_interfaces.$(OBJEXT) netcdf_nc_interfaces.mod

# Add additional source files to the library to support netCDF4.
libnetcdff_la_SOURCES += nf_lib.c nf_nc4.f90

# Add these uninstalled convenience libraries for netcdf-4.
noinst_LTLIBRARIES += libnetcdf4_nc_interfaces.la \
libnetcdf4_nf_interfaces.la libnetcdf4_f03.la

# Each convenience library depends on its source.
libnetcdf4_nc_interfaces_la_SOURCES = module_netcdf4_nc_interfaces.f90
libnetcdf4_nf_interfaces_la_SOURCES = module_netcdf4_nf_interfaces.F90
libnetcdf4_f03_la_SOURCES = module_netcdf4_f03.f90

# Each mod file depends on the .o file.
netcdf4_nc_interfaces.mod: module_netcdf4_nc_interfaces.$(OBJEXT)
netcdf4_nf_interfaces.mod: module_netcdf4_nf_interfaces.$(OBJEXT)
netcdf4_f03.mod: module_netcdf4_f03.$(OBJEXT)
endif USE_NETCDF4

# The mod files and the netcdf.inc file are built on the user machine,
# and installed as headers.
BUILT_SOURCES = $(MODFILES) netcdf.inc
nodist_include_HEADERS = $(MODFILES) netcdf.inc
libnetcdff_la_DEPENDENCIES += $(MODFILES) netcdf.inc
# Some mods are dependant on other mods in this dir.
module_netcdf4_nc_interfaces.$(OBJEXT): netcdf_nc_interfaces.mod
module_netcdf4_nf_interfaces.$(OBJEXT): netcdf4_nc_interfaces.mod
module_netcdf4_f03.$(OBJEXT): netcdf_nf_data.mod netcdf_nf_interfaces.mod netcdf4_nf_interfaces.mod

# Add the netcdf4 mod files to the list.
MODFILES += netcdf4_nc_interfaces.mod netcdf4_nf_interfaces.mod \
netcdf4_f03.mod

# Add the netcdf4 convenience libraries to the netcdf fortran library.
libnetcdff_la_LIBADD += libnetcdf4_nc_interfaces.la \
libnetcdf4_nf_interfaces.la libnetcdf4_f03.la

endif # USE_NETCDF4

# This must come last in the list of MODFILES.
MODFILES += netcdf.mod

# Mod files are build sources.
BUILT_SOURCES = $(MODFILES)

# Mod files are installed as headers, but not distrubuted.
nodist_include_HEADERS = $(MODFILES)

# The netcdf.inc file is built on the user machine, and installed as
# a header.
BUILT_SOURCES += netcdf.inc
nodist_include_HEADERS += netcdf.inc

# Build netcdf.inc file from netcdf2, netcdf3 and netcdf4 files
netcdf.inc: netcdf2.inc netcdf3.inc netcdf4.inc
Expand Down
2 changes: 1 addition & 1 deletion fortran/netcdf.f90
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
! length of the argument character string.
!
module netcdf
use typeSizes, only: OneByteInt, TwoByteInt, FourByteInt, EightByteInt, &
use typesizes, only: OneByteInt, TwoByteInt, FourByteInt, EightByteInt, &
FourByteReal, EightByteReal
implicit none
private
Expand Down
2 changes: 1 addition & 1 deletion fortran/netcdf4.f90
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
! Hartnett in 2006 to support the netCDF-4 API.
!
module netcdf
use typeSizes, only: OneByteInt, TwoByteInt, FourByteInt, EightByteInt, &
use typesizes, only: OneByteInt, TwoByteInt, FourByteInt, EightByteInt, &
FourByteReal, EightByteReal
implicit none
private
Expand Down
2 changes: 1 addition & 1 deletion fortran/typeSizes.f90
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
! Fortran 90 doesn't allow one to check the number of bytes in a real variable;
! we check only that four byte and eight byte reals have different kind parameters.
!
module typeSizes
module typesizes
implicit none
public
integer, parameter :: OneByteInt = selected_int_kind(2), &
Expand Down

0 comments on commit 9b4265e

Please sign in to comment.