home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.fortran:4299 comp.os.vms:17854
- Newsgroups: comp.lang.fortran,comp.os.vms
- Path: sparky!uunet!charon.amdahl.com!pacbell.com!ames!haven.umd.edu!decuac!pa.dec.com!e2big.mko.dec.com!quark.enet.dec.com!lionel
- From: lionel@quark.enet.dec.com (Steve Lionel)
- Subject: Re: Turning VAX FORTRAN IOSTAT returns into VMS status codes?
- Message-ID: <1992Nov12.150639.8340@e2big.mko.dec.com>
- Lines: 78
- Sender: usenet@e2big.mko.dec.com (Mr. USENET)
- Reply-To: lionel@quark.enet.dec.com (Steve Lionel)
- Organization: Digital Equipment Corporation, Nashua NH
- References: <2b022ab8.3aaa@lhn.gns.cri.nz>
- Date: Thu, 12 Nov 1992 15:06:39 GMT
-
-
- In article <2b022ab8.3aaa@lhn.gns.cri.nz>, mdlcpgs@lhn.gns.cri.nz writes:
- |>Hi. I wonder if anyone can tell me how to turn a VAX FORTRAN
- |>IOSTAT status return value into a VMS status for signalling
- |>by LIB$SIGNAL? I cant in this application use ERRSNS because
- |>the error of interest may not be the last io transaction on
- |>the file at the time when I want to signal.
-
- Here's a function that does it. It's a bit wordier than I might have hacked
- up on my own but I wanted it to be understandable. The key notion is that
- the IOSTAT value is just the "message number" part of a VMS condition code
- using the FOR$ (FORTRAN Run-Time Library) facility. Note that you can't
- recover the severity of the original error except by using knowledge of how
- it was assigned, which I have done here.
-
- INTEGER*4 FUNCTION IOSTAT_TO_STATUS (IOSTAT)
- C+
- C
- C FUNCTIONAL DESCRIPTION:
- C
- C Converts FORTRAN IOSTAT value to a VMS condition code suitable for
- C use by LIB$SIGNAL
- C
- C FORMAL PARAMETERS:
- C
- C IOSTAT:
- C The IOSTAT value to be converted, INTEGER*4
- C
- C FUNCTION VALUE:
- C
- C The VMS condition code equivalent of the IOSTAT value argument.
- C
- C-
- IMPLICIT NONE
- INTEGER*4 IOSTAT
- INCLUDE '($FORDEF)' ! FORTRAN RTL error message codes
- INCLUDE '($FORIOSDEF)' ! IOSTAT definitions
- INCLUDE '($STSDEF)' ! VMS condition code format
- INCLUDE '($SSDEF)' ! VMS statuses
-
- ! Define base message code value
- !
- INTEGER*4 FORMSG_BASE
- PARAMETER (FORMSG_BASE =
- 1 ISHFT(FOR$_FACILITY,STS$V_FAC_NO) + ! FOR$ facility code
- 2 STS$M_FAC_SP) ! Facility specific
-
- ! IOSTAT of zero means success
- !
- IF (IOSTAT .EQ. 0) THEN
- IOSTAT_TO_STATUS = SS$_NORMAL
- !
- ! Negative IOSTAT means end of file
- !
- ELSE IF (IOSTAT .LT. 0) THEN
- IOSTAT_TO_STATUS = FOR$_ENDDURREA
- !
- ! Otherwise IOSTAT is MSG_NO part of message with F severity
- ! (except for OUTCONERR which is E severity)
- !
- ELSE
- IF (IOSTAT .EQ. FOR$IOS_OUTCONERR) THEN
- IOSTAT_TO_STATUS = FOR$_OUTCONERR
- ELSE
- IOSTAT_TO_STATUS = FORMSG_BASE +
- 1 ISHFT(IOSTAT,STS$V_MSG_NO) + STS$K_SEVERE
- END IF
- END IF
- RETURN
- END
-
- --
-
- Steve Lionel lionel@quark.enet.dec.com
- SDT Languages Group
- Digital Equipment Corporation
- 110 Spit Brook Road
- Nashua, NH 03062
-