Array SIZE intrinsic after being passed to subroutine

Hello, I have a question is about the behavior of the SIZE intrinsic on an array after it is passed to a subroutine. In my experience, it looks like the dimensions of the array are being lost. Here’s my test program:

PROGRAM test
   REAL    :: array (101, 101)
   CALL mambo (array, 101, 101)
END PROGRAM

SUBROUTINE mambo (array,x,y)
   INTEGER  :: x, y
   REAL       :: array(x,y)
   print *, SIZE (array)
END SUBROUTINE mambo

When executed, I would expect the SIZE(array) to be printed as (101*101) or (10201)… but I seem to be getting garbage results. Am I doing something wrong here?

I’m using 6.1/i686/Linux.

pgf90 -Mfreeform test.F

Thanks!

Hi mwhite,

I tried the test using PGI versions 5.1, 5.2, 6.0, 6.1, and 6.2 on a 32-bit Pentium 4 system running Red Hat 7.3, and all got the correct 10201 answer. What OS are you using? What minor release of 6.1 do you have?

  • Mat
huckle:/tmp% pgf90 -V5.1 ~/tmp/test.f90

pgf90 5.1-6
Copyright 1989-2000, The Portland Group, Inc.  All Rights Reserved.
Copyright 2000-2003, STMicroelectronics, Inc.  All Rights Reserved.
PGF90/any Linux/x86 5.1-6
Copyright 1989-2000, The Portland Group, Inc.  All Rights Reserved.
Copyright 2000-2003, STMicroelectronics, Inc.  All Rights Reserved.
PGF90/x86 Linux/x86 5.1-6
Copyright 1989-2000, The Portland Group, Inc.  All Rights Reserved.
Copyright 2000-2003, STMicroelectronics, Inc.  All Rights Reserved.
huckle:/tmp% a.out
        10201
huckle:/tmp% pgf90 -V5.2 ~/tmp/test.f90
huckle:/tmp% a.out
        10201
huckle:/tmp% pgf90 -V6.0 ~/tmp/test.f90
huckle:/tmp% a.out
        10201
huckle:/tmp% pgf90 -V6.1 ~/tmp/test.f90
huckle:/tmp% a.out
        10201
huckle:/tmp% pgf90 -V6.2 ~/tmp/test.f90
huckle:/tmp% a.out
        10201

Interesting… here’s my output:

inferno [233] pgf90 -Mfreeform -V test.F

pgf90 6.1-1 32-bit target on x86 Linux
Copyright 1989-2000, The Portland Group, Inc.  All Rights Reserved.
Copyright 2000-2005, STMicroelectronics, Inc.  All Rights Reserved.
PGF90/any Linux/x86 6.1-1
Copyright 1989-2000, The Portland Group, Inc.  All Rights Reserved.
Copyright 2000-2005, STMicroelectronics, Inc.  All Rights Reserved.
PGF90/x86 Linux/x86 6.1-1
Copyright 1989-2000, The Portland Group, Inc.  All Rights Reserved.
Copyright 2000-2005, STMicroelectronics, Inc.  All Rights Reserved.
inferno [234] ./a.out
      5824500
inferno [247] uname -a
Linux inferno 2.6.16-1.2115_FC4smp #1 SMP Mon Jun 5 15:01:58 EDT 2006 i686 i686 i386 GNU/Linux

My machine is a dual core Xeon, Fedora Core 4…

Please let me know if there’s any other output I can show you, or something I could try.

Hi mwhite,

Found it. This was a short lived bug found in 6.1-1 (TPR#3740) and fixed in 6.1-3. The latest 6.1 release (6.1-6) can be found in our Download archives. Installing this version will fix the problem.

Thanks,
Mat

Hey, alright! I’ll give the new release a try.

Thanks Mat!