[cig-commits] [commit] master: Update Makefiles to match other SPECFEM code. (d4d879a)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Mon Jan 5 23:01:46 PST 2015
Repository : https://github.com/geodynamics/specfem1d
On branch : master
Link : https://github.com/geodynamics/specfem1d/compare/0474318db2f3c07f3ea053913eed9404264a153e...35bd59c099344f3bf7aa0e5570daa5ec1eca3c07
>---------------------------------------------------------------
commit d4d879a7639670abab36a702e6500666ffbfc1d3
Author: Elliott Sales de Andrade <esalesde at physics.utoronto.ca>
Date: Tue Jan 6 01:55:54 2015 -0500
Update Makefiles to match other SPECFEM code.
That is, use pattern rules to build things. Also, fix old Makefile to
correctly build all targets.
>---------------------------------------------------------------
d4d879a7639670abab36a702e6500666ffbfc1d3
.gitignore | 1 +
Fortran_version/Makefile | 83 +++++++++++-----------
Fortran_version/README | 2 +-
.../Makefile | 70 +++++-------------
4 files changed, 60 insertions(+), 96 deletions(-)
diff --git a/.gitignore b/.gitignore
index a18b4d1..da11488 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,6 +2,7 @@
obj/*.o
# Executable file
+xdiffusion
xwave
# Runtime exampple files
diff --git a/Fortran_version/Makefile b/Fortran_version/Makefile
index 1706c6c..d5d017f 100644
--- a/Fortran_version/Makefile
+++ b/Fortran_version/Makefile
@@ -14,15 +14,15 @@ DEBUG=no # Debug mode or not
EXEC=xspecfem1d # Executable name
# Intel
-#F90 = ifort # Fortran Compiler
-#FLAGS=#-W -Wall -Wextra -pedantic # Compiler flags
-#FLAGS_DEBUG = -O1 -vec-report0 -std95 -implicitnone -warn truncated_source -warn argument_checking -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -check all -align sequence -assume byterecl -ftz -traceback -ftrapuv # Compiler debug flags
+#FC = ifort # Fortran Compiler
+#FCFLAGS=#-W -Wall -Wextra -pedantic # Compiler flags
+#FCFLAGS_DEBUG = -O1 -vec-report0 -std95 -implicitnone -warn truncated_source -warn argument_checking -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -check all -align sequence -assume byterecl -ftz -traceback -ftrapuv # Compiler debug flags
#LDFLAGS = #Linker flags
#MOD_OPTION = -module #Specifies the directory <dir> where module (.mod) files should be placed when created and where they should be searched for
# GNU gfortran
-F90 = gfortran # Fortran Compiler
-FLAGS=#-W -Wall -Wextra -pedantic # Compiler flags
+FC = gfortran # Fortran Compiler
+FCFLAGS=#-W -Wall -Wextra -pedantic # Compiler flags
FLAGS_DEBUG = -std=gnu -fimplicit-none -frange-check -O2 -fmax-errors=10 -pedantic -pedantic-errors -Waliasing -Wampersand -Wcharacter-truncation -Wline-truncation -Wsurprising -Wno-tabs -Wunderflow -fbounds-check # Compiler debug flags
LDFLAGS = #Linker flags
MOD_OPTION = -J #Specifies the directory <dir> where module (.mod) files should be placed when created and where they should be searched for
@@ -30,58 +30,55 @@ MOD_OPTION = -J #Specifies the directory <dir> where module (.mod) files should
#******* DO NOT CHANGE ANYTHING BELOW *******#
-OBJ_DIR_NAME := obj
-SRC_DIR_NAME := src
-BIN_DIR_NAME := bin
-
-PWD := $(shell pwd)
-OBJ_DIR := $(PWD)/$(OBJ_DIR_NAME)
-SRC_DIR := $(PWD)/$(SRC_DIR_NAME)
-BIN_DIR := $(PWD)/$(BIN_DIR_NAME)
+O := obj
+S := src
+B := bin
ifeq ($(DEBUG),yes)
- FLAGS := $(FLAGS_DEBUG)
+ FCFLAGS := $(FCFLAGS_DEBUG)
endif
-SRC = $(wildcard $(SRC_DIR)/*.f90)
-
-# List of object files :
-NAME := $(basename $(notdir $(SRC)))
-OBJ := $(addprefix $(OBJ_DIR)/, $(addsuffix .o, $(NAME)))
+OBJ = \
+ $O/modules.o \
+ $O/define_derivative_matrix.o \
+ $O/gaussm3.o \
+ $O/gll_library.o \
+ $O/lagrange_poly.o \
+ $O/source_time_function.o \
+ $O/specfem1d.o
+
+MODS = \
+ gaussm3 \
+ globalstiffmat \
+ grid \
+ othervariables
+
+# Default target
+all: $B/$(EXEC)
+
+# Module dependencies
+$O/modules.o: $O/gaussm3.o
+$O/define_derivative_matrix.o: $O/modules.o
+$O/gll_library.o: $O/modules.o
+$O/lagrange_poly.o: $O/modules.o
+$O/source_time_function.o: $O/modules.o
+$O/specfem1d.o: $O/modules.o
# To make the executable
-all: $(OBJ)
- $(F90) -o $(BIN_DIR)/$(EXEC) $(OBJ) $(LDFLAGS)
-
-$(OBJ_DIR)/gaussm3.o: $(SRC_DIR)/gaussm3.f90
- $(F90) $(MOD_OPTION)$(OBJ_DIR) -I$(OBJ_DIR) -c $(SRC_DIR)/gaussm3.f90 -o $(OBJ_DIR)/gaussm3.o $(FLAGS)
-
-$(OBJ_DIR)/modules.o: $(OBJ_DIR)/gaussm3.o $(SRC_DIR)/modules.f90
- $(F90) $(MOD_OPTION)$(OBJ_DIR) -I$(OBJ_DIR) -c $(SRC_DIR)/modules.f90 -o $(OBJ_DIR)/modules.o $(FLAGS)
-
-$(OBJ_DIR)/define_derivative_matrix.o: $(OBJ_DIR)/modules.o $(SRC_DIR)/define_derivative_matrix.f90
- $(F90) $(MOD_OPTION)$(OBJ_DIR) -I$(OBJ_DIR) -c $(SRC_DIR)/define_derivative_matrix.f90 -o $(OBJ_DIR)/define_derivative_matrix.o $(FLAGS)
-
-$(OBJ_DIR)/gll_library.o: $(OBJ_DIR)/modules.o $(SRC_DIR)/gll_library.f90
- $(F90) $(MOD_OPTION)$(OBJ_DIR) -I$(OBJ_DIR) -c $(SRC_DIR)/gll_library.f90 -o $(OBJ_DIR)/gll_library.o $(FLAGS)
-
-$(OBJ_DIR)/lagrange_poly.o: $(OBJ_DIR)/modules.o $(SRC_DIR)/lagrange_poly.f90
- $(F90) $(MOD_OPTION)$(OBJ_DIR) -I$(OBJ_DIR) -c $(SRC_DIR)/lagrange_poly.f90 -o $(OBJ_DIR)/lagrange_poly.o $(FLAGS)
-
-$(OBJ_DIR)/source_time_function.o: $(OBJ_DIR)/modules.o $(SRC_DIR)/source_time_function.f90
- $(F90) $(MOD_OPTION)$(OBJ_DIR) -I$(OBJ_DIR) -c $(SRC_DIR)/source_time_function.f90 -o $(OBJ_DIR)/source_time_function.o $(FLAGS)
+$B/$(EXEC): $(OBJ)
+ $(FC) -o $@ $(LDFLAGS) $+
-$(OBJ_DIR)/specfem1d.o: $(OBJ_DIR)/modules.o $(SRC_DIR)/specfem1d.f90
- $(F90) $(MOD_OPTION)$(OBJ_DIR) -I$(OBJ_DIR) -c $(SRC_DIR)/specfem1d.f90 -o $(OBJ_DIR)/specfem1d.o $(FLAGS)
+$O/%.o: $S/%.f90
+ $(FC) $(MOD_OPTION)$O -I$O -o $@ $(FCFLAGS) -c $<
# .PHONY is useful for example if a file called "clean" exists in the current directory -> "make clean" would not work
.PHONY: clean purge
# Clean remove all .o (if you don't want to see the messages use : @rm -rf *.o -> only the error messages will appear)
clean:
- rm -rf $(OBJ) $(SRC_DIR)/*~ *~ .plot_all_snapshots.gnu utils/*~ $(BIN_DIR)/$(EXEC)
+ rm -f $(OBJ) $(addprefix $O/, $(addsuffix .mod, $(MODS))) $B/$(EXEC)
# Clean and remove executable
purge: clean
- rm -rf OUTPUT_FILES
+ rm -f OUTPUT_FILES/* $S/*~ *~ _________plot_all_snapshots.gnu
diff --git a/Fortran_version/README b/Fortran_version/README
index 557d2a7..64fbe8e 100644
--- a/Fortran_version/README
+++ b/Fortran_version/README
@@ -14,7 +14,7 @@ Getting started :
-open Makefile and uncomment the lines corresponding to your compiler (GNU gfortran or ifort)
-then : "make" produces the executable in the bin directory
-finally : type "./bin/xspecfem1d" to run it
- -"make clean" to remove the obj/ directory
+ -"make clean" to remove the build results
-"make purge" to delete all files created
There is no parameter file for this simple 1D version, the run characteristics are chosen in src/constant.h.
diff --git a/older_Fortran_version_from_Jeroen_and_Dimitri_also_with_diffusion_equation/Makefile b/older_Fortran_version_from_Jeroen_and_Dimitri_also_with_diffusion_equation/Makefile
index b7a791c..26b8fd6 100644
--- a/older_Fortran_version_from_Jeroen_and_Dimitri_also_with_diffusion_equation/Makefile
+++ b/older_Fortran_version_from_Jeroen_and_Dimitri_also_with_diffusion_equation/Makefile
@@ -1,4 +1,3 @@
-
#=====================================================================
#
# S p e c f e m 1 D V e r s i o n 1 . 0
@@ -27,64 +26,31 @@
O = obj
# Portland
-#F90 = pgf90
-#FLAGS =-fast -Mnobounds -Minline -Mneginfo -Mdclchk -Knoieee -Minform=warn -fastsse -tp amd64e -Msmart
+#FC = pgf90
+#FCFLAGS =-fast -Mnobounds -Minline -Mneginfo -Mdclchk -Knoieee -Minform=warn -fastsse -tp amd64e -Msmart
# Intel
-#F90 = ifort
-#FLAGS = -O1 -vec-report0 -std95 -implicitnone -warn truncated_source -warn argument_checking -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -check all -align sequence -assume byterecl -ftz -traceback -ftrapuv
+#FC = ifort
+#FCFLAGS = -O1 -vec-report0 -std95 -implicitnone -warn truncated_source -warn argument_checking -warn unused -warn declarations -warn alignments -warn ignore_loc -warn usage -check all -align sequence -assume byterecl -ftz -traceback -ftrapuv
# GNU gfortran
-F90 = gfortran
-FLAGS = -std=gnu -fimplicit-none -frange-check -O2 -fmax-errors=10 -pedantic -pedantic-errors -Waliasing -Wampersand -Wcharacter-truncation -Wline-truncation -Wsurprising -Wno-tabs -Wunderflow -fbounds-check
-
-wave: constants.h \
- $O/wave.o \
- $O/gll_library.o \
- $O/lagrange_poly.o \
- $O/source_time_function.o \
- $O/define_derivative_matrix.o
- ${F90} $(FLAGS) -o xwave \
- $O/wave.o \
- $O/gll_library.o \
- $O/lagrange_poly.o \
- $O/source_time_function.o \
- $O/define_derivative_matrix.o
-
-diffusion: constants.h \
- $O/diffusion.o \
- $O/gll_library.o \
- $O/lagrange_poly.o \
- $O/define_derivative_matrix.o
- ${F90} $(FLAGS) -o xdiffusion \
- $O/diffusion.o \
- $O/gll_library.o \
- $O/lagrange_poly.o \
- $O/define_derivative_matrix.o
+FC = gfortran
+FCFLAGS = -std=gnu -fimplicit-none -frange-check -O2 -fmax-errors=10 -pedantic -pedantic-errors -Waliasing -Wampersand -Wcharacter-truncation -Wline-truncation -Wsurprising -Wno-tabs -Wunderflow -fbounds-check
-bak:
- cp *f90 *h Makefile bak
-
-clean:
- rm -f $O/*.o *.o snapshot* seismogram xwave xdiffusion
+all: xwave xdiffusion
-all: clean wave diffusion
+xwave: $O/wave.o $O/gll_library.o $O/lagrange_poly.o $O/source_time_function.o $O/define_derivative_matrix.o
+ ${FC} $(FCFLAGS) -o $@ $+
-$O/wave.o: constants.h wave.f90
- ${F90} $(FLAGS) -c -o $O/wave.o wave.f90
+xdiffusion: $O/diffusion.o $O/gll_library.o $O/lagrange_poly.o $O/define_derivative_matrix.o
+ ${FC} $(FCFLAGS) -o $@ $+
-$O/diffusion.o: constants.h diffusion.f90
- ${F90} $(FLAGS) -c -o $O/diffusion.o diffusion.f90
+$O/%.o: %.f90 constants.h
+ ${FC} $(FCFLAGS) -c -o $@ $<
-$O/define_derivative_matrix.o: constants.h define_derivative_matrix.f90
- ${F90} $(FLAGS) -c -o $O/define_derivative_matrix.o define_derivative_matrix.f90
-
-$O/gll_library.o: gll_library.f90
- ${F90} $(FLAGS) -c -o $O/gll_library.o gll_library.f90
-
-$O/lagrange_poly.o: lagrange_poly.f90
- ${F90} $(FLAGS) -c -o $O/lagrange_poly.o lagrange_poly.f90
-
-$O/source_time_function.o: source_time_function.f90
- ${F90} $(FLAGS) -c -o $O/source_time_function.o source_time_function.f90
+.PHONY: clean purge
+clean:
+ rm -f $O/*.o xwave xdiffusion
+purge: clean
+ rm -f snapshot* seismogram
More information about the CIG-COMMITS
mailing list