  subroutine rdmagi_biomass_fire(nopr,iout,indir,outdir,lstrn,iset,&
  lset,llset,nlines,wcm,wavelength,rndat,ridat,iwave)

! ***
! Read in the data from the netCDF file
! Will use netCDF f90 routines
  use netcdf

! param1.inc gives the maximum size of indices and extinction vectors
  include 'param1.inc'

! ****
! See rdinoutdir.f90
  character(len=60) :: indir,outdir
  integer :: nopr,iout,iset

! See main.f90
  integer :: nlines,iwave
  real :: wcm(nwavemax),wavelength(nwavemax)
  real :: rndat(nwavemax),ridat(nwavemax)
  character(len=100) :: lstrn,lset,filnm

! Used here
  integer,parameter :: ndat=15,mdays=6
  integer :: nwave,ndays,n70,ntext,iday
  integer :: start(1),count(1),stride(1)
  integer :: start2(2),count2(2),stride2(2)
  real :: wcmdat(ndat),wavedat(ndat)
! Note that the ndat,nt is opposite to the ncdump dump
  real :: rnval(ndat,mdays),rival(ndat,mdays)
  character(len=30) :: fil
  character (len=16) :: llset,files(mdays)

!         '1234567890123456'
  files(1)=' 1 Aug 22 2000 '
  files(2)=' 2 Aug 24 2000 '
  files(3)=' 3 Aug 31 2000 '
  files(4)=' 4 Sep 3 2000  '
  files(5)=' 5 Sep 6 2000  '
  files(6)=' 6 Sep 6 2000  '

! ***
! Will specify which day to work with

   write(0,fmt=130) 
   130 format(2x,"These are the days to work with for the Magi data")
  do i=1,6 
   write(0,fmt=135) i,files(i)
   135 format(2x,i3,2x,a16)
  end do

  write(0,fmt=140)
  140 format(2x," Will select day to work with (1-6) ")

  write(0,fmt=160)
  160 format(2x,"Specify iday ")

  read(5,*) iday
  iday=int(iday)

! The compound string
  llset=files(iday)

  write(0,fmt=170) iday,llset
  170 format(2x," iday,llset ",i4,2x,a16)

! ***
! Read in the data from the netCDF file
   lset=lstrn

! ***
! The input netCDF file
!     '123456789012345678901234567890'
  fil='magi_biomass_fire.nc          '

! Obtain the full pathname of the input netCDF file
   noprf=1
  call getfilnm(noprf,iout,fil,indir,filnm)
  if (noprf .eq. 1) then
!  stop
  end if

! ***
! Open the netCDF file
  istat=nf90_open(filnm,nf90_nowrite,id1)
   call handle(iout,istat)

  if (nopr .eq. 1) then
   write(iout,fmt=100) id1,filnm
   100 format(/,2x,"rdmagi_biomass_fire: id1,filnm ",i8,2x,a100)
  end if

! ***
! Get dimension ids
  istat=nf90_inq_varid(id1,'nwave',idnwave)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'ndays',idndays)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'ntext',idntext)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'n70',idn70)
   call handle(iout,istat)

! *****
! Get the dimensions
  istat=nf90_get_var(id1,idnwave,nwave)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idndays,ndays)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idntext,ntext)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idn70,n70)
   call handle(iout,istat)

! *****
! Get variable ids
  istat=nf90_inq_varid(id1,'wcmobs',idwcm)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'wmicobs',idwave)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'rn',idrn)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'ri',idri)
   call handle(iout,istat)

  nlines=ndat

  if (nopr .eq. 1) then
   write(iout,fmt=500) nwave,nlines,ndays,ntext,n70
   500 format(/,2x,"nwave,nlines,ndays,ntext,n70",/,2x,5(2x,i4))
   write(iout,fmt=510) idwcm,idwave,idrn,idri
   510 format(/,2x,"idwcm,idwave,idrn,idri",/,2x,5(2x,i4))
  end if

! ****
!  Read in the wcm and wavelength
   start(1)=1
   count(1)=ndat
   stride(1)=1
  istat=nf90_get_var(id1,idwcm,wcmdat,start,count,stride)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idwave,wavedat,start,count,stride)
   call handle(iout,istat)

! from the ncdump
!       float wcmobs(nwave) ;
!       float wmicobs(nwave) ;
!       float rn(ndays, nwave) ;
!       float ri(ndays, nwave) ;

!  Read in the real and imaginary indices
   start2(1)=1
   start2(2)=1
! Note that count2(1) and count2(2) are opposite to the ncdump dump
   count2(1)=ndat
   count2(2)=mdays
   stride2(1)=1
   stride2(2)=1
  istat=nf90_get_var(id1,idrn,rnval,start2,count2,stride2)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idri,rival,start2,count2,stride2)
   call handle(iout,istat)

! ****
! Exit define mode
  istat=nf90_enddef(id1)

! Close the data set
  istat=nf90_close(id1)

! *****
! Put values into the output arrays
  do i=1,nlines
   wcm(i)=wcmdat(i)
   wavelength(i)=wavedat(i)
   rndat(i)=rnval(i,iday)
   ridat(i)=rival(i,iday)
  end do

! *****
  if (nopr .eq. 1) then
    write(iout,fmt=830) nlines
    830 format(/,2x,"rdmagi_biomass_fire: nlines ",i4)
    write(iout,fmt=840)
    840 format(/,2x,"rdmagi_biomass_fire: i,wcm,wavelength,rndat,ridat")
   do i=1,nlines
    write(iout,fmt=850) i,wcm(i),wavelength(i),rndat(i),ridat(i)
    850 format(2x,i4,2(1x,f10.4),1p,2(1x,e10.3))
   end do
  end if

! ******
  return
  end
