Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

About integer KIND parameter

Blane_J_
New Contributor I
525 Views

I was doing some tests on integer kind type parameters and something went wrong like: when I assign the value Z'80000000' to INTEGER(KIND=4) variable, the compiler generates a warning message saying that "The INTEGER(KIND=4) value is out-of-range"; But there's nothing odd when I assign Z'80' to INTEGER(KIND=1) variable as well as assign Z'8000' to INTEGER(KIND=2). So is it a compiler bug or something? By the way, Intel Parallel Studio 2015 is my current compiler.

0 Kudos
4 Replies
mecej4
Honored Contributor III
525 Views

In an assignment statement v = e, the kind of the variable v need not be the same as the kind of the expression e. Try this very short program:

write(*,*)kind(Z'80'),kind(Z'8000'),kind(Z'80000000')
end

If you want to change the kind of the expression e to something other than the default kind for the type, the language gives you the means to do so.

 

0 Kudos
Blane_J_
New Contributor I
525 Views

Thank you, mecej4. I've tried your program and it all returned value 4. Does that mean the  kind type of parameters like Z'xxxxxxxx'  are acquiescently INTEGER(KIND=4)?

0 Kudos
Steven_L_Intel1
Employee
525 Views

It is not standard Fortran to use the Z'nnnn' syntax in this context. See Binary, Octal, Hexadecimal, and Hollerith Constants and especially the subsection Determining the Data Type of Nondecimal Constants. (Note - the documentation link will probably become broken in a future release - see the FAQ for the current starting link for documentation.)

0 Kudos
Blane_J_
New Contributor I
525 Views

Thank you so much, Steve. I've read the pages you mentioned and I got a clear view on this issue now.

0 Kudos
Reply