02.07.2013 Views

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

HP Fortran Programmer's Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Data types and data objects<br />

Intrinsic data types<br />

Table 3-2 Attributes in type declaration statement (Continued)<br />

VOLATILE Provides for data sharing between asynchronous processes<br />

(extension).<br />

The following are examples of type declaration statements:<br />

! Default, KIND=4, integers i j k.<br />

INTEGER i, j, k<br />

! Using optional separator.<br />

INTEGER :: i,j,k<br />

! An 8-byte initialized integer.<br />

INTEGER(KIND=8) :: i=2**40<br />

! 10 element array of 8-byte integers.<br />

INTEGER(8),DIMENSION(10) :: i<br />

! Using an array constructor for initialization.<br />

REAL, DIMENSION(2,2):: a = RESHAPE((/1.,2.,3.,4./),(/2,2/))<br />

! Initialized complex.<br />

COMPLEX :: z=(1.0,2.0)<br />

! SYNTAX ERROR - no :: present.<br />

COMPLEX z=(1.0,2.0) ! ILLEGAL<br />

! Initialization using the <strong>HP</strong> slash extension<br />

INTEGER i/1/,j/2/<br />

REAL a(2,2)/1.1,2.1,1.2,2.2/ ! a(i,j)=i.j<br />

! One character (default length).<br />

CHARACTER(KIND=1) :: c<br />

! A 10-byte character string.<br />

CHARACTER(LEN=10) :: c<br />

! Length can be * for a named constant; title is a 13-byte<br />

! character string<br />

CHARACTER(*),PARAMETER :: title=’Ftn 90 MANUAL’<br />

! next four declarations are all equivalent, but only the last<br />

! is standard-conforming<br />

REAL*8 r8(10)<br />

REAL r8*8(10)<br />

REAL r8(10)*8<br />

REAL(8), DIMENSION(10) :: r8<br />

! If the statement is in a subprogram, n must be known at entry;<br />

! otherwise, it must be a constant.<br />

CHARACTER(LEN=n) :: c<br />

30<br />

Attribute Description<br />

Chapter 3

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!