Skip to content

Commit

Permalink
make MAX_REAC a compile-time option in the GNUmakefile instead of har…
Browse files Browse the repository at this point in the history
…d-coded in chemistry_namespace

error checking to make sure MAX_REAC and MAX_SPEC are larger than nreaction and nspecies
  • Loading branch information
ajnonaka committed Aug 21, 2024
1 parent d802798 commit f2433ed
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
6 changes: 5 additions & 1 deletion exec/chemistry_testing/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ USE_OMP = FALSE
USE_CUDA = FALSE
COMP = gnu
DIM = 3
MAX_SPEC = 8
MAX_SPEC = 8
MAX_REAC = 5

TINY_PROFILE = FALSE

Expand Down Expand Up @@ -40,3 +41,6 @@ include $(AMREX_HOME)/Tools/GNUMake/Make.rules
MAXSPECIES := $(strip $(MAX_SPEC))
DEFINES += -DMAX_SPECIES=$(MAXSPECIES)

MAXREACTION := $(strip $(MAX_REAC))
DEFINES += -DMAX_REACTION=$(MAXREACTION)

4 changes: 4 additions & 0 deletions exec/compressible/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ COMP = gnu
DIM = 3
TINY_PROFILE = FALSE
MAX_SPEC = 8
MAX_REAC = 5

USE_PARTICLES = FALSE

Expand Down Expand Up @@ -60,3 +61,6 @@ endif
MAXSPECIES := $(strip $(MAX_SPEC))
DEFINES += -DMAX_SPECIES=$(MAXSPECIES)

MAXREACTION := $(strip $(MAX_REAC))
DEFINES += -DMAX_REACTION=$(MAXREACTION)

4 changes: 4 additions & 0 deletions exec/compressible_stag/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ COMP = gnu
DIM = 3
TINY_PROFILE = FALSE
MAX_SPEC = 8
MAX_REAC = 5

USE_PARTICLES = FALSE
DO_TURB = FALSE
Expand Down Expand Up @@ -74,3 +75,6 @@ endif

MAXSPECIES := $(strip $(MAX_SPEC))
DEFINES += -DMAX_SPECIES=$(MAXSPECIES)

MAXREACTION := $(strip $(MAX_REAC))
DEFINES += -DMAX_REACTION=$(MAXREACTION)
3 changes: 3 additions & 0 deletions exec/compressible_stag_mui/GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ USE_MUI = TRUE
USE_SLURM = FALSE
USE_AMREX_MPMD = TRUE
MAX_SPEC = 8
MAX_REAC = 5

USE_PARTICLES = FALSE

Expand Down Expand Up @@ -127,3 +128,5 @@ endif
MAXSPECIES := $(strip $(MAX_SPEC))
DEFINES += -DMAX_SPECIES=$(MAXSPECIES)

MAXREACTION := $(strip $(MAX_REAC))
DEFINES += -DMAX_REACTION=$(MAXREACTION)
3 changes: 3 additions & 0 deletions src_chemistry/chemistry_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ void InitializeChemistryNamespace()
nreaction = 0;
// get number of reactions
pp.query("nreaction",nreaction);
if (nreaction > MAX_REACTION) {
Abort("nreaction > MAX_REACTION; recompile with a new MAX_REAC in the GNUmakefile");
}

// if nreaction is set to zero or not defined in the inputs file, quit the routine
if (nreaction==0) return;
Expand Down
2 changes: 0 additions & 2 deletions src_chemistry/chemistry_namespace.H
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
namespace chemistry {
#define MAX_REACTION 5

extern AMREX_GPU_MANAGED int nreaction;

extern AMREX_GPU_MANAGED GpuArray<amrex::Real, MAX_REACTION> rate_const;
Expand Down
3 changes: 3 additions & 0 deletions src_common/common_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,9 @@ void InitializeCommonNamespace() {
// pp.getarr and queryarr("string",inputs,start_indx,count); can be used for arrays

pp.query("nspecies",nspecies);
if (nspecies > MAX_SPECIES) {
Abort("nspecies > MAX_SPECIES; recompile with a new MAX_SPEC in the GNUmakefile");
}
pp.query("nbonds",nbonds);

if (pp.queryarr("prob_lo",temp)) {
Expand Down

0 comments on commit f2433ed

Please sign in to comment.