[comp.lang.fortran] flush doesn't work with dec3100 f77 compiler

oliveria@engin.umich.edu (ROQUE DONIZETE DE OLIVEIRA) (05/25/91)

C Apparently the FLUSH routine doesn't work on the dec3100 (ultrix 3.1)
C and dec5000 (ultrix 4.1). It did work on a Sun Sparcstation and Apollo (you
C don't even need to flush on the apollos).
C To test it out, compile the program below, run it in the background, and
C monitor the output file (as fast as you can) using "cat out" several times
C (until program completion, 15 secs).
C If any Decstation user out there knowns what could be wrong, I would appreciate
C hearing about it.

      program tflush
c
c---- Tests routine "flush"
c
      iw = 10
      open (unit=iw,file='out')
c
      do 10 i = 1,5
        write(iw,*) i
        call flush(iw)
        call sleep(3)
 10   continue
c
      stop
      end

C Roque Oliveira
C oliveria@caen.engin.umich.edu

ralph@uhheph.phys.hawaii.edu (Ralph Becker-Szendy) (05/26/91)

In article <_Q1+34+@engin.umich.edu> oliveria@engin.umich.edu (ROQUE DONIZETE 
DE OLIVEIRA) writes (about the FORTRAB flush system routine):
>C Apparently the FLUSH routine doesn't work on the dec3100 (ultrix 3.1)
>C and dec5000 (ultrix 4.1). 

Yes, it doesn't. I noticed that, within 1/2 day of starting to use Ultrix. You
get the feeling that the guys at DEC never test their software if a brandnew
user can find bugs within a few hours. It by the way neither works on stdout
(unit 6), and not when called with parameter "0" to flush all streams.

>                            It did work on a Sun Sparcstation and Apollo (you
>C don't even need to flush on the apollos).  .... rest deleted
Yes, it indeed DOES work on Suns. I guess it won't work on IBM AIX though. 
Right now I have the feeling NOTHING works in AIX FORTRAN (which isn't called
f77 but xlf instead); there isn't even a dtime routine :-) I just wasted a day
trying to port "pretty clean" f77 code to AIX, and didn't get anywhere. Boy,
IBM is weird. I guess I really don't need that much CPU power :-) :-) :-)

>C Roque Oliveira
>C oliveria@caen.engin.umich.edu
-- 
Ralph Becker-Szendy                          UHHEPG=24742::RALPH (HEPNet,SPAN)
University of Hawaii                              RALPH@UHHEPG.PHYS.HAWAII.EDU
High Energy Physics Group                                  RALPH@UHHEPG.BITNET
Watanabe Hall #203, 2505 Correa Road, Honolulu, HI 96822         (808)956-2931

dwip@milton.u.washington.edu (Dave Pierce) (05/29/91)

ralph@uhheph.phys.hawaii.edu (Ralph Becker-Szendy) writes:

>In article <_Q1+34+@engin.umich.edu> oliveria@engin.umich.edu (ROQUE DONIZETE 
>DE OLIVEIRA) writes (about the FORTRAB flush system routine):
>>C Apparently the FLUSH routine doesn't work on the dec3100 (ultrix 3.1)
>>C and dec5000 (ultrix 4.1). 

>Yes, it doesn't. I noticed that, within 1/2 day... [stuff deleted]

Although the fortran routine doesn't work, the C routine does.  I use the
following for flushing fortran unit 6 (standard output).

/* program myflush.c */
#include <stdio.h>
#include <stdlib.h>

void myflush_()
{
	fflush( stdout );
	return;
}

compile the c program:  cc -c -o myflush.o myflush.c

In your fortran program, just use "call myflush()".

When you compile the fortran program, link in myflush.o: f77 myflush.o prog.f

Also note that this technique works for the 'random' function, if you
have problems getting that to work under fortran (I certainly did!).

>>C Roque Oliveira
>>C oliveria@caen.engin.umich.edu
>-- 
>Ralph Becker-Szendy                          UHHEPG=24742::RALPH (HEPNet,SPAN)
>University of Hawaii                              RALPH@UHHEPG.PHYS.HAWAII.EDU
---------------------------------------------------------------------------
D. Pierce
University of Washington
dwip@u.washington.edu

peterson@fman.enet.dec.com (Bob Peterson) (05/29/91)

In article <_Q1+34+@engin.umich.edu> oliveria@engin.umich.edu (ROQUE DONIZETE 
DE OLIVEIRA) writes (about the FORTRAB flush system routine):
>C Apparently the FLUSH routine doesn't work on the dec3100 (ultrix 3.1)
>C and dec5000 (ultrix 4.1). 


We tried it with DEC Fortran (RISC f77 V3.0) and it worked fine.  

BTW: flush is almost a NOP for DEC Fortran since we don't do buffered
output.

FYI: The FORTRAN for RISC (RISC f77 V2.0) flush called fflush(3s), DF
calls fsynch(2) and flushes the read ahead buffer.  If/when we do
buffered writes we'll have to flush that too.

If you're using something before V3 it isn't called DEC Fortran but the
command is still f77.  As far as we can tell flush(3f) works with DEC
Fortran.  Of course, you can't mix in I/O units from objects compiled
by pre-V3 f77.

\bob
 DEC Fortran

pmontgom@luna.math.ucla.edu (Peter Montgomery) (05/30/91)

C		Compile this program with f77 under ULTRIX V4.0.  
C	Then try ``a.out | cat''.  The program requires input; type a 0.
C	All outputs will appear on your screen at once, as the
C	program terminates.  Try ``a.out | cat'' again, this time entering
C	a 1 for input.  The outputs will appear more quickly.

C		Also, CarriageControl = 'fortran' has its price.  
C	Every format statement should output a blank initially.
C	If we redirect output (i.e., a.out > xxx) and later look 
C	at output with the vi editor, 
C	then every line ends with an unwanted control M.  

C		In a larger program which has other output files 
C	(on which I use an OPEN statement but no 
C	CarriageControl = 'fortran'), the latest line is always missing
C	after I do a flush.  I have been unable to get a small test case.

	program test
	implicit none
	integer iflag, OUTFIL, i, j
	parameter (OUTFIL=6)
	read *, iflag
	if (iflag.ne.0) then
	    open(OUTFIL, CarriageControl = 'Fortran')
	    write(OUTFIL, '('' Using Fortran carriage controls '')')
	else
	    write(OUTFIL, '('' No open statement used '')')
	end if	
	do i = 1, 3
	    call flush(OUTFIL)
	    call sleep(2)
	    write(OUTFIL, '('' Line '', i3, '' of pass '',  i3)')
     *			(j, i, j = 1, 3)
	end do
	end
--
        Peter L. Montgomery 
        pmontgom@MATH.UCLA.EDU 
        Department of Mathematics, UCLA, Los Angeles, CA 90024-1555
If I spent as much time on my dissertation as I do reading news, I'd graduate.