[net.lang.f77] Namelist Interpreter

dpw@bonnie.UUCP (David Williams) (10/14/85)

Help!  Does anyone have routines that mimic in any way
the namelist feature of VMS and IBM Fortran?  I have just
obtained a large program that uses the feature extensively,
and I am constrained to use f77 under System V Release 2.

Thanks,

David Williams
AT&T Bell Laboratories
Morristown, NJ
201-898-1452
ihnp4!bonnie!dpw

dpw@bonnie.UUCP (David Williams) (10/15/85)

> 
> Help!  Does anyone have routines that mimic in any way
> the namelist feature of VMS and IBM Fortran?  I have just
> obtained a large program that uses the feature extensively,
> and I am constrained to use f77 under System V Release 2.
> 
> Thanks,
> 
> David  Williams

	According to the compiler folks at AIS in Summit
	the V.2 f77 compiler includes stuff to support 
	namelist, but it requires an upgrade of the operating
	system (!???) to function.

AT&T Bell Laboratories
Morristown, NJ
201-898-1452
ihnp4!bonnie!dpw

donn@utah-cs.UUCP (Donn Seeley) (10/17/85)

	According to the compiler folks at AIS in Summit the V.2 f77
	compiler includes stuff to support namelist, but it requires an
	upgrade of the operating system (!???) to function.

I doubt that the AIS (= ATTIS?) folks had this in mind, but if you
upgrade your machine to 4.3 BSD you will find that the new f77 supports
NAMELIST operations.  There's also a convenient '-r8' flag that forces
REAL values to be REAL*8 (DOUBLE PRECISION).

Aren't standards wonderful?

Donn Seeley    University of Utah CS Dept    donn@utah-cs.arpa
40 46' 6"N 111 50' 34"W    (801) 581-5668    decvax!utah-cs!donn

woods@hao.UUCP (Greg Woods) (10/18/85)

> Help!  Does anyone have routines that mimic in any way
> the namelist feature of VMS and IBM Fortran?

  We have implemented a limited NAMELIST capability here. The man page 
follows. If anyone wants it, we can get it to you. I'm not sure how big
it is; if there's interest I'll check. If small enough I could email it
to interested parties, otherwise if you sent me a tape I would gladly
send you the software. It is written in a mixture of FORTRAN and C,
which means your system must be able to link routines from both
languages together.
  Unfortunately, ours is implemented as a subroutine library, which means
syntax changes in your FORTRAN program will be required in order to use it.
(Any other method would require compiler hacking anyway, I suppose).

--Greg
--
{ucbvax!hplabs | allegra!nbires | decvax!noao | harpo!seismo | ihnp4!noao}
       		        !hao!woods

CSNET: woods@NCAR  ARPA: woods%ncar@CSNET-RELAY
-----------------------------------------------------------------------------
.TH READNAME PLIB acd
.SH NAME
readname \- simulate namelist read
.SH SYNOPSIS
.B integer function readname(iu,namelist,n,names,sizes,types,a\d1\u,a\d2\u...a\dn\u)
.br
.B integer iu,n,sizes(n),types(n)
.br
.B character*8 namelist,names(n)
.SH DESCRIPTION
Lines will be read on fortran logical unit
.I iu
(opened previously) and
interpreted as namelist assignments for the variable a\d1\u,a\d2\u,...a\dn\u.
The variable
.I namelist
should be set to the namelist name. 
.I n
is the
total number of variables. For each variable a\di\u, the corresponding
entries names(i),sizes(i) and types(i) give the variable name, its
dimension (1 for a scalar), and its type.  The type is an integer
code:
.sp
.TS
box,center;
c l.
code	type
=
-n	character*n
_
0	logical
_
1	character*8
_
2	integer
_
3	real
_
4	double
.TE
.SH FILES
/usr/local/lib/libplib.a
.SH SEE ALSO
getoken,setvari,setvarc,setvarr,setvard
.SH DIAGNOSTICS
Readname returns 0 on success. -1 indicates a general error and
a positive number indicates a probable error with that variable
number.  Error diagnostics are written to stderr. If a segmentation
fault or other opaque error condition presents itself, check that
n corresponds to the number of variables provided and that the
types for the variables correspond.
.SH BUGS
N is currently limited to a maximum of 50.  Input can have any
number of leading spaces, not just one.  Arrays may be only
singly subscripted (give total length for multiply subscripted
arrays). Only the full variable may be named, not a single
element (eg: a(3)) or a range (a(i,i=2,5) are illegal). Character*N
variables are currently limited to a maxiumum of 32 characters.

