   subroutine get_nloat(lomax,nat,nloat)


    integer    i,l,k,ios
    real*8, allocatable :: elo(:,:)
    integer, allocatable :: LOCHECK(:,:)

    nloat=0
!!    allocate (elo(0:lomax,1:nloat))
    allocate(LOCHECK(0:lomax,1:nat))
    LOCHECK=0

!-b-reading case.in1 file----------
      read(4,*,iostat=ios)
      if (ios.ne.0) then
         if (myid.eq.0) write(6,*) "Something wrong with case.in1 file"
         CALL OUTERR('LAPWSO','Something wrong with case.in1 file')
         stop 'case.in1 not present'
      endif
      read(4,*)
      do J=1,nat
         READ (4,*) EI, NLR,iapw
         do I=1,NLR
            READ (4,5000) L, EI, DE, EMAIN, iapw
            if(l.gt.lomax) then
                    if (myid.eq.0) write(6,*) "lomax=",lomax," in modules.F too small for l=",l
                    CALL OUTERR('LAPWSO','lomax too small in modules.F')
                    STOP 'lomax too small'
            endif
            LOCHECK(L,J)=LOCHECK(L,J)+1
            if (LOCHECK(L,J).gt.nloat) nloat=LOCHECK(L,J)
         enddo
      enddo
      nloat=nloat+1
      if (nloat.lt.3) nloat=3
!-e-reading case.in1 file----------


     deallocate (LOCHECK)
5000 FORMAT (1X,I1,2F10.5,A4,i2)
!    print*, "nloat=",nloat



!!      ii=1
!!     nloat=0
!!      DO i=1,nat
!!
!!         read(9)
!!
!!         do
!!            read(9,iostat=ios) elo(0:lomax,1:ii)
!!            if (ios.ne.0) exit
!!            ii=ii+1
!!            backspace(9)
!!         enddo
!!
!!         nloat=ii
!!$         DO l = 0,lomax
!!$            DO k=1,ii-1
!!$               IF (elo(l,k).LT.(995.0d+0)) then
!!$                  nloat=max(nloat,k)
!!$               endif
!!$            ENDDO
!!$         ENDDO

!!      ENDDO



!!      deallocate(elo)
!!      rewind(9)
   end subroutine get_nloat


