Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??



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


.



Relevant Pages

  • Re: Program Fails When Parameter Fixed Constants are Changed (F77) ??
    ... As per your suggestion, ... Dimension xbys, rbys ... calculated integer numerical constant ... CALL ReadInp (nPdum, nRdum, nTdum) ...
    (comp.lang.fortran)
  • Re: gfortran & adjustable array: most values remain zero
    ... Indeed I expected that adjustable arrays would work in 2D the same ... adjustable arrays of more than one dimension should be generally avoided ... the actual and dummy arrays don't ...
    (comp.lang.fortran)
  • Re: Pros and cons of assumed-shape arrays
    ... dimension relations. ... In most subroutines with several arrays as ... arguments almost all of the arrays have similar shapes. ... is loop invariant and will be done once in the loop preamble ...
    (comp.lang.fortran)
  • Two dimensional arrays "C question"
    ... My question has to do with two dimensional arrays. ... int main ... So we see that the compiler can automatically calculate the first dimension. ...
    (microsoft.public.vc.language)
  • Re: CheckedListbox
    ... Dim MyInt(,) - Verschlechterung? ... Das Problem ist ich kann immer nur die letzte Dimension verändern, ... Man kann überhaupt keine Dimension eines Arrays verändern. ... Falls du auf Redim Preserve anspielst: ...
    (microsoft.public.de.german.entwickler.dotnet.vb)