Previous: plot79_v Up: ../plot79.html Next: pretty
The PORT library framework provides a convenient standard interface between a FORTRAN program and various quantities associated with the host operating system. The software contains in comment statements definitions appropriate to Burroughs, CDC, Cray, Data General, Harris, Honeywell, IBM, SEL, PDP-11, DEC-10, DEC-20, Univac, DEC VAX-11/780, and Xerox computing systems. The PORT framework is in the public domain, and may be freely transported between computer systems without any licensing or copyright restrictions. It is described fully in the article by P.A. Fox, A.D. Hall, and N.L. Schryer, "The PORT Mathematical Subroutine Library", ACM Transactions on Mathematical Software, 104-126, 177-188 (1978). The PORT framework consists of three interlinked parts. First, function calls for access to machine-dependent parameters such as word length, number base, and so on. Second, routines for dynamic allocation of core from a master common block. Third, routines for uniform error handling. The descriptions of these routines are taken almost verbatim from the second article noted above. The PORT routines are maintained in source form in the publicly-accessible files on the College of Science DEC-20 in NHFB:<SOURCES.PORT-LIBRARY-FRAMEWORK>*.*, and in relocatable object form in the library SYS:PORT.REL. To simplify loading, a command file has been provided which may be specified as @SYS:PORT on any LOAD or EXECUTE command. A tape containing the PORT Library Framework in a machine-portable form is available on request. On PLOT79 VAX installations, the sources are found in [PLOT79.PORT] and may be loaded by $ LINK myprog,PLT:PORTLIB/LIB
The second package provides a basic mechanism for dealing with the occurrence of errors. In the PORT Library [1], for which the package was developed, calls to the general subroutines in the library do not include flags for error indication in their calling sequences. Instead, when a called subroutine detects an error, it calls the principal error-handling routine, SETERR. The package allows two types of error, "fatal", and "recoverable", and a parameter in the call to SETERR must be set to specify the type. Fatal errors cause an error message to be printed, the run terminated, and a call made to a dump routine. (A dummy dump routine, FDUMP, is provided here.) For recoverable errors, unless the user has specifically requested to enter the recovery mode, similar events occur, an error message is printed, and the run terminated. Thus the process is failsafe for unwary users. When the recovery mode is in effect, any call to SETERR given within a subroutine which has detected a recoverable error has the effect only of storing the fact that an error has occurred; the run is not terminated. The user, upon return from the subprogram, is responsible for testing for the occurrence of an error. If an error has occurred, the user must turn off the error state, because additional errors might arise and the occurrence of a recoverable error while in the error state constitutes an unrecoverable error, terminating the run. Finally, since a called subprogram, say SUBA, may, in turn, call a lower-level subprogram containing recoverable errors, SUBA must check for the occurrence of errors in the lower-level routines and reinterpret them in the context of SUBA, which the user knows about. This means that SUBA must enter the recovery mode (saving the mode previously in effect), make the call to the lower-level subprogram, then, upon return from the lower-level routine, check for errors, and, before returning to the user, restore the previous recovery mode. An error which has caused an invocation of SETERR has an associated number, message, and type (fatal or recoverable), and the effect of the error depends on whether the recovery mode is in effect or not. The various capabilities offered in the subprograms of the package are summarized as follows: To signal that an error has occurred: CALL SETERR (MESSG, NMESSG, NERR, IOPT) where MESSG and NMESSG are, respectively, a Hollerith message and the number of characters in the message, and NERR is the error number. IOPT is used to specify the type of error: IOPT = 1 for a recoverable error and IOPT = 2 for a fatal error. To save the recovery (or nonrecovery) mode which was previously saved in IROLD: CALL ENTSRC (IROLD,IRNEW) which save the current mode in IROLD and sets the new one to IRNEW. IRNEW = 0 leaves the recovery mode unchanged, IRNEW = 1 gives recovery, and IRNEW = 2 turns recovery off. To avoid having multiple errors outstanding, it is a fatal error to call SETERR or ENTSRC if the error state is on, meaning that an error has occurred but has not been recovered from. To restore the recovery (or nonrecovery) mode which was previously save in IROLD: CALL RETSRC (IROLD) where RETSRC not only restores the previous mode, but also acts as a "safety" exit gate. Since multiple errors are illegal, RETSRC checks out the situation and allows return to the calling program only if (1) an error is not outstanding, or (2) the restored mode is recovery, so that the calling program is responsible for error checking. To test if an error has occurred, and if its number was, say, 4, a statement such as the following is used: IF (NERROR(NERR) .EQ. 4) GO TO 50 The value of the function NERROR and the value of the argument NERR are both set to the current value of the error number by NERROR. (The double assignment may be useful and comes free since Fortran (1966) prohibits functions with no arguments.) If the error number is nonzero, it means that an error has occurred and that corrective action must be taken. To turn off the error state: CALL ERROFF In summary the user subprograms are: SETERR - turns on the error state and saves a message and an error number; ENTSRC - at entry, sets recovery (or nonrecovery) mode, provided no error state exists; RETSRC - before returning, checks error situation and, if no errors exist, restores prior recovery (or nonrecovery) mode; NERROR - returns the error number; ERROFF - turns off the error state; EPRINT - prints the error message. These, in turn, call on the lower-level subprograms: E9RINT - stores or prints error message, depending on switch setting; S88FMT - set up FORMAT array for printing; I8SAVE - returns error number or recovery (or nonrecovery) mode, depending on one switch, and resets or does not reset the corresponding value depending on another; FDUMP - a dummy subroutine to be replaced, if possible, by a locally written symbolic dump routine
The third package provides the basic mechanism for allocating and deallocating working storage on a storage stack. In the PORT library [1], for which the package was developed, calls to the general subroutines in the library do not include, in their calling sequences, parameters representing scratch arrays; the work space is allocated and deallocated within the called subprograms. To implement the stack in Fortran in a portable way, it has been put in labeled COMMON as a double-precision array of length 500: DOUBLE PRECISION DSTAK COMMON / CSTAK / DSTAK(500) The stack handling capabilities, which are described more fully in [1], include stack allocation and deallocation (releasing space), stack initialization to a size different from the default length of 500 double-precision locations, stack query, i.e. the ability to find out dynamically how much space is available, modification of the length of the latest allocation, and finally, the ability to ascertain certain stack statistics, such as the number of outstanding allocations, the current active length, and the maximum active length achieved. The various capabilities are summarized as follows: ITYPE flags are: 1 - LOGICAL 2 - INTEGER 3 - REAL 4 - DOUBLE PRECISION 5 - COMPLEX To allocate (get) N locations of type ITYPE on the stack, set INDEX = ISTKGT(N,ITYPE) which returns an index into the stack for the first of the N items. To deallocate (release) the last K allocations (NOT locations, but ENTIRE allocations): CALL ISTKRL (K) To initialize the stack to, say, 1000 double precision locations, use the subroutine, ISTKIN (N,ITYPE), as follows: DOUBLE PRECISION DSTAK COMMON / CSTAK / DSTAK(1000) ... CALL ISTKIN (1000,4) To find out (query) how much space of type, ITYPE, is left: NLEFT = ISKTQU(ITYPE) To modify the length of the current outstanding allocation to N items: INDEX = ISTKMD(N) which will modify the length of the allocation to N items and, as in ISTKGT, return the index of the first item of that allocation. To obtain certain stack statistics, use the INTEGER FUNCTION ISTKST(N) where the argument, N, is 1 - return the number of current allocations, 2 - return the current active length (in INTEGER storage units), 3 - return the maximum length used, 4 - return the maximum length allowed. In summary, the user subprograms are: ISTKGT - allocates space on the stack; ISTKRL - releases (deallocates) space; ISTKIN - initializes (sets length) of stack; ISTKMD - modifies size of last allocation; ISTKQU - answers query as to space available on stack; ISTKST - provides statistics on stack usage; These, in turn, call on the lower-level subprogram: I0TK00 - initializes stack for special cases of nonstandard lengths for INTEGER, REAL, and DOUBLE PRECISION numbers.
The first package contains three Fortran function subprograms which can be invoked to determine basic machine or operating system dependent constants. Versions are provided in commented DATA statements for the Burroughs 5700/6700/7700, the CDC 6000/7000 series, Cray, Data General Eclipse, Harris S220, Honeywell 6000 series, IBM 360/370 series, SEL systems 85/86, PDP-11, DEC-10, DEC-20, Univac 1100, DEC VAX-11/780, and Xerox SIGMA 5/7/9 series; others can be easily added. When the library is moved to a new environment, only the appropriate DATA statements in these three subprograms need to be activated by removing the C's from column 1. The three functions are: I1MACH, which delivers integer constants, R1MACH, which delivers single-precision floating-point (REAL) constants, and D1MACH, which delivers double-precision floating-point constants. These functions have a single integer argument indicating the particular constant desired. For example, R1MACH(2) is the largest single-precision floating-point number on the host machine, so the statement XMAX = R1MACH(2) sets XMAX to this largest number.
Test program 2 in the Port Library Framework checks and prints the constants. Here is its output for the DEC-20/60. FORMAT CONVERSION FOR INTEGERS IS - I13 INTEGER CONSTANTS FOLLOW THE STANDARD INPUT UNIT 5 THE STANDARD OUTPUT UNIT 6 THE STANDARD PUNCH UNIT 7 THE STANDARD ERROR MESSAGE UNIT 6 THE NUMBER OF BITS PER WORD 36 THE NUMBER OF CHARACTERS PER WORD 5 A, THE BASE OF AN S-DIGIT INTEGER 2 S, THE NUMBER OF BASE-A DIGITS 35 A**S - 1, THE LARGEST MAGNITUDE 34359738367 B, THE BASE OF A T-DIGIT FLOATING-POINT NUMBER 2 T, THE NUMBER OF BASE-B DIGITS IN SINGLE-PRECISION 27 EMIN, THE SMALLEST SINGLE-PRECISION EXPONENT -128 EMAX, THE LARGEST SINGLE-PRECISION EXPONENT 127 T, THE NUMBER OF BASE-B DIGITS IN DOUBLE-PRECISION 62 EMIN, THE SMALLEST DOUBLE-PRECISION EXPONENT -128 EMAX, THE LARGEST DOUBLE-PRECISION EXPONENT 127 FORMAT CONVERSION FOR SINGLE-PRECISION IS - E17.09 SINGLE-PRECISION CONSTANTS FOLLOW THE SMALLEST POSITIVE MAGNITUDE 0.146936794E-38 THE LARGEST MAGNITUDE 0.170141182E+39 THE SMALLEST RELATIVE SPACING 0.745058060E-08 THE LARGEST RELATIVE SPACING 0.149011612E-07 LOG10 OF THE BASE 0.301029995E+00 FORMAT CONVERSION FOR DOUBLE-PRECISION IS - D27.19 DOUBLE-PRECISION CONSTANTS FOLLOW THE SMALLEST POSITIVE MAGNITUDE 0.1469367938527859385D-38 THE LARGEST MAGNITUDE 0.1701411834604692317D+39 THE SMALLEST RELATIVE SPACING 0.2168404344971008868D-18 THE LARGEST RELATIVE SPACING 0.4336808689942017736D-18 LOG10 OF THE BASE 0.3010299956639811952D+00
Test program 2 in the Port Library Framework checks and prints the constants. Here is its output for the DEC VAX VMS system. FORMAT CONVERSION FOR INTEGERS IS - I12 INTEGER CONSTANTS FOLLOW THE STANDARD INPUT UNIT 5 THE STANDARD OUTPUT UNIT 6 THE STANDARD PUNCH UNIT 7 THE STANDARD ERROR MESSAGE UNIT 4 THE NUMBER OF BITS PER WORD 32 THE NUMBER OF CHARACTERS PER WORD 4 A, THE BASE OF AN S-DIGIT INTEGER 2 S, THE NUMBER OF BASE-A DIGITS 31 A**S - 1, THE LARGEST MAGNITUDE 2147483647 B, THE BASE OF A T-DIGIT FLOATING-POINT NUMBER 2 T, THE NUMBER OF BASE-B DIGITS IN SINGLE-PRECISION 24 EMIN, THE SMALLEST SINGLE-PRECISION EXPONENT -127 EMAX, THE LARGEST SINGLE-PRECISION EXPONENT 127 T, THE NUMBER OF BASE-B DIGITS IN DOUBLE-PRECISION 56 EMIN, THE SMALLEST DOUBLE-PRECISION EXPONENT -127 EMAX, THE LARGEST DOUBLE-PRECISION EXPONENT 127 FORMAT CONVERSION FOR SINGLE-PRECISION IS - E16.08 SINGLE-PRECISION CONSTANTS FOLLOW THE SMALLEST POSITIVE MAGNITUDE 0.29387359E-38 THE LARGEST MAGNITUDE 0.17014117E+39 THE SMALLEST RELATIVE SPACING 0.59604645E-07 THE LARGEST RELATIVE SPACING 0.11920929E-06 LOG10 OF THE BASE 0.30103001E+00 FORMAT CONVERSION FOR DOUBLE-PRECISION IS - D25.17 DOUBLE-PRECISION CONSTANTS FOLLOW THE SMALLEST POSITIVE MAGNITUDE 0.29387358770557188D-38 THE LARGEST MAGNITUDE 0.17014118346046923D+39 THE SMALLEST RELATIVE SPACING 0.13877787807814457D-16 THE LARGEST RELATIVE SPACING 0.27755575615628914D-16 LOG10 OF THE BASE 0.30102999566398121D+00 D1MACH(5) DOES NOT AGREE WITH CALCULATED VALUE D1MACH(5) = 0.301029995663981212D+00 CALCULATED VALUE = 0.301029995663981198D+00 DIFFERENCE = 0.138777878078144568D-16
DOUBLE PRECISION FUNCTION D1MACH(I) C C DOUBLE-PRECISION MACHINE CONSTANTS C C D1MACH(1) = B**(EMIN-1), THE SMALLEST POSITIVE MAGNITUDE. C C D1MACH(2) = B**EMAX*(1 - B**(-T)), THE LARGEST MAGNITUDE. C C D1MACH(3) = B**(-T), THE SMALLEST RELATIVE SPACING. C C D1MACH(4) = B**(1-T), THE LARGEST RELATIVE SPACING. C C D1MACH(5) = LOG10(B) C
SUBROUTINE E9RINT(MESSG,NW,NERR,SAVE) C C THIS ROUTINE STORES THE CURRENT ERROR MESSAGE OR PRINTS THE OLD ONE, C IF ANY, DEPENDING ON WHETHER OR NOT SAVE = .TRUE. . C
SUBROUTINE ENTSRC(IROLD,IRNEW) C C THIS ROUTINE RETURNS IROLD = LRECOV AND SETS LRECOV = IRNEW. C C IF THERE IS AN ACTIVE ERROR STATE, THE MESSAGE IS PRINTED C AND EXECUTION STOPS. C C IRNEW = 0 LEAVES LRECOV UNCHANGED, WHILE C IRNEW = 1 GIVES RECOVERY AND C IRNEW = 2 TURNS RECOVERY OFF. C C ERROR STATES - C C 1 - ILLEGAL VALUE OF IRNEW. C 2 - CALLED WHILE IN AN ERROR STATE. C
SUBROUTINE EPRINT C C THIS SUBROUTINE PRINTS THE LAST ERROR MESSAGE, IF ANY. C
SUBROUTINE ERROFF C C TURNS OFF THE ERROR STATE OFF BY SETTING LERROR=0. C
SUBROUTINE FDUMP C THIS IS A DUMMY ROUTINE TO BE SENT OUT ON C THE PORT SEDIT TAPE C
INTEGER FUNCTION I1MACH(I) C C I/O UNIT NUMBERS-- C C I1MACH( 1) = THE STANDARD INPUT UNIT. C C I1MACH( 2) = THE STANDARD OUTPUT UNIT. C C I1MACH( 3) = THE STANDARD PUNCH UNIT. C C I1MACH( 4) = THE STANDARD ERROR MESSAGE UNIT. C C WORDS-- C C I1MACH( 5) = THE NUMBER OF BITS PER INTEGER STORAGE UNIT. C C I1MACH( 6) = THE NUMBER OF CHARACTERS PER INTEGER STORAGE UNIT. C C INTEGERS-- C C ASSUME INTEGERS ARE REPRESENTED IN THE S-DIGIT, BASE-A FORM C C SIGN ( X(S-1)*A**(S-1) + ... + X(1)*A + X(0) ) C C WHERE 0 .LE. X(I) .LT. A FOR I=0,...,S-1. C C I1MACH( 7) = A, THE BASE. C C I1MACH( 8) = S, THE NUMBER OF BASE-A DIGITS. C C I1MACH( 9) = A**S - 1, THE LARGEST MAGNITUDE. C C FLOATING-POINT NUMBERS-- C C ASSUME FLOATING-POINT NUMBERS ARE REPRESENTED IN THE T-DIGIT, C BASE-B FORM C C SIGN (B**E)*( (X(1)/B) + ... + (X(T)/B**T) ) C C WHERE 0 .LE. X(I) .LT. B FOR I=1,...,T, C 0 .LT. X(1), AND EMIN .LE. E .LE. EMAX. C C I1MACH(10) = B, THE BASE. C C SINGLE-PRECISION C C I1MACH(11) = T, THE NUMBER OF BASE-B DIGITS. C C I1MACH(12) = EMIN, THE SMALLEST EXPONENT E. C C I1MACH(13) = EMAX, THE LARGEST EXPONENT E. C C DOUBLE-PRECISION C C I1MACH(14) = T, THE NUMBER OF BASE-B DIGITS. C C I1MACH(15) = EMIN, THE SMALLEST EXPONENT E. C C I1MACH(16) = EMAX, THE LARGEST EXPONENT E. C
INTEGER FUNCTION I8SAVE(ISW,IVALUE,SET) C C IF (ISW = 1) I8SAVE RETURNS THE CURRENT ERROR NUMBER AND C SETS IT TO IVALUE IF SET = .TRUE. . C C IF (ISW = 2) I8SAVE RETURNS THE CURRENT RECOVERY SWITCH AND C SETS IT TO IVALUE IF SET = .TRUE. . C
INTEGER FUNCTION ISTKGT(NITEMS,ITYPE) C C ALLOCATES SPACE OUT OF THE INTEGER ARRAY ISTAK (IN COMMON C BLOCK CSTAK) FOR AN ARRAY OF LENGTH NITEMS AND OF TYPE C DETERMINED BY ITYPE AS FOLLOWS C C 1 - LOGICAL C 2 - INTEGER C 3 - REAL C 4 - DOUBLE PRECISION C 5 - COMPLEX C C ON RETURN, THE ARRAY WILL OCCUPY C C STAK(ISTKGT), STAK(ISTKGT+1), ..., STAK(ISTKGT-NITEMS+1) C C WHERE STAK IS AN ARRAY OF TYPE ITYPE EQUIVALENCED TO ISTAK. C C (FOR THOSE WANTING TO MAKE MACHINE DEPENDENT MODIFICATIONS C TO SUPPORT OTHER TYPES, CODES 6,7,8,9,10,11 AND 12 HAVE C BEEN RESERVED FOR 1/4 LOGICAL, 1/2 LOGICAL, 1/4 INTEGER, C 1/2 INTEGER, QUAD PRECISION, DOUBLE COMPLEX AND QUAD C COMPLEX, RESPECTIVELY.) C C THE ALLOCATOR RESERVES THE FIRST TEN INTEGER WORDS OF THE STACK C FOR ITS OWN INTERNAL BOOK-KEEPING. THESE ARE INITIALIZED BY C THE INITIALIZING SUBPROGRAM I0TK00 UPON THE FIRST CALL C TO A SUBPROGRAM IN THE ALLOCATION PACKAGE. C C THE USE OF THE FIRST FIVE WORDS IS DESCRIBED BELOW. C C ISTAK( 1) - LOUT, THE NUMBER OF CURRENT ALLOCATIONS. C ISTAK( 2) - LNOW, THE CURRENT ACTIVE LENGTH OF THE STACK. C ISTAK( 3) - LUSED, THE MAXIMUM VALUE OF ISTAK(2) ACHIEVED. C ISTAK( 4) - LMAX, THE MAXIMUM LENGTH THE STACK. C ISTAK( 5) - LBOOK, THE NUMBER OF WORDS USED FOR BOOKEEPING. C C THE NEXT FIVE WORDS CONTAIN INTEGERS DESCRIBING THE AMOUNT C OF STORAGE ALLOCATED BY THE FORTRAN SYSTEM TO THE VARIOUS C DATA TYPES. THE UNIT OF MEASUREMENT IS ARBITRARY AND MAY C BE WORDS, BYTES OR BITS OR WHATEVER IS CONVENIENT. THE C VALUES CURRENTLY ASSUMED CORRESPOND TO AN ANS FORTRAN C ENVIRONMENT. FOR SOME MINI-COMPUTER SYSTEMS THE VALUES MAY C HAVE TO BE CHANGED (SEE I0TK00). C C ISTAK( 6) - THE NUMBER OF UNITS ALLOCATED TO LOGICAL C ISTAK( 7) - THE NUMBER OF UNITS ALLOCATED TO INTEGER C ISTAK( 8) - THE NUMBER OF UNITS ALLOCATED TO REAL C ISTAK( 9) - THE NUMBER OF UNITS ALLOCATED TO DOUBLE PRECISION C ISTAK(10) - THE NUMBER OF UNITS ALLOCATED TO COMPLEX C C ERROR STATES - C C 1 - NITEMS .LT. 0 C 2 - ITYPE .LE. 0 .OR. ITYPE .GE. 6 C 3 - LNOW, LUSED, LMAX OR LBOOK OVERWRITTEN C 4 - STACK OVERFLOW C
SUBROUTINE ISTKIN(NITEMS,ITYPE) C C INITIALIZES THE STACK ALLOCATOR, SETTING THE LENGTH OF THE STACK. C C ERROR STATES - C C 1 - NITEMS .LE. 0 C 2 - ITYPE .LE. 0 .OR. ITYPE .GE. 6 C
INTEGER FUNCTION ISTKMD(NITEMS) C C CHANGES THE LENGTH OF THE FRAME AT THE TOP OF THE STACK C TO NITEMS. C C ERROR STATES - C C 1 - LNOW OVERWRITTEN C 2 - ISTAK(LNOWO-1) OVERWRITTEN C
INTEGER FUNCTION ISTKQU(ITYPE) C C RETURNS THE NUMBER OF ITEMS OF TYPE ITYPE THAT REMAIN C TO BE ALLOCATED IN ONE REQUEST. C C ERROR STATES - C C 1 - LNOW, LUSED, LMAX OR LBOOK OVERWRITTEN C 2 - ITYPE .LE. 0 .OR. ITYPE .GE. 6 C
SUBROUTINE ISTKRL(NUMBER) C C DE-ALLOCATES THE LAST (NUMBER) ALLOCATIONS MADE IN THE STACK C BY ISTKGT. C C ERROR STATES - C C 1 - NUMBER .LT. 0 C 2 - LNOW, LUSED, LMAX OR LBOOK OVERWRITTEN C 3 - ATTEMPT TO DE-ALLOCATE NON-EXISTENT ALLOCATION C 4 - THE POINTER AT ISTAK(LNOW) OVERWRITTEN C
INTEGER FUNCTION ISTKST(NFACT) C C RETURNS CONTROL INFORMATION AS FOLLOWS C C NFACT ITEM RETURNED C C 1 LOUT, THE NUMBER OF CURRENT ALLOCATIONS C 2 LNOW, THE CURRENT ACTIVE LENGTH C 3 LUSED, THE MAXIMUM USED C 4 LMAX, THE MAXIMUM ALLOWED C
INTEGER FUNCTION NERROR(NERR) C C RETURNS NERROR = NERR = THE VALUE OF THE ERROR FLAG LERROR. C
REAL FUNCTION R1MACH(I) C C SINGLE-PRECISION MACHINE CONSTANTS C C R1MACH(1) = B**(EMIN-1), THE SMALLEST POSITIVE MAGNITUDE. C C R1MACH(2) = B**EMAX*(1 - B**(-T)), THE LARGEST MAGNITUDE. C C R1MACH(3) = B**(-T), THE SMALLEST RELATIVE SPACING. C C R1MACH(4) = B**(1-T), THE LARGEST RELATIVE SPACING. C C R1MACH(5) = LOG10(B) C
SUBROUTINE RETSRC(IROLD) C C THIS ROUTINE SETS LRECOV = IROLD. C C IF THE CURRENT ERROR BECOMES UNRECOVERABLE, C THE MESSAGE IS PRINTED AND EXECUTION STOPS. C C ERROR STATES - C C 1 - ILLEGAL VALUE OF IROLD. C
SUBROUTINE S88FMT( N, W, IFMT ) C C S88FMT REPLACES IFMT(1), ... , IFMT(N) WITH C THE CHARACTERS CORRESPONDING TO THE N LEAST SIGNIFICANT C DIGITS OF W. C
SUBROUTINE SETERR(MESSG,NMESSG,NERR,IOPT) C C SETERR SETS LERROR = NERR, OPTIONALLY PRINTS THE MESSAGE AND DUMPS C ACCORDING TO THE FOLLOWING RULES... C C IF IOPT = 1 AND RECOVERING - JUST REMEMBER THE ERROR. C IF IOPT = 1 AND NOT RECOVERING - PRINT AND STOP. C IF IOPT = 2 - PRINT, DUMP AND STOP. C C INPUT C C MESSG - THE ERROR MESSAGE. C NMESSG - THE LENGTH OF THE MESSAGE, IN CHARACTERS. C NERR - THE ERROR NUMBER. MUST HAVE NERR NON-ZERO. C IOPT - THE OPTION. MUST HAVE IOPT=1 OR 2. C C ERROR STATES - C C 1 - MESSAGE LENGTH NOT POSITIVE. C 2 - CANNOT HAVE NERR=0. C 3 - AN UNRECOVERED ERROR FOLLOWED BY ANOTHER ERROR. C 4 - BAD VALUE FOR IOPT. C C ONLY THE FIRST 72 CHARACTERS OF THE MESSAGE ARE PRINTED. C C THE ERROR HANDLER CALLS A SUBROUTINE NAMED FDUMP TO PRODUCE A C SYMBOLIC DUMP. TO COMPLETE THE PACKAGE, A DUMMY VERSION OF FDUMP C IS SUPPLIED, BUT IT SHOULD BE REPLACED BY A LOCALLY WRITTEN VERSION C WHICH AT LEAST GIVES A TRACE-BACK. C