  subroutine read_Kp_data(datim,ikp,nrec)
  
  character(len= 2) :: bid,Kp,Kppos(28)
  character(len=13) :: datim(80000)
  integer           :: ikp(80000)
  
  Kppos( 1)='0o'
  Kppos( 2)='0+'
  Kppos( 3)='1-'
  Kppos( 4)='1o'
  Kppos( 5)='1+'
  Kppos( 6)='2-'
  Kppos( 7)='2o'
  Kppos( 8)='2+'
  Kppos( 9)='3-'
  Kppos(10)='3o'
  Kppos(11)='3+'
  Kppos(12)='4-'
  Kppos(13)='4o'
  Kppos(14)='4+'
  Kppos(15)='5-'
  Kppos(16)='5o'
  Kppos(17)='5+'
  Kppos(18)='6-'
  Kppos(19)='6o'
  Kppos(20)='6+'
  Kppos(21)='7-'
  Kppos(22)='7o'
  Kppos(23)='7+'
  Kppos(24)='8-'
  Kppos(25)='8o'
  Kppos(26)='8+'
  Kppos(27)='9-'
  Kppos(28)='9o'
  
! reading file
! ------------

  open(1,file='Kp_2000-10-01_2025-08-31_D.dat')
  
  do i=1,37
     read(1,*) bid
  enddo

  iosta=0
  nrec=1
! 2000-10-01 00:00:00.000 275 4o  27    13 0.7  3  2282   11
       
  DO while(iosta == 0)  ! reading each record of the file
   
     read(1,10,iostat=iosta, end=20) datim(nrec),Kp
     if(iosta /= 0) then
           print*,'iosta=',iosta
           print*,'record #',nrec,' cannot be read'
           go to 20
     endif
  10 format(a13,15x,a2)
  
     do k=1,28
        if(Kp == Kppos(k)) then
           ikp(nrec)=k
           exit
        endif
     enddo
     
     nrec=nrec+1

  ENDDO ! end of reading file
   
  20 continue  ! pour EOF sur fichier 
  
  print*,'records read: ',nrec


  return
  end
