      program csv2dat
      implicit none

c -----
c maximum number of station
      integer NPMAX
      parameter (NPMAX=100)

c missing value
      real    MISS
      parameter (MISS=-999.)

c location data IO
      integer IS
      parameter (IS=11)

c -----
c number of station
      integer NP

c station postion
      real    x(NPMAX), y(NPMAX)

c data
      real    tmin, tmax
      real    wdmin, wdmax
      real    wsmin, wsmax
      real    dT

c loop control
      integer i

c -----
c read number of station
      open(IS,FILE='num.dat')
      read(IS,*) NP
      close(IS)
      if (NP.gt.NPMAX) then
          write(*,*) 'NPMAX is smaller than NP'
          stop
      end if

c read station postion
      open(IS,FILE='location.txt')
      do 100 i = 1, NP
        read(IS,*) x(i), y(i)
 100  continue
      close(IS)

c read data and write data
      do 120 i = 1, NP
c        read(*,*) tmin, tmax, wsmin, wsmax, wdmin, wdmax
        read(*,*) tmin, tmax, wsmin, wsmax
        dT = tmax - tmin
        if (dT.eq.(0.0)) then
            dT = MISS
        end if
        write(*,*) x(i), y(i), dT
 120  continue

      stop
      end
