Skip to content

Commit abd09c0

Browse files
committed
refactor(BaseDisType): make abstract, use interfaces and deferred procs
1 parent 88ec384 commit abd09c0

File tree

4 files changed

+468
-698
lines changed

4 files changed

+468
-698
lines changed

src/Model/GroundWaterFlow/gwf3dis8.f90

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ module GwfDisModule
5656
procedure :: log_griddata
5757
procedure :: grid_finalize
5858
procedure :: write_grb
59-
procedure :: allocate_scalars
60-
procedure :: allocate_arrays
59+
procedure :: allocate_scalars => allocate_scalars_dis
60+
procedure :: allocate_arrays => allocate_arrays_dis
6161
!
6262
! -- Read a node-sized model array (reduced or not)
6363
procedure :: read_int_array
@@ -159,7 +159,7 @@ subroutine dis3d_da(this)
159159
call memorylist_remove(this%name_model, 'DIS', idm_context)
160160
!
161161
! -- DisBaseType deallocate
162-
call this%DisBaseType%dis_da()
162+
call this%dis_da_default()
163163
!
164164
! -- Deallocate scalars
165165
call mem_deallocate(this%nlay)
@@ -866,7 +866,7 @@ function get_nodenumber_idx3(this, k, i, j, icheck) &
866866
return
867867
end function get_nodenumber_idx3
868868

869-
subroutine allocate_scalars(this, name_model, input_mempath)
869+
subroutine allocate_scalars_dis(this, name_model, input_mempath)
870870
! ******************************************************************************
871871
! allocate_scalars -- Allocate and initialize scalars
872872
! ******************************************************************************
@@ -881,7 +881,7 @@ subroutine allocate_scalars(this, name_model, input_mempath)
881881
! ------------------------------------------------------------------------------
882882
!
883883
! -- Allocate parent scalars
884-
call this%DisBaseType%allocate_scalars(name_model, input_mempath)
884+
call this%allocate_scalars_default(name_model, input_mempath)
885885
!
886886
! -- Allocate
887887
call mem_allocate(this%nlay, 'NLAY', this%memoryPath)
@@ -896,9 +896,9 @@ subroutine allocate_scalars(this, name_model, input_mempath)
896896
!
897897
! -- Return
898898
return
899-
end subroutine allocate_scalars
899+
end subroutine allocate_scalars_dis
900900

901-
subroutine allocate_arrays(this)
901+
subroutine allocate_arrays_dis(this)
902902
! ******************************************************************************
903903
! allocate_arrays -- Allocate arrays
904904
! ******************************************************************************
@@ -912,7 +912,7 @@ subroutine allocate_arrays(this)
912912
! ------------------------------------------------------------------------------
913913
!
914914
! -- Allocate arrays in DisBaseType (mshape, top, bot, area)
915-
call this%DisBaseType%allocate_arrays()
915+
call this%allocate_arrays_default()
916916
!
917917
! -- Allocate arrays for GwfDisType
918918
if (this%nodes < this%nodesuser) then
@@ -931,7 +931,7 @@ subroutine allocate_arrays(this)
931931
!
932932
! -- Return
933933
return
934-
end subroutine allocate_arrays
934+
end subroutine allocate_arrays_dis
935935

936936
function nodeu_from_string(this, lloc, istart, istop, in, iout, line, &
937937
flag_string, allow_zero) result(nodeu)

src/Model/GroundWaterFlow/gwf3disu8.f90

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ module GwfDisuModule
5555
procedure :: connection_normal
5656
procedure :: connection_vector
5757
procedure :: supports_layers
58-
procedure :: get_ncpl
58+
procedure :: get_ncpl => get_ncpl
5959
procedure, public :: record_array
6060
procedure, public :: record_srcdst_list_header
6161
! -- private
62-
procedure :: allocate_scalars
63-
procedure :: allocate_arrays
62+
procedure :: allocate_scalars => allocate_scalars_disu
63+
procedure :: allocate_arrays => allocate_arrays_disu
6464
procedure :: allocate_arrays_mem
6565
procedure :: source_options
6666
procedure :: source_dimensions
@@ -78,6 +78,9 @@ module GwfDisuModule
7878
! -- Read a node-sized model array (reduced or not)
7979
procedure :: read_int_array
8080
procedure :: read_dbl_array
81+
!
82+
procedure :: nlarray_to_nodelist
83+
procedure :: read_layer_array
8184
end type GwfDisuType
8285

