home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / sgi / 11132 < prev    next >
Encoding:
Internet Message Format  |  1992-07-21  |  6.0 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!mp.cs.niu.edu!fnnews!fnsony.fnal.gov!shah
  2. From: shah@fnsony.fnal.gov (Hemant Shah)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: trouble with f77 and named pipes
  5. Message-ID: <2099@fnnews.fnal.gov>
  6. Date: 21 Jul 92 20:33:17 GMT
  7. References: <1992Jul21.100630.11396@dxcern.cern.ch>
  8. Sender: news@fnnews.fnal.gov
  9. Reply-To: shah@fnalb.fnal.gov
  10. Organization: Fermi National Accelerator Laboratory, Batavia, IL
  11. Lines: 165
  12. Nntp-Posting-Host: fnsony.fnal.gov
  13.  
  14. In article <1992Jul21.100630.11396@dxcern.cern.ch>, burow@dxcern.cern.ch (Burkhard Burow) writes:
  15. |> 
  16. |> I'm having trouble using named pipes with SGI's f77. My troubles get worse
  17. |> with the newer software releases.
  18. |> 
  19. |> SUMMARY: I'd like SGI f77 to behave like DECFortran w.r.t. named pipes.
  20. |>          i.e. - The READONLY specifier in the OPEN allows Fortran to read from
  21. |>                 a named pipe and recognize the EOF when the partner program has
  22. |>                 closed the pipe.
  23. |>               - Without the READONLY specifier Fortran can write to a named
  24. |>         pipe, blocking etc. as usual.
  25. |> 
  26. |> My observations of SGI and Ultrix Fortran with named pipes follows. 
  27. |> If I'm doing something goofy please tell me!
  28. |> 
  29. |> I'm currently running a simulation program on ~40 DECstations in parallel and
  30. |> the main input and output streams for each instance of the program go through
  31. |> named pipes and on to the manager-program. In a month I'll have access to
  32. |> 32 4D/35's. 
  33. |> [Not using named pipes is NOT an option. I'm using an application written for
  34. |>  one proccessor, and use named pipes to allow the unmodified application to
  35. |>  continue to think that it is running on a single processor.]
  36. |> 
  37. |> thanks,
  38. |> burkhard   burow@vxdesy.cern.ch
  39. |> 
  40. |> -------begin observations from Fortran/named pipe tests------------------
  41. |> 
  42. |> Ultrix  == DECFortran 3.1 running under Ultrix 4.2 on a DECstation.
  43. |> 4D/25   == f77 (versions says ftn 90/10/02) under IRIX 3.3.1 on a 4D/25
  44. |> Crimson == f77 (versions says ftn 06/01/92) under IRIX 4.0.4
  45. |> 
  46. |> Fortran reading from a named pipe:
  47. |> ----------------------------------
  48. |> 
  49. |> unix> cat > i.f
  50. |>       program i
  51. |>       open (unit=11,status='unknown',form='formatted',file='pipe'
  52. |>      +      ,readonly)
  53. |>       do 100 i=1,10000
  54. |>          read (unit=11,fmt=*,end=999) n
  55. |>          print *, n
  56. |>  100  continue
  57. |>  999  continue
  58. |>       close (unit=11)
  59. |>       end
  60. |> ^D
  61. |> unix> f77 -o i i.f
  62. |> unix> cat > data
  63. |> 1
  64. |> 2
  65. |> 3
  66. |> 4
  67. |> ^D
  68. |> unix> mknod pipe p
  69. |> 
  70. |> Then, 
  71. |> 
  72. |> unix> cat data > pipe & i
  73. |>  and
  74. |> unix> i >& temp & cat data > pipe && cat temp
  75. |> 
  76. |> work as expected on the 4D/25 (not the Crimson) and Ultrix.
  77. |> i.e. It doesn't matter which process connects first, and the Fortran program
  78. |>      can read from the named pipe.
  79. |> 
  80. |> Ultrix - 
  81. |> If I remove the READONLY specifier from the OPEN, DECFortran will never see EOF
  82. |> from the named pipe when the writing process closes its connection. The 4D/25
  83. |> doesn't care about the READONLY and continues to work normally without it.
  84. |> 
  85. |> Crimson -
  86. |> I can't get Fortran to recognize 'EOF' for a named pipe. The only way I can get
  87. |> the program to stop reading from the pipe is to send 'bad' input data so that
  88. |> the program exits. e.g.
  89. |> Crimson> i >& i.log&
  90. |> [2] 24448
  91. |> Crimson> cat data > pipe&
  92. |> [3] 24449
  93. |> Crimson>
  94. |> [3]    Done                   cat data > pipe
  95. |> Crimson> echo junk > pipe
  96. |> Crimson>
  97. |> [2]    Exit 112               i >& i.log
  98. |> Crimson> cat i.log
  99. |> list input: incomprehensible list input
  100. |> apparent state: unit 11 named pipe
  101. |> last format: list io
  102. |> lately reading sequential formatted external IO
  103. |>             1
  104. |>             2
  105. |>             3
  106. |>             4
  107. |> Crimson>
  108. |> 
  109. |> Again, this behavior is independent of using the READONLY specifier in OPEN.
  110. |> 
  111. |> 
  112. |> Fortran writing to a named pipe:
  113. |> --------------------------------
  114. |> 
  115. |> unix> cat > o.f
  116. |>       program o
  117. |>       open (unit=11,status='unknown',form='formatted',
  118. |>      +      file='pipe')
  119. |>       write (unit=11,fmt=*) 'hi, how are you ?'
  120. |>       end
  121. |> ^D
  122. |> unix> f77 -o o o.f
  123. |> unix> mknod pipe p
  124. |> 
  125. |> 
  126. |> Now,
  127. |> 
  128. |> Ultrix> o & cat pipe > temp
  129. |>  and
  130. |> Ultrix> o & cat pipe > temp
  131. |> 
  132. |> works, but on the 4D/25
  133. |> 
  134. |> 4D/25> o&
  135. |> 4D/25> cat pipe > temp&
  136. |> 4D/25> echo > pipe
  137. |> 
  138. |> 'works'. i.e. A third process has to write to the pipe, and hangup, before the
  139. |> original processes will. Note that if you switch the order of the processes
  140. |> connecting to the pipe, 
  141. |> 
  142. |> 4D/25> cat pipe > temp&
  143. |> 4D/25> o&
  144. |> 
  145. |> nothing will be transferred through the pipe.
  146. |> 
  147. |> The Crimson doesn't write to a named pipe. It makes the connection, but doesn't
  148. |> ouput anything. e.g.
  149. |> Crimson> mknod pipe p
  150. |> Crimson> cat pipe >& o.log&
  151. |> [2] 24408
  152. |> Crimson> o
  153. |> [2]  - Done                   cat pipe > & o.log
  154. |> Crimson> cat o.log
  155. |> Crimson>
  156. |> 
  157. |> -------end observations from Fortran/named pipe tests------------------
  158.  
  159. I had similar problem with pipes using C. My code worked under SUN (SunOS
  160. 4.1.x) IBM RS/6000 (AIX3.1.5 and AIX 3.2) and SGI (IRIX 3.3.x) but failed 
  161. under IRIX 4.0.x. SGI has changed implementation of pipes under IRIX 4.0.x. 
  162. The pipes should be opened as READONLY by one process and WRITEONLY by another
  163. process (uni-directional pipe) or both processes should open the pipe
  164. READWRITE (bi-directional) otherwise the system gets confused.
  165.  
  166. You may want to check your code and make sure that you open pipes in correct
  167. manner.
  168.  
  169. Hope this help :-)
  170. -- 
  171. -------------------------------------------------------------------------------
  172. Hemant Shah                            | All the opinions expressed are my own
  173. Fermi National Accelerator Laboratory  | and does not necessarily reflect
  174. Systems Integration Group              | those of Fermilab.
  175. E-mail :shah@fnal.fnal.gov             |
  176.  Voice : (708) 840-8071                   | I haven't lost my mind
  177.    Fax : (708) 840-2783                | it's backed on tape somewhere.
  178. -------------------------------------------------------------------------------
  179.