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 

Optional arguments

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



Joined: 05 Jul 2006
Posts: 172

PostPosted: Fri Jul 17, 2020 3:51 pm    Post subject: Optional arguments Reply with quote

The following code does not generate a runtime error using FTN95 or gfortran, but NAG issues a message at line 5 (the call to s2) indicating that there is a reference to optional argument r which is not present. I thought the NAG compiler was in error, but apparently it is correct because line 5 should be written as:

Code:
Call s2 (r=r)


to avoid a declaration that argument r is present.

Code:
Module m
Contains
 Subroutine s1 (r)
   Integer, Dimension(:), Optional :: r
    Call s2 (r=r(:))
   Return
 End Subroutine s1

 Subroutine s2 (r)
   Integer, Dimension(:), Optional :: r
   Return
 End Subroutine s2
End Module m

Program p
   Use m, Only: s1
   Implicit None
   Call s1 ()
End Program p
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Jul 17, 2020 4:05 pm    Post subject: Reply with quote

Simon

A first sight I suspect that NAG is mistaken.
Back to top
View user's profile Send private message AIM Address
simon



Joined: 05 Jul 2006
Posts: 172

PostPosted: Fri Jul 17, 2020 6:00 pm    Post subject: Reply with quote

Hi Paul.

That's what I thought too. They wrote back with the response:

Quote:
With the array section in the call

Code:
Call s2 (r=r(:))


you are referencing r, which is not permitted in the Fortran standard if r is not present.


And then they suggested using

Code:
Call s2 (r=r)


I do not know what the standard is, but thought I would report this issue here in case a fix is needed and in case anybody else is experiencing similar issues.
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