Re: question about negative indices in fortran 77

From: Jose Miguel Pasini (jmpeightyfour_at_cornell.nospam.edu)
Date: 12/29/04

  • Next message: Walter Spector: "Re: Using file system API"
    Date: Wed, 29 Dec 2004 14:45:08 -0500
    
    

    On Wed, 29 Dec 2004 12:21:34 -0700
    "James Van Buskirk" <not_valid@comcast.net> wrote:

    > "Jose Miguel Pasini" <jmpeightyfour@cornell.nospam.edu> wrote in
    > message
    > news:20041229105352.48359f8d.jmpeightyfour@cornell.nospam.edu...
    >
    > > Now we arrive at the interesting part. Let's say I have the
    > > following declaration at the beginning of a subroutine:
    >
    > > implicit real*8 (a-h,o-z)
    > > real*8 e(m*n),d(m*n),c(m*n),b(m*n),a(m*n),
    > > & ef(m*n),df(m*n),cf(m*n),bf(m*n),af(m*n),
    > > & x(m*n),y(m*n),r(m*n),up(m*n),aux(m*n)
    >
    > > The way I understand it, an expression like d(-i) is equivalent to
    > > e(m*n-i).
    >
    > If this code worked, there is something that ties all those
    > declared arrays together somehow. Since this is f77, all
    > those arrays aren't automatic arrays, so they must be dummy
    > arguments or in common. You must include the code from the
    > subroutine statement up to the first executable statement
    > within the subroutine. Then we can determine whether the
    > arrays are dummy arguments or in common. If they are dummies,
    > your compiler should have the capacity to give you a
    > traceback so you can know where the subroutine was fatally
    > called from. From there we might conceivably need the
    > declarations of the calling subprogram and the values of
    > any actual arguments.
    >
    > --

    James,

    Thank you very much for the comments. You nailed it on the head! I'd
    like to also thank the other people that have answered so promptly.
    Indeed, the arrays are dummy arguments, and the subroutine that calls
    this one uses arguments from a common block, where they're declared in a
    different order. Actually, in the common block they're declared like
    this (the same letters are used)

    real*8 d(nxy),e(nxy), etc.

    instead of the other way around. Here nxy=(m+2)*(n+2). Therefore, in
    order to sanitize the program I should change the declarations in the
    subroutine to

    real*8 e((m+2)*(n+2)),d((m+2)*(n+2)), etc

    and then change the reference to e(-i) into d((m+2)*(n+2) - i).

    Thanks again,

    -- 
    Jose Miguel Pasini
    To reach me, replace the numbers with actual numbers.
    

  • Next message: Walter Spector: "Re: Using file system API"

    Relevant Pages

    • Re: question about negative indices in fortran 77
      ... >> those arrays aren't automatic arrays, ... >> subroutine statement up to the first executable statement ... in the common block they're declared like ... > order to sanitize the program I should change the declarations in the ...
      (comp.lang.fortran)
    • local and my variables in a subroutine
      ... The above code doesn't work unless I remove the "my" declarations. ... I understand if I put the subroutine at the bottom of the code it ... subroutine first if I "local" the page arrays. ...
      (comp.lang.perl.misc)
    • Re: problem in interface
      ... I'd guess that something is wrong with the subroutine call. ... it is too big a mess. ... With a separate interface body like you have, the relevant declarations ... That you are having trouble with it is no surprise; ...
      (comp.lang.fortran)
    • Re: intersection of two sets
      ... sets(say two 1D arrays) in Fortran? ... is there any function that can find out intersection of these two ... SUBROUTINE remove_from_list ...
      (comp.lang.fortran)
    • Re: using pointers as aliases to avoid global variables
      ... I would do things differently though: If SUB1 and SUB2 only access different elements or non-overlapping sections of LARGE, I recommend passing them as separate arguments instead. ... SUBROUTINE MAINSUB ... Since SUB1 has fixed size arrays you do not need to use assumed shape arrays ...
      (comp.lang.fortran)