Re: defining an arbitrary type in your newer Fortrans
- From: Walter Spector <w6ws_xthisoutx@xxxxxxxxxxxxx>
- Date: Tue, 28 Nov 2006 20:28:24 GMT
Ancient_Hacker wrote:
Walter Spector wrote:
INTEGER, PARAMETER :: dbl_k = KIND (1.0d0) ! Double precision kind
REAL(dbl_k), ALLOCATABLE, DIMENSION(:,:) :: TwoDimmer
Whew! That's a little roundabout, but certainly better than my
ancient recourse to the old (IBMish?) REAL * 8. Of course we never used
that on the CDC's which didnt have bytes and single precision was quite
adequate.
So what you really want to use is the SELECTED_REAL_KIND intrinsic. Give
it the number of mantissa and/or exponent digits and it will return you
an appropriate kind for the computer in use:
INTEGER, PARAMETER :: real_k = SELECTED_REAL_KIND (14) ! enough for 14 digits, please
REAL(real_k), ALLOCATABLE :: TwoDimmer(:,:)
Then you will get single precision on the CDC (assuming that CDC had ever
implemented a F90 compiler - which they didn't), and double on most other
gear - without changing any code.
Note that you can't go hog-wild. If you asked for, say, 200 digits, and the
compiler did not support it, the intrinsic will return a negative value.
This then causes compilation errors - because kind values must be positive
integers.
W.
.
- References:
- defining an arbitrary type in your newer Fortrans
- From: Ancient_Hacker
- Re: defining an arbitrary type in your newer Fortrans
- From: Walter Spector
- Re: defining an arbitrary type in your newer Fortrans
- From: Ancient_Hacker
- defining an arbitrary type in your newer Fortrans
- Prev by Date: Re: defining an arbitrary type in your newer Fortrans
- Next by Date: Re: random numbers in fortran
- Previous by thread: Re: defining an arbitrary type in your newer Fortrans
- Index(es):
Relevant Pages
|