Fortran compiler specific kind modifier.

  • Fortran
  • Thread starter uart
  • Start date
  • #1
uart
Science Advisor
2,776
9

Main Question or Discussion Point

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.
 

Answers and Replies

  • #2
DrClaude
Mentor
7,339
3,520
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.
 

Related Threads on Fortran compiler specific kind modifier.

  • Last Post
Replies
2
Views
3K
  • Last Post
Replies
10
Views
3K
  • Last Post
Replies
4
Views
4K
  • Last Post
Replies
4
Views
2K
  • Last Post
Replies
4
Views
7K
Replies
11
Views
2K
  • Last Post
Replies
9
Views
8K
Replies
1
Views
2K
Replies
5
Views
5K
  • Last Post
Replies
6
Views
2K
Top