<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Fortran program hangs when writing to offline reverse TNA device in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188273#M105808</link>
    <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;Thanks for the code, I have a similar test program based on the info Volker directed me to. It seems to me the timeout only concerns reads and not writes, my program will still hang indefinitely when I write to the device and it's off.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;c
        Program test_useropen
c
        integer         iostat,ierr,sysfil
        external        timeout_config
c
        sysfil = 10000
c
        Print *, 'opening device'
        OPEN (UNIT=SYSFIL, 
        1       STATUS='OLD', 
        1       SHARED,
        1       ACCESS='APPEND',
        1       FILE='FIL',         ! FIL is a system logical = TNA101:
        1       IOSTAT=IOSTAT,
        1       FORM='FORMATTED',
        1       USEROPEN=TIMEOUT_CONFIG)
        Print *, 'open status: ',iostat
c
c
        Print *, 'starting write'
        write(sysfil,fmt=10,iostat=iostat)
10      format(1x,'testing writing to an offline device')
        Print *, 'finished or skipped write with status: ',iostat
        close(sysfil)
c
        END
c
c
        Integer Function Timeout_config(FAB,RAB,LUN)
c
        Include '($FABDEF)'
        Include '($RABDEF)'
        Include '($SYSSRVNAM)'
c
        Record /FABDEF/ FAB
        Record /RABDEF/ RAB
c
        RAB.RAB$L_ROP = IBSET(RAB.RAB$L_ROP,RAB$V_TMO) 
        RAB.RAB$B_TMO = 5
c
        Timeout_config = sys$open(fab)
        IF (.not. timeout_config) RETURN
        Timeout_config = sys$connect(rab)
c
        Return
        END
c&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;RBW&lt;/P&gt;</description>
    <pubDate>Tue, 16 May 2023 23:17:54 GMT</pubDate>
    <dc:creator>R_B_W</dc:creator>
    <dc:date>2023-05-16T23:17:54Z</dc:date>
    <item>
      <title>Fortran program hangs when writing to offline reverse TNA device</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7187802#M105798</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I've recently inherited our VMS system and I'm running into problems when a fortran program tries to write to a reverse TNA device that is offline at the device end (e.g. powered off, network outage). These still show up as online when using:&lt;BR /&gt;&amp;gt;show dev tna&lt;BR /&gt;(Which I believe to be property of reverse telnet devices.)&lt;/P&gt;&lt;P&gt;The TNA devices are opened in fortran using the standard Open() function and are written to using the standard write() function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally the write function, or underlying tcp, would hit a timeout/error condition and return an iostat which can be handled and the program can continue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've read through the available documentation on fortran and tcpip but haven't found anything I think is relevant.&lt;/P&gt;&lt;P&gt;Any ideas on how I can prevent the program hanging? Thanks!&lt;/P&gt;&lt;P&gt;Running:&amp;nbsp;&lt;BR /&gt;OpenVMS 8.4-2&amp;nbsp;&amp;nbsp;&lt;BR /&gt;TCPIP V5.7 - ECO5&lt;BR /&gt;VSI Fortran V8.3&lt;/P&gt;&lt;P&gt;Apologies if this is poorly worded/explained, I'm new to both VMS and software management.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;RBW&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 04:29:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7187802#M105798</guid>
      <dc:creator>R_B_W</dc:creator>
      <dc:date>2023-05-11T04:29:17Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran program hangs when writing to offline reverse TNA device</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7187840#M105799</link>
      <description>&lt;P&gt;RBW,&lt;/P&gt;&lt;P&gt;AFAIK a write with timeout cannot be done with standard FORTRAN statements.&lt;/P&gt;&lt;P&gt;You have 2 alternatives. both require OpenVMS programming skills and changes to your source code:&lt;/P&gt;&lt;P&gt;- use USEROPEN and set RAB$V_TMO and&amp;nbsp;&lt;SPAN&gt;RAB$B_TMO&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;see&amp;nbsp;&lt;A href="https://docs.vmssoftware.com/vsi-fortran-for-openvms-user-manual/" target="_blank"&gt;VSI Fortran for OpenVMS User Manual — VMS Software, Inc.&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;- use QIOs with a timer, ASTs and/or event flags&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Volker.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 09:32:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7187840#M105799</guid>
      <dc:creator>Volker Halle</dc:creator>
      <dc:date>2023-05-10T09:32:09Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran program hangs when writing to offline reverse TNA device</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188174#M105803</link>
      <description>&lt;P&gt;Thanks for the leads Volker! I'll accept this as the solution until I get around to testing/confirming useropen.&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;RBW&lt;/P&gt;</description>
      <pubDate>Mon, 15 May 2023 21:09:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188174#M105803</guid>
      <dc:creator>R_B_W</dc:creator>
      <dc:date>2023-05-15T21:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran program hangs when writing to offline reverse TNA device</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188249#M105804</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I did something similar with useropen to set the wait-for-lock bit.&amp;nbsp; I've modified this slightly to use the timeout bit to produce a demo program.&amp;nbsp; Hopefully this will help.&amp;nbsp; It does I/O to the terminal using Fortran Read/Write.&amp;nbsp; If the read times out, it will exit with an error.&lt;/P&gt;&lt;P&gt;Tom Wade&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;C   Program to demonstrate timeout I/O

        Program Demo_Timeout

        Implicit None
        Integer         status, unit, length
        Character *256  line
        Integer         Set_Timeout_IO
        External        Set_Timeout_IO

        Call Lib$Get_LUN (unit)
        Open (unit, name='SYS$COMMAND', status='old', useropen=Set_Timeout_IO)

