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

! ****
! 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=180,ncomp=2
  integer :: id1,istat,noprf,mset
  integer :: start(1),count(1),stride(1)
  real :: wcmdat(ndat),wavedat(ndat),rnval(ndat),rival(ndat)
  character(len=30) :: fil
  character (len=16) :: files(ncomp),llset

! **
! The different compositions
!          '1234567890123456'
  files(1)='TiO2 Rutile ord '
  files(2)='TiO2 Rutile ext '

! **
! User will select which set to work with
  write(0,fmt=140)
  140 format(2x," Will select mset value for a specific compound")
  write(0,fmt=145)
  145 format(2x," i, compound")

  do i=1,ncomp
   write(0,fmt=150) i,files(i)
   150 format(2x,i3,2x,a16)
  end do

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

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

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

! ***
! The input netCDF file
  if (mset .eq. 1) then
!      '123456789012345678901234567890'
   fil='zeidler_tio2_rutile_ord.nc    '
!       '1234567890123456'
   llset='tio2 rutile ord'
  end if
  if (mset .eq. 2) then
!      '123456789012345678901234567890'
   fil='zeidler_tio2_rutile_ext.nc    '
!       '1234567890123456'
   llset='tio2 rutile ext'
  end if

   noprf=1
  call getfilnm(noprf,iout,fil,indir,filnm)
  if (noprf .eq. 1) then  
!  stop
  end if

! *****
! Open the netCDF file
   ifile=1
  istat=nf90_open(filnm,nf90_nowrite,id1)
  call handle(iout,istat)
 
! ***
! Get dimension ids
  istat=nf90_inq_varid(id1,'nlines',idnlines)
   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,idnlines,nlines)
   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)

  if (nopr .eq. 1) then
   write(iout,fmt=500) nlines,ntext,n70
   500 format(/,2x,"nlines ",i4,/,2x,"ntext ",i4,/,2x,"n70 ",i4)
  end if

! ***
! Get variable ids 
  istat=nf90_inq_varid(id1,'wcm',idwcm)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'wavelength',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)

  if (nopr .eq. 1) then
   write(iout,fmt=510) idwcm,idwave,idrn,idri
   510 format(/,2x," idwcm,idwave,idrn,idri ",/,2x,4(1x,i4))
  end if

! ***
! Get data
   start(1)=1
   count(1)=nlines
   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)
  istat=nf90_get_var(id1,idrn,rnval,start,count,stride)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idri,rival,start,count,stride)
   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)
   ridat(i)=rival(i)
  end do

! *****
  if (nopr .eq. 1) then

   write(iout,fmt=200)
   200 format(/)
   write(iout,fmt=210)
   210 format(2x,"rdzeidler_tio2_rutile: text(i)")
   do i=1,ntext
!   write(iout,fmt=*) text(i)
   end do

   write(iout,fmt=200)
   write(iout,fmt=230)
   230 format(2x,"rdzeidler_tio2_rutile: i,wcm,wavelength,rndat and ridat")
   do i=1,nlines
    write(iout,fmt=240) i,wcm(i),wavelength(i),rndat(i),ridat(i)
    240 format(2x,i4,1p,2(1x,e10.3),2x,2(1x,e10.3))
   end do

  end if

! ******
  return
  end


