      subroutine freadnc(ncid,TIME_id,LON_id,LAT_id,TIME_len,LON_len,
     +                        LAT_len,lon,lat,time)
      include 'netcdf.inc'
* error status return
      integer*4  iret
* netCDF id
      integer*4  ncid
* dimension lengths
      integer*4  LON_len
      integer*4  LAT_len
      integer*4  TIME_len
* variable ids
      integer*4  LON_id
      integer*4  LAT_id
      integer*4  TIME_id
* data variables
      real*8  lon(LON_len)
      real*8  lat(LAT_len)
      real*8  time(TIME_len)
      logical lon_neg
* get variables
      iret = nf_get_var_double(ncid, LON_id, lon)
      call check_err(iret)
      lon_neg = .false.
      do i=1,LON_len
      	if (lon(i).LT.0.) lon_neg = .true.
      end do
      if (lon_neg) then
        do i=1,LON_len
          lon(i) = lon(i) + 360.0
        end do
      end if
      iret = nf_get_var_double(ncid, LAT_id, lat)
      call check_err(iret)
      iret = nf_get_var_double(ncid, TIME_id, time)
      call check_err(iret)
c      write(3,*) ' leave freadnc'
      end
