Skip to content

Commit

Permalink
trying this fix a bit differently
Browse files Browse the repository at this point in the history
  • Loading branch information
emorway-usgs committed Aug 26, 2024
1 parent 41a24ba commit fe2913c
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 35 deletions.
3 changes: 3 additions & 0 deletions src/Model/Connection/GweInterfaceModel.f90
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ subroutine gweifmod_df(this)
this%ia => this%dis%con%ia
this%ja => this%dis%con%ja
!
! -- Define shared data (cpw, rhow, latent heat of vaporization)
call this%gwecommon%gweshared_dat_df(this%neq)
!
! -- Allocate model arrays, now that neq and nja are assigned
call this%allocate_arrays()
!
Expand Down
2 changes: 1 addition & 1 deletion src/Model/GroundWaterEnergy/gwe-est.f90
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ subroutine est_ar(this, dis, ibound)
!
! -- set data required by other packages
call this%gwecommon%set_gwe_dat_ptrs(this%rhow, this%cpw, this%latheatvap, &
this%rhos, this%cps)
this%rhos, this%cps, dis%nodes)
!
! -- Return
return
Expand Down
4 changes: 4 additions & 0 deletions src/Model/GroundWaterEnergy/gwe.f90
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ end subroutine gwe_cr
subroutine gwe_df(this)
! -- modules
use SimModule, only: store_error
use GweInputDataModule, only: gweshared_dat_df
! -- dummy
class(GweModelType) :: this
! -- local
Expand Down Expand Up @@ -180,6 +181,9 @@ subroutine gwe_df(this)
this%ia => this%dis%con%ia
this%ja => this%dis%con%ja
!
! -- Define shared data (cpw, rhow, latent heat of vaporization)
call this%gwecommon%gweshared_dat_df(this%neq)
!
! -- Allocate model arrays, now that neq and nja are assigned
call this%allocate_arrays()
!
Expand Down
117 changes: 83 additions & 34 deletions src/Model/ModelUtilities/GweInputData.f90
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module GweInputDataModule
private
public :: GweInputDataType
public :: gweshared_dat_cr
public :: gweshared_dat_df
public :: set_gwe_dat_ptrs

!> Data for sharing among multiple packages. Originally read in from
Expand All @@ -30,11 +31,13 @@ module GweInputDataModule
contains

! public
procedure, public :: gweshared_dat_df
procedure, public :: set_gwe_dat_ptrs
procedure, public :: gweshared_dat_da
! private
procedure, private :: set_gwe_scalar_ptrs
procedure, private :: set_gwe_array_ptrs
procedure, private :: allocate_shared_vars
procedure, private :: set_gwe_shared_scalars
procedure, private :: set_gwe_shared_arrays

end type GweInputDataType

Expand All @@ -43,15 +46,55 @@ module GweInputDataModule
!> @brief Allocate the shared data
!<
subroutine gweshared_dat_cr(gwe_dat)
! modules
! dummy
type(GweInputDataType), pointer :: gwe_dat !< the input data block

! create the object
! Create the object
allocate (gwe_dat)

end subroutine gweshared_dat_cr

!> @brief Define the shared data
!<
subroutine gweshared_dat_df(this, nodes)
! dummy
class(GweInputDataType) :: this !< the input data block
integer(I4B), intent(in) :: nodes

! allocate variables
call this%allocate_shared_vars(nodes)

end subroutine gweshared_dat_df

!> @brief Define the information this object holds
!!
!! Allocate strings for storing label names
!! Intended to be analogous to allocate_scalars()
!<
subroutine allocate_shared_vars(this, nodes)
! dummy
class(GweInputDataType) :: this !< TspLabelsType object
integer(I4B), intent(in) :: nodes
! local
integer(I4B) :: i

allocate (this%gwecpw)
allocate (this%gwerhow)
allocate (this%gwelatheatvap)
allocate (this%gwerhos(nodes))
allocate (this%gwecps(nodes))

! initialize values
this%gwecpw = 4.184e3 !< J/(kg*C) @ 20C
this%gwerhow = DEP3 !< kg/m3 @ 20C
this%gwelatheatvap = 2.4535e6 !< J/kg @ 20C
do i = 1, nodes
this%gwecps(i) = DZERO
this%gwerhos(i) = DZERO
end do

end subroutine allocate_shared_vars

