I have been trying to convert some f77 code to f90, but have encountered
an unexpected problem. The program writes stuff to the screen, assumed to
be a VT100 or later, using escape sequences such as
WRITE(*,'(2A,$)') CHAR(27), '[12;34H'
(which in this case sets the cursor to line 12 column 34, ready for some
subsequent output).
The "$" format descriptor is, of course, non-standard but it is supported
very widely by f77 compilers as a way of suppressing the end-of-record
characters (CR,LF, or whatever). This is needed here, otherwise the
subsequent output appears on the wrong line of the screen.
The "$" descriptor is, in fact, an extension also supported by most of the
f90 compilers to which I have access, but not by those from NAG, and even
their -dusty switch does not help. I suppose one cannot complain too much
about this, but I cannot find a portable substitute.
The obvious thing is to try something like:
write(*, '(2A)', advance="no")
but on most compiler/operating system combinations that I have tried, this
does not do what is required: the output is generally not flushed, merely
appended to an internal buffer, ready for some later record which uses
normal advancing I/O. So nothing appears on the screen until much too
late.
Some systems have a CALL FLUSH, but this isn't standard either. Using NAG
f90/f95 I find that ADVANCE="NO" does work (presumably flushing after each
write), but since on most other systems this doesn't work, it isn't a
portable solution.
My conclusion is that non-advancing output is not a substitute for the
"$" format descriptor, and that Fortran ought to have incorporated it. I
suppose it is now too late to get the dollar descriptor in F200x ?
By the way, it's obviously a good thing that Fortran2000 is no longer the
expected name, as it makes it sound like a Microsoft product. :-)
--
Clive Page, Internet: [log in to unmask]
Dept of Physics & Astronomy,
University of Leicester, Phone +44 116 252 3551
Leicester, LE1 7RH, U.K. Fax +44 116 252 3311
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|