  subroutine rdbiermann_hno3(nopr,iout,indir,outdir,lstrn,iset,&
  lset,llset,&
  nlinesr,wcmr,wavelengthr,rndat,&
  nlinesi,wcmi,wavelengthi,ridat,&
  ndifferent,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

! Case here where number of real and imaginary indices differs
  real :: wcmr(nwavemax),wavelengthr(nwavemax)
  real :: wcmi(nwavemax),wavelengthi(nwavemax)

! Used here
! Notice that the exact number of elements in rnval,rival works
  integer,parameter :: ndatr=8192,ndati=4768,mtempmax=7,nwt=7
  integer :: i,mn,nc
  integer :: ival,jval
  integer :: nwhno3,ntext,n70
  integer :: start(1),count(1),stride(1)
  integer :: start2(2),count2(2),stride2(2)
  integer :: start3(3),count3(3),stride3(3)
  integer :: nlinesr,nlinesi
  real :: a1,a2
  real :: wghthno3
  real :: vec1(nwt),vec2(nwt)
  integer :: ivec1(nwt),ivec2(nwt)
  real :: diff1,diff2
! Note that the ndat,mtemp is opposite to the ncdump dump
  real :: temps(mtempmax)
  real :: numlinesr(mtempmax),numlinesi(mtempmax)
  real :: whno3(mtempmax,nwt)
  real :: wcmr2(ndatr)
  real :: waver2(ndatr)
  real :: rn(ndatr)
  real :: wcmi2(ndati)
  real :: wavei2(ndati)
  real :: ri(ndati)

  character(len=30) :: fil
  character (len=16) :: llset

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

! ***
! The input netCDF file
!     '123456789012345678901234567890'
  fil='biermann_hno3.nc             '
   noprf=1
  call getfilnm(noprf,iout,fil,indir,filnm)
  if (noprf .eq. 1) then
!  stop
  end if

! ***
! The compound string
!       '1234567890123456'
  llset=' Biermann H2SO4 '

! ***
! 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,"rdbiermann_hno3: id1,filnm ",i8,2x,a100)
  end if

! ***
! Get dimension ids (work with variables part of ncdump)
  istat=nf90_inq_varid(id1,'ntemps',idntemps)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'nlinesr',idnlinesr)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'nlinesi',idnlinesi)
   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)
  istat=nf90_inq_varid(id1,'nwhno3',idnwhno3)
   call handle(iout,istat)

  if (nopr .eq. 1) then 
   write(iout,fmt=180) idnwhno3,idntemps,idnlinesr
   180 format(2x,"idnwhno3,idntemps,idnlinesr ",/,2x,3(1x,i4))
   write(iout,fmt=190) idnlinesi,idntext,idn70
   190 format(2x,"idnlinesi,idntext,idn70 ",/,2x,3(1x,i4))
  end if

! *****
! Get the dimensions
  istat=nf90_get_var(id1,idnwhno3,nwhno3)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idntemps,ntemps)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idnlinesr,nlinesr)
   call handle(iout,istat)
  istat=nf90_get_var(id1,idnlinesi,nlinesi)
   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=200) nwhno3,ntemps,nlinesr,nlinesi,ntext,n70
   200 format(/,2x,"nwhno3,ntemps,nlinesr,nlinesi,ntext,n70 ",/,&
   2x,6(1x,i4))
  end if

! *****
! Get variable ids
  istat=nf90_inq_varid(id1,'temps',idtemps)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'numlinesr',idnumlinesr)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'numlinesi',idnumlinesi)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'whno3',idwhno3)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'wcmr',idwcmr)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'wavelengthr',idwavelengthr)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'rn',idrn)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'wcmi',idwcmi)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'wavelengthi',idwavelengthi)
   call handle(iout,istat)
  istat=nf90_inq_varid(id1,'ri',idri)
   call handle(iout,istat)

  if (nopr .eq. 1) then
   write(iout,fmt=210) idnumlinesr,idnumlinesi,idtemps,idntemps,idwhno3
   210 format(/,2x,"idnumlinesr,idnumlinesi,idtemps,idntemps,idwhno3, ",/,&
   2x,5(1x,i4))
   write(iout,fmt=220) idwcmr,idwavelengthr,idrn
   220 format(/,2x,"idwcmr,idwavelengthr,idrn ",/,2x,3(1x,i4))
   write(iout,fmt=230) idwcmi,idwavelengthi,idri
   230 format(/,2x,"idwcmi,idwavelengthi,idri ",/,2x,3(1x,i4))
  end if

