This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Fwd: [Help] question about assumed shape arrays in gfortran


On Mon, Apr 04, 2011 at 08:06:34PM -0700, Jerry DeLisle wrote:
> Hi I got this off the help list at gfortran.org.  The reason I post here is 
> that gfortran 4.4 and 4.5 accept the assumed shape syntax in basictest.  
> 4.7 rejects it with:
> 
> $ gfc basictest1.f
> basictest1.f:9.18:
> 
>         call mysub(nums, n)
>                   1
> Error: Procedure 'mysub' at (1) with assumed-shape dummy argument 'nums' 
> must have an explicit interface
> 
> I tried -std=legacy to no avail.  So, we either have tightened up on a 
> constraint or we have a regression.
> 

I believe that gfortran has tight the constraints.  Assumed-shaped
arrays did not exist prior to F90 (95?), so -std=legacy is of course
of no help.  If one has old code that used the kludge of

   subroutine (x)
   real x(1)

to pass an array of unknown size, then the correct fix is to
use an assumed-size array, ie.,

   subroutine (x)
   real x(*)

And to be pedantic, from F95

12.3.1.1  Explicit interface
A procedure other than a statement function shall have an explicit interface if
   (1) A reference to the procedure appears
       (a) With an argument keyword (12.4.1),
       (b) As a reference by its generic name (12.3.2.1),
       (c) As a defined assignment (subroutines only),
       (d) In an expression as a defined operator (functions only), or
       (e) In a context that requires it to be pure,
   (2) The procedure has
       (a) An optional dummy argument,
       (b) A dummy argument that is an assumed-shape array, a pointer,
           or a target,

So, the difference in the posted code is due to the differences on
implicit and explicit interfaces.
-- 
Steve


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]