Skip to content

Commit

Permalink
refactor(exg-gwf*): check for equal idomain
Browse files Browse the repository at this point in the history
Check that models connected to a flow model via an exchange have an identical idomain array to the flow model's.
  • Loading branch information
wpbonelli committed Jan 17, 2025
1 parent a8347e6 commit b8ecd3a
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/Exchange/exg-gwfgwe.f90
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ end subroutine exg_df
subroutine exg_ar(this)
! -- modules
use MemoryManagerModule, only: mem_checkin
use DisModule, only: DisType
use DisvModule, only: DisvType
use DisuModule, only: DisuType
! -- dummy
class(GwfGweExchangeType) :: this
! -- local
Expand All @@ -194,6 +197,11 @@ subroutine exg_ar(this)
& GWF Model has ', i0, ' user nodes and ', i0, ' reduced nodes.&
& GWE Model has ', i0, ' user nodes and ', i0, ' reduced nodes.&
& Ensure discretization packages, including IDOMAIN, are identical.')"
character(len=*), parameter :: fmtidomerr = &
"('GWF and GWE Models do not have the same discretization for exchange&
& ',a,'.&
& GWF Model and GWE Model have different IDOMAIN arrays.&
& Ensure discretization packages, including IDOMAIN, are identical.')"
!
! -- set gwfmodel
mb => GetBaseModelFromList(basemodellist, this%m1_idx)
Expand All @@ -220,6 +228,34 @@ subroutine exg_ar(this)
call store_error(errmsg, terminate=.TRUE.)
end if
!
! -- Make sure idomains are identical
select type (gwfdis => gwfmodel%dis)
type is (DisType)
select type (gwedis => gwemodel%dis)
type is (DisType)
if (.not. all(gwfdis%idomain == gwedis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
type is (DisvType)
select type (gwedis => gwemodel%dis)
type is (DisvType)
if (.not. all(gwfdis%idomain == gwedis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
type is (DisuType)
select type (gwedis => gwemodel%dis)
type is (DisuType)
if (.not. all(gwfdis%idomain == gwedis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
end select
!
! -- setup pointers to gwf variables allocated in gwf_ar
gwemodel%fmi%gwfhead => gwfmodel%x
call mem_checkin(gwemodel%fmi%gwfhead, &
Expand Down
36 changes: 36 additions & 0 deletions src/Exchange/exg-gwfgwt.f90
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ end subroutine exg_df
subroutine exg_ar(this)
! -- modules
use MemoryManagerModule, only: mem_checkin
use DisModule, only: DisType
use DisvModule, only: DisvType
use DisuModule, only: DisuType
! -- dummy
class(GwfGwtExchangeType) :: this
! -- local
Expand All @@ -197,6 +200,11 @@ subroutine exg_ar(this)
& GWF Model has ', i0, ' user nodes and ', i0, ' reduced nodes.&
& GWT Model has ', i0, ' user nodes and ', i0, ' reduced nodes.&
& Ensure discretization packages, including IDOMAIN, are identical.')"
character(len=*), parameter :: fmtidomerr = &
"('GWF and GWT Models do not have the same discretization for exchange&
& ',a,'.&
& GWF Model and GWT Model have different IDOMAIN arrays.&
& Ensure discretization packages, including IDOMAIN, are identical.')"
!
! -- set gwfmodel
mb => GetBaseModelFromList(basemodellist, this%m1_idx)
Expand All @@ -223,6 +231,34 @@ subroutine exg_ar(this)
call store_error(errmsg, terminate=.TRUE.)
end if
!
! -- Make sure idomains are identical
select type (gwfdis => gwfmodel%dis)
type is (DisType)
select type (gwtdis => gwtmodel%dis)
type is (DisType)
if (.not. all(gwfdis%idomain == gwtdis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
type is (DisvType)
select type (gwtdis => gwtmodel%dis)
type is (DisvType)
if (.not. all(gwfdis%idomain == gwtdis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
type is (DisuType)
select type (gwtdis => gwtmodel%dis)
type is (DisuType)
if (.not. all(gwfdis%idomain == gwtdis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
end select
!
! -- setup pointers to gwf variables allocated in gwf_ar
gwtmodel%fmi%gwfhead => gwfmodel%x
call mem_checkin(gwtmodel%fmi%gwfhead, &
Expand Down
36 changes: 36 additions & 0 deletions src/Exchange/exg-gwfprt.f90
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ end subroutine exg_df
subroutine exg_ar(this)
! -- modules
use MemoryManagerModule, only: mem_checkin
use DisModule, only: DisType
use DisvModule, only: DisvType
use DisuModule, only: DisuType
! -- dummy
class(GwfPrtExchangeType) :: this
! -- local
Expand All @@ -190,6 +193,11 @@ subroutine exg_ar(this)
& GWF Model has ', i0, ' user nodes and ', i0, ' reduced nodes.&
& PRT Model has ', i0, ' user nodes and ', i0, ' reduced nodes.&
& Ensure discretization packages, including IDOMAIN, are identical.')"
character(len=*), parameter :: fmtidomerr = &
"('GWF and PRT Models do not have the same discretization for exchange&
& ',a,'.&
& GWF Model and PRT Model have different IDOMAIN arrays.&
& Ensure discretization packages, including IDOMAIN, are identical.')"
!
! -- set gwfmodel
mb => GetBaseModelFromList(basemodellist, this%m1id)
Expand All @@ -216,6 +224,34 @@ subroutine exg_ar(this)
call store_error(errmsg, terminate=.TRUE.)
end if
!
! -- Make sure idomains are identical
select type (gwfdis => gwfmodel%dis)
type is (DisType)
select type (prtdis => prtmodel%dis)
type is (DisType)
if (.not. all(gwfdis%idomain == prtdis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
type is (DisvType)
select type (prtdis => prtmodel%dis)
type is (DisvType)
if (.not. all(gwfdis%idomain == prtdis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
type is (DisuType)
select type (prtdis => prtmodel%dis)
type is (DisuType)
if (.not. all(gwfdis%idomain == prtdis%idomain)) then
write (errmsg, fmtidomerr) trim(this%name)
call store_error(errmsg, terminate=.TRUE.)
end if
end select
end select
!
! -- setup pointers to gwf variables allocated in gwf_ar
prtmodel%fmi%gwfhead => gwfmodel%x
call mem_checkin(prtmodel%fmi%gwfhead, &
Expand Down
2 changes: 1 addition & 1 deletion src/Model/ModelUtilities/FlowModelInterface.f90
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module FlowModelInterfaceModule
logical, pointer :: flows_from_file => null() !< if .false., then flows come from GWF through GWF-Model exg
type(ListType), pointer :: gwfbndlist => null() !< list of gwf stress packages
integer(I4B), pointer :: iflowsupdated => null() !< flows were updated for this time step
integer(I4B), dimension(:), pointer, contiguous :: ibound => null() !< pointer to Model ibound
integer(I4B), dimension(:), pointer, contiguous :: ibound => null() !< pointer to model ibound
real(DP), dimension(:), pointer, contiguous :: gwfflowja => null() !< pointer to the GWF flowja array
real(DP), dimension(:, :), pointer, contiguous :: gwfspdis => null() !< pointer to npf specific discharge array
real(DP), dimension(:), pointer, contiguous :: gwfhead => null() !< pointer to the GWF head array
Expand Down

0 comments on commit b8ecd3a

Please sign in to comment.