Re: character array initialization
From: Roman (janrom1_at_yahoo.com)
Date: 04/20/04
- Next message: Feed_me_spam: "[Solved:] Re: why segfault for large ifc-compiled executable?"
- Previous message: MISHAL ALHARBI: "Re: Program compiled on intel acting weired"
- In reply to: Richard Maine: "Re: character array initialization"
- Next in thread: Paul Van Delst: "Re: character array initialization"
- Reply: Paul Van Delst: "Re: character array initialization"
- Reply: Richard Maine: "Re: character array initialization"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 20 Apr 2004 03:25:25 -0700
What you will tell if I will tell you that it is the safest way to have 100% of
portability ? Many times I have problems with programs (specially on Cray) which
was compilled with some special options like -sdefault128, what means that for
all paramters e.g. real you didn't defined as kind=4 system assumed that right
know all variables are kind=16. The same happened for integer.
Now let's imagine that you are writting unofrmatted files and you want to
read it on another system which do not have possibillity to read such data (32B)?
So im my opinion it is worthly to use always KIND when you delcare any variables.
Regards,
Roman
> janrom1@yahoo.com (Roman) writes:
>
> > To have
> > your program work properlly on all systems under every compiler...
> ...
> > INTEGER(KIND=2) :: i
>
> Well, if you really want it to work correctly on all systems under
> every compiler, avoid hard-wired kind numbers. It is not guaranteed
> that kind=2 is valid. To my knowledge, INTEGER(KIND=2) happens to be
> valid and even mean the same thing on all the f90 implementations I
> know of, but it is more by happenstance than by design (by one
> scheme, the 2 means 2 bytes of storage; by another, the 2 means the
> 2nd integer kind).
>
> When you actually need to specify kinds, there are portable ways
> to do so (though a bit verbose - I've submitted a proposal to
> provide a simpler way for f2003+). But for situations like this
> sample, the KIND is completely superfluous. I recommend sticking
> with default integer kind unless you have specific reason to
> choose otherwise.
>
> Wanting to save a few bytes of storage for scalar variables is nowhere
> near good enough specific reason (and might not even have that effect
> anyway). If you have a large array, the storage saving might be
> important. Or if you are doing something where exact storage layout
> matters. In the other direction, you might need to specify the kind
> if there is a reasonable chance that you might need values too large
> to fit in a default integer.
>
> But for the most part, I recommend avoiding kind specification for
> integers. The compiler probably has at least as good an idea as
> you do of what a reasonable default kind is. By specifying a
> hardwired integer kind value, you just clutter up the code, make
> it non-portable, and make it potentially less efficient. (Yes,
> there are cases where sizes smaller than the default are actually
> less efficient).
- Next message: Feed_me_spam: "[Solved:] Re: why segfault for large ifc-compiled executable?"
- Previous message: MISHAL ALHARBI: "Re: Program compiled on intel acting weired"
- In reply to: Richard Maine: "Re: character array initialization"
- Next in thread: Paul Van Delst: "Re: character array initialization"
- Reply: Paul Van Delst: "Re: character array initialization"
- Reply: Richard Maine: "Re: character array initialization"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]