  subroutine rdmyhre_organic_acids(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=1001,ncomp=21
  integer :: id1,istat,noprf,mset,i1,i2
  integer :: idwcm,idwave,idrn,idri,idtk
  integer :: start(1),count(1),stride(1)
  integer :: start2(2),count2(2),stride2(2)
  integer :: ntext,n70
  real :: numlines(ncomp)
  real :: wcmdat(ndat,ncomp),wavedat(ndat,ncomp)
  real :: rnval(ndat,ncomp),rival(ndat,ncomp)
  character(len=30) :: fil
  character (len=40) :: files(ncomp)
  character (len=16) :: llset

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

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

! Obtain the full pathname of the input netCDF file
   noprf=0
  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,"rdmyhre_organic_acids: id1,filnm ",i8,2x,a100)
  end if

! ***
! Get dimension ids (work with variables part of ncdump)
  istat=nf90_inq_varid(id1,'ncases',idncases)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'nlinesmax',idnlinesmax)
   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,idncases,ncases)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idnlinesmax,nlinesmax)
   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=110) ncases,nlinesmax
   110 format(/,2x,"ncases,nlinesmax ",/,&
   2x,4(1x,i4))
   write(iout,fmt=120) ntext,n70
   120 format(/,2x,"ntext,n70",/,&
   2x,2(1x,i4))
  end if

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

! The different compositions
!          '1234567890123456789012345678901234567890'
  files(1)='Imaginary indices of ammoniumsulfate    '
  files(2)='Imaginary indices of benzoic acid       '
  files(3)='Real indices of 25 wt% Glutaric acid    '
  files(4)='Real indices of 50 wt% Glutaric acid    '
  files(5)='Real indices of 5 wt% Glutaric acid     '
  files(6)='Imaginary indices of glutaric acid K    '
  files(7)='Imaginary indices of hydroxymalonic acid' 
  files(8)='Real indices of 10 wt% Malonic acid     '
  files(9)='Real indices of 25 wt% Malonic acid     '
  files(10)='Real indices of 60 wt% Malonic acid    '
  files(11)='Imaginary indices of malonic acid      '
  files(12)='Real indices of 10 wt% Oxalic acid     '
  files(13)='Real indices of 5 wt% Oxalic acid      '
  files(14)='Imaginary indices of oxalic acid       '
  files(15)='Imaginary indices of phthalic acid     '
  files(16)='Imaginary indices of pinonic acid      '
  files(17)='Real indices of 5 wt% Pyruvic acid     '
  files(18)='Imaginary indices of pyruvic acid      '
  files(19)='Real indices of 8 wt% Succinic acid    '
  files(20)='Imaginary indices of succinic acid     '
  files(21)='Imaginary indices of water at 293K     '

! *
! Write out the compounds included in the netCDF file
  write(0,fmt=140)
  140 format(2x," Will select mset value for a specific case")
  write(0,fmt=145)
  145 format(2x," i, case ")

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

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

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

! The compound string
!       '1234567890123456'
  llset=' Myhre organic  '

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

! ***
! Obtain variable ids
   istat=nf90_inq_varid(id1,'numlines',idnumlines)
    call handle(iout,istat)
   istat=nf90_inq_varid(id1,'wcm',idwcm)
    call handle(iout,istat)
   istat=nf90_inq_varid(id1,'wavelengthr',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(0,fmt=190) idnumlines,idwcm,idwave,idrn,idri
   write(iout,fmt=190) idnumlines,idwcm,idwave,idrn,idri
   190 format(/,2x,"idnumlines,idwcm,idwave,idrn,idri ",/,&
   2x,1(1x,i4),2x,4(1x,i4))
  end if 

! ****
!  Read in the data
   start(1)=1
   count(1)=ncomp
   stride(1)=1
  istat=nf90_get_var(id1,idnumlines,numlines,start,count,stride)
   call handle(iout,istat)

   start2(1)=1
   start2(2)=1
   count2(1)=ndat
   count2(2)=ncomp
   stride2(1)=1
   stride2(2)=1
  istat=nf90_get_var(id1,idwcm,wcmdat,start2,count2,stride2)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idwave,wavedat,start2,count2,stride2)
   call handle(iout,istat)
  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)

! *****
! Determine how many lines to work with
  nlines=int(numlines(mset))

  write(0,fmt=700) nlines
  write(iout,fmt=700) nlines
  700 format(/,2x,"nlines ",i4)

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

! *****
  if (nopr .eq. 1) then
    write(iout,fmt=800) mset,files(mset)
    800 format(/,2x,"rdmyhre_organic_acids: work with mset, files(mset)",/,&
    2x,i3,2x,a40)
    write(iout,fmt=840)
    840 format(2x,"rdmyhre_organic_acids: 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
