replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - interface operators
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 

interface operators

 
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: 299

PostPosted: Tue Mar 05, 2013 6:24 am    Post subject: interface operators Reply with quote

The following program defines two interface operators (both ==) for separate derived types. They are defined in separate modules, but the second module uses the derived type in the first module for some independent reason. The use creates a warning message that I am nto quite sure how to interpret. It seems to imply that I cannot use the first interface operator in module 2. Any advice on what might be happening here would be greatly appreciated.

Code:
MODULE m1
  TYPE type1
   INTEGER :: i1
   INTEGER :: i2
  END TYPE type1
  INTERFACE OPERATOR(==)
     MODULE PROCEDURE same1
  END INTERFACE
CONTAINS
 FUNCTION same1(t1a,t1b)
  LOGICAL :: same1
  TYPE(type1), INTENT(IN) :: t1a
  TYPE(type1), INTENT(IN) :: t1b
  IF ((t1a%i1==t1b%i1).AND.(t1a%i2==t1b%i2)) THEN
     same1=.true.
  ELSE
     same1=.false.
  ENDIF
 END FUNCTION same1
END MODULE m1
!
MODULE m2
  USE m1, ONLY: type1
  TYPE type2
   INTEGER :: i1
   INTEGER :: i2
   INTEGER :: i3
  END TYPE type2
  PUBLIC :: OPERATOR(==)
  INTERFACE OPERATOR(==)
     MODULE PROCEDURE same2
  END INTERFACE
CONTAINS
 FUNCTION same2(t2a,t2b)
  LOGICAL :: same2
  TYPE(type2), INTENT(IN) :: t2a
  TYPE(type2), INTENT(IN) :: t2b
  IF ((t2a%i1==t2b%i1).AND.(t2a%i2==t2b%i2).AND.(t2a%i3==t2b%i3)) THEN
     same2=.true.
  ELSE
     same2=.false.
  ENDIF
 END FUNCTION same2
END MODULE m2
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Mar 05, 2013 10:06 am    Post subject: Reply with quote

This looks like a false warning message.
Does it work if you ignore the warning?
I have logged this for investigation.
Back to top
View user's profile Send private message AIM Address
simon



Joined: 05 Jul 2006
Posts: 299

PostPosted: Tue Mar 05, 2013 3:54 pm    Post subject: Reply with quote

Thanks Paul. I think the program works anyway, I don't think this particular problem has been creating any run-time problems, but I've been struggling to clear up some other module conflicts and wasn't sure if I was making some obscure programming error in this instance.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Apr 09, 2013 3:46 pm    Post subject: Reply with quote

I have had a look at this and I don't think there is a problem here.

The compiler just thinks that you may have made a mistake and flags up a warning.

If you remove the redundant "PUBLIC" statement then the warning does not appear.
Back to top
View user's profile Send private message AIM Address
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Tue Apr 09, 2013 5:13 pm    Post subject: Reply with quote

The use of PUBLIC OPERATOR(=) in M2 might be necessary if M2 contains a PRIVATE statement (I know its redundant in this case).

I would suggest this warning is associated with the issue identified in this other thread.

http://forums.silverfrost.com/viewtopic.php?t=2033&start=15

In simon's code above, the intention is that OPERATOR(=) in M1 should not be being used so there shouldn't be a conflict with the OPERATOR(=) in M2. If you comment out the USE statement which is also redundant, the code compiles with no warnings.

If you fix the issue with ONLY, in the other thread then this bug will also disappear I think.

So fix the other bug and see what happens with this one. Smile
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
simon



Joined: 05 Jul 2006
Posts: 299

PostPosted: Wed Apr 10, 2013 10:03 pm    Post subject: Reply with quote

David is correct - although it is redundant in the example, I do need the PUBLIC statement because in my larger module I have a PRIVATE statement. Plus I need the USE statement even though it is redundant here.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Apr 10, 2013 10:28 pm    Post subject: Reply with quote

If the warning is a nuisance then you can use /ignore 928 on the command line to suppress it.
Back to top
View user's profile Send private message AIM Address
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