!> @brief Allocate and read data from EST
!!
!! EST data, including heat capacity of water (cpw), density of water
Expand All @@ -61,20 +104,21 @@ end subroutine gweshared_dat_cr
!! separate class
!<
subroutine set_gwe_dat_ptrs(this, gwerhow, gwecpw, gwelatheatvap, &
gwerhos, gwecps)
gwerhos, gwecps, nodes)
! dummy
class(GweInputDataType) :: this !< the input data block
real(DP), intent(in), pointer :: gwerhow !< ptr to density of water specified in EST
real(DP), intent(in), pointer :: gwecpw !< ptr to heat capacity of water specified in EST
real(DP), intent(in), pointer :: gwelatheatvap !< ptr to latent heat of vaporization specified in EST
real(DP), intent(in) :: gwerhow !< ptr to density of water specified in EST
real(DP), intent(in) :: gwecpw !< ptr to heat capacity of water specified in EST
real(DP), intent(in) :: gwelatheatvap !< ptr to latent heat of vaporization specified in EST
real(DP), dimension(:), pointer, contiguous :: gwerhos !< ptr to sptially-variably density of aquifer material specified in EST
real(DP), dimension(:), pointer, contiguous :: gwecps !< ptr to sptially-variably heat capacity of aquifer material specified in EST
integer(I4B), intent(in) :: nodes

! allocate scalars
call this%set_gwe_scalar_ptrs(gwerhow, gwecpw, gwelatheatvap)
call this%set_gwe_shared_scalars(gwerhow, gwecpw, gwelatheatvap)

! allocate arrays
call this%set_gwe_array_ptrs(gwerhos, gwecps)
call this%set_gwe_shared_arrays(gwerhos, gwecps, nodes)

end subroutine set_gwe_dat_ptrs

Expand All @@ -86,60 +130,65 @@ end subroutine set_gwe_dat_ptrs
!! simulating evaporation will need access to latent heat of
!! of vaporization.
!<
subroutine set_gwe_scalar_ptrs(this, gwerhow, gwecpw, gwelatheatvap)
subroutine set_gwe_shared_scalars(this, gwerhow, gwecpw, gwelatheatvap)
! dummy
class(GweInputDataType) :: this !< GweInputDataType object
real(DP), pointer, intent(in) :: gwerhow !< density of water
real(DP), pointer, intent(in) :: gwecpw !< mass-based heat capacity of water
real(DP), pointer, intent(in), optional :: gwelatheatvap !< latent heat of vaporization
real(DP), intent(in) :: gwerhow
real(DP), intent(in) :: gwecpw
real(DP), intent(in), optional :: gwelatheatvap

! set the pointers
! fixed density of water to be used by GWE (vs GWT-based density)
this%gwerhow => gwerhow
! fixed density of water to be used by GWE
this%gwerhow = gwerhow
! spatially constant heat capacity of water ! kluge note: "specific heat" (which is heat capacity per unit mass) is probably the more correct term
this%gwecpw => gwecpw
this%gwecpw = gwecpw
! latent heat of vaporization
if (present(gwelatheatvap)) then
this%gwelatheatvap => gwelatheatvap
this%gwelatheatvap = gwelatheatvap
end if

end subroutine set_gwe_scalar_ptrs
end subroutine set_gwe_shared_scalars

!> @brief Set pointers to data arrays read by the EST package
!! for use by other packages
!!
!! Set pointers to GWE-related arrays for use by multiple packages
!! Set pointers to GWE-related arrays for use
!! by multiple packages.
!<
subroutine set_gwe_array_ptrs(this, gwerhos, gwecps)
subroutine set_gwe_shared_arrays(this, gwerhos, gwecps, nodes)
! dummy
class(GweInputDataType) :: this !< GweInputDataType object
real(DP), dimension(:), pointer, contiguous, intent(in) :: gwerhos
real(DP), dimension(:), pointer, contiguous, intent(in) :: gwecps
integer(I4B), intent(in) :: nodes

! local
integer(I4B) :: i

! set the pointers
! spatially-variable density of aquifer solid material
this%gwerhos => gwerhos
! spatially-variable heat capacity of aquifer solid material
this%gwecps => gwecps
do i = 1, nodes
! spatially-variable density of aquifer solid material
this%gwerhos(i) = gwerhos(i)
! spatially-variable heat capacity of aquifer solid material
this%gwecps(i) = gwecps(i)
end do

end subroutine set_gwe_array_ptrs
end subroutine set_gwe_shared_arrays

!> @ brief Deallocate memory
!!
!! Set pointers to null
!! Deallocate GWE shared data array memory
!<
subroutine gweshared_dat_da(this)
! dummy
class(GweInputDataType) :: this !< the input data block

! scalars
this%gwelatheatvap => null()
this%gwerhow => null()
this%gwecpw => null()
deallocate (this%gwelatheatvap)
deallocate (this%gwerhow)
deallocate (this%gwecpw)

! arrays
this%gwerhos => null()
this%gwecps => null()
deallocate (this%gwerhos)
deallocate (this%gwecps)

end subroutine gweshared_dat_da

Expand Down

0 comments on commit fe2913c

Please sign in to comment.