      SUBROUTINE UPDATEACTIONLOG(jp,maxprobe,npro,actionrec,
     * iaccesstype,ilocknum)

C    UPDATEACTIONLOG UPDATES ACTION LOG FILE
C    IN SYS.INF 

      parameter (maxline=10000)
      character*(*) actionrec
      character*11 callrelease,proberec
      character*15 whorec,logrec
      character*25 actionstring
      character*30 tdate
      character*80 text(maxline),filename,logstring

      dimension jp(0:maxprobe)

      ilockact=iaccesstype
      if ( ilockact .eq. 3 ) ilockact=0

c     Make sure this is a main probe

      if ( ilocknum .eq. 0 .or. ilocknum .ge. npro ) then
       iloop=npro
      else
       iloop=ilocknum
      endif

c     Get present user
      call setlockowner(whorec,15)

c     Get program being run
      if ( actionrec(1:1) .ne. ' ' ) then
       ispam=1
       logrec=actionrec
      else
       ispam=0
       logrec='- unknown -    '
      endif

c     Get date
      call clearstring(tdate,30)
      call fdate(tdate)

c     Set call/release
      call clearstring(callrelease,11)
      if ( iaccesstype .gt. -1 .and. ispam .eq. 1) then
       callrelease='  (call)   '
      elseif ( ispam .eq. 1 ) then
       callrelease='  (release)'
      endif

c    Create log string
      call clearstring(logstring,80)
      logstring=tdate(1:19)//' '//whorec//' '//logrec//
     * ' '//callrelease

      do 40 n=1,iloop

       call clearstring(proberec,11)
       call getprobename(jp(n),proberec)

       icheck=ismainprobe(proberec)
       if ( icheck .eq. 0 ) goto 40
        
c    Open appropriate action log
       call findlastchar(nsp,proberec,11)
       call clearstring(actionstring,25)
       actionstring='actionlog.'//proberec(1:nsp)//CHAR(0)
       call clearstring(filename,80)
       call extraname('sys.inf'//CHAR(0),actionstring,filename)
       open(9,file=filename,status='unknown')

c    Read in all actions presently in actionlog

       nlines=0
       do 50 nn=1,maxline

        call clearstring(text(nn),80)
        read(9,'(a80)',END=4) text(nn) 
        nlines=nlines+1
   
50     continue
4      continue

c    Write actions out to file, with present action listed first

       close(9)
       open(9,file=filename,status='unknown')

       write(9,'(a80)') logstring
       do 60 nn=1,nlines

        write(9,'(a80)') text(nn)

60     continue

       close(9)

40    continue

      return
      end
