      SUBROUTINE LOCKEXEC(proberec,lockup,actionrec)

c     Program to upgrade or downgrade a lock

c*****************************************************************
c    
c     INPUT:
c       proberec - probe of interest
c       lockup  - new lock status
c
c*****************************************************************

      parameter (ilockfile = 78, maxprobe = 25)
      parameter (ip=11,il=15,it=8,iw=15,iw2=25)

      dimension iLOCK(maxprobe)

      character*(*) actionrec
      character*11 proberec
      character*11 probename(maxprobe)
      character*15 probeusr(maxprobe)
      character*8 probetime(maxprobe)
      character*15 lockstat(maxprobe)
      character*25 whatrec(maxprobe)

      call readlockfile(icounter,maxprobe,
     * probename,ip,lockstat,il,probeusr,iw,
     * probetime,it,whatrec,iw2,iLOCK,ilockfile)

      call matchlockprobe(icounter,probename,ip,proberec,
     * iprobe, maxprobe)
      if ( iprobe .gt. 0 ) then
       call lockown(probeusr(iprobe),iw,iown)
       
       if ( iown .eq. 1 .or. iLOCK(iprobe) .eq. 0 ) then

        if ( lockup .gt. -1 ) 
     *   call changelockstatus(lockstat(iprobe),il,lockup)
        call updatelocktime(probetime(iprobe),it)
        call setlockwhat(whatrec(iprobe),iw2,actionrec,15)
        call setlockowner(probeusr(iprobe),iw)
        if ( lockup .lt. 0 .and. iLOCK(iprobe) .eq. 0 ) then 
         call clearstring(probeusr(iprobe),iw)
         call clearstring(probetime(iprobe),it)
         call clearstring(whatrec(iprobe),iw2)
        endif

        call writelockfile(icounter,maxprobe,
     *   probename,ip,lockstat,il,probeusr,iw,
     *   probetime,it,whatrec,iw2,ilockfile)
       endif
      endif

      return
      end

