30 integer(I4B),
pointer :: njausr => null()
31 integer(I4B),
pointer :: nvert => null()
32 real(dp),
pointer :: voffsettol => null()
33 real(dp),
dimension(:, :),
pointer,
contiguous :: vertices => null()
34 real(dp),
dimension(:, :),
pointer,
contiguous :: cellxy => null()
35 real(dp),
dimension(:),
pointer,
contiguous :: top1d => null()
36 real(dp),
dimension(:),
pointer,
contiguous :: bot1d => null()
37 real(dp),
dimension(:),
pointer,
contiguous :: area1d => null()
38 integer(I4B),
dimension(:),
pointer,
contiguous :: iainp => null()
39 integer(I4B),
dimension(:),
pointer,
contiguous :: jainp => null()
40 integer(I4B),
dimension(:),
pointer,
contiguous :: ihcinp => null()
41 real(dp),
dimension(:),
pointer,
contiguous :: cl12inp => null()
42 real(dp),
dimension(:),
pointer,
contiguous :: hwvainp => null()
43 real(dp),
dimension(:),
pointer,
contiguous :: angldegxinp => null()
44 integer(I4B),
pointer :: iangledegx => null()
45 integer(I4B),
dimension(:),
pointer,
contiguous :: iavert => null()
46 integer(I4B),
dimension(:),
pointer,
contiguous :: javert => null()
47 integer(I4B),
dimension(:),
pointer,
contiguous :: idomain => null()
48 logical(LGP) :: readfromfile
94 logical :: length_units = .false.
95 logical :: nogrb = .false.
96 logical :: xorigin = .false.
97 logical :: yorigin = .false.
98 logical :: angrot = .false.
99 logical :: voffsettol = .false.
100 logical :: nodes = .false.
101 logical :: nja = .false.
102 logical :: nvert = .false.
103 logical :: top = .false.
104 logical :: bot = .false.
105 logical :: area = .false.
106 logical :: idomain = .false.
107 logical :: iac = .false.
108 logical :: ja = .false.
109 logical :: ihc = .false.
110 logical :: cl12 = .false.
111 logical :: hwva = .false.
112 logical :: angldegx = .false.
113 logical :: iv = .false.
114 logical :: xv = .false.
115 logical :: yv = .false.
116 logical :: icell2d = .false.
117 logical :: xc = .false.
118 logical :: yc = .false.
119 logical :: ncvert = .false.
120 logical :: icvert = .false.
127 subroutine disu_cr(dis, name_model, input_mempath, inunit, iout)
130 character(len=*),
intent(in) :: name_model
131 character(len=*),
intent(in) :: input_mempath
132 integer(I4B),
intent(in) :: inunit
133 integer(I4B),
intent(in) :: iout
136 character(len=*),
parameter :: fmtheader = &
137 "(1X, /1X, 'DISU -- UNSTRUCTURED GRID DISCRETIZATION PACKAGE,', &
138 &' VERSION 2 : 3/27/2014 - INPUT READ FROM MEMPATH: ', A, //)"
145 call dis%allocate_scalars(name_model, input_mempath)
154 write (iout, fmtheader) dis%input_mempath
158 call disnew%disu_load()
170 call this%source_options()
171 call this%source_dimensions()
172 call this%source_griddata()
173 call this%source_connectivity()
176 if (this%nvert > 0)
then
177 call this%source_vertices()
178 call this%source_cell2d()
196 call this%grid_finalize()
208 integer(I4B) :: noder
209 integer(I4B) :: nrsize
211 character(len=*),
parameter :: fmtdz = &
212 "('CELL (',i0,',',i0,',',i0,') THICKNESS <= 0. ', &
213 &'TOP, BOT: ',2(1pg24.15))"
214 character(len=*),
parameter :: fmtnr = &
215 "(/1x, 'The specified IDOMAIN results in a reduced number of cells.',&
216 &/1x, 'Number of user nodes: ',I0,&
217 &/1X, 'Number of nodes in solution: ', I0, //)"
221 do n = 1, this%nodesuser
222 if (this%idomain(n) > 0) this%nodes = this%nodes + 1
226 if (this%nodes == 0)
then
227 call store_error(
'Model does not have any active nodes. &
228 &Ensure IDOMAIN array has some values greater &
234 if (this%nodes < this%nodesuser)
then
235 write (this%iout, fmtnr) this%nodesuser, this%nodes
239 call this%allocate_arrays()
245 if (this%nodes < this%nodesuser)
then
247 do node = 1, this%nodesuser
248 if (this%idomain(node) > 0)
then
249 this%nodereduced(node) = noder
251 elseif (this%idomain(node) < 0)
then
252 this%nodereduced(node) = -1
254 this%nodereduced(node) = 0
260 if (this%nodes < this%nodesuser)
then
262 do node = 1, this%nodesuser
263 if (this%idomain(node) > 0)
then
264 this%nodeuser(noder) = node
271 do node = 1, this%nodesuser
273 if (this%nodes < this%nodesuser) noder = this%nodereduced(node)
274 if (noder <= 0) cycle
275 this%top(noder) = this%top1d(node)
276 this%bot(noder) = this%bot1d(node)
277 this%area(noder) = this%area1d(node)
281 if (this%nvert > 0)
then
282 do node = 1, this%nodesuser
284 if (this%nodes < this%nodesuser) noder = this%nodereduced(node)
285 if (noder <= 0) cycle
286 this%xc(noder) = this%cellxy(1, node)
287 this%yc(noder) = this%cellxy(2, node)
296 if (this%nodes < this%nodesuser) nrsize = this%nodes
298 call this%con%disuconnections(this%name_model, this%nodes, &
299 this%nodesuser, nrsize, &
300 this%nodereduced, this%nodeuser, &
301 this%iainp, this%jainp, &
302 this%ihcinp, this%cl12inp, &
303 this%hwvainp, this%angldegxinp, &
305 this%nja = this%con%nja
306 this%njas = this%con%njas
321 character(len=*),
parameter :: fmtidm = &
322 &
"('Invalid idomain value ', i0, ' specified for node ', i0)"
323 character(len=*),
parameter :: fmtdz = &
324 &
"('Cell ', i0, ' with thickness <= 0. Top, bot: ', 2(1pg24.15))"
325 character(len=*),
parameter :: fmtarea = &
326 &
"('Cell ', i0, ' with area <= 0. Area: ', 1(1pg24.15))"
327 character(len=*),
parameter :: fmtjan = &
328 &
"('Cell ', i0, ' must have its first connection be itself. Found: ', i0)"
329 character(len=*),
parameter :: fmtjam = &
330 &
"('Cell ', i0, ' has invalid connection in JA. Found: ', i0)"
331 character(len=*),
parameter :: fmterrmsg = &
332 "('Top elevation (', 1pg15.6, ') for cell ', i0, ' is above bottom &
333 &elevation (', 1pg15.6, ') for cell ', i0, '. Based on node numbering &
334 &rules cell ', i0, ' must be below cell ', i0, '.')"
337 do n = 1, this%nodesuser
348 write (
errmsg, fmtjan) n, m
353 do ipos = this%iainp(n) + 1, this%iainp(n + 1) - 1
355 if (m < 0 .or. m > this%nodesuser)
then
357 write (
errmsg, fmtjam) n, m
365 if (this%inunit > 0)
then
371 do n = 1, this%nodesuser
372 if (this%idomain(n) > 1 .or. this%idomain(n) < 0)
then
373 write (
errmsg, fmtidm) this%idomain(n), n
380 do n = 1, this%nodesuser
381 if (this%idomain(n) == 1)
then
382 dz = this%top1d(n) - this%bot1d(n)
383 if (dz <=
dzero)
then
384 write (
errmsg, fmt=fmtdz) n, this%top1d(n), this%bot1d(n)
387 if (this%area1d(n) <=
dzero)
then
388 write (
errmsg, fmt=fmtarea) n, this%area1d(n)
395 if (this%voffsettol <
dzero)
then
396 write (
errmsg,
'(a, 1pg15.6)') &
397 'Vertical offset tolerance must be greater than zero. Found ', &
400 if (this%inunit > 0)
then
407 do n = 1, this%nodesuser
408 do ipos = this%iainp(n) + 1, this%iainp(n + 1) - 1
410 ihc = this%ihcinp(ipos)
411 if (ihc == 0 .and. m > n)
then
412 dz = this%top1d(m) - this%bot1d(n)
413 if (dz > this%voffsettol)
then
414 write (
errmsg, fmterrmsg) this%top1d(m), m, this%bot1d(n), n, m, n
423 if (this%inunit > 0)
then
448 if (this%readFromFile)
then
452 if (
associated(this%iavert))
then
472 call this%DisBaseType%dis_da()
481 integer(I4B),
intent(in) :: nodeu
482 character(len=*),
intent(inout) :: str
484 character(len=10) :: nstr
486 write (nstr,
'(i0)') nodeu
487 str =
'('//trim(adjustl(nstr))//
')'
495 integer(I4B),
intent(in) :: nodeu
496 integer(I4B),
dimension(:),
intent(inout) :: arr
498 integer(I4B) :: isize
502 if (isize /= this%ndim)
then
503 write (
errmsg,
'(a,i0,a,i0,a)') &
504 'Program error: nodeu_to_array size of array (', isize, &
505 ') is not equal to the discretization dimension (', this%ndim,
')'
520 character(len=LENVARNAME),
dimension(3) :: lenunits = &
521 &[character(len=LENVARNAME) ::
'FEET',
'METERS',
'CENTIMETERS']
525 call mem_set_value(this%lenuni,
'LENGTH_UNITS', this%input_mempath, &
526 lenunits, found%length_units)
527 call mem_set_value(this%nogrb,
'NOGRB', this%input_mempath, found%nogrb)
528 call mem_set_value(this%xorigin,
'XORIGIN', this%input_mempath, found%xorigin)
529 call mem_set_value(this%yorigin,
'YORIGIN', this%input_mempath, found%yorigin)
530 call mem_set_value(this%angrot,
'ANGROT', this%input_mempath, found%angrot)
531 call mem_set_value(this%voffsettol,
'VOFFSETTOL', this%input_mempath, &
535 if (this%iout > 0)
then
536 call this%log_options(found)
548 write (this%iout,
'(1x,a)')
'Setting Discretization Options'
550 if (found%length_units)
then
551 write (this%iout,
'(4x,a,i0)')
'Model length unit [0=UND, 1=FEET, &
552 &2=METERS, 3=CENTIMETERS] set as ', this%lenuni
555 if (found%nogrb)
then
556 write (this%iout,
'(4x,a,i0)')
'Binary grid file [0=GRB, 1=NOGRB] &
557 &set as ', this%nogrb
560 if (found%xorigin)
then
561 write (this%iout,
'(4x,a,G0)')
'XORIGIN = ', this%xorigin
564 if (found%yorigin)
then
565 write (this%iout,
'(4x,a,G0)')
'YORIGIN = ', this%yorigin
568 if (found%angrot)
then
569 write (this%iout,
'(4x,a,G0)')
'ANGROT = ', this%angrot
572 if (found%voffsettol)
then
573 write (this%iout,
'(4x,a,G0)')
'VERTICAL_OFFSET_TOLERANCE = ', &
577 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Options'
591 call mem_set_value(this%nodesuser,
'NODES', this%input_mempath, found%nodes)
592 call mem_set_value(this%njausr,
'NJA', this%input_mempath, found%nja)
593 call mem_set_value(this%nvert,
'NVERT', this%input_mempath, found%nvert)
596 if (this%iout > 0)
then
597 call this%log_dimensions(found)
601 if (this%nodesuser < 1)
then
603 'NODES was not specified or was specified incorrectly.')
605 if (this%njausr < 1)
then
607 'NJA was not specified or was specified incorrectly.')
616 this%readFromFile = .true.
617 call mem_allocate(this%top1d, this%nodesuser,
'TOP1D', this%memoryPath)
618 call mem_allocate(this%bot1d, this%nodesuser,
'BOT1D', this%memoryPath)
619 call mem_allocate(this%area1d, this%nodesuser,
'AREA1D', this%memoryPath)
620 call mem_allocate(this%idomain, this%nodesuser,
'IDOMAIN', this%memoryPath)
621 call mem_allocate(this%vertices, 2, this%nvert,
'VERTICES', this%memoryPath)
622 call mem_allocate(this%iainp, this%nodesuser + 1,
'IAINP', this%memoryPath)
623 call mem_allocate(this%jainp, this%njausr,
'JAINP', this%memoryPath)
624 call mem_allocate(this%ihcinp, this%njausr,
'IHCINP', this%memoryPath)
625 call mem_allocate(this%cl12inp, this%njausr,
'CL12INP', this%memoryPath)
626 call mem_allocate(this%hwvainp, this%njausr,
'HWVAINP', this%memoryPath)
627 call mem_allocate(this%angldegxinp, this%njausr,
'ANGLDEGXINP', &
629 if (this%nvert > 0)
then
630 call mem_allocate(this%cellxy, 2, this%nodesuser,
'CELLXY', this%memoryPath)
632 call mem_allocate(this%cellxy, 2, 0,
'CELLXY', this%memoryPath)
636 do n = 1, this%nodesuser
648 write (this%iout,
'(1x,a)')
'Setting Discretization Dimensions'
650 if (found%nodes)
then
651 write (this%iout,
'(4x,a,i0)')
'NODES = ', this%nodesuser
655 write (this%iout,
'(4x,a,i0)')
'NJA = ', this%njausr
658 if (found%nvert)
then
659 write (this%iout,
'(4x,a,i0)')
'NVERT = ', this%nvert
662 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Dimensions'
675 call mem_set_value(this%top1d,
'TOP', this%input_mempath, found%top)
676 call mem_set_value(this%bot1d,
'BOT', this%input_mempath, found%bot)
677 call mem_set_value(this%area1d,
'AREA', this%input_mempath, found%area)
678 call mem_set_value(this%idomain,
'IDOMAIN', this%input_mempath, found%idomain)
681 if (this%iout > 0)
then
682 call this%log_griddata(found)
694 write (this%iout,
'(1x,a)')
'Setting Discretization Griddata'
697 write (this%iout,
'(4x,a)')
'TOP set from input file'
701 write (this%iout,
'(4x,a)')
'BOT set from input file'
705 write (this%iout,
'(4x,a)')
'AREA set from input file'
708 if (found%idomain)
then
709 write (this%iout,
'(4x,a)')
'IDOMAIN set from input file'
712 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Griddata'
723 integer(I4B),
dimension(:),
contiguous,
pointer :: iac => null()
727 call mem_set_value(this%jainp,
'JA', this%input_mempath, found%ja)
728 call mem_set_value(this%ihcinp,
'IHC', this%input_mempath, found%ihc)
729 call mem_set_value(this%cl12inp,
'CL12', this%input_mempath, found%cl12)
730 call mem_set_value(this%hwvainp,
'HWVA', this%input_mempath, found%hwva)
731 call mem_set_value(this%angldegxinp,
'ANGLDEGX', this%input_mempath, &
735 call mem_setptr(iac,
'IAC', this%input_mempath)
738 if (
associated(iac))
call iac_to_ia(iac, this%iainp)
741 if (found%angldegx) this%iangledegx = 1
744 if (this%iout > 0)
then
745 call this%log_connectivity(found, iac)
755 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: iac
757 write (this%iout,
'(1x,a)')
'Setting Discretization Connectivity'
759 if (
associated(iac))
then
760 write (this%iout,
'(4x,a)')
'IAC set from input file'
764 write (this%iout,
'(4x,a)')
'JA set from input file'
768 write (this%iout,
'(4x,a)')
'IHC set from input file'
772 write (this%iout,
'(4x,a)')
'CL12 set from input file'
776 write (this%iout,
'(4x,a)')
'HWVA set from input file'
779 if (found%angldegx)
then
780 write (this%iout,
'(4x,a)')
'ANGLDEGX set from input file'
783 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Connectivity'
794 real(DP),
dimension(:),
contiguous,
pointer :: vert_x => null()
795 real(DP),
dimension(:),
contiguous,
pointer :: vert_y => null()
799 call mem_setptr(vert_x,
'XV', this%input_mempath)
800 call mem_setptr(vert_y,
'YV', this%input_mempath)
803 if (
associated(vert_x) .and.
associated(vert_y))
then
805 this%vertices(1, i) = vert_x(i)
806 this%vertices(2, i) = vert_y(i)
809 call store_error(
'Required Vertex arrays not found.')
813 if (this%iout > 0)
then
814 write (this%iout,
'(1x,a)')
'Discretization Vertex data loaded'
828 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: icell2d
829 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: ncvert
830 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: icvert
833 integer(I4B) :: i, j, ierr
834 integer(I4B) :: icv_idx, startvert, maxnnz = 5
837 call vert_spm%init(this%nodesuser, this%nvert, maxnnz)
841 do i = 1, this%nodesuser
842 if (icell2d(i) /= i)
call store_error(
'ICELL2D input sequence violation.')
844 call vert_spm%addconnection(i, icvert(icv_idx), 0)
846 startvert = icvert(icv_idx)
847 elseif (j == ncvert(i) .and. (icvert(icv_idx) /= startvert))
then
848 call vert_spm%addconnection(i, startvert, 0)
850 icv_idx = icv_idx + 1
855 call mem_allocate(this%iavert, this%nodesuser + 1,
'IAVERT', this%memoryPath)
856 call mem_allocate(this%javert, vert_spm%nnz,
'JAVERT', this%memoryPath)
857 call vert_spm%filliaja(this%iavert, this%javert, ierr)
858 call vert_spm%destroy()
868 integer(I4B),
dimension(:),
contiguous,
pointer :: icell2d => null()
869 integer(I4B),
dimension(:),
contiguous,
pointer :: ncvert => null()
870 integer(I4B),
dimension(:),
contiguous,
pointer :: icvert => null()
871 real(DP),
dimension(:),
contiguous,
pointer :: cell_x => null()
872 real(DP),
dimension(:),
contiguous,
pointer :: cell_y => null()
876 call mem_setptr(icell2d,
'ICELL2D', this%input_mempath)
877 call mem_setptr(ncvert,
'NCVERT', this%input_mempath)
878 call mem_setptr(icvert,
'ICVERT', this%input_mempath)
881 if (
associated(icell2d) .and.
associated(ncvert) &
882 .and.
associated(icvert))
then
883 call this%define_cellverts(icell2d, ncvert, icvert)
885 call store_error(
'Required cell vertex arrays not found.')
889 call mem_setptr(cell_x,
'XC', this%input_mempath)
890 call mem_setptr(cell_y,
'YC', this%input_mempath)
893 if (
associated(cell_x) .and.
associated(cell_y))
then
894 do i = 1, this%nodesuser
895 this%cellxy(1, i) = cell_x(i)
896 this%cellxy(2, i) = cell_y(i)
899 call store_error(
'Required cell center arrays not found.')
903 if (this%iout > 0)
then
904 write (this%iout,
'(1x,a)')
'Discretization Cell2d data loaded'
922 integer(I4B),
dimension(:),
intent(in) :: icelltype
924 integer(I4B) :: i, iunit, ntxt, version
925 integer(I4B),
parameter :: lentxt = 100
926 character(len=50) :: txthdr
927 character(len=lentxt) :: txt
928 character(len=LINELENGTH) :: fname
929 character(len=LENBIGLINE) :: crs
930 logical(LGP) :: found_crs
932 character(len=*),
parameter :: fmtgrdsave = &
933 "(4X,'BINARY GRID INFORMATION WILL BE WRITTEN TO:', &
934 &/,6X,'UNIT NUMBER: ', I0,/,6X, 'FILE NAME: ', A)"
939 if (this%nvert > 0) ntxt = ntxt + 5
941 call mem_set_value(crs,
'CRS', this%input_mempath, found_crs)
950 fname = trim(this%output_fname)
952 write (this%iout, fmtgrdsave) iunit, trim(adjustl(fname))
953 call openfile(iunit, this%iout, trim(adjustl(fname)),
'DATA(BINARY)', &
957 write (txthdr,
'(a)')
'GRID DISU'
958 txthdr(50:50) = new_line(
'a')
960 write (txthdr,
'(a)')
'VERSION 1'
961 txthdr(50:50) = new_line(
'a')
963 write (txthdr,
'(a, i0)')
'NTXT ', ntxt
964 txthdr(50:50) = new_line(
'a')
966 write (txthdr,
'(a, i0)')
'LENTXT ', lentxt
967 txthdr(50:50) = new_line(
'a')
971 write (txt,
'(3a, i0)')
'NODES ',
'INTEGER ',
'NDIM 0 # ', this%nodesuser
972 txt(lentxt:lentxt) = new_line(
'a')
974 write (txt,
'(3a, i0)')
'NJA ',
'INTEGER ',
'NDIM 0 # ', this%con%nja
975 txt(lentxt:lentxt) = new_line(
'a')
977 write (txt,
'(3a, 1pg24.15)')
'XORIGIN ',
'DOUBLE ',
'NDIM 0 # ', this%xorigin
978 txt(lentxt:lentxt) = new_line(
'a')
980 write (txt,
'(3a, 1pg24.15)')
'YORIGIN ',
'DOUBLE ',
'NDIM 0 # ', this%yorigin
981 txt(lentxt:lentxt) = new_line(
'a')
983 write (txt,
'(3a, 1pg24.15)')
'ANGROT ',
'DOUBLE ',
'NDIM 0 # ', this%angrot
984 txt(lentxt:lentxt) = new_line(
'a')
986 write (txt,
'(3a, i0)')
'TOP ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
987 txt(lentxt:lentxt) = new_line(
'a')
989 write (txt,
'(3a, i0)')
'BOT ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
990 txt(lentxt:lentxt) = new_line(
'a')
992 write (txt,
'(3a, i0)')
'IA ',
'INTEGER ',
'NDIM 1 ', this%nodesuser + 1
993 txt(lentxt:lentxt) = new_line(
'a')
995 write (txt,
'(3a, i0)')
'JA ',
'INTEGER ',
'NDIM 1 ', this%con%nja
996 txt(lentxt:lentxt) = new_line(
'a')
998 write (txt,
'(3a, i0)')
'IDOMAIN ',
'INTEGER ',
'NDIM 1 ', this%nodesuser
999 txt(lentxt:lentxt) = new_line(
'a')
1001 write (txt,
'(3a, i0)')
'ICELLTYPE ',
'INTEGER ',
'NDIM 1 ', this%nodesuser
1002 txt(lentxt:lentxt) = new_line(
'a')
1006 if (this%nvert > 0)
then
1007 write (txt,
'(3a, i0)')
'VERTICES ',
'DOUBLE ',
'NDIM 2 2 ', this%nvert
1008 txt(lentxt:lentxt) = new_line(
'a')
1010 write (txt,
'(3a, i0)')
'CELLX ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
1011 txt(lentxt:lentxt) = new_line(
'a')
1013 write (txt,
'(3a, i0)')
'CELLY ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
1014 txt(lentxt:lentxt) = new_line(
'a')
1016 write (txt,
'(3a, i0)')
'IAVERT ',
'INTEGER ',
'NDIM 1 ', this%nodesuser + 1
1017 txt(lentxt:lentxt) = new_line(
'a')
1019 write (txt,
'(3a, i0)')
'JAVERT ',
'INTEGER ',
'NDIM 1 ',
size(this%javert)
1020 txt(lentxt:lentxt) = new_line(
'a')
1025 if (version == 2)
then
1027 write (txt,
'(3a, i0)')
'CRS ',
'CHARACTER ',
'NDIM 1 ', &
1029 txt(lentxt:lentxt) = new_line(
'a')
1035 write (iunit) this%nodesuser
1036 write (iunit) this%nja
1037 write (iunit) this%xorigin
1038 write (iunit) this%yorigin
1039 write (iunit) this%angrot
1040 write (iunit) this%top1d
1041 write (iunit) this%bot1d
1042 write (iunit) this%con%iausr
1043 write (iunit) this%con%jausr
1044 write (iunit) this%idomain
1045 write (iunit) icelltype
1048 if (this%nvert > 0)
then
1049 write (iunit) this%vertices
1050 write (iunit) (this%cellxy(1, i), i=1, this%nodesuser)
1051 write (iunit) (this%cellxy(2, i), i=1, this%nodesuser)
1052 write (iunit) this%iavert
1053 write (iunit) this%javert
1057 if (version == 2)
then
1058 if (found_crs)
write (iunit) trim(crs)
1069 class(
disutype),
intent(in) :: this
1070 integer(I4B),
intent(in) :: nodeu
1071 integer(I4B),
intent(in) :: icheck
1072 integer(I4B) :: nodenumber
1074 if (icheck /= 0)
then
1075 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1076 write (
errmsg,
'(a,i0,a,i0,a)') &
1077 'Node number (', nodeu,
') is less than 1 or greater than nodes (', &
1078 this%nodesuser,
').'
1085 if (this%nodes == this%nodesuser)
then
1088 nodenumber = this%nodereduced(nodeu)
1101 integer(I4B),
intent(in) :: noden
1102 integer(I4B),
intent(in) :: nodem
1103 integer(I4B),
intent(in) :: ihc
1104 real(DP),
intent(inout) :: xcomp
1105 real(DP),
intent(inout) :: ycomp
1106 real(DP),
intent(inout) :: zcomp
1107 integer(I4B),
intent(in) :: ipos
1109 real(DP) :: angle, dmult
1117 if (nodem < noden)
then
1129 angle = this%con%anglex(this%con%jas(ipos))
1131 if (nodem < noden) dmult = -
done
1132 xcomp = cos(angle) * dmult
1133 ycomp = sin(angle) * dmult
1145 xcomp, ycomp, zcomp, conlen)
1148 integer(I4B),
intent(in) :: noden
1149 integer(I4B),
intent(in) :: nodem
1150 logical,
intent(in) :: nozee
1151 real(DP),
intent(in) :: satn
1152 real(DP),
intent(in) :: satm
1153 integer(I4B),
intent(in) :: ihc
1154 real(DP),
intent(inout) :: xcomp
1155 real(DP),
intent(inout) :: ycomp
1156 real(DP),
intent(inout) :: zcomp
1157 real(DP),
intent(inout) :: conlen
1159 real(DP) :: xn, xm, yn, ym, zn, zm
1163 if (
size(this%cellxy, 2) < 1)
then
1165 'Cannot calculate unit vector components for DISU grid if VERTEX '// &
1166 'data are not specified'
1180 zn = this%bot(noden) +
dhalf * (this%top(noden) - this%bot(noden))
1181 zm = this%bot(nodem) +
dhalf * (this%top(nodem) - this%bot(nodem))
1190 zn = this%bot(noden) +
dhalf * satn * (this%top(noden) - this%bot(noden))
1191 zm = this%bot(nodem) +
dhalf * satm * (this%top(nodem) - this%bot(nodem))
1205 class(
disutype),
intent(in) :: this
1206 character(len=*),
intent(out) :: dis_type
1215 class(
disutype),
intent(in) :: this
1216 integer(I4B) :: dis_enum
1225 character(len=*),
intent(in) :: name_model
1226 character(len=*),
intent(in) :: input_mempath
1229 call this%DisBaseType%allocate_scalars(name_model, input_mempath)
1232 call mem_allocate(this%njausr,
'NJAUSR', this%memoryPath)
1233 call mem_allocate(this%nvert,
'NVERT', this%memoryPath)
1234 call mem_allocate(this%voffsettol,
'VOFFSETTOL', this%memoryPath)
1235 call mem_allocate(this%iangledegx,
'IANGLEDEGX', this%memoryPath)
1241 this%voffsettol =
dzero
1243 this%readFromFile = .false.
1254 call this%DisBaseType%allocate_arrays()
1257 if (this%nodes < this%nodesuser)
then
1258 call mem_allocate(this%nodeuser, this%nodes,
'NODEUSER', this%memoryPath)
1259 call mem_allocate(this%nodereduced, this%nodesuser,
'NODEREDUCED', &
1262 call mem_allocate(this%nodeuser, 1,
'NODEUSER', this%memoryPath)
1263 call mem_allocate(this%nodereduced, 1,
'NODEREDUCED', this%memoryPath)
1267 this%mshape(1) = this%nodesuser
1279 call mem_allocate(this%idomain, this%nodes,
'IDOMAIN', this%memoryPath)
1280 call mem_allocate(this%vertices, 2, this%nvert,
'VERTICES', this%memoryPath)
1281 if (this%icondir > 0)
then
1282 call mem_allocate(this%cellxy, 2, this%nodes,
'CELLXY', this%memoryPath)
1284 call mem_allocate(this%cellxy, 2, 0,
'CELLXY', this%memoryPath)
1296 flag_string, allow_zero)
result(nodeu)
1299 integer(I4B),
intent(inout) :: lloc
1300 integer(I4B),
intent(inout) :: istart
1301 integer(I4B),
intent(inout) :: istop
1302 integer(I4B),
intent(in) :: in
1303 integer(I4B),
intent(in) :: iout
1304 character(len=*),
intent(inout) :: line
1305 logical,
optional,
intent(in) :: flag_string
1306 logical,
optional,
intent(in) :: allow_zero
1307 integer(I4B) :: nodeu
1309 integer(I4B) :: lloclocal, ndum, istat, n
1312 if (
present(flag_string))
then
1313 if (flag_string)
then
1316 call urword(line, lloclocal, istart, istop, 1, ndum, r, iout, in)
1317 read (line(istart:istop), *, iostat=istat) n
1318 if (istat /= 0)
then
1326 call urword(line, lloc, istart, istop, 2, nodeu, r, iout, in)
1328 if (nodeu == 0)
then
1329 if (
present(allow_zero))
then
1330 if (allow_zero)
then
1336 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1337 write (
errmsg,
'(a,i0,a)') &
1338 "Node number in list (", nodeu,
") is outside of the grid. "// &
1339 "Cell number cannot be determined in line '"// &
1340 trim(adjustl(line))//
"'."
1356 allow_zero)
result(nodeu)
1358 integer(I4B) :: nodeu
1361 character(len=*),
intent(inout) :: cellid
1362 integer(I4B),
intent(in) :: inunit
1363 integer(I4B),
intent(in) :: iout
1364 logical,
optional,
intent(in) :: flag_string
1365 logical,
optional,
intent(in) :: allow_zero
1367 integer(I4B) :: lloclocal, istart, istop, ndum, n
1368 integer(I4B) :: istat
1371 if (
present(flag_string))
then
1372 if (flag_string)
then
1375 call urword(cellid, lloclocal, istart, istop, 1, ndum, r, iout, inunit)
1376 read (cellid(istart:istop), *, iostat=istat) n
1377 if (istat /= 0)
then
1386 call urword(cellid, lloclocal, istart, istop, 2, nodeu, r, iout, inunit)
1388 if (nodeu == 0)
then
1389 if (
present(allow_zero))
then
1390 if (allow_zero)
then
1396 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1397 write (
errmsg,
'(a,i0,a)') &
1398 "Cell number cannot be determined for cellid ("// &
1399 trim(adjustl(cellid))//
") and results in a user "// &
1400 "node number (", nodeu,
") that is outside of the grid."
1434 class(
disutype),
intent(inout) :: this
1435 character(len=*),
intent(inout) :: line
1436 integer(I4B),
intent(inout) :: lloc
1437 integer(I4B),
intent(inout) :: istart
1438 integer(I4B),
intent(inout) :: istop
1439 integer(I4B),
intent(in) :: in
1440 integer(I4B),
intent(in) :: iout
1441 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(inout) :: iarray
1442 character(len=*),
intent(in) :: aname
1444 integer(I4B) :: nval
1445 integer(I4B),
dimension(:),
pointer,
contiguous :: itemp
1451 if (this%nodes < this%nodesuser)
then
1452 nval = this%nodesuser
1461 call readarray(in, itemp, aname, this%ndim, nval, iout, 0)
1464 if (this%nodes < this%nodesuser)
then
1465 call this%fill_grid_array(itemp, iarray)
1475 class(
disutype),
intent(inout) :: this
1476 character(len=*),
intent(inout) :: line
1477 integer(I4B),
intent(inout) :: lloc
1478 integer(I4B),
intent(inout) :: istart
1479 integer(I4B),
intent(inout) :: istop
1480 integer(I4B),
intent(in) :: in
1481 integer(I4B),
intent(in) :: iout
1482 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: darray
1483 character(len=*),
intent(in) :: aname
1485 integer(I4B) :: nval
1486 real(DP),
dimension(:),
pointer,
contiguous :: dtemp
1492 if (this%nodes < this%nodesuser)
then
1493 nval = this%nodesuser
1501 call readarray(in, dtemp, aname, this%ndim, nval, iout, 0)
1504 if (this%nodes < this%nodesuser)
then
1505 call this%fill_grid_array(dtemp, darray)
1516 cdatafmp, nvaluesp, nwidthp, editdesc, dinact)
1518 class(
disutype),
intent(inout) :: this
1519 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: darray
1520 integer(I4B),
intent(in) :: iout
1521 integer(I4B),
intent(in) :: iprint
1522 integer(I4B),
intent(in) :: idataun
1523 character(len=*),
intent(in) :: aname
1524 character(len=*),
intent(in) :: cdatafmp
1525 integer(I4B),
intent(in) :: nvaluesp
1526 integer(I4B),
intent(in) :: nwidthp
1527 character(len=*),
intent(in) :: editdesc
1528 real(DP),
intent(in) :: dinact
1530 integer(I4B) :: k, ifirst
1531 integer(I4B) :: nlay
1532 integer(I4B) :: nrow
1533 integer(I4B) :: ncol
1534 integer(I4B) :: nval
1535 integer(I4B) :: nodeu, noder
1536 integer(I4B) :: istart, istop
1537 real(DP),
dimension(:),
pointer,
contiguous :: dtemp
1539 character(len=*),
parameter :: fmthsv = &
1540 "(1X,/1X,a,' WILL BE SAVED ON UNIT ',I4, &
1541 &' AT END OF TIME STEP',I5,', STRESS PERIOD ',I4)"
1546 ncol = this%mshape(1)
1550 if (this%nodes < this%nodesuser)
then
1553 do nodeu = 1, this%nodesuser
1554 noder = this%get_nodenumber(nodeu, 0)
1555 if (noder <= 0)
then
1556 dtemp(nodeu) = dinact
1559 dtemp(nodeu) = darray(noder)
1567 if (iprint /= 0)
then
1570 istop = istart + nrow * ncol - 1
1572 aname, cdatafmp, nvaluesp, nwidthp, editdesc)
1578 if (idataun > 0)
then
1583 istop = istart + nrow * ncol - 1
1584 if (ifirst == 1)
write (iout, fmthsv) &
1585 trim(adjustl(aname)), idataun, &
1592 elseif (idataun < 0)
then
1595 call ubdsv1(
kstp,
kper, aname, -idataun, dtemp, ncol, nrow, nlay, &
1604 dstmodel, dstpackage, naux, auxtxt, &
1605 ibdchn, nlist, iout)
1608 character(len=16),
intent(in) :: text
1609 character(len=16),
intent(in) :: textmodel
1610 character(len=16),
intent(in) :: textpackage
1611 character(len=16),
intent(in) :: dstmodel
1612 character(len=16),
intent(in) :: dstpackage
1613 integer(I4B),
intent(in) :: naux
1614 character(len=16),
dimension(:),
intent(in) :: auxtxt
1615 integer(I4B),
intent(in) :: ibdchn
1616 integer(I4B),
intent(in) :: nlist
1617 integer(I4B),
intent(in) :: iout
1619 integer(I4B) :: nlay, nrow, ncol
1623 ncol = this%mshape(1)
1626 call ubdsv06(
kstp,
kper, text, textmodel, textpackage, dstmodel, dstpackage, &
1627 ibdchn, naux, auxtxt, ncol, nrow, nlay, &
1636 class(*),
pointer :: dis
subroutine, public iac_to_ia(iac, ia)
Convert an iac array into an ia array.
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lenbigline
maximum length of a big line
@ disu
DISV6 discretization.
integer(i4b), parameter lenvarname
maximum length of a variable name
real(dp), parameter dhalf
real constant 1/2
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenmempath
maximum length of the memory path
real(dp), parameter done
real constant 1
subroutine allocate_scalars(this, name_model, input_mempath)
Allocate and initialize scalar variables.
subroutine write_grb(this, icelltype)
Write a binary grid file.
subroutine allocate_arrays(this)
Allocate and initialize arrays.
subroutine disu_load(this)
Transfer IDM data into this discretization object.
subroutine source_connectivity(this)
Copy grid connectivity info from IDM into package.
subroutine, public disu_cr(dis, name_model, input_mempath, inunit, iout)
Create a new unstructured discretization object.
subroutine source_dimensions(this)
Copy dimensions from IDM into package.
subroutine source_options(this)
Copy options from IDM into package.
subroutine log_dimensions(this, found)
Write dimensions to list file.
subroutine disu_da(this)
Deallocate variables.
class(disutype) function, pointer, public castasdisutype(dis)
Cast base to DISU.
integer(i4b) function get_ncpl(this)
Get number of cells per layer (total nodes since DISU isn't layered)
subroutine define_cellverts(this, icell2d, ncvert, icvert)
Build data structures to hold cell vertex info.
subroutine read_dbl_array(this, line, lloc, istart, istop, iout, in, darray, aname)
Read a double precision array.
integer(i4b) function nodeu_from_cellid(this, cellid, inunit, iout, flag_string, allow_zero)
Convert a cellid string to a user nodenumber.
subroutine log_options(this, found)
Write user options to list file.
subroutine record_srcdst_list_header(this, text, textmodel, textpackage, dstmodel, dstpackage, naux, auxtxt, ibdchn, nlist, iout)
Record list header for imeth=6.
subroutine get_dis_type(this, dis_type)
Get the discretization type.
subroutine source_vertices(this)
Copy grid vertex data from IDM into package.
subroutine source_cell2d(this)
Copy cell2d data from IDM into package.
subroutine log_griddata(this, found)
Write griddata found to list file.
subroutine allocate_arrays_mem(this)
Allocate arrays in memory manager.
subroutine source_griddata(this)
Copy grid data from IDM into package.
subroutine nodeu_to_array(this, nodeu, arr)
Convert a user nodenumber to an array (nodenumber)
subroutine connection_vector(this, noden, nodem, nozee, satn, satm, ihc, xcomp, ycomp, zcomp, conlen)
Get unit vector components between the cell and a given neighbor.
subroutine record_array(this, darray, iout, iprint, idataun, aname, cdatafmp, nvaluesp, nwidthp, editdesc, dinact)
Record a double precision array.
subroutine disu_df(this)
Define the discretization.
logical function supports_layers(this)
Indicates whether the grid discretization supports layers.
subroutine read_int_array(this, line, lloc, istart, istop, iout, in, iarray, aname)
Read an integer array.
subroutine grid_finalize(this)
Finalize the grid.
integer(i4b) function get_nodenumber_idx1(this, nodeu, icheck)
Get reduced node number from user node number.
subroutine nodeu_to_string(this, nodeu, str)
Convert a user nodenumber to a string (nodenumber)
integer(i4b) function nodeu_from_string(this, lloc, istart, istop, in, iout, line, flag_string, allow_zero)
Convert a string to a user nodenumber.
subroutine disu_ck(this)
Check discretization info.
integer(i4b) function get_dis_enum(this)
Get the discretization type enumeration.
subroutine log_connectivity(this, found, iac)
Write griddata found to list file.
subroutine connection_normal(this, noden, nodem, ihc, xcomp, ycomp, zcomp, ipos)
Get normal vector components between the cell and a given neighbor.
subroutine, public line_unit_vector(x0, y0, z0, x1, y1, z1, xcomp, ycomp, zcomp, vmag)
Calculate the vector components (xcomp, ycomp, and zcomp) for a line defined by two points,...
This module defines variable data types.
subroutine, public memorystore_remove(component, subcomponent, context)
subroutine, public memorystore_release(varname, memory_path)
Release a single variable from the memory store.
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
integer(i4b) function, public count_errors()
Return number of errors.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
real(dp), pointer, public pertim
time relative to start of stress period
real(dp), pointer, public totim
time relative to start of simulation
integer(i4b), pointer, public kstp
current time step number
integer(i4b), pointer, public kper
current stress period number
real(dp), pointer, public delt
length of the current time step
Unstructured grid discretization.