find_kipp_header Subroutine

private subroutine find_kipp_header(path, hdrfile)

Locate sidecar header of .kipp file ("Header file", docs/kippfiles.md).

Tries <path>.hdr next to data file, then <basename>.hdr in working directory (skipped if data file is there). Missing header stops load w/ error.

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: path

Path of .kipp file.

character(len=*), intent(out) :: hdrfile

Path of header.


Source Code

   subroutine find_kipp_header(path, hdrfile)
      !! Locate sidecar header of `.kipp` file ("Header file", docs/kippfiles.md).
      !!
      !! Tries `<path>.hdr` next to data file, then `<basename>.hdr` in working directory (skipped
      !! if data file is there). Missing header stops load w/ error.
      ! Arguments
      character(len=*), intent(in) :: path
         !! Path of `.kipp` file.
      character(len=*), intent(out) :: hdrfile
         !! Path of header.
      integer(int32) :: slash
      logical :: ex

      hdrfile = trim(path)//'.hdr'
      inquire (file=trim(hdrfile), exist=ex)
      if (ex) return

      slash = index(trim(path), '/', back=.true.)
      if (slash > 0) then
         hdrfile = trim(path(slash + 1:))//'.hdr'
         inquire (file=trim(hdrfile), exist=ex)
         if (ex) return
      end if

      error stop '[loadkipp] cannot find sidecar .hdr for '//trim(path)
   end subroutine find_kipp_header