! ****
! Get the data

! The temperatures
   start(1)=1
   count(1)=mtempmax
   stride(1)=1
  istat=nf90_get_var(id1,idtemps,temps,start,count,stride)
   call handle(iout,istat)

! The number of lines for real indices
   start(1)=1
   count(1)=mtempmax
   stride(1)=1
  istat=nf90_get_var(id1,idnumlinesr,numlinesr,start,count,stride)
   call handle(iout,istat)

! The number of lines for imaginary indices
   start(1)=1
   count(1)=mtempmax
   stride(1)=1
  istat=nf90_get_var(id1,idnumlinesi,numlinesi,start,count,stride)
   call handle(iout,istat)

! ****
! The whno3 values
   start2(1)=1
   start2(2)=1
   count2(1)=mtempmax
   count2(2)=nwt
   stride2(1)=1
   stride2(2)=1
  istat=nf90_get_var(id1,idwhno3,whno3,start2,count2,stride2)
   call handle(iout,istat)

! ****
! Determine which data to look at
  
! Will specify the wghthno3 and temp pair
! First, will write out the possibilities

! The whno3 and temps values
  if (nopr .eq. 1) then
   write(iout,fmt=320) 
   320 format(/,2x,"rdbiermann_hno3: i,j,whno3(i,j),temps(i)")
   do i=1,mtempmax
   do j=1,nwt
    write(iout,fmt=330) i,j,whno3(i,j),temps(i)
    330 format(2x,2(1x,i4),2x,2(1x,f10.4))
   end do
   end do
  end if

! **
! Write out to the screen
   write(0,fmt=360) 
   360 format(/,2x,"rdbiermann_hno3: i,temps(1),whno3(i,j)")
   do i=1,mtempmax
   do j=1,nwt
    ivec1(j)=int(whno3(i,j))
    ivec2(j)=int(temps(i))
   end do
    write(0,fmt=365) i,ivec2(1),(ivec1(j),j=1,7)
    365 format(2x,1(1x,i3),1(1x,i4),2x,7(1x,i4))
   end do

! Specify the temp and wghthno3 values
  write(0,fmt=165)
  165 format(2x,"Specify temp value (e.g. 215) ")
  read(5,*) temp

  write(0,fmt=160)
  160 format(2x,"Specify wghthno3 value (e.g. 80) ")
  read(5,*) wghthno3

  write(0,fmt=170) wghthno3,temp
  170 format(2x," wghthno3,temp ",2(1x,f10.4))

    diffmin=1.0e3
    ival=-99
    jval=-99
   do i=1,nwt
   do j=1,mtempmax
    diff1=whno3(j,i)-wghthno3
    diff2=temps(j)-temp
    a1=sqrt((diff1*diff1)+(diff2*diff2))
    if (a1 .lt. diffmin) then 
     ival=i
     jval=j
     diffmin=a1
    end if
   end do
   end do

  if ((ival .lt. 0) .or. (jval .lt. 0)) then
   write(iout,fmt=350) ival,jval
   350 format(/,2x,"rdbiermann_hno3: ival,jval ",2(1x,i4)," will stop")
   stop
  end if

  if (nopr .eq. 1) then
   write(iout,fmt=170) wghthno3,temp
   write(iout,fmt=410) ival,jval,whno3(jval,ival),temps(jval)
   410 format(/,2x,"rdbiermann_hno3:ival,jval,whno3,temps, ",/,&
   2x,2(1x,i4),2(1x,f10.4))
  end if

