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

Keyword arguments in intrinsics

12 views
Skip to first unread message

James Van Buskirk

unread,
May 16, 2008, 4:15:24 AM5/16/08
to
I found some places where the gfortran manual had keyword arguments
inconsistent with standard. In all cases the actual compiler agreed
with the standard rather than gfortran documentation:

C:\gfortran\james\intrinsics\func1>type names.f90
program names
implicit none
integer i
real x
complex z
logical L

i = 43
x = 3.14
z = (67,163)
L = .FALSE.
write(*,*) abs(A=x)
write(*,*) aint(A=x)
write(*,*) anint(A=x)
write(*,*) ceiling(A=x)
write(*,*) dble(A=z)
write(*,*) float(A=i)
write(*,*) dfloat(A=z)
write(*,*) floor(A=x)
write(*,*) loc(ARRAY=L)
write(*,*) nint(A=x)
write(*,*) real(A=i)
write(*,*) sizeof(I=x)
end program names
C:\gfortran\james\intrinsics\func1>gfortran names.f90 -onames

C:\gfortran\james\intrinsics\func1>names
3.1400001
3.0000000
3.0000000
4
67.000000000000000
43.000000
67.000000000000000
3
2293368
3
43.000000
4

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


Tom Micevski

unread,
May 16, 2008, 11:53:23 PM5/16/08
to
James Van Buskirk wrote:
> I found some places where the gfortran manual had keyword arguments
> inconsistent with standard. In all cases the actual compiler agreed
> with the standard rather than gfortran documentation:

this message reminded me that i noticed this the other day for the
move_alloc intrinsic.

the gfortran manual[1] says:
MOVE_ALLOC(SRC, DEST)
while the f2003 (draft) standard uses keywords "from" and "to":
MOVE ALLOC (FROM, TO) ==> section 13.7.82, page 337

[1] http://gcc.gnu.org/onlinedocs/gfortran/MOVE_005fALLOC.html

James Van Buskirk

unread,
May 17, 2008, 1:07:04 AM5/17/08
to
"Tom Micevski" <no...@none.au> wrote in message
news:0389cc37$0$27319$c3e...@news.astraweb.com...

> [1] http://gcc.gnu.org/onlinedocs/gfortran/MOVE_005fALLOC.html

Yeah, here's a sample dialog:

C:\gfortran\test\acosh>notepad move.f90

C:\gfortran\test\acosh>type move.f90
program move
write(*,*) MOVE_ALLOC()
end program move

