Previous Next Up Title Contents Index Top Library

5.2 ERROR HANDLING

There are two error routines in the PHIGS FORTRAN binding, named PERLOG and PERHND.

PERLOG is the system error logging procedure. It writes error messages in the specified error file.

PERHND should be replaced by a user function in order to catch PHIGS errors. In GPHIGS error handling is completely written in C. So the FORTRAN PERHND function is never called. Instead GPHIGS calls the C function named perr_hand.

FORTRAN applications which wants to catch PHIGS errors can do the following:

1/ write the PERHND procedure in FORTRAN

		SUBROUTINE PERHND(ERRNUM, FUNCNU,  ERRFIL)
		INTEGER ERRNUM,FUNCNUM,ERRFIL
		COMMON /ERROR/ ERRSTA
		...
		IF ( ERRNUM .EQ. 54) THEN
			WRITE(ERRFIL,*) " ERROR OCCURS IN ", FUNCNU,
	+		" WORKSTATION NOT OPEN"
			ERRSTA = ERRNUM
		ELSE 
C others errors
			CALL PERLOG(ERRNUM, FUNCNU,  ERRFIL)
		ENDIF
		...
		RETURN
		END
2/ write the perr_hand in C as follows:
		void perr_hand(Pint err_num,Pint func_num, char *err_file)
		{
			int fd;
			fd=6;
			perhnd(&err_num,&func_num,&fd);
		}
3/ compile and link the application

NOTE: The err_file parameter in C is a string whereas in FORTRAN it is a file descriptor. To use the same file descriptor as passed to OPEN PHIGS just store the value in a COMMON accessed from PERHND.

Fortran compilers often append an underscore after the name of the function whereas C compilers do not. On such a compiler the call to perhnd in the C function must be replaced by perhnd_ . See the FORTRAN to C calling syntax in the FORTRAN documentation to find out if an underscore is required.


Previous Next Up Title Contents Index Top Library