Skip to content

Commit

Permalink
refactor(input-data-model): rework found construct for readability an…
Browse files Browse the repository at this point in the history
…d maintainability (#1072)

Co-authored-by: mjreno <[email protected]>
  • Loading branch information
mjreno and mjreno authored Nov 1, 2022
1 parent 682972b commit 41e9c34
Show file tree
Hide file tree
Showing 13 changed files with 471 additions and 294 deletions.
44 changes: 22 additions & 22 deletions make/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@ include ./makedefaults
# Define the source file directories
SOURCEDIR1=../src
SOURCEDIR2=../src/Exchange
SOURCEDIR3=../src/Solution
SOURCEDIR4=../src/Solution/LinearMethods
SOURCEDIR5=../src/Timing
SOURCEDIR6=../src/Utilities
SOURCEDIR7=../src/Utilities/Idm
SOURCEDIR8=../src/Utilities/TimeSeries
SOURCEDIR9=../src/Utilities/Memory
SOURCEDIR10=../src/Utilities/OutputControl
SOURCEDIR11=../src/Utilities/ArrayRead
SOURCEDIR12=../src/Utilities/Libraries
SOURCEDIR13=../src/Utilities/Libraries/rcm
SOURCEDIR14=../src/Utilities/Libraries/blas
SOURCEDIR15=../src/Utilities/Libraries/sparskit2
SOURCEDIR16=../src/Utilities/Libraries/daglib
SOURCEDIR17=../src/Utilities/Libraries/sparsekit
SOURCEDIR18=../src/Utilities/Observation
SOURCEDIR19=../src/Model
SOURCEDIR20=../src/Model/Connection
SOURCEDIR21=../src/Model/GroundWaterTransport
SOURCEDIR22=../src/Model/ModelUtilities
SOURCEDIR23=../src/Model/GroundWaterFlow
SOURCEDIR24=../src/Model/Geometry
SOURCEDIR3=../src/Model
SOURCEDIR4=../src/Model/Connection
SOURCEDIR5=../src/Model/Geometry
SOURCEDIR6=../src/Model/GroundWaterFlow
SOURCEDIR7=../src/Model/GroundWaterTransport
SOURCEDIR8=../src/Model/ModelUtilities
SOURCEDIR9=../src/Solution
SOURCEDIR10=../src/Solution/LinearMethods
SOURCEDIR11=../src/Timing
SOURCEDIR12=../src/Utilities
SOURCEDIR13=../src/Utilities/ArrayRead
SOURCEDIR14=../src/Utilities/Idm
SOURCEDIR15=../src/Utilities/Libraries
SOURCEDIR16=../src/Utilities/Libraries/blas
SOURCEDIR17=../src/Utilities/Libraries/daglib
SOURCEDIR18=../src/Utilities/Libraries/rcm
SOURCEDIR19=../src/Utilities/Libraries/sparsekit
SOURCEDIR20=../src/Utilities/Libraries/sparskit2
SOURCEDIR21=../src/Utilities/Memory
SOURCEDIR22=../src/Utilities/Observation
SOURCEDIR23=../src/Utilities/OutputControl
SOURCEDIR24=../src/Utilities/TimeSeries

VPATH = \
${SOURCEDIR1} \
Expand Down
82 changes: 44 additions & 38 deletions src/Model/GroundWaterFlow/gwf3dis8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -200,28 +200,29 @@ subroutine source_options(this)
use MemoryTypeModule, only: MemoryType
use MemoryManagerExtModule, only: mem_set_value
use SimVariablesModule, only: idm_context
use GwfDisInputModule, only: GwfDisParamFoundType
! -- dummy
class(GwfDisType) :: this
! -- locals
character(len=LENMEMPATH) :: idmMemoryPath
character(len=LENVARNAME), dimension(3) :: lenunits = &
&[character(len=LENVARNAME) :: 'FEET', 'METERS', 'CENTIMETERS']
logical, dimension(5) :: afound
type(GwfDisParamFoundType) :: found
!
! -- set memory path
idmMemoryPath = create_mem_path(this%name_model, 'DIS', idm_context)
!
! -- update defaults with idm sourced values
call mem_set_value(this%lenuni, 'LENGTH_UNITS', idmMemoryPath, lenunits, &
afound(1))
call mem_set_value(this%nogrb, 'NOGRB', idmMemoryPath, afound(2))
call mem_set_value(this%xorigin, 'XORIGIN', idmMemoryPath, afound(3))
call mem_set_value(this%yorigin, 'YORIGIN', idmMemoryPath, afound(4))
call mem_set_value(this%angrot, 'ANGROT', idmMemoryPath, afound(5))
found%length_units)
call mem_set_value(this%nogrb, 'NOGRB', idmMemoryPath, found%nogrb)
call mem_set_value(this%xorigin, 'XORIGIN', idmMemoryPath, found%xorigin)
call mem_set_value(this%yorigin, 'YORIGIN', idmMemoryPath, found%yorigin)
call mem_set_value(this%angrot, 'ANGROT', idmMemoryPath, found%angrot)
!
! -- log values to list file
if (this%iout > 0) then
call this%log_options(afound)
call this%log_options(found)
end if
!
! -- Return
Expand All @@ -230,31 +231,32 @@ end subroutine source_options

