replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Problem with derived types when compiling with /CHECK
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 

Problem with derived types when compiling with /CHECK

 
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 Jun 28, 2011 9:26 am    Post subject: Problem with derived types when compiling with /CHECK Reply with quote

The following program generates what appears to be a spurious error when compiled with /CHECK or /CHECKMATE, but works otherwise. Module m1 defines a simple derived type, and a procedure for assigning values to the derived type. Module m2 defines a second derived type that contains the derived type from m1. The second derived type is declared as a pointer, and a subroutine is defined to assign memory, and to define an initial value.

Please advise if I am doing something invalid, or if this is a compiler problem.

Code:

MODULE m1
!
  TYPE t1
     INTEGER :: i
  END TYPE t1
!
  INTERFACE ASSIGNMENT(=)
     MODULE PROCEDURE s1
  END INTERFACE
!
CONTAINS
!
 SUBROUTINE s1 (t,j)
!
  INTEGER, INTENT(IN) :: j
  TYPE(t1), INTENT(OUT) :: t
!
  t%i=j
!
 END SUBROUTINE s1
!
END MODULE m1
!
!
MODULE m2
!
 USE m1
!
 TYPE t2
  TYPE(t1) :: t
 END TYPE t2
!
 TYPE(t2), POINTER, PUBLIC :: tt(:)=>NULL()
!
CONTAINS
!
 SUBROUTINE s2 (tt)
  TYPE(t2), POINTER :: tt(:)
  ALLOCATE (tt(1))
  tt(1)%t=1
 END SUBROUTINE s2
!
END MODULE m2
!
!
PROGRAM p
!
 USE m2
!
 CALL s2 (tt)
!
END PROGRAM p
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Tue Jun 28, 2011 12:52 pm    Post subject: Reply with quote

If "tt" is a pointer, is the statement "tt(1)%t=1 " a valid statement ?
Back to top
View user's profile Send private message
simon



Joined: 05 Jul 2006
Posts: 299

PostPosted: Tue Jun 28, 2011 5:39 pm    Post subject: Reply with quote

I have declared tt as a pointer because I want an allocatable array that is assigned memory in a subroutine, and retains that memory for use later. The size of the array is not known a priori, and so in my actual program the size of the array is passed as an argument. In the example program I simply assign the array to have dimension 1, just to simplify the program for identifying the error, but in my original program there is an additional argument to s2 that defines the intended dimension of tt.

Regardless of my intention, I am not sure of the answer to your question!
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Jun 29, 2011 8:20 am    Post subject: Reply with quote

/check appears to be failing to work for the INTERFACE ASSIGNMENT(=). I guess it is one of those special situations that has never been tested.

In the short term you will need to either a) avoid /check in this locality or b) use the default "equals" rather than your over-ride of "equals" [i.e. use tt(1)%t%i=42].
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