71 lines
1.9 KiB
HTML
71 lines
1.9 KiB
HTML
<h2>Comments</h2>
|
|
<pre><code>! This is a comment</code></pre>
|
|
|
|
<h2>Strings</h2>
|
|
<pre><code>"foo 'bar' baz"
|
|
'foo ''bar'' baz'
|
|
''
|
|
ITALICS_'This is in italics'
|
|
"test &
|
|
! Some "tricky comment" here
|
|
&test"</code></pre>
|
|
|
|
<h2>Numbers</h2>
|
|
<pre><code>473
|
|
+56
|
|
-101
|
|
21_2
|
|
21_SHORT
|
|
1976354279568241_8
|
|
B'01110'
|
|
B"010"
|
|
O'047'
|
|
O"642"
|
|
Z'F41A'
|
|
Z"00BC"
|
|
-12.78
|
|
+1.6E3
|
|
2.1
|
|
-16.E4_8
|
|
0.45E-4
|
|
10.93E7_QUAD
|
|
.123
|
|
3E4</code></pre>
|
|
|
|
<h2>Full example</h2>
|
|
<pre><code>MODULE MOD1
|
|
TYPE INITIALIZED_TYPE
|
|
INTEGER :: I = 1 ! Default initialization
|
|
END TYPE INITIALIZED_TYPE
|
|
SAVE :: SAVED1, SAVED2
|
|
INTEGER :: SAVED1, UNSAVED1
|
|
TYPE(INITIALIZED_TYPE) :: SAVED2, UNSAVED2
|
|
ALLOCATABLE :: SAVED1(:), SAVED2(:), UNSAVED1(:), UNSAVED2(:)
|
|
END MODULE MOD1
|
|
|
|
PROGRAM MAIN
|
|
CALL SUB1 ! The values returned by the ALLOCATED intrinsic calls
|
|
! in the PRINT statement are:
|
|
! .FALSE., .FALSE., .FALSE., and .FALSE.
|
|
! Module MOD1 is used, and its variables are allocated.
|
|
! After return from the subroutine, whether the variables
|
|
! which were not specified with the SAVE attribute
|
|
! retain their allocation status is processor dependent.
|
|
CALL SUB1 ! The values returned by the first two ALLOCATED intrinsic
|
|
! calls in the PRINT statement are:
|
|
! .TRUE., .TRUE.
|
|
! The values returned by the second two ALLOCATED
|
|
! intrinsic calls in the PRINT statement are
|
|
! processor dependent and each could be either
|
|
! .TRUE. or .FALSE.
|
|
CONTAINS
|
|
SUBROUTINE SUB1
|
|
USE MOD1 ! Brings in saved and not saved variables.
|
|
PRINT *, ALLOCATED(SAVED1), ALLOCATED(SAVED2), &
|
|
ALLOCATED(UNSAVED1), ALLOCATED(UNSAVED2)
|
|
IF (.NOT. ALLOCATED(SAVED1)) ALLOCATE(SAVED1(10))
|
|
IF (.NOT. ALLOCATED(SAVED2)) ALLOCATE(SAVED2(10))
|
|
IF (.NOT. ALLOCATED(UNSAVED1)) ALLOCATE(UNSAVED1(10))
|
|
IF (.NOT. ALLOCATED(UNSAVED2)) ALLOCATE(UNSAVED2(10))
|
|
END SUBROUTINE SUB1
|
|
END PROGRAM MAIN</code></pre> |