Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Paul van Delst <Paul.vanDelst@xxxxxxxx>
- Date: Wed, 31 Jan 2007 09:47:14 -0500
Clive Page wrote:
In message <epohfj$j3m$1@xxxxxxxxxxxxxxxxxx>, Paul van Delst <Paul.vanDelst@xxxxxxxx> writesBut seriously, I use this for the multi-byte case:
MODULE Endian_Utility
USE Type_Kinds
IMPLICIT NONE
CONTAINS
FUNCTION Big_Endian()
INTEGER(Short) :: Source = 1_Short
LOGICAL :: Big_Endian
Big_Endian = .FALSE.
IF ( IACHAR(TRANSFER(Source,'a')) == 0 ) Big_Endian = .TRUE.
END FUNCTION Big_Endian
....
END MODULE Endian_Utility
That looks very similar to a module that I posted some years ago. If only I could remember how it worked :-)
Ha! I was going to write the exact same comment but I figured too much tongue in cheek would detract from my post's utility (such as it was). :oD
I probably did crib it from you via clf - most of my generally useful tools I've acquired via clf posts.
Now to a more difficult topic: how to get the effect of LOGICAL*1
What for? :o)
If you want a really large array of logicals, e.g. flags for bad pixels in a huge image, then the difference between 1-byte and 4-byte data can be significant.
Yeah, I was just pulling yer proverbial about that. But, wouldn't an array of integer(byte) achieve the same purpose? Depending on how you name your mask array, values of true/false or 0/1 can be ambiguous either way. But parameters would solve that:
use type_kinds ! definition of integer byte kind in here
integer(byte), parameter :: bad_pixel = 0_byte
integer(byte), parameter :: good_pixel = 1_byte
......
integer, parameter :: n = 100000
......
integer :: image(n,n) ! Assume default for image
integer(byte) :: mask(n,n)
where (mask == good_pixel)
..process pixels in image
end where
It's not as succinct as something like:
use type_kinds
integer, parameter :: n = 100000
......
integer :: image(n,n) ! Assume default for image
logical(byte) :: good_pixels(n,n) ! Assuming you can do this
where (good_pixels)
..process pixels in image
end where
but it's portable. :o)
Does the difference between doing
where (mask == good_pixel)
or
where (good_pixels)
incur any performance penalties?
cheers,
paulv
--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Ph: (301)763-8000 x7748
Fax:(301)763-8545
.
- Follow-Ups:
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Clive Page
- Re: Declaration to get 8-bit (or 16-bit) integer?
- References:
- Declaration to get 8-bit (or 16-bit) integer?
- From: Clive Page
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Terence
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Richard E Maine
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: glen herrmannsfeldt
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Richard Maine
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Gordon Sande
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Clive Page
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Paul van Delst
- Re: Declaration to get 8-bit (or 16-bit) integer?
- From: Clive Page
- Declaration to get 8-bit (or 16-bit) integer?
- Prev by Date: Re: What is going on with Lahey?
- Next by Date: Re: CVF and Vista
- Previous by thread: Re: Declaration to get 8-bit (or 16-bit) integer?
- Next by thread: Re: Declaration to get 8-bit (or 16-bit) integer?
- Index(es):
Relevant Pages
|