update Subroutine

subroutine update(key, valin)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: key
character(len=*), intent(in), optional :: valin

Contents

Source Code


Variables

Type Visibility Attributes Name Initial
integer, public :: ilen
integer, public :: place
character(len=:), public, allocatable :: val

Source Code

      subroutine update(key,valin)
      character(len=*),intent(in)           :: key
      character(len=*),intent(in),optional  :: valin
      integer                               :: place
      integer                               :: ilen
      character(len=:),allocatable          :: val
      if(present(valin))then
         val=valin
         ilen=len_trim(val)
         ! find where string is or should be
         call locate(keywords,key,place)
         ! if string was not found insert it
         if(place.lt.1)then
            call insert(keywords,key,iabs(place))
            call insert(values,val,iabs(place))
            call insert(counts,ilen,iabs(place))
         else
            call replace(values,val,place)
            call replace(counts,ilen,place)
         endif
      else
         call locate(keywords,key,place)
         if(place.gt.0)then
            call remove(keywords,place)
            call remove(values,place)
            call remove(counts,place)
         endif
      endif
      end subroutine update