C:\gfortran\test\acosh>gfortran move.f90 -omove
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp/ccYCGbHw.o:move.f90:(.text+0x55):
undefined reference to `_move_alloc_'
collect2: ld returned 1 exit status

C:\gfortran\test\acosh>type move.f90
program move
call MOVE_ALLOC()
end program move

C:\gfortran\test\acosh>gfortran move.f90 -omove
move.f90:2.20:

call MOVE_ALLOC()
1
Error: Missing actual argument 'from' in call to 'move_alloc' at (1)

C:\gfortran\test\acosh>type move.f90
program move
integer, allocatable :: x(:)
allocate(x(2))
x = 1
call MOVE_ALLOC(x)
end program move

C:\gfortran\test\acosh>gfortran move.f90 -omove
move.f90:5.21:

call MOVE_ALLOC(x)
1
Error: Missing actual argument 'to' in call to 'move_alloc' at (1)

C:\gfortran\test\acosh>type move.f90
program move
integer, allocatable :: x(:)
allocate(x(2))
x = 1
call MOVE_ALLOC(x,x(3))
end program move

C:\gfortran\test\acosh>gfortran move.f90 -omove
move.f90:5.21:

call MOVE_ALLOC(x,x(3))
1
Error: 'from' argument of 'move_alloc' intrinsic at (1) must be an array

C:\gfortran\test\acosh>type move.f90
program move
integer, allocatable :: x(:), y(:)
allocate(x(2), y(3))
x = 1
y = 2
call MOVE_ALLOC(y,x)
end program move

C:\gfortran\test\acosh>gfortran move.f90 -omove

C:\gfortran\test\acosh>type move.f90
program move
integer, allocatable :: x(:), y(:)
allocate(x(2), y(3))
x = 1
y = 2
write(*,*) 'x = ', x
write(*,*) 'y = ', y
call MOVE_ALLOC(y,x)
write(*,*) 'x = ', x
write(*,*) 'y = ', y
end program move

C:\gfortran\test\acosh>gfortran move.f90 -omove

C:\gfortran\test\acosh>move
The syntax of the command is incorrect.

C:\gfortran\test\acosh>gfortran move.f90 -omove1

C:\gfortran\test\acosh>move1
x = 1 1
y = 2 2 2
x = 2 2 2
y =

C:\gfortran\test\acosh>type move.f90
program move
integer, allocatable :: x(:), y(:)
allocate(x(2), y(3))
x = 1
y = 2
write(*,*) 'x = ', x
write(*,*) 'y = ', y
call MOVE_ALLOC(SRC=y,DEST=x)
write(*,*) 'x = ', x
write(*,*) 'y = ', y
end program move

C:\gfortran\test\acosh>gfortran move.f90 -omove1
move.f90:8.32:

call MOVE_ALLOC(SRC=y,DEST=x)
1
Error: Can't find keyword named 'src' in call to 'move_alloc' at (1)

C:\gfortran\test\acosh>type move.f90
program move
integer, allocatable :: x(:), y(:)
allocate(x(2), y(3))
x = 1
y = 2
write(*,*) 'x = ', x
write(*,*) 'y = ', y
call MOVE_ALLOC(FROM=y,TO=x)
write(*,*) 'x = ', x
write(*,*) 'y = ', y
end program move

C:\gfortran\test\acosh>gfortran move.f90 -omove1

C:\gfortran\test\acosh>move1
x = 1 1
y = 2 2 2
x = 2 2 2
y =

So you can see that the error messages and compiler behavior are
more consistent with the standard than the manual.

Steven G. Kargl

unread,
May 17, 2008, 1:26:19 AM5/17/08
to
In article <RNidnZA4h9Nl-rPV...@comcast.com>,

"James Van Buskirk" <not_...@comcast.net> writes:
> "Tom Micevski" <no...@none.au> wrote in message
> news:0389cc37$0$27319$c3e...@news.astraweb.com...
>
>> James Van Buskirk wrote:
>>> I found some places where the gfortran manual had keyword arguments
>>> inconsistent with standard. In all cases the actual compiler agreed
>>> with the standard rather than gfortran documentation:
>
>> this message reminded me that i noticed this the other day for the
>> move_alloc intrinsic.
>
>> the gfortran manual[1] says:
>> MOVE_ALLOC(SRC, DEST)
>> while the f2003 (draft) standard uses keywords "from" and "to":
>> MOVE ALLOC (FROM, TO) ==> section 13.7.82, page 337
>
>> [1] http://gcc.gnu.org/onlinedocs/gfortran/MOVE_005fALLOC.html
>

(snip)

>
> So you can see that the error messages and compiler behavior are
> more consistent with the standard than the manual.
>

From the very first page of the manual:

_Warning:_ This document, and the compiler it describes, are still
under development. While efforts are made to keep it up-to-date, it
might not accurately reflect the status of the most recent GNU Fortran
compiler.

Fixing a documentation problem is the easiest way to get invoked.

Index: intrinsic.texi
===================================================================
--- intrinsic.texi (revision 135453)
+++ intrinsic.texi (working copy)
@@ -7932,8 +7932,8 @@

@table @asis
@item @emph{Description}:
-@code{MOVE_ALLOC(SRC, DEST)} moves the allocation from @var{SRC} to
-@var{DEST}. @var{SRC} will become deallocated in the process.
+@code{MOVE_ALLOC(FROM, TO)} moves the allocation from @var{FROM} to
+@var{TO}. @var{FROM} will become deallocated in the process.

@item @emph{Standard}:
Fortran 2003 and later
@@ -7942,14 +7942,14 @@
Subroutine

@item @emph{Syntax}:
-@code{CALL MOVE_ALLOC(SRC, DEST)}
+@code{CALL MOVE_ALLOC(FROM, TO)}

@item @emph{Arguments}:
@multitable @columnfractions .15 .70
-@item @var{SRC} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
+@item @var{FROM} @tab @code{ALLOCATABLE}, @code{INTENT(INOUT)}, may be
of any type and kind.
-@item @var{DEST} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
- of the same type, kind and rank as @var{SRC}
+@item @var{TO} @tab @code{ALLOCATABLE}, @code{INTENT(OUT)}, shall be
+ of the same type, kind and rank as @var{FROM}
@end multitable

@item @emph{Return value}:

--
Steve
http://troutmask.apl.washington.edu/~kargl/

0 new messages