!> @brief Write user options to list file
!<
subroutine log_options(this, afound)
subroutine log_options(this, found)
use GwfDisInputModule, only: GwfDisParamFoundType
class(GwfDisType) :: this
logical, dimension(:), intent(in) :: afound
type(GwfDisParamFoundType), intent(in) :: found

write (this%iout, '(1x,a)') 'Setting Discretization Options'

if (afound(1)) then
if (found%length_units) then
write (this%iout, '(4x,a,i0)') 'MODEL LENGTH UNIT [0=UND, 1=FEET, &
&2=METERS, 3=CENTIMETERS] SET AS ', this%lenuni
end if

if (afound(2)) then
if (found%nogrb) then
write (this%iout, '(4x,a,i0)') 'BINARY GRB FILE [0=GRB, 1=NOGRB] &
&SET AS ', this%nogrb
end if

if (afound(3)) then
if (found%xorigin) then
write (this%iout, '(4x,a,G0)') 'XORIGIN = ', this%xorigin
end if

if (afound(4)) then
if (found%yorigin) then
write (this%iout, '(4x,a,G0)') 'YORIGIN = ', this%yorigin
end if

if (afound(5)) then
if (found%angrot) then
write (this%iout, '(4x,a,G0)') 'ANGROT = ', this%angrot
end if

Expand All @@ -269,24 +271,25 @@ subroutine source_dimensions(this)
use MemoryTypeModule, only: MemoryType
use MemoryManagerExtModule, only: mem_set_value
use SimVariablesModule, only: idm_context
use GwfDisInputModule, only: GwfDisParamFoundType
! -- dummy
class(GwfDisType) :: this
! -- locals
character(len=LENMEMPATH) :: idmMemoryPath
integer(I4B) :: i, j, k
logical, dimension(3) :: afound
type(GwfDisParamFoundType) :: found
!
! -- set memory path
idmMemoryPath = create_mem_path(this%name_model, 'DIS', idm_context)
!
! -- update defaults with idm sourced values
call mem_set_value(this%nlay, 'NLAY', idmMemoryPath, afound(1))
call mem_set_value(this%nrow, 'NROW', idmMemoryPath, afound(2))
call mem_set_value(this%ncol, 'NCOL', idmMemoryPath, afound(3))
call mem_set_value(this%nlay, 'NLAY', idmMemoryPath, found%nlay)
call mem_set_value(this%nrow, 'NROW', idmMemoryPath, found%nrow)
call mem_set_value(this%ncol, 'NCOL', idmMemoryPath, found%ncol)
!
! -- log simulation values
if (this%iout > 0) then
call this%log_dimensions(afound)
call this%log_dimensions(found)
end if
!
! -- verify dimensions were set
Expand Down Expand Up @@ -335,21 +338,22 @@ end subroutine source_dimensions

!> @brief Write dimensions to list file
!<
subroutine log_dimensions(this, afound)
subroutine log_dimensions(this, found)
use GwfDisInputModule, only: GwfDisParamFoundType
class(GwfDisType) :: this
logical, dimension(:), intent(in) :: afound
type(GwfDisParamFoundType), intent(in) :: found

write (this%iout, '(1x,a)') 'Setting Discretization Dimensions'

