Register to reply

FORTRAN WRITE question

by Choragos
Tags: fortran, output, screen, write
Share this thread:
Choragos
#1
May13-09, 02:10 PM
P: 20
Hello. In producing screen output from Fortran, I use the write statement. Back in the day, there was a way to use the FORMAT statement to allow you to replace text on the screen with different text. For example, counting up percentage complete of a process or something like that.

Well, Fortran 90 put the nix on that and now I don't know how to do it. For all of us who don't want to let go of our DOS prompts (or who sit in Linux command lines), is there a way to accomplish this task?

Thanks
Andy
Phys.Org News Partner Science news on Phys.org
Scientists develop 'electronic nose' for rapid detection of C. diff infection
Why plants in the office make us more productive
Tesla Motors dealing as states play factory poker
minger
#2
May13-09, 02:23 PM
Sci Advisor
P: 1,498
I've never heard of this. What was the procedure to do it in previous versions?
Choragos
#3
May13-09, 02:41 PM
P: 20
It was buried in the FORMAT statement. I believe this is how it was done (I had to change the code and I believe this was the original version):

15 format('+Processing decay number ',I6)

I believe it's that '+' sitting there. If that doesn't make any sense I'll go on the hunt and make sure this is the original version.

mathmate
#4
May13-09, 02:43 PM
P: 366
FORTRAN WRITE question

I believe it is called the non-advancing I/O in Fortran 90.
You would use this to prompt for input on the same line after displaying a text, or as you said, to give the percentage completion.
It would typically take the form:
WRITE (*,*, ADVANCE='NO') ....
Try this link or google for other articles:
http://www.pcc.qub.ac.uk/tec/courses...tml#HEADING122
Choragos
#5
May13-09, 02:47 PM
P: 20
If I'm not mistaken, that only prevents advancement to the next line; it does not overwrite what is already there. I'll check it though and post results. Thanks!
mathmate
#6
May13-09, 02:48 PM
P: 366
Sorry I didn't see you post before sending out mine.
The '+' character was used for printer control in the good old days where we have a $35000 line printer but no screen. The printer control will simply be displayed on the screen but won't halt the advance of the cursor. See post #4 for details.
mathmate
#7
May13-09, 02:53 PM
P: 366
To move the cursor horizontally, you could use the T-descriptor (tab).
The T-descriptor goes to the absolute column, while the TL and TR moves the cursor to the left or the right (relative movement) respectively.
Try:
http://docs.hp.com/en/B3908-90002/ch09s03.html#d0e22660
Choragos
#8
May13-09, 03:02 PM
P: 20
That looks like it will do it. Thank you.
minger
#9
May13-09, 03:59 PM
Sci Advisor
P: 1,498
If you got it to work, then let me know how you did. I wrote a quick sample program
PROGRAM test

do i=1,10
 WRITE(6,999,ADVANCE='NO') i
END DO

999 FORMAT(TL2I2.2)

END PROGRAM
Which outputs
01020304050607080910:~>
TRn and Tn both seem to skip the wrong way. I can't figure out how to overwrite.

p.s. Good fortran reference though
Choragos
#10
May13-09, 04:17 PM
P: 20
Indeed, it isn't overwriting for me either. I'm using

10 FORMAT(TL2I2)

and

10 FORMAT(T1I2).

The formatting is working, except that T will not move the cursor back over what has been written. It will advance, but not go back.

Edit: by the way, I'm using both Intel and gfortran compilers.
mathmate
#11
May13-09, 04:51 PM
P: 366
Indeed, it does not work between writes. It works only within the buffer, i.e. before the write statement is executed. So it doesn't do what you need to do.
It looks to me that you'll need some system calls, which unfortunately will be platform dependent. I know it is possible with Borland C which has a set of routines (conio.h) for that purpose. You may want to check out the versions of Fortran you're using to see if some equivalent library exists.
Another possibility is if your have called c-libraries before, you may want to take advantage of that.
Sorry folks, good try, but do post back if you find something. This will benefit everyone.


Register to reply

Related Discussions
Fortran write (or print). How to controll new line or not Programming & Computer Science 7
Commenting out a WRITE statement in FORTRAN 95 causes changes in non-related outputs Programming & Computer Science 3
Accessing Fortran Modules within a Fortran library from Fortran Programming & Computer Science 0
Help me to write fortran code Programming & Computer Science 1
Help! need to write fortran program Programming & Computer Science 8