Skip to content

Commit

Permalink
refactor(MemoryManager): add mem_reassignptr functions and clean up (#92
Browse files Browse the repository at this point in the history
)

* Completed the mem_reassignptr routines so there are versions for int1d, int2d, dbl1d, dbl2d
* Adding optional name and origin arguments to the other array deallocate routines.  In general, we should be passing name and origin to the mem_deallocate routine.  Ultimately, I think we will want to make this mandatory.
* Discovered that rclose was not being deallocated and made the fix.  
* NPF variables K22 and K33 are now reassigned to K11 if they are not specified.  
* The memory manager type now has a new logical attribute called "master".  If true, then this means this this variable is the master version, and should be deallocated.  If this memory type is just a copy to another variable, then master should be set to zero.  This information is used for deallocation and for determining memory usage.
* closes #65
  • Loading branch information
langevin-usgs committed Feb 15, 2019
1 parent af67357 commit 1c7309f
Show file tree
Hide file tree
Showing 10 changed files with 421 additions and 351 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Automated Testing Status on Travis-CI

### Version 6.0.3 develop — build 65
### Version 6.0.3 develop — build 70
[![Build Status](https://travis-ci.org/MODFLOW-USGS/modflow6.svg?branch=develop)](https://travis-ci.org/MODFLOW-USGS/modflow6)

## Introduction
Expand All @@ -31,7 +31,7 @@ MODFLOW 6 is the latest core version of MODFLOW. It synthesizes many of the capa

#### ***Software/Code citation for MODFLOW 6:***

[Langevin, C.D., Hughes, J.D., Banta, E.R., Provost, A.M., Niswonger, R.G., and Panday, Sorab, 2019, MODFLOW 6 Modular Hydrologic Model version 6.0.3 — develop: U.S. Geological Survey Software Release, 13 February 2019, https://doi.org/10.5066/F76Q1VQV](https://doi.org/10.5066/F76Q1VQV)
[Langevin, C.D., Hughes, J.D., Banta, E.R., Provost, A.M., Niswonger, R.G., and Panday, Sorab, 2019, MODFLOW 6 Modular Hydrologic Model version 6.0.3 — develop: U.S. Geological Survey Software Release, 15 February 2019, https://doi.org/10.5066/F76Q1VQV](https://doi.org/10.5066/F76Q1VQV)

## Instructions for building definition files for new packages

Expand Down
4 changes: 2 additions & 2 deletions code.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"email": "langevin@usgs.gov"
},
"laborHours": -1,
"version": "6.0.3.65",
"version": "6.0.3.70",
"date": {
"metadataLastUpdated": "2019-02-13"
"metadataLastUpdated": "2019-02-15"
},
"organization": "U.S. Geological Survey",
"permissions": {
Expand Down
4 changes: 2 additions & 2 deletions doc/version.tex
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
\newcommand{\modflowversion}{mf6.0.3.65}
\newcommand{\modflowdate}{February 13, 2019}
\newcommand{\modflowversion}{mf6.0.3.70}
\newcommand{\modflowdate}{February 15, 2019}
\newcommand{\currentmodflowversion}{Version \modflowversion---\modflowdate}
11 changes: 7 additions & 4 deletions src/Model/GroundWaterFlow/gwf3npf8.f90
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ subroutine npf_fn(this, kiter, nodes, nja, njasln, amat, idxglo, rhs, hnew)
integer(I4B) :: isymcon, idiagm
integer(I4B) :: iups
integer(I4B) :: idn
real(DP) :: athk
real(DP) :: cond
real(DP) :: consterm
real(DP) :: filledterm
Expand Down Expand Up @@ -938,8 +937,8 @@ subroutine npf_da(this)
! -- Deallocate arrays
call mem_deallocate(this%icelltype)
call mem_deallocate(this%k11)
call mem_deallocate(this%k22)
call mem_deallocate(this%k33)
call mem_deallocate(this%k22, 'K22', this%origin)
call mem_deallocate(this%k33, 'K33', this%origin)
call mem_deallocate(this%sat)
call mem_deallocate(this%condsat)
call mem_deallocate(this%wetdry)
Expand Down Expand Up @@ -1461,7 +1460,7 @@ subroutine read_data(this)
! ------------------------------------------------------------------------------
! -- modules
use ConstantsModule, only: LINELENGTH, DONE, DPIO180
use MemoryManagerModule, only: mem_reallocate
use MemoryManagerModule, only: mem_reallocate, mem_reassignptr
use SimModule, only: ustop, store_error, count_errors
! -- dummy
class(GwfNpftype) :: this
Expand Down Expand Up @@ -1604,6 +1603,8 @@ subroutine read_data(this)
! -- Check for K33
if(.not. lname(3)) then
write(this%iout, '(1x, a)') 'K33 not provided. Assuming K33 = K.'
call mem_reassignptr(this%k33, 'K33', trim(this%origin), &
'K11', trim(this%origin))
else
nerr = 0
do n = 1, size(this%k33)
Expand All @@ -1626,6 +1627,8 @@ subroutine read_data(this)
! -- Check for K22
if(.not. lname(4)) then
write(this%iout, '(1x, a)') 'K22 not provided. Assuming K22 = K.'
call mem_reassignptr(this%k22, 'K22', trim(this%origin), &
'K11', trim(this%origin))
else
! -- Check to make sure that angles are available
if(this%dis%con%ianglex == 0) then
Expand Down
10 changes: 5 additions & 5 deletions src/Model/ModelUtilities/BoundaryPackage.f90
Original file line number Diff line number Diff line change
Expand Up @@ -1004,11 +1004,11 @@ subroutine allocate_arrays(this, nodelist, auxvar)
end do

do i = 1, this%maxbound
this%hcof(i) = DZERO
this%rhs(i) = DZERO
if(this%inamedbound==1) then
this%boundname(i) = ''
end if
this%hcof(i) = DZERO
this%rhs(i) = DZERO
if(this%inamedbound==1) then
this%boundname(i) = ''
end if
end do
if(this%inamedbound /= 1) this%boundname(1) = ''
!
Expand Down
1 change: 1 addition & 0 deletions src/Solution/SparseMatrixSolver/ims8linear.f90
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,7 @@ subroutine IMSLINEAR_DA(this)
call mem_deallocate(this%niapc)
call mem_deallocate(this%njapc)
call mem_deallocate(this%hclose)
call mem_deallocate(this%rclose)
call mem_deallocate(this%relax)
call mem_deallocate(this%epfact)
call mem_deallocate(this%l2norm0)
Expand Down
13 changes: 9 additions & 4 deletions src/Utilities/Memory/Memory.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module MemoryTypeModule
character(len=50) :: memtype !type (INTEGER or DOUBLE)
integer(I4B) :: id !id, not used
integer(I4B) :: nrealloc = 0 !number of times reallocated
integer(I4B) :: isize !size of the array
integer(I4B) :: isize !size of the array
logical :: master = .true. !master copy, others point to this one
logical, pointer :: logicalsclr => null() !pointer to the logical
integer(I4B), pointer :: intsclr => null() !pointer to the integer
real(DP), pointer :: dblsclr => null() !pointer to the double
Expand All @@ -37,14 +38,18 @@ module MemoryTypeModule
subroutine table_entry(this, msg)
class(MemoryType) :: this
character(len=*), intent(inout) :: msg
character(len=*), parameter :: fmt = "(1x, a40, a20, a20, i10, i10, a2)"
character(len=*), parameter :: &
fmt = "(1x, a40, a20, a20, i10, i10, a10, a2)"
character(len=1) :: cptr
character(len=1) :: dastr
!
! -- Create the msg table entry
! -- Create the msg table entry
cptr = ''
if (.not. this%master) cptr = 'T'
dastr = ''
if (this%mt_associated() .and. this%isize > 0) dastr='*'
write(msg, fmt) this%origin, this%name, this%memtype, this%isize, &
this%nrealloc, dastr
this%nrealloc, cptr, dastr
end subroutine table_entry

function mt_associated(this) result(al)
Expand Down
Loading

0 comments on commit 1c7309f

Please sign in to comment.