home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / fortran / 4299 < prev    next >
Encoding:
Internet Message Format  |  1992-11-12  |  2.8 KB

  1. Xref: sparky comp.lang.fortran:4299 comp.os.vms:17854
  2. Newsgroups: comp.lang.fortran,comp.os.vms
  3. 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
  4. From: lionel@quark.enet.dec.com (Steve Lionel)
  5. Subject: Re: Turning VAX FORTRAN IOSTAT returns into VMS status codes?
  6. Message-ID: <1992Nov12.150639.8340@e2big.mko.dec.com>
  7. Lines: 78
  8. Sender: usenet@e2big.mko.dec.com (Mr. USENET)
  9. Reply-To: lionel@quark.enet.dec.com (Steve Lionel)
  10. Organization: Digital Equipment Corporation, Nashua NH
  11. References:  <2b022ab8.3aaa@lhn.gns.cri.nz>
  12. Date: Thu, 12 Nov 1992 15:06:39 GMT
  13.  
  14.  
  15. In article <2b022ab8.3aaa@lhn.gns.cri.nz>, mdlcpgs@lhn.gns.cri.nz writes:
  16. |>Hi. I wonder if anyone can tell me how to turn a VAX FORTRAN
  17. |>IOSTAT status return value into a VMS status for signalling
  18. |>by LIB$SIGNAL?  I cant in this application use ERRSNS because
  19. |>the error of interest may not be the last io transaction on
  20. |>the file at the time when I want to signal.
  21.  
  22. Here's a function that does it.  It's a bit wordier than I might have hacked
  23. up on my own but I wanted it to be understandable.  The key notion is that
  24. the IOSTAT value is just the "message number" part of a VMS condition code
  25. using the FOR$ (FORTRAN Run-Time Library) facility.  Note that you can't
  26. recover the severity of the original error except by using knowledge of how
  27. it was assigned, which I have done here.
  28.  
  29.     INTEGER*4 FUNCTION IOSTAT_TO_STATUS (IOSTAT)
  30. C+
  31. C FUNCTIONAL DESCRIPTION:
  32. C     Converts FORTRAN IOSTAT value to a VMS condition code suitable for
  33. C     use by LIB$SIGNAL
  34. C FORMAL PARAMETERS:
  35. C  
  36. C     IOSTAT:
  37. C      The IOSTAT value to be converted, INTEGER*4
  38. C   
  39. C FUNCTION VALUE:
  40. C     The VMS condition code equivalent of the IOSTAT value argument.
  41. C-
  42.     IMPLICIT NONE
  43.     INTEGER*4 IOSTAT
  44.     INCLUDE '($FORDEF)' ! FORTRAN RTL error message codes
  45.     INCLUDE '($FORIOSDEF)'    ! IOSTAT definitions
  46.     INCLUDE '($STSDEF)' ! VMS condition code format
  47.     INCLUDE '($SSDEF)'  ! VMS statuses
  48.  
  49.     ! Define base message code value
  50.     !
  51.     INTEGER*4 FORMSG_BASE
  52.     PARAMETER (FORMSG_BASE =
  53.     1  ISHFT(FOR$_FACILITY,STS$V_FAC_NO) +    ! FOR$ facility code
  54.     2  STS$M_FAC_SP)                ! Facility specific
  55.  
  56.     ! IOSTAT of zero means success
  57.     !
  58.     IF (IOSTAT .EQ. 0) THEN
  59.         IOSTAT_TO_STATUS = SS$_NORMAL
  60.     !
  61.     ! Negative IOSTAT means end of file
  62.     !
  63.     ELSE IF (IOSTAT .LT. 0) THEN
  64.         IOSTAT_TO_STATUS = FOR$_ENDDURREA
  65.     !
  66.     ! Otherwise IOSTAT is MSG_NO part of message with F severity
  67.     ! (except for OUTCONERR which is E severity)
  68.     !
  69.     ELSE
  70.         IF (IOSTAT .EQ. FOR$IOS_OUTCONERR) THEN
  71.           IOSTAT_TO_STATUS = FOR$_OUTCONERR
  72.         ELSE
  73.           IOSTAT_TO_STATUS = FORMSG_BASE +
  74.     1       ISHFT(IOSTAT,STS$V_MSG_NO) + STS$K_SEVERE
  75.         END IF
  76.     END IF
  77.     RETURN
  78.     END
  79.  
  80. --
  81.  
  82. Steve Lionel                    lionel@quark.enet.dec.com
  83. SDT Languages Group
  84. Digital Equipment Corporation
  85. 110 Spit Brook Road
  86. Nashua, NH 03062
  87.