home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / unix / question / 13520 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.9 KB  |  106 lines

  1. Xref: sparky comp.unix.questions:13520 comp.sys.hp:12993
  2. Newsgroups: comp.unix.questions,comp.sys.hp
  3. Path: sparky!uunet!utcsri!helios.physics.utoronto.ca!alchemy.chem.utoronto.ca!system
  4. From: system@alchemy.chem.utoronto.ca (System Admin (Mike Peterson))
  5. Subject: Re: lib77 "flush" call. Where is it in UNIX?
  6. Message-ID: <1992Nov17.172955.27890@alchemy.chem.utoronto.ca>
  7. Organization: University of Toronto Chemistry Department
  8. References: <1992Nov17.122303.3080@cfa160.harvard.edu>
  9. Date: Tue, 17 Nov 1992 17:29:55 GMT
  10. Lines: 94
  11.  
  12. In article <1992Nov17.122303.3080@cfa160.harvard.edu> bruce@head-cfa.harvard.edu (Bruce Sams) writes:
  13. >Dear fellow UNIX and HP-UX folks,
  14. >
  15. >   I am trying to bring up the graphics package MONGO on our HP-720 machine
  16. >   and I have encountered a problem.  It seems that MONGO uses a "flush"
  17. >   call deep in its IO guts.  Looking through all the HP-UX libraries I 
  18. >   find no such routine.  Rather, I find "pflushli", "flushinp", "intrflush",
  19. >   "__cflush", "fflush", and "fflush_p."  Some of these are clearly not
  20. >   what I want, but others are less certainly wrong.  I find no documentation
  21.  
  22. You can write a "flush" that calls "fflush" (which is a standard C
  23. routine, and you should have a man page for it). You will need to use the
  24. HP-UX 'fstream' routine to map the FORTRAN unit number to a C stream number.
  25.  
  26. I can't send you source for flush since it is licensed, but you can
  27. have these routines I used to make it work:
  28.  
  29.       function igetfstream (lunit)
  30. c
  31. c     Purpose:
  32. c        Return the FILE pointer corresponding to unit 'lunit',
  33. c        or 0 if unit 'lunit' is not open.
  34. c
  35.       logical opened
  36. c
  37. c
  38. c     write (6,*) 'igetfstream called for unit ', lunit
  39.       inquire (unit=lunit, opened=opened)
  40.       if (opened) then
  41.          igetfstream = fstream (lunit)
  42.          if (igetfstream .eq. 0) then
  43.             if (lunit .eq. 5) then
  44.                igetfstream = igetstdin ()
  45.             else if (lunit .eq. 6) then
  46.                igetfstream = igetstdout ()
  47.             else if (lunit .eq. 7) then
  48.                igetfstream = igetstderr ()
  49.             end if
  50.          end if
  51.       else
  52.          igetfstream = 0
  53.       end if
  54. c     write (6,'(1x,a,z9.8)') 'igetfstream returning ', igetfstream
  55.       return
  56.       end
  57.  
  58. To get the stream number for stdin/stdout/stderr, try:
  59.  
  60. /*
  61.  * Return the FILE pointer to stdin.
  62.  */
  63.  
  64. #include <stdio.h>
  65.  
  66.     FILE *
  67. igetstdin_ ()
  68. {
  69.     return (stdin);
  70. }
  71.  
  72.  
  73. /*
  74.  * Return the FILE pointer to stdout.
  75.  */
  76.  
  77. #include <stdio.h>
  78.  
  79.     FILE *
  80. igetstdout_ ()
  81. {
  82.     return (stdout);
  83. }
  84.  
  85.  
  86. /*
  87.  * Return the FILE pointer to stderr.
  88.  */
  89.  
  90. #include <stdio.h>
  91.  
  92.     FILE *
  93. igetstderr_ ()
  94. {
  95.     return (stderr);
  96. }
  97.  
  98.  
  99. Note that always use "+ppu" for f77 compilations; you will need
  100. to remove the trailing '_' on the C routines if you don't.
  101.  
  102. I have (cross-)posted this to comp.sys.hp.
  103. -- 
  104. What are the chances that any HP computer system will ever "work" properly?
  105. ... and Slim just left town. -*- Mike Peterson, SysAdmin, U/Toronto Chemistry
  106.