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 

URGENT HELP
Goto page Previous  1, 2
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> 64-bit
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


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

PostPosted: Mon Apr 30, 2018 9:20 am    Post subject: Reply with quote

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


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

PostPosted: Mon Apr 30, 2018 11:34 am    Post subject: Reply with quote

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



Joined: 31 Oct 2006
Posts: 933

PostPosted: Mon Apr 30, 2018 11:56 am    Post subject: Re: Reply with quote

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



Joined: 10 Mar 2008
Posts: 1864
Location: South Pole, Antarctica

PostPosted: Mon Apr 30, 2018 4:17 pm    Post subject: Reply with quote

Mecej4, Paul, Okay, forget AAA, rename one of it to BBB. Otherwise all look like kind of tripple witching Smile -- 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
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1864
Location: South Pole, Antarctica

PostPosted: Wed May 02, 2018 6:31 pm    Post subject: Reply with quote

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


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

PostPosted: Wed May 02, 2018 7:17 pm    Post subject: Reply with quote

No. No doubts and it has already been fixed.
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1864
Location: South Pole, Antarctica

PostPosted: Thu May 03, 2018 11:02 am    Post subject: Reply with quote

Thanks, Paul.
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 -> 64-bit All times are GMT + 1 Hour
Goto page Previous  1, 2
Page 2 of 2

 
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