8386
contains
@@ -482,7 +485,7 @@ subroutine disu_da(this)
482485
call mem_deallocate(this%nodereduced)
483486
!
484487
! -- DisBaseType deallocate
485-
call this%DisBaseType%dis_da()
488+
call this%dis_da_default()
486489
!
487490
! -- Return
488491
return
@@ -1305,7 +1308,7 @@ subroutine get_dis_type(this, dis_type)
13051308

13061309
end subroutine get_dis_type
13071310

1308-
subroutine allocate_scalars(this, name_model, input_mempath)
1311+
subroutine allocate_scalars_disu(this, name_model, input_mempath)
13091312
! ******************************************************************************
13101313
! allocate_scalars -- Allocate and initialize scalar variables in this class
13111314
! ******************************************************************************
@@ -1322,7 +1325,7 @@ subroutine allocate_scalars(this, name_model, input_mempath)
13221325
! ------------------------------------------------------------------------------
13231326
!
13241327
! -- Allocate parent scalars
1325-
call this%DisBaseType%allocate_scalars(name_model, input_mempath)
1328+
call this%allocate_scalars_default(name_model, input_mempath)
13261329
!
13271330
! -- Allocate variables for DISU
13281331
call mem_allocate(this%njausr, 'NJAUSR', this%memoryPath)
@@ -1340,9 +1343,9 @@ subroutine allocate_scalars(this, name_model, input_mempath)
13401343
!
13411344
! -- Return
13421345
return
1343-
end subroutine allocate_scalars
1346+
end subroutine allocate_scalars_disu
13441347

1345-
subroutine allocate_arrays(this)
1348+
subroutine allocate_arrays_disu(this)
13461349
! ******************************************************************************
13471350
! allocate_arrays -- Read discretization information from file
13481351
! ******************************************************************************
@@ -1357,7 +1360,7 @@ subroutine allocate_arrays(this)
13571360
! ------------------------------------------------------------------------------
13581361
!
13591362
! -- Allocate arrays in DisBaseType (mshape, top, bot, area)
1360-
call this%DisBaseType%allocate_arrays()
1363+
call this%allocate_arrays_default()
13611364
!
13621365
! -- Allocate arrays in DISU
13631366
if (this%nodes < this%nodesuser) then
@@ -1374,7 +1377,7 @@ subroutine allocate_arrays(this)
13741377
!
13751378
! -- Return
13761379
return
1377-
end subroutine allocate_arrays
1380+
end subroutine allocate_arrays_disu
13781381

13791382
subroutine allocate_arrays_mem(this)
13801383
use MemoryManagerModule, only: mem_allocate
@@ -1809,4 +1812,52 @@ function CastAsDisuType(dis) result(disu)
18091812

18101813
end function CastAsDisuType
18111814

1815+
! todo: are the below needed??? can they be removed fromm DiscretizationBase?
1816+
1817+
subroutine nlarray_to_nodelist(this, darray, nodelist, maxbnd, nbound, aname)
1818+
! -- modules
1819+
use SimModule, only: store_error
1820+
use ConstantsModule, only: LINELENGTH
1821+
! -- dummy
1822+
class(GwfDisuType) :: this
1823+
integer(I4B), intent(in) :: maxbnd
1824+
integer(I4B), dimension(:), pointer, contiguous :: darray
1825+
integer(I4B), dimension(maxbnd), intent(inout) :: nodelist
1826+
integer(I4B), intent(inout) :: nbound
1827+
character(len=*), intent(in) :: aname
1828+
!
1829+
errmsg = 'Programmer error: nlarray_to_nodelist called for DISU grid.'
1830+
call store_error(errmsg, terminate=.TRUE.)
1831+
1832+
end subroutine nlarray_to_nodelist
1833+
1834+
subroutine read_layer_array(this, nodelist, darray, ncolbnd, maxbnd, &
1835+
icolbnd, aname, inunit, iout)
1836+
! ******************************************************************************
1837+
! read_layer_array -- Read a 2d double array into col icolbnd of darray.
1838+
! For cells that are outside of the active domain,
1839+
! do not copy the array value into darray.
1840+
! ******************************************************************************
1841+
!
1842+
! SPECIFICATIONS:
1843+
! ------------------------------------------------------------------------------
1844+
! -- modules
1845+
! -- dummy
1846+
class(GwfDisuType) :: this
1847+
integer(I4B), intent(in) :: ncolbnd
1848+
integer(I4B), intent(in) :: maxbnd
1849+
integer(I4B), dimension(maxbnd) :: nodelist
1850+
real(DP), dimension(ncolbnd, maxbnd), intent(inout) :: darray
1851+
integer(I4B), intent(in) :: icolbnd
1852+
character(len=*), intent(in) :: aname
1853+
integer(I4B), intent(in) :: inunit
1854+
integer(I4B), intent(in) :: iout
1855+
!
1856+
!
1857+
errmsg = 'Programmer error: read_layer_array called for DISU grid.'
1858+
call store_error(errmsg, terminate=.TRUE.)
1859+
!
1860+
! -- return
1861+
end subroutine read_layer_array
1862+
18121863
end module GwfDisuModule

