C***********************************************************************
C*****************************************************************
C get_obs8c.f   11 Nov 1999
C   return mesh name from input file. CGH  
C
C getobs_8b.f  18 May 1998 
C Charles Hannah
C get observations from file format *.m3d 
C  t,x,y,u,v, zminobs, zmaxobs, zbotobs
C  t   : time in gmt0  (decimal days)
C  x,y : position in meters and inside mesh being used
C  u,v : observed velocities, partial vertical averge,  in m/s 
C  zminobs : distance below surface of upper limit of observation
C  zmaxobs : distance below surface of lower limit of observation
C  zbotobs : observed water depth. 
C
C The vertical coordinate system for zminobs, zmaxobs, zbotobs is
C zero at the seasurface and positive down (thus they are generally 
C positive).  This is different from the models vertical coordinate
C system. 
C 

C
      Subroutine GETOBS_8c(lun,Nobs, Xobs, Yobs, Tobsgmt0, 
     & Ubarobs,Vbarobs,Zmaxobs,Zminobs,Zbotobs,nobsdim,iyear,meshname)
C
c june 9 '97: from getobs_8.f
c
      integer lun
      integer Nobs
      real Xobs(nobsdim), Yobs(nobsdim)
      real Tobsgmt0(nobsdim)
      real Ubarobs(nobsdim), Vbarobs(nobsdim) 
      real Zmaxobs(nobsdim), Zminobs(nobsdim), Zbotobs(nobsdim)
      integer nobsdim
      integer iyear
      character*(*) meshname 

C local variables 
      integer i, ncol
c      character*120 filename
      character*120 header 

c     write(*,*)'Enter observations *.m3d file'
c     write(*,*)'format: t x y u v zmin zmax zbot *'
c     read(*,'(a)')filename
c     open(unit=4, file=filename, status='old') 


C   read and discard header
      HEADER=' '
      do while(HEADER(1:4).NE.'XXXX')
         read(lun,'(A)')HEADER
      enddo
C   read comment line, year, and number of columns
      read(lun,'(A)')meshname
      read(lun,'(A)')HEADER
      read(lun,*)IYEAR
      read(lun,*)NCOL
        if(NCOL.lt.8) then 
           write(2,*)'GET_OBS: Not enough data columns; Stopping'
           write(2,*)'NCOL = ',NCOL
           close(2)
           stop
        endif
c        
      if(NCOL.gt.8) then 
         write(2,22) NCOL
   22 Format('GetObs_8b: There are',I3, ' data columns in file ',(A))
         write(2,'(a)')' Only the first 8 data columns will be used.'
      endif

C   read the forcing data

      i=1       
  100 continue
         read(lun,*,end=101)tobsgmt0(i), xobs(i), yobs(i), 
     &   ubarobs(i), vbarobs(i), zminobs(i), zmaxobs(i), zbotobs(i)
	 if(i.gt.nobsdim) then 
	    write(2,*)'GET_OBS: Too many observations; Stopping '
	    write(2,*)'NOBSDIM = ',nobsdim 
	    close(2)
	    stop
	 endif
         i=i+1
      go to 100
  101 continue
      nobs=i-1
      write(*,*)'GetObs_8c: meshname, ',meshname(1:4)
      write(*,*)'GetObs_8c: nobs, ncol ',nobs,ncol
C
      close(lun)
c
      write(*,*)'getobs_8c',tobsgmt0(1),tobsgmt0(nobs)
      return
      end
