giraffe.mk.in 6.78 KB
Newer Older
Kevin Dugan's avatar
Kevin Dugan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
# == Source and destination directories ============================================================
VPATH    := @abs_srcdir@/Nek5000/core:@abs_srcdir@/Nek5000/core/cmt:@abs_srcdir@/Nek5000/core/3rd_party:@abs_srcdir@/Nek5000/jl:@abs_srcdir@/src_nek
srcdir   := @abs_srcdir@
GIRAFFE_EXAMPLE ?= @abs_srcdir@/examples/integration_example
builddir := $(GIRAFFE_EXAMPLE)
nek_objdir   := $(GIRAFFE_EXAMPLE)/nek_obj
nek_includedir := $(GIRAFFE_EXAMPLE)/include

# == Discovered by autoconf script
CASENAME     ?= $(shell basename $(GIRAFFE_EXAMPLE))
nek_CFLAGS   := $(libmesh_CFLAGS)
nek_INCLUDES := -I$(builddir) -I$(nek_includedir) -I$(srcdir)/Nek5000/core -I$(srcdir)/Nek5000/core/cmt -I$(srcdir)/Nek5000/core/3rd_party -I$(srcdir)/Nek5000/jl -I$(srcdir)/src_nek
nek_CPPFLAGS := $(libmesh_CPPFLAGS) @DEFS@ @nek_DEFS@ $(nek_INCLUDES)
nek_LDFLAGS  := @LDFLAGS@
nek_LIBS     := $(libmesh_LIBS)

nek_FFLAGS   := @FFLAGS@ @FCFLAGS_f@ $(subst -D, @FC_DEFINE@, @DEFS@ @nek_DEFS@) $(nek_INCLUDES)
nek_FLIBS    := $(libmesh_LIBS)

nek_debug_flags := @nek_debug_flags@
nek_opt_flags   := @nek_opt_flags@
nek_real8_flags := @nek_real8_flags@
jl_prefix       := @jl_prefix@

# == FORTRAN objects ===============================================================================
nek_drive_obj  := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), drive))

nek_core_f_obj := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), \
                  drive1 drive2 plan4 bdry coef conduct connect1 connect2 \
                  dssum edgec eigsolv gauss genxyz navier1 makeq navier0 \
                  navier2 navier3 navier4 prepost speclib map2 turb mvmesh ic \
                  ssolv planx mxm_wrapper hmholtz gfdm_par  gfdm_op gfdm_solve \
                  subs1 subs2 genbox gmres hsmg convect induct perturb navier5 \
                  navier6 navier7 navier8 fast3d fasts calcz postpro \
                  cvode_driver vprops qthermal cvode_aux makeq_aux papi nek_in_situ \
                  readat_new nek_moose))

nek_case_f_obj := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), $(CASENAME)))

nek_math_obj   := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), math))
nek_blas_obj   := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), @nek_blas_obj@))   # blas.o | null
nek_cmt_obj    := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), @nek_cmt_obj@))    # drive1_cmt.o ... | cmt_dummy.o
nek_lapack_obj := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), @nek_lapack_obj@)) # dsygv.o ssygv.o | null
nek_mpi_obj    := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), @nek_mpi_obj@))    # byte_mpi.o comm_mpi.o | byte_mpi.o comm_mpi.o mpi_dummy.o
nek_mxm_obj    := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), @nek_mxm_obj@))    # mxm_std.o | mxm_std.o mxm_bgq.o
nek_neknek_obj := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), @nek_neknek_obj@)) # singlmesh.o | multimesh.o

nek_flib_obj   := $(nek_core_f_obj) $(nek_math_obj) $(nek_blas_obj) $(nek_cmt_obj) \
                  $(nek_lapack_obj) $(nek_mpi_obj) $(nek_mxm_obj) $(nek_neknek_obj) \
                  $(nek_case_f_obj)

# == C objects =====================================================================================
nek_core_c_obj := $(addprefix $(nek_objdir)/, $(addsuffix .$(obj-suffix), \
                  byte chelpers nek_comm finiparser iniparser dictionary))

jl_core_obj    := $(addprefix $(nek_objdir)/, $(patsubst %, $(jl_prefix)%.$(obj-suffix), \
                  gs sort sarray_transfer sarray_sort gs_local crystal comm tensor fail fcrystal))
jl_interp_obj  := $(addprefix $(nek_objdir)/, $(patsubst %, $(jl_prefix)%.$(obj-suffix), \
                  findpts findpts_local obbox poly lob_bnd findpts_el_3 findpts_el_2))
jl_cgs_obj     := $(addprefix $(nek_objdir)/, $(patsubst %, $(jl_prefix)%.$(obj-suffix), @jl_cgs_obj@))

nek_clib_obj   := $(nek_core_c_obj) $(jl_core_obj) $(jl_interp_obj) $(jl_cgs_obj)

# == MOOSE app flags and objects ==================================================================
# Recursive definition (= rather than :=) is probably the right usage, since they're probably
# defined here after they're referenced by MOOSE makefile

ADDITIONAL_CPPFLAGS = $(libmesh_CPPFLAGS) @DEFS@                  # Used by pattern rules in moose/framework/build.mk
ADDITIONAL_INCLUDES = $(nek_INCLUDES)                    # Used by pattern rules in moose/framework/build.mk (through app_INCLUDES)
ADDITIONAL_LIBS     = $(nek_LIBS) $(nek_FLIBS)           # Used during linking in moose/framework/app.mk
ADDITIONAL_APP_OBJECTS = $(nek_flib_obj) $(nek_clib_obj) # Added to dependencies in moose/framework/app.mk

# == Rules =========================================================================================

nek5000: $(nek_drive_obj) $(nek_flib_obj) $(nek_clib_obj)
	@echo "Linking Executable "$@"..."
	@$(libmesh_LIBTOOL) --tag=F77 $(LIBTOOLFLAGS) --mode=link --quiet \
	  $(libmesh_F77) $(libmesh_FFLAGS) -o $@ $^ $(libmesh_LIBS) $(libmesh_LDFLAGS) $(nek_LIBS) $(nek_LDFLAGS) $(nek_FLIBS)

$(nek_case_f_obj): $(nek_objdir)/%.$(obj-suffix): $(GIRAFFE_EXAMPLE)/%.f $(GIRAFFE_EXAMPLE)/SIZE | $(nek_objdir)
	@echo "Nek5000 Compiling Fortran (in "$(METHOD)" mode) "$<"..."
	@$(libmesh_LIBTOOL) --tag=F77 $(LIBTOOLFLAGS) --mode=compile --quiet \
	  $(libmesh_F77) $(nek_FFLAGS) $(nek_real8_flags) -c $< -o $@

$(nek_drive_obj) $(nek_core_f_obj) $(nek_cmt_obj) $(nek_math_obj) $(nek_mxm_obj): $(nek_objdir)/%.$(obj-suffix): %.f $(GIRAFFE_EXAMPLE)/SIZE | $(nek_objdir)
	@echo "Nek5000 Compiling Fortran (in "$(METHOD)" mode) "$<"..."
	@$(libmesh_LIBTOOL) --tag=F77 $(LIBTOOLFLAGS) --mode=compile --quiet \
	  $(libmesh_F77) $(nek_FFLAGS) $(nek_real8_flags) -c $< -o $@

$(nek_mpi_obj) $(nek_neknek_obj): $(nek_objdir)/%.$(obj-suffix): %.f $(GIRAFFE_EXAMPLE)/SIZE mpiheader | $(nek_objdir)
	@echo "Nek5000 Compiling Fortran (in "$(METHOD)" mode) "$<"..."
	@$(libmesh_LIBTOOL) --tag=F77 $(LIBTOOLFLAGS) --mode=compile --quiet \
	  $(libmesh_F77) $(nek_FFLAGS) $(nek_real8_flags) -c $< -o $@

$(nek_core_c_obj): $(nek_objdir)/%.$(obj-suffix): %.c | $(nek_objdir)
	@echo "Nek5000 Compiling C (in "$(METHOD)" mode) "$<"..."
	@$(libmesh_LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=compile --quiet \
	  $(libmesh_CC) $(nek_CPPFLAGS) $(nek_CFLAGS) -MMD -MP -MF $@.d -MT $@ -c $< -o $@

$(jl_core_obj) $(jl_interp_obj) $(jl_cgs_obj): $(nek_objdir)/$(jl_prefix)%.$(obj-suffix): %.c | $(nek_objdir)
	@echo "Nek5000 Compiling C (in "$(METHOD)" mode) "$<"..."
	@$(libmesh_LIBTOOL) --tag=CC $(LIBTOOLFLAGS) --mode=compile --quiet \
	  $(libmesh_CC) $(nek_CPPFLAGS) $(nek_CFLAGS) -MMD -MP -MF $@.d -MT $@ -c $< -o $@

mpiheader: | $(nek_includedir)
ifneq ($(findstring mpi_dummy.o, $(nek_mpi_obj)),)
	cp $(srcdir)/Nek5000/core/mpi_dummy.h $(nek_includedir)/mpif.h
else
	rm -rf $(srcdir)/Nek5000/core/mpif.h $(nek_includedir)/mpif.h
endif

$(nek_objdir) $(nek_includedir):
	mkdir -p $@

PHONY: mpiheader