Re: Warning: The structure contains misaligned fields
- From: blitheli <blitheli@xxxxxxxxx>
- Date: Mon, 28 Apr 2008 06:23:42 -0700 (PDT)
On 4月28日, 下午9时08分, Gordon Sande <g.sa...@xxxxxxxxxxxxxxxx> wrote:
On 2008-04-28 09:28:50 -0300, blitheli <blith...@xxxxxxxxx> said:
Is anybody can tell me what is wrong with this? Is this a fatal error
in fortran?
Thanks!
-------------------------------
module test
implicit none
type :: ccc
sequence
private
logical :: is_null=.true.
real(8):: A0=0d0,B0=0d0, Lambda0=0d0, H0=0d0
end type ccc
end module test
-------------------------------
The compile says:
Warning: The structure contains one or more misaligned fields.
[CCC]
If you read he words it says WARNing. It does not say FATAL.
Usually the manual will list the types of errors and comment
on the distinction. Since only you know what system/compiler
you are using noone else can be of much help. Please RTFM!
REAL(8) is a trouble point in the long run when you get around to
changing compilers. But today the LOGICAL is 4 bytes and REAL(8)
will be 8 bytes. The module starts out on an even memory boundary
and assigns the 4 bytes for the logical. You have specified SEQUENCE
so the compiler has no choice in its assignement. Next you will find
an 8 byte double precision that will not be on an 8 byte boundary.
That could mean 1. poor esthetics 2. poor performance 3. run time
terminating exception depending on what processor you are using.
Hence a warning. If you current processor had option 3 it would
most likely have been a fatal error. So either it will run slowly
(which you might not notice) or it won't but may casuse trouble
when you change processor. Hence just a warning.
The fixs are to change the order of the variables, take off the
sequence or just live with it. Depends on why you have the module
structure presented. Some compilers have options to hide the warning
messaage so you can live with it and hide that fact from your boss
and/or colleagues
Telling folks what system/compiler comlete with versions is helpful.
It marks you as someone who may not have very much experience so
you will get more further questions than answers. Any answers will
be vague like the above. A few will be definitive because they will
have guessed important facts that may have been guessed incorrectly.
You have been warned but, hey, this is the internet.
Thank you very much. I understand it now.
By the way, what is the most important role of "sequence" in
fortran?
.
- Follow-Ups:
- Re: Warning: The structure contains misaligned fields
- From: Craig Powers
- Re: Warning: The structure contains misaligned fields
- References:
- Warning: The structure contains misaligned fields
- From: blitheli
- Re: Warning: The structure contains misaligned fields
- From: Gordon Sande
- Warning: The structure contains misaligned fields
- Prev by Date: Re: ranlux
- Next by Date: Re: right sequence of included module files
- Previous by thread: Re: Warning: The structure contains misaligned fields
- Next by thread: Re: Warning: The structure contains misaligned fields
- Index(es):
Relevant Pages
|
|