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
97 logical :: length_units = .false.
98 logical :: nogrb = .false.
99 logical :: xorigin = .false.
100 logical :: yorigin = .false.
101 logical :: angrot = .false.
102 logical :: voffsettol = .false.
103 logical :: nodes = .false.
104 logical :: nja = .false.
105 logical :: nvert = .false.
106 logical :: top = .false.
107 logical :: bot = .false.
108 logical :: area = .false.
109 logical :: idomain = .false.
110 logical :: iac = .false.
111 logical :: ja = .false.
112 logical :: ihc = .false.
113 logical :: cl12 = .false.
114 logical :: hwva = .false.
115 logical :: angldegx = .false.
116 logical :: iv = .false.
117 logical :: xv = .false.
118 logical :: yv = .false.
119 logical :: icell2d = .false.
120 logical :: xc = .false.
121 logical :: yc = .false.
122 logical :: ncvert = .false.
123 logical :: icvert = .false.
130 subroutine disu_cr(dis, name_model, input_mempath, inunit, iout)
133 character(len=*),
intent(in) :: name_model
134 character(len=*),
intent(in) :: input_mempath
135 integer(I4B),
intent(in) :: inunit
136 integer(I4B),
intent(in) :: iout
139 character(len=*),
parameter :: fmtheader = &
140 "(1X, /1X, 'DISU -- UNSTRUCTURED GRID DISCRETIZATION PACKAGE,', &
141 &' VERSION 2 : 3/27/2014 - INPUT READ FROM MEMPATH: ', A, //)"
148 call dis%allocate_scalars(name_model, input_mempath)
157 write (iout, fmtheader) dis%input_mempath
161 call disnew%disu_load()
173 call this%source_options()
174 call this%source_dimensions()
175 call this%source_griddata()
176 call this%source_connectivity()
179 if (this%nvert > 0)
then
180 call this%source_vertices()
181 call this%source_cell2d()
199 call this%grid_finalize()
211 integer(I4B) :: noder
212 integer(I4B) :: nrsize
214 character(len=*),
parameter :: fmtdz = &
215 "('CELL (',i0,',',i0,',',i0,') THICKNESS <= 0. ', &
216 &'TOP, BOT: ',2(1pg24.15))"
217 character(len=*),
parameter :: fmtnr = &
218 "(/1x, 'The specified IDOMAIN results in a reduced number of cells.',&
219 &/1x, 'Number of user nodes: ',I0,&
220 &/1X, 'Number of nodes in solution: ', I0, //)"
224 do n = 1, this%nodesuser
225 if (this%idomain(n) > 0) this%nodes = this%nodes + 1
229 if (this%nodes == 0)
then
230 call store_error(
'Model does not have any active nodes. &
231 &Ensure IDOMAIN array has some values greater &
237 if (this%nodes < this%nodesuser)
then
238 write (this%iout, fmtnr) this%nodesuser, this%nodes
242 call this%allocate_arrays()
248 if (this%nodes < this%nodesuser)
then
250 do node = 1, this%nodesuser
251 if (this%idomain(node) > 0)
then
252 this%nodereduced(node) = noder
254 elseif (this%idomain(node) < 0)
then
255 this%nodereduced(node) = -1
257 this%nodereduced(node) = 0
263 if (this%nodes < this%nodesuser)
then
265 do node = 1, this%nodesuser
266 if (this%idomain(node) > 0)
then
267 this%nodeuser(noder) = node
274 do node = 1, this%nodesuser
276 if (this%nodes < this%nodesuser) noder = this%nodereduced(node)
277 if (noder <= 0) cycle
278 this%top(noder) = this%top1d(node)
279 this%bot(noder) = this%bot1d(node)
280 this%area(noder) = this%area1d(node)
284 if (this%nvert > 0)
then
285 do node = 1, this%nodesuser
287 if (this%nodes < this%nodesuser) noder = this%nodereduced(node)
288 if (noder <= 0) cycle
289 this%xc(noder) = this%cellxy(1, node)
290 this%yc(noder) = this%cellxy(2, node)
299 if (this%nodes < this%nodesuser) nrsize = this%nodes
301 call this%con%disuconnections(this%name_model, this%nodes, &
302 this%nodesuser, nrsize, &
303 this%nodereduced, this%nodeuser, &
304 this%iainp, this%jainp, &
305 this%ihcinp, this%cl12inp, &
306 this%hwvainp, this%angldegxinp, &
308 this%nja = this%con%nja
309 this%njas = this%con%njas
324 character(len=*),
parameter :: fmtidm = &
325 &
"('Invalid idomain value ', i0, ' specified for node ', i0)"
326 character(len=*),
parameter :: fmtdz = &
327 &
"('Cell ', i0, ' with thickness <= 0. Top, bot: ', 2(1pg24.15))"
328 character(len=*),
parameter :: fmtarea = &
329 &
"('Cell ', i0, ' with area <= 0. Area: ', 1(1pg24.15))"
330 character(len=*),
parameter :: fmtjan = &
331 &
"('Cell ', i0, ' must have its first connection be itself. Found: ', i0)"
332 character(len=*),
parameter :: fmtjam = &
333 &
"('Cell ', i0, ' has invalid connection in JA. Found: ', i0)"
334 character(len=*),
parameter :: fmterrmsg = &
335 "('Top elevation (', 1pg15.6, ') for cell ', i0, ' is above bottom &
336 &elevation (', 1pg15.6, ') for cell ', i0, '. Based on node numbering &
337 &rules cell ', i0, ' must be below cell ', i0, '.')"
340 do n = 1, this%nodesuser
351 write (
errmsg, fmtjan) n, m
356 do ipos = this%iainp(n) + 1, this%iainp(n + 1) - 1
358 if (m < 0 .or. m > this%nodesuser)
then
360 write (
errmsg, fmtjam) n, m
368 if (this%inunit > 0)
then
374 do n = 1, this%nodesuser
375 if (this%idomain(n) > 1 .or. this%idomain(n) < 0)
then
376 write (
errmsg, fmtidm) this%idomain(n), n
383 do n = 1, this%nodesuser
384 if (this%idomain(n) == 1)
then
385 dz = this%top1d(n) - this%bot1d(n)
386 if (dz <=
dzero)
then
387 write (
errmsg, fmt=fmtdz) n, this%top1d(n), this%bot1d(n)
390 if (this%area1d(n) <=
dzero)
then
391 write (
errmsg, fmt=fmtarea) n, this%area1d(n)
398 if (this%voffsettol <
dzero)
then
399 write (
errmsg,
'(a, 1pg15.6)') &
400 'Vertical offset tolerance must be greater than zero. Found ', &
403 if (this%inunit > 0)
then
410 do n = 1, this%nodesuser
411 do ipos = this%iainp(n) + 1, this%iainp(n + 1) - 1
413 ihc = this%ihcinp(ipos)
414 if (ihc == 0 .and. m > n)
then
415 dz = this%top1d(m) - this%bot1d(n)
416 if (dz > this%voffsettol)
then
417 write (
errmsg, fmterrmsg) this%top1d(m), m, this%bot1d(n), n, m, n
426 if (this%inunit > 0)
then
451 if (this%readFromFile)
then
455 if (
associated(this%iavert))
then
475 call this%DisBaseType%dis_da()
484 integer(I4B),
intent(in) :: nodeu
485 character(len=*),
intent(inout) :: str
487 character(len=10) :: nstr
489 write (nstr,
'(i0)') nodeu
490 str =
'('//trim(adjustl(nstr))//
')'
498 integer(I4B),
intent(in) :: nodeu
499 integer(I4B),
dimension(:),
intent(inout) :: arr
501 integer(I4B) :: isize
505 if (isize /= this%ndim)
then
506 write (
errmsg,
'(a,i0,a,i0,a)') &
507 'Program error: nodeu_to_array size of array (', isize, &
508 ') is not equal to the discretization dimension (', this%ndim,
')'
523 character(len=LENVARNAME),
dimension(3) :: lenunits = &
524 &[character(len=LENVARNAME) ::
'FEET',
'METERS',
'CENTIMETERS']
528 call mem_set_value(this%lenuni,
'LENGTH_UNITS', this%input_mempath, &
529 lenunits, found%length_units)
530 call mem_set_value(this%nogrb,
'NOGRB', this%input_mempath, found%nogrb)
531 call mem_set_value(this%xorigin,
'XORIGIN', this%input_mempath, found%xorigin)
532 call mem_set_value(this%yorigin,
'YORIGIN', this%input_mempath, found%yorigin)
533 call mem_set_value(this%angrot,
'ANGROT', this%input_mempath, found%angrot)
534 call mem_set_value(this%voffsettol,
'VOFFSETTOL', this%input_mempath, &
538 if (this%iout > 0)
then
539 call this%log_options(found)
551 write (this%iout,
'(1x,a)')
'Setting Discretization Options'
553 if (found%length_units)
then
554 write (this%iout,
'(4x,a,i0)')
'Model length unit [0=UND, 1=FEET, &
555 &2=METERS, 3=CENTIMETERS] set as ', this%lenuni
558 if (found%nogrb)
then
559 write (this%iout,
'(4x,a,i0)')
'Binary grid file [0=GRB, 1=NOGRB] &
560 &set as ', this%nogrb
563 if (found%xorigin)
then
564 write (this%iout,
'(4x,a,G0)')
'XORIGIN = ', this%xorigin
567 if (found%yorigin)
then
568 write (this%iout,
'(4x,a,G0)')
'YORIGIN = ', this%yorigin
571 if (found%angrot)
then
572 write (this%iout,
'(4x,a,G0)')
'ANGROT = ', this%angrot
575 if (found%voffsettol)
then
576 write (this%iout,
'(4x,a,G0)')
'VERTICAL_OFFSET_TOLERANCE = ', &
580 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Options'
594 call mem_set_value(this%nodesuser,
'NODES', this%input_mempath, found%nodes)
595 call mem_set_value(this%njausr,
'NJA', this%input_mempath, found%nja)
596 call mem_set_value(this%nvert,
'NVERT', this%input_mempath, found%nvert)
599 if (this%iout > 0)
then
600 call this%log_dimensions(found)
604 if (this%nodesuser < 1)
then
606 'NODES was not specified or was specified incorrectly.')
608 if (this%njausr < 1)
then
610 'NJA was not specified or was specified incorrectly.')
619 this%readFromFile = .true.
620 call mem_allocate(this%top1d, this%nodesuser,
'TOP1D', this%memoryPath)
621 call mem_allocate(this%bot1d, this%nodesuser,
'BOT1D', this%memoryPath)
622 call mem_allocate(this%area1d, this%nodesuser,
'AREA1D', this%memoryPath)
623 call mem_allocate(this%idomain, this%nodesuser,
'IDOMAIN', this%memoryPath)
624 call mem_allocate(this%vertices, 2, this%nvert,
'VERTICES', this%memoryPath)
625 call mem_allocate(this%iainp, this%nodesuser + 1,
'IAINP', this%memoryPath)
626 call mem_allocate(this%jainp, this%njausr,
'JAINP', this%memoryPath)
627 call mem_allocate(this%ihcinp, this%njausr,
'IHCINP', this%memoryPath)
628 call mem_allocate(this%cl12inp, this%njausr,
'CL12INP', this%memoryPath)
629 call mem_allocate(this%hwvainp, this%njausr,
'HWVAINP', this%memoryPath)
630 call mem_allocate(this%angldegxinp, this%njausr,
'ANGLDEGXINP', &
632 if (this%nvert > 0)
then
633 call mem_allocate(this%cellxy, 2, this%nodesuser,
'CELLXY', this%memoryPath)
635 call mem_allocate(this%cellxy, 2, 0,
'CELLXY', this%memoryPath)
639 do n = 1, this%nodesuser
651 write (this%iout,
'(1x,a)')
'Setting Discretization Dimensions'
653 if (found%nodes)
then
654 write (this%iout,
'(4x,a,i0)')
'NODES = ', this%nodesuser
658 write (this%iout,
'(4x,a,i0)')
'NJA = ', this%njausr
661 if (found%nvert)
then
662 write (this%iout,
'(4x,a,i0)')
'NVERT = ', this%nvert
665 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Dimensions'
678 call mem_set_value(this%top1d,
'TOP', this%input_mempath, found%top)
679 call mem_set_value(this%bot1d,
'BOT', this%input_mempath, found%bot)
680 call mem_set_value(this%area1d,
'AREA', this%input_mempath, found%area)
681 call mem_set_value(this%idomain,
'IDOMAIN', this%input_mempath, found%idomain)
684 if (this%iout > 0)
then
685 call this%log_griddata(found)
697 write (this%iout,
'(1x,a)')
'Setting Discretization Griddata'
700 write (this%iout,
'(4x,a)')
'TOP set from input file'
704 write (this%iout,
'(4x,a)')
'BOT set from input file'
708 write (this%iout,
'(4x,a)')
'AREA set from input file'
711 if (found%idomain)
then
712 write (this%iout,
'(4x,a)')
'IDOMAIN set from input file'
715 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Griddata'
726 integer(I4B),
dimension(:),
contiguous,
pointer :: iac => null()
730 call mem_set_value(this%jainp,
'JA', this%input_mempath, found%ja)
731 call mem_set_value(this%ihcinp,
'IHC', this%input_mempath, found%ihc)
732 call mem_set_value(this%cl12inp,
'CL12', this%input_mempath, found%cl12)
733 call mem_set_value(this%hwvainp,
'HWVA', this%input_mempath, found%hwva)
734 call mem_set_value(this%angldegxinp,
'ANGLDEGX', this%input_mempath, &
738 call mem_setptr(iac,
'IAC', this%input_mempath)
741 if (
associated(iac))
call iac_to_ia(iac, this%iainp)
744 if (found%angldegx) this%iangledegx = 1
747 if (this%iout > 0)
then
748 call this%log_connectivity(found, iac)
758 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: iac
760 write (this%iout,
'(1x,a)')
'Setting Discretization Connectivity'
762 if (
associated(iac))
then
763 write (this%iout,
'(4x,a)')
'IAC set from input file'
767 write (this%iout,
'(4x,a)')
'JA set from input file'
771 write (this%iout,
'(4x,a)')
'IHC set from input file'
775 write (this%iout,
'(4x,a)')
'CL12 set from input file'
779 write (this%iout,
'(4x,a)')
'HWVA set from input file'
782 if (found%angldegx)
then
783 write (this%iout,
'(4x,a)')
'ANGLDEGX set from input file'
786 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Connectivity'
797 real(DP),
dimension(:),
contiguous,
pointer :: vert_x => null()
798 real(DP),
dimension(:),
contiguous,
pointer :: vert_y => null()
802 call mem_setptr(vert_x,
'XV', this%input_mempath)
803 call mem_setptr(vert_y,
'YV', this%input_mempath)
806 if (
associated(vert_x) .and.
associated(vert_y))
then
808 this%vertices(1, i) = vert_x(i)
809 this%vertices(2, i) = vert_y(i)
812 call store_error(
'Required Vertex arrays not found.')
816 if (this%iout > 0)
then
817 write (this%iout,
'(1x,a)')
'Discretization Vertex data loaded'
831 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: icell2d
832 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: ncvert
833 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: icvert
836 integer(I4B) :: i, j, ierr
837 integer(I4B) :: icv_idx, startvert, maxnnz = 5
840 call vert_spm%init(this%nodesuser, this%nvert, maxnnz)
844 do i = 1, this%nodesuser
845 if (icell2d(i) /= i)
call store_error(
'ICELL2D input sequence violation.')
847 call vert_spm%addconnection(i, icvert(icv_idx), 0)
849 startvert = icvert(icv_idx)
850 elseif (j == ncvert(i) .and. (icvert(icv_idx) /= startvert))
then
851 call vert_spm%addconnection(i, startvert, 0)
853 icv_idx = icv_idx + 1
858 call mem_allocate(this%iavert, this%nodesuser + 1,
'IAVERT', this%memoryPath)
859 call mem_allocate(this%javert, vert_spm%nnz,
'JAVERT', this%memoryPath)
860 call vert_spm%filliaja(this%iavert, this%javert, ierr)
861 call vert_spm%destroy()
871 integer(I4B),
dimension(:),
contiguous,
pointer :: icell2d => null()
872 integer(I4B),
dimension(:),
contiguous,
pointer :: ncvert => null()
873 integer(I4B),
dimension(:),
contiguous,
pointer :: icvert => null()
874 real(DP),
dimension(:),
contiguous,
pointer :: cell_x => null()
875 real(DP),
dimension(:),
contiguous,
pointer :: cell_y => null()
879 call mem_setptr(icell2d,
'ICELL2D', this%input_mempath)
880 call mem_setptr(ncvert,
'NCVERT', this%input_mempath)
881 call mem_setptr(icvert,
'ICVERT', this%input_mempath)
884 if (
associated(icell2d) .and.
associated(ncvert) &
885 .and.
associated(icvert))
then
886 call this%define_cellverts(icell2d, ncvert, icvert)
888 call store_error(
'Required cell vertex arrays not found.')
892 call mem_setptr(cell_x,
'XC', this%input_mempath)
893 call mem_setptr(cell_y,
'YC', this%input_mempath)
896 if (
associated(cell_x) .and.
associated(cell_y))
then
897 do i = 1, this%nodesuser
898 this%cellxy(1, i) = cell_x(i)
899 this%cellxy(2, i) = cell_y(i)
902 call store_error(
'Required cell center arrays not found.')
906 if (this%iout > 0)
then
907 write (this%iout,
'(1x,a)')
'Discretization Cell2d data loaded'
925 integer(I4B),
dimension(:),
intent(in) :: icelltype
927 integer(I4B) :: i, iunit, ntxt, version
928 integer(I4B),
parameter :: lentxt = 100
929 character(len=50) :: txthdr
930 character(len=lentxt) :: txt
931 character(len=LINELENGTH) :: fname
932 character(len=LENBIGLINE) :: crs
933 logical(LGP) :: found_crs
935 character(len=*),
parameter :: fmtgrdsave = &
936 "(4X,'BINARY GRID INFORMATION WILL BE WRITTEN TO:', &
937 &/,6X,'UNIT NUMBER: ', I0,/,6X, 'FILE NAME: ', A)"
942 if (this%nvert > 0) ntxt = ntxt + 5
944 call mem_set_value(crs,
'CRS', this%input_mempath, found_crs)
953 fname = trim(this%output_fname)
955 write (this%iout, fmtgrdsave) iunit, trim(adjustl(fname))
956 call openfile(iunit, this%iout, trim(adjustl(fname)),
'DATA(BINARY)', &
960 write (txthdr,
'(a)')
'GRID DISU'
961 txthdr(50:50) = new_line(
'a')
963 write (txthdr,
'(a, i0)')
'VERSION ', version
964 txthdr(50:50) = new_line(
'a')
966 write (txthdr,
'(a, i0)')
'NTXT ', ntxt
967 txthdr(50:50) = new_line(
'a')
969 write (txthdr,
'(a, i0)')
'LENTXT ', lentxt
970 txthdr(50:50) = new_line(
'a')
974 write (txt,
'(3a, i0)')
'NODES ',
'INTEGER ',
'NDIM 0 # ', this%nodesuser
975 txt(lentxt:lentxt) = new_line(
'a')
977 write (txt,
'(3a, i0)')
'NJA ',
'INTEGER ',
'NDIM 0 # ', this%con%nja
978 txt(lentxt:lentxt) = new_line(
'a')
980 write (txt,
'(3a, 1pg24.15)')
'XORIGIN ',
'DOUBLE ',
'NDIM 0 # ', this%xorigin
981 txt(lentxt:lentxt) = new_line(
'a')
983 write (txt,
'(3a, 1pg24.15)')
'YORIGIN ',
'DOUBLE ',
'NDIM 0 # ', this%yorigin
984 txt(lentxt:lentxt) = new_line(
'a')
986 write (txt,
'(3a, 1pg24.15)')
'ANGROT ',
'DOUBLE ',
'NDIM 0 # ', this%angrot
987 txt(lentxt:lentxt) = new_line(
'a')
989 write (txt,
'(3a, i0)')
'TOP ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
990 txt(lentxt:lentxt) = new_line(
'a')
992 write (txt,
'(3a, i0)')
'BOT ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
993 txt(lentxt:lentxt) = new_line(
'a')
995 write (txt,
'(3a, i0)')
'IA ',
'INTEGER ',
'NDIM 1 ', this%nodesuser + 1
996 txt(lentxt:lentxt) = new_line(
'a')
998 write (txt,
'(3a, i0)')
'JA ',
'INTEGER ',
'NDIM 1 ', this%con%nja
999 txt(lentxt:lentxt) = new_line(
'a')
1001 write (txt,
'(3a, i0)')
'IDOMAIN ',
'INTEGER ',
'NDIM 1 ', this%nodesuser
1002 txt(lentxt:lentxt) = new_line(
'a')
1004 write (txt,
'(3a, i0)')
'ICELLTYPE ',
'INTEGER ',
'NDIM 1 ', this%nodesuser
1005 txt(lentxt:lentxt) = new_line(
'a')
1009 if (this%nvert > 0)
then
1010 write (txt,
'(3a, i0)')
'VERTICES ',
'DOUBLE ',
'NDIM 2 2 ', this%nvert
1011 txt(lentxt:lentxt) = new_line(
'a')
1013 write (txt,
'(3a, i0)')
'CELLX ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
1014 txt(lentxt:lentxt) = new_line(
'a')
1016 write (txt,
'(3a, i0)')
'CELLY ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
1017 txt(lentxt:lentxt) = new_line(
'a')
1019 write (txt,
'(3a, i0)')
'IAVERT ',
'INTEGER ',
'NDIM 1 ', this%nodesuser + 1
1020 txt(lentxt:lentxt) = new_line(
'a')
1022 write (txt,
'(3a, i0)')
'JAVERT ',
'INTEGER ',
'NDIM 1 ',
size(this%javert)
1023 txt(lentxt:lentxt) = new_line(
'a')
1028 if (version == 2)
then
1030 write (txt,
'(3a, i0)')
'CRS ',
'CHARACTER ',
'NDIM 1 ', &
1032 txt(lentxt:lentxt) = new_line(
'a')
1038 write (iunit) this%nodesuser
1039 write (iunit) this%nja
1040 write (iunit) this%xorigin
1041 write (iunit) this%yorigin
1042 write (iunit) this%angrot
1043 write (iunit) this%top1d
1044 write (iunit) this%bot1d
1045 write (iunit) this%con%iausr
1046 write (iunit) this%con%jausr
1047 write (iunit) this%idomain
1048 write (iunit) icelltype
1051 if (this%nvert > 0)
then
1052 write (iunit) this%vertices
1053 write (iunit) (this%cellxy(1, i), i=1, this%nodesuser)
1054 write (iunit) (this%cellxy(2, i), i=1, this%nodesuser)
1055 write (iunit) this%iavert
1056 write (iunit) this%javert
1060 if (version == 2)
then
1061 if (found_crs)
write (iunit) trim(crs)
1072 class(
disutype),
intent(in) :: this
1073 integer(I4B),
intent(in) :: nodeu
1074 integer(I4B),
intent(in) :: icheck
1075 integer(I4B) :: nodenumber
1077 if (icheck /= 0)
then
1078 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1079 write (
errmsg,
'(a,i0,a,i0,a)') &
1080 'Node number (', nodeu,
') is less than 1 or greater than nodes (', &
1081 this%nodesuser,
').'
1088 if (this%nodes == this%nodesuser)
then
1091 nodenumber = this%nodereduced(nodeu)
1104 integer(I4B),
intent(in) :: noden
1105 integer(I4B),
intent(in) :: nodem
1106 integer(I4B),
intent(in) :: ihc
1107 real(DP),
intent(inout) :: xcomp
1108 real(DP),
intent(inout) :: ycomp
1109 real(DP),
intent(inout) :: zcomp
1110 integer(I4B),
intent(in) :: ipos
1112 real(DP) :: angle, dmult
1120 if (nodem < noden)
then
1132 angle = this%con%anglex(this%con%jas(ipos))
1134 if (nodem < noden) dmult = -
done
1135 xcomp = cos(angle) * dmult
1136 ycomp = sin(angle) * dmult
1148 xcomp, ycomp, zcomp, conlen)
1151 integer(I4B),
intent(in) :: noden
1152 integer(I4B),
intent(in) :: nodem
1153 logical,
intent(in) :: nozee
1154 real(DP),
intent(in) :: satn
1155 real(DP),
intent(in) :: satm
1156 integer(I4B),
intent(in) :: ihc
1157 real(DP),
intent(inout) :: xcomp
1158 real(DP),
intent(inout) :: ycomp
1159 real(DP),
intent(inout) :: zcomp
1160 real(DP),
intent(inout) :: conlen
1162 real(DP) :: xn, xm, yn, ym, zn, zm
1166 if (
size(this%cellxy, 2) < 1)
then
1168 'Cannot calculate unit vector components for DISU grid if VERTEX '// &
1169 'data are not specified'
1183 zn = this%bot(noden) +
dhalf * (this%top(noden) - this%bot(noden))
1184 zm = this%bot(nodem) +
dhalf * (this%top(nodem) - this%bot(nodem))
1193 zn = this%bot(noden) +
dhalf * satn * (this%top(noden) - this%bot(noden))
1194 zm = this%bot(nodem) +
dhalf * satm * (this%top(nodem) - this%bot(nodem))
1208 class(
disutype),
intent(in) :: this
1209 character(len=*),
intent(out) :: dis_type
1218 class(
disutype),
intent(in) :: this
1219 integer(I4B) :: dis_enum
1228 character(len=*),
intent(in) :: name_model
1229 character(len=*),
intent(in) :: input_mempath
1232 call this%DisBaseType%allocate_scalars(name_model, input_mempath)
1235 call mem_allocate(this%njausr,
'NJAUSR', this%memoryPath)
1236 call mem_allocate(this%nvert,
'NVERT', this%memoryPath)
1237 call mem_allocate(this%voffsettol,
'VOFFSETTOL', this%memoryPath)
1238 call mem_allocate(this%iangledegx,
'IANGLEDEGX', this%memoryPath)
1244 this%voffsettol =
dzero
1246 this%readFromFile = .false.
1257 call this%DisBaseType%allocate_arrays()
1260 if (this%nodes < this%nodesuser)
then
1261 call mem_allocate(this%nodeuser, this%nodes,
'NODEUSER', this%memoryPath)
1262 call mem_allocate(this%nodereduced, this%nodesuser,
'NODEREDUCED', &
1265 call mem_allocate(this%nodeuser, 1,
'NODEUSER', this%memoryPath)
1266 call mem_allocate(this%nodereduced, 1,
'NODEREDUCED', this%memoryPath)
1270 this%mshape(1) = this%nodesuser
1282 call mem_allocate(this%idomain, this%nodes,
'IDOMAIN', this%memoryPath)
1283 call mem_allocate(this%vertices, 2, this%nvert,
'VERTICES', this%memoryPath)
1284 if (this%icondir > 0)
then
1285 call mem_allocate(this%cellxy, 2, this%nodes,
'CELLXY', this%memoryPath)
1287 call mem_allocate(this%cellxy, 2, 0,
'CELLXY', this%memoryPath)
1299 flag_string, allow_zero)
result(nodeu)
1302 integer(I4B),
intent(inout) :: lloc
1303 integer(I4B),
intent(inout) :: istart
1304 integer(I4B),
intent(inout) :: istop
1305 integer(I4B),
intent(in) :: in
1306 integer(I4B),
intent(in) :: iout
1307 character(len=*),
intent(inout) :: line
1308 logical,
optional,
intent(in) :: flag_string
1309 logical,
optional,
intent(in) :: allow_zero
1310 integer(I4B) :: nodeu
1312 integer(I4B) :: lloclocal, ndum, istat, n
1315 if (
present(flag_string))
then
1316 if (flag_string)
then
1319 call urword(line, lloclocal, istart, istop, 1, ndum, r, iout, in)
1320 read (line(istart:istop), *, iostat=istat) n
1321 if (istat /= 0)
then
1329 call urword(line, lloc, istart, istop, 2, nodeu, r, iout, in)
1331 if (nodeu == 0)
then
1332 if (
present(allow_zero))
then
1333 if (allow_zero)
then
1339 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1340 write (
errmsg,
'(a,i0,a)') &
1341 "Node number in list (", nodeu,
") is outside of the grid. "// &
1342 "Cell number cannot be determined in line '"// &
1343 trim(adjustl(line))//
"'."
1359 allow_zero)
result(nodeu)
1361 integer(I4B) :: nodeu
1364 character(len=*),
intent(inout) :: cellid
1365 integer(I4B),
intent(in) :: inunit
1366 integer(I4B),
intent(in) :: iout
1367 logical,
optional,
intent(in) :: flag_string
1368 logical,
optional,
intent(in) :: allow_zero
1370 integer(I4B) :: lloclocal, istart, istop, ndum, n
1371 integer(I4B) :: istat
1374 if (
present(flag_string))
then
1375 if (flag_string)
then
1378 call urword(cellid, lloclocal, istart, istop, 1, ndum, r, iout, inunit)
1379 read (cellid(istart:istop), *, iostat=istat) n
1380 if (istat /= 0)
then
1389 call urword(cellid, lloclocal, istart, istop, 2, nodeu, r, iout, inunit)
1391 if (nodeu == 0)
then
1392 if (
present(allow_zero))
then
1393 if (allow_zero)
then
1399 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1400 write (
errmsg,
'(a,i0,a)') &
1401 "Cell number cannot be determined for cellid ("// &
1402 trim(adjustl(cellid))//
") and results in a user "// &
1403 "node number (", nodeu,
") that is outside of the grid."
1437 class(
disutype),
intent(inout) :: this
1438 character(len=*),
intent(inout) :: line
1439 integer(I4B),
intent(inout) :: lloc
1440 integer(I4B),
intent(inout) :: istart
1441 integer(I4B),
intent(inout) :: istop
1442 integer(I4B),
intent(in) :: in
1443 integer(I4B),
intent(in) :: iout
1444 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(inout) :: iarray
1445 character(len=*),
intent(in) :: aname
1447 integer(I4B) :: nval
1448 integer(I4B),
dimension(:),
pointer,
contiguous :: itemp
1454 if (this%nodes < this%nodesuser)
then
1455 nval = this%nodesuser
1464 call readarray(in, itemp, aname, this%ndim, nval, iout, 0)
1467 if (this%nodes < this%nodesuser)
then
1468 call this%fill_grid_array(itemp, iarray)
1478 class(
disutype),
intent(inout) :: this
1479 character(len=*),
intent(inout) :: line
1480 integer(I4B),
intent(inout) :: lloc
1481 integer(I4B),
intent(inout) :: istart
1482 integer(I4B),
intent(inout) :: istop
1483 integer(I4B),
intent(in) :: in
1484 integer(I4B),
intent(in) :: iout
1485 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: darray
1486 character(len=*),
intent(in) :: aname
1488 integer(I4B) :: nval
1489 real(DP),
dimension(:),
pointer,
contiguous :: dtemp
1495 if (this%nodes < this%nodesuser)
then
1496 nval = this%nodesuser
1504 call readarray(in, dtemp, aname, this%ndim, nval, iout, 0)
1507 if (this%nodes < this%nodesuser)
then
1508 call this%fill_grid_array(dtemp, darray)
1519 cdatafmp, nvaluesp, nwidthp, editdesc, dinact)
1521 class(
disutype),
intent(inout) :: this
1522 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: darray
1523 integer(I4B),
intent(in) :: iout
1524 integer(I4B),
intent(in) :: iprint
1525 integer(I4B),
intent(in) :: idataun
1526 character(len=*),
intent(in) :: aname
1527 character(len=*),
intent(in) :: cdatafmp
1528 integer(I4B),
intent(in) :: nvaluesp
1529 integer(I4B),
intent(in) :: nwidthp
1530 character(len=*),
intent(in) :: editdesc
1531 real(DP),
intent(in) :: dinact
1533 integer(I4B) :: k, ifirst
1534 integer(I4B) :: nlay
1535 integer(I4B) :: nrow
1536 integer(I4B) :: ncol
1537 integer(I4B) :: nval
1538 integer(I4B) :: nodeu, noder
1539 integer(I4B) :: istart, istop
1540 real(DP),
dimension(:),
pointer,
contiguous :: dtemp
1542 character(len=*),
parameter :: fmthsv = &
1543 "(1X,/1X,a,' WILL BE SAVED ON UNIT ',I4, &
1544 &' AT END OF TIME STEP',I5,', STRESS PERIOD ',I4)"
1549 ncol = this%mshape(1)
1553 if (this%nodes < this%nodesuser)
then
1556 do nodeu = 1, this%nodesuser
1557 noder = this%get_nodenumber(nodeu, 0)
1558 if (noder <= 0)
then
1559 dtemp(nodeu) = dinact
1562 dtemp(nodeu) = darray(noder)
1570 if (iprint /= 0)
then
1573 istop = istart + nrow * ncol - 1
1575 aname, cdatafmp, nvaluesp, nwidthp, editdesc)
1581 if (idataun > 0)
then
1586 istop = istart + nrow * ncol - 1
1587 if (ifirst == 1)
write (iout, fmthsv) &
1588 trim(adjustl(aname)), idataun, &
1595 elseif (idataun < 0)
then
1598 call ubdsv1(
kstp,
kper, aname, -idataun, dtemp, ncol, nrow, nlay, &
1607 dstmodel, dstpackage, naux, auxtxt, &
1608 ibdchn, nlist, iout)
1611 character(len=16),
intent(in) :: text
1612 character(len=16),
intent(in) :: textmodel
1613 character(len=16),
intent(in) :: textpackage
1614 character(len=16),
intent(in) :: dstmodel
1615 character(len=16),
intent(in) :: dstpackage
1616 integer(I4B),
intent(in) :: naux
1617 character(len=16),
dimension(:),
intent(in) :: auxtxt
1618 integer(I4B),
intent(in) :: ibdchn
1619 integer(I4B),
intent(in) :: nlist
1620 integer(I4B),
intent(in) :: iout
1622 integer(I4B) :: nlay, nrow, ncol
1626 ncol = this%mshape(1)
1629 call ubdsv06(
kstp,
kper, text, textmodel, textpackage, dstmodel, dstpackage, &
1630 ibdchn, naux, auxtxt, ncol, nrow, nlay, &
1645 class(
disutype),
intent(inout) :: this
1646 integer(I4B),
intent(in) :: ic
1647 real(DP),
allocatable,
intent(out) :: polyverts(:, :)
1648 logical(LGP),
intent(in),
optional :: closed
1650 integer(I4B) :: icu, iavert, nverts, m, j
1651 logical(LGP) :: lclosed
1654 nverts = this%get_npolyverts(ic)
1655 if (nverts == 0)
then
1656 allocate (polyverts(2, 0))
1661 if (.not. (
present(closed)))
then
1669 allocate (polyverts(2, nverts + 1))
1671 allocate (polyverts(2, nverts))
1675 icu = this%get_nodeuser(ic)
1676 iavert = this%iavert(icu)
1678 j = this%javert(iavert - 1 + m)
1679 polyverts(:, m) = (/this%vertices(1, j), this%vertices(2, j)/)
1684 polyverts(:, nverts + 1) = polyverts(:, 1)
1690 class(
disutype),
intent(inout) :: this
1691 integer(I4B),
intent(in) :: ic
1692 logical(LGP),
intent(in),
optional :: closed
1693 integer(I4B) :: npolyverts
1698 if (this%nvert < 1)
then
1703 icu = this%get_nodeuser(ic)
1704 npolyverts = this%iavert(icu + 1) - this%iavert(icu) - 1
1705 if (
present(closed))
then
1706 if (closed) npolyverts = npolyverts + 1
1712 class(
disutype),
intent(inout) :: this
1713 logical(LGP),
intent(in),
optional :: closed
1714 integer(I4B) :: max_npolyverts
1718 do ic = 1, this%nodes
1719 max_npolyverts = max(max_npolyverts, this%get_npolyverts(ic, closed))
1725 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 get_polyverts(this, ic, polyverts, closed)
Cast base to DISU.
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)
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.
integer(i4b) function get_max_npolyverts(this, closed)
Get the maximum number of cell polygon vertices.
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.
integer(i4b) function get_npolyverts(this, ic, closed)
Get the number of cell polygon vertices, 0 if none are defined.
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.