! ****
! The wcmr values (note wcmr2)
! note use of start2(2)=ndatr and count2(2)=1 to just look at one index
   start2(1)=1
   start2(2)=jval
   count2(1)=ndatr
   count2(2)=1
   stride2(1)=1
   stride2(2)=1
  istat=nf90_get_var(id1,idwcmr,wcmr2,start2,count2,stride2)
   call handle(iout,istat)

! The wavelengthr values (note waver2)
   start2(1)=1
   start2(2)=jval
   count2(1)=ndatr
   count2(2)=1
   stride2(1)=1
   stride2(2)=1
  istat=nf90_get_var(id1,idwavelengthr,waver2,start2,count2,stride2)
   call handle(iout,istat)

! Read in the real indices
! Note that count3(1) and count3(2) etc are opposite to the ncdump dump
   start3(1)=1
   start3(2)=jval
   start3(3)=ival
   count3(1)=ndatr
   count3(2)=1
   count3(3)=1
   stride3(1)=1
   stride3(2)=1
   stride3(3)=1
  istat=nf90_get_var(id1,idrn,rn,start3,count3,stride3)
   call handle(iout,istat)

! ****
! The wcmi values (note wcmi2)
   start2(1)=1
   start2(2)=jval
   count2(1)=ndati
   count2(2)=1
   stride2(1)=1
   stride2(2)=1
  istat=nf90_get_var(id1,idwcmi,wcmi2,start2,count2,stride2)
   call handle(iout,istat)

! The wavelengthi values (note wavei2)
   start2(1)=1
   start2(2)=jval
   count2(1)=ndati
   count2(2)=1
   stride2(1)=1
   stride2(2)=1
  istat=nf90_get_var(id1,idwavelengthi,wavei2,start2,count2,stride2)
   call handle(iout,istat)

! Read in the imaginary indices
! Note that count3(1) and count3(2) etc are opposite to the ncdump dump
   start3(1)=1
   start3(2)=jval
   start3(3)=ival
   count3(1)=ndati
   count3(2)=1
   count3(3)=1
   stride3(1)=1
   stride3(2)=1
   stride3(3)=1
  istat=nf90_get_var(id1,idri,ri,start3,count3,stride3)
   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

! The real indices
   nlines=ndatr
  do i=1,nlines
   wcmr(i)=wcmr2(i)
   wavelengthr(i)=waver2(i)
   write(0,fmt=7000) i,wcmr2(i),waver2(i),rn(i)
   7000 format(2x,i4,2x,3(1x,f10.4))
   a1=rn(i)
   if (a1 .le. 0.0) then 
    a1=0.0
   endif
   rndat(i)=a1
  end do

! The imaginary indices
   nlines=ndati
  do i=1,nlines
   wcmi(i)=wcmi2(i)
   wavelengthi(i)=wavei2(i)
   a2=ri(i)
   if (a2 .le. 0.0) then 
    a2=0.0
   endif
   ridat(i)=a2
  end do

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

    write(iout,fmt=800) temp,wghthno3
    800 format(/,2x,"rdbiermann_hno3: temp,wghthno3 ",/,2x,2(1x,f10.4),/,&
    2x,"rdbiermann_hno3: i,wcmr,wavelengthr,rndat")
   do i=1,nlinesr
    write(iout,fmt=850) i,wcmr(i),wavelengthr(i),rndat(i)
    850 format(2x,i4,2(1x,f12.4),1p,2(1x,e10.3))
   end do

    write(iout,fmt=870) temp,wghthno3
    870 format(/,2x,"rdbiermann_hno3: temp,wghthno3 ",/,2x,2(1x,f10.4),/,&
    2x,"rdbiermann_hno3: i,wcmi,wavelengthi,ridat")
   do i=1,nlinesi
    write(iout,fmt=880) i,wcmi(i),wavelengthi(i),ridat(i)
    880 format(2x,i4,2(1x,f12.4),1p,2(1x,e10.3))
   end do

  end if

! ******
  return
  end
