Skip to content

Commit 73f3e73

Browse files
committed
fortran sources for acoustics_1d_example1.
1 parent 3c624b2 commit 73f3e73

22 files changed

+2348
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
# Makefile for Clawpack code in this directory.
3+
# This version only sets the local files and frequently changed
4+
# options, and then includes the standard makefile pointed to by CLAWMAKE.
5+
CLAWMAKE = Makefile.common
6+
7+
# See the above file for details and a list of make options, or type
8+
# make .help
9+
# at the unix prompt.
10+
11+
12+
# Adjust these variables if desired:
13+
# ----------------------------------
14+
15+
CLAW_PKG = classic # Clawpack package to use
16+
EXE = xclaw # Executable to create
17+
SETRUN_FILE = setrun.py # File containing function to make data
18+
OUTDIR = _output # Directory for output
19+
SETPLOT_FILE = setplot.py # File containing function to set plots
20+
PLOTDIR = _plots # Directory for plots
21+
22+
OVERWRITE ?= True # False ==> make a copy of OUTDIR first
23+
RESTART ?= False # Should = clawdata.restart in setrun
24+
25+
# Environment variable FC should be set to fortran compiler, e.g. gfortran
26+
27+
# Compiler flags can be specified here or set as an environment variable
28+
FFLAGS ?=
29+
30+
# ---------------------------------
31+
# List of sources for this program:
32+
# ---------------------------------
33+
34+
MODULES = \
35+
36+
SOURCES = \
37+
qinit.f90 \
38+
setprob.f90 \
39+
./rp1_acoustics.f90 \
40+
./setaux.f90 \
41+
./bc1.f \
42+
./b4step1.f90 \
43+
./driver.f90 \
44+
./claw1ez.f \
45+
./claw1.f \
46+
./copyq1.f \
47+
./inlinelimiter.f90 \
48+
./opendatafile.f \
49+
./out1.f \
50+
./src1.f90 \
51+
./step1.f90
52+
53+
#-------------------------------------------------------------------
54+
# Include Makefile containing standard definitions and make options:
55+
include $(CLAWMAKE)
56+
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
#
2+
# Makefile.common for the clawpack code
3+
# This file is generally "included" in Makefiles for libraries or apps.
4+
#
5+
# See the end of this file for a summary, or type "make help".
6+
7+
8+
# General makefile settings
9+
SHELL = /bin/sh
10+
INSTALL_PROGRAM ?= $(INSTALL)
11+
INSTALL_DATA ?= $(INSTALL) -m 644
12+
13+
# Fortran compiler: FC may be set as an environment variable or in make
14+
# file that 'includes' this one. Otherwise assume gfortran.
15+
FC ?= gfortran
16+
ifeq ($(FC),f77)
17+
# make sometimes sets FC=f77 if it is not set as environment variable
18+
# reset to gfortran since f77 will not work.
19+
FC = gfortran
20+
endif
21+
22+
CLAW_FC ?= $(FC)
23+
LINK ?= $(CLAW_FC)
24+
25+
# Path to version of python to use: May need to use something other than
26+
# the system default in order for plotting to work. Can set CLAW_PYTHON as
27+
# environment variable or in make file that 'includes' this one.
28+
PYTHON ?= python
29+
CLAW_PYTHON ?= $(PYTHON)
30+
31+
# Variables below should be set in Makefile that "includes" this one.
32+
# Default values if not set:
33+
EXE ?= xclaw
34+
CLAW_PKG ?= classic
35+
OUTDIR ?= _output
36+
PLOTDIR ?= _plots
37+
LIB_PATHS ?= $(CURDIR)/
38+
OVERWRITE ?= True
39+
RESTART ?= False
40+
GIT_STATUS ?= False
41+
SETRUN_FILE ?= ./setrun.py
42+
SETPLOT_FILE ?= ./setplot.py
43+
44+
#----------------------------------------------------------------------------
45+
# Lists of source, modules, and objects
46+
# These should be set in the including Makefile
47+
SOURCES ?=
48+
MODULES ?=
49+
50+
# Make list of .o files required from the sources above:
51+
OBJECTS = $(subst .F,.o, $(subst .F90,.o, $(subst .f,.o, $(subst .f90,.o, $(SOURCES)))))
52+
MODULE_FILES = $(subst .F,.mod, $(subst .F90,.mod, $(subst .f,.mod, $(subst .f90,.mod, $(MODULES)))))
53+
# FYI: Sort weeds out duplicate paths
54+
MODULE_PATHS = $(sort $(dir $(MODULE_FILES)))
55+
MODULE_OBJECTS = $(subst .F,.o, $(subst .F90,.o, $(subst .f,.o, $(subst .f90,.o, $(MODULES)))))
56+
57+
#----------------------------------------------------------------------------
58+
# Compiling, linking, and include flags
59+
# User set flags, empty if not set
60+
INCLUDE ?=
61+
#FFLAGS ?=
62+
FFLAGS += -g
63+
LFLAGS ?= $(FFLAGS)
64+
# PPFLAGS ?=
65+
66+
# These will be included in all actual compilation and linking, one could
67+
# actually overwrite these before hand but that is not the intent of these
68+
# variables
69+
ALL_INCLUDE ?=
70+
ALL_FFLAGS ?=
71+
ALL_LFLAGS ?=
72+
73+
# Add includes, the module search paths and library search paths are appended
74+
# at the end of the ALL_INCLUDE variable so that INCLUDE can override any of
75+
# the default settings
76+
ALL_INCLUDE += $(addprefix -I,$(INCLUDE))
77+
ALL_INCLUDE += $(addprefix -I,$(MODULE_PATHS)) $(addprefix -I,$(LIB_PATHS))
78+
79+
# ALL_FFLAGS and ALL_LFLAGS currently only includes the user defined flags
80+
ALL_FFLAGS += $(FFLAGS)
81+
ALL_LFLAGS += $(LFLAGS)
82+
83+
# Module flag setting, please add other compilers here as necessary
84+
ifeq ($(findstring gfortran,$(CLAW_FC)),gfortran)
85+
# There should be no space between this flag and the argument
86+
MODULE_FLAG = -J
87+
OMP_FLAG = -fopenmp
88+
else ifeq ($(CLAW_FC),ifort)
89+
# Note that there shoud be a space after this flag
90+
MODULE_FLAG = -module
91+
OMP_FLAG = -openmp
92+
else
93+
# Assume gcc like flagging, probably should raise an error here
94+
MODULE_FLAG = -J
95+
OMP_FLAG = -fopenmp
96+
endif
97+
98+
# We may want to set MAKELEVEL here as it is not always set but we know we are
99+
# not the first level (the original calling Makefile should be MAKELEVEL = 0)
100+
# MAKELEVEL ?= 0
101+
102+
#----------------------------------------------------------------------------
103+
# Targets that do not correspond to file names:
104+
.PHONY: .objs .exe clean clobber new all output plots;
105+
106+
# Reset suffixes that we understand
107+
.SUFFIXES:
108+
.SUFFIXES: .f90 .f .mod .o
109+
110+
# Default Rules, the module rule should be executed first in most instances,
111+
# this way the .mod file ends up always in the correct spot
112+
%.mod : %.f90 ; touch $@; $(CLAW_FC) -c $< $(MODULE_FLAG)$(@D) $(ALL_INCLUDE) $(ALL_FFLAGS) -o $*.o
113+
%.mod : %.f ; touch $@; $(CLAW_FC) -c $< $(MODULE_FLAG)$(@D) $(ALL_INCLUDE) $(ALL_FFLAGS) -o $*.o
114+
115+
%.o : %.f90 ; $(CLAW_FC) -c $< $(ALL_INCLUDE) $(ALL_FFLAGS) -o $@
116+
%.o : %.f ; $(CLAW_FC) -c $< $(ALL_INCLUDE) $(ALL_FFLAGS) -o $@
117+
118+
#----------------------------------------------------------------------------
119+
# Executable:
120+
121+
.objs: $(MODULE_FILES) $(OBJECTS);
122+
123+
# The order here is to again build the module files correctly
124+
$(EXE): $(MODULE_FILES) $(MODULE_OBJECTS) $(OBJECTS) $(MAKEFILE_LIST) ;
125+
$(LINK) $(MODULE_OBJECTS) $(OBJECTS) $(ALL_INCLUDE) $(ALL_LFLAGS) -o $(EXE)
126+
127+
.exe: $(EXE)
128+
129+
debug:
130+
@echo 'debugging -- MODULES:'
131+
@echo $(MODULES)
132+
@echo 'debugging -- MODULE_FILES:'
133+
@echo $(MODULE_FILES)
134+
@echo 'debugging -- MODULE_PATHS:'
135+
@echo $(MODULE_PATHS)
136+
137+
#----------------------------------------------------------------------------
138+
139+
# Command to create *.html files from *.f etc:
140+
CC2HTML = $(CLAW_PYTHON) $(CLAW)/clawutil/src/python/clawutil/clawcode2html.py --force
141+
142+
# make list of html files to be created by 'make .htmls':
143+
HTML = \
144+
$(subst .f,.f.html,$(wildcard *.f)) \
145+
$(subst .f95,.f95.html,$(wildcard *.f95)) \
146+
$(subst .f90,.f90.html,$(wildcard *.f90)) \
147+
$(subst .m,.m.html,$(wildcard *.m)) \
148+
$(subst .py,.py.html,$(wildcard *.py)) \
149+
$(subst .data,.data.html,$(wildcard *.data)) \
150+
$(subst .txt,.html,$(wildcard *.txt)) \
151+
$(subst .sh,.sh.html,$(wildcard *.sh)) \
152+
Makefile.html
153+
154+
# Rules to make html files:
155+
# e.g. qinit.f --> qinit.f.html
156+
%.f.html : %.f ; $(CC2HTML) $<
157+
%.f95.html : %.f95 ; $(CC2HTML) $<
158+
%.f90.html : %.f90 ; $(CC2HTML) $<
159+
%.m.html : %.m ; $(CC2HTML) $<
160+
%.py.html : %.py ; $(CC2HTML) $<
161+
%.data.html : %.data ; $(CC2HTML) $<
162+
%.sh.html : %.sh ; $(CC2HTML) $<
163+
Makefile.html : Makefile ; $(CC2HTML) $<
164+
# drop .txt extension, e.g. README.txt --> README.html
165+
%.html : %.txt ; $(CC2HTML) --dropext $<
166+
167+
.htmls: $(HTML) ;
168+
$(CLAW_PYTHON) $(CLAW)/clawutil/src/python/clawutil/convert_readme.py
169+
170+
#----------------------------------------------------------------------------
171+
172+
# Make data files needed by Fortran code:
173+
.data: $(SETRUN_FILE) $(MAKEFILE_LIST) ;
174+
$(MAKE) data
175+
176+
data: $(MAKEFILE_LIST);
177+
-rm -f .data
178+
$(CLAW_PYTHON) $(SETRUN_FILE) $(CLAW_PKG)
179+
touch .data
180+
181+
#----------------------------------------------------------------------------
182+
# Run the code and put fort.* files into subdirectory named output:
183+
# runclaw will execute setrun.py to create data files and determine
184+
# what executable to run, e.g. xclaw or xamr.
185+
.output: $(EXE) .data $(MAKEFILE_LIST);
186+
$(MAKE) output
187+
188+
#----------------------------------------------------------------------------
189+
# Run the code without checking dependencies:
190+
output: $(MAKEFILE_LIST);
191+
-rm -f .output
192+
$(CLAW_PYTHON) $(CLAW)/clawutil/src/python/clawutil/runclaw.py $(EXE) $(OUTDIR) \
193+
$(OVERWRITE) $(RESTART) . $(GIT_STATUS)
194+
@echo $(OUTDIR) > .output
195+
196+
#----------------------------------------------------------------------------
197+
198+
# Python command to create plots:
199+
200+
# (Removed Cygwin stuff...)
201+
# Plotting command
202+
PLOTCMD ?= $(CLAW_PYTHON) $(CLAW)/visclaw/src/python/visclaw/plotclaw.py
203+
204+
# Rule to make the plots into subdirectory specified by PLOTDIR,
205+
# using data in subdirectory specified by OUTDIR and the plotting
206+
# commands specified in SETPLOT_FILE.
207+
.plots: .output $(SETPLOT_FILE) $(MAKEFILE_LIST) ;
208+
$(MAKE) plots
209+
210+
# Make the plots without checking dependencies
211+
# This has to use its own plot command to skip the check for .output
212+
plots: $(SETPLOT_FILE) $(MAKEFILE_LIST);
213+
-rm -f .plots
214+
$(PLOTCMD) $(OUTDIR) $(PLOTDIR) $(SETPLOT_FILE)
215+
@echo $(PLOTDIR) > .plots
216+
217+
#----------------------------------------------------------------------------
218+
219+
# Rule to make full program by catenating all source files.
220+
# Sometimes useful for debugging:
221+
# Note that this will probably not compile due to mixed source forms
222+
223+
.program: $(MODULES) $(SOURCES) $(MAKEFILE_LIST);
224+
cat $(MODULES) $(SOURCES) claw_program.f90
225+
touch .program
226+
227+
#----------------------------------------------------------------------------
228+
229+
# Recompile everything:
230+
231+
# Note that we reset MAKELEVEL to 0 here so that we make sure to set the
232+
# preprocessor flags correctly
233+
new:
234+
-rm -f $(OBJECTS)
235+
-rm -f $(MODULE_OBJECTS)
236+
-rm -f $(MODULE_FILES)
237+
-rm -f $(EXE)
238+
$(MAKE) $(EXE) MAKELEVEL=0
239+
240+
241+
# Clean up options:
242+
clean:
243+
-rm -f $(EXE) $(HTML)
244+
-rm -f .data .output .plots .htmls
245+
246+
clobber:
247+
$(MAKE) clean
248+
-rm -f $(OBJECTS)
249+
-rm -f $(MODULE_OBJECTS)
250+
-rm -f $(MODULE_FILES)
251+
-rm -f fort.* *.pyc pyclaw.log
252+
-rm -f -r $(OUTDIR) $(PLOTDIR)
253+
254+
#----------------------------------------------------------------------------
255+
256+
# Default option that may be redefined in the application Makefile:
257+
all:
258+
$(MAKE) .plots
259+
$(MAKE) .htmls
260+
261+
#----------------------------------------------------------------------------
262+
263+
help:
264+
@echo ' "make .objs" to compile object files'
265+
@echo ' "make .exe" to create executable'
266+
@echo ' "make .data" to create data files using setrun.py'
267+
@echo ' "make .output" to run code'
268+
@echo ' "make output" to run code with no dependency checking'
269+
@echo ' "make .plots" to produce plots'
270+
@echo ' "make plots" to produce plots with no dependency checking'
271+
@echo ' "make .htmls" to produce html versions of files'
272+
@echo ' "make .program" to produce single program file'
273+
@echo ' "make new" to remove all objs and then make .exe'
274+
@echo ' "make clean" to clean up compilation and html files'
275+
@echo ' "make clobber" to also clean up output and plot files'
276+
@echo ' "make help" to print this message'
277+
278+
.help: help
279+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
.. _classic_examples_acoustics_1d_example1:
3+
4+
Acoustics 1D Example 1
5+
------------------------------------------
6+
7+
1D acoustics in a constant medium.
8+
9+
The density and bulk modulus of the medium are specified in setrun.py,
10+
along with the width parameter of the Gaussian pressure pulse used for
11+
the initial condition.
12+
13+
Boundary conditions are outflow at both boundaries.
14+
15+
After running this code and creating plots via "make .plots", you
16+
should be able to view the plots in _plots/_PlotIndex.html.
17+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
for mq1=mq
2+
subplot(length(mq),1,find(mq==mq1))
3+
axis([-1 1 -0.5 1])
4+
end
5+
6+
shg;
7+
clear afterframe
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
subroutine b4step1(mbc,mx,meqn,q,xlower,dx,t,dt,maux,aux)
2+
3+
! Called before each call to step1.
4+
! Use to set time-dependent aux arrays or perform other tasks.
5+
!
6+
! This default version does nothing.
7+
8+
implicit none
9+
integer, intent(in) :: mbc,mx,meqn,maux
10+
real(kind=8), intent(in) :: xlower,dx,t,dt
11+
real(kind=8), intent(inout) :: q(meqn,1-mbc:mx+mbc)
12+
real(kind=8), intent(inout) :: aux(maux,1-mbc:mx+mbc)
13+
14+
end subroutine b4step1
15+

0 commit comments

Comments
 (0)