From 22a8c86befc2b993d1d67b41759d9e24ec996754 Mon Sep 17 00:00:00 2001 From: rhaas Date: Thu, 13 Mar 2014 03:01:52 +0000 Subject: EOS_Omni: always set anyerr when an error is detected consistently abort the EOS call when checkbounds fails From: Roland Haas git-svn-id: http://svn.einsteintoolkit.org/cactus/EinsteinEOS/EOS_Omni/trunk@100 8e189c6b-2ab8-4400-aa02-70a9cfce18b9 --- src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc | 4 ++-- src/nuc_eos_cxx/nuc_eos_full.cc | 11 ++++++++--- src/nuc_eos_cxx/nuc_eos_press.cc | 7 ++++++- src/nuc_eos_cxx/nuc_eos_press_cs2.cc | 10 +++++++--- src/nuc_eos_cxx/nuc_eos_short.cc | 16 ++++++++++++---- 5 files changed, 35 insertions(+), 13 deletions(-) diff --git a/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc b/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc index ace3670..1ff15eb 100644 --- a/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc +++ b/src/nuc_eos_cxx/nuc_eos_dpdrhoe_dpderho.cc @@ -57,11 +57,11 @@ void CCTK_FNAME(nuc_eos_m_kt0_dpdrhoe_dpderho)(const int *restrict n_in, nuc_eos_findtemp(lr,lt,ye[i],lxeps,*prec, (double *restrict)(<out),&keyerr[i]); } else { + // will be overwritten further down, only marks error keyerr[i] = 667; - *anyerr = 1; } // epstot > 0.0 - if(keyerr[i] != 0) { + if(keyerr[i]) { // now try negative temperature treatment double eps0, eps1; int idx[8]; diff --git a/src/nuc_eos_cxx/nuc_eos_full.cc b/src/nuc_eos_cxx/nuc_eos_full.cc index d1f511d..57f0776 100644 --- a/src/nuc_eos_cxx/nuc_eos_full.cc +++ b/src/nuc_eos_cxx/nuc_eos_full.cc @@ -41,10 +41,14 @@ void CCTK_FNAME(nuc_eos_m_kt1_full)(const int *restrict n_in, keyerr[i] = checkbounds(rho[i], temp[i], ye[i]); if(keyerr[i] != 0) { *anyerr = 1; - return; } } + // Abort if there is any error in checkbounds. + // This should never happen and the program should abort with + // a fatal error anyway. No point in doing any further EOS calculations. + if(*anyerr) return; + for(int i=0;i 0.0 - if(!keyerr[i]) { + if(keyerr[i]) { + *anyerr=1; + } else { temp[i] = exp(ltout); int idx[8]; double delx,dely,delz; diff --git a/src/nuc_eos_cxx/nuc_eos_press.cc b/src/nuc_eos_cxx/nuc_eos_press.cc index 13b0558..52c3168 100644 --- a/src/nuc_eos_cxx/nuc_eos_press.cc +++ b/src/nuc_eos_cxx/nuc_eos_press.cc @@ -27,10 +27,14 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps)(const int *restrict n_in, keyerr[i] = checkbounds(rho[i], temp[i], ye[i]); if(keyerr[i] != 0) { *anyerr = 1; - return; } } + // Abort if there is any error in checkbounds. + // This should never happen and the program should abort with + // a fatal error anyway. No point in doing any further EOS calculations. + if(*anyerr) return; + for(int i=0;i 0.0 diff --git a/src/nuc_eos_cxx/nuc_eos_press_cs2.cc b/src/nuc_eos_cxx/nuc_eos_press_cs2.cc index 08ab8c2..2652ac5 100644 --- a/src/nuc_eos_cxx/nuc_eos_press_cs2.cc +++ b/src/nuc_eos_cxx/nuc_eos_press_cs2.cc @@ -28,10 +28,14 @@ void CCTK_FNAME(nuc_eos_m_kt1_press_eps_cs2)(const int *restrict n_in, keyerr[i] = checkbounds(rho[i], temp[i], ye[i]); if(keyerr[i] != 0) { *anyerr = 1; - return; } } + // Abort if there is any error in checkbounds. + // This should never happen and the program should abort with + // a fatal error anyway. No point in doing any further EOS calculations. + if(*anyerr) return; + for(int i=0;i 0.0 - if(keyerr[i] != 0) { + if(keyerr[i]) { // now try negative temperature treatment double eps0, eps1; int idx[8]; diff --git a/src/nuc_eos_cxx/nuc_eos_short.cc b/src/nuc_eos_cxx/nuc_eos_short.cc index 06e66d8..0e6347e 100644 --- a/src/nuc_eos_cxx/nuc_eos_short.cc +++ b/src/nuc_eos_cxx/nuc_eos_short.cc @@ -33,10 +33,14 @@ void CCTK_FNAME(nuc_eos_m_kt1_short)(const int *restrict n_in, keyerr[i] = checkbounds(rho[i], temp[i], ye[i]); if(keyerr[i] != 0) { *anyerr = 1; - return; } } + // Abort if there is any error in checkbounds. + // This should never happen and the program should abort with + // a fatal error anyway. No point in doing any further EOS calculations. + if(*anyerr) return; + for(int i=0;i 0.0 - if(!keyerr[i]) { + if(keyerr[i]) { + *anyerr = 1; + } else { temp[i] = exp(ltout); int idx[8]; double delx,dely,delz; @@ -258,7 +264,9 @@ extern "C" nuc_eos_findtemp_entropy(lr,lt,ye[i],ent[i],*prec, (double *restrict)(<out),&keyerr[i]); - if(!keyerr[i]) { + if(keyerr[i]) { + *anyerr = 1; + } else { temp[i] = exp(ltout); int idx[8]; double delx,dely,delz; -- cgit v1.2.3