aboutsummaryrefslogtreecommitdiff
path: root/src/GRHydro_Prim2Con.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/GRHydro_Prim2Con.c')
-rw-r--r--src/GRHydro_Prim2Con.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/GRHydro_Prim2Con.c b/src/GRHydro_Prim2Con.c
index 36578b0..b3c59be 100644
--- a/src/GRHydro_Prim2Con.c
+++ b/src/GRHydro_Prim2Con.c
@@ -69,8 +69,9 @@ void Primitive2ConservativeC(CCTK_ARGUMENTS)
// EOS calls (now GF-wide)
if(!*evolve_temper) {
- int n = cctk_lsh[0]*cctk_lsh[1]*cctk_lsh[2];
- int keyerr[n]; int anyerr = 0;
+ int n = cctk_ash[0]*cctk_ash[1]*cctk_ash[2];
+ int *keyerr = malloc(sizeof(*keyerr)*n);
+ int anyerr = 0;
int keytemp = 0;
// don't need special error handling for analytic EOS
@@ -80,12 +81,12 @@ void Primitive2ConservativeC(CCTK_ARGUMENTS)
EOS_Omni_pressOMP(*GRHydro_eos_handle,keytemp,GRHydro_eos_rf_prec,n,
rhoplus,epsplus,NULL,NULL,pressplus,keyerr,&anyerr);
+ free(keyerr);
} else {
if(reconstruct_temper) {
- int n = cctk_lsh[0]*cctk_lsh[1]*cctk_lsh[2];
- // Linux usually offers ~8MB of stack which is good for ~1M points.
- // We should consider malloc() if we ever smash the stack.
- int keyerr[n]; int anyerr = 0;
+ int n = cctk_ash[0]*cctk_ash[1]*cctk_ash[2];
+ int *keyerr = malloc(sizeof(*keyerr)*n);
+ int anyerr = 0;
int keytemp = 1;
// ensure Y_e and temperature within bounds
@@ -140,10 +141,12 @@ void Primitive2ConservativeC(CCTK_ARGUMENTS)
CCTK_VWarn(0, __LINE__, __FILE__, CCTK_THORNSTRING,
"Aborting!");
}
+ free(keyerr);
} else {
// ******************** EPS RECONSTRUCTION BRANCH ******************
- int n = cctk_lsh[0]*cctk_lsh[1]*cctk_lsh[2];
- int keyerr[n]; int anyerr = 0;
+ int n = cctk_ash[0]*cctk_ash[1]*cctk_ash[2];
+ int *keyerr = malloc(sizeof(*keyerr)*n);
+ int anyerr = 0;
int keytemp = 0;
// ensure Y_e and temperature within bounds
@@ -236,6 +239,7 @@ void Primitive2ConservativeC(CCTK_ARGUMENTS)
}
} // for i, i<n error checking
}
+ free(keyerr);
} // end branch for no temp reconsturction
} // end of evolve temper branch