|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Mon Feb 14, 2022 2:36 am Post subject: get_command_argument |
|
|
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.
Code: | 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 Code: | /ERROR_NUMBERS
/ECHO_OPTIONS
/IMPLICIT_NONE
/INTL
/LOGL
|
The following also fails ? Code: | 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 |
|
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Mon Feb 14, 2022 2:55 am Post subject: |
|
|
It looks to work ok with FTN95 Ver 8.62.0 |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Mon Feb 14, 2022 8:40 am Post subject: |
|
|
It is interesting that it compiles with extra declared integers, as Code: | subroutine get_arg_string (n, arg)
integer :: n, l, stat
character*16 :: arg, string
call get_command_argument (n, string)
arg = string
end subroutine get_arg_string
|
but ICE with the in-line comment or multiple routines Code: | subroutine get_arg_string (n, arg)
integer :: n, l, stat
character*16 :: arg, string
call get_command_argument (n, string)
arg = string
end subroutine get_arg_string
subroutine get_arg_str (n, arg)
integer :: n, l, stat ! inline comment
character*16 :: arg, string
call get_command_argument (n, string)
arg = string
end subroutine get_arg_str
|
and fails if 2 routines are together, even without the in-line comment |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Mon Feb 14, 2022 11:21 am Post subject: |
|
|
John
Thanks for the feedback. I have logged this for investigation. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Tue Feb 15, 2022 9:18 am Post subject: |
|
|
A regression at about 8.72 has the effect that the first argument of get_command_argument must not itself be an argument.
So a temporary work-around is to copy n to i (say) before the call...
Code: | i = n
call get_command_argument (i, arg)
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7916 Location: Salford, UK
|
Posted: Tue Feb 15, 2022 10:19 am Post subject: |
|
|
This regression has now been fixed for the next release of FTN95. |
|
Back to top |
|
|
JohnCampbell
Joined: 16 Feb 2006 Posts: 2554 Location: Sydney
|
Posted: Tue Feb 15, 2022 1:36 pm Post subject: |
|
|
Paul,
Thanks for the quick clarification. I can use that work-around.
John |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|