integer, external :: get_arg_num (n), as a function,
I started trying to quickly write a simple integer function in Plato to return the value of the n'th argument, but got an ICE when compiling using FTN95 8.80.0.
I can't see what I have done wrong ? Is an internal read in a function a problem ? I have made a few changes, but the ICE remains.
integer function get_arg_num (n)
integer :: n, i, iostat
character(16) :: arg
call get_command_argument (n, arg)
read (arg,fmt='(bn,i16)', iostat=iostat) i
if ( iostat /= 0 ) then
write (*,12) n,arg
12 format ('Unable to obtain number from arg ',i0,' :',a)
i = 0
end if
get_arg_num = i
end function get_arg_num
subroutine get_arg_val (n, i)
integer :: n, i, iostat, L
character(16) :: arg
call get_command_argument (n, arg, L)
! read (arg,fmt='(bn,i16)', iostat=iostat) i
read (arg,11, iostat=iostat) i
11 format (bn,i16)
if ( iostat /= 0 ) then
write (*,12) n,arg
12 format ('Unable to obtain number from arg ',i0,' :',a)
i = 0
end if
! get_arg_num = i
end subroutine get_arg_val
My ftn95.cfg is /ERROR_NUMBERS /ECHO_OPTIONS /IMPLICIT_NONE /INTL /LOGL
The following also fails ? subroutine get_arg_string (n, arg) integer :: n character*16 :: arg, string
call get_command_argument (n, string)
arg = string
end subroutine get_arg_string