newbie: passing parameters to subroutine
From: Louis Luangkesorn (lluang_at_verizon.net)
Date: 09/26/04
- Next message: Gordo: "Re: newbie: passing parameters to subroutine"
- Previous message: GioX®: "accuracy and precision computing"
- Next in thread: Gordo: "Re: newbie: passing parameters to subroutine"
- Reply: Gordo: "Re: newbie: passing parameters to subroutine"
- Maybe reply: Louis Luangkesorn: "Re: newbie: passing parameters to subroutine"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Sep 2004 06:16:52 -0700
Ok. I realize that this is something that must be obvious to anyone
who has programed in Fortran for any length of time, but I don't have
any such person around right now.
I am trying to use an array to hold the results of a subroutine. When
I do so, the value I get back in the calling function is not the same
as the value that the variable has at the end of the subroutine. Is
there anything obvious (or not so obvious) that I'm doing wrong?
Thank you for your help. I've spent days tracking this down.
The calling subroutine(properly indented for G77):
subroutine pipe( . . .)
real*8::pc(0:368)
DATA pc /369 * 0.0d0/
<snip>
PRINT *, 'MMCIN:cr, rhor:', cr, rhor
CALL MMC(cr,rhor,pc,sump,maxr)
PRINT *, 'MMCOUT:cr, rhor, pc(0), sump, maxr :', cr, rhor,
! pc(0),sump , maxr
<snip>
The subroutine being called:
subroutine MMC(c,rho,pc,sump,maxc)
implicit none
real*8::c,rho,pc(0:368),r,sump
<snip>
print *, "MMC: p0, sump, maxc", pc(0),sump, maxc
end subroutine MMC
The output:
MMCIN:cr, rhor: 1. 0.724261284
MMC: p0, sump, maxc 0.99612261 1. 2
MMCOUT:cr, rhor, pc(0), sump, maxr : 1. 0.724261284 -8.72913609E+015
1. 2
Note that the value of p0 = pc(0) changed from the end of subroutine
to when it returned. I have also used 1000 in the place of 368 in
both locations (I happen to know that the array will not go beyond
368)
Thanks in advance.
Louis Luangkesorn
- Next message: Gordo: "Re: newbie: passing parameters to subroutine"
- Previous message: GioX®: "accuracy and precision computing"
- Next in thread: Gordo: "Re: newbie: passing parameters to subroutine"
- Reply: Gordo: "Re: newbie: passing parameters to subroutine"
- Maybe reply: Louis Luangkesorn: "Re: newbie: passing parameters to subroutine"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|