Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: Louis Krupp <lkrupp_nospam@xxxxxxxxxxxxxxxx>
- Date: Mon, 06 Apr 2009 12:19:04 -0600
monir wrote:
On Apr 4, 7:16 pm, Louis Krupp <lkrupp_nos...@xxxxxxxxxxxxxxxx> wrote:monir wrote:
As far as I can tell, you have two choices:
1. Do what I suggested earlier. It might take a while to write the
code to pass all those arrays and their working dimensions, but at the
end of the day, it's faster than trying variations on the theme and
hoping that something will work.
2. Learn about Fortran 95 dynamic allocation and modules and so on.
This will pay off in the long run. Others here will be able to answer
most of your questions better than I.
If you have questions about your code, strip it down to a small example
of what fails and post it. We're nerds. We read code, not English prose.
Good luck.
Louis- Hide quoted text -
- Show quoted text -
Louis;
1) Richard Maine clearly and convincingly advised: "If you are trying
to get dynamic sizing in f77, you are just wasting your time."
He appears to have a very valid point!!
2) As per your suggestion, here's a non-working example.
It produces the compiler error:
"Error: ARRAY BOUND at (nPlns) MUST BE CONSTANT"
with reference to 1st arg *nPlns* in the 3rd dim statement in sub
PRSCAV8f:
... Dimension xbys1(nPlns,nRdim,nTHdim), rbys1(nPlns,nRdim,nTHdim).
PROGRAM MainPRSCAV8f
Parameter (maxPln=25, maxR=35, maxTH=45)
Integer maxPln, maxR, maxTH
Integer nP, nR, nTH
!--------------
Dimension xbys(maxPln,maxR,maxTH), rbys(maxPln,maxR,maxTH)
Dimension theta(maxPln,maxR,maxTH)
!--------------
nP = ... calculated integer numerical constant
nR = ... calculated integer numerical constant
nTH = ...calculated integer numerical constant
Call PRSCAV8f (xbys,rbys,theta, nP, nR, nTH)
End
C ***********************************************************
Subroutine PRSCAV8f (xbys,rbys,theta, nPlns,nRdim,nTHdim)
C ***********************************************************
Integer nPlns,nRdim,nTHdim
Dimension xbys(nPlns,nRdim,nTHdim), rbys(nPlns,nRdim,nTHdim)
Dimension theta(nPlns,nRdim,nTHdim)
!----------need to declare different arrays with the same size
Dimension xbys1(nPlns,nRdim,nTHdim), rbys1(nPlns,nRdim,nTHdim) !
problem
Dimension theta1(nPlns,nRdim,nTHdim)
!--------------
COMMON /ABSCISAE/xbys1,rbys1,theta1
!--------------
nPdum = nPlans
nRdum = nRdim
nTdum = nTHdim
!--------------
CALL ReadInp (nPdum, nRdum, nTdum)
CALL VelDeriv (nPdum, nRdum, nTdum)
!--------------
Return
End
Please modify the above as you see fit and let me try it one more
time.
Thank you kindly for your help.
Monir
You can only dimension arrays passed as arguments with nPlns, etc. You can't use variables like nPlns to dimension local arrays or arrays in COMMON.
Declare *all* of your arrays in the main program with maximum (maximal?) dimensions, compute the working dimensions, and pass arrays and working dimensions as needed. Your original problem was that you were populating an array declared with maximum dimensions and then referring to elements in a subroutine where the array was declared with different, working dimensions. Don't do that.
I know you don't want to pass arrays everywhere. I know you'd rather put them in COMMON. It doesn't matter what you want -- or what I want. If it doesn't work, it doesn't work.
You could always join the 21st century and follow Ron Shepard's suggestion, but you'll have to follow it carefully. Once you have something that works, you can try to change it if you think you can make the code more elegant.
Louis
.
- Follow-Ups:
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: James Van Buskirk
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- References:
- Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: monir
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: dpb
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: monir
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: ken . fairfield
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: monir
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: Louis Krupp
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: monir
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: Louis Krupp
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: glen herrmannsfeldt
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: Richard Maine
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: monir
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: Louis Krupp
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: Louis Krupp
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: monir
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: Louis Krupp
- Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- From: monir
- Program Fails When Parameter Fixed Constants are Changed (F77) ??
- Prev by Date: Re: Error writing on unit 22
- Next by Date: Re: Error writing on unit 22
- Previous by thread: Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- Next by thread: Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
- Index(es):
Relevant Pages
|