Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Too many arguments in call to 'shape'

217 views
Skip to first unread message

James Van Buskirk

unread,
Jan 29, 2011, 3:09:47 AM1/29/11
to
C:\gfortran\opengl\gridview>type bug1.f90
program bug1
use ISO_C_BINDING
implicit none
real,allocatable :: weevil(:,:)

write(*,*) achar(64,C_CHAR)
write(*,*) char(64,C_CHAR)
write(*,*) iachar('A',C_INTPTR_T)
write(*,*) ichar('A',C_INTPTR_T)
write(*,*) len('A',C_INTPTR_T)
write(*,*) len_trim('A',C_INTPTR_T)
allocate(weevil(2,2))
weevil = 42
write(*,*) ceiling(weevil,C_INTPTR_T)
write(*,*) floor(weevil,C_INTPTR_T)
write(*,*) shape(weevil,C_INTPTR_T)
write(*,*) storage_size(weevil,C_INTPTR_T)
end program bug1

C:\gfortran\opengl\gridview>gfortran bug1.f90 -obug1
bug1.f90:16.13:

write(*,*) shape(weevil,C_INTPTR_T)
1
Error: Too many arguments in call to 'shape' at (1)

--
write(*,*) transfer((/17.392111325966148d0,6.5794487871554595D-85, &
6.0134700243160014d-154/),(/'x'/)); end


steve

unread,
Jan 29, 2011, 1:30:34 PM1/29/11
to
On Jan 29, 12:09 am, "James Van Buskirk" <not_va...@comcast.net>
wrote:

> C:\gfortran\opengl\gridview>type bug1.f90
> program bug1
>    use ISO_C_BINDING
>    implicit none
>    real,allocatable :: weevil(:,:)
>
>    write(*,*) achar(64,C_CHAR)
>    write(*,*) char(64,C_CHAR)
>    write(*,*) iachar('A',C_INTPTR_T)
>    write(*,*) ichar('A',C_INTPTR_T)
>    write(*,*) len('A',C_INTPTR_T)
>    write(*,*) len_trim('A',C_INTPTR_T)
>    allocate(weevil(2,2))
>    weevil = 42
>    write(*,*) ceiling(weevil,C_INTPTR_T)
>    write(*,*) floor(weevil,C_INTPTR_T)
>    write(*,*) shape(weevil,C_INTPTR_T)
>    write(*,*) storage_size(weevil,C_INTPTR_T)
> end program bug1
>
> C:\gfortran\opengl\gridview>gfortran bug1.f90 -obug1
> bug1.f90:16.13:
>
>    write(*,*) shape(weevil,C_INTPTR_T)
>              1
> Error: Too many arguments in call to 'shape' at (1)

From WG5/N1176 X3J3/96-007,

13.14.97 SHAPE (SOURCE)
Description. Returns the shape of an array or a scalar.

From the Gfortran info file:


1.1 About GNU Fortran
=====================

The GNU Fortran compiler supports the Fortran 77, 90 and 95 standards
completely, parts of the Fortran 2003 and Fortran 2008 standards, and
several vendor extensions.

--
steve

James Van Buskirk

unread,
Jan 29, 2011, 3:01:11 PM1/29/11
to
"steve" <kar...@comcast.net> wrote in message
news:55ac2e63-ad84-477c...@l22g2000pre.googlegroups.com...

> From WG5/N1176 X3J3/96-007,

> Description. Returns the shape of an array or a scalar.

> From the Gfortran info file:

> 1.1 About GNU Fortran
> =====================

> The GNU Fortran compiler supports the Fortran 77, 90 and 95 standards
> completely, parts of the Fortran 2003 and Fortran 2008 standards, and
> several vendor extensions.

For a more rambling disucussion of the topic: I was up really late
again working on OpenGL and gfortran, this time trying to get Norman
Lawrence's GridView example to compile. Truly an inspiring example
and even though it has some obvious bugs, it's a port I am quite
obsessed about. I've got the non-integer array indices and free
mixing between integer and logical data types and passing double
precision actual arguments to single precision dummy arguments
and so on fixed up, and in this mini-marathon of effort the
anomaly of this thread was the only one I had to report that was
not an old one.

So it makes me optimistic about gfortran that I'm not having more
problems than this one. The test program I wrote came from
searching N1830.pdf for the string 'KIND=' and checking whether
gfortran supported the optional argument. In all the other
cases I checked it did, even though the LEN intrinsic could get
by with default integer kinds because gfortran use C_INT instead
of C_SIZE_T internally to represent string lengths, while it
uses C_SIZE_T (I think) to represent extents.

It looked to me like an unintentional omission, so I thought it
would be worthwhile to point it out. The workaround I suppose is
to use SIZE with both DIM and KIND arguments present, although I
didn't actually try it because the arrays in GridView don't come
close to overflowing default integer variables in any case.

James Van Buskirk

unread,
Jan 29, 2011, 3:16:53 PM1/29/11
to
"James Van Buskirk" <not_...@comcast.net> wrote in message
news:ii1rme$oc8$1...@news.eternal-september.org...

[snip]

Whoops. Didn't notice that Tobias had already smoked this one and
you had approved it. You guys are just the best!!

steve

