I want to know the size of every data type

I use the pgi WorkStation 6.0 under Linux FC4 64bit, I want to know the default size of integer, real and double under 64bit and 32bit Linux. Is there a funcation like “sizeof” in C language?
Thank you!

Hi HuPo,

Do you mean what are the default data size of the Fortran data types (called ‘kind’ in Fortran)? If so, then you can use the “KIND” intrinsic. Note that the language defines the default kinds so it’s the same in 32-bits as it is in 64-bits. However, you can change the default kind using the “-i8” or “-r8” flags.

Example:

% cat tmp.f90

program default_kinds
    INTEGER I
    REAL X
    CHARACTER C

    PRINT *, 'Default INTEGER kind=', KIND(I)
    PRINT *, 'Default REAL kind=', KIND(X)
    PRINT *, 'Default CHARACTER kind=', KIND(C)

end program default_kinds

% pgf90 tmp.f90
% a.out
 Default INTEGER kind=            4
 Default REAL kind=            4
 Default CHARACTER kind=            1
% pgf90 tmp.f90 -i8 -r8
% a.out
 Default INTEGER kind=                        8
 Default REAL kind=                        8
 Default CHARACTER kind=                        1

Hope this helps,
Mat

That’s great!
Thank you very much!