C   Write and read some data.

        Write (unit, 21, err=80)
21      Format (' This is some data')
        Read (unit, 11, err=80) length, line
11      Format (Q, A)
        Write (unit, 22, err=80) line (1:length)
22      Format (' Read "', A, '"')
        Close (unit)
        Call Lib$Free_Lun (unit)
        Call Exit

C  Error branch

80      Call Errsns (,status,,,)
        Call Exit (status)
        End

C+
        Integer Function Set_Timeout_IO (fab, rab, unit)

C  Open the file described by File Access Block 'fab', Record Access Block
C  'rab' and logical unit number 'unit'.  We open the file so that all I/O
C  is subject to a timeout.
C-
        Integer         unit, status
        Include         '($FABDEF)'
        Include         '($RABDEF)'
        Include         '($SYSSRVNAM)'
        Record  /FABDEF/        fab
        Record  /RABDEF/        rab


C   Set the required bit for timeout

        rab.Rab$L_Rop = rab.Rab$L_Rop .or. Rab$M_Tmo

C   Set the timeout period

        rab.Rab$B_Tmo = 5               ! seconds


C   Open the file.

        status = Sys$Open (fab)

        If (status) status = Sys$Connect (rab)

C   Return status

        Set_Timeout_IO = status
        End&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 16:15:36 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188249#M105804</guid>
      <dc:creator>Tom Wade_1</dc:creator>
      <dc:date>2023-05-16T16:15:36Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran program hangs when writing to offline reverse TNA device</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188273#M105808</link>
      <description>&lt;P&gt;Hi Tom,&lt;/P&gt;&lt;P&gt;Thanks for the code, I have a similar test program based on the info Volker directed me to. It seems to me the timeout only concerns reads and not writes, my program will still hang indefinitely when I write to the device and it's off.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;c
        Program test_useropen
c
        integer         iostat,ierr,sysfil
        external        timeout_config
c
        sysfil = 10000
c
        Print *, 'opening device'
        OPEN (UNIT=SYSFIL, 
        1       STATUS='OLD', 
        1       SHARED,
        1       ACCESS='APPEND',
        1       FILE='FIL',         ! FIL is a system logical = TNA101:
        1       IOSTAT=IOSTAT,
        1       FORM='FORMATTED',
        1       USEROPEN=TIMEOUT_CONFIG)
        Print *, 'open status: ',iostat
c
c
        Print *, 'starting write'
        write(sysfil,fmt=10,iostat=iostat)
10      format(1x,'testing writing to an offline device')
        Print *, 'finished or skipped write with status: ',iostat
        close(sysfil)
c
        END
c
c
        Integer Function Timeout_config(FAB,RAB,LUN)
c
        Include '($FABDEF)'
        Include '($RABDEF)'
        Include '($SYSSRVNAM)'
c
        Record /FABDEF/ FAB
        Record /RABDEF/ RAB
c
        RAB.RAB$L_ROP = IBSET(RAB.RAB$L_ROP,RAB$V_TMO) 
        RAB.RAB$B_TMO = 5
c
        Timeout_config = sys$open(fab)
        IF (.not. timeout_config) RETURN
        Timeout_config = sys$connect(rab)
c
        Return
        END
c&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;RBW&lt;/P&gt;</description>
      <pubDate>Tue, 16 May 2023 23:17:54 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188273#M105808</guid>
      <dc:creator>R_B_W</dc:creator>
      <dc:date>2023-05-16T23:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: Fortran program hangs when writing to offline reverse TNA device</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188358#M105814</link>
      <description>&lt;P&gt;RBW,&lt;/P&gt;&lt;P&gt;as the RAB$V_TMO mechanism does not seem to work on WRITE - see above examples - I checked the DCL READ and WRITE statements. There is a /TIME_OUT=n parameter for READ, but not for WRITE. This might mean, that a timeout for a RMS WRITE operation is not implemented - except for a timeout on a record lock.&lt;/P&gt;&lt;P&gt;So the best approch would be to write a subroutine, which uses QIOs and TIMER ASTs&lt;/P&gt;&lt;P&gt;See previous discussion of a similar questions in&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.hpe.com/t5/operating-system-openvms/sys-qiow-doesn-t-return-to-caller/m-p/3178822#" target="_blank"&gt;Re: SYS$QIOW doesn't return to caller - Hewlett Packard Enterprise Community (hpe.com)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Volker.&lt;/P&gt;</description>
      <pubDate>Thu, 18 May 2023 05:50:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/fortran-program-hangs-when-writing-to-offline-reverse-tna-device/m-p/7188358#M105814</guid>
      <dc:creator>Volker Halle</dc:creator>
      <dc:date>2023-05-18T05:50:48Z</dc:date>
    </item>
  </channel>
</rss>

