replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - sequence derived types needed
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 

sequence derived types needed

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
davidb



Joined: 17 Jul 2009
Posts: 560
Location: UK

PostPosted: Mon Dec 24, 2012 12:27 am    Post subject: sequence derived types needed Reply with quote

In the following code, the compiler should generate an error because the derived type foo_t is not a sequence type. However, it doesn't.

Although there is an explicit interface for subroutine init, the type foo_t it requires as an argument is not being USEd by the program anon, which is actually creating its own, different type.

The correct error is generated by FTN95 if init is just made an external subroutine without an explicit interface.

Code:

module mmm
contains
   subroutine init(foo)
      type foo_t
         real :: a
         real :: b
      end type foo_t
      type (foo_t), intent(out) :: foo
      foo%a = 1.0; foo%b = 2.0
   end subroutine init
end module mmm

program anon
   use mmm
   type foo_t
      real :: a
      real :: b
   end type foo_t
   type (foo_t) :: foo
   call init(foo)
   print *, foo%a, foo%b
end program anon

The code can be made "correct" by changing foo_t in each place to:

Code:

   type foo_t
      sequence
      real :: a
      real :: b
   end type foo_t


P.S. Most other compilers I have also fail to detect this and similar cases where sequence is needed. Rolling Eyes
_________________
Programmer in: Fortran 77/95/2003/2008, C, C++ (& OpenMP), java, Python, Perl
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Dec 24, 2012 10:11 am    Post subject: Reply with quote

Thanks for this. I have logged it for attention.
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