Re: Console I/O Help with g77

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I greatly appreciated Tom Crane's very helpful comments and suggestions.  I
am getting closer now, but not quite there yet.  Please see below.  I would
continue to appreciate a direct reply, since I am not subscribed to this
list.

s/KAM


Tom Crane <TPCnospam@xxxxxxxxxxxxxxxxxxx> wrote:

> > 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.

Hmm, I tried that and also:
write(6,'(a1)') '\f'

Both produced a graphic character in the console output rather than clearing
the screen or issuing a form feed as desired.  The results that I would
really like are equivalent to the MSDOS/Windows CLS command.  Any further
suggestions on this problem appreciated.

> > 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.
>
>

I definitely appreciate those tips and the code.  However, I think the
behavior I am looking for may be somewhat different from what your code
does.  In the program that is being converted, the desired behavior is as
follows:  If the user hits Enter without entering anything, then the
previous value of the variable that was being entered (PCS in my sample code
above) needs to be maintained, and the user should *not* have to hit another
key or enter another value.  On the other hand, if the user enters an
erroneous value (e.g. an invalid alpha character for a numeric variable),
then the READ statement should be executed again so that the user can enter
a correct value.  Part of the problem that I am seeing under Win2K is that
the END label branch is apparantly *never* taken.  The ERR label branch
seems to be taken on null input instead.  Unless I am missing something, I
don't think that your reset_unit code addresses that problem.  Perhaps this
behavior is different on other platforms...?

> >
> > 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.

Got it, thanks.  That's exactly the kind of tip that I was looking for.  Not
the answer that I hoped for, but I can address the problem now that I know
for sure what to expect.

>
> Hope this is some help...

Absolutely.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux