[ Pobierz całość w formacie PDF ]
16 020 10 DLE ^P Data link escape
17 021 11 DC1 ^Q Device control 1 (X-ON)
18 022 12 DC2 ^R Device control 2 (TAPE)
19 023 13 DC3 ^S Device control 3 (X-OFF)
20 024 14 DC4 ^T Device control 4 (TAPE)
21 025 15 NAK ^U Negative acknowledge
22 026 16 SYN ^V Synchronous idle
23 027 17 ETB ^W End of transmission blocks
24 030 18 CAN ^X Cancel
25 031 19 EM ^Y End Of medium
26 032 1A SS ^Z Special sequence
27 033 1B ESC s^K Escape ( ^ [ )
28 034 1C FS s^L File separator ( ^ \ )
29 035 1D GS s^M Group separator ( ^ ] )
30 036 1E RS s^N Record separator ( ^ )
31 037 1F US s^O Unit separator ( ^ / )
127 177 7F DEL s^0 Delete or rubout ( ^ _ )
ASCII Character Set 445
A
446 FORTRAN 77 Reference Manual
Sample Statements
B
This appendix shows a table that contains selected samples of the f77
statement types. The purpose is to provide a quick reference for syntax details
of the more common variations of each statement type.
In the table, the following conventions are used:
C Character variable N Numeric variable
CA Character array L Logical variable
I Integer variable S Switch variable
U External unit Nonstandard feature
R Real variable
447
B
Table B-1 FORTRAN 77 Statement Samples
Name Examples Comments
ACCEPT ACCEPT *, A, I Compare to READ.
ASSIGN ASSIGN 9 TO I
ASSIGNMENT C = 'abc' Character
C = "abc"
C = S // 'abc'
C = S(I:M)
L = L1 .OR. L2 Logical
L = I .LE. 80
N = N+1 Arithmetic
X = '7FF00000'x Hex
CURR = NEXT Compare to RECORD.
NEXT.ID = 82
AUTOMATIC AUTOMATIC A, B, C
AUTOMATIC REAL P, D, Q
IMPLICIT AUTOMATIC REAL (X-Z)
BACKSPACE BACKSPACE U
BACKSPACE( UNIT=U, IOSTAT=I, ERR=9 )
BLOCK DATA BLOCK DATA
BLOCK DATA COEFFS
BYTE BYTE A, B, C
BYTE A, B, C(10)
BYTE A /'x'/, B /255/, C(10) Initialize A and B
CALL CALL P( A, B )
CALL P( A, B, *9 ) Alternate return
CALL P( A, B, &9 ) Alternate return
CALL P
CHARACTER CHARACTER C*80, D*1(4)
CHARACTER*18 A, B, C
CHARACTER A, B*3 /'xyz'/, C /'z'/ Initialize B and C
CLOSE CLOSE ( UNIT=I )
CLOSE( UNIT=U, ERR=90, IOSTAT=I )
COMMON COMMON / DELTAS / H, P, T
COMMON X, Y, Z
COMMON P, D, Q(10,100)
448 FORTRAN 77 Reference Manual
B
Table B-1 FORTRAN 77 Statement Samples (Continued)
Name Examples Comments
COMPLEX COMPLEX U, V, U(3,6)
COMPLEX U*16 Double complex
COMPLEX U*32 Quad complex (SPARC)
COMPLEX U / (1.0,1.0) /, V /(1.0,10.0) / Initialize U and V
CONTINUE 100 CONTINUE
DATA DATA A, C / 4.01, 'z' /
DATA (V(I),I=1,3) /.7, .8, .9/
DATA ARRAY(4,4) / 1.0 /
DATA B,O,X,Y /B'0011111', O'37', X'1f',
Z'1f'/
DECODE DECODE ( 4, 1, S ) V
DIMENSION DIMENSION ARRAY(4, 4)
DIMENSION V(1000), W(3)
DO DO 100 I = INIT, LAST, INCR
&
100 CONTINUE
DO I = INIT, LAST Unlabeled DO
&
END DO
DO WHILE ( DIFF .LE. DELTA ) DO WHILE
&
END DO
DO 100 WHILE ( DIFF .LE. DELTA )
&
100 CONTINUE
DOUBLE COMPLEX DOUBLE COMPLEX U, V COMPLEX*16
DOUBLE COMPLEX U, V COMPLEX
COMPLEX U / (1.0,1.0D0) /, V / (1.0,1.0D0) /Initialize U and V
DOUBLE PRECISION DOUBLE PRECISION A, D, Y(2) REAL*8
DOUBLE PRECISION A, D / 1.2D3 /, Y(2) Initialize D
ELSE ELSE Compare to IF (Block)
ELSE IF ELSE IF
ENCODE ENCODE( 4, 1, T ) A, B, C
END END
END DO END DO Compare to DO
Sample Statements 449
B
Table B-1 FORTRAN 77 Statement Samples (Continued)
Name Examples Comments
ENDFILE ENDFILE ( UNIT=I )
ENDFILE I
ENDFILE( UNIT=U, IOSTAT=I, ERR=9 )
END IF END IF
END MAP END MAP Compare to MAP
END STRUCTURE END STRUCTURE Compare to STRUCTURE
END UNION END UNION Compare to UNION
ENTRY ENTRY SCHLEP( X, Y )
ENTRY SCHLEP( A1, A2, *4 )
ENTRY SCHLEP
EQUIVALENCE EQUIVALENCE ( V(1), A(1,1) )
EQUIVALENCE ( V, A )
EQUIVALENCE (X,V(10)), (P,D,Q)
EXTERNAL EXTERNAL RNGKTA, FIT
FORMAT 10 FORMAT(// 2X, 2I3, 3F6.1, 4E12.2, 2A6,3L2 X I F E A L
) D G
10 FORMAT(// 2D6.1, 3G12.2 ) w
10 FORMAT( 2I3.3, 3G6.1E3, 4E12.2E3 )
10 FORMAT('a quoted string', " another", I2)Strings
10 FORMAT( 18Ha hollerith string, I2) Hollerith
10 FORMAT( 1X, T10, A1, T20, A1 ) Tabs
10 FORMAT( 5X, TR10, A1, TR10, A1, TL5, A1 )Tab right, left
10 FORMAT(" Init=", I2, :, 3X, "Last=", I2) :
10 FORMAT( 1X, "Enter path name ", $ ) $
10 FORMAT( F4.2, Q, 80 A1 ) Q
10 FORMAT( 'Octal ', O6, ', Hex ' Z6 ) Octal, hex
10 FORMAT( 3F.2 ) Variable expression
FUNCTION FUNCTION Z( A, B )
FUNCTION W( P,D, *9 )
CHARACTER FUNCTION R*4(P,D,*9 )
INTEGER*2 FUNCTION M( I, J ) Short integer
GO TO GO TO 99 Unconditional
GO TO I, ( 10, 50, 99 ) Assigned
GO TO I
GO TO ( 10, 50, 99), I Computed
450 FORTRAN 77 Reference Manual
B
Table B-1 FORTRAN 77 Statement Samples (Continued)
Name Examples Comments
IF IF ( I -K ) 10, 50, 90 Arithmetic IF
IF ( L ) RETURN LOGICAL IF
IF ( L ) THEN BLOCK IF
N=N+1
CALL CALC
ELSE
K=K+1
CALL DISP
ENDIF
IF ( C .EQ. 'a' ) THEN BLOCK IF
NA=NA+1 With ELSE IF
CALL APPEND
ELSE IF ( C .EQ. 'b' ) THEN
NB=NB+1
CALL BEFORE
ELSE IF ( C .EQ. 'c' ) THEN
NC=NC+1
CALL CENTER
END IF
IMPLICIT IMPLICIT COMPLEX (U-W,Z)
IMPLICIT UNDEFINED (A-Z)
INCLUDE INCLUDE 'project02/header'
INQUIRE INQUIRE( UNIT=3, OPENED=OK )
INQUIRE( FILE='mydata', EXIST=OK )
INQUIRE( UNIT=3, OPENED=OK, IOSTAT=ERRNO )
INTEGER INTEGER C, D(4)
INTEGER C*2 Short integer
INTEGER*4 A, B, C
INTEGER A/ 100 /, B, C / 9 / Initialize A and C
INTRINSIC INTRINSIC SQRT, EXP
LOGICAL LOGICAL C
LOGICAL B*1, C*1
LOGICAL*1 B, C
LOGICAL*4 A, B, C
LOGICAL B / .FALSE. /, C Initialize B
Sample Statements 451
B
Table B-1 FORTRAN 77 Statement Samples (Continued)
Name Examples Comments
Map MAP Compare to STRUCTURE and UNION
CHARACTER *18 MAJOR
END MAP
MAP
INTEGER*2 CREDITS
CHARACTER*8 GRAD_DATE
END MAP
NAMELIST NAMELIST /CASE/ S, N, D
OPEN OPEN( UNIT=3, FILE="data.test" )
OPEN( UNIT=3, IOSTAT=ERRNO )
OPTIONS OPTIONS /CHECK /EXTEND_SOURCE
PARAMETER PARAMETER (A="xyz"), (PI=3.14)
PARAMETER (A="z", PI=3.14)
PARAMETER X=11, Y=X/3
PAUSE PAUSE
POINTER POINTER ( P, V ), ( I, X )
PRAGMA EXTERNAL RNGKTA, FIT !$PRAGMA C(RNGKTA, FIT)C() directive
PROGRAM PROGRAM FIDDLE
PRINT PRINT *, A, I List-directed
PRINT 10, A, I Formatted
PRINT 10, M Array M
PRINT 10, (M(I),I=J,K) Implied-DO
PRINT 10, C(I:K) Substring
PRINT '(A6,I3)', A, I Character constant format
PRINT FMT='(A6,I3)', A, I
[ Pobierz całość w formacie PDF ]