Fortran 90 KIND type?

The KIND of a variable is an integer label which tells the compiler which of its supported kinds it should use Beware that although it is common for the KIND parameter to be the same as the number of bytes stored in a variable of that KIND, it is not required by the Fortran standard That is, on a lot of systems REAl(KIND=4) :: xs! 4 byte ieee float REAl(KIND=8) :: xd! 8 byte ieee float REAl(KIND=16) :: xq!16 byte ieee float but there may be compilers for example with: REAL(KIND=1) :: XS!4 BYTE FLOAT REAL(KIND=2) :: XD!8 BYTE FLOAT REAL(KIND=3) :: XQ!16 BYTE FLOAT Similarly for integer and logical types (If I went digging, I could probably find examples.

Search the usenet group comp.lang. Fortran for kind to find examples. The most informed discussion of fortran occurs there, with some highly experienced people contributing.) So, if you can't count on a particular kind value giving you the same data representation on different platforms, what do you do?

That's what the intrinsic functions SELECTED_REAL_KIND and SELECTED_INT_KIND are for. Basically, you tell the function what sort of numbers you need to be able to represent, and it will return the kind you need to use I usually use these kinds, as they usually give me 4 byte and 8 byte reals:! --!

Specific precisions, usually same as real and double precision integer, parameter :: r6 = selected_real_kind(6) integer, parameter :: r15 = selected_real_kind(15) So I might subsequently declare a variable as: real(kind=r15) :: xd Note that this may cause problems where you use mixed language programs, and you need to absolutely specify the number of bytes that variables occupy. If you need to make sure, there are enquiry intrinsics that will tell you about each kind, from which you can deduce the memory footprint of a variable, its precision, exponent range and so on. Or, you can revert to the non-standard but commonplace real*4, real*8 etc declaration style When you start with a new compiler, it's worth looking at the compiler specific kind values so you know what you're dealing with.

Search the net for kindfinder. F90 for a handy program that will tell you about the kinds available for a compiler.

The KIND of a variable is an integer label which tells the compiler which of its supported kinds it should use. Beware that although it is common for the KIND parameter to be the same as the number of bytes stored in a variable of that KIND, it is not required by the Fortran standard. That is, on a lot of systems, REAl(KIND=4) :: xs!4 byte ieee float REAl(KIND=8) :: xd!8 byte ieee float REAl(KIND=16) :: xq!16 byte ieee float but there may be compilers for example with: REAL(KIND=1) :: XS!4 BYTE FLOAT REAL(KIND=2) :: XD!8 BYTE FLOAT REAL(KIND=3) :: XQ!16 BYTE FLOAT Similarly for integer and logical types.(If I went digging, I could probably find examples.

Search the usenet group comp.lang. Fortran for kind to find examples. The most informed discussion of fortran occurs there, with some highly experienced people contributing.) So, if you can't count on a particular kind value giving you the same data representation on different platforms, what do you do?

That's what the intrinsic functions SELECTED_REAL_KIND and SELECTED_INT_KIND are for. Basically, you tell the function what sort of numbers you need to be able to represent, and it will return the kind you need to use. I usually use these kinds, as they usually give me 4 byte and 8 byte reals:!

--! Specific precisions, usually same as real and double precision integer, parameter :: r6 = selected_real_kind(6) integer, parameter :: r15 = selected_real_kind(15) So I might subsequently declare a variable as: real(kind=r15) :: xd Note that this may cause problems where you use mixed language programs, and you need to absolutely specify the number of bytes that variables occupy. If you need to make sure, there are enquiry intrinsics that will tell you about each kind, from which you can deduce the memory footprint of a variable, its precision, exponent range and so on.

Or, you can revert to the non-standard but commonplace real*4, real*8 etc declaration style. When you start with a new compiler, it's worth looking at the compiler specific kind values so you know what you're dealing with. Search the net for kindfinder.

F90 for a handy program that will tell you about the kinds available for a compiler.

That kindfinder. F90 program is very cool. – Tim Whitcomb May 13 '09 at 16:01 A search of usenet turns up: salford f95 compiler uses kinds 1,2, and 3 to stand for 2- 4- and 8-byte variables; I saw a claim that g77 did the same before g95 and gfortran came along; and a report that the NAG fortran compiler had a compiler switch that allowed the selection between the (1,2,3,4) scheme and the (1,2,4,8) scheme.

No doubt there are others. Yes, kindfinder is handy. You can use it to set up a site-specific module file that contains named parameters for the different kinds, so that your real programs aren't littered with nonportable magic numbers.

– Andrej Panjkov May 14 '09 at 4:12.

From the Portland Group Fortran Reference, the KIND parameter "specifies a precision for intrinsic data types. " Thus, in the declaration real(kind=4) :: float32 real(kind=8) :: float64 the variable float64 declared as an 8-byte real (the old Fortran DOUBLE PRECISION) and the variable float32 is declared as a 4-byte real (the old Fortran REAL). This is nice because it allows you to fix the precision for your variables independent of the compiler and machine you are running on.

If you are running a computation that requires more precision that the traditional IEEE-single-precision real (which, if you're taking a numerical analysis class, is very probable), but declare your variable as real :: myVar, you'll be fine if the compiler is set to default all real values to double-precision, but changing the compiler options or moving your code to a different machine with different default sizes for real and integer variables will lead to some possibly nasty surprises (e.g. Your iterative matrix solver blows up). Fortran also includes some functions that will help pick a KIND parameter to be what you need - SELECTED_INT_KIND and SELECTED_REAL_KIND - but if you are just learning I wouldn't worry about those at this point. Since you mentioned that you're learning Fortran as part of a class, you should also see this question on Fortran resources and maybe look at the reference manuals from the compiler suite that you are using (e.g. Portland Group or Intel) - these are usually freely available.

Of the Fortran 90 Standard. Contact us for product literature. Fortran 90, we recommend Migrating to Fortran 90 by James Kerrigan.

Adams, Jeanne C. Brainerd, Jeanne T.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions