From 4d57317297f08b55fe922002ee4e097706997f1b Mon Sep 17 00:00:00 2001 From: Randy LeVeque Date: Tue, 31 Dec 2019 09:41:38 -0800 Subject: [PATCH 1/2] Remove all .mod files with make new Determine all directories containing source files and remove any .mod files from these directories to avoid using old versions. --- src/Makefile.common | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Makefile.common b/src/Makefile.common index 5c7c160..fed026a 100644 --- a/src/Makefile.common +++ b/src/Makefile.common @@ -70,6 +70,18 @@ MODULE_FILES = $(subst .F,.mod, $(subst .F90,.mod, $(subst .f,.mod, $(subst .f90 MODULE_PATHS = $(sort $(dir $(MODULE_FILES))) MODULE_OBJECTS = $(subst .F,.o, $(subst .F90,.o, $(subst .f,.o, $(subst .f90,.o, $(MODULES))))) +# list of all paths containing sources: +SOURCE_PATHS = $(sort $(dir $(SOURCES))) +# list of all .mod files on these paths (to remove with 'make new'): +RM_MODULE_FILES = $(addsuffix *.mod,$(MODULE_PATHS)) +RM_MODULE_FILES += $(addsuffix *.mod,$(SOURCE_PATHS)) +ALL_MODULE_FILES = $(sort $(RM_MODULE_FILES)) +# note that this should contain everything in MODULE_FILES but maybe +# additional ones if the user has a local version of some module in a +# different directory. Previously the library version of .mod was not removed +# in that case, and was wrongly used by library routines that "use" the module. + + #---------------------------------------------------------------------------- # Compiling, linking, and include flags # User set flags, empty if not set @@ -116,7 +128,7 @@ endif #---------------------------------------------------------------------------- # Targets that do not correspond to file names: -.PHONY: .objs .exe clean clobber new all output plots; +.PHONY: .objs .exe clean clobber new all output plots debug_new; # Reset suffixes that we understand .SUFFIXES: @@ -255,10 +267,16 @@ plots: $(SETPLOT_FILE) $(MAKEFILE_LIST); new: $(MAKEFILE_LIST) -rm -f $(OBJECTS) -rm -f $(MODULE_OBJECTS) - -rm -f $(MODULE_FILES) + -rm -f $(ALL_MODULE_FILES) -rm -f $(EXE) $(MAKE) $(EXE) MAKELEVEL=0 -f $(MAKEFILE_LIST) +debug_new: + @echo MODULE_PATHS: $(MODULE_PATHS) + @echo SOURCE_PATHS: $(SOURCE_PATHS) + @echo ALL_MODULE_FILES: $(ALL_MODULE_FILES) + + # Clean up options: clean: From 0229aad56ae07e57de3cd78b51a18f0be42c4c76 Mon Sep 17 00:00:00 2001 From: Randy LeVeque Date: Tue, 31 Dec 2019 12:32:01 -0800 Subject: [PATCH 2/2] remove all *_module.mod and *_module.o files --- src/Makefile.common | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Makefile.common b/src/Makefile.common index fed026a..0667506 100644 --- a/src/Makefile.common +++ b/src/Makefile.common @@ -73,9 +73,16 @@ MODULE_OBJECTS = $(subst .F,.o, $(subst .F90,.o, $(subst .f,.o, $(subst .f90,.o, # list of all paths containing sources: SOURCE_PATHS = $(sort $(dir $(SOURCES))) # list of all .mod files on these paths (to remove with 'make new'): -RM_MODULE_FILES = $(addsuffix *.mod,$(MODULE_PATHS)) -RM_MODULE_FILES += $(addsuffix *.mod,$(SOURCE_PATHS)) +RM_MODULE_FILES = $(addsuffix *_module.mod,$(MODULE_PATHS)) +RM_MODULE_FILES += $(addsuffix *_module.mod,$(SOURCE_PATHS)) ALL_MODULE_FILES = $(sort $(RM_MODULE_FILES)) +RM_MODULE_OBJECTS = $(addsuffix *_module.o,$(MODULE_PATHS)) +RM_MODULE_OBJECTS += $(addsuffix *_module.o,$(SOURCE_PATHS)) +ALL_MODULE_OBJECTS = $(sort $(RM_MODULE_OBJECTS)) + +# This doesn't seem to work: +#ALL_MODULE_OBJECTS = $(subst .mod, .o, $(ALL_MODULE_FILES)) + # note that this should contain everything in MODULE_FILES but maybe # additional ones if the user has a local version of some module in a # different directory. Previously the library version of .mod was not removed @@ -275,6 +282,7 @@ debug_new: @echo MODULE_PATHS: $(MODULE_PATHS) @echo SOURCE_PATHS: $(SOURCE_PATHS) @echo ALL_MODULE_FILES: $(ALL_MODULE_FILES) + @echo ALL_MODULE_OBJECTS: $(ALL_MODULE_OBJECTS)