if (afound(1)) then
if (found%nlay) then
write (this%iout, '(4x,a,i0)') 'NLAY = ', this%nlay
end if

if (afound(2)) then
if (found%nrow) then
write (this%iout, '(4x,a,i0)') 'NROW = ', this%nrow
end if

if (afound(3)) then
if (found%ncol) then
write (this%iout, '(4x,a,i0)') 'NCOL = ', this%ncol
end if

Expand All @@ -367,27 +371,28 @@ subroutine source_griddata(this)
! -- modules
use MemoryManagerExtModule, only: mem_set_value
use SimVariablesModule, only: idm_context
use GwfDisInputModule, only: GwfDisParamFoundType
! -- dummy
class(GwfDisType) :: this
! -- locals
character(len=LENMEMPATH) :: idmMemoryPath
logical, dimension(5) :: afound
type(GwfDisParamFoundType) :: found
! -- formats
! ------------------------------------------------------------------------------
!
! -- set memory path
idmMemoryPath = create_mem_path(this%name_model, 'DIS', idm_context)
!
! -- update defaults with idm sourced values
call mem_set_value(this%delr, 'DELR', idmMemoryPath, afound(1))
call mem_set_value(this%delc, 'DELC', idmMemoryPath, afound(2))
call mem_set_value(this%top2d, 'TOP', idmMemoryPath, afound(3))
call mem_set_value(this%bot3d, 'BOTM', idmMemoryPath, afound(4))
call mem_set_value(this%idomain, 'IDOMAIN', idmMemoryPath, afound(5))
call mem_set_value(this%delr, 'DELR', idmMemoryPath, found%delr)
call mem_set_value(this%delc, 'DELC', idmMemoryPath, found%delc)
call mem_set_value(this%top2d, 'TOP', idmMemoryPath, found%top)
call mem_set_value(this%bot3d, 'BOTM', idmMemoryPath, found%botm)
call mem_set_value(this%idomain, 'IDOMAIN', idmMemoryPath, found%idomain)
!
! -- log simulation values
if (this%iout > 0) then
call this%log_griddata(afound)
call this%log_griddata(found)
end if
!
! -- Return
Expand All @@ -396,29 +401,30 @@ end subroutine source_griddata

!> @brief Write dimensions to list file
!<
subroutine log_griddata(this, afound)
subroutine log_griddata(this, found)
use GwfDisInputModule, only: GwfDisParamFoundType
class(GwfDisType) :: this
logical, dimension(:), intent(in) :: afound
type(GwfDisParamFoundType), intent(in) :: found

write (this%iout, '(1x,a)') 'Setting Discretization Griddata'

if (afound(1)) then
if (found%delr) then
write (this%iout, '(4x,a)') 'DELR set from input file'
end if

if (afound(2)) then
if (found%delc) then
write (this%iout, '(4x,a)') 'DELC set from input file'
end if

if (afound(3)) then
if (found%top) then
write (this%iout, '(4x,a)') 'TOP set from input file'
end if

if (afound(4)) then
if (found%botm) then
write (this%iout, '(4x,a)') 'BOTM set from input file'
end if

if (afound(5)) then
if (found%idomain) then
write (this%iout, '(4x,a)') 'IDOMAIN set from input file'
end if

Expand Down
17 changes: 17 additions & 0 deletions src/Model/GroundWaterFlow/gwf3dis8idm.f90
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,23 @@ module GwfDisInputModule
public gwf_dis_param_definitions
public gwf_dis_aggregate_definitions
public gwf_dis_block_definitions
public GwfDisParamFoundType

type GwfDisParamFoundType
logical :: length_units = .false.
logical :: nogrb = .false.
logical :: xorigin = .false.
logical :: yorigin = .false.
logical :: angrot = .false.
logical :: nlay = .false.
logical :: nrow = .false.
logical :: ncol = .false.
logical :: delr = .false.
logical :: delc = .false.
logical :: top = .false.
logical :: botm = .false.
logical :: idomain = .false.
end type GwfDisParamFoundType

type(InputParamDefinitionType), parameter :: &
gwfdis_length_units = InputParamDefinitionType &
Expand Down
Loading

0 comments on commit 41e9c34

Please sign in to comment.