From 5b12e3d992956bf3dc6429364aba803bb9da0295 Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Thu, 7 Dec 2023 08:14:03 -0500 Subject: [PATCH] refactor(GeomUtil): move get_ijk, get_jk, get_node from InputOutput (#1488) --- autotest/TestGeomUtil.f90 | 49 ++++++++++- autotest/TestInputOutput.f90 | 51 +---------- make/makefile | 58 +++++++------ src/Model/GroundWaterFlow/gwf3csub8.f90 | 3 +- src/Model/GroundWaterFlow/gwf3dis8.f90 | 3 +- src/Model/GroundWaterFlow/gwf3disv8.f90 | 3 +- src/Model/GroundWaterFlow/gwf3evt8.f90 | 2 +- src/Model/GroundWaterFlow/gwf3lak8.f90 | 3 +- src/Model/GroundWaterFlow/gwf3maw8.f90 | 3 +- src/Model/GroundWaterFlow/gwf3rch8.f90 | 3 +- .../ModelUtilities/BoundaryPackageExt.f90 | 5 +- src/Model/ModelUtilities/Connections.f90 | 4 +- src/Model/ModelUtilities/DisvGeom.f90 | 2 +- src/Utilities/GeomUtil.f90 | 69 ++++++++++++++- src/Utilities/InputOutput.f90 | 86 +------------------ src/Utilities/ListReader.f90 | 6 +- utils/mf5to6/make/makefile | 1 + utils/mf5to6/msvs/mf5to6.vfproj | 1 + utils/mf5to6/pymake/extrafiles.txt | 1 + utils/mf5to6/src/Exchange.f90 | 2 +- utils/mf5to6/src/Preproc/Discretization3D.f90 | 5 +- .../src/Preproc/DiscretizationBasePHMF.f90 | 2 +- utils/zonebudget/make/makefile | 1 + utils/zonebudget/msvs/zonebudget.vfproj | 1 + utils/zonebudget/pymake/extrafiles.txt | 1 + 25 files changed, 179 insertions(+), 186 deletions(-) diff --git a/autotest/TestGeomUtil.f90 b/autotest/TestGeomUtil.f90 index c7f9f73ed7d..56a9190439f 100644 --- a/autotest/TestGeomUtil.f90 +++ b/autotest/TestGeomUtil.f90 @@ -2,7 +2,7 @@ module TestGeomUtil use KindModule, only: I4B, DP use testdrive, only: check, error_type, new_unittest, test_failed, & to_string, unittest_type - use GeomUtilModule, only: point_in_polygon + use GeomUtilModule, only: get_node, get_ijk, get_jk, point_in_polygon use ConstantsModule, only: LINELENGTH implicit none private @@ -14,6 +14,8 @@ module TestGeomUtil subroutine collect_geomutil(testsuite) type(unittest_type), allocatable, intent(out) :: testsuite(:) testsuite = [ & + new_unittest("get_node_get_ijk", & + test_get_node_get_ijk), & new_unittest("point_in_polygon_sq", & test_point_in_polygon_sq), & new_unittest("point_in_polygon_tri", & @@ -25,6 +27,51 @@ end subroutine collect_geomutil ! 2D arrays for polygons and check points use column-major indexing + subroutine test_get_node_get_ijk(error) + type(error_type), allocatable, intent(out) :: error + integer :: ilay + integer :: irow + integer :: icol + integer :: nlay + integer :: nrow + integer :: ncol + integer :: nnum + integer :: ncls + integer :: k, i, j + + ! trivial grid with 1 cell + nnum = get_node(1, 1, 1, 1, 1, 1) + call get_ijk(nnum, 1, 1, 1, ilay, irow, icol) + call check(error, nnum == 1) + call check(error, ilay == 1) + call check(error, irow == 1) + call check(error, icol == 1) + if (allocated(error)) return + + ! small grid, 3x4x5 + nlay = 3 + nrow = 4 + ncol = 5 + ncls = nlay * nrow * ncol + do k = 1, nlay + do i = 1, nrow + do j = 1, ncol + ! node number from ijk + nnum = get_node(k, i, j, nlay, nrow, ncol) + call check(error, nnum == (k - 1) * nrow * ncol + (i - 1) * ncol + j) + if (allocated(error)) return + + ! ijk from node number + call get_ijk(nnum, nrow, ncol, nlay, irow, icol, ilay) + call check(error, ilay == k) + call check(error, irow == i) + call check(error, icol == j) + if (allocated(error)) return + end do + end do + end do + end subroutine test_get_node_get_ijk + subroutine test_point_in_polygon(error, shape, & poly, in_pts, out_pts, vert_pts, face_pts) type(error_type), allocatable, intent(inout) :: error diff --git a/autotest/TestInputOutput.f90 b/autotest/TestInputOutput.f90 index 4ebc484dadb..49ca3483321 100644 --- a/autotest/TestInputOutput.f90 +++ b/autotest/TestInputOutput.f90 @@ -1,7 +1,7 @@ module TestInputOutput use testdrive, only: error_type, unittest_type, new_unittest, check use ConstantsModule, only: LINELENGTH - use InputOutputModule, only: get_node, get_ijk + ! use InputOutputModule, only: ??? implicit none private public :: collect_inputoutput @@ -10,54 +10,7 @@ module TestInputOutput subroutine collect_inputoutput(testsuite) type(unittest_type), allocatable, intent(out) :: testsuite(:) - testsuite = [ & - new_unittest("get_node_get_ijk", test_get_node_get_ijk) & - ] + allocate (testsuite(0)) end subroutine collect_inputoutput - subroutine test_get_node_get_ijk(error) - type(error_type), allocatable, intent(out) :: error - integer :: ilay - integer :: irow - integer :: icol - integer :: nlay - integer :: nrow - integer :: ncol - integer :: nnum - integer :: ncls - integer :: k, i, j - - ! trivial grid with 1 cell - nnum = get_node(1, 1, 1, 1, 1, 1) - call get_ijk(nnum, 1, 1, 1, ilay, irow, icol) - call check(error, nnum == 1) - call check(error, ilay == 1) - call check(error, irow == 1) - call check(error, icol == 1) - if (allocated(error)) return - - ! small grid, 3x4x5 - nlay = 3 - nrow = 4 - ncol = 5 - ncls = nlay * nrow * ncol - do k = 1, nlay - do i = 1, nrow - do j = 1, ncol - ! node number from ijk - nnum = get_node(k, i, j, nlay, nrow, ncol) - call check(error, nnum == (k - 1) * nrow * ncol + (i - 1) * ncol + j) - if (allocated(error)) return - - ! ijk from node number - call get_ijk(nnum, nrow, ncol, nlay, irow, icol, ilay) - call check(error, ilay == k) - call check(error, irow == i) - call check(error, icol == j) - if (allocated(error)) return - end do - end do - end do - end subroutine test_get_node_get_ijk - end module TestInputOutput diff --git a/make/makefile b/make/makefile index 8d594705129..b64b631395e 100644 --- a/make/makefile +++ b/make/makefile @@ -9,32 +9,33 @@ SOURCEDIR2=../src/Exchange SOURCEDIR3=../src/Distributed SOURCEDIR4=../src/Solution SOURCEDIR5=../src/Solution/LinearMethods -SOURCEDIR6=../src/Solution/PETSc -SOURCEDIR7=../src/Timing -SOURCEDIR8=../src/Utilities -SOURCEDIR9=../src/Utilities/Idm -SOURCEDIR10=../src/Utilities/Idm/selector -SOURCEDIR11=../src/Utilities/Idm/mf6blockfile -SOURCEDIR12=../src/Utilities/TimeSeries -SOURCEDIR13=../src/Utilities/Memory -SOURCEDIR14=../src/Utilities/OutputControl -SOURCEDIR15=../src/Utilities/ArrayRead -SOURCEDIR16=../src/Utilities/Libraries -SOURCEDIR17=../src/Utilities/Libraries/rcm -SOURCEDIR18=../src/Utilities/Libraries/blas -SOURCEDIR19=../src/Utilities/Libraries/sparskit2 -SOURCEDIR20=../src/Utilities/Libraries/daglib -SOURCEDIR21=../src/Utilities/Libraries/sparsekit -SOURCEDIR22=../src/Utilities/Vector -SOURCEDIR23=../src/Utilities/Matrix -SOURCEDIR24=../src/Utilities/Observation -SOURCEDIR25=../src/Model -SOURCEDIR26=../src/Model/Connection -SOURCEDIR27=../src/Model/GroundWaterTransport -SOURCEDIR28=../src/Model/ModelUtilities -SOURCEDIR29=../src/Model/GroundWaterFlow -SOURCEDIR30=../src/Model/TransportModel -SOURCEDIR31=../src/Model/Geometry +SOURCEDIR6=../src/Solution/ParticleTracker +SOURCEDIR7=../src/Solution/PETSc +SOURCEDIR8=../src/Timing +SOURCEDIR9=../src/Utilities +SOURCEDIR10=../src/Utilities/Idm +SOURCEDIR11=../src/Utilities/Idm/selector +SOURCEDIR12=../src/Utilities/Idm/mf6blockfile +SOURCEDIR13=../src/Utilities/TimeSeries +SOURCEDIR14=../src/Utilities/Memory +SOURCEDIR15=../src/Utilities/OutputControl +SOURCEDIR16=../src/Utilities/ArrayRead +SOURCEDIR17=../src/Utilities/Libraries +SOURCEDIR18=../src/Utilities/Libraries/rcm +SOURCEDIR19=../src/Utilities/Libraries/blas +SOURCEDIR20=../src/Utilities/Libraries/sparskit2 +SOURCEDIR21=../src/Utilities/Libraries/daglib +SOURCEDIR22=../src/Utilities/Libraries/sparsekit +SOURCEDIR23=../src/Utilities/Vector +SOURCEDIR24=../src/Utilities/Matrix +SOURCEDIR25=../src/Utilities/Observation +SOURCEDIR26=../src/Model +SOURCEDIR27=../src/Model/Connection +SOURCEDIR28=../src/Model/GroundWaterTransport +SOURCEDIR29=../src/Model/ModelUtilities +SOURCEDIR30=../src/Model/GroundWaterFlow +SOURCEDIR31=../src/Model/TransportModel +SOURCEDIR32=../src/Model/Geometry VPATH = \ ${SOURCEDIR1} \ @@ -67,7 +68,8 @@ ${SOURCEDIR27} \ ${SOURCEDIR28} \ ${SOURCEDIR29} \ ${SOURCEDIR30} \ -${SOURCEDIR31} +${SOURCEDIR31} \ +${SOURCEDIR32} .SUFFIXES: .f90 .F90 .o @@ -99,6 +101,7 @@ $(OBJDIR)/BlockParser.o \ $(OBJDIR)/MemoryManager.o \ $(OBJDIR)/TimeSeries.o \ $(OBJDIR)/ats.o \ +$(OBJDIR)/GeomUtil.o \ $(OBJDIR)/TimeSeriesLink.o \ $(OBJDIR)/TimeSeriesFileList.o \ $(OBJDIR)/tdis.o \ @@ -326,7 +329,6 @@ $(OBJDIR)/sparsekit.o \ $(OBJDIR)/rcm.o \ $(OBJDIR)/blas1_d.o \ $(OBJDIR)/Iunit.o \ -$(OBJDIR)/GeomUtil.o \ $(OBJDIR)/RectangularGeometry.o \ $(OBJDIR)/CircularGeometry.o diff --git a/src/Model/GroundWaterFlow/gwf3csub8.f90 b/src/Model/GroundWaterFlow/gwf3csub8.f90 index d7de64d3635..28fbb247d79 100644 --- a/src/Model/GroundWaterFlow/gwf3csub8.f90 +++ b/src/Model/GroundWaterFlow/gwf3csub8.f90 @@ -29,7 +29,8 @@ module GwfCsubModule use BlockParserModule, only: BlockParserType use TimeSeriesLinkModule, only: TimeSeriesLinkType, & GetTimeSeriesLinkFromList - use InputOutputModule, only: get_node, extract_idnum_or_bndname + use GeomUtilModule, only: get_node + use InputOutputModule, only: extract_idnum_or_bndname use BaseDisModule, only: DisBaseType use SimModule, only: count_errors, store_error, store_error_unit, & store_warning diff --git a/src/Model/GroundWaterFlow/gwf3dis8.f90 b/src/Model/GroundWaterFlow/gwf3dis8.f90 index 02e7edf5220..5ddb0adb81b 100644 --- a/src/Model/GroundWaterFlow/gwf3dis8.f90 +++ b/src/Model/GroundWaterFlow/gwf3dis8.f90 @@ -5,7 +5,8 @@ module GwfDisModule use ConstantsModule, only: LINELENGTH, DHALF, DONE, DZERO, & LENMEMPATH, LENVARNAME use BaseDisModule, only: DisBaseType - use InputOutputModule, only: get_node, get_ijk, URWORD, ulasav, ulaprufw, & + use GeomUtilModule, only: get_node, get_ijk + use InputOutputModule, only: URWORD, ulasav, ulaprufw, & ubdsv1, ubdsv06, urword, getunit, openfile use SimModule, only: count_errors, store_error, store_error_unit, & store_error_filename diff --git a/src/Model/GroundWaterFlow/gwf3disv8.f90 b/src/Model/GroundWaterFlow/gwf3disv8.f90 index fdc68387b17..41237ddacf8 100644 --- a/src/Model/GroundWaterFlow/gwf3disv8.f90 +++ b/src/Model/GroundWaterFlow/gwf3disv8.f90 @@ -5,7 +5,8 @@ module GwfDisvModule use ConstantsModule, only: LINELENGTH, LENMEMPATH, LENVARNAME, & DZERO, DONE, DHALF use BaseDisModule, only: DisBaseType - use InputOutputModule, only: get_node, get_ijk, get_jk, URWORD, ulasav, & + use GeomUtilModule, only: get_node, get_ijk, get_jk + use InputOutputModule, only: URWORD, ulasav, & ulaprufw, ubdsv1, ubdsv06, getunit, openfile use SimModule, only: count_errors, store_error, store_error_unit, & store_error_filename diff --git a/src/Model/GroundWaterFlow/gwf3evt8.f90 b/src/Model/GroundWaterFlow/gwf3evt8.f90 index dff33eab36f..54e39301aaf 100644 --- a/src/Model/GroundWaterFlow/gwf3evt8.f90 +++ b/src/Model/GroundWaterFlow/gwf3evt8.f90 @@ -12,6 +12,7 @@ module EvtModule use BlockParserModule, only: BlockParserType use CharacterStringModule, only: CharacterStringType use MatrixBaseModule + use GeomUtilModule, only: get_node ! implicit none ! @@ -794,7 +795,6 @@ end subroutine evt_define_listlabel !< subroutine default_nodelist(this) ! -- modules - use InputOutputModule, only: get_node use SimModule, only: store_error use ConstantsModule, only: LINELENGTH ! -- dummy diff --git a/src/Model/GroundWaterFlow/gwf3lak8.f90 b/src/Model/GroundWaterFlow/gwf3lak8.f90 index e7a137c95bc..cd5e43a6b46 100644 --- a/src/Model/GroundWaterFlow/gwf3lak8.f90 +++ b/src/Model/GroundWaterFlow/gwf3lak8.f90 @@ -23,7 +23,8 @@ module LakModule use TableModule, only: TableType, table_cr use ObserveModule, only: ObserveType use ObsModule, only: ObsType - use InputOutputModule, only: get_node, URWORD, extract_idnum_or_bndname + use GeomUtilModule, only: get_node + use InputOutputModule, only: URWORD, extract_idnum_or_bndname use BaseDisModule, only: DisBaseType use SimModule, only: count_errors, store_error, store_error_unit, & deprecation_warning diff --git a/src/Model/GroundWaterFlow/gwf3maw8.f90 b/src/Model/GroundWaterFlow/gwf3maw8.f90 index 216c8a76108..df40289b0d3 100644 --- a/src/Model/GroundWaterFlow/gwf3maw8.f90 +++ b/src/Model/GroundWaterFlow/gwf3maw8.f90 @@ -18,7 +18,8 @@ module MawModule use TableModule, only: TableType, table_cr use ObserveModule, only: ObserveType use ObsModule, only: ObsType - use InputOutputModule, only: get_node, URWORD, extract_idnum_or_bndname, & + use GeomUtilModule, only: get_node + use InputOutputModule, only: URWORD, extract_idnum_or_bndname, & GetUnit, openfile use BaseDisModule, only: DisBaseType use SimModule, only: count_errors, store_error, store_error_unit, & diff --git a/src/Model/GroundWaterFlow/gwf3rch8.f90 b/src/Model/GroundWaterFlow/gwf3rch8.f90 index 99877b3e33b..38d83efbfbd 100644 --- a/src/Model/GroundWaterFlow/gwf3rch8.f90 +++ b/src/Model/GroundWaterFlow/gwf3rch8.f90 @@ -13,6 +13,7 @@ module RchModule use BlockParserModule, only: BlockParserType use CharacterStringModule, only: CharacterStringType use MatrixBaseModule + use GeomUtilModule, only: get_node ! implicit none ! @@ -472,8 +473,6 @@ end subroutine rch_define_listlabel !! Equivalent to reading IRCH as CONSTANT 1 !< subroutine default_nodelist(this) - ! -- modules - use InputOutputModule, only: get_node ! -- dummy class(RchType) :: this ! -- local diff --git a/src/Model/ModelUtilities/BoundaryPackageExt.f90 b/src/Model/ModelUtilities/BoundaryPackageExt.f90 index a7e4d2eb504..16d6e7e3975 100644 --- a/src/Model/ModelUtilities/BoundaryPackageExt.f90 +++ b/src/Model/ModelUtilities/BoundaryPackageExt.f90 @@ -14,6 +14,7 @@ module BndExtModule use SimVariablesModule, only: errmsg use SimModule, only: store_error, count_errors, store_error_filename use BndModule, only: BndType + use GeomUtilModule, only: get_node, get_ijk implicit none @@ -466,7 +467,6 @@ end subroutine source_dimensions subroutine nodelist_update(this) ! -- modules use SimVariablesModule, only: errmsg - use InputOutputModule, only: get_node ! -- dummy class(BndExtType) :: this !< BndExtType object ! -- local @@ -530,7 +530,6 @@ end subroutine nodelist_update subroutine check_cellid(this, ii, cellid, mshape, ndim) ! -- modules use SimVariablesModule, only: errmsg - use InputOutputModule, only: get_node ! -- dummy class(BndExtType) :: this !< BndExtType object ! -- local @@ -596,7 +595,7 @@ subroutine write_list(this) ! -- modules use ConstantsModule, only: LINELENGTH, LENBOUNDNAME, & TABLEFT, TABCENTER, DZERO - use InputOutputModule, only: ulstlb, get_ijk + use InputOutputModule, only: ulstlb use TableModule, only: TableType, table_cr ! -- dummy class(BndExtType) :: this !< BndExtType object diff --git a/src/Model/ModelUtilities/Connections.f90 b/src/Model/ModelUtilities/Connections.f90 index 9dfaec39fae..e6e0ba44cee 100644 --- a/src/Model/ModelUtilities/Connections.f90 +++ b/src/Model/ModelUtilities/Connections.f90 @@ -6,6 +6,7 @@ module ConnectionsModule use GenericUtilitiesModule, only: sim_message use SimVariablesModule, only: errmsg use BlockParserModule, only: BlockParserType + use GeomUtilModule, only: get_node implicit none private @@ -513,7 +514,6 @@ subroutine disconnections(this, name_model, nodes, ncol, nrow, nlay, & ! -- modules use ConstantsModule, only: DHALF, DZERO, DTHREE, DTWO, DPI use SparseModule, only: sparsematrix - use InputOutputModule, only: get_node ! -- dummy class(ConnectionsType) :: this character(len=*), intent(in) :: name_model @@ -762,7 +762,6 @@ subroutine disvconnections(this, name_model, nodes, ncpl, nlay, nrsize, & ! -- modules use ConstantsModule, only: DHALF, DZERO, DTHREE, DTWO, DPI use SparseModule, only: sparsematrix - use InputOutputModule, only: get_node use DisvGeom, only: DisvGeomType use MemoryManagerModule, only: mem_reallocate ! -- dummy @@ -1196,7 +1195,6 @@ subroutine vertexconnect(nodes, nrsize, maxnnz, nlay, ncpl, sparse, & ! ------------------------------------------------------------------------------ ! -- modules use SparseModule, only: sparsematrix - use InputOutputModule, only: get_node use DisvGeom, only: DisvGeomType ! -- dummy integer(I4B), intent(in) :: nodes diff --git a/src/Model/ModelUtilities/DisvGeom.f90 b/src/Model/ModelUtilities/DisvGeom.f90 index d21a10b80ec..603c7705c8e 100644 --- a/src/Model/ModelUtilities/DisvGeom.f90 +++ b/src/Model/ModelUtilities/DisvGeom.f90 @@ -1,7 +1,7 @@ module DisvGeom use KindModule, only: DP, I4B - use InputOutputModule, only: get_node, get_jk + use GeomUtilModule, only: get_node, get_jk implicit none private public :: DisvGeomType diff --git a/src/Utilities/GeomUtil.f90 b/src/Utilities/GeomUtil.f90 index f6014f56c23..0fa64664976 100644 --- a/src/Utilities/GeomUtil.f90 +++ b/src/Utilities/GeomUtil.f90 @@ -2,7 +2,7 @@ module GeomUtilModule use KindModule, only: I4B, DP implicit none private - public :: between, point_in_polygon + public :: between, point_in_polygon, get_node, get_ijk, get_jk contains !> @brief Check if a value is between two other values (inclusive). @@ -64,4 +64,71 @@ logical function point_in_polygon(x, y, poly) end do end function point_in_polygon + !> @brief Get node number, given layer, row, and column indices + !! for a structured grid. If any argument is invalid return -1. + function get_node(ilay, irow, icol, nlay, nrow, ncol) + integer(I4B), intent(in) :: ilay, irow, icol, nlay, nrow, ncol + integer(I4B) :: get_node + + if (nlay > 0 .and. nrow > 0 .and. ncol > 0 .and. & + ilay > 0 .and. ilay <= nlay .and. & + irow > 0 .and. irow <= nrow .and. & + icol > 0 .and. icol <= ncol) then + get_node = & + icol + ncol * (irow - 1) + (ilay - 1) * nrow * ncol + else + get_node = -1 + end if + end function get_node + + !> @brief Get row, column and layer indices from node number and grid + !! dimensions. If nodenumber is invalid, irow, icol, and ilay are -1. + subroutine get_ijk(nodenumber, nrow, ncol, nlay, irow, icol, ilay) + ! -- dummy variables + integer(I4B), intent(in) :: nodenumber + integer(I4B), intent(in) :: nrow + integer(I4B), intent(in) :: ncol + integer(I4B), intent(in) :: nlay + integer(I4B), intent(out) :: irow + integer(I4B), intent(out) :: icol + integer(I4B), intent(out) :: ilay + ! -- local variables + integer(I4B) :: nodes + integer(I4B) :: ij + + nodes = nlay * nrow * ncol + if (nodenumber < 1 .or. nodenumber > nodes) then + irow = -1 + icol = -1 + ilay = -1 + else + ilay = (nodenumber - 1) / (ncol * nrow) + 1 + ij = nodenumber - (ilay - 1) * ncol * nrow + irow = (ij - 1) / ncol + 1 + icol = ij - (irow - 1) * ncol + end if + end subroutine get_ijk + + !> @brief Get layer index and within-layer node index from node number + !! and grid dimensions. If nodenumber is invalid, icpl and ilay are -1. + subroutine get_jk(nodenumber, ncpl, nlay, icpl, ilay) + ! -- dummy variables + integer(I4B), intent(in) :: nodenumber + integer(I4B), intent(in) :: ncpl + integer(I4B), intent(in) :: nlay + integer(I4B), intent(out) :: icpl + integer(I4B), intent(out) :: ilay + ! -- local variables + integer(I4B) :: nodes + + nodes = ncpl * nlay + if (nodenumber < 1 .or. nodenumber > nodes) then + icpl = -1 + ilay = -1 + else + ilay = (nodenumber - 1) / ncpl + 1 + icpl = nodenumber - (ilay - 1) * ncpl + end if + end subroutine get_jk + end module GeomUtilModule diff --git a/src/Utilities/InputOutput.f90 b/src/Utilities/InputOutput.f90 index 824529fa87d..8c6296d7bc5 100644 --- a/src/Utilities/InputOutput.f90 +++ b/src/Utilities/InputOutput.f90 @@ -17,12 +17,12 @@ module InputOutputModule UPCASE, URWORD, ULSTLB, UBDSV4, & ubdsv06, UBDSVB, UCOLNO, ULAPRW, & ULASAV, ubdsv1, ubdsvc, ubdsvd, UWWORD, & - same_word, get_node, get_ijk, str_pad_left, unitinquire, & + same_word, str_pad_left, unitinquire, & ParseLine, ulaprufw, openfile, & linear_interpolate, lowcase, & read_line, & GetFileFromPath, extract_idnum_or_bndname, urdaux, & - get_jk, print_format, BuildFixedFormat, & + print_format, BuildFixedFormat, & BuildFloatFormat, BuildIntFormat, fseek_stream, & get_nwords, u9rdcom, & append_processor_id @@ -1144,62 +1144,6 @@ logical function same_word(word1, word2) return end function same_word - function get_node(ilay, irow, icol, nlay, nrow, ncol) - ! Return node number, given layer, row, and column indices - ! for a structured grid. If any argument is invalid, - ! return -1. - implicit none - ! -- return - integer(I4B) :: get_node - ! -- dummy variables - integer(I4B), intent(in) :: ilay, irow, icol, nlay, nrow, ncol - ! - if (nlay>0 .and. nrow>0 .and. ncol>0) then - if (ilay>0 .and. ilay<=nlay) then - if (irow>0 .and. irow<=nrow) then - if (icol>0 .and. icol<=ncol) then - get_node = icol + ncol*(irow-1) + (ilay-1)*nrow*ncol - return - endif - endif - endif - endif - get_node = -1 - return - end function get_node - - subroutine get_ijk(nodenumber, nrow, ncol, nlay, irow, icol, ilay) - ! Calculate irow, icol, and ilay from the nodenumber and grid - ! dimensions. If nodenumber is invalid, set irow, icol, and - ! ilay to -1 - implicit none - ! -- dummy variables - integer(I4B), intent(in) :: nodenumber - integer(I4B), intent(in) :: nrow - integer(I4B), intent(in) :: ncol - integer(I4B), intent(in) :: nlay - integer(I4B), intent(out) :: irow - integer(I4B), intent(out) :: icol - integer(I4B), intent(out) :: ilay - ! -- local variables - integer(I4B) :: nodes - integer(I4B) :: ij - ! - nodes = nlay * nrow * ncol - if(nodenumber < 1 .or. nodenumber > nodes) then - irow = -1 - icol = -1 - ilay = -1 - else - ilay = (nodenumber - 1) / (ncol * nrow) + 1 - ij = nodenumber - (ilay - 1) * ncol * nrow - irow = (ij - 1) / ncol + 1 - icol = ij - (irow - 1) * ncol - endif - ! - return - end subroutine get_ijk - !> @brief Function for string manipulation !< function str_pad_left(str, width) result(res) @@ -1216,32 +1160,6 @@ function str_pad_left(str, width) result(res) return end function - subroutine get_jk(nodenumber, ncpl, nlay, icpl, ilay) - ! Calculate icpl, and ilay from the nodenumber and grid - ! dimensions. If nodenumber is invalid, set irow, icol, and - ! ilay to -1 - implicit none - ! -- dummy variables - integer(I4B), intent(in) :: nodenumber - integer(I4B), intent(in) :: ncpl - integer(I4B), intent(in) :: nlay - integer(I4B), intent(out) :: icpl - integer(I4B), intent(out) :: ilay - ! -- local variables - integer(I4B) :: nodes - ! - nodes = ncpl * nlay - if(nodenumber < 1 .or. nodenumber > nodes) then - icpl = -1 - ilay = -1 - else - ilay = (nodenumber - 1) / ncpl + 1 - icpl = nodenumber - (ilay - 1) * ncpl - endif - ! - return - end subroutine get_jk - subroutine unitinquire(iu) ! -- dummy variables integer(I4B) :: iu diff --git a/src/Utilities/ListReader.f90 b/src/Utilities/ListReader.f90 index 959b1cdd0e2..db38583f1b5 100644 --- a/src/Utilities/ListReader.f90 +++ b/src/Utilities/ListReader.f90 @@ -7,6 +7,7 @@ module ListReaderModule use SimVariablesModule, only: errmsg use SimModule, only: store_error, count_errors, store_error_unit use LongLineReaderModule, only: LongLineReaderType + use GeomUtilModule, only: get_ijk, get_jk, get_node implicit none private @@ -288,7 +289,6 @@ subroutine read_binary(this) ! ------------------------------------------------------------------------------ ! -- modules use ConstantsModule, only: LINELENGTH, LENBIGLINE - use InputOutputModule, only: get_node ! -- dummy class(ListReaderType) :: this ! -- local @@ -400,7 +400,7 @@ subroutine read_ascii(this) ! ------------------------------------------------------------------------------ ! -- modules use ConstantsModule, only: LENBOUNDNAME, LINELENGTH, DZERO - use InputOutputModule, only: urword, get_node + use InputOutputModule, only: urword use ArrayHandlersModule, only: ExpandArray use TdisModule, only: kper ! -- dummy @@ -636,7 +636,7 @@ subroutine write_list(this) ! -- modules use ConstantsModule, only: LINELENGTH, LENBOUNDNAME, & TABLEFT, TABCENTER - use InputOutputModule, only: ulstlb, get_ijk + use InputOutputModule, only: ulstlb use TableModule, only: TableType, table_cr ! -- dummy class(ListReaderType) :: this diff --git a/utils/mf5to6/make/makefile b/utils/mf5to6/make/makefile index 621d30e3a1d..5fd9b2f1d12 100644 --- a/utils/mf5to6/make/makefile +++ b/utils/mf5to6/make/makefile @@ -52,6 +52,7 @@ $(OBJDIR)/DevFeature.o \ $(OBJDIR)/Utilities.o \ $(OBJDIR)/ConstantsPHMF.o \ $(OBJDIR)/MemoryManager.o \ +$(OBJDIR)/GeomUtil.o \ $(OBJDIR)/BlockParser.o \ $(OBJDIR)/ArrayReadersMF5.o \ $(OBJDIR)/precutls.o \ diff --git a/utils/mf5to6/msvs/mf5to6.vfproj b/utils/mf5to6/msvs/mf5to6.vfproj index 93f8637e238..f2f4308ae4f 100644 --- a/utils/mf5to6/msvs/mf5to6.vfproj +++ b/utils/mf5to6/msvs/mf5to6.vfproj @@ -106,6 +106,7 @@ + diff --git a/utils/mf5to6/pymake/extrafiles.txt b/utils/mf5to6/pymake/extrafiles.txt index 7d95ddb2adf..0590f14ebf5 100644 --- a/utils/mf5to6/pymake/extrafiles.txt +++ b/utils/mf5to6/pymake/extrafiles.txt @@ -11,6 +11,7 @@ ../../../src/Utilities/compilerversion.F90 ../../../src/Utilities/genericutils.f90 ../../../src/Utilities/ErrorUtil.f90 +../../../src/Utilities/GeomUtil.f90 ../../../src/Utilities/InputOutput.f90 ../../../src/Utilities/kind.f90 ../../../src/Utilities/List.f90 diff --git a/utils/mf5to6/src/Exchange.f90 b/utils/mf5to6/src/Exchange.f90 index 9071210c74b..3a5d2f1a7de 100644 --- a/utils/mf5to6/src/Exchange.f90 +++ b/utils/mf5to6/src/Exchange.f90 @@ -5,7 +5,7 @@ module ExchangeModule use FileWriterModule, only: FileWriterType use GLOBAL, only: NLAY, NROW, NCOL, IBOUND, BOTM, DELC, DELR, LBOTM, NBOTM use GlobalVariablesModule, only: LgrBilinear - use InputOutputModule, only: get_ijk, get_node + use GeomUtilModule, only: get_ijk, get_node use LGRMODULE, only: IBFLG, NPLBEG, NPRBEG, NPCBEG, NPLEND, & NPREND, NPCEND, NCPP, NCPPL use ModelModule, only: ModelType diff --git a/utils/mf5to6/src/Preproc/Discretization3D.f90 b/utils/mf5to6/src/Preproc/Discretization3D.f90 index 38fe5b57304..0d373c8ebae 100644 --- a/utils/mf5to6/src/Preproc/Discretization3D.f90 +++ b/utils/mf5to6/src/Preproc/Discretization3D.f90 @@ -5,7 +5,8 @@ module DnmDis3dModule use ConstantsPHMFModule, only: PI use DnmDisBaseModule, only: DisBaseType use GlobalVariablesPHMFModule, only: verbose - use InputOutputModule, only: get_ijk, get_node, URWORD + use GeomUtilModule, only: get_ijk, get_node + use InputOutputModule, only: URWORD use SimModule, only: count_errors, store_error, & store_error_unit, ustop implicit none @@ -545,7 +546,6 @@ subroutine nodeu_to_string(this, nodeu, str) ! ! SPECIFICATIONS: ! ------------------------------------------------------------------------------ - use InputOutputModule, only: get_ijk implicit none class(Dis3dType) :: this integer, intent(in) :: nodeu @@ -617,7 +617,6 @@ integer function get_nodenumber_idx3(this, k, i, j, icheck) & ! SPECIFICATIONS: ! ------------------------------------------------------------------------------ use ConstantsModule, only: LINELENGTH - use InputOutputModule, only: get_node implicit none ! dummy class(Dis3dType), intent(in) :: this diff --git a/utils/mf5to6/src/Preproc/DiscretizationBasePHMF.f90 b/utils/mf5to6/src/Preproc/DiscretizationBasePHMF.f90 index 5bc906a4b21..3158b4a3c7e 100644 --- a/utils/mf5to6/src/Preproc/DiscretizationBasePHMF.f90 +++ b/utils/mf5to6/src/Preproc/DiscretizationBasePHMF.f90 @@ -5,6 +5,7 @@ module DnmDisBaseModule use InputOutputModule, only: URWORD use SimModule, only: count_errors, store_error, store_error_unit, & ustop + use GeomUtilModule, only: get_node implicit none private public :: DisBaseType @@ -504,7 +505,6 @@ function get_nodenumber_idx2(this, k, j, icheck) result(nodenumber) ! SPECIFICATIONS: ! ------------------------------------------------------------------------------ use SimModule, only: ustop, store_error - use InputOutputModule, only: get_node implicit none ! Dummy arguments class(DisBaseType), intent(in) :: this diff --git a/utils/zonebudget/make/makefile b/utils/zonebudget/make/makefile index da71a89f852..09354769be3 100644 --- a/utils/zonebudget/make/makefile +++ b/utils/zonebudget/make/makefile @@ -37,6 +37,7 @@ $(OBJDIR)/Budget.o \ $(OBJDIR)/zoneoutput.o \ $(OBJDIR)/grb.o \ $(OBJDIR)/budgetdata.o \ +$(OBJDIR)/GeomUtil.o \ $(OBJDIR)/zbud6.o # Define the objects that make up the program diff --git a/utils/zonebudget/msvs/zonebudget.vfproj b/utils/zonebudget/msvs/zonebudget.vfproj index d77e3204c8f..f24872d4846 100644 --- a/utils/zonebudget/msvs/zonebudget.vfproj +++ b/utils/zonebudget/msvs/zonebudget.vfproj @@ -47,6 +47,7 @@ + diff --git a/utils/zonebudget/pymake/extrafiles.txt b/utils/zonebudget/pymake/extrafiles.txt index e5e75b3d7bd..846b560f0d5 100644 --- a/utils/zonebudget/pymake/extrafiles.txt +++ b/utils/zonebudget/pymake/extrafiles.txt @@ -6,6 +6,7 @@ ../../../src/Utilities/compilerversion.F90 ../../../src/Utilities/genericutils.f90 ../../../src/Utilities/ErrorUtil.f90 +../../../src/Utilities/GeomUtil.f90 ../../../src/Utilities/InputOutput.f90 ../../../src/Utilities/kind.f90 ../../../src/Utilities/LongLineReader.f90