|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Mon Apr 30, 2018 9:20 am Post subject: |
|
|
The code
Code: | program AAA
CALL AAA
end |
is not correct Fortran - the subroutine should not have the same name as the main program.
I will see if the error report can be made more specific. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Mon Apr 30, 2018 11:34 am Post subject: |
|
|
For the next release of FTN95, the code...
Code: | module A
integer,parameter::idim=10
real*4 AA(idim)
contains
subroutine AAA
AA(:)=-1
end subroutine
end module
program AAA
use A
CALL AAA
AAAA=sqrt(AA(1))
end |
will result in the compilation error..
Quote: | error 647 - AAA is a PROGRAM name, so cannot be called |
|
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1892
|
Posted: Mon Apr 30, 2018 11:56 am Post subject: Re: |
|
|
DanRRight wrote: | Code: | module A
parameter (idim=10)
real*4 AA(idim)
contains
subroutine AAA
AA(:)=-1
end subroutine
end module
program AAA
use A
CALL AAA
AAAA=sqrt(AA(1))
end |
|
Dan, the compiler fails to process the PARAMETER declaration correctly, as Paul has already acknowledged, so let us put that aside, and assume that the compiler has processed the whole module correctly, and is now compiling the main program. When it sees use A, it may scan all the public entities of the module A, find AAA defined in the module and, as Paul pointed out, in conflict with the program name, which is also AAA. At this point, the compiler may see the conflict but postpone giving error messages because, although AAA is accessible by "use association", it has not yet been actually used. After it scans the next line, CALL AAA, the compiler has to decide what error message to give, and it needs to resolve the ambiguity about AAA to do that. The choice that it makes in doing so may not agree with the choice that a human reader would make.
Here is what Gfortran 7.1 says:
Code: | $gfortran -std=f95 *.f95 -o main
main.f95:11:4:
use A
1
Error: �aaa� of module �a�, imported at (1), is also the name of the current program unit
main.f95:12:8:
CALL AAA
1
Error: Name �aaa� at (1) is an ambiguous reference to �aaa� from current program unit |
|
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Mon Apr 30, 2018 4:17 pm Post subject: |
|
|
Mecej4, Paul, Okay, forget AAA, rename one of it to BBB. Otherwise all look like kind of tripple witching -- all damn devilry here, parameters conflict, dysfunctional modules conflict, program names conflict. Does ftn95 still crash with my third example?
Meantime thanks for program-subs name conflict fix |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Wed May 02, 2018 6:31 pm Post subject: |
|
|
To put things on end, and make sure correct bug will be fixed, do now we have any doubts that the parameters syntax caused this access violation? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7933 Location: Salford, UK
|
Posted: Wed May 02, 2018 7:17 pm Post subject: |
|
|
No. No doubts and it has already been fixed. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2826 Location: South Pole, Antarctica
|
Posted: Thu May 03, 2018 11:02 am Post subject: |
|
|
Thanks, Paul. |
|
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
|