This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Console I/O Help with g77
- From: TPCnospam at mklab dot ph dot rhul dot ac dot uk
- To: KMyers at ProcomInc dot net (Kevin Myers)
- Cc: gcc-help at gcc dot gnu dot org, TPCnospam at mklab dot ph dot rhul dot ac dot uk
- Date: Mon, 2 Jan 2006 15:39:07 +0000 (GMT)
- Subject: Re: Console I/O Help with g77
- Reply-to: TPCnospam at mklab dot ph dot rhul dot ac dot uk
>
> Hello,
>
> I am new to g77, and am attempting to convert a program that ran under VS
> Fortran on an IBM mainframe. I have converted most of the program without
> difficulty, but am having some problems related to console I/O. I am using
> g77 under Windows 2000.
>
> The mainframe version of the program to be converted contains a number of
> lines similar to the following:
>
> CALL CMS(IRC,'CLRTERM ')
>
> These calls are used to clear the screen on IBM 3270 style terminals prior
> to subsequent output. Is there an equivalent g77 command that be used to
> clear the contents of the console (e.g. issue a form feed?)?
No. Your CMS call is not part of the language. I'm not familiar with
console I/O under W2k. If a form feed does the trick then something like,
write (6,'(a1)') 12
should work.
>
>
> The mainframe version of the program also contains numerous chunks of code
> similar to the following:
>
> 1315 REWIND 5
> 1411 WRITE(7,1412) PCS
> 1412 FORMAT(' ','Surface casing pressure (psi): ',F6.0)
> READ(5,*,ERR=1411,END=1415) PCS
>
> g77 doesn't seem to allow a REWIND for unit 5 (console input). Without the
> REWIND there doesn't seem to be any way to detect and handle null input
> (which is very important in this program to accept numerous default values).
> Is there some way to do this that I am missing?
I used this trick a lot under DEC VMS which also allows recovery from END=
& ERR= on terminal input and had the same problem when porting to g77.
Here is my solution. At the <label> when the 'READ (5,*,END=<label>)'
condition has been taken I do a 'call reset_unit_5' which clears the
end-of-file condition and allows it to be taken again.
subroutine reset_unit_5
character *20 Name
C--- Simple subroutine for G77 to close and reopen unit 5 when connected
C--- to a tty, to permit reads on unit 5 after an end-of-file condition
C--- eg. <CTRL-D> was encountered.
if (IsaTty(5)) then
name=TtyNam(5)
close (unit=5)
open (unit=5,file=name,status='old')
endif
return
end
You might also like to look at g95. Following a request from me, Andy
Vaught has added this feature to g95 which is an OSS fortran-95 compiler
(www.g95.org). To get the same behaviour as the VMS runtime just define
the shell environment variable G95_IGNORE_ENDFILE.
>
> Finally, a portion of this program is intended to write output to a standard
> text (ASCII) file that can be viewed or printed. The mainframe version of
> the program includes traditional FORTRAN formatting characters for column 1
> of the output file (e.g. '0', '1', etc.). g77 doesn't seem to translate
> these formatting commands into the appropriate ASCII characters for line
> feed, form feed, etc. in the output file. Is there some way to get g77 to
> automatically perform this translation? If not, what is the standard way of
> writing form feeds and such for an ASCII output file under G77?
Reading from g77.info;
] `g77' doesn't support `FORM='PRINT'' or an equivalent to translate
] the traditional `carriage control' characters in column 1 of output to
] use backspaces, carriage returns and the like. However programs exist
] to translate them in output files (or standard output). These are
] typically called either `fpr' or `asa'. You can get a version of `asa'
] from `ftp://sunsite.unc.edu/pub/Linux/devel/lang/fortran' for GNU
] systems which will probably build easily on other systems.
] Alternatively, `fpr' is in BSD distributions in various archive sites.
I've not tried either of these but suggest you check them out.
Hope this is some help...
Regards
Tom Crane
CC: KMyers@ProcomInc.net
--
Tom Crane, Dept. Physics, Royal Holloway, University of London, Egham Hill,
Egham, Surrey, TW20 0EX, England.
Email: T.Crane@rhul.ac.uk
Fax: +44 (0) 1784 472794