      PROGRAM CHECK_POINT
C
C     THIS PROGRAM WILL SET EVENT FLAG 64 OF THE NAMED PROCESS
C        IT IS DESIGNED TO INTERFACE WITH THE PACKAGE 'SEMO'
C
      CHARACTER NAME_SPECIFIED*80,NAME_SUBSTRING*8,NAME*15,MODE*1
      INTEGER FLAG, STATUS ! FLAG NUMBER AND RETURN STATUS OF SYSTEM CALLS
	INTEGER ID_FLAG

C      PARAMETER ! DEFINES SOME SYSTEM SERVICE RETURN CODES
C     +    SS$_NORMAL='00000001'X,
C     +    SS$_WASSET='00000009'X,
C     +    SS$_WASCLR='00000001'X

	EXTERNAL SS$_NORMAL,SS$_WASSET,SS$_WASCLR

C     DEFINE NAMES OF SYSTEM SERVICE FUNCTIONS USED:
      INTEGER SYS$ASCEFC, ! ASSOCIATE PROCESS WITH COMMON EVENT FLAG CLUSTER
     +        SYS$SETEF,  ! SET EVENT FLAG
     +        SYS$CLREF,  ! CLEAR EVENT FLAG
     +        SYS$DACEFC  ! DISASSOCIATE PROCESS FROM COMMON EVENT FLAG CLUSTER

	FLAG = 64

	STATUS = LIB$GET_FOREIGN(NAME_SPECIFIED,
     1      'Name of process ["_JOB" is default prefix] ',,)
	IF (.NOT. STATUS) THEN
	   WRITE (*,*) ' STATUS=',STATUS
	   CALL EXIT
	ENDIF
      LL = INDEX(NAME_SPECIFIED,' ')-1
      LENGTH=LEN(NAME_SPECIFIED)
      IF (LL .LT. LENGTH) LENGTH = LL
      IF (LENGTH.GT.8) LENGTH=8 ! UP TO 8 CHARACTERS OF SPECIFIED NAME ARE USED
      IF (NAME_SPECIFIED(:1) .GE. '0'
     1      .AND. NAME_SPECIFIED(:1) .LE. '9') THEN
	   NAME_SUBSTRING = '_JOB'//NAME_SPECIFIED(:LENGTH)
      ELSE
	   NAME_SUBSTRING = NAME_SPECIFIED(:LENGTH)
      ENDIF

	NAME=NAME_SUBSTRING//'_EFLAGS' 

C     ASSOCIATE CURRENT PROCESS WITH APPROPRIATE COMMON EVENT FLAG CLUSTER
      STATUS=SYS$ASCEFC(%VAL(64),NAME,,)
      IF (STATUS.NE. %LOC(SS$_NORMAL) ) THEN
	WRITE(*,*) 'ERROR IN ACCESSING COMMON EVENT FLAG CLUSTER:',
	1	NAME
	STOP
      ENDIF

	ID_FLAG = 65
        STATUS=SYS$SETEF(%VAL(ID_FLAG))

      IF (STATUS.NE.%LOC(SS$_WASSET)) THEN
	WRITE(*,*) ' ERROR IN ATTEMPT TO FIND ',NAME_SUBSTRING
      ELSE
        STATUS=SYS$SETEF(%VAL(FLAG))
      IF (STATUS.NE.%LOC(SS$_WASCLR)) 
	1	WRITE(*,*) 'ERROR IN ATTEMPT TO SET EVENT FLAG FOR ',
	1	    NAME_SUBSTRING
      ENDIF
      STATUS=SYS$DACEFC(%VAL(FLAG)) ! DISASSOCIATE CURRENT PROCESS FROM CLUSTER
      IF (.NOT.STATUS) 
	1	WRITE(*,*) 'TROUBLE DISASSOCIATING WITH EVENT FLAG CLUSTER:',
	1	NAME
      END
