From d3f49dffa106e8c525dd09391df9bcb5d7cece6b Mon Sep 17 00:00:00 2001 From: wpbonelli Date: Thu, 23 Jan 2025 23:22:51 -0500 Subject: [PATCH] revert inputoutput.f90 --- .../ModelUtilities/FlowModelInterface.f90 | 1 + src/Utilities/DblHashTable.f90 | 216 ------------------ src/Utilities/InputOutput.f90 | 8 +- 3 files changed, 3 insertions(+), 222 deletions(-) delete mode 100644 src/Utilities/DblHashTable.f90 diff --git a/src/Model/ModelUtilities/FlowModelInterface.f90 b/src/Model/ModelUtilities/FlowModelInterface.f90 index 988f40ebb2e..3941a6ab9a5 100644 --- a/src/Model/ModelUtilities/FlowModelInterface.f90 +++ b/src/Model/ModelUtilities/FlowModelInterface.f90 @@ -485,6 +485,7 @@ subroutine read_packagedata(this) end if end select end select + ! TODO other grid types case default write (errmsg, '(a,3(1x,a))') & 'UNKNOWN', trim(adjustl(this%text)), 'PACKAGEDATA:', trim(keyword) diff --git a/src/Utilities/DblHashTable.f90 b/src/Utilities/DblHashTable.f90 deleted file mode 100644 index a669b6ce137..00000000000 --- a/src/Utilities/DblHashTable.f90 +++ /dev/null @@ -1,216 +0,0 @@ -!> @brief A chaining hash map for integers. -!! -!! Convenient for use as an index into arrays of arbitrary -!! data type. The implementation is based on Arjen Markus' -!! dictionary in the Flibs collection of Fortran utilities. -!< -module DblHashTableModule - - use KindModule, only: DP, I4B - - implicit none - - private - public DblHashTableType - public dbl_hash_table_cr - public dbl_hash_table_da - - integer, parameter, private :: HASH_SIZE = 4993 - integer, parameter, private :: MULTIPLIER = 31 - - type :: NodeType - character(len=:), allocatable :: key - real(DP) :: value - type(NodeType), pointer :: next => null() - contains - procedure :: add => list_add - end type NodeType - - type :: BucketType - type(NodeType), pointer :: list => null() - end type BucketType - - type :: DblHashTableType - private - type(BucketType), pointer :: buckets(:) => null() - contains - procedure :: add => ht_add - procedure :: get => ht_get - procedure, private :: find_node - end type DblHashTableType - -contains - - !> @brief Create a hash table - subroutine dbl_hash_table_cr(map) - ! -- dummy - type(DblHashTableType), pointer :: map - ! -- local - integer(I4B) :: i - - ! -- allocate - allocate (map) - allocate (map%buckets(HASH_SIZE)) - - ! -- initialize nul buckets - do i = 1, HASH_SIZE - map%buckets(i)%list => null() - end do - - end subroutine dbl_hash_table_cr - - !> @brief Deallocate the hash table - subroutine dbl_hash_table_da(map) - ! -- dummy - type(DblHashTableType), pointer :: map - ! -- local - integer(I4B) :: i - - ! -- deallocate each bucket - do i = 1, size(map%buckets) - if (associated(map%buckets(i)%list)) then - call list_da(map%buckets(i)%list) - end if - end do - - ! -- deallocate bucket array and hash table - deallocate (map%buckets) - deallocate (map) - - end subroutine dbl_hash_table_da - - !> @brief Associate the given key and value - subroutine ht_add(this, k, v) - ! -- dummy - class(DblHashTableType) :: this - character(len=*), intent(in) :: k - real(DP), intent(in) :: v - ! -- local - type(NodeType), pointer :: node - integer(I4B) :: h - - ! -- find the element corresponding to this key and replace index or - ! get an unassociated elem that corresponds to this key - node => this%find_node(k) - - ! -- replace index or create new entry - if (associated(node)) then - node%value = v - else - h = hash(trim(k)) - if (associated(this%buckets(h)%list)) then - call this%buckets(h)%list%add(k, v) - else - call list_cr(this%buckets(h)%list, k, v) - end if - end if - - end subroutine ht_add - - !> @brief Find the node containing the given key - function find_node(this, k) result(node) - ! -- dummy - class(DblHashTableType) :: this !< the hash map - character(len=*), intent(in) :: k !< the key - ! -- local - type(NodeType), pointer :: node - integer(I4B) :: h - - h = hash(trim(k)) - node => this%buckets(h)%list - - ! -- search bucket for node with matching key - do while (associated(node)) - if (node%key == k) then - exit - else - node => node%next - end if - end do - - end function find_node - - !> @brief Get the value for the given key if it exists, otherwise return zero. - function ht_get(this, k) result(v) - ! -- dummy - class(DblHashTableType) :: this !< the hash map - character(len=*), intent(in) :: k !< the key - ! -- return - real(DP) :: v - ! -- local - type(NodeType), pointer :: node - - node => this%find_node(k) - if (associated(node)) then - v = node%value - else - v = 0 - end if - - end function ht_get - - !> @brief Create a list with the given key/value pair - subroutine list_cr(list, k, v) - ! -- dummy - type(NodeType), pointer :: list !< pointer to the list - character(len=*), intent(in) :: k !< the first key - real(DP), intent(in) :: v !< the first value - - allocate (list) - list%next => null() - list%key = k - list%value = v - - end subroutine list_cr - - !> @brief Add a key/value pair to the list - subroutine list_add(this, k, v) - ! -- dummy - class(NodeType) :: this !< the list - character(len=*), intent(in) :: k !< the key - real(DP), intent(in) :: v !< the value - ! -- local - type(NodeType), pointer :: next - - allocate (next) - next%key = k - next%value = v - next%next => this%next - this%next => next - - end subroutine list_add - - !> @brief Deallocate the list - subroutine list_da(list) - ! -- dummy - type(NodeType), pointer, intent(in) :: list !< the list - ! -- local - type(NodeType), pointer :: curr - type(NodeType), pointer :: node - - node => list - do while (associated(node)) - curr => node - node => curr%next - deallocate (curr) - end do - - end subroutine list_da - - !> @brief Map a character string to an integer - function hash(k) result(h) - ! -- dummy - character(len=*), intent(in) :: k !< the key - ! -- local - integer(I4B) :: h - integer(I4B) :: i - - h = 0 - do i = 1, len(k) - h = modulo(MULTIPLIER * h + ichar(k(i:i)), HASH_SIZE) - end do - h = 1 + modulo(h - 1, HASH_SIZE) - - end function hash - -end module DblHashTableModule diff --git a/src/Utilities/InputOutput.f90 b/src/Utilities/InputOutput.f90 index 2198b9a0769..88cc749dd36 100644 --- a/src/Utilities/InputOutput.f90 +++ b/src/Utilities/InputOutput.f90 @@ -40,7 +40,6 @@ subroutine openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, & character(len=*), intent(in), optional :: filstat_opt !< file status, default is 'old'. Use 'REPLACE' for output file. integer(I4B), intent(in), optional :: mode_opt !< simulation mode that is evaluated to determine if the file should be opened ! -- local - character(len=MAXCHARLEN) :: iomsg character(len=20) :: fmtarg character(len=20) :: accarg character(len=20) :: filstat @@ -108,12 +107,11 @@ subroutine openfile(iu, iout, fname, ftype, fmtarg_opt, accarg_opt, & ivar = -1 else open (unit=iu, file=fname(1:iflen), form=fmtarg, access=accarg, & - status=filstat, action=filact, iostat=ivar, iomsg=iomsg) + status=filstat, action=filact, iostat=ivar) end if ! ! -- Check for an error if (ivar /= 0) then - print *, "iomsg: ", iomsg write (errmsg, '(3a,1x,i0,a)') & 'Could not open "', fname(1:iflen), '" on unit', iu, '.' if (iuop > 0) then @@ -1855,12 +1853,10 @@ subroutine get_line(lun, line, iostat) ! -- dummy integer(I4B), intent(in) :: lun character(len=:), intent(out), allocatable :: line - integer(I4B), intent(out) :: iostat ! -- local integer(I4B), parameter :: buffer_len = MAXCHARLEN character(len=buffer_len) :: buffer - character(len=buffer_len) :: iomsg character(len=:), allocatable :: linetemp integer(I4B) :: size_read, linesize character(len=1), parameter :: cr = CHAR(13) @@ -1872,7 +1868,7 @@ subroutine get_line(lun, line, iostat) ! ! -- process do - read (lun, '(A)', iomsg=iomsg, iostat=iostat, advance='no', size=size_read) buffer + read (lun, '(A)', iostat=iostat, advance='no', size=size_read) buffer if (is_iostat_eor(iostat)) then linesize = len(line) deallocate (linetemp)