Skip to content

Commit db09bd9

Browse files
authored
Merge pull request #644 from rjleveque/bouss_petsc_updates
Updates to bouss files for PETSc setup
2 parents 338c609 + 2f93c29 commit db09bd9

File tree

4 files changed

+86
-19
lines changed

4 files changed

+86
-19
lines changed

examples/bouss/README.txt

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

2-
GeoClaw Boussinesq solver examples
2+
GeoClaw Boussinesq solver examples (in 2D)
3+
4+
Some 1D Boussinesq solver examples are in $CLAW/geoclaw/examples/1d_classic
5+
in directories starting with bouss_
36

47
The radial_flat subdirectory contains one example using the Boussinesq
58
solver introduced in Clawpack v5.10.0.
@@ -13,8 +16,12 @@ which are described in the paper found at:
1316

1417
Running these codes requires PETSc Version 3.20 (or later) in order to use
1518
OpenMP along with MPI. Some flags have to be set as environment variables
16-
or directly in the application Makefile, e.g. see the lines commented out in
17-
radial_flat/Makefile.
19+
or directly in the application Makefile.
20+
21+
For more information on installing PETSc and setting these environment
22+
variables properly, see:
23+
https://www.clawpack.org/bouss2d.html
24+
1825

1926
**Update:** Clawpack 5.12.0 now requires PETSc Version 3.23 (or later).
2027

@@ -24,6 +31,38 @@ variables for the bash shell.
2431
A file petscMPIoptions is also required to set some PETSc parameters for the
2532
iterative method used to solve the large sparse linear systems that arise at
2633
each refinement level when the Boussinesq equations are solved.
27-
One of the environment variables mentioned above points to this file, and a
28-
sample is included in this directory.
34+
The environment variable PETSC_OPTIONS should point to the version of this
35+
file that you wish to use, see setenv.sh for an example of setting this to
36+
point to the sample petscMPIoptions file included in this directory.
37+
38+
39+
**Check:**
40+
41+
The example Makefile in
42+
$CLAW/geoclaw/examples/bouss/radial_flat/Makefile
43+
contains an option so that you can do
44+
$ make check
45+
at the command line to see how various options are set and to check that
46+
they look correct (or help debug if the code does not run).
47+
This is an enhancement of the 'make check' option added to the common
48+
Makefile for all Clawpack applications in v5.12.0, and should produce
49+
something like this:
50+
51+
===================
52+
CLAW = /Users/rjl/git/clawpack
53+
OMP_NUM_THREADS = 6
54+
BOUSS_MPI_PROCS = 6
55+
PETSC_OPTIONS=-options_file /Users/rjl/git/clawpack/geoclaw/examples/bouss/petscMPIoptions
56+
PETSC_DIR = /Users/rjl/git/Clones/petsc
57+
PETSC_ARCH = arch-darwin-c-opt
58+
CLAW_MPIEXEC = mpiexec
59+
RUNEXE = mpiexec -n 6
60+
EXE = /Users/rjl/git/clawpack/geoclaw/examples/bouss/radial_flat/xgeoclaw
61+
CLAW_MPIFC = mpif90
62+
FC = mpif90
63+
FFLAGS = -O2 -fopenmp -DHAVE_PETSC -ffree-line-length-none
64+
LFLAGS = -L/Users/rjl/git/Clones/petsc/arch-darwin-c-opt/lib -lpetsc -fopenmp
65+
OUTDIR = _output
66+
PLOTDIR = _plots
67+
===================
2968

examples/bouss/petscMPIoptions

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
# preconditioner:
2727
-pc_type gamg
28-
#-pc_type hypre
28+
#-pc_type hypre # requires installing hypre
2929

3030

3131
# debug options:
@@ -36,6 +36,8 @@
3636
#-ksp_view
3737
#-info
3838

39+
# print options at end of run:
40+
-options_view
41+
3942
# test if any options are not used:
4043
#-options_left
41-
-options_view

examples/bouss/radial_flat/Makefile

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ CLAWMAKE = $(CLAW)/clawutil/src/Makefile.common
2222

2323
CLAW_PKG = geoclaw # Clawpack package to use
2424

25-
# These environment variables need to be set properly, usually in your
26-
# shell, but they could be explicitly set here:
27-
#PETSC_DIR=/full/path/to/petsc
28-
#PETSC_ARCH=arch-darwin-c-opt
25+
# Several environment variables are expected in this Makefile,
26+
# as set for example in the bash script
27+
# $CLAW/geoclaw/examples/bouss/setenv.sh
28+
# Some of these could instead be set here explicitly.
2929

