FORTRAN like formatting

beliavsky at aol.com beliavsky at aol.com
Sat Jul 9 16:43:53 CEST 2005


Dennis Lee Bieber wrote:

> > On 7/8/05, Einstein, Daniel R <daniel.einstein at pnl.gov> wrote:
> > >
> > >
> > > Hi,
> > >
> > > Sorry for this, but I need to write ASCII from my Python to be read by
> > > FORTRAN and the formatting is very important. Is there any way of doing
> > > anything like:
> > >
> > > write(*,'(3(" ",1pe20.12))') (variable)
> > >
>
> 	Which Fortran compiler? I know VMS Fortran was very friendly,
> when specifying "blanks not significant" or something like that... To
> read three floating numbers (regardless of format) merely required
> something like:
>
> 	read(*, '(bn,3f)') a, b, c
>
> (or 'bs' for blanks significant -- I forget which one enabled free
> format input processing)

Fortran 77 and later versions have "list-directed" I/O, so the OP could
simply write

read (inunit,*) a,b,c

if the numbers in his input file are separated by spaces or commas. An
online reference is
http://docs.hp.com/cgi-bin/doc3k/B3150190022.12120/9 .




More information about the Python-list mailing list