Fortran Fortran compiler specific kind modifier.

AI Thread Summary
The discussion highlights a compatibility issue between the SilverFrost FTN95 and g95 Fortran compilers regarding the "kind" specifier for integer types. The SilverFrost implementation assigns kind values differently, with kind=3 corresponding to int32, while g95 uses kind=4 for int32. Users are encouraged to utilize the selected_int_kind function to ensure portability across different compilers, as the Fortran standard does not define a specific relationship between kind values and variable sizes. The g95 implementation is suggested to align more closely with the Fortran 95 standard compared to SilverFrost. Adopting standard practices will enhance code compatibility and portability.
uart
Science Advisor
Messages
2,797
Reaction score
21
Fortran compiler specific "kind" modifier.

I've recently switched over from the SilverFrost (Salford) FTN95 compiler to the open source g95 compliler. So far everything seems very compatible between the two compilers (as in the same source compiles without modification on either compiler) except for one thing. The "kind" specifier in the Silverfrost implementation seems to be different to that of the g95 implementation.

In the SF ftn95 implementation they use -
kind=1 : int8
kind=2 : int16
kind=3 : int32
kind=4 : int64.

Just now I went to compile a program that had some code like "integer (kind=3) :: i, j, k" and it told me that kind=3 was not a valid integer kind.

I've just made a few quick tests and it seems that g95 integer kinds are defined as follows -
kind=1 : int8
kind=2 : int16
kind=4 : int32
kind=8 : int64.

Can someone please confirm that the above is correct?

BTW. I'm suspecting that the g95 implementation is actually the correct fortran95 standard and the SF ftn95 is the one that's breaking standard.
 
Technology news on Phys.org
uart said:
BTW. I'm suspecting that the g95 implementation is actually the correct fortran95 standard and the SF ftn95 is the one that's breaking standard.
The standard doesn't specify the relation between the kind value of the size of the variable. Using hard-coded values for kind will lead to a program that is not portable. One has to use selected_int_kind.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Back
Top