MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
iunitmodule Module Reference

– Module to manage unit numbers. Allows for multiple unit numbers – assigned to a single package type, as shown below. – row(i) cunit(i) iunit(i)nval iunit(i)iunit iunit(i)ipos – 1 BCF6 1 (1000) (1) – 2 WEL 3 (1001,1003,1005) (2,5,7) – 3 GHB 1 (1002) (4) – 4 EVT 2 (1004,1006) (6,10) – 5 RIV 0 () () – ...

Data Types

type  iunitrowtype
type  iunittype

Functions/Subroutines

subroutine init (this, niunit, cunit)
 Allocate the cunit and iunit entries of this object, and copy cunit into the object.
subroutine addfile (this, ftyp, iunit, ipos, namefilename)
 Add an ftyp and unit number.
subroutine getunitnumber (this, ftyp, iunit, iremove)
 Get the last unit number for type ftyp or return 0 for iunit.

Function/Subroutine Documentation

◆ addfile()

subroutine iunitmodule::addfile ( class(iunittype), intent(inout) this,
character(len=*), intent(in) ftyp,
integer(i4b), intent(in) iunit,
integer(i4b), intent(in) ipos,
character(len=*), intent(in) namefilename )
private

Find the row for the ftyp and store another iunit value.

Definition at line 63 of file Iunit.f90.

64 ! -- dummy
65 class(IunitType), intent(inout) :: this
66 character(len=*), intent(in) :: ftyp
67 integer(I4B), intent(in) :: iunit
68 integer(I4B), intent(in) :: ipos
69 character(len=*), intent(in) :: namefilename
70 ! -- local
71 character(len=LINELENGTH) :: errmsg
72 integer(I4B), allocatable, dimension(:) :: itemp
73 integer(I4B) :: i, irow
74 !
75 ! -- Find the row containing ftyp
76 irow = 0
77 do i = 1, this%niunit
78 if (this%cunit(i) == ftyp) then
79 irow = i
80 exit
81 end if
82 end do
83 if (irow == 0) then
84 write (errmsg, '(a,a)') 'Package type not supported: ', ftyp
85 call store_error(errmsg)
86 call store_error_filename(namefilename, terminate=.true.)
87 end if
88 !
89 ! -- Store the iunit number for this ftyp
90 if (this%iunit(irow)%nval == 0) then
91 allocate (this%iunit(irow)%iunit(1))
92 allocate (this%iunit(irow)%ipos(1))
93 this%iunit(irow)%nval = 1
94 else
95 !
96 ! -- Increase size of iunit
97 allocate (itemp(this%iunit(irow)%nval))
98 itemp(:) = this%iunit(irow)%iunit(:)
99 deallocate (this%iunit(irow)%iunit)
100 this%iunit(irow)%nval = this%iunit(irow)%nval + 1
101 allocate (this%iunit(irow)%iunit(this%iunit(irow)%nval))
102 this%iunit(irow)%iunit(1:this%iunit(irow)%nval - 1) = itemp(:)
103 !
104 ! -- Increase size of ipos
105 itemp(:) = this%iunit(irow)%ipos(:)
106 deallocate (this%iunit(irow)%ipos)
107 allocate (this%iunit(irow)%ipos(this%iunit(irow)%nval))
108 this%iunit(irow)%ipos(1:this%iunit(irow)%nval - 1) = itemp(:)
109 !
110 ! -- Cleanup temp
111 deallocate (itemp)
112 end if
113 this%iunit(irow)%iunit(this%iunit(irow)%nval) = iunit
114 this%iunit(irow)%ipos(this%iunit(irow)%nval) = ipos
Here is the call graph for this function:

◆ getunitnumber()

subroutine iunitmodule::getunitnumber ( class(iunittype), intent(inout) this,
character(len=*), intent(in) ftyp,
integer(i4b), intent(inout) iunit,
integer(i4b), intent(in) iremove )
private

If iremove is 1, then remove this unit number. Similar to a list.pop().

Definition at line 121 of file Iunit.f90.

122 ! -- dummy
123 class(IunitType), intent(inout) :: this
124 character(len=*), intent(in) :: ftyp
125 integer(I4B), intent(inout) :: iunit
126 integer(I4B), intent(in) :: iremove
127 ! -- local
128 integer(I4B) :: i, irow, nval
129 !
130 ! -- Find the row
131 irow = 0
132 do i = 1, this%niunit
133 if (this%cunit(i) == ftyp) then
134 irow = i
135 exit
136 end if
137 end do
138 !
139 ! -- Find the unit number
140 iunit = 0
141 if (irow > 0) then
142 nval = this%iunit(irow)%nval
143 if (nval > 0) then
144 iunit = this%iunit(irow)%iunit(nval)
145 if (iremove > 0) then
146 this%iunit(irow)%iunit(nval) = 0
147 this%iunit(irow)%nval = nval - 1
148 end if
149 else
150 iunit = 0
151 end if
152 end if

◆ init()

subroutine iunitmodule::init ( class(iunittype), intent(inout) this,
integer(i4b), intent(in) niunit,
character(len=*), dimension(niunit), intent(in) cunit )

Definition at line 43 of file Iunit.f90.

44 ! -- dummy
45 class(IunitType), intent(inout) :: this
46 integer(I4B), intent(in) :: niunit
47 character(len=*), dimension(niunit), intent(in) :: cunit
48 ! -- local
49 integer(I4B) :: i
50 !
51 allocate (this%cunit(niunit))
52 allocate (this%iunit(niunit))
53 this%niunit = niunit
54 do i = 1, niunit
55 this%cunit(i) = cunit(i)
56 end do