25 integer(I4B),
pointer :: nlay => null()
26 integer(I4B),
pointer :: ncpl => null()
27 integer(I4B),
pointer :: nvert => null()
28 real(dp),
dimension(:, :),
pointer,
contiguous :: vertices => null()
29 real(dp),
dimension(:, :),
pointer,
contiguous :: cellxy => null()
30 integer(I4B),
dimension(:),
pointer,
contiguous :: iavert => null()
31 integer(I4B),
dimension(:),
pointer,
contiguous :: javert => null()
32 real(dp),
dimension(:),
pointer,
contiguous :: top1d => null()
33 real(dp),
dimension(:, :),
pointer,
contiguous :: bot2d => null()
34 integer(I4B),
dimension(:, :),
pointer,
contiguous :: idomain => null()
83 logical :: length_units = .false.
84 logical :: nogrb = .false.
85 logical :: xorigin = .false.
86 logical :: yorigin = .false.
87 logical :: angrot = .false.
88 logical :: nlay = .false.
89 logical :: ncpl = .false.
90 logical :: nvert = .false.
91 logical :: top = .false.
92 logical :: botm = .false.
93 logical :: idomain = .false.
94 logical :: iv = .false.
95 logical :: xv = .false.
96 logical :: yv = .false.
97 logical :: icell2d = .false.
98 logical :: xc = .false.
99 logical :: yc = .false.
100 logical :: ncvert = .false.
101 logical :: icvert = .false.
108 subroutine disv_cr(dis, name_model, input_mempath, inunit, iout)
111 character(len=*),
intent(in) :: name_model
112 character(len=*),
intent(in) :: input_mempath
113 integer(I4B),
intent(in) :: inunit
114 integer(I4B),
intent(in) :: iout
118 character(len=*),
parameter :: fmtheader = &
119 "(1X, /1X, 'DISV -- VERTEX GRID DISCRETIZATION PACKAGE,', &
120 &' VERSION 1 : 12/23/2015 - INPUT READ FROM MEMPATH: ', A, //)"
124 call disnew%allocate_scalars(name_model, input_mempath)
133 write (iout, fmtheader) dis%input_mempath
137 call disnew%disv_load()
149 call this%source_options()
150 call this%source_dimensions()
151 call this%source_griddata()
152 call this%source_vertices()
153 call this%source_cell2d()
163 call this%grid_finalize()
179 call this%DisBaseType%dis_da()
205 character(len=LENVARNAME),
dimension(3) :: lenunits = &
206 &[character(len=LENVARNAME) ::
'FEET',
'METERS',
'CENTIMETERS']
210 call mem_set_value(this%lenuni,
'LENGTH_UNITS', this%input_mempath, &
211 lenunits, found%length_units)
212 call mem_set_value(this%nogrb,
'NOGRB', this%input_mempath, found%nogrb)
213 call mem_set_value(this%xorigin,
'XORIGIN', this%input_mempath, found%xorigin)
214 call mem_set_value(this%yorigin,
'YORIGIN', this%input_mempath, found%yorigin)
215 call mem_set_value(this%angrot,
'ANGROT', this%input_mempath, found%angrot)
218 if (this%iout > 0)
then
219 call this%log_options(found)
231 write (this%iout,
'(1x,a)')
'Setting Discretization Options'
233 if (found%length_units)
then
234 write (this%iout,
'(4x,a,i0)')
'Model length unit [0=UND, 1=FEET, &
235 &2=METERS, 3=CENTIMETERS] set as ', this%lenuni
238 if (found%nogrb)
then
239 write (this%iout,
'(4x,a,i0)')
'Binary grid file [0=GRB, 1=NOGRB] &
240 &set as ', this%nogrb
243 if (found%xorigin)
then
244 write (this%iout,
'(4x,a,G0)')
'XORIGIN = ', this%xorigin
247 if (found%yorigin)
then
248 write (this%iout,
'(4x,a,G0)')
'YORIGIN = ', this%yorigin
251 if (found%angrot)
then
252 write (this%iout,
'(4x,a,G0)')
'ANGROT = ', this%angrot
255 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Options'
269 call mem_set_value(this%nlay,
'NLAY', this%input_mempath, found%nlay)
270 call mem_set_value(this%ncpl,
'NCPL', this%input_mempath, found%ncpl)
271 call mem_set_value(this%nvert,
'NVERT', this%input_mempath, found%nvert)
274 if (this%iout > 0)
then
275 call this%log_dimensions(found)
279 if (this%nlay < 1)
then
281 'NLAY was not specified or was specified incorrectly.')
284 if (this%ncpl < 1)
then
286 'NCPL was not specified or was specified incorrectly.')
289 if (this%nvert < 1)
then
291 'NVERT was not specified or was specified incorrectly.')
296 this%nodesuser = this%nlay * this%ncpl
299 call mem_allocate(this%idomain, this%ncpl, this%nlay,
'IDOMAIN', &
301 call mem_allocate(this%top1d, this%ncpl,
'TOP1D', this%memoryPath)
302 call mem_allocate(this%bot2d, this%ncpl, this%nlay,
'BOT2D', &
306 call mem_allocate(this%vertices, 2, this%nvert,
'VERTICES', this%memoryPath)
307 call mem_allocate(this%cellxy, 2, this%ncpl,
'CELLXY', this%memoryPath)
312 this%idomain(j, k) = 1
325 write (this%iout,
'(1x,a)')
'Setting Discretization Dimensions'
328 write (this%iout,
'(4x,a,i0)')
'NLAY = ', this%nlay
332 write (this%iout,
'(4x,a,i0)')
'NCPL = ', this%ncpl
335 if (found%nvert)
then
336 write (this%iout,
'(4x,a,i0)')
'NVERT = ', this%nvert
339 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Dimensions'
352 call mem_set_value(this%top1d,
'TOP', this%input_mempath, found%top)
353 call mem_set_value(this%bot2d,
'BOTM', this%input_mempath, found%botm)
354 call mem_set_value(this%idomain,
'IDOMAIN', this%input_mempath, found%idomain)
357 if (this%iout > 0)
then
358 call this%log_griddata(found)
370 write (this%iout,
'(1x,a)')
'Setting Discretization Griddata'
373 write (this%iout,
'(4x,a)')
'TOP set from input file'
377 write (this%iout,
'(4x,a)')
'BOTM set from input file'
380 if (found%idomain)
then
381 write (this%iout,
'(4x,a)')
'IDOMAIN set from input file'
384 write (this%iout,
'(1x,a,/)')
'End Setting Discretization Griddata'
394 integer(I4B) :: node, noder, j, k
398 character(len=*),
parameter :: fmtdz = &
399 "('CELL (',i0,',',i0,') THICKNESS <= 0. ', &
400 &'TOP, BOT: ',2(1pg24.15))"
401 character(len=*),
parameter :: fmtnr = &
402 "(/1x, 'The specified IDOMAIN results in a reduced number of cells.',&
403 &/1x, 'Number of user nodes: ',I0,&
404 &/1X, 'Number of nodes in solution: ', I0, //)"
410 if (this%idomain(j, k) > 0) this%nodes = this%nodes + 1
415 if (this%nodes == 0)
then
416 call store_error(
'Model does not have any active nodes. &
417 &Ensure IDOMAIN array has some values greater &
425 if (this%idomain(j, k) == 0) cycle
426 if (this%idomain(j, k) > 0)
then
428 top = this%bot2d(j, k - 1)
432 dz = top - this%bot2d(j, k)
433 if (dz <=
dzero)
then
434 write (
errmsg, fmt=fmtdz) k, j, top, this%bot2d(j, k)
445 if (this%nodes < this%nodesuser)
then
446 write (this%iout, fmtnr) this%nodesuser, this%nodes
450 call this%allocate_arrays()
456 if (this%nodes < this%nodesuser)
then
461 if (this%idomain(j, k) > 0)
then
462 this%nodereduced(node) = noder
464 elseif (this%idomain(j, k) < 0)
then
465 this%nodereduced(node) = -1
467 this%nodereduced(node) = 0
475 if (this%nodes < this%nodesuser)
then
480 if (this%idomain(j, k) > 0)
then
481 this%nodeuser(noder) = node
496 if (this%nodes < this%nodesuser) noder = this%nodereduced(node)
497 if (noder <= 0) cycle
499 top = this%bot2d(j, k - 1)
503 this%top(noder) = top
504 this%bot(noder) = this%bot2d(j, k)
505 this%xc(noder) = this%cellxy(1, j)
506 this%yc(noder) = this%cellxy(2, j)
522 real(DP),
dimension(:),
contiguous,
pointer :: vert_x => null()
523 real(DP),
dimension(:),
contiguous,
pointer :: vert_y => null()
526 call mem_setptr(vert_x,
'XV', this%input_mempath)
527 call mem_setptr(vert_y,
'YV', this%input_mempath)
530 if (
associated(vert_x) .and.
associated(vert_y))
then
532 this%vertices(1, i) = vert_x(i)
533 this%vertices(2, i) = vert_y(i)
536 call store_error(
'Required Vertex arrays not found.')
540 if (this%iout > 0)
then
541 write (this%iout,
'(1x,a)')
'Discretization Vertex data loaded'
553 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: icell2d
554 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: ncvert
555 integer(I4B),
dimension(:),
contiguous,
pointer,
intent(in) :: icvert
558 integer(I4B) :: i, j, ierr
559 integer(I4B) :: icv_idx, startvert, maxnnz = 5
562 call vert_spm%init(this%ncpl, this%nvert, maxnnz)
567 if (icell2d(i) /= i)
call store_error(
'ICELL2D input sequence violation.')
569 call vert_spm%addconnection(i, icvert(icv_idx), 0)
571 startvert = icvert(icv_idx)
572 elseif (j == ncvert(i) .and. (icvert(icv_idx) /= startvert))
then
573 call vert_spm%addconnection(i, startvert, 0)
575 icv_idx = icv_idx + 1
580 call mem_allocate(this%iavert, this%ncpl + 1,
'IAVERT', this%memoryPath)
581 call mem_allocate(this%javert, vert_spm%nnz,
'JAVERT', this%memoryPath)
582 call vert_spm%filliaja(this%iavert, this%javert, ierr)
583 call vert_spm%destroy()
593 integer(I4B),
dimension(:),
contiguous,
pointer :: icell2d => null()
594 integer(I4B),
dimension(:),
contiguous,
pointer :: ncvert => null()
595 integer(I4B),
dimension(:),
contiguous,
pointer :: icvert => null()
596 real(DP),
dimension(:),
contiguous,
pointer :: cell_x => null()
597 real(DP),
dimension(:),
contiguous,
pointer :: cell_y => null()
601 call mem_setptr(icell2d,
'ICELL2D', this%input_mempath)
602 call mem_setptr(ncvert,
'NCVERT', this%input_mempath)
603 call mem_setptr(icvert,
'ICVERT', this%input_mempath)
606 if (
associated(icell2d) .and.
associated(ncvert) &
607 .and.
associated(icvert))
then
608 call this%define_cellverts(icell2d, ncvert, icvert)
610 call store_error(
'Required cell vertex array(s) [ICELL2D, NCVERT, ICVERT] &
615 call mem_setptr(cell_x,
'XC', this%input_mempath)
616 call mem_setptr(cell_y,
'YC', this%input_mempath)
619 if (
associated(cell_x) .and.
associated(cell_y))
then
621 this%cellxy(1, i) = cell_x(i)
622 this%cellxy(2, i) = cell_y(i)
625 call store_error(
'Required cell center arrays not found.')
629 if (this%iout > 0)
then
630 write (this%iout,
'(1x,a)')
'Discretization Cell2d data loaded'
642 integer(I4B) :: noder, nrsize
643 integer(I4B) :: narea_eq_zero
644 integer(I4B) :: narea_lt_zero
653 area = this%get_cell2d_area(j)
655 noder = this%get_nodenumber(k, j, 0)
656 if (noder > 0) this%area(noder) = area
658 if (area <
dzero)
then
659 narea_lt_zero = narea_lt_zero + 1
660 write (
errmsg,
'(a,i0,a)') &
661 &
'Calculated CELL2D area less than zero for cell ', j,
'.'
664 if (area ==
dzero)
then
665 narea_eq_zero = narea_eq_zero + 1
666 write (
errmsg,
'(a,i0,a)') &
667 'Calculated CELL2D area is zero for cell ', j,
'.'
674 if (narea_lt_zero > 0)
then
675 write (
errmsg,
'(i0,a)') narea_lt_zero, &
676 ' cell(s) have an area less than zero. Calculated cell &
677 &areas must be greater than zero. Negative areas often &
678 &mean vertices are not listed in clockwise order.'
681 if (narea_eq_zero > 0)
then
682 write (
errmsg,
'(i0,a)') narea_eq_zero, &
683 ' cell(s) have an area equal to zero. Calculated cell &
684 &areas must be greater than zero. Calculated cell &
685 &areas equal to zero indicate that the cell is not defined &
686 &by a valid polygon.'
694 if (this%nodes < this%nodesuser) nrsize = this%nodes
696 call this%con%disvconnections(this%name_model, this%nodes, &
697 this%ncpl, this%nlay, nrsize, &
698 this%nvert, this%vertices, this%iavert, &
699 this%javert, this%cellxy, &
700 this%top, this%bot, &
701 this%nodereduced, this%nodeuser)
702 this%nja = this%con%nja
703 this%njas = this%con%njas
715 integer(I4B),
dimension(:),
intent(in) :: icelltype
717 integer(I4B) :: iunit, i, ntxt, version
718 integer(I4B),
parameter :: lentxt = 100
719 character(len=50) :: txthdr
720 character(len=lentxt) :: txt
721 character(len=LINELENGTH) :: fname
722 character(len=LENBIGLINE) :: crs
723 logical(LGP) :: found_crs
725 character(len=*),
parameter :: fmtgrdsave = &
726 "(4X,'BINARY GRID INFORMATION WILL BE WRITTEN TO:', &
727 &/,6X,'UNIT NUMBER: ', I0,/,6X, 'FILE NAME: ', A)"
733 call mem_set_value(crs,
'CRS', this%input_mempath, found_crs)
742 fname = trim(this%output_fname)
744 write (this%iout, fmtgrdsave) iunit, trim(adjustl(fname))
745 call openfile(iunit, this%iout, trim(adjustl(fname)),
'DATA(BINARY)', &
749 write (txthdr,
'(a)')
'GRID DISV'
750 txthdr(50:50) = new_line(
'a')
752 write (txthdr,
'(a, i0)')
'VERSION ', version
753 txthdr(50:50) = new_line(
'a')
755 write (txthdr,
'(a, i0)')
'NTXT ', ntxt
756 txthdr(50:50) = new_line(
'a')
758 write (txthdr,
'(a, i0)')
'LENTXT ', lentxt
759 txthdr(50:50) = new_line(
'a')
763 write (txt,
'(3a, i0)')
'NCELLS ',
'INTEGER ',
'NDIM 0 # ', this%nodesuser
764 txt(lentxt:lentxt) = new_line(
'a')
766 write (txt,
'(3a, i0)')
'NLAY ',
'INTEGER ',
'NDIM 0 # ', this%nlay
767 txt(lentxt:lentxt) = new_line(
'a')
769 write (txt,
'(3a, i0)')
'NCPL ',
'INTEGER ',
'NDIM 0 # ', this%ncpl
770 txt(lentxt:lentxt) = new_line(
'a')
772 write (txt,
'(3a, i0)')
'NVERT ',
'INTEGER ',
'NDIM 0 # ', this%nvert
773 txt(lentxt:lentxt) = new_line(
'a')
775 write (txt,
'(3a, i0)')
'NJAVERT ',
'INTEGER ',
'NDIM 0 # ',
size(this%javert)
776 txt(lentxt:lentxt) = new_line(
'a')
778 write (txt,
'(3a, i0)')
'NJA ',
'INTEGER ',
'NDIM 0 # ', this%con%nja
779 txt(lentxt:lentxt) = new_line(
'a')
781 write (txt,
'(3a, 1pg25.15e3)') &
782 'XORIGIN ',
'DOUBLE ',
'NDIM 0 # ', this%xorigin
783 txt(lentxt:lentxt) = new_line(
'a')
785 write (txt,
'(3a, 1pg25.15e3)') &
786 'YORIGIN ',
'DOUBLE ',
'NDIM 0 # ', this%yorigin
787 txt(lentxt:lentxt) = new_line(
'a')
789 write (txt,
'(3a, 1pg25.15e3)')
'ANGROT ',
'DOUBLE ',
'NDIM 0 # ', this%angrot
790 txt(lentxt:lentxt) = new_line(
'a')
792 write (txt,
'(3a, i0)')
'TOP ',
'DOUBLE ',
'NDIM 1 ', this%ncpl
793 txt(lentxt:lentxt) = new_line(
'a')
795 write (txt,
'(3a, i0)')
'BOTM ',
'DOUBLE ',
'NDIM 1 ', this%nodesuser
796 txt(lentxt:lentxt) = new_line(
'a')
798 write (txt,
'(3a, i0)')
'VERTICES ',
'DOUBLE ',
'NDIM 2 2 ', this%nvert
799 txt(lentxt:lentxt) = new_line(
'a')
801 write (txt,
'(3a, i0)')
'CELLX ',
'DOUBLE ',
'NDIM 1 ', this%ncpl
802 txt(lentxt:lentxt) = new_line(
'a')
804 write (txt,
'(3a, i0)')
'CELLY ',
'DOUBLE ',
'NDIM 1 ', this%ncpl
805 txt(lentxt:lentxt) = new_line(
'a')
807 write (txt,
'(3a, i0)')
'IAVERT ',
'INTEGER ',
'NDIM 1 ', this%ncpl + 1
808 txt(lentxt:lentxt) = new_line(
'a')
810 write (txt,
'(3a, i0)')
'JAVERT ',
'INTEGER ',
'NDIM 1 ',
size(this%javert)
811 txt(lentxt:lentxt) = new_line(
'a')
813 write (txt,
'(3a, i0)')
'IA ',
'INTEGER ',
'NDIM 1 ', this%nodesuser + 1
814 txt(lentxt:lentxt) = new_line(
'a')
816 write (txt,
'(3a, i0)')
'JA ',
'INTEGER ',
'NDIM 1 ',
size(this%con%jausr)
817 txt(lentxt:lentxt) = new_line(
'a')
819 write (txt,
'(3a, i0)')
'IDOMAIN ',
'INTEGER ',
'NDIM 1 ', this%nodesuser
820 txt(lentxt:lentxt) = new_line(
'a')
822 write (txt,
'(3a, i0)')
'ICELLTYPE ',
'INTEGER ',
'NDIM 1 ', this%nodesuser
823 txt(lentxt:lentxt) = new_line(
'a')
827 if (version == 2)
then
829 write (txt,
'(3a, i0)')
'CRS ',
'CHARACTER ',
'NDIM 1 ', &
831 txt(lentxt:lentxt) = new_line(
'a')
837 write (iunit) this%nodesuser
838 write (iunit) this%nlay
839 write (iunit) this%ncpl
840 write (iunit) this%nvert
841 write (iunit)
size(this%javert)
842 write (iunit) this%nja
843 write (iunit) this%xorigin
844 write (iunit) this%yorigin
845 write (iunit) this%angrot
846 write (iunit) this%top1d
847 write (iunit) this%bot2d
848 write (iunit) this%vertices
849 write (iunit) (this%cellxy(1, i), i=1, this%ncpl)
850 write (iunit) (this%cellxy(2, i), i=1, this%ncpl)
851 write (iunit) this%iavert
852 write (iunit) this%javert
853 write (iunit) this%con%iausr
854 write (iunit) this%con%jausr
855 write (iunit) this%idomain
856 write (iunit) icelltype
859 if (version == 2)
then
860 if (found_crs)
write (iunit) trim(crs)
873 integer(I4B),
intent(in) :: nodeu
874 character(len=*),
intent(inout) :: str
876 integer(I4B) :: i, j, k
877 character(len=10) :: kstr, jstr
879 call get_ijk(nodeu, 1, this%ncpl, this%nlay, i, j, k)
880 write (kstr,
'(i10)') k
881 write (jstr,
'(i10)') j
882 str =
'('//trim(adjustl(kstr))//
','// &
883 trim(adjustl(jstr))//
')'
892 integer(I4B),
intent(in) :: nodeu
893 integer(I4B),
dimension(:),
intent(inout) :: arr
895 integer(I4B) :: isize
896 integer(I4B) :: i, j, k
900 if (isize /= this%ndim)
then
901 write (
errmsg,
'(a,i0,a,i0,a)') &
902 'Program error: nodeu_to_array size of array (', isize, &
903 ') is not equal to the discretization dimension (', this%ndim,
').'
908 call get_ijk(nodeu, 1, this%ncpl, this%nlay, i, j, k)
920 integer(I4B) :: nodenumber
923 integer(I4B),
intent(in) :: nodeu
924 integer(I4B),
intent(in) :: icheck
928 if (icheck /= 0)
then
931 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
933 write (
errmsg,
'(a,i0,a,i0,a)') &
934 'Node number (', nodeu,
') is less than 1 or greater than nodes (', &
939 if (this%nodes < this%nodesuser) nodenumber = this%nodereduced(nodeu)
943 if (this%nodes < this%nodesuser) nodenumber = this%nodereduced(nodeu)
952 integer(I4B) :: nodenumber
955 integer(I4B),
intent(in) :: k, j
956 integer(I4B),
intent(in) :: icheck
958 integer(I4B) :: nodeu
960 character(len=*),
parameter :: fmterr = &
961 &
"('Error in disv grid cell indices: layer = ',i0,', node = ',i0)"
963 nodeu =
get_node(k, 1, j, this%nlay, 1, this%ncpl)
965 write (
errmsg, fmterr) k, j
969 if (this%nodes < this%nodesuser) nodenumber = this%nodereduced(nodeu)
972 if (icheck /= 0)
then
976 if (k < 1 .or. k > this%nlay)
then
977 write (
errmsg,
'(a,i0,a)') &
978 'Layer number in list (', k,
') is outside of the grid.'
980 if (j < 1 .or. j > this%ncpl)
then
981 write (
errmsg,
'(a,1x,a,i0,a)') &
982 trim(adjustl(
errmsg)),
'Node number in list (', j, &
983 ') is outside of the grid.'
987 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
988 write (
errmsg,
'(a,1x,a,i0,a,i0,a)') &
990 'Node number (', nodeu,
') is less than 1 or greater '// &
991 'than nodes (', this%nodesuser,
').'
994 if (len_trim(adjustl(
errmsg)) > 0)
then
1010 integer(I4B),
intent(in) :: noden
1011 integer(I4B),
intent(in) :: nodem
1012 integer(I4B),
intent(in) :: ihc
1013 real(DP),
intent(inout) :: xcomp
1014 real(DP),
intent(inout) :: ycomp
1015 real(DP),
intent(inout) :: zcomp
1016 integer(I4B),
intent(in) :: ipos
1018 real(DP) :: angle, dmult
1024 if (nodem < noden)
then
1037 angle = this%con%anglex(this%con%jas(ipos))
1039 if (nodem < noden) dmult = -
done
1040 xcomp = cos(angle) * dmult
1041 ycomp = sin(angle) * dmult
1053 xcomp, ycomp, zcomp, conlen)
1056 integer(I4B),
intent(in) :: noden
1057 integer(I4B),
intent(in) :: nodem
1058 logical,
intent(in) :: nozee
1059 real(DP),
intent(in) :: satn
1060 real(DP),
intent(in) :: satm
1061 integer(I4B),
intent(in) :: ihc
1062 real(DP),
intent(inout) :: xcomp
1063 real(DP),
intent(inout) :: ycomp
1064 real(DP),
intent(inout) :: zcomp
1065 real(DP),
intent(inout) :: conlen
1067 integer(I4B) :: nodeu, ncell2d, mcell2d, k
1068 real(DP) :: xn, xm, yn, ym, zn, zm
1076 if (nodem < noden)
then
1081 zn = this%bot(noden) +
dhalf * (this%top(noden) - this%bot(noden))
1082 zm = this%bot(nodem) +
dhalf * (this%top(nodem) - this%bot(nodem))
1083 conlen = abs(zm - zn)
1092 zn = this%bot(noden) +
dhalf * satn * (this%top(noden) - this%bot(noden))
1093 zm = this%bot(nodem) +
dhalf * satm * (this%top(nodem) - this%bot(nodem))
1095 nodeu = this%get_nodeuser(noden)
1096 call get_jk(nodeu, this%ncpl, this%nlay, ncell2d, k)
1097 nodeu = this%get_nodeuser(nodem)
1098 call get_jk(nodeu, this%ncpl, this%nlay, mcell2d, k)
1099 xn = this%cellxy(1, ncell2d)
1100 yn = this%cellxy(2, ncell2d)
1101 xm = this%cellxy(1, mcell2d)
1102 ym = this%cellxy(2, mcell2d)
1113 class(
disvtype),
intent(in) :: this
1114 character(len=*),
intent(out) :: dis_type
1123 class(
disvtype),
intent(in) :: this
1124 integer(I4B) :: dis_enum
1133 character(len=*),
intent(in) :: name_model
1134 character(len=*),
intent(in) :: input_mempath
1137 call this%DisBaseType%allocate_scalars(name_model, input_mempath)
1142 call mem_allocate(this%nvert,
'NVERT', this%memoryPath)
1159 call this%DisBaseType%allocate_arrays()
1162 if (this%nodes < this%nodesuser)
then
1163 call mem_allocate(this%nodeuser, this%nodes,
'NODEUSER', this%memoryPath)
1164 call mem_allocate(this%nodereduced, this%nodesuser,
'NODEREDUCED', &
1167 call mem_allocate(this%nodeuser, 1,
'NODEUSER', this%memoryPath)
1168 call mem_allocate(this%nodereduced, 1,
'NODEREDUCED', this%memoryPath)
1171 this%mshape(1) = this%nlay
1172 this%mshape(2) = this%ncpl
1186 integer(I4B),
intent(in) :: icell2d
1190 integer(I4B) :: ivert
1191 integer(I4B) :: nvert
1192 integer(I4B) :: icount
1200 nvert = this%iavert(icell2d + 1) - this%iavert(icell2d)
1202 iv1 = this%javert(this%iavert(icell2d))
1203 x1 = this%vertices(1, iv1)
1204 y1 = this%vertices(2, iv1)
1205 do ivert = this%iavert(icell2d), this%iavert(icell2d + 1) - 1
1206 x = this%vertices(1, this%javert(ivert))
1207 if (icount < nvert)
then
1208 y = this%vertices(2, this%javert(ivert + 1))
1210 y = this%vertices(2, this%javert(this%iavert(icell2d)))
1212 area = area + (x - x1) * (y - y1)
1217 do ivert = this%iavert(icell2d), this%iavert(icell2d + 1) - 1
1218 y = this%vertices(2, this%javert(ivert))
1219 if (icount < nvert)
then
1220 x = this%vertices(1, this%javert(ivert + 1))
1222 x = this%vertices(1, this%javert(this%iavert(icell2d)))
1224 area = area - (x - x1) * (y - y1)
1239 flag_string, allow_zero)
result(nodeu)
1242 integer(I4B),
intent(inout) :: lloc
1243 integer(I4B),
intent(inout) :: istart
1244 integer(I4B),
intent(inout) :: istop
1245 integer(I4B),
intent(in) :: in
1246 integer(I4B),
intent(in) :: iout
1247 character(len=*),
intent(inout) :: line
1248 logical,
optional,
intent(in) :: flag_string
1249 logical,
optional,
intent(in) :: allow_zero
1250 integer(I4B) :: nodeu
1252 integer(I4B) :: j, k, nlay, nrow, ncpl
1253 integer(I4B) :: lloclocal, ndum, istat, n
1256 if (
present(flag_string))
then
1257 if (flag_string)
then
1260 call urword(line, lloclocal, istart, istop, 1, ndum, r, iout, in)
1261 read (line(istart:istop), *, iostat=istat) n
1262 if (istat /= 0)
then
1270 nlay = this%mshape(1)
1272 ncpl = this%mshape(2)
1274 call urword(line, lloc, istart, istop, 2, k, r, iout, in)
1275 call urword(line, lloc, istart, istop, 2, j, r, iout, in)
1277 if (k == 0 .and. j == 0)
then
1278 if (
present(allow_zero))
then
1279 if (allow_zero)
then
1288 if (k < 1 .or. k > nlay)
then
1289 write (
errmsg,
'(a,i0,a)') &
1290 'Layer number in list (', k,
') is outside of the grid.'
1292 if (j < 1 .or. j > ncpl)
then
1293 write (
errmsg,
'(a,1x,a,i0,a)') &
1294 trim(adjustl(
errmsg)),
'Cell2d number in list (', j, &
1295 ') is outside of the grid.'
1298 nodeu =
get_node(k, 1, j, nlay, nrow, ncpl)
1300 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1301 write (
errmsg,
'(a,1x,a,i0,a)') &
1303 "Node number in list (", nodeu,
") is outside of the grid. "// &
1304 "Cell number cannot be determined in line '"// &
1305 trim(adjustl(line))//
"'."
1308 if (len_trim(adjustl(
errmsg)) > 0)
then
1324 allow_zero)
result(nodeu)
1326 integer(I4B) :: nodeu
1329 character(len=*),
intent(inout) :: cellid
1330 integer(I4B),
intent(in) :: inunit
1331 integer(I4B),
intent(in) :: iout
1332 logical,
optional,
intent(in) :: flag_string
1333 logical,
optional,
intent(in) :: allow_zero
1335 integer(I4B) :: j, k, nlay, nrow, ncpl
1336 integer(I4B) :: lloclocal, ndum, istat, n
1337 integer(I4B) :: istart, istop
1340 if (
present(flag_string))
then
1341 if (flag_string)
then
1344 call urword(cellid, lloclocal, istart, istop, 1, ndum, r, iout, inunit)
1345 read (cellid(istart:istop), *, iostat=istat) n
1346 if (istat /= 0)
then
1354 nlay = this%mshape(1)
1356 ncpl = this%mshape(2)
1359 call urword(cellid, lloclocal, istart, istop, 2, k, r, iout, inunit)
1360 call urword(cellid, lloclocal, istart, istop, 2, j, r, iout, inunit)
1362 if (k == 0 .and. j == 0)
then
1363 if (
present(allow_zero))
then
1364 if (allow_zero)
then
1373 if (k < 1 .or. k > nlay)
then
1374 write (
errmsg,
'(a,i0,a)') &
1375 'Layer number in list (', k,
') is outside of the grid.'
1377 if (j < 1 .or. j > ncpl)
then
1378 write (
errmsg,
'(a,1x,a,i0,a)') &
1379 trim(adjustl(
errmsg)),
'Cell2d number in list (', j, &
1380 ') is outside of the grid.'
1383 nodeu =
get_node(k, 1, j, nlay, nrow, ncpl)
1385 if (nodeu < 1 .or. nodeu > this%nodesuser)
then
1386 write (
errmsg,
'(a,1x,a,i0,a)') &
1388 "Cell number cannot be determined for cellid ("// &
1389 trim(adjustl(cellid))//
") and results in a user "// &
1390 "node number (", nodeu,
") that is outside of the grid."
1393 if (len_trim(adjustl(
errmsg)) > 0)
then
1427 class(
disvtype),
intent(inout) :: this
1428 integer(I4B),
intent(in) :: ic
1429 real(DP),
allocatable,
intent(out) :: polyverts(:, :)
1430 logical(LGP),
intent(in),
optional :: closed
1432 integer(I4B) :: icu, icu2d, iavert, ncpl, nverts, m, j
1433 logical(LGP) :: lclosed
1436 ncpl = this%get_ncpl()
1437 icu = this%get_nodeuser(ic)
1438 icu2d = icu - ((icu - 1) / ncpl) * ncpl
1439 nverts = this%iavert(icu2d + 1) - this%iavert(icu2d) - 1
1440 if (nverts .le. 0) nverts = nverts +
size(this%javert)
1443 if (.not. (
present(closed)))
then
1451 allocate (polyverts(2, nverts + 1))
1453 allocate (polyverts(2, nverts))
1457 iavert = this%iavert(icu2d)
1459 j = this%javert(iavert - 1 + m)
1460 polyverts(:, m) = (/this%vertices(1, j), this%vertices(2, j)/)
1465 polyverts(:, nverts + 1) = polyverts(:, 1)
1474 class(
disvtype),
intent(inout) :: this
1475 character(len=*),
intent(inout) :: line
1476 integer(I4B),
intent(inout) :: lloc
1477 integer(I4B),
intent(inout) :: istart
1478 integer(I4B),
intent(inout) :: istop
1479 integer(I4B),
intent(in) :: in
1480 integer(I4B),
intent(in) :: iout
1481 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(inout) :: iarray
1482 character(len=*),
intent(in) :: aname
1484 integer(I4B) :: ival
1486 integer(I4B) :: nlay
1487 integer(I4B) :: nrow
1488 integer(I4B) :: ncol
1489 integer(I4B) :: nval
1490 integer(I4B),
dimension(:),
pointer,
contiguous :: itemp
1496 nlay = this%mshape(1)
1498 ncol = this%mshape(2)
1500 if (this%nodes < this%nodesuser)
then
1501 nval = this%nodesuser
1509 call urword(line, lloc, istart, istop, 1, ival, rval, iout, in)
1510 if (line(istart:istop) .EQ.
'LAYERED')
then
1513 call readarray(in, itemp, aname, this%ndim, ncol, nrow, nlay, nval, &
1518 call readarray(in, itemp, aname, this%ndim, nval, iout, 0)
1522 if (this%nodes < this%nodesuser)
then
1523 call this%fill_grid_array(itemp, iarray)
1533 class(
disvtype),
intent(inout) :: this
1534 character(len=*),
intent(inout) :: line
1535 integer(I4B),
intent(inout) :: lloc
1536 integer(I4B),
intent(inout) :: istart
1537 integer(I4B),
intent(inout) :: istop
1538 integer(I4B),
intent(in) :: in
1539 integer(I4B),
intent(in) :: iout
1540 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: darray
1541 character(len=*),
intent(in) :: aname
1543 integer(I4B) :: ival
1545 integer(I4B) :: nlay
1546 integer(I4B) :: nrow
1547 integer(I4B) :: ncol
1548 integer(I4B) :: nval
1549 real(DP),
dimension(:),
pointer,
contiguous :: dtemp
1555 nlay = this%mshape(1)
1557 ncol = this%mshape(2)
1559 if (this%nodes < this%nodesuser)
then
1560 nval = this%nodesuser
1568 call urword(line, lloc, istart, istop, 1, ival, rval, iout, in)
1569 if (line(istart:istop) .EQ.
'LAYERED')
then
1572 call readarray(in, dtemp, aname, this%ndim, ncol, nrow, nlay, nval, &
1577 call readarray(in, dtemp, aname, this%ndim, nval, iout, 0)
1581 if (this%nodes < this%nodesuser)
then
1582 call this%fill_grid_array(dtemp, darray)
1593 icolbnd, aname, inunit, iout)
1596 integer(I4B),
intent(in) :: ncolbnd
1597 integer(I4B),
intent(in) :: maxbnd
1598 integer(I4B),
dimension(maxbnd) :: nodelist
1599 real(DP),
dimension(ncolbnd, maxbnd),
intent(inout) :: darray
1600 integer(I4B),
intent(in) :: icolbnd
1601 character(len=*),
intent(in) :: aname
1602 integer(I4B),
intent(in) :: inunit
1603 integer(I4B),
intent(in) :: iout
1605 integer(I4B) :: ir, ic, ncol, nrow, nlay, nval, ipos, nodeu
1608 nlay = this%mshape(1)
1610 ncol = this%mshape(2)
1614 call readarray(inunit, this%dbuff, aname, this%ndim, nval, iout, 0)
1623 nodeu =
get_node(1, ir, ic, nlay, nrow, ncol)
1624 darray(icolbnd, ipos) = this%dbuff(nodeu)
1637 cdatafmp, nvaluesp, nwidthp, editdesc, dinact)
1639 class(
disvtype),
intent(inout) :: this
1640 real(DP),
dimension(:),
pointer,
contiguous,
intent(inout) :: darray
1641 integer(I4B),
intent(in) :: iout
1642 integer(I4B),
intent(in) :: iprint
1643 integer(I4B),
intent(in) :: idataun
1644 character(len=*),
intent(in) :: aname
1645 character(len=*),
intent(in) :: cdatafmp
1646 integer(I4B),
intent(in) :: nvaluesp
1647 integer(I4B),
intent(in) :: nwidthp
1648 character(len=*),
intent(in) :: editdesc
1649 real(DP),
intent(in) :: dinact
1651 integer(I4B) :: k, ifirst
1652 integer(I4B) :: nlay
1653 integer(I4B) :: nrow
1654 integer(I4B) :: ncol
1655 integer(I4B) :: nval
1656 integer(I4B) :: nodeu, noder
1657 integer(I4B) :: istart, istop
1658 real(DP),
dimension(:),
pointer,
contiguous :: dtemp
1660 character(len=*),
parameter :: fmthsv = &
1661 "(1X,/1X,a,' WILL BE SAVED ON UNIT ',I4, &
1662 &' AT END OF TIME STEP',I5,', STRESS PERIOD ',I4)"
1665 nlay = this%mshape(1)
1667 ncol = this%mshape(2)
1671 if (this%nodes < this%nodesuser)
then
1674 do nodeu = 1, this%nodesuser
1675 noder = this%get_nodenumber(nodeu, 0)
1676 if (noder <= 0)
then
1677 dtemp(nodeu) = dinact
1680 dtemp(nodeu) = darray(noder)
1688 if (iprint /= 0)
then
1691 istop = istart + nrow * ncol - 1
1693 aname, cdatafmp, nvaluesp, nwidthp, editdesc)
1699 if (idataun > 0)
then
1704 istop = istart + nrow * ncol - 1
1705 if (ifirst == 1)
write (iout, fmthsv) &
1706 trim(adjustl(aname)), idataun, &
1713 elseif (idataun < 0)
then
1716 call ubdsv1(
kstp,
kper, aname, -idataun, dtemp, ncol, nrow, nlay, &
1725 dstmodel, dstpackage, naux, auxtxt, &
1726 ibdchn, nlist, iout)
1729 character(len=16),
intent(in) :: text
1730 character(len=16),
intent(in) :: textmodel
1731 character(len=16),
intent(in) :: textpackage
1732 character(len=16),
intent(in) :: dstmodel
1733 character(len=16),
intent(in) :: dstpackage
1734 integer(I4B),
intent(in) :: naux
1735 character(len=16),
dimension(:),
intent(in) :: auxtxt
1736 integer(I4B),
intent(in) :: ibdchn
1737 integer(I4B),
intent(in) :: nlist
1738 integer(I4B),
intent(in) :: iout
1740 integer(I4B) :: nlay, nrow, ncol
1742 nlay = this%mshape(1)
1744 ncol = this%mshape(2)
1747 call ubdsv06(
kstp,
kper, text, textmodel, textpackage, dstmodel, dstpackage, &
1748 ibdchn, naux, auxtxt, ncol, nrow, nlay, &
1758 integer(I4B),
intent(in) :: maxbnd
1759 integer(I4B),
dimension(:),
pointer,
contiguous :: darray
1760 integer(I4B),
dimension(maxbnd),
intent(inout) :: nodelist
1761 integer(I4B),
intent(inout) :: nbound
1762 character(len=*),
intent(in) :: aname
1764 integer(I4B) :: il, ir, ic, ncol, nrow, nlay, nval, nodeu, noder, ipos, ierr
1767 nlay = this%mshape(1)
1769 ncol = this%mshape(2)
1778 nodeu =
get_node(1, ir, ic, nlay, nrow, ncol)
1780 if (il < 1 .or. il > nlay)
then
1781 write (
errmsg,
'(a,i0,a)') &
1782 'Invalid layer number (', il,
').'
1785 nodeu =
get_node(il, ir, ic, nlay, nrow, ncol)
1786 noder = this%get_nodenumber(nodeu, 0)
1787 if (ipos > maxbnd)
then
1790 nodelist(ipos) = noder
1799 write (
errmsg,
'(a,i0,a)') &
1800 'MAXBOUND dimension is too small. Increase MAXBOUND to ', ierr,
'.'
1805 if (nbound < maxbnd)
then
1806 do ipos = nbound + 1, maxbnd
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
@ disv
DISU6 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, 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,...
subroutine write_grb(this, icelltype)
Write a binary grid file.
real(dp) function get_cell2d_area(this, icell2d)
Get the signed area of the cell.
integer(i4b) function get_ncpl(this)
Get number of cells per layer (ncpl)
subroutine record_array(this, darray, iout, iprint, idataun, aname, cdatafmp, nvaluesp, nwidthp, editdesc, dinact)
Record a double precision array.
subroutine grid_finalize(this)
Finalize grid (check properties, allocate arrays, compute connections)
subroutine log_dimensions(this, found)
Write dimensions to list file.
subroutine log_griddata(this, found)
Write griddata found to list file.
subroutine disv_da(this)
Deallocate variables.
subroutine source_dimensions(this)
Copy dimensions from IDM into package.
subroutine log_options(this, found)
Write user options to list file.
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.
integer(i4b) function get_nodenumber_idx2(this, k, j, icheck)
Get reduced node number from layer and within-layer node indices.
subroutine nodeu_to_string(this, nodeu, str)
Convert a user nodenumber to a string (nodenumber) or (k,j)
subroutine nlarray_to_nodelist(this, darray, nodelist, maxbnd, nbound, aname)
Convert an integer array (layer numbers) to nodelist.
integer(i4b) function get_nodenumber_idx1(this, nodeu, icheck)
Get reduced node number from user node number.
subroutine get_polyverts(this, ic, polyverts, closed)
Get a 2D array of polygon vertices, listed in clockwise order beginning with the lower left corner.
subroutine disv_df(this)
Define the discretization.
subroutine record_srcdst_list_header(this, text, textmodel, textpackage, dstmodel, dstpackage, naux, auxtxt, ibdchn, nlist, iout)
Record list header for imeth=6.
subroutine read_dbl_array(this, line, lloc, istart, istop, iout, in, darray, aname)
Read a double precision array.
subroutine source_cell2d(this)
Copy cell2d data from IDM into package.
subroutine source_options(this)
Copy options from IDM into package.
subroutine nodeu_to_array(this, nodeu, arr)
Convert a user nodenumber to an array (nodenumber) or (k,j)
subroutine connect(this)
Build grid connections.
integer(i4b) function nodeu_from_cellid(this, cellid, inunit, iout, flag_string, allow_zero)
Convert a cellid string to a user nodenumber.
subroutine source_griddata(this)
Copy grid data from IDM into package.
subroutine disv_load(this)
Transfer IDM data into this discretization object.
subroutine, public disv_cr(dis, name_model, input_mempath, inunit, iout)
Create a new discretization by vertices object.
subroutine define_cellverts(this, icell2d, ncvert, icvert)
Build data structures to hold cell vertex info.
subroutine source_vertices(this)
Load grid vertices from IDM into package.
subroutine read_int_array(this, line, lloc, istart, istop, iout, in, iarray, aname)
Read an integer array.
subroutine read_layer_array(this, nodelist, darray, ncolbnd, maxbnd, icolbnd, aname, inunit, iout)
Read a 2d double array into col icolbnd of darray.
subroutine connection_normal(this, noden, nodem, ihc, xcomp, ycomp, zcomp, ipos)
Get normal vector components between the cell and a given neighbor.
subroutine allocate_arrays(this)
Allocate and initialize arrays.
subroutine get_dis_type(this, dis_type)
Get the discretization type.
subroutine allocate_scalars(this, name_model, input_mempath)
Allocate and initialize scalars.
logical function supports_layers(this)
Indicates whether the grid discretization supports layers.
integer(i4b) function get_dis_enum(this)
Get the discretization type enumeration.
integer(i4b) function nodeu_from_string(this, lloc, istart, istop, in, iout, line, flag_string, allow_zero)
Convert a string to a user nodenumber.
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
subroutine, public get_ijk(nodenumber, nrow, ncol, nlay, irow, icol, ilay)
Get row, column and layer indices from node number and grid dimensions. If nodenumber is invalid,...
subroutine, public get_jk(nodenumber, ncpl, nlay, icpl, ilay)
Get layer index and within-layer node index from node number and grid dimensions. If nodenumber is in...
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
Vertex grid discretization.