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 

Allocatable derived type components?

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



Joined: 08 Mar 2007
Posts: 19

PostPosted: Fri Jan 18, 2008 4:18 am    Post subject: Allocatable derived type components? Reply with quote

To the good people at Silverfrost,

I tried the latest Personal Edition of FTN95,
and it seems that allocatable derived type
components are not yet supported. Any
estimate as to when these will be added?

Thanks,
Ludwig
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Jan 18, 2008 9:40 am    Post subject: Reply with quote

Can you provide a short and simple example of code that does not work.

If it is in the Fortran 95 standard then the ommission needs to be classified as a bug.
Back to top
View user's profile Send private message AIM Address
Neo



Joined: 08 Mar 2007
Posts: 19

PostPosted: Sat Jan 19, 2008 8:28 am    Post subject: Example that produces compiler error Reply with quote

Dear Paul,

Thanks so much for your reply. The following code...
(the emoticon comes out when I put a colon between
parentheses.)

module example
type test1
real, dimension(10) :: a, b
end type test1
type test2
real, dimension(Smile, allocatable :: a, b
end type test2
end module example

produces the this error message upon compilation:

fatal 515 - ALLOCATABLE is invalid in the definition of a derived TYPE

The constant array dimension is fine, but the allocatable
attribute within the type test2 is not. Perhaps I am missing
something. (The above works with gfortran).

With best regards,
Ludwig
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Jan 19, 2008 10:18 am    Post subject: Reply with quote

The Fortran 95 standard does not say that you can use ALLOCATABLE in this context. It allows you to use POINTER and this serves the same purpose. I have not checked the Fortran 2003 standard.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


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

PostPosted: Sat Jan 19, 2008 1:25 pm    Post subject: Reply with quote

It looks like you can ignore or downgrade this error (using for example /ignore 515). For the next release I will change the default to a warning unless /ISO is specified. If it causes no problems then we can remove the warning later.

You can change the compiler defaults by using /config. You may have edit the resulting configuration file by hand in order to implement /ignore 515.
Back to top
View user's profile Send private message AIM Address
sparge



Joined: 11 Apr 2005
Posts: 371

PostPosted: Mon Jan 25, 2010 2:53 am    Post subject: Re: Reply with quote

PaulLaidler wrote:
The Fortran 95 standard does not say that you can use ALLOCATABLE in this context. It allows you to use POINTER and this serves the same purpose. I have not checked the Fortran 2003 standard.


This is a topic of real interest to me at the moment so I have been doing my homework, and I came to the same conclusion as Paul states above. However, when I try and implement it, I am falling at the first hurdle. I actually want to use derived types but I can't even make it work with intrinsic types. The following code:

module pointless
type mytype
integer, pointer :: a (Smile
end mytype
! type (mytype) b
end module pointless

(usual display problem with "colon right bracket => smiley face") compiles OK, but as soon as I try and declare an actual variable of type mytype, by uncommenting line 5, FTN95 v5.10.0 barfs horribly, as below.

Am I myself horribly misunderstanding something? (even if so, compilers should not barf Crying or Very sad ). I've checked all the things fixed in subsequent releases and it doesn't mention anything like this.

Andy
---
Access violation:
The instruction at address 0042e388 attempted to read from location 00000004
0042b86e make_new_variable(<ref>(<ptr>char),int,longÄlongÄint,int,<ptr>structÄtoken,enum [+2b1a]

00430dad add_variables(int,longÄlongÄint,int,<ptr>char,<ptr>structÄtoken,enumÄlogical) [+007a]

0040a953 parse_declaration_statement(<ptr>char,int,int,<ref>int) [+364e]

0041202b handle_token(<ptr>char,int,int,int,int,<ref>int) [+0df5]

0040514d ProcessEntireLine(void) [+0695]

0040619b compile(<ptr>char) [+00ce]

00401000 main [+049b]

00559736 SALFStart [+06ff]

eax=041f2700 ebx=040deab8 ecx=00000000
edx=00000000 esi=041f3440 edi=041f2700
ebp=0383f830 esp=0383d590 IOPL=0
ds=0023 es=0023 fs=003b
gs=0000 cs=001b ss=0023
flgs=00210202 [NC OP NZ SN DN NV]
0360/6820 TSTK=5 [ ]
0042e388 push [ecx+0x4]

0042e38b push edi
Back to top
View user's profile Send private message Send e-mail
PaulLaidler
Site Admin


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

PostPosted: Mon Jan 25, 2010 9:19 am    Post subject: Reply with quote

Andy

The following code compiles OK for me.

Code:
module pointless
type mytype
integer, pointer :: a(:)
end type
type (mytype) b
end module pointless
Back to top
View user's profile Send private message AIM Address
sparge



Joined: 11 Apr 2005
Posts: 371

PostPosted: Mon Jan 25, 2010 11:11 am    Post subject: Reply with quote

<slaps forehead> Doh. I'd like to say "that'll teach me to try and write sensible code at 01:30" but I don't suppose it will. It will reinforce the lesson about the perils of mixing keywords and variable names, though. Out of curiosity, I mutated the code some more and discovered, not sure whether to my delight or horror, that even this compiles OK:

module pointless
type type
integer, pointer :: type(Smile
end type
type (type) type
end module pointless

However, I have now tried v5.21 and it catches the syntactical error (that v5.10 misses), which leads to the problem. And I also now see the reported bug fix (I think) in vv5.20:

Missing "TYPE" in "END TYPE" causes a module to terminate prematurely

I guess "terminate prematurely" is the correct technical term for "barf horribly".

Andy
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General 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