Skip to content

Commit

Permalink
Enable fortran preprocessor for fortran interface and then add same l…
Browse files Browse the repository at this point in the history
…ogic in fortran interface as is in the c/c++ interface.
  • Loading branch information
dholladay00 committed Oct 12, 2023
1 parent 790cba7 commit ade7a10
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions singularity-eos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ endif()

if (SINGULARITY_USE_FORTRAN)
list(APPEND EOS_SRCS eos/singularity_eos.f90)
set_source_files_properties(eos/singularity_eos.f90
PROPERTIES Fortran_PREPROCESS ON)
list(APPEND EOS_SRCS eos/singularity_eos.cpp)
list(APPEND EOS_HEADERS eos/singularity_eos.hpp)
# would rather handle this more robustly, being sloppy for now
Expand Down
26 changes: 18 additions & 8 deletions singularity-eos/eos/singularity_eos.f90
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ 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

Expand Down Expand Up @@ -164,7 +170,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, &
Expand All @@ -179,7 +186,7 @@ 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, &
Expand All @@ -205,7 +212,8 @@ 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) &
Expand All @@ -216,7 +224,7 @@ 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,&
Expand Down Expand Up @@ -443,7 +451,8 @@ integer function init_sg_NobleAbel_f(matindex, eos, gm1, Cv, &
err = init_sg_NobleAbel(matindex-1, eos%ptr, gm1, Cv, bb, qq, &
c_loc(sg_mods_enabled), c_loc(sg_mods_values))
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)
Expand All @@ -458,7 +467,7 @@ integer function init_sg_Helmholtz_f(matindex, eos, filename, rad, gas, coul, io
rad, gas, coul, ion, ele, verbose, &
c_loc(sg_mods_enabled), c_loc(sg_mods_values))
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) &
Expand Down Expand Up @@ -489,7 +498,8 @@ integer function init_sg_SpinerDependsRhoSie_f(matindex, eos, filename, id, &
c_loc(sg_mods_enabled), &
c_loc(sg_mods_values))
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)
Expand All @@ -500,7 +510,7 @@ integer function init_sg_eospac_f(matindex, eos, id, sg_mods_enabled, &
err = init_sg_eospac(matindex-1, eos%ptr, id, c_loc(sg_mods_enabled), &
c_loc(sg_mods_values))
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
Expand Down

0 comments on commit ade7a10

Please sign in to comment.