program IkeHarrisrunup

  implicit none

      character(120)                :: ike08
      character(120), allocatable   :: HWMid(:)
      integer                       :: Nsta, i, j
      integer                       :: yy, mo, dd, hh, mi
      double precision, allocatable :: lat(:), lon(:), HWM(:)
      parameter (yy = 2008, mo = 9, dd = 13, hh = 0, mi = 0)

!!Program will ask for the name of the text file that contains the
!hurricane data and store it as ike08.
      write(6,*) "Enter the name of the harriscounty.txt file"
      read(5,*) ike08
      write(6,*)      

!!The program will now open the designated file and read how many stations there
!are within the text file. This number will be stored as Nsta.
      open(unit=61,file=ike08,status='old',action='read')
      read(61,*) Nsta
      read(61,*)

!!Allocate the variables in each column into there own arrays.      
      allocate(HWMid(1:Nsta), lat(1:Nsta), lon(1:Nsta), HWM(1:Nsta))

!! Collect data from Harris County output file
      do i = 1,Nsta
         write(6,*) "Collecting data for each station", i, "."
         read(61,*) HWMid(i), lat(i), lon(i), HWM(i)
      enddo
      close(61)
     
!! Reformat data as IMEDS generic output
open(unit=23,file="hwm_harriscounty_tc_ike_waverunup.txt",status='replace',action='write')
      write(23,*) "% IMEDS generic format - High Water Mark, wave run-up mark type"
      write(23,*) "% ", "year ","month ","day ","hour ","min ", "hwm (m)"
      write(23,*) "HarrisCounty " , "UTC", " NAVD88"
                  
do j = 1,Nsta
      write(23,*) "HarrisCounty_"//TRIM(HWMid(j)), lat(j), -lon(j)
      write(23,*) yy, mo, dd, hh, mi, HWM(j)*.3048
enddo

close(23)


end program
