29 integer(I4B),
pointer :: njausr => null()
30 integer(I4B),
pointer :: nvert => null()
31 real(dp),
pointer :: voffsettol => null()
32 real(dp),
dimension(:, :),
pointer,
contiguous :: vertices => null()
33 real(dp),
dimension(:, :),
pointer,
contiguous :: cellxy => null()
34 real(dp),
dimension(:),
pointer,
contiguous :: top1d => null()
35 real(dp),
dimension(:),
pointer,
contiguous :: bot1d => null()
36 real(dp),
dimension(:),
pointer,
contiguous :: area1d => null()
37 integer(I4B),
dimension(:),
pointer,
contiguous :: iainp => null()
38 integer(I4B),
dimension(:),
pointer,
contiguous :: jainp => null()
39 integer(I4B),
dimension(:),
pointer,
contiguous :: ihcinp => null()
40 real(dp),
dimension(:),
pointer,
contiguous :: cl12inp => null()
41 real(dp),
dimension(:),
pointer,
contiguous :: hwvainp => null()
42 real(dp),
dimension(:),
pointer,
contiguous :: angldegxinp => null()
43 integer(I4B),
pointer :: iangledegx => null()
44 integer(I4B),
dimension(:),
pointer,
contiguous :: iavert => null()
45 integer(I4B),
dimension(:),
pointer,
contiguous :: javert => null()
46 integer(I4B),
dimension(:),
pointer,
contiguous :: idomain => null()
47 logical(LGP) :: readfromfile
93 logical :: length_units = .false.
94 logical :: nogrb = .false.
95 logical :: xorigin = .false.
96 logical :: yorigin = .false.
97 logical :: angrot = .false.
98 logical :: voffsettol = .false.
99 logical :: nodes = .false.
100 logical :: nja = .false.
101 logical :: nvert = .false.
102 logical :: top = .false.
103 logical :: bot = .false.
104 logical :: area = .false.
105 logical :: idomain = .false.
106 logical :: iac = .false.
107 logical :: ja = .false.
108 logical :: ihc = .false.
109 logical :: cl12 = .false.
110 logical :: hwva = .false.
111 logical :: angldegx = .false.
112 logical :: iv = .false.
113 logical :: xv = .false.
114 logical :: yv = .false.
115 logical :: icell2d = .false.
116 logical :: xc = .false.
117 logical :: yc = .false.
118 logical :: ncvert = .false.
119 logical :: icvert = .false.
126 subroutine disu_cr(dis, name_model, input_mempath, inunit, iout)
129 character(len=*),
intent(in) :: name_model
130 character(len=*),
intent(in) :: input_mempath
131 integer(I4B),
intent(in) :: inunit
132 integer(I4B),
intent(in) :: iout
135 character(len=*),
parameter :: fmtheader = &
136 "(1X, /1X, 'DISU -- UNSTRUCTURED GRID DISCRETIZATION PACKAGE,', &
137 &' VERSION 2 : 3/27/2014 - INPUT READ FROM MEMPATH: ', A, //)"
144 call dis%allocate_scalars(name_model, input_mempath)
153 write (iout, fmtheader) dis%input_mempath
157 call disnew%disu_load()
169 call this%source_options()
170 call this%source_dimensions()
171 call this%source_griddata()
172 call this%source_connectivity()
175 if (this%nvert > 0)
then
176 call this%source_vertices()
177 call this%source_cell2d()
195 call this%grid_finalize()
207 integer(I4B) :: noder
208 integer(I4B) :: nrsize
210 character(len=*),
parameter :: fmtdz = &
211 "('CELL (',i0,',',i0,',',i0,') THICKNESS <= 0. ', &
212 &'TOP, BOT: ',2(1pg24.15))"
213 character(len=*),
parameter :: fmtnr = &
214 "(/1x, 'The specified IDOMAIN results in a reduced number of cells.',&
215 &/1x, 'Number of user nodes: ',I0,&
216 &/1X, 'Number of nodes in solution: ', I0, //)"
220 do n = 1, this%nodesuser
221 if (this%idomain(n) > 0) this%nodes = this%nodes + 1
225 if (this%nodes == 0)
then
226 call store_error(
'Model does not have any active nodes. &
227 &Ensure IDOMAIN array has some values greater &
233 if (this%nodes < this%nodesuser)
then
234 write (this%iout, fmtnr) this%nodesuser, this%nodes
238 call this%allocate_arrays()
244 if (this%nodes < this%nodesuser)
then
246 do node = 1, this%nodesuser
247 if (this%idomain(node) > 0)
then
248 this%nodereduced(node) = noder
250 elseif (this%idomain(node) < 0)
then
251 this%nodereduced(node) = -1
253 this%nodereduced(node) = 0
259 if (this%nodes < this%nodesuser)
then
261 do node = 1, this%nodesuser
262 if (this%idomain(node) > 0)
then
263 this%nodeuser(noder) = node
270 do node = 1, this%nodesuser
272 if (this%nodes < this%nodesuser) noder = this%nodereduced(node)
273 if (noder <= 0) cycle
274 this%top(noder) = this%top1d(node)
275 this%bot(noder) = this%bot1d(node)
276 this%area(noder) = this%area1d(node)
280 if (this%nvert > 0)
then
281 do node = 1, this%nodesuser
283 if (this%nodes < this%nodesuser) noder = this%nodereduced(node)
284 if (noder <= 0) cycle
285 this%xc(noder) = this%cellxy(1, node)
286 this%yc(noder) = this%cellxy(2, node)
295 if (this%nodes < this%nodesuser) nrsize = this%nodes
297 call this%con%disuconnections(this%name_model, this%nodes, &
298 this%nodesuser, nrsize, &
299 this%nodereduced, this%nodeuser, &
300 this%iainp, this%jainp, &
301 this%ihcinp, this%cl12inp, &
302 this%hwvainp, this%angldegxinp, &
304 this%nja = this%con%nja
305 this%njas = this%con%njas
320 character(len=*),
parameter :: fmtidm = &
321 &
"('Invalid idomain value ', i0, ' specified for node ', i0)"
322 character(len=*),
parameter :: fmtdz = &
323 &
"('Cell ', i0, ' with thickness <= 0. Top, bot: ', 2(1pg24.15))"
324 character(len=*),
parameter :: fmtarea = &
325 &
"('Cell ', i0, ' with area <= 0. Area: ', 1(1pg24.15))"
326 character(len=*),
parameter :: fmtjan = &
327 &
"('Cell ', i0, ' must have its first connection be itself. Found: ', i0)"
328 character(len=*),
parameter :: fmtjam = &
329 &
"('Cell ', i0, ' has invalid connection in JA. Found: ', i0)"
330 character(len=*),
parameter :: fmterrmsg = &
331 "('Top elevation (', 1pg15.6, ') for cell ', i0, ' is above bottom &
332 &elevation (', 1pg15.6, ') for cell ', i0, '. Based on node numbering &
333 &rules cell ', i0, ' must be below cell ', i0, '.')"
336 do n = 1, this%nodesuser
347 write (
errmsg, fmtjan) n, m
352 do ipos = this%iainp(n) + 1, this%iainp(n + 1) - 1
354 if (m < 0 .or. m > this%nodesuser)
then
356 write (
errmsg, fmtjam) n, m
364 if (this%inunit > 0)
then
370 do n = 1, this%nodesuser
371 if (this%idomain(n) > 1 .or. this%idomain(n) < 0)
then
372 write (
errmsg, fmtidm) this%idomain(n), n
379 do n = 1, this%nodesuser
380 if (this%idomain(n) == 1)
then
381 dz = this%top1d(n) - this%bot1d(n)
382 if (dz <=
dzero)
then
383 write (
errmsg, fmt=fmtdz) n, this%top1d(n), this%bot1d(n)
386 if (this%area1d(n) <=
dzero)
then
387 write (
errmsg, fmt=fmtarea) n, this%area1d(n)
394 if (this%voffsettol <
dzero)
then
395 write (
errmsg,
'(a, 1pg15.6)') &
396 'Vertical offset tolerance must be greater than zero. Found ', &
399 if (this%inunit > 0)
then
406 do n = 1, this%nodesuser
407 do ipos = this%iainp(n) + 1, this%iainp(n + 1) - 1
409 ihc = this%ihcinp(ipos)
410 if (ihc == 0 .and. m > n)
then
411 dz = this%top1d(m) - this%bot1d(n)
412 if (dz > this%voffsettol)
then
413 write (
errmsg, fmterrmsg) this%top1d(m), m, this%bot1d(n), n, m, n
422 if (this%inunit > 0)
then
447 if (this%readFromFile)
then
451 if (
associated(this%iavert))
then
471 call this%DisBaseType%dis_da()
480 integer(I4B),
intent(in) :: nodeu
481 character(len=*),
intent(inout) :: str
483 character(len=10) :: nstr
485 write (nstr,
'(i0)') nodeu
486 str =
'('//trim(adjustl(nstr))//
')'
494 integer(I4B),
intent(in) :: nodeu
495 integer(I4B),
dimension(:),
intent(inout) :: arr
497 integer(I4B) :: isize
501 if (isize /= this%ndim)
then
502 write (
errmsg,
'(a,i0,a,i0,a)') &
503 'Program error: nodeu_to_array size of array (', isize, &
504 ') is not equal to the discretization dimension (', this%ndim,
')'
519 character(len=LENVARNAME),
dimension(3) :: lenunits = &
520 &[character(len=LENVARNAME) ::
'FEET',
'METERS',
'CENTIMETERS']
524 call mem_set_value(this%lenuni,
'LENGTH_UNITS', this%input_mempath, &
525 lenunits, found%length_units)
526 call mem_set_value(this%nogrb,
'NOGRB', this%input_mempath, found%nogrb)
527 call mem_set_value(this%xorigin,
'XORIGIN', this%input_mempath, found%xorigin)
528 call mem_set_value(this%yorigin,
'YORIGIN', this%input_mempath, found%yorigin)
529 call mem_set_value(this%angrot,
'ANGROT', this%input_mempath, found%angrot)
530 call mem_set_value(this%voffsettol,
'VOFFSETTOL', this%input_mempath, &
534 if (this%iout > 0)
then
535 call this%log_options(found)
547 write (this%iout,
'(1x,a)')
'Setting Discretization Options'
549 if (found%length_units)
then
550 write (this%iout,
'(4x,a,i0)')
'Model length unit [0=UND, 1=FEET, &
551 &2=METERS, 3=CENTIMETERS] set as ', this%lenuni
554 if (found%nogrb)
then
555 write (this%iout,
'(4x,a,i0)')
'Binary grid file [0=GRB, 1=NOGRB] &
556 &set as ', this%nogrb
559 if (found%xorigin)
then
560 write (this%iout,
'(4x,a,G0)')
'XORIGIN = ', this%xorigin
563 if (found%yorigin)
then
564 write (this%iout,
'(4x,a,G0)')
'YORIGIN = ', this%yorigin
567 if (found%angrot)
then
568 write (this%iout,
'(4x,a,G0)')
'ANGROT = ', this%angrot
571 if (found%voffsettol)
then
572 write (this%iout,
'(4x,a,G0)')
'VERTICAL_OFFSET_TOLERANCE = ', &
576 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Options'
590 call mem_set_value(this%nodesuser,
'NODES', this%input_mempath, found%nodes)
591 call mem_set_value(this%njausr,
'NJA', this%input_mempath, found%nja)
592 call mem_set_value(this%nvert,
'NVERT', this%input_mempath, found%nvert)
595 if (this%iout > 0)
then
596 call this%log_dimensions(found)
600 if (this%nodesuser < 1)
then
602 'NODES was not specified or was specified incorrectly.')
604 if (this%njausr < 1)
then
606 'NJA was not specified or was specified incorrectly.')
615 this%readFromFile = .true.
616 call mem_allocate(this%top1d, this%nodesuser,
'TOP1D', this%memoryPath)
617 call mem_allocate(this%bot1d, this%nodesuser,
'BOT1D', this%memoryPath)
618 call mem_allocate(this%area1d, this%nodesuser,
'AREA1D', this%memoryPath)
619 call mem_allocate(this%idomain, this%nodesuser,
'IDOMAIN', this%memoryPath)
620 call mem_allocate(this%vertices, 2, this%nvert,
'VERTICES', this%memoryPath)
621 call mem_allocate(this%iainp, this%nodesuser + 1,
'IAINP', this%memoryPath)
622 call mem_allocate(this%jainp, this%njausr,
'JAINP', this%memoryPath)
623 call mem_allocate(this%ihcinp, this%njausr,
'IHCINP', this%memoryPath)
624 call mem_allocate(this%cl12inp, this%njausr,
'CL12INP', this%memoryPath)
625 call mem_allocate(this%hwvainp, this%njausr,
'HWVAINP', this%memoryPath)
626 call mem_allocate(this%angldegxinp, this%njausr,
'ANGLDEGXINP', &
628 if (this%nvert > 0)
then
629 call mem_allocate(this%cellxy, 2, this%nodesuser,
'CELLXY', this%memoryPath)
631 call mem_allocate(this%cellxy, 2, 0,
'CELLXY', this%memoryPath)
635 do n = 1, this%nodesuser
647 write (this%iout,
'(1x,a)')
'Setting Discretization Dimensions'
649 if (found%nodes)
then
650 write (this%iout,
'(4x,a,i0)')
'NODES = ', this%nodesuser
654 write (this%iout,
'(4x,a,i0)')
'NJA = ', this%njausr
657 if (found%nvert)
then
658 write (this%iout,
'(4x,a,i0)')
'NVERT = ', this%nvert
661 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Dimensions'
674 call mem_set_value(this%top1d,
'TOP', this%input_mempath, found%top)
675 call mem_set_value(this%bot1d,
'BOT', this%input_mempath, found%bot)
676 call mem_set_value(this%area1d,
'AREA', this%input_mempath, found%area)
677 call mem_set_value(this%idomain,
'IDOMAIN', this%input_mempath, found%idomain)
680 if (this%iout > 0)
then
681 call this%log_griddata(found)
693 write (this%iout,
'(1x,a)')
'Setting Discretization Griddata'
696 write (this%iout,
'(4x,a)')
'TOP set from input file'
700 write (this%iout,
'(4x,a)')
'BOT set from input file'
704 write (this%iout,
'(4x,a)')
'AREA set from input file'
707 if (found%idomain)
then
708 write (this%iout,
'(4x,a)')
'IDOMAIN set from input file'
711 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Griddata'
722 integer(I4B),
dimension(:),
contiguous,
pointer :: iac => null()
726 call mem_set_value(this%jainp,
'JA', this%input_mempath, found%ja)
727 call mem_set_value(this%ihcinp,
'IHC', this%input_mempath, found%ihc)
728 call mem_set_value(this%cl12inp,
'CL12', this%input_mempath, found%cl12)
729 call mem_set_value(this%hwvainp,
'HWVA', this%input_mempath, found%hwva)
730 call mem_set_value(this%angldegxinp,
'ANGLDEGX', this%input_mempath, &
734 call mem_setptr(iac,
'IAC', this%input_mempath)
737 if (
associated(iac))
call iac_to_ia(iac, this%iainp)
740 if (found%angldegx) this%iangledegx = 1
743 if (this%iout > 0)
then
744 call this%log_connectivity(found, iac)
754 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: iac
756 write (this%iout,
'(1x,a)')
'Setting Discretization Connectivity'
758 if (
associated(iac))
then
759 write (this%iout,
'(4x,a)')
'IAC set from input file'
763 write (this%iout,
'(4x,a)')
'JA set from input file'
767 write (this%iout,
'(4x,a)')
'IHC set from input file'
771 write (this%iout,
'(4x,a)')
'CL12 set from input file'
775 write (this%iout,
'(4x,a)')
'HWVA set from input file'
778 if (found%angldegx)
then
779 write (this%iout,
'(4x,a)')
'ANGLDEGX set from input file'
782 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Connectivity'
793 real(DP),
dimension(:),
contiguous,
pointer :: vert_x => null()
794 real(DP),
dimension(:),
contiguous,
pointer :: vert_y => null()
798 call mem_setptr(vert_x,
'XV', this%input_mempath)
799 call mem_setptr(vert_y,
'YV', this%input_mempath)
802 if (
associated(vert_x) .and.
associated(vert_y))
then
804 this%vertices(1, i) = vert_x(i)
805 this%vertices(2, i) = vert_y(i)
808 call store_error(
'Required Vertex arrays not found.')
812 if (this%iout > 0)
then
813 write (this%iout,
'(1x,a)')
'Discretization Vertex data loaded'
825 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: icell2d
826 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: ncvert
827 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: icvert
830 integer(I4B) :: i, j, ierr
831 integer(I4B) :: icv_idx, startvert, maxnnz = 5
834 call vert_spm%init(this%nodesuser, this%nvert, maxnnz)
838 do i = 1, this%nodesuser
839 if (icell2d(i) /= i)
call store_error(
'ICELL2D input sequence violation.')
841 call vert_spm%addconnection(i, icvert(icv_idx), 0)
843 startvert = icvert(icv_idx)
844 elseif (j == ncvert(i) .and. (icvert(icv_idx) /= startvert))
then
845 call vert_spm%addconnection(i, startvert, 0)
847 icv_idx = icv_idx + 1
852 call mem_allocate(this%iavert, this%nodesuser + 1,
'IAVERT', this%memoryPath)
853 call mem_allocate(this%javert, vert_spm%nnz,
'JAVERT', this%memoryPath)
854 call vert_spm%filliaja(this%iavert, this%javert, ierr)
855 call vert_spm%destroy()
865 integer(I4B),
dimension(:),
contiguous,
pointer :: icell2d => null()
866 integer(I4B),
dimension(:),
contiguous,
pointer :: ncvert => null()
867 integer(I4B),
dimension(:),
contiguous,
pointer :: icvert => null()
868 real(DP),
dimension(:),
contiguous,
pointer :: cell_x => null()
869 real(DP),
dimension(:),
contiguous,
pointer :: cell_y => null()
873 call mem_setptr(icell2d,
'ICELL2D', this%input_mempath)
874 call mem_setptr(ncvert,
'NCVERT', this%input_mempath)
875 call mem_setptr(icvert,
'ICVERT', this%input_mempath)
878 if (
associated(icell2d) .and.
associated(ncvert) &
879 .and.
associated(icvert))
then
880 call this%define_cellverts(icell2d, ncvert, icvert)
882 call store_error(
'Required cell vertex arrays not found.')
886 call mem_setptr(cell_x,
'XC', this%input_mempath)
887 call mem_setptr(cell_y,
'YC', this%input_mempath)
890 if (
associated(cell_x) .and.
associated(cell_y))
then
891 do i = 1, this%nodesuser
892 this%cellxy(1, i) = cell_x(i)
893 this%cellxy(2, i) = cell_y(i)
896 call store_error(
'Required cell center arrays not found.')
900 if (this%iout > 0)
then
901 write (this%iout,
'(1x,a)')
'Discretization Cell2d data loaded'
914 integer(I4B),
dimension(:),
intent(in) :: icelltype
916 integer(I4B) :: i, iunit, ntxt, version
917 integer(I4B),
parameter :: lentxt = 100
918 character(len=50) :: txthdr
919 character(len=lentxt) :: txt
920 character(len=LINELENGTH) :: fname
921 character(len=LENBIGLINE) :: crs
922 logical(LGP) :: found_crs
924 character(len=*),
parameter :: fmtgrdsave = &
925 "(4X,'BINARY GRID INFORMATION WILL BE WRITTEN TO:', &
926 &/,6X,'UNIT NUMBER: ', I0,/,6X, 'FILE NAME: ', A)"
931 if (this%nvert > 0) ntxt = ntxt + 5
933 call mem_set_value(crs,
'CRS', this%input_mempath, found_crs)
942 fname = trim(this%output_fname)
944 write (this%iout, fmtgrdsave) iunit, trim(adjustl(fname))
945 call openfile(iunit, this%iout, trim(adjustl(fname)),
'DATA(BINARY)', &
949 write (txthdr,
'(a)')
'GRID DISU'
950 txthdr(50:50) = new_line(
'a')
952 write (txthdr,
'(a)')
'VERSION 1'
953 txthdr(50:50) = new_line(
'a')
955 write (txthdr,
'(a, i0)')
'NTXT ', ntxt
956 txthdr(50:50) = new_line(
'a')
958 write (txthdr,
'(a, i0)')
'LENTXT ', lentxt
959 txthdr(50:50) = new_line(
'a')
963 write (txt,
'(3a, i0)')
'NODES ',
'INTEGER ',
'NDIM 0 # ', this%nodesuser
964 txt(lentxt:lentxt) = new_line(
'a')
966 write (txt,
'(3a, i0)')
'NJA ',
'INTEGER ',
'NDIM 0 # ', this%con%nja
967 txt(lentxt:lentxt) = new_line(
'a')
969 write (txt,
'(3a, 1pg24.15)')
'XORIGIN ',
'DOUBLE ',
'NDIM 0 # ', this%xorigin
970 txt(lentxt:lentxt) = new_line(
'a')
972 write (txt,
'(3a, 1pg24.15)')
'YORIGIN ',
'DOUBLE ',
'NDIM 0 # ', this%yorigin
973 txt(lentxt:lentxt) = new_line(
'a')
975 write (txt,
'(3a, 1pg24.15)')
'ANGROT ',
'DOUBLE ',
'NDIM 0 # ', this%angrot
976 txt(lentxt:lentxt) = new_line(
'a')
978 write (txt,
'(3a, i0)')
'TOP ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
979 txt(lentxt:lentxt) = new_line(
'a')
981 write (txt,
'(3a, i0)')
'BOT ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
982 txt(lentxt:lentxt) = new_line(
'a')
984 write (txt,
'(3a, i0)')
'IA ',
'INTEGER ',
'NDIM 1 ', this%nodesuser + 1
985 txt(lentxt:lentxt) = new_line(
'a')
987 write (txt,
'(3a, i0)')
'JA ',
'INTEGER ',
'NDIM 1 ', this%con%nja
988 txt(lentxt:lentxt) = new_line(
'a')
990 write (txt,
'(3a, i0)')
'IDOMAIN ',
'INTEGER ',
'NDIM 1 ', this%nodesuser
991 txt(lentxt:lentxt) = new_line(
'a')
993 write (txt,
'(3a, i0)')
'ICELLTYPE ',
'INTEGER ',
'NDIM 1 ', this%nodesuser
994 txt(lentxt:lentxt) = new_line(
'a')
998 if (this%nvert > 0)
then
999 write (txt,
'(3a, i0)')
'VERTICES ',
'DOUBLE ',
'NDIM 2 2 ', this%nvert
1000 txt(lentxt:lentxt) = new_line(
'a')
1002 write (txt,
'(3a, i0)')
'CELLX ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
1003 txt(lentxt:lentxt) = new_line(
'a')
1005 write (txt,
'(3a, i0)')
'CELLY ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
1006 txt(lentxt:lentxt) = new_line(
'a')
1008 write (txt,
'(3a, i0)')
'IAVERT ',
'INTEGER ',
'NDIM 1 ', this%nodesuser + 1
1009 txt(lentxt:lentxt) = new_line(
'a')
1011 write (txt,
'(3a, i0)')
'JAVERT ',
'INTEGER ',
'NDIM 1 ',
size(this%javert)
1012 txt(lentxt:lentxt) = new_line(
'a')
1017 if (version == 2)
then
1019 write (txt,
'(3a, i0)')
'CRS ',
'CHARACTER ',
'NDIM 1 ', &
1021 txt(lentxt:lentxt) = new_line(
'a')
1027 write (iunit) this%nodesuser
1028 write (iunit) this%nja
1029 write (iunit) this%xorigin
1030 write (iunit) this%yorigin
1031 write (iunit) this%angrot
1032 write (iunit) this%top1d
1033 write (iunit) this%bot1d
1034 write (iunit) this%con%iausr
1035 write (iunit) this%con%jausr
1036 write (iunit) this%idomain
1037 write (iunit) icelltype
1040 if (this%nvert > 0)
then
1041 write (iunit) this%vertices
1042 write (iunit) (this%cellxy(1, i), i=1, this%nodesuser)
1043 write (iunit) (this%cellxy(2, i), i=1, this%nodesuser)
1044 write (iunit) this%iavert
1045 write (iunit) this%javert
1049 if (version == 2)
then
1050 if (found_crs)
write (iunit) trim(crs)
1061 class(
disutype),
intent(in) :: this
1062 integer(I4B),
intent(in) :: nodeu
1063 integer(I4B),
intent(in) :: icheck
1064 integer(I4B) :: nodenumber
1066 if (icheck /= 0)
then
1067 if (nodeu < 1 .or. nodeu > this%nodes)
then
1068 write (
errmsg,
'(a,i0,a,i0,a)') &
1069 'Node number (', nodeu,
') is less than 1 or greater than nodes (', &
1077 if (this%nodes == this%nodesuser)
then
1080 nodenumber = this%nodereduced(nodeu)
1093 integer(I4B),
intent(in) :: noden
1094 integer(I4B),
intent(in) :: nodem
1095 integer(I4B),
intent(in) :: ihc
1096 real(DP),
intent(inout) :: xcomp
1097 real(DP),
intent(inout) :: ycomp
1098 real(DP),
intent(inout) :: zcomp
1099 integer(I4B),
intent(in) :: ipos
1101 real(DP) :: angle, dmult
1109 if (nodem < noden)
then
1121 angle = this%con%anglex(this%con%jas(ipos))
1123 if (nodem < noden) dmult = -
done
1124 xcomp = cos(angle) * dmult
1125 ycomp = sin(angle) * dmult
1137 xcomp, ycomp, zcomp, conlen)
1140 integer(I4B),
intent(in) :: noden
1141 integer(I4B),
intent(in) :: nodem
1142 logical,
intent(in) :: nozee
1143 real(DP),
intent(in) :: satn
1144 real(DP),
intent(in) :: satm
1145 integer(I4B),
intent(in) :: ihc
1146 real(DP),
intent(inout) :: xcomp
1147 real(DP),
intent(inout) :: ycomp
1148 real(DP),
intent(inout) :: zcomp
1149 real(DP),
intent(inout) :: conlen
1151 real(DP) :: xn, xm, yn, ym, zn, zm
1155 if (
size(this%cellxy, 2) < 1)
then
1157 'Cannot calculate unit vector components for DISU grid if VERTEX '// &
1158 'data are not specified'
1172 zn = this%bot(noden) +
dhalf * (this%top(noden) - this%bot(noden))
1173 zm = this%bot(nodem) +
dhalf * (this%top(nodem) - this%bot(nodem))
1182 zn = this%bot(noden) +
dhalf * satn * (this%top(noden) - this%bot(noden))
1183 zm = this%bot(nodem) +
dhalf * satm * (this%top(nodem) - this%bot(nodem))
1197 class(
disutype),
intent(in) :: this
1198 character(len=*),
intent(out) :: dis_type
1207 class(
disutype),
intent(in) :: this
1208 integer(I4B) :: dis_enum
1217 character(len=*),
intent(in) :: name_model
1218 character(len=*),
intent(in) :: input_mempath
1221 call this%DisBaseType%allocate_scalars(name_model, input_mempath)
1224 call mem_allocate(this%njausr,
'NJAUSR', this%memoryPath)
1225 call mem_allocate(this%nvert,
'NVERT', this%memoryPath)
1226 call mem_allocate(this%voffsettol,
'VOFFSETTOL', this%memoryPath)
1227 call mem_allocate(this%iangledegx,
'IANGLEDEGX', this%memoryPath)
1233 this%voffsettol =
dzero
1235 this%readFromFile = .false.
1246 call this%DisBaseType%allocate_arrays()
1249 if (this%nodes < this%nodesuser)
then
1250 call mem_allocate(this%nodeuser, this%nodes,
'NODEUSER', this%memoryPath)
1251 call mem_allocate(this%nodereduced, this%nodesuser,
'NODEREDUCED', &
1254 call mem_allocate(this%nodeuser, 1,
'NODEUSER', this%memoryPath)
1255 call mem_allocate(this%nodereduced, 1,
'NODEREDUCED', this%memoryPath)
1259 this%mshape(1) = this%nodesuser
1271 call mem_allocate(this%idomain, this%nodes,
'IDOMAIN', this%memoryPath)
1272 call mem_allocate(this%vertices, 2, this%nvert,
'VERTICES', this%memoryPath)
1273 call mem_allocate(this%cellxy, 2, this%nodes,
'CELLXY', this%memoryPath)
1284 flag_string, allow_zero)
result(nodeu)
1287 integer(I4B),
intent(inout) :: lloc
1288 integer(I4B),
intent(inout) :: istart
1289 integer(I4B),
intent(inout) :: istop
1290 integer(I4B),
intent(in) :: in
1291 integer(I4B),
intent(in) :: iout
1292 character(len=*),
intent(inout) :: line
1293 logical,
optional,
intent(in) :: flag_string
1294 logical,
optional,
intent(in) :: allow_zero
1295 integer(I4B) :: nodeu
1297 integer(I4B) :: lloclocal, ndum, istat, n
1300 if (
present(flag_string))
then
1301 if (flag_string)
then
1304 call urword(line, lloclocal, istart, istop, 1, ndum, r, iout, in)
1305 read (line(istart:istop), *, iostat=istat) n
1306 if (istat /= 0)
then
1314 call urword(line, lloc, istart, istop, 2, nodeu, r, iout, in)
1316 if (nodeu == 0)
then
1317 if (
present(allow_zero))
then
1318 if (allow_zero)
then
1324 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1325 write (
errmsg,
'(a,i0,a)') &
1326 "Node number in list (", nodeu,
") is outside of the grid. "// &
1327 "Cell number cannot be determined in line '"// &
1328 trim(adjustl(line))//
"'."
1344 allow_zero)
result(nodeu)
1346 integer(I4B) :: nodeu
1349 character(len=*),
intent(inout) :: cellid
1350 integer(I4B),
intent(in) :: inunit
1351 integer(I4B),
intent(in) :: iout
1352 logical,
optional,
intent(in) :: flag_string
1353 logical,
optional,
intent(in) :: allow_zero
1355 integer(I4B) :: lloclocal, istart, istop, ndum, n
1356 integer(I4B) :: istat
1359 if (
present(flag_string))
then
1360 if (flag_string)
then
1363 call urword(cellid, lloclocal, istart, istop, 1, ndum, r, iout, inunit)
1364 read (cellid(istart:istop), *, iostat=istat) n
1365 if (istat /= 0)
then
1374 call urword(cellid, lloclocal, istart, istop, 2, nodeu, r, iout, inunit)
1376 if (nodeu == 0)
then
1377 if (
present(allow_zero))
then
1378 if (allow_zero)
then
1384 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1385 write (
errmsg,
'(a,i0,a)') &
1386 "Cell number cannot be determined for cellid ("// &
1387 trim(adjustl(cellid))//
") and results in a user "// &
1388 "node number (", nodeu,
") that is outside of the grid."
1422 class(
disutype),
intent(inout) :: this
1423 character(len=*),
intent(inout) :: line
1424 integer(I4B),
intent(inout) :: lloc
1425 integer(I4B),
intent(inout) :: istart
1426 integer(I4B),
intent(inout) :: istop
1427 integer(I4B),
intent(in) :: in
1428 integer(I4B),
intent(in) :: iout
1429 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(inout) :: iarray
1430 character(len=*),
intent(in) :: aname
1432 integer(I4B) :: nval
1433 integer(I4B),
dimension(:),
pointer,
contiguous :: itemp
1439 if (this%nodes < this%nodesuser)
then
1440 nval = this%nodesuser
1449 call readarray(in, itemp, aname, this%ndim, nval, iout, 0)
1452 if (this%nodes < this%nodesuser)
then
1453 call this%fill_grid_array(itemp, iarray)
1463 class(
disutype),
intent(inout) :: this
1464 character(len=*),
intent(inout) :: line
1465 integer(I4B),
intent(inout) :: lloc
1466 integer(I4B),
intent(inout) :: istart
1467 integer(I4B),
intent(inout) :: istop
1468 integer(I4B),
intent(in) :: in
1469 integer(I4B),
intent(in) :: iout
1470 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: darray
1471 character(len=*),
intent(in) :: aname
1473 integer(I4B) :: nval
1474 real(DP),
dimension(:),
pointer,
contiguous :: dtemp
1480 if (this%nodes < this%nodesuser)
then
1481 nval = this%nodesuser
1489 call readarray(in, dtemp, aname, this%ndim, nval, iout, 0)
1492 if (this%nodes < this%nodesuser)
then
1493 call this%fill_grid_array(dtemp, darray)
1504 cdatafmp, nvaluesp, nwidthp, editdesc, dinact)
1506 class(
disutype),
intent(inout) :: this
1507 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: darray
1508 integer(I4B),
intent(in) :: iout
1509 integer(I4B),
intent(in) :: iprint
1510 integer(I4B),
intent(in) :: idataun
1511 character(len=*),
intent(in) :: aname
1512 character(len=*),
intent(in) :: cdatafmp
1513 integer(I4B),
intent(in) :: nvaluesp
1514 integer(I4B),
intent(in) :: nwidthp
1515 character(len=*),
intent(in) :: editdesc
1516 real(DP),
intent(in) :: dinact
1518 integer(I4B) :: k, ifirst
1519 integer(I4B) :: nlay
1520 integer(I4B) :: nrow
1521 integer(I4B) :: ncol
1522 integer(I4B) :: nval
1523 integer(I4B) :: nodeu, noder
1524 integer(I4B) :: istart, istop
1525 real(DP),
dimension(:),
pointer,
contiguous :: dtemp
1527 character(len=*),
parameter :: fmthsv = &
1528 "(1X,/1X,a,' WILL BE SAVED ON UNIT ',I4, &
1529 &' AT END OF TIME STEP',I5,', STRESS PERIOD ',I4)"
1534 ncol = this%mshape(1)
1538 if (this%nodes < this%nodesuser)
then
1541 do nodeu = 1, this%nodesuser
1542 noder = this%get_nodenumber(nodeu, 0)
1543 if (noder <= 0)
then
1544 dtemp(nodeu) = dinact
1547 dtemp(nodeu) = darray(noder)
1555 if (iprint /= 0)
then
1558 istop = istart + nrow * ncol - 1
1560 aname, cdatafmp, nvaluesp, nwidthp, editdesc)
1566 if (idataun > 0)
then
1571 istop = istart + nrow * ncol - 1
1572 if (ifirst == 1)
write (iout, fmthsv) &
1573 trim(adjustl(aname)), idataun, &
1580 elseif (idataun < 0)
then
1583 call ubdsv1(
kstp,
kper, aname, -idataun, dtemp, ncol, nrow, nlay, &
1592 dstmodel, dstpackage, naux, auxtxt, &
1593 ibdchn, nlist, iout)
1596 character(len=16),
intent(in) :: text
1597 character(len=16),
intent(in) :: textmodel
1598 character(len=16),
intent(in) :: textpackage
1599 character(len=16),
intent(in) :: dstmodel
1600 character(len=16),
intent(in) :: dstpackage
1601 integer(I4B),
intent(in) :: naux
1602 character(len=16),
dimension(:),
intent(in) :: auxtxt
1603 integer(I4B),
intent(in) :: ibdchn
1604 integer(I4B),
intent(in) :: nlist
1605 integer(I4B),
intent(in) :: iout
1607 integer(I4B) :: nlay, nrow, ncol
1611 ncol = this%mshape(1)
1614 call ubdsv06(
kstp,
kper, text, textmodel, textpackage, dstmodel, dstpackage, &
1615 ibdchn, naux, auxtxt, ncol, nrow, nlay, &
1624 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)
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.