🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.f77
Article #356

Re: Query: Sharing f77 COMMONs with C Externals

#356
From: Donn Seeley
Date: Wed, 07 May 1986 07:55
53 lines
1742 bytes
At least on the VAX under 4.3 BSD, f77 COMMON blocks are represented in
exactly the same way as C externals.  The following two files, one
Fortran and one C, demonstrate the correspondence:

------------------------------------------------------------------------
	integer a
	real b(4)
	double complex c
	character*4 d
	integer*2 e(2)
	complex f
	common /z/ a, b, c, d, e, f

	a = 1
	b(1) = 2.
	c = (3., 4.)
	d = 'a'
	e(2) = 5
	f = (6., 7.)

	call croutine
	stop
	end
------------------------------------------------------------------------
struct complex { float r, i; };
struct double_complex { double dr, di; };
struct z {
	int a;
	float b[4];
	struct double_complex c;
	char d[4];
	short e[2];
	struct complex f;
} z_;

void
croutine_()
{
	printf("%d %f %f %.4s %hd %f\n",
		z_.a,
		z_.b[0],
		z_.c.di,
		z_.d,
		z_.e[1],
		z_.f.r);
}
------------------------------------------------------------------------

Notice the difference in the origin for arrays...  A properly aligned
f77 COMMON block should produce a properly aligned C structure.

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
Technical Details
Message-ID: <3777@utah-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!utah-cs!donn
References: <469@cubsvax.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!linus!philabs!cmcl2!seismo!utah-cs!donn
From: donn@utah-cs.UUCP (Donn Seeley)
Newsgroups: net.lang.f77
Subject: Re: Query:  Sharing f77 COMMONs with C Externals
Message-ID: <3777@utah-cs.UUCP>
Date: Wed, 7-May-86 03:55:31 EDT
Article-I.D.: utah-cs.3777
Posted: Wed May  7 03:55:31 1986
Date-Received: Sat, 10-May-86 12:26:15 EDT
References: <469@cubsvax.UUCP>
Organization: University of Utah CS Dept
Lines: 53
Summary: an example