PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Course

I want to know the size of every data type

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
HuPo



Joined: 24 Aug 2006
Posts: 7

PostPosted: Sun Jul 15, 2007 11:28 pm    Post subject: I want to know the size of every data type Reply with quote

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!
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6630
Location: The Portland Group Inc.

PostPosted: Mon Jul 16, 2007 1:53 pm    Post subject: Reply with quote

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:
Code:
% 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
Back to top
View user's profile
HuPo



Joined: 24 Aug 2006
Posts: 7

PostPosted: Wed Jul 18, 2007 9:57 pm    Post subject: Reply with quote

That's great!
Thank you very much!
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group