   subroutine rdkou(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 :: ncomp=3
  integer :: i
  integer :: nwater22,nwaterm8,nicem25
  integer :: ntext,n70
  integer :: start(1),count(1),stride(1)
  integer,parameter :: ndat=5000
  real :: wcmdat(ndat),wavedat(ndat),rnval(ndat),rival(ndat)
  character(len=30) :: fil
  character (len=16) :: files(ncomp),llset

! ***
! Obtain the listing of the compounds
! Will ask the user to choose which compound to work with

! Specify by hand (have code read in values)
!          '1234567890123456'
  files(1)='Water 22 C      '
  files(2)='Ice   -8 C      '
  files(3)='Ice  -22 C      '

  write(0,fmt=140)
  140 format(2x," Will select  mset  value for a specific compound")
  write(0,fmt=145)
  145 format(2x," mset, 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 (1-3) e.g. mset=1 for Water 22 C ")

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

! The compound string
  llset=files(mset)

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

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

! ***
! The input netCDF file
!     '123456789012345678901234567890'
  fil='kou_imag_water_ice.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,"rdkou: id1,filnm ",i8,2x,a100)
  end if

! ***
! Get dimension ids (work with variables part of ncdump)

  istat=nf90_inq_varid(id1,'ntext',idntext)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'n70',idn70)
   call handle(iout,istat)

  istat=nf90_inq_varid(id1,'nwater22',idnwater22)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'nwaterm8',idnwaterm8)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'nicem25',idnicem25)
   call handle(iout,istat)

! *****
! Get the dimensions

  istat=nf90_get_var(id1,idntext,ntext)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idn70,n70)
   call handle(iout,istat)

  istat=nf90_get_var(id1,idnwater22,nwater22)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idnwaterm8,nwaterm8)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idnicem25,nicem25)
   call handle(iout,istat)

   if (nopr .eq. 1) then
    write(iout,fmt=110) mset,ntext,n70,nwater22,nwaterm8,nicem25
    110 format(2x,"mset,ntext,n70,nwater22,nwaterm8,nicem25",/,&
    2x,6(1x,i4))
   end if

   if (mset .eq. 1) then
     nlines=nwater22
    istat=nf90_inq_varid(id1,'wcmwater22',idwcm)
     call handle(iout,istat)
    istat=nf90_inq_varid(id1,'wmicwater22',idwave)
     call handle(iout,istat)
    istat=nf90_inq_varid(id1,'riwater22',idri)
     call handle(iout,istat)
   end if

   if (mset .eq. 2) then
     nlines=nwaterm8
    istat=nf90_inq_varid(id1,'wcmwaterm8',idwcm)
     call handle(iout,istat)
    istat=nf90_inq_varid(id1,'wmicwaterm8',idwave)
     call handle(iout,istat)
    istat=nf90_inq_varid(id1,'riwaterm8',idri)
     call handle(iout,istat)
   end if

   if (mset .eq. 3) then
     nlines=nicem25
    istat=nf90_inq_varid(id1,'wcmicem25',idwcm)
     call handle(iout,istat)
    istat=nf90_inq_varid(id1,'wmicicem25',idwave)
     call handle(iout,istat)
    istat=nf90_inq_varid(id1,'riicem25',idri)
     call handle(iout,istat)
   end if

! ****
!  Read in the real and imaginary indices
   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,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)=0.0
   ridat(i)=rival(i)
  end do

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

    write(iout,fmt=800) mset,files(mset)
    800 format(/,2x,"rdkou: work with mset, files(mset)",/,&
    2x,i3,2x,a70,/,&
    2x,"rdkou: i,files(i)")
   do i=1,ncomp
    write(iout,810) i,files(i)
    810 format(2x,i3,2x,a70)
   end do
    iwrtext=0
   if (iwrtext .eq. 1) then
    write(iout,fmt=820)
    820 format(/,2x,"rdkou: text(i)")
    do i=1,ntext
     write(iout,fmt=830) text(i)
     830 format(2x,a70)
    end do
   end if

    write(iout,fmt=840)
    840 format(/,2x,"rdkou: 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
