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

'aint' has the wrong number of arguments

15 views
Skip to first unread message

James Van Buskirk

unread,
Dec 7, 2010, 10:31:55 PM12/7/10
to
I composed a test to see verify gfortran documentation for some
specific names. Here are some cases I would consider failures:

C:\gfortran\clf\quadtest>type ainttest.f90
program ainttest
implicit none
intrinsic aint
intrinsic anint
intrinsic char
intrinsic ichar
intrinsic index
intrinsic int
intrinsic len
intrinsic len_trim
intrinsic lnblnk
intrinsic nint
real r
character c, string2
character(7) string1
integer i

r = 3.14
c = 'A'
string2 = 'n'
string1 = 'string1'
i = 13
call rsub('aint',aint,r)
call rsub('anint',anint,r)
call charsub('char',char,i)
call charisub('ichar',ichar,c)
call char2isub('index',index,string1,string2)
call rsubi('int',int,r)
call charstarisub('len',len,string1)
call charstarisub('len_trim',len_trim,string1)
call charstarisub('lnblnk',lnblnk,string1)
call rsubi('nint',nint,r)
end program ainttest

subroutine rsub(label,fun,x)
implicit none
character(*) label
interface
function fun(x)
implicit none
real, intent(in) :: x
real fun
end function fun
end interface
real x

write(*,*) label//'(',x,') = ',fun(x)
end subroutine rsub

subroutine charsub(label,fun,x)
implicit none
character(*) label
interface
function fun(x)
implicit none
integer, intent(in) :: x
character fun
end function fun
end interface
integer x

write(*,*) label//'(',x,') = ',fun(x)
end subroutine charsub

subroutine charisub(label,fun,x)
implicit none
character(*) label
interface
function fun(x)
implicit none
character, intent(in) :: x
integer fun
end function fun
end interface
character x

write(*,*) label//'(',x,') = ',fun(x)
end subroutine charisub

subroutine char2isub(label,fun,x,y)
implicit none
character(*) label,x,y
interface
function fun(x,y)
implicit none
character(*), intent(in) :: x,y
integer fun
end function fun
end interface

write(*,*) label//'(',x,',',y,') = ',fun(x,y)
end subroutine char2isub

subroutine rsubi(label,fun,x)
implicit none
character(*) label
interface
function fun(x)
implicit none
real, intent(in) :: x
integer fun
end function fun
end interface
real x

write(*,*) label//'(',x,') = ',fun(x)
end subroutine rsubi

subroutine charstarisub(label,fun,x)
implicit none
character(*) label,x
interface
function fun(x)
implicit none
character(*), intent(in) :: x
integer fun
end function fun
end interface

write(*,*) label//'(',x,') = ',fun(x)
end subroutine charstarisub

C:\gfortran\clf\quadtest>gfortran ainttest.f90 -oainttest
ainttest.f90:23.20:

call rsub('aint',aint,r)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'aint' has the
wron
g number of arguments
ainttest.f90:24.21:

call rsub('anint',anint,r)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'anint' has the
wro
ng number of arguments
ainttest.f90:25.23:

call charsub('char',char,i)
1
Error: Intrinsic 'char' at (1) is not allowed as an actual argument
ainttest.f90:25.23:

call charsub('char',char,i)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'char' has the
wron
g number of arguments
ainttest.f90:26.25:

call charisub('ichar',ichar,c)
1
Error: Intrinsic 'ichar' at (1) is not allowed as an actual argument
ainttest.f90:26.25:

call charisub('ichar',ichar,c)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'ichar' has the
wro
ng number of arguments
ainttest.f90:27.26:

call char2isub('index',index,string1,string2)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'index' has the
wro
ng number of arguments
ainttest.f90:28.20:

call rsubi('int',int,r)
1
Error: Intrinsic 'int' at (1) is not allowed as an actual argument
ainttest.f90:28.20:

call rsubi('int',int,r)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'int' has the
wrong
number of arguments
ainttest.f90:29.27:

call charstarisub('len',len,string1)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'len' has the
wrong
number of arguments
ainttest.f90:30.32:

call charstarisub('len_trim',len_trim,string1)
1
Error: Intrinsic 'len_trim' at (1) is not allowed as an actual argument
ainttest.f90:30.32:

call charstarisub('len_trim',len_trim,string1)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'len_trim' has
the
wrong number of arguments
ainttest.f90:31.30:

call charstarisub('lnblnk',lnblnk,string1)
1
Error: Intrinsic 'lnblnk' at (1) is not allowed as an actual argument
ainttest.f90:31.30:

call charstarisub('lnblnk',lnblnk,string1)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'lnblnk' has
the wr
ong number of arguments
ainttest.f90:32.21:

call rsubi('nint',nint,r)
1
Warning: Interface mismatch in dummy procedure 'fun' at (1): 'nint' has the
wron
g number of arguments

Except for INDEX, the wrong number of arguments warning seems to
be there because of an optional KIND argument. However, checking
N1830.pdf, section 13.6 we see that the KIND argument isn't part
of the specifics, except for LEN_TRIM and LNBLNK which aren't listed
as specific names at all. Checking the gfortran documentation, the
specific name INDEX takes exactly two arguments, not three or four
as the generic function does.

The error statements about CHAR, ICHAR, and INT are valid because
they are marked with a bullet in section 13.6. The errors for
LEN_TRIM and LNBLNK are in a different category because the gfortran
manual doesn't list them as specific names at all. Perhaps the
thing to do would be to report instead an error to the effect that
LEN_TRIM (or LNBLNK) is not a specific name, or to amend the manual
to list them as specific names.

However, the gfortran manual doesn't mark any specific names with
a bullet so we couldn't tell by reading it whether a declaration
such as:

procedure(DACOSH), pointer :: fun

would be accepted in gfortran. Of elemental functions, the standard
seems to mark 3 kinds of functions with a bullet:

1) Type conversion functions
2) MIN/MAX
3) Lexical comparison functions

It seems logical to me for gfortran to do the same with its
specific names provided as extensions, with one possible exception.
Maybe the way to do this would be to provide a statement about the
four things you can't do with the bulleted names in each place in
the manual where they appear (there are not many.)

A couple more comments on these specific names before I move on to
different topics:

The specific name ICHAR might better describe its argument to be
CHARACTER(LEN=1,KIND=1) and INDEX to take arguments
CHARACTER(LEN=*,KIND=1). Also the specific name LEN takes an
argument CHARACTER(LEN=*,KIND=1).

One might think that CMPLX and REAL would have a problem with
that optional KIND argument but in fact they have different
singularities.

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


Richard Maine

unread,
Dec 7, 2010, 10:43:50 PM12/7/10
to
James Van Buskirk <not_...@comcast.net> wrote:
[details elided]

Or in slightly different words, 'aint' ain't right. :-)

--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain

0 new messages