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



On Apr 2, 7:07 pm, nos...@xxxxxxxxxxxxx (Richard Maine) wrote:
glen herrmannsfeldt <g...@xxxxxxxxxxxxxxxx> wrote:
Louis Krupp <lkrupp_nos...@xxxxxxxxxxxxxxxx> wrote:

Hello;

Thank you all for your helpful replies.

1) Ron Shepard's suggestion is a good one:
"The easiest way to make sure all of your dimensions match up is to
allocate the array at the beginning of the program to the correct
size, put your subroutines in a module (so they will get an explicit
interface), and declare all of the dummy arrays as assumed shape.
real :: dummy(:,:,:) "
Unfortunately, I know very little about F95 modules, dynamic arrays,
arrays operations, etc.

2) Louis Krupp's suggestion (which sounds the easiest to implement!) :
"You could declare VxGrid dimensioned (maxR, maxTH) in another
subroutine and then call DCpZeros passing VxGrid, nRdim, and nTHdim.
Then DCpZeros can dimension VxGrid (nRdim, nTHdim). As long as the
only code that touches VxGrid sees it dimensioned (nRdim, nTHdim), you
should be OK."
I have given it a try, and here's what I did.
(PS. I'm not concerned or worried about the array bounds exceeded!
There're sufficient built-in red flags in the program.)

3) First, with F77 code and g95 compiler, one definitely cannot use
common block variables to dimension a local array as some of you have
already advised.
Compilation Error:
"Variables '.....' cannot appear in a specification expression in a
PROGRAM"
Richard Maine and glen herrmannsfeldt correctly predicted that in
their replis.

4) Basically, forget about the maximum anticipated values maxR, maxTH
and maxPln. Dimension the arrays based on the computed nRdim, nTdim
and nPlanes, by including them as arguments in the call to the various
routines. Hence, don't need the Common block /DIM/ (which wouldn't
have worked anyway based on Item 3 above).

5) Algorithmically, the entire "earlier" program is treated now as a
subroutine called by a "new" main program.
(It's quite confusing trying to describe the changes. They will
become pretty obvious as you'll see. Here's the latest relevant parts
of the code.)

C ****************************************************************
PROGRAM MainPRSCAV8
C ****************************************************************
!....myCode1.........
nT = !integer numerical value....
nR = !integer numerical value....
nP = !integer numerical value....
Call PRSCAV8e (nP, nR, nT)
End

C
****************************************************************
Subroutine PRSCAV8e (nPlanes, nRdim, nTdim)
C
****************************************************************
Dimension xbys (nPlanes,nRdim,nTdim), rbys(nPlanes,nRdim,nTdim) !
Compiler error
!...myCode2..................
Call DCpZeros (nRdim, nTdim, nPlanes)
!...myCode3..................
Return
End

C
****************************************************************
SUBROUTINE DCpZeros (nP,nR,nT)
C
****************************************************************
C This subroutine determines the abscissas of a potential minimum of
Cp
C on a given R-TH (T*=const) plane.
...................................
dimension Rgrid(nR), Tgrid(nT)
dimension VxGrid(nR,nT)
! ...myCode4.................
Call Polin2 (Rgrid,Tgrid,VxGrid,nR,nT,Rp,THp,VxCentre,accx)
! ...myCode5.................
Return
End

6) The following Compiler Error message is displayed (reference to the
1st arg in the 1st dim statement in sub PRSCAV8e):
"Error: Array bound at (nPlanes) must be constant"
What ?? It's a constant equals 10

I'm trying to fix this latest problem (or even make sense of it!) with
no luck!

Any suggestion ??

Thank you.
Monir
.



Relevant Pages

  • Re: Loading matrix from file? [fortran 77]
    ... > Is there any way to load matrix (array) from file, ... You need to allocate enough space for the largest possible matrix at ... You had to know at least the first dimension of the matrix before you ... subroutine sub ...
    (comp.lang.fortran)
  • Re: dimension question
    ... dimension a ... If the subroutine DIMENSION statement is athe array ...
    (comp.lang.fortran)
  • Re: Neq Max Limit
    ... you are passing incorrect arguments to a subroutine. ... One may be the array size and another an array. ... dimension y,dy ... PRINT *,i at the top of the outer loop may tell you if the program is ...
    (comp.lang.fortran)
  • Re: g95 wish list
    ... (big snip on dimension of (1) ... > have a bounds check which fails if the subroutine references X. ... allowing the full dimension information to be ... > the possibility of a check as to whether you passed an array of size 2 ...
    (comp.lang.fortran)
  • Re: Error on UBound with Dynamic Array
    ... ReDim Preserve arrSplit+ 1) ... is that arrSplit has not yet been dimmed as having any dimension. ... need to use a dynamic array and may be checking the boundries, ... Public Function Split(csvString As String) As Variant ...
    (microsoft.public.access.modulesdaovba)