View previous topic :: View next topic |
Author |
Message |
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri Jul 17, 2020 3:51 pm Post subject: Optional arguments |
|
|
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:
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 |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7925 Location: Salford, UK
|
Posted: Fri Jul 17, 2020 4:05 pm Post subject: |
|
|
Simon
A first sight I suspect that NAG is mistaken. |
|
Back to top |
|
|
simon
Joined: 05 Jul 2006 Posts: 268
|
Posted: Fri Jul 17, 2020 6:00 pm Post subject: |
|
|
Hi Paul.
That's what I thought too. They wrote back with the response:
Quote: | With the array section in the call
you are referencing r, which is not permitted in the Fortran standard if r is not present. |
And then they suggested using
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 |
|
|
|