unread,
Jan 29, 2011, 3:31:55 PM1/29/11
to
On Jan 29, 12:16 pm, "James Van Buskirk" <not_va...@comcast.net>
wrote:
> "James Van Buskirk" <not_va...@comcast.net> wrote in messagenews:ii1rme$oc8$1...@news.eternal-september.org...

>
> [snip]
>
> Whoops.  Didn't notice that Tobias had already smoked this one and
> you had approved it.  You guys are just the best!!
>

:-)

Thanks. I was just messing with you a tiny bit.

As Richard is fond of noting, there is a difference between
a Fortran 95 that supports some Fortran 2003 (and now 2008)
features and a Fortran compiler that claims to be a Fortran
2003 compiler, which is missing a feature or two (such as
allocation-on-assignment or IEEE 754 intrinsic module).

GCC is in stage 3 development, so no features are allowed
to be committed. I suspect that sometime this summer
gfortran will be able to claim Fortran 2003 conformance
(albeit with bugs).

--
steve

James Van Buskirk

unread,
Feb 5, 2011, 6:32:41 PM2/5/11
to
"steve" <kar...@comcast.net> wrote in message
news:6d9d2ae3-4d76-44d5...@o32g2000prb.googlegroups.com...

> On Jan 29, 12:16 pm, "James Van Buskirk" <not_va...@comcast.net>
> wrote:

> > Whoops. Didn't notice that Tobias had already smoked this one and
> > you had approved it. You guys are just the best!!

> Thanks. I was just messing with you a tiny bit.

:)

I was looking at:

http://fortranwiki.org/fortran/show/Fortran+2003+status

and noticed that gfortran was specifically called out for not only
SHAPE, but also MAXLOC and MINLOC:

C:\gfortran\opengl\gridview>type bug7.f90
program bug7
use ISO_C_BINDING, only: C_SIZE_T
integer,allocatable :: x(:)
integer i

allocate(x(7))
x = [(i,i=1,size(x))]
write(*,*) shape(x,kind=C_SIZE_T)
write(*,*) maxloc(x,kind=C_SIZE_T)
write(*,*) minloc(x,kind=C_SIZE_T)
write(*,*) maxloc(x,back=.TRUE.)
write(*,*) minloc(x,back=.TRUE.)
write(*,*) findloc(x,3)
write(*,*) findloc(x,3,kind=C_SIZE_T)
write(*,*) findloc(x,3,back=.TRUE.)
end program bug7

C:\gfortran\opengl\gridview>gfortran bug7.f90 -obug7
bug7.f90:9.13:

write(*,*) maxloc(x,kind=C_SIZE_T)
1
Error: Can't find keyword named 'kind' in call to 'maxloc' at (1)
bug7.f90:10.13:

write(*,*) minloc(x,kind=C_SIZE_T)
1
Error: Can't find keyword named 'kind' in call to 'minloc' at (1)
bug7.f90:11.13:

write(*,*) maxloc(x,back=.TRUE.)
1
Error: Can't find keyword named 'back' in call to 'maxloc' at (1)
bug7.f90:12.13:

write(*,*) minloc(x,back=.TRUE.)
1
Error: Can't find keyword named 'back' in call to 'minloc' at (1)
bug7.f90:14.31:

write(*,*) findloc(x,3,kind=C_SIZE_T)
1
Error: Keyword argument requires explicit interface for procedure 'findloc'
at (
1)
bug7.f90:15.31:

write(*,*) findloc(x,3,back=.TRUE.)
1
Error: Keyword argument requires explicit interface for procedure 'findloc'
at (
1)

C:\gfortran\opengl\gridview>gfortran -v
Built by Equation Solution <http://www.Equation.com>.
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=c:/gcc_equation/bin/../libexec/gcc/x86_64-w64-mingw32/4.6.0/
lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with:
../gcc-4.6-20110129-mingw/configure --host=x86_64-w64-mingw32 -
-build=x86_64-unknown-linux-gnu --target=x86_64-w64-mingw32 --prefix=/home/gfort
ran/gcc-home/binary/mingw32/native/x86_64/gcc/4.6-20110129 --with-gmp=/home/gfor
tran/gcc-home/binary/mingw32/native/x86_64/gmp --with-mpfr=/home/gfortran/gcc-ho
me/binary/mingw32/native/x86_64/mpfr --with-mpc=/home/gfortran/gcc-home/binary/m
ingw32/native/x86_64/mpc --with-ppl=/home/gfortran/gcc-home/binary/mingw32/nativ
e/x86_64/ppl --with-cloog=/home/gfortran/gcc-home/binary/mingw32/native/x86_64/c
loog --with-sysroot=/home/gfortran/gcc-home/binary/mingw32/cross/x86_64/gcc/4.6-
20110129 --with-gcc --with-gnu-ld --with-gnu-as --with-lto-plugin --enable-cloog
-backend=ppl --with-host-libstdcxx='-lstdc++ -lsupc++ -lm' --enable-targets=i686
-w64-mingw32,x86_64-w64-mingw32 --enable-lto --enable-languages=c,c++,fortran
--
enable-libgomp --enable-threads=win32 --enable-static --disable-shared --disable
-nls --disable-tls --disable-win32-registry
Thread model: win32
gcc version 4.6.0 20110129 (experimental) (GCC)

0 new messages