src/Model/GroundWaterFlow/gwf3disv8.f90

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ module GwfDisvModule
4848
procedure :: connection_normal
4949
procedure :: connection_vector
5050
procedure :: supports_layers
51-
procedure :: get_ncpl
51+
procedure :: get_ncpl => get_ncpl
5252
! -- private
5353
procedure :: source_options
5454
procedure :: source_dimensions
@@ -62,8 +62,8 @@ module GwfDisvModule
6262
procedure :: grid_finalize
6363
procedure :: connect
6464
procedure :: write_grb
65-
procedure :: allocate_scalars
66-
procedure :: allocate_arrays
65+
procedure :: allocate_scalars => allocate_scalars_disv
66+
procedure :: allocate_arrays => allocate_arrays_disv
6767
procedure :: get_cell2d_area
6868
!
6969
procedure :: read_int_array
@@ -180,7 +180,7 @@ subroutine disv_da(this)
180180
context=idm_context)
181181
!
182182
! -- DisBaseType deallocate
183-
call this%DisBaseType%dis_da()
183+
call this%dis_da_default()
184184
!
185185
! -- Deallocate scalars
186186
call mem_deallocate(this%nlay)
@@ -1234,7 +1234,7 @@ subroutine get_dis_type(this, dis_type)
12341234

12351235
end subroutine get_dis_type
12361236

1237-
subroutine allocate_scalars(this, name_model, input_mempath)
1237+
subroutine allocate_scalars_disv(this, name_model, input_mempath)
12381238
! ******************************************************************************
12391239
! allocate_scalars -- Allocate and initialize scalars
12401240
! ******************************************************************************
@@ -1250,7 +1250,7 @@ subroutine allocate_scalars(this, name_model, input_mempath)
12501250
! ------------------------------------------------------------------------------
12511251
!
12521252
! -- Allocate parent scalars
1253-
call this%DisBaseType%allocate_scalars(name_model, input_mempath)
1253+
call this%allocate_scalars_default(name_model, input_mempath)
12541254
!
12551255
! -- Allocate
12561256
call mem_allocate(this%nlay, 'NLAY', this%memoryPath)
@@ -1265,9 +1265,9 @@ subroutine allocate_scalars(this, name_model, input_mempath)
12651265
!
12661266
! -- Return
12671267
return
1268-
end subroutine allocate_scalars
1268+
end subroutine allocate_scalars_disv
12691269

1270-
subroutine allocate_arrays(this)
1270+
subroutine allocate_arrays_disv(this)
12711271
! ******************************************************************************
12721272
! allocate_arrays -- Allocate arrays
12731273
! ******************************************************************************
@@ -1281,7 +1281,7 @@ subroutine allocate_arrays(this)
12811281
! ------------------------------------------------------------------------------
12821282
!
12831283
! -- Allocate arrays in DisBaseType (mshape, top, bot, area)
1284-
call this%DisBaseType%allocate_arrays()
1284+
call this%allocate_arrays_default()
12851285
!
12861286
! -- Allocate arrays for GwfDisvType
12871287
if (this%nodes < this%nodesuser) then
@@ -1298,7 +1298,7 @@ subroutine allocate_arrays(this)
12981298
!
12991299
! -- Return
13001300
return
1301-
end subroutine allocate_arrays
1301+
end subroutine allocate_arrays_disv
13021302

13031303
function get_cell2d_area(this, icell2d) result(area)
13041304
! ******************************************************************************

0 commit comments

Comments
 (0)