diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bba35e26b..f57aad0db4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - [[PR228]](https://github.com/lanl/singularity-eos/pull/228) added untracked header files in cmake - [[PR215]](https://github.com/lanl/singularity-eos/pull/215) and [[PR216]](https://github.com/lanl/singularity-eos/pull/216) fix duplicate definition of EPS and fix CI - [[PR232]](https://github.com/lanl/singularity-eos/pull/228) Fixed uninitialized cmake path variables +- [[PR308]](https://github.com/lanl/singularity-eos/pull/308) spack builds +fortran now compile via correct blocking out of interfaces via preprocessor ifdef ### Added (new features/APIs/variables/...) - [[PR306]](https://github.com/lanl/singularity-eos/pull/306) Added generic Evaluate method @@ -48,10 +49,12 @@ - [[PR234]](https://github.com/lanl/singularity-eos/pull/234) update ports-of-call to correct for undefined behavior in error handling - [[PR219]](https://github.com/lanl/singularity-eos/pull/219) Removed static analysis from re-git pipeline - [[PR233]](https://github.com/lanl/singularity-eos/pull/233) Exposed entropy for the EOS type (now required for future EOS) +- [[PR308]](https://github.com/lanl/singularity-eos/pull/308) Fortran initialization interface functions no longer require modifier arrays, they are optional parameters. ### Infrastructure (changes irrelevant to downstream codes) - [[PR190]](https://github.com/lanl/singularity-eos/pull/190) update CI on re-git - [[PR245]](https://github.com/lanl/singularity-eos/pull/245) Separating get_sg_eos to other files. Build/compilation improvements, warning fixes/suppression. +- [[PR308]](https://github.com/lanl/singularity-eos/pull/308) Added a fortran test. ### Removed (removing behavior/API/varaibles/...) - [[PR293]](https://github.com/lanl/singularity-eos/pull/293) Removing PTofRE function. This will no longer be callable downstream. diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fe1c76dc5..fd0e8b1d2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -393,6 +393,7 @@ if(SINGULARITY_USE_FORTRAN) target_include_directories( singularity-eos INTERFACE $ $) + set_target_properties(singularity-eos PROPERTIES Fortran_PREPROCESS ON) endif() # SINGULARITY_USE_FORTRAN target_include_directories( diff --git a/singularity-eos/eos/modifiers/ramps_eos.hpp b/singularity-eos/eos/modifiers/ramps_eos.hpp index a0111b8ea5..935c32a6df 100644 --- a/singularity-eos/eos/modifiers/ramps_eos.hpp +++ b/singularity-eos/eos/modifiers/ramps_eos.hpp @@ -75,6 +75,9 @@ void pAlpha2BilinearRampParams(const T &eos, const Real alpha0, const Real Pe, template class BilinearRampEOS : public EosBase> { public: + // Vector functions that overload the scalar versions declared here. + SG_ADD_BASE_CLASS_USINGS(BilinearRampEOS) + // move semantics ensures dynamic memory comes along for the ride BilinearRampEOS(T &&t, const Real r0, const Real a, const Real b, const Real c) : t_(std::forward(t)), r0_(r0), a_(a), b_(b), c_(c), @@ -425,9 +428,6 @@ class BilinearRampEOS : public EosBase> { t_.ValuesAtReferenceState(rho, temp, sie, press, cv, bmod, dpde, dvdt, lambda); } - // Vector functions that overload the scalar versions declared here. - SG_ADD_BASE_CLASS_USINGS(BilinearRampEOS) - inline constexpr bool IsModified() const { return true; } inline constexpr T UnmodifyOnce() { return t_; } diff --git a/singularity-eos/eos/singularity_eos.f90 b/singularity-eos/eos/singularity_eos.f90 index 7f908f8880..d04b98d68f 100644 --- a/singularity-eos/eos/singularity_eos.f90 +++ b/singularity-eos/eos/singularity_eos.f90 @@ -40,10 +40,19 @@ module singularity_eos init_sg_NobleAbel_f,& init_sg_SAP_Polynomial_f,& init_sg_StiffGas_f,& +#ifdef SINGULARITY_USE_SPINER_WITH_HDF5 +#ifdef SINGULARITY_USE_HELMHOLTZ init_sg_Helmholtz_f,& +#endif +! SINGULARITY_USE_HELMHOLTZ init_sg_SpinerDependsRhoT_f,& init_sg_SpinerDependsRhoSie_f,& +#endif +! SINGULARITY_USE_SPINER_WITH_HDF5 +#ifdef SINGULARITY_USE_EOSPAC init_sg_eospac_f,& +#endif +! SINGULARITY_USE_EOSPAC get_sg_eos_f,& finalize_sg_eos_f @@ -164,7 +173,8 @@ end function init_sg_StiffGas type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values end function init_sg_SAP_Polynomial end interface - +#ifdef SINGULARITY_USE_SPINER_WITH_HDF5 +#ifdef SINGULARITY_USE_HELMHOLTZ interface integer(kind=c_int) function & init_sg_Helmholtz(matindex, eos, filename, rad, gas, coul, ion, ele, & @@ -179,7 +189,8 @@ end function init_sg_SAP_Polynomial type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values end function init_sg_Helmholtz end interface - +#endif +! SINGULARITY_USE_HELMHOLTZ interface integer(kind=c_int) function & init_sg_SpinerDependsRhoT(matindex, eos, filename, id, sg_mods_enabled, & @@ -205,7 +216,9 @@ end function init_sg_SpinerDependsRhoT type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values end function init_sg_SpinerDependsRhoSie end interface - +#endif +! SINGULARITY_USE_SPINER_WITH_HDF5 +#ifdef SINGULARITY_USE_EOSPAC interface integer(kind=c_int) function & init_sg_eospac(matindex, eos, id, sg_mods_enabled, sg_mods_values) & @@ -216,7 +229,8 @@ end function init_sg_SpinerDependsRhoSie type(c_ptr), value, intent(in) :: sg_mods_enabled, sg_mods_values end function init_sg_eospac end interface - +#endif +! SINGULARITY_USE_EOSPAC interface integer(kind=c_int) function & get_sg_eos(nmat, ncell, cell_dim,& @@ -341,10 +355,19 @@ integer function init_sg_IdealGas_f(matindex, eos, gm1, Cv, & integer(c_int), value, intent(in) :: matindex type(sg_eos_ary_t), intent(in) :: eos real(kind=8), value, intent(in) :: gm1, Cv - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_IdealGas(matindex-1, eos%ptr, gm1, Cv, & - c_loc(sg_mods_enabled), c_loc(sg_mods_values)) + c_loc(sg_mods_enabled_use), c_loc(sg_mods_values_use)) end function init_sg_IdealGas_f integer function init_sg_Gruneisen_f(matindex, eos, C0, s1, s2, s3, G0, b,& @@ -355,11 +378,20 @@ integer function init_sg_Gruneisen_f(matindex, eos, C0, s1, s2, s3, G0, b,& type(sg_eos_ary_t), intent(in) :: eos real(kind=8), value, intent(in) :: C0, s1, s2, s3, G0, b, rho0 real(kind=8), value, intent(in) :: T0, P0, Cv - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_Gruneisen(matindex-1, eos%ptr, C0, s1, s2, s3, G0, b, rho0,& - T0, P0, Cv, c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) + T0, P0, Cv, c_loc(sg_mods_enabled_use), & + c_loc(sg_mods_values_use)) end function init_sg_Gruneisen_f integer function init_sg_JWL_f(matindex, eos, A, B, R1, R2, w, rho0, Cv, & @@ -368,10 +400,19 @@ integer function init_sg_JWL_f(matindex, eos, A, B, R1, R2, w, rho0, Cv, & integer(c_int), value, intent(in) :: matindex type(sg_eos_ary_t), intent(in) :: eos real(kind=8), value, intent(in) :: A, B, R1, R2, w, rho0, Cv - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_JWL(matindex-1, eos%ptr, A, B, R1, R2, w, rho0, Cv, & - c_loc(sg_mods_enabled), c_loc(sg_mods_values)) + c_loc(sg_mods_enabled_use), c_loc(sg_mods_values_use)) end function init_sg_JWL_f integer function init_sg_DavisProducts_f(matindex, eos, a, b, k, n, vc, pc, & @@ -381,11 +422,20 @@ integer function init_sg_DavisProducts_f(matindex, eos, a, b, k, n, vc, pc, & integer(c_int), value, intent(in) :: matindex type(sg_eos_ary_t), intent(in) :: eos real(kind=8), value, intent(in) :: a, b, k, n, vc, pc, Cv, E0 - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_DavisProducts(matindex-1, eos%ptr, a, b, k, n, vc, pc, Cv, & - E0, c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) + E0, c_loc(sg_mods_enabled_use), & + c_loc(sg_mods_values_use)) end function init_sg_DavisProducts_f integer function init_sg_DavisReactants_f(matindex, eos, rho0, e0, P0, T0, & @@ -396,11 +446,20 @@ integer function init_sg_DavisReactants_f(matindex, eos, rho0, e0, P0, T0, & type(sg_eos_ary_t), intent(in) :: eos real(kind=8), value, intent(in) :: rho0, e0, P0, T0, A, B, C, G0, Z real(kind=8), value, intent(in) :: alpha, Cv0 - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_DavisReactants(matindex-1, eos%ptr, rho0, e0, P0, T0, A, B, & - C, G0, Z, alpha, Cv0, c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) + C, G0, Z, alpha, Cv0, c_loc(sg_mods_enabled_use), & + c_loc(sg_mods_values_use)) end function init_sg_DavisReactants_f integer function init_sg_SAP_Polynomial_f(matindex, eos, rho0, a0, a1, a2c, & @@ -411,11 +470,20 @@ integer function init_sg_SAP_Polynomial_f(matindex, eos, rho0, a0, a1, a2c, & type(sg_eos_ary_t), intent(in) :: eos real(kind=8), value, intent(in) :: rho0, a0, a1, a2c, a2e, a3,& b0, b1, b2c, b2e, b3 - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_SAP_Polynomial(matindex-1, eos%ptr, rho0, a0, a1, a2c, a2e, & a3, b0, b1, b2c, b2e, b3, & - c_loc(sg_mods_enabled), c_loc(sg_mods_values)) + c_loc(sg_mods_enabled_use), c_loc(sg_mods_values_use)) end function init_sg_SAP_Polynomial_f integer function init_sg_StiffGas_f(matindex, eos, gm1, Cv, & @@ -425,10 +493,19 @@ integer function init_sg_StiffGas_f(matindex, eos, gm1, Cv, & integer(c_int), value, intent(in) :: matindex type(sg_eos_ary_t), intent(in) :: eos real(kind=8), value, intent(in) :: gm1, Cv, Pinf, qq - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_StiffGas(matindex-1, eos%ptr, gm1, Cv, Pinf, qq, & - c_loc(sg_mods_enabled), c_loc(sg_mods_values)) + c_loc(sg_mods_enabled_use), c_loc(sg_mods_values_use)) end function init_sg_StiffGas_f integer function init_sg_NobleAbel_f(matindex, eos, gm1, Cv, & @@ -438,12 +515,22 @@ integer function init_sg_NobleAbel_f(matindex, eos, gm1, Cv, & integer(c_int), value, intent(in) :: matindex type(sg_eos_ary_t), intent(in) :: eos real(kind=8), value, intent(in) :: gm1, Cv, bb, qq - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_NobleAbel(matindex-1, eos%ptr, gm1, Cv, bb, qq, & - c_loc(sg_mods_enabled), c_loc(sg_mods_values)) + c_loc(sg_mods_enabled_use), c_loc(sg_mods_values_use)) end function init_sg_NobleAbel_f - +#ifdef SINGULARITY_USE_SPINER_WITH_HDF5 +#ifdef SINGULARITY_USE_HELMHOLTZ integer function init_sg_Helmholtz_f(matindex, eos, filename, rad, gas, coul, ion, ele, & verbose, sg_mods_enabled, sg_mods_values) & result(err) @@ -452,13 +539,22 @@ integer function init_sg_Helmholtz_f(matindex, eos, filename, rad, gas, coul, io character(len=*, kind=c_char), intent(in) :: filename logical(c_bool), value, intent(in) :: rad, gas, coul, ion, ele, & verbose - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_Helmholtz(matindex-1, eos%ptr, trim(filename)//C_NULL_CHAR, & rad, gas, coul, ion, ele, verbose, & - c_loc(sg_mods_enabled), c_loc(sg_mods_values)) + c_loc(sg_mods_enabled_use), c_loc(sg_mods_values_use)) end function init_sg_Helmholtz_f - +#endif ! SINGULARITY_USE_HELMHOLTZ integer function init_sg_SpinerDependsRhoT_f(matindex, eos, filename, id, & sg_mods_enabled, & sg_mods_values) & @@ -467,12 +563,21 @@ integer function init_sg_SpinerDependsRhoT_f(matindex, eos, filename, id, & type(sg_eos_ary_t), intent(in) :: eos character(len=*, kind=c_char), intent(in) :: filename integer(c_int), intent(inout) :: id - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_SpinerDependsRhoT(matindex-1, eos%ptr,& trim(filename)//C_NULL_CHAR, id, & - c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) + c_loc(sg_mods_enabled_use), & + c_loc(sg_mods_values_use)) end function init_sg_SpinerDependsRhoT_f integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, & @@ -482,25 +587,44 @@ integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, & integer(c_int), value, intent(in) :: matindex, id type(sg_eos_ary_t), intent(in) :: eos character(len=*, kind=c_char), intent(in) :: filename - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + err = init_sg_SpinerDependsRhoSie(matindex-1, eos%ptr,& trim(filename)//C_NULL_CHAR, id, & - c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) + c_loc(sg_mods_enabled_use), & + c_loc(sg_mods_values_use)) end function init_sg_SpinerDependsRhoSie_f - +#endif ! SINGULARITY_USE_SPINER_WITH_HDF5 +#ifdef SINGULARITY_USE_EOSPAC integer function init_sg_eospac_f(matindex, eos, id, sg_mods_enabled, & sg_mods_values) & result(err) integer(c_int), value, intent(in) :: matindex, id type(sg_eos_ary_t), intent(in) :: eos - integer(kind=c_int), dimension(:), target, intent(inout) :: sg_mods_enabled - real(kind=8), dimension(:), target, intent(inout) :: sg_mods_values - err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(sg_mods_enabled), & - c_loc(sg_mods_values)) + integer(kind=c_int), dimension(:), target, optional, intent(inout) :: sg_mods_enabled + real(kind=8), dimension(:), target, optional, intent(inout) :: sg_mods_values + ! local vars + integer(kind=c_int), target, dimension(4) :: sg_mods_enabled_use + real(kind=8), target, dimension(6) :: sg_mods_values_use + + sg_mods_enabled_use = 0 + sg_mods_values_use = 0.d0 + if(present(sg_mods_enabled)) sg_mods_enabled_use = sg_mods_enabled + if(present(sg_mods_values)) sg_mods_values_use = sg_mods_values + + err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(sg_mods_enabled_use), & + c_loc(sg_mods_values_use)) end function init_sg_eospac_f - +#endif ! SINGULARITY_USE_EOSPAC integer function finalize_sg_eos_f(nmat, eos) & result(err) integer(c_int), value, intent(in) :: nmat diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d30b5b0b8e..80b1097329 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -131,6 +131,13 @@ if(SINGULARITY_USE_SPINER) target_link_libraries(profile_eos singularity-eos::singularity-eos) endif() +if(SINGULARITY_USE_FORTRAN) + add_executable(ftn_interface test_f_iface.f90) + target_link_libraries(ftn_interface singularity-eos::singularity-eos) + set_target_properties(ftn_interface PROPERTIES LINKER_LANGUAGE Fortran) + add_test(test_fortran_interface ftn_interface) +endif() + if(SINGULARITY_USE_EOSPAC AND SINGULARITY_TEST_SESAME AND NOT SINGULARITY_USE_CUDA) diff --git a/test/eos_unit_test_helpers.hpp b/test/eos_unit_test_helpers.hpp index a5616f83eb..b23f5cf93e 100644 --- a/test/eos_unit_test_helpers.hpp +++ b/test/eos_unit_test_helpers.hpp @@ -23,6 +23,10 @@ #include #include +#include +#include +#include + // typename demangler #ifdef __GNUG__ #include @@ -64,9 +68,15 @@ PORTABLE_INLINE_FUNCTION Real myAtan(Real x, Real shift, Real scale, Real offset template inline void array_compare(int num, X &&x, Y &&y, Z &&z, ZT &&ztrue, XN xname, YN yname, Real tol = 1e-12) { + assert(num > 0); + using underlying_t = + typename std::remove_cv::type>::type; for (int i = 0; i < num; i++) { - INFO("i: " << i << ", " << xname << ": " << x[i] << ", " << yname << ": " << y[i] - << ", Value: " << z[i] << ", True Value: " << ztrue[i]); + auto s = std::ostringstream{}; + s << std::setprecision(std::numeric_limits::max_digits10) + << std::scientific << "i: " << i << ", " << xname << ": " << x[i] << ", " << yname + << ": " << y[i] << ", Value: " << z[i] << ", True Value: " << ztrue[i]; + INFO(s.str()); CHECK(isClose(z[i], ztrue[i], 1e-12)); } } diff --git a/test/test_eos_gruneisen.cpp b/test/test_eos_gruneisen.cpp index fcefd1fe3a..e0c0b9bbfc 100644 --- a/test/test_eos_gruneisen.cpp +++ b/test/test_eos_gruneisen.cpp @@ -479,7 +479,7 @@ SCENARIO("Gruneisen EOS density limit") { INFO("FillEos bmod: " << bmod << ", Lookup bmod: " << bmod_true); CHECK(bmod == bmod_true); INFO("FillEos pressure: " << P << ", Lookup pressure: " << pres_true); - CHECK(P == pres_true); + CHECK(isClose(P, pres_true, 1.e-14)); } } } diff --git a/test/test_eos_stellar_collapse.cpp b/test/test_eos_stellar_collapse.cpp index 859031d5b5..66366fe186 100644 --- a/test/test_eos_stellar_collapse.cpp +++ b/test/test_eos_stellar_collapse.cpp @@ -44,7 +44,7 @@ SCENARIO("Test 3D reinterpolation to fast log grid", "[StellarCollapse]") { constexpr int N2 = 100; constexpr int N1 = 101; constexpr int N0 = 102; - StellarCollapse::Grid_t g2(0, 1, N2); + StellarCollapse::Grid_t g2(1.0 / N2, 1, N2); StellarCollapse::Grid_t g1(1, 3, N1); StellarCollapse::Grid_t g0(2, 4, N0); StellarCollapse::DataBox db(N2, N1, N0); diff --git a/test/test_eos_stiff.cpp b/test/test_eos_stiff.cpp index 6871f0d406..0ab248a236 100644 --- a/test/test_eos_stiff.cpp +++ b/test/test_eos_stiff.cpp @@ -79,14 +79,14 @@ SCENARIO("StiffGas1", "[StiffGas][StiffGas1]") { // Gold standard values for a subset of lookups constexpr std::array pressure_true{ - 1.0132500000019073e+06, 3.4450500000000000e+07, 6.7887750000001907e+07, - 1.0132500000000000e+08}; + 1.01324999999964016e+06, 3.44504999999983162e+07, 6.78877500000010729e+07, + 1.01324999999999583e+08}; constexpr std::array bulkmodulus_true{ - 2.3502381137500000e+10, 2.3580958675000000e+10, 2.3659536212500004e+10, - 2.3738113750000004e+10}; + 2.35023811375000000e+10, 2.35809586749999962e+10, 2.36595362125000038e+10, + 2.37381137500000000e+10}; constexpr std::array temperature_true{ - 2.9814999999999998e+02, 1.5320999999999999e+03, 2.7660500000000002e+03, - 4.0000000000000000e+03}; + 2.98149999999999920e+02, 1.53209999999999968e+03, 2.76605000000000064e+03, + 3.99999999999999955e+03}; constexpr std::array gruneisen_true{1.35, 1.35, 1.35, 1.35}; #ifdef PORTABILITY_STRATEGY_KOKKOS diff --git a/test/test_f_iface.f90 b/test/test_f_iface.f90 index 61ca03a6a8..b69bd7d33f 100644 --- a/test/test_f_iface.f90 +++ b/test/test_f_iface.f90 @@ -12,81 +12,30 @@ ! publicly and display publicly, and to permit others to do so. !------------------------------------------------------------------------------ -program test -use bedroom_door_eos -integer :: res, nmat, ncell, i, j, matid -type(bd_eos_ary_t) :: eos -integer, allocatable, dimension(:) :: offsets -real(kind=8), allocatable, dimension(:) :: spvol, sie_tot, vsum, press, pmax -real(kind=8), allocatable, dimension(:) :: temp, bmod, dpde, cv -real(kind=8), allocatable, dimension(:,:) :: frac_mass, frac_vol, frac_sie -real(kind=8) :: vsumint -character(len=64) :: filename +program test_sg_fortran_interface +! modules +use singularity_eos_types +use singularity_eos +! no implicit vars +implicit none +! variable declaration +integer :: nmat, res +type(sg_eos_ary_t) :: eos -ncell = 1 +! set test parameters nmat = 3 -filename = "../data/materials.sp5" -! allocate arrays -allocate(spvol(ncell), sie_tot(ncell), temp(ncell), press(ncell), vsum(ncell)) -allocate(bmod(ncell), dpde(ncell), cv(ncell), pmax(ncell)) -allocate(offsets(ncell)) -allocate(frac_mass(ncell, nmat)) -allocate(frac_vol(ncell, nmat), frac_sie(ncell, nmat)) -! initialize eos's -res = init_bd_eos_f(nmat, eos) +! allocate and initialize eos's +res = init_sg_eos_f(nmat, eos) -res = init_Gruneisen_f(1, eos, 394000.d0, 1.489d0, 0.d0, 0.d0, 2.02d0, 0.47d0,& +res = init_sg_Gruneisen_f(1, eos, 394000.d0, 1.489d0, 0.d0, 0.d0, 2.02d0, 0.47d0,& 8.93d0, 297.0d0, 1.0d6, 0.383d7) -res = init_DavisReactants_f(2, eos, 1.890d0, 4.115d10, 1.0d6, 297.0d0, 1.8d0,& +res = init_sg_DavisReactants_f(2, eos, 1.890d0, 4.115d10, 1.0d6, 297.0d0, 1.8d0,& 4.6d0, 0.34d0, 0.56d0,0.d0, 0.4265d0, 0.001074d10) -res = init_DavisProducts_f(3, eos, 0.798311d0, 0.58d0, 1.35d0, 2.66182d0,& +res = init_sg_DavisProducts_f(3, eos, 0.798311d0, 0.58d0, 1.35d0, 2.66182d0,& 0.75419d0, 3.2d10, 0.001072d10, 0.d0) -!matid = 4272 -!res = init_SpinerDependsRhoT_f(2, eos, filename, matid) -!matid = 5030 -!res = init_SpinerDependsRhoT_f(3, eos, filename, matid) -! initialize state variables -call srand(10) -press = 0.d0 -do i=1,ncell - vsum(i) = 1.0d-2 - frac_mass(i,1) = 8.93d0*vsum(i)*0.33 - frac_mass(i,2) = 1.89d0*vsum(i)*.033 - frac_mass(i,3) = 2.5d0*vsum(i)*0.34 - sie_tot(i) = 0.d0 - spvol(i) = 0.d0 - !vsum(i) = 0.d0 - offsets(i) = i - frac_sie(i,1) = 1.16049000000000000d+09 - frac_sie(i,2) = 4.50111706015744858d+10 - frac_sie(i,3) = 3.29477034927098885d+10 - temp(i) = 0.d0 - ! frac_vols will be normalized in eos call - do j=1,nmat - frac_vol(i,j) = 0.d0 - enddo - do j=1,nmat - spvol(i) = spvol(i) + frac_mass(i,j) - sie_tot(i) = sie_tot(i) + frac_mass(i,j)*frac_sie(i,j) - frac_sie(i,j) = frac_sie(i,j)*frac_mass(i,j) ! needs to be energy - enddo - sie_tot(i) = sie_tot(i)/spvol(i) - spvol(i) = vsum(i)/spvol(i) -enddo -!write(*,*) 'spvol', spvol -write(*,*) frac_mass, frac_vol, frac_sie -! calculate PTE eos -res = get_bd_eos_f(nmat, ncell, ncell, 0, eos, offsets, press, pmax, vsum,& - spvol, sie_tot, temp, bmod, dpde, cv, frac_mass, frac_vol,& - frac_sie) - -write(*,*) press, cv, bmod, temp -write(*,*) frac_mass, frac_vol, frac_sie ! cleanup -res = finalize_bd_eos_f(nmat, eos) +res = finalize_sg_eos_f(nmat, eos) -deallocate(vsum, sie_tot, spvol, frac_mass, temp, press, frac_vol, frac_sie) -deallocate(bmod, dpde, cv, offsets, pmax) -end program test +end program test_sg_fortran_interface