30+
# But PETSC_OPTIONS must be set as an environment variable!
3031
# The file petscMPIoptions sets parameters for MPI and the iterative solver:
31-
# PETSC_OPTIONS must be set as an environment variable!
3232
# e.g. in bash:
3333
# export PETSC_OPTIONS="-options_file $CLAW/geoclaw/examples/bouss/petscMPIoptions"
3434

@@ -58,7 +58,6 @@ FC = ${CLAW_MPIFC}
5858
BOUSS_MPI_PROCS ?= 6
5959

6060
EXE = $(PWD)/xgeoclaw
61-
#RUNEXE="${PETSC_DIR}/${PETSC_ARCH}/bin/mpiexec -n ${BOUSS_MPI_PROCS}"
6261
RUNEXE="${CLAW_MPIEXEC} -n ${BOUSS_MPI_PROCS}"
6362
SETRUN_FILE = setrun.py # File containing function to make data
6463
OUTDIR = _output # Directory for output
@@ -67,7 +66,7 @@ PLOTDIR = _plots # Directory for plots
6766

6867

6968
# Some compiler flags below are needed for PETSc
70-
PETSC_INCLUDE = $(PETSC_DIR)/include $(PETSC_DIR)/$(PETSC_ARCH)/include
69+
PETSC_INCLUDE = $(PETSC_DIR)/include $(PETSC_DIR)/$(PETSC_ARCH)/include
7170
INCLUDE += $(PETSC_INCLUDE)
7271
PETSC_LFLAGS = $(shell PKG_CONFIG_PATH=$(PETSC_DIR)/$(PETSC_ARCH)/lib/pkgconfig pkg-config --libs-only-L --libs-only-l PETSc)
7372

@@ -93,7 +92,7 @@ include $(BOUSSLIB)/Makefile.bouss
9392

9493
# ---------------------------------------
9594
# package sources specifically to exclude
96-
# (i.e. if a custom replacement source
95+
# (i.e. if a custom replacement source
9796
# under a different name is provided)
9897
# ---------------------------------------
9998

examples/bouss/setenv.sh

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,42 @@
33
# to run the Bouss version of GeoClaw with MPI and OpenMP.
44
# Adjust as needed for your system...
55

6-
# You also need to set CLAW, FC, and perhaps PYTHONPATH
7-
8-
# For more information, see
6+
# For more information on installing PETSc and setting these environment
7+
# variables properly, see $CLAW/geoclaw/examples/bouss/README.txt and
98
# https://www.clawpack.org/bouss2d.html
9+
10+
# You also need to set CLAW, and perhaps PYTHONPATH, see:
1011
# https://www.clawpack.org/setenv.html
1112

13+
# export CLAW=full/path/to/clawpack
14+
echo CLAW is set to $CLAW
15+
16+
# path to PETSc installation:
1217
export PETSC_DIR=/full/path/to/petsc
18+
19+
# PETSC_ARCH is only needed if PETSc is installed inside the PETSc directory.
1320
export PETSC_ARCH=arch-darwin-c-opt
21+
# For PETSc installs by conda or package managers, it should not be set.
22+
#export PETSC_ARCH=
23+
24+
# PETSC_OPTIONS should point to the options file needed to specify
25+
# many parameters controlling which solver, preconditioner, etc are used:
1426
export PETSC_OPTIONS="-options_file $CLAW/geoclaw/examples/bouss/petscMPIoptions"
27+
28+
# number of OpenMP threads to use for explicit AMR (as usual in GeoClaw):
1529
export OMP_NUM_THREADS=6
16-
export BOUSS_MPI_PROCS=6 # only used in Clawpack Boussinesq example
1730

31+
# number of MPI processes to use for solving linear systems with PETSc:
32+
export BOUSS_MPI_PROCS=6
33+
34+
# the mpiexec command to use to run the executable:
35+
export CLAW_MPIEXEC=mpiexec
36+
# set CLAW_MPIEXEC to mpiexec only if this command is defined in your shell,
37+
# e.g. to use some version of MPI was installed outside of PETSc.
38+
# Or set to the full path to this command, e.g. for the PETSc version:
39+
#export CLAW_MPIEXEC=$PETSC_DIR/$PETSC_ARCH/bin/mpiexec # requires PETSC_ARCH
40+
41+
# the proper Fortran compiler to use for MPI code:
42+
# e.g. mpif90 if that is defined in your shell, or gfortran *might* work.
43+
# This will over-rule any FC environment variable.
44+
export CLAW_MPIFC=mpif90

0 commit comments

Comments
 (0)