- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Below is the code I am useing (MUCH simplified from my original), but it will not compile, giving me the dreaded error #6633. Does anyone have any idea what I am doing wrong? I am building a windows program from VS2008 using intel fortrna 11...
program typetest
type griddata
integer nx,ny
real dx,dy,x0,y0
end type griddata
type(griddata) :: alt
call elsize(alt)
end program
subroutine elsize(alt)
type griddata
integer nx,ny
real dx,dy,x0,y0
end type griddata
type (griddata) :: alt
end
Bruce
program typetest
type griddata
integer nx,ny
real dx,dy,x0,y0
end type griddata
type(griddata) :: alt
call elsize(alt)
end program
subroutine elsize(alt)
type griddata
integer nx,ny
real dx,dy,x0,y0
end type griddata
type (griddata) :: alt
end
Bruce
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Suggest you put the type declaration in a module:
module mytypes
type griddata
integer nx,ny
real dx,dy,x0,y0
end type griddata
end module mytypes
program typetest
use mytypes
type(griddata) :: alt
call elsize(alt)
end program
subroutine elsize(alt)
use mytypes
type (griddata) :: alt
end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Bruce,
of course as seen from the point of elegancy, the remarks of David areto the point.Nevertheless the code seems correct Fortranand thus must compile correct. I presume that the automatic interface creating causesthe problem here; if you add /warn:nointerfaces then everything wents fine!
I did not have taken a look at the generated interface.
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
While we may dispute the logic behind the rules of the language, the compiler is simply telling you that your code is in violation of the standard. Here is the relevant quotation from Metcalf, Reid and Cohen, Fortran 95/2003 Simplified, OUP, 2004:
...even if two derived-type definitions are identical in every respect except their names, entities of these two types are not equivalent. Even if the names, too, are identical, the types are different (unless...).
I guess that the reason for this counter-intuitive rule is to give the compiler leeway to produce different memory layouts of such variables in different contexts, possibly increasing efficiency by some measure.
Put the type definition in a module and USE the module wherever you need the type, as David White already suggested.
...even if two derived-type definitions are identical in every respect except their names, entities of these two types are not equivalent. Even if the names, too, are identical, the types are different (unless...).
I guess that the reason for this counter-intuitive rule is to give the compiler leeway to produce different memory layouts of such variables in different contexts, possibly increasing efficiency by some measure.
Put the type definition in a module and USE the module wherever you need the type, as David White already suggested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
mecej4 is quit right! This issue has been raises earlier (see thread August 1) but this forum member hasforgotten that he was the one who started the thread (sic!!)
So, Bruce, definethe type in a module and everyting is oke.
Of course, the question remains why the compiler will not give an error or warning, irrespective the setting of /warn.
Robert
So, Bruce, definethe type in a module and everyting is oke.
Of course, the question remains why the compiler will not give an error or warning, irrespective the setting of /warn.
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
But the thread was started because the compiler DID give an error.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks everyone. Using the module to store my derived types solved my problem, and now my code is that much more sleek!

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page