🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2458

Re: Fortran vs. C for numerical work

#2458
From: Bruce.Hoult
Date: Sun, 09 Dec 1990 04:06
44 lines
2309 bytes
In article <77124@iuvax.cs.indiana.edu> templon@copper.ucs.indiana.edu (jeffrey templon) writes:

>the problem i think most fortran-scientific-types have with C is that it
>is 'economic in expression' to misquote k&r.  constructs like
>
>	b = sqrt( a < 0 ? -a : a)
> 
>look very strange to a fortran programmer, compared to
>
>	IF ( a .lt. 0.0) THEN
>	   b = sqrt(-1.0*a)
>	ELSE
>	   b = sqrt(a)
>	ENDIF

That's a turn-around!  I forget the exact syntax (haven't used FORTRAN for a
decade), but can't you do this in FORTRAN?

	IF(a) 1111,1112,1113
1111	b = sqrt(-1.0*a)
	GO TO 1114
1112	b = 0
	GO TO 1114
1113	b = sqrt(a)
1114	CONTINUE


>	another reason (vms-specific) is that vms C uses the CALLS instruction
>to jump to a subroutine, as compared to fortran using CALLG.  CALLS needs
>to build the argument list dynamically, at run time, for each subroutine
>call, while CALLG relies on the compiler having built the arglist and
>providing the its address.  so when fortran calls a subroutine, the current
>context is saved, the pointer to the argument list structure is pushed on
>to the stack, and bang! you are in the subroutine.  for CALLS, each argument
>has to be pushed onto the stack, and this takes enough time to be of concern
>if you have some program

In C or Pascal you could allocate a structure as a global (static) variable,
assign your parameters into it and just pass a pointer to the structure to
the called routine.  The compiler might even be smart enough to use CALLG,
but in any case the CALLS will be much faster pushing only one parameter.
-- 
Bruce.Hoult@bbs.actrix.gen.nz   Twisted pair: +64 4 772 116
BIX: brucehoult                 Last Resort:  PO Box 4145 Wellington, NZ
Technical Details
Message-ID: <1990Dec9.040635.12696@actrix.gen.nz>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!comp.vuw.ac.nz!actrix!Bruce.Hoult
References: <18016@hydra.gatech.EDU> <16671@csli.Stanford.EDU> <77124@iuvax.cs.indiana.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!comp.vuw.ac.nz!actrix!Bruce.Hoult
From: Bruce.Hoult@bbs.actrix.gen.nz
Newsgroups: comp.lang.misc
Subject: Re: Fortran vs. C for numerical work
Message-ID: <1990Dec9.040635.12696@actrix.gen.nz>
Date: 9 Dec 90 04:06:35 GMT
References: <18016@hydra.gatech.EDU> <16671@csli.Stanford.EDU> <77124@iuvax.cs.indiana.edu>
Sender: Bruce.Hoult@actrix.gen.nz (Bruce Hoult)
Organization: Actrix Information Exchange, Wellington, New Zealand
Lines: 44
Comment-To: templon@copper.ucs.indiana.edu