dave@inset.UUCP (Dave Lukes) (10/21/85)

In article <584@bonnie.UUCP> dpw@bonnie.UUCP (David Williams) writes:
>	According to the compiler folks at AIS in Summit
>	the V.2 f77 compiler includes stuff to support 
>	namelist, but it requires an upgrade of the operating
>	system (!???) to function.

Well then, how come the following program seems to work perfectly well
(VAX V.2R2):

	program fred
	character*32 c
	namelist /joe/i,c,a
	i=123405
	a=1234.5
	c = 'institute for contemporary arts'
	write(8,joe)
	rewind(8)
	read(8,joe)
	end

upgrade schmupgrage i.e. namelist i/o works quite well, thank you ...

		Dave (``try it out'') Lukes.

guy@sun.uucp (Guy Harris) (10/22/85)

> > Help!  Does anyone have routines that mimic in any way
> > the namelist feature of VMS and IBM Fortran?
> 
>   We have implemented a limited NAMELIST capability here. ...
> Unfortunately, ours is implemented as a subroutine library, which means
> syntax changes in your FORTRAN program will be required in order to use it.
> (Any other method would require compiler hacking anyway, I suppose).

Some compiler hacking, perhaps.  Somebody (Stu Feldman?) stuck items in the
"f77" grammar and I/O statement handling code to support NAMELIST; however,
they never got around to writing (or, at least, releasing) the support
library routines.  The people at AT&T-IS (formerly at the Bell Labs UNIX
System Development Laboratory, formerly at..., formerly at...) and the
people doing the 4.3BSD version of "f77" finally wrote, or at least released
(or will release, presumably, in the cae of 4.3BSD) the needed library
routines.  I don't know how much in the way of fixes to the compiler, or
changes (as opposed to additions) to the "f77" I/O library were needed to
make it work.

	Guy Harris

jerry@ucbopal.BERKELEY.EDU (Jerry Berkman) (10/25/85)

In article <2919@sun.uucp> guy@sun.uucp (Guy Harris) writes:
>> > Help!  Does anyone have routines that mimic in any way
>> > the namelist feature of VMS and IBM Fortran?
>> 
>>   We have implemented a limited NAMELIST capability here. ...
>> Unfortunately, ours is implemented as a subroutine library, which means
>> syntax changes in your FORTRAN program will be required in order to use it.
>> (Any other method would require compiler hacking anyway, I suppose).
>
>Some compiler hacking, perhaps.  Somebody (Stu Feldman?) stuck items in the
>"f77" grammar and I/O statement handling code to support NAMELIST; however,
>they never got around to writing (or, at least, releasing) the support
>library routines.  The people at AT&T-IS (formerly at the Bell Labs UNIX
>System Development Laboratory, formerly at..., formerly at...) and the
>people doing the 4.3BSD version of "f77" finally wrote, or at least released
>(or will release, presumably, in the cae of 4.3BSD) the needed library
>routines.  I don't know how much in the way of fixes to the compiler, or
>changes (as opposed to additions) to the "f77" I/O library were needed to
>make it work.
>
>	Guy Harris

Back in June or July, I got namelist I/O to work with f77 for 4.3 BSD
and added it to the 4.3 BSD version.  I implemented it so that most
VMS, CDC, and IBM programs using namelist I/O will work with no
changes.  Note I said most, not all.  E.g. VMS allows substring
notation in the data; I didn't bother to implement that.

The f77 compiler has had code for namelist for a long time.  It was
disabled a few years ago because there were no library routines to
implement namelist I/O.  A few months ago, I wrote the necessary
routines and added them to the library.  I then enabled the code in the
compiler by adding -DNAMELIST to the makefile.  The code generated had
two minor bugs (not differentiating between 2 and 4 byte logicals and
forgetting to multiply an offset by 4) which I fixed.

I added nmlio.h (49 lines), rsnmle.c (611 lines), and wsnmle.c (92
lines) to the library to implement namelist I/O.  wsnmle.c is very
short because namelist write is implemented by writing the namelist
name and then using the list-directed routines to write the variables
names and values.  rsnmle.c similarly uses the routines for
list-directed reads.  The list-directed routines have been modified as
appropriate so they can be called for list-directed or namelist I/O.

	- Jerry Berkman
	  Computing Services, (415) 642-4804
	  jerry@opal.Berkeley.EDU