!
      subroutine SiftRead(ncid,timeid,tsid,
     & mxaid,mnaid,spaid,mxbid,mnbid,spbid,mxcid,mncid,spcid,
     & maxha,minha,maxspa,ma,na,nxa1,nya1,
     & maxhb,minhb,maxspb,mb1,nb1,nxb1,nyb1,
     & maxhc,minhc,maxspc,mc1,nc1,nxc1,nyc1,numts,floodid,
     & latimgA,latimgB,latimgC)
      implicit none
      include 'netcdf.inc'

      integer*4 ncid,timeid,tsid,floodid
      integer*4 mxaid,mnaid,spaid,mxbid,mnbid,spbid,mxcid,mncid,spcid
      integer ma,na,nxa1,nya1
      integer mb1,nb1,nxb1,nyb1
      integer mc1,nc1,nxc1,nyc1
      integer i,j,numts
      real*4 maxha(nxa1,nya1), minha(nxa1,nya1), maxspa(nxa1,nya1)
      real*4 maxhb(nxb1,nyb1), minhb(nxb1,nyb1), maxspb(nxb1,nyb1)
      real*4 maxhc(nxc1,nyc1), minhc(nxc1,nyc1), maxspc(nxc1,nyc1)
      real*4 dumha(ma,na),dummnha(ma,na)
      real*4 dumhb(mb1,nb1),dummnhb(mb1,nb1)
      real*4 dumhc(mc1,nc1),dummnhc(mc1,nc1)
      real*4 dumspa(ma,na)
      real*4 dumspb(mb1,nb1)
      real*4 dumspc(mc1,nc1)
      logical latimgA,latimgB,latimgC

      call check_err(nf_inq_varid(ncid,'TIME',timeid))
      if (numts.gt.0) then
        call check_err(nf_inq_varid(ncid,'ts',tsid))
      end if
      call check_err(nf_inq_varid(ncid,'inundation',floodid))
      call check_err(nf_inq_varid(ncid,'max_amp_a',mxaid))
      call check_err(nf_inq_varid(ncid,'min_amp_a',mnaid))
      call check_err(nf_inq_varid(ncid,'max_speed_a',spaid))
      call check_err(nf_inq_varid(ncid,'max_amp_b',mxbid))
      call check_err(nf_inq_varid(ncid,'min_amp_b',mnbid))
      call check_err(nf_inq_varid(ncid,'max_speed_b',spbid))
      call check_err(nf_inq_varid(ncid,'max_amp_c',mxcid))
      call check_err(nf_inq_varid(ncid,'min_amp_c',mncid))
      call check_err(nf_inq_varid(ncid,'max_speed_c',spcid))


      call check_err(nf_get_var_real(ncid,mxaid,dumha))
      call check_err(nf_get_var_real(ncid,mxbid,dumhb))
      call check_err(nf_get_var_real(ncid,mxcid,dumhc))

      call check_err(nf_get_var_real(ncid,mnaid,dummnha))
      call check_err(nf_get_var_real(ncid,mnbid,dummnhb))
      call check_err(nf_get_var_real(ncid,mncid,dummnhc))

      call check_err(nf_get_var_real(ncid,spaid,dumspa))
      call check_err(nf_get_var_real(ncid,spbid,dumspb))
      call check_err(nf_get_var_real(ncid,spcid,dumspc))

      if (latimgA) then
        do j=1,na
          do i=1,ma
            maxha(i,j) = dumha(i,na-j+1)
            minha(i,j) = dummnha(i,na-j+1)
            maxspa(i,j) = dumspa(i,na-j+1)
          end do
        end do
      else
        do j=1,na
          do i=1,ma
            maxha(i,j) = dumha(i,j)
            minha(i,j) = dummnha(i,j)
            maxspa(i,j) = dumspa(i,j)
          end do
        end do
      endif
      if (latimgB) then
        do j=1,nb1
          do i=1,mb1
            maxhb(i,j) = dumhb(i,nb1-j+1)
            minhb(i,j) = dummnhb(i,nb1-j+1)
            maxspb(i,j) = dumspb(i,nb1-j+1)
          end do
        end do
      else
        do j=1,nb1
          do i=1,mb1
            maxhb(i,j) = dumhb(i,j)
            minhb(i,j) = dummnhb(i,j)
            maxspb(i,j) = dumspb(i,j)
          end do
        end do
      endif
      if (latimgC) then
        do j=1,nc1
          do i=1,mc1
            maxhc(i,j) = dumhc(i,nc1-j+1)
            minhc(i,j) = dummnhc(i,nc1-j+1)
            maxspc(i,j) = dumspc(i,nc1-j+1)
          end do
        end do
      else
        do j=1,nc1
          do i=1,mc1
            maxhc(i,j) = dumhc(i,j)
            minhc(i,j) = dummnhc(i,j)
            maxspc(i,j) = dumspc(i,j)
          end do
        end do
      endif

      end
