Skip to content

Commit

Permalink
refactor(mover): refactor and clean up water mover for possible BOUND…
Browse files Browse the repository at this point in the history
…NAME support (#86)

This is some minor clean up to the water mover that improves some of the comments, and eliminates storage of a 20-character string for each water mover, and instead replaces it with an integer.  Reading of the reach id is now done using the IO utility, extract_idnum_or_bndname.
  • Loading branch information
langevin-usgs committed Feb 11, 2019
1 parent 7e3fe9f commit bc013c5
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 56 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 42
### Version 6.0.3 develop — build 59
[![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, 08 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, 11 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.42",
"version": "6.0.3.59",
"date": {
"metadataLastUpdated": "2019-02-08"
"metadataLastUpdated": "2019-02-11"
},
"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.42}
\newcommand{\modflowdate}{February 08, 2019}
\newcommand{\modflowversion}{mf6.0.3.59}
\newcommand{\modflowdate}{February 11, 2019}
\newcommand{\currentmodflowversion}{Version \modflowversion---\modflowdate}
34 changes: 19 additions & 15 deletions src/Model/GroundWaterFlow/gwf3mvr8.f90
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
!Water Mover Module
!GWF Water Mover Module
!This module contains a derived type, called GwfMvrType, that
!is attached to the GWF model. The water mover can be used to move water
!between packages. The mover requires that mover-aware packages have access to
!three arrays: qformvr, qtomvr, and qfrommvr. These arrays are store and
!managed by a separate object PackageMoverType. qformvr is a
!between packages. The mover requires that mover-aware packages have access
!to four arrays: qtformvr, qformvr, qtomvr, and qfrommvr. These arrays are
!stored and managed by a separate PackageMoverType object. qformvr is a
!vector of volumetric flow rates available for the mover. The package
!must fill the vector (dimensioned by number of reaches) with the available
!water. qtomvr is a vector containing how much water was actually moved
Expand All @@ -21,7 +21,8 @@
!
! type(GwfMvrType), pointer :: mvr => null()
!
! Mover aware packages define the following members:
! Mover aware packages have access to the following vectors of mover
! information, which are stored in the PackageMoverType object:
!
! integer(I4B), pointer :: imover => null()
! real(DP), dimension(:), pointer, contiguous :: qtformvr => null()
Expand All @@ -35,23 +36,24 @@
! water, but this value decreases as the mover object consumes water from
! it.
!
! 2. Create the mover package by calling the cr subroutine:
! 2. In gwf_cr create the mover package by calling the CR subroutine:
!
! call mvr_cr(this%mvr, this%name, this%inmvr, this%iout)
!
! 3. The AR method for the mover is called:
! 3. In gwf_ar call the AR method for the mover:
!
! if(this%inmvr > 0) call this%mvr%mvr_ar()
!
! Mover aware packages allocate the three vectors (typically to size
! maxbound)
! Mover aware packages allocate the four vectors. The first three
! (qtformvr, qformvr, qtomvr) are allocated to the number of providers
! and the last one (qfrommvr) is allocated to the number of receivers.
!
! 4. The RP method for the mover is called. This reads the movers active
! for the current period.
! 4. In gwf_rp call the RP method for the mover. This reads the
! movers active for the current period.
!
! if(this%inmvr > 0) call this%mvr%mvr_rp()
!
! 5. The AD method for the mover is called. This saves qtomvr from the
! 5. In gwf_ad call the AD method for the mover. This saves qtomvr from the
! the last time step.
!
! if(this%inmvr > 0) call this%mvr%mvr_ad()
Expand All @@ -60,7 +62,7 @@
! qtomvr(:) = 0.
! qformvr(:) = 0.
!
! 6. In the CF routine, Mover aware packages set:
! 6. In gwf_cf call the CF routine. Mover aware packages set:
! qtformvr(:) = qformvr(:)
! qfrommvr(:) = 0.
! qtomvr(:) = 0.
Expand All @@ -71,10 +73,12 @@
! qfrommvr vectors inside the packages. This is done by the mover package
! using pointers to the appropriate reach locations in qtomvr and qfrommvr.
!
! if(this%inmvr > 0) call this%mvr%mvr_fc() ! called from gwf%fc()
! if(this%inmvr > 0) call this%mvr%mvr_fc() ! called from gwf%gwf_fc()
!
! a. Mover aware packages first set qformvr(:) = 0.
! b. Mover aware packages add qfrommvr terms as a source of water
! b. Mover aware packages that are receivers (MAW, SFR, LAK, UZF) add
! qfrommvr terms to their individual control volume equations as a
! source of water.
! c. Mover aware packages calculate qformvr as amount of water available
! to be moved (these qformvr terms are used in the next iteration
! by this%mvr%mvr_fc() to calculate how much water is actually moved)
Expand Down
66 changes: 35 additions & 31 deletions src/Model/ModelUtilities/Mover.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module MvrModule

use KindModule, only: DP, I4B
use ConstantsModule, only: LENMODELNAME, LENPACKAGENAME, LINELENGTH, &
LENBUDTXT, LENAUXNAME, DZERO, DONE
LENBUDTXT, LENAUXNAME, LENBOUNDNAME, DZERO, DONE

implicit none
private
Expand All @@ -16,15 +16,15 @@ module MvrModule
character(len=LENMODELNAME+LENPACKAGENAME+1) :: pname2 = '' !receiver package name
integer(I4B) :: irch1 = 0 !provider reach number
integer(I4B) :: irch2 = 0 !receiver reach number
character(len=20) :: mvrtype = '' !FACTOR, THRESHOLD, UPTO, EXCESS
integer(I4B) :: imvrtype = 0 !mover type (1, 2, 3, 4) corresponds to mvrtypes
real(DP) :: value = DZERO !factor or rate depending on mvrtype
real(DP) :: qpold = DZERO !provider rate from last time step
real(DP) :: qpnew = DZERO !new provider rate
real(DP) :: qpactual = DZERO !rate provided to the receiver
real(DP) :: qanew = DZERO !rate available at time of providing
real(DP) :: qaold = DZERO !rate available fromtime step
real(DP), pointer :: qtformvr_ptr => null() !pointer to total available flow (qtformvr)
real(DP), pointer :: qformvr_ptr => null() !pointer to available flow after being consumed (qformvr)
real(DP), pointer :: qformvr_ptr => null() !pointer to available flow after consumed (qformvr)
real(DP), pointer :: qtomvr_ptr => null() !pointer to provider flow rate (qtomvr)
real(DP), pointer :: qfrommvr_ptr => null() !pointer to receiver flow rate (qfrommvr)
contains
Expand All @@ -48,7 +48,7 @@ subroutine set(this, line, inunit, iout, mname)
! SPECIFICATIONS:
! ------------------------------------------------------------------------------
! -- modules
use InputOutputModule, only: urword
use InputOutputModule, only: urword, extract_idnum_or_bndname
use SimModule, only: ustop, store_error, store_error_unit
use MemoryManagerModule, only: mem_setptr
! -- dummy
Expand All @@ -59,11 +59,11 @@ subroutine set(this, line, inunit, iout, mname)
character(len=LENMODELNAME), intent(in) :: mname
! -- local
character(len=LENMODELNAME+LENPACKAGENAME+1) :: origin
integer(I4B) :: lloc, istart, istop, ival, i
integer(I4B) :: lloc, istart, istop, ival
real(DP) :: rval
real(DP), dimension(:), pointer, contiguous :: temp_ptr => null()
logical :: valid
character(len=LINELENGTH) :: errmsg
character(len=LENBOUNDNAME) :: bndname
logical :: mnamel
! ------------------------------------------------------------------------------
!
Expand All @@ -88,7 +88,7 @@ subroutine set(this, line, inunit, iout, mname)
this%pname1 = trim(this%pname1) // ' ' // line(istart:istop)
!
! -- Read id for the provider
call urword(line, lloc, istart, istop, 2, ival, rval, iout, inunit)
call extract_idnum_or_bndname(line, lloc, istart, istop, ival, bndname)
this%irch1 = ival
!
! -- Construct receiver name, which is modelname followed by packagename
Expand All @@ -102,29 +102,30 @@ subroutine set(this, line, inunit, iout, mname)
this%pname2 = trim(this%pname2) // ' ' // line(istart:istop)
!
! -- Read id for the receiver
call urword(line, lloc, istart, istop, 2, ival, rval, iout, inunit)
call extract_idnum_or_bndname(line, lloc, istart, istop, ival, bndname)
this%irch2 = ival
!
! -- Read type and value
! -- Read mover type
call urword(line, lloc, istart, istop, 1, ival, rval, iout, inunit)
this%mvrtype = line(istart:istop)
select case(line(istart:istop))
case('FACTOR')
this%imvrtype = 1
case('EXCESS')
this%imvrtype = 2
case('THRESHOLD')
this%imvrtype = 3
case('UPTO')
this%imvrtype = 4
case default
call store_error('ERROR. INVALID MOVER TYPE: '//trim(line(istart:istop)) )
call store_error_unit(inunit)
call ustop()
end select
!
! -- Read mover value
call urword(line, lloc, istart, istop, 3, ival, rval, iout, inunit)
this%value = rval
!
! -- Ensure mvrtype is valid
valid = .false.
do i = 1, size(mvrtypes)
if(this%mvrtype == mvrtypes(i)) then
valid = .true.
exit
endif
enddo
if(.not. valid) then
call store_error('ERROR. INVALID MOVER TYPE: '//trim(this%mvrtype) )
call store_error_unit(inunit)
call ustop()
endif
!
! -- initialize values to zero
call this%set_qpold(DZERO)
!
Expand Down Expand Up @@ -237,8 +238,8 @@ subroutine echo(this, iout)
' FROM ID: ', this%irch1
write(iout, '(4x, a, a, a, i0)') 'TO PACKAGE: ', trim(this%pname2), &
' TO ID: ', this%irch2
write(iout, '(4x, a, a, a, 1pg15.6,/)') 'MOVER TYPE: ', trim(this%mvrtype),&
' ', this%value
write(iout, '(4x, a, a, a, 1pg15.6,/)') 'MOVER TYPE: ', &
trim(mvrtypes(this%imvrtype)), ' ', this%value
!
! -- return
return
Expand Down Expand Up @@ -330,25 +331,28 @@ function qrcalc(this, qa, qta) result(qr)
! go to the receiver.
qr = DZERO
! -- Calculate qr
select case (this%mvrtype)
case('FACTOR')
select case (this%imvrtype)
case(1)
! -- FACTOR uses total available to make calculation, and then
! limits qr by consumed available
if(qta > DZERO) qr = qta * this%value
qr = min(qr, qa)
case('EXCESS')
case(2)
! -- EXCESS
if(qa > this%value) then
qr = qa - this%value
else
qr = DZERO
endif
case('THRESHOLD')
case(3)
! -- THRESHOLD
if(this%value > qa) then
qr = DZERO
else
qr = this%value
endif
case('UPTO')
case(4)
! -- UPTO
if(qa > this%value) then
qr = this%value
else
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/version.f90
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module VersionModule
public
! -- modflow 6 version
integer(I4B), parameter :: IDEVELOPMODE = 1
character(len=40), parameter :: VERSION = '6.0.3.42 02/08/2019'
character(len=40), parameter :: VERSION = '6.0.3.59 02/11/2019'
character(len=10), parameter :: MFVNAM = ' 6'
character(len=*), parameter :: MFTITLE = &
'U.S. GEOLOGICAL SURVEY MODULAR HYDROLOGIC MODEL'
Expand Down
6 changes: 3 additions & 3 deletions version.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# MODFLOW 6 version file automatically created using...pre-commit.py
# created on...February 08, 2019 18:34:20
# created on...February 11, 2019 07:33:06

# add some comments on how this version file
# should be manually updated and used

major = 6
minor = 0
micro = 3
build = 42
commit = 143
build = 59
commit = 160

0 comments on commit bc013c5

Please sign in to comment.