nmin = 0    !initialize number of minerals
*______________________________
      do k=1,2    !two passes for each mineral set (gases+supersat+undersat)
        do         !loop reading through minerals
          n = 0


          string='Gas names'
          read (inp1,"(a80)",end=1002) record1
          if (record1(1:8).eq.blank8) exit
          if (record1(1:4).eq.'    ') exit    !case if other text
          read(record1(1:55),"(2x,a20,23x,f10.4)") name, qkdat
          do
            n = n + 1
            if(n.ge.nmin) nmin=n

* ptx nmin_save added to get mineral Q/Ks dropped at high P, T because of absent data
            if(nmin.ge.nmin_save) nmin_save = nmin
            if((name.eq.rname(n)).or.(rname(n).eq.blank20)) exit
          end do

          if(nmin.gt.max7) then
            write(*,"(/5x,'Number of minerals (max7) exceeded.'/
     &       ,5x,'Maximum allowed is: ',i3)") max7
            stop
          endif
          rname(n) = name
          qklog(n) = qkdat
        end do

* At this point, we reached a blank line. Check to see if there is a
*   list of minerals (i.e. SUPERSATURATED or UNDERSATURATED or both.)
        If (k.eq.1) then
           read(inp1,"(//a80)", end=1002) record1
        else
           read(inp1,"(a80)", end=1002) record1
        endif
        if (record1(20:33).ne.'UNDERSATURATED'.and.
     +     record1(20:33).ne.'SUPERSATURATED') exit
        IF (record1(20:33).eq.'SUPERSATURATED')
     +     string='Supersaturated minerals'
        if (record1(20:33).eq.'UNDERSATURATED')
     +     string='Undersaturated minerals'

* Skip to top of mineral block, super- or undersaturated
        read(inp1,"(//a80)",end=1001) record1
      end do
*______________________________
* Finished reading one set