forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

get_command_argument

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Feb 14, 2022 2:36 am    Post subject: get_command_argument Reply with quote

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
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Feb 14, 2022 2:55 am    Post subject: Reply with quote

It looks to work ok with FTN95 Ver 8.62.0
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Mon Feb 14, 2022 8:40 am    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Feb 14, 2022 11:21 am    Post subject: Reply with quote

John

Thanks for the feedback. I have logged this for investigation.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Feb 15, 2022 9:18 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Feb 15, 2022 10:19 am    Post subject: Reply with quote

This regression has now been fixed for the next release of FTN95.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2554
Location: Sydney

PostPosted: Tue Feb 15, 2022 1:36 pm    Post subject: Reply with quote

Paul,

Thanks for the quick clarification. I can use that work-around.

John
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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