lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) (07/12/89)
Consider the following program: program main dimension a(100) do 10 i = 1, 100 a(i) = 2.0 10 continue write(6,*) 'The sum is ', sum(a) write(6,*) 'The sum is ', sum(a(51)) end function sum(x) dimension x(50) temp = 0.0 do 10 i = 1, 50 temp = temp + x(i) 10 continue sum = temp end This produces: The sum is 100.0 The sum is 100.0 on each of an IBM 3090 using fortvs under both CMS and fvs under AIX, Sun 386i using SunOS f77 Version 4.0.1, and a Cray X-MP/48 using cft77 under UNICOS 4.0.8. My understanding was that since a(51) is a scalar it would be passed by reference and this code wouldn't work. Apparently though, a(51) is being resolve to the address of a(51). to see that it does work though. I used to think that you needed to equivalence a(51) to another array to do this kind of thing. What is the official F77 word on this type of construct? Mike Lijewski (H)607/277-7623 (W)607/255-0539 (desk)607/255-2960 Cornell National Supercomputer Facility ARPA: mjlx@cornellf.tn.cornell.edu BITNET: mjlx@cornellf.bitnet SMAIL: 102 E. Court St. Ithaca, NY 14850 -- Mike Lijewski (H)607/277-7623 (W)607/255-0539 (desk)607/255-2960 Cornell National Supercomputer Facility ARPA: mjlx@cornellf.tn.cornell.edu BITNET: mjlx@cornellf.bitnet SMAIL: 102 E. Court St. Ithaca, NY 14850
lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) (07/13/89)
In article <8378@batcomputer.tn.cornell.edu> lijewski@batcomputer.tn.cornell.edu (Mike Lijewski) writes:
Well, looks like I need to retract this question. Seems I've been
C'ing it for too long. Arguments are always passed by value in
FORTRAN. Sorry for the wasted bandwidth.
--
Mike Lijewski (H)607/277-7623 (W)607/255-0539 (desk)607/255-2960
Cornell National Supercomputer Facility
ARPA: mjlx@cornellf.tn.cornell.edu BITNET: mjlx@cornellf.bitnet
SMAIL: 102 E. Court St. Ithaca, NY 14850