Beruflich Dokumente
Kultur Dokumente
.
CFD .
) (FORmula TRANslation
.
.
. 90
CFD .
IBM . .
.
77 90 90 .
90 77 .
][2
Fortran I 1954
Fortran II 1958
Fortran IV 1958
. .
. C
. 40
. .
. .
) (Graphical User Interface
) API!( . Visual Basic Delphi
. GUI
FORTRAN (Dynamic Link Library) DLL .
) ( .
Ansys .
90
90 .
77 . 90 ,
. ,
90 C++ !77 , )
( . 95
.
OK . Finish .
OK . . .
.
.
New < File -3
OK . . .
.
PROGRAM hello_fortran
!This is comment in fortran file
CHARACTER::A
'WRITE(*,*) 'Hello dear user, Fortran is so easy
READ(*,*) A
END PROGRAM hello_fortran
. .
)Hello.exe - 0 error(s), 0 warning(s
Debug F5 .
go ) (.
.
-1 )
!( .
. .
-2 .
-3 .
90 .
PROGRAM program_name
! Comment and program information
Declaration of variables and/or external functions
Program body
END PROGRAM program_name
Declaration and body of user-made functions
. 77 ! 77
. 77 :
7 72 .
1 5 6
) 19 !(.
1 5 5 )
GOTO .
C.
77 .
PROGRAM program_name
Comment and program information
Declare of variables and/or external functions
Body of program
END PROGRAM program_name
Declaration an body of user-made functions
77 :
PROGRAM hello_fortran
) ( .
IMPLICIT NONE .
. ! .
.
)
( . .
.
.
34 .
. 77
:
INTEGER
REAL ) 8(
DOUBLE ) 16 ( ] [
CHARACTER
LOGICAL
COMPLEX REAL 77
.
. ) (3.14,-1E5
AbBa .S .TRUE. .FALSE. )
(.
. .
) (Compiler . IMPILICIT
NONE . .
a..h o..z
i,j,k,l,m,n
) (:
REAL:: alpha, beta, c=10.0
PARAMETER
)PARAMETER (pi=3.141592
) / - + ( * ) ( . ** .
.1 .
.
.2
.3
.4
A*B**n-C/D ) A*(B**n)-(C/D .
.
.
. 1/5 0 1./5.
0.2 1d0/1d5 0.2 .
. 4 4. 4d0
.
.
variable = expression
The image part with relationship ID rId7
was not found in the file.
The image part with relationship ID rId8 was not found in the
file.
a .
.
. 77 > < , ...
.EQ. .
.EQ. equal to
.GE. greater or equal to
.GT. greater than
.LE. less than or equal to
.LT. less than
.NE. not equal to
:
logical negative
.NOT.
logical and
.AND.
logical or
.OR.
logical equivalence
.EQV.
.NEQV.
T: TRUE, F:FALSE
.NOT. x
x .AND. y
x .OR. y
x .EQV. y
x .NEQV. y
77 . 77 :
CHARACTER name*length
:
CHARACTER array (size)*length
* .
)*(*CHARACTER format_scope
)!PARAMETER(format_scope=this is constant character
77 .
: . // .
)substring= string(start position: end position
, .
CHARACTER first_word*8, second_word*5, third_word*20
first_word=FORTRAN
)second_word=first_word(:3
)third_word=second_word // first_word(4:
. LEN CHAR ICHAR
INDEX . .
.
READ
.
READ *, {input list} or
}RAED([UNIT=] unit type, [FMT=] format) {input list
unit type 5
format . * .
READ (*,*) a, b, c
WRITE
.
}PRINT *,{output list
}WRITE([UNIT=] unit type, [FMT=] format) {output list
. .
format .
) 77 1 5 (. .
.
)FORMAT (format sequence
WRITE .
)FMT= (format sequence
.
* .
format sequence
FORMAT .
.
Data description
Iw, Iw.m
Integer
Floating Point
Lw
Logical
A, Aw
Character
:
:I
:F
:E
:G
:L
Data type
:A
:w
:m
:d
)(
:e
Any string
nX
:
'WRITE(UNIT=*,FMT=10) 'The frequency is', f, 'Hz
)FORMAT(1X, A, F10.5, A
10
f 15 5
. UNIT FMT
.
'WRITE(*,10) 'The frequency is', f, 'Hz
)FORMAT(1X, A, F10.5, A
10
:
.
2 . 2 .
. .
The image part with relationship ID rId10 was not found in the file.
.1
.2
.3
.4
.1-4
.2-4
" "
.3-4
.5
:
PROGRAM Equation_solver_fortran
! This is program calculate the real roots of second order equation
IMPLICIT NONE
! Variable decleration
CHARACTER::end_key
REAL::a,b,c
REAL::Delta, x1, x2
! Main Porgram
WRITE(*,*) Please enter the equation coefficients a*x^2+b*x+c
WRITE(*,*) a: ?
READ(*,*) a
WRITE(*,*) b: ?
READ(*,*) b
WRITE(*,*) c: ?
READ(*,*) c
Delta=b**2-4*a*c
. .
. IF..THEN..ELSE )( SQRT
IF..THEN..ELSE )( SQRT
.
. .
.
. .
.
.
READ WRITE . UNIT .
UNIT * .
) (UNIT .
OPEN
. .
:
number ) 0 255
255 !( .
status NEW OLD
UNKNOWN SCRATCH
! REPLACE .
.
access DIRECT SEQUENTAL .
SEQUENTAL . .
.
CLOSE
. :
(UNIT= unit, STATUS = status) CLOSE
Intrinsic Functions
. .
SIN, COS, ASIN, ACOS, TAN, ATAN, COTAN :
.
!!
. Digital Visual Fortran
) help .(.
.
)}Result_variable = function_name({list of parameters
:
)a= sin(b
b a !
Intrinsic Subroutines
. !
. .
. CALL .
)}CALL subroutine_name({list of variables
:
SYSTEM_CLOCK ,DATE_AND_TIME, MVBITS, RANDOM_NUMBER, RANDOM_SEED
External Functions
. . :
)}type FUNCTION name ({dummy arguments
type ) ( . .
. .
"" .
arguments dummy 1 ) .
( . .
.
!
.
)REAL FUNCTION Newton (m1, m2, r
REAL:: gamma = 6.672E-11, m1, m2, r
Newton = -gamma*m1*m2/r**2
END Newton
Statement Functions
.
Function_name({list of parameters}) = expression
.
Newton(m1, m2, r) = -6.672E-11*m1*m2/r**2
External Subroutines
) ( . RETURN .
.
.
) (STATIC ALLOCATION .
SAVE . :
]}SAVE [{list of local variables to be saved
.
.
}INTRINSIC {list of function names
}EXTERNAL {list of function names
PROGRAM func
EXTERNAL CTN
INTRINSIC SIN, COS
REAL::angle=0.785 !...pi/4
REAL::sine,cosine,tangent
CALL TRIG(angle,SIN,sine)
WRITE(*,*) 'SIN(0.785)=',sine
CALL TRIG(angle,COS,cosine)
WRITE(*,*) 'COS(0.785)=',cosine
CALL TRIG(angle,CTN,cotangent)
WRITE(*,*) 'COTAN(0.785)=',cotangent
READ*,r
END PROGRAM func
SUBROUTINE TRIG(X,F,Y)
Y = F(X)
RETURN
END SUBROUTINE TRIG
FUNCTION CTN(X)
CTN = COS(X)/SIN(X)
RETURN
END FUNCTION CTN
.
IF
. .
.
IF (First condition statement) THEN
First sequence of commands
ELSE
Alternative sequence of commands
END IF
:
IF (number .LT. 0) THEN
sign=-1
ELSE IF (number .GT. 0) THEN
sign=1
ELSE
sign=0
END IF
Do
. GOTO )
( .
.
DO :
label: DO counter=start, limit, step
Sequence of commands to be looped through
END DO label
for while C .
EXIT CYCLE .
) (label GOTO!
:
]EXIT [name of loop
]CYCLE [name of loop
. .
. .
)REAL:: array(5
Outer: DO
READ(*,*) array
Inner: DO k=1, 5
IF (array(k)==0) CYCLE inner
IF (array(k)<0) EXIT
))Array(k)=1/SQRT(array(k
END DO inner
WRITE(*,*) array
END DO outer
) DO ( . EXIT
.
DO 77 :
DO label, counter=start, limit, step
Sequence of commands to be looped through
CONTINUE
GOTO
. .
label
GOTO label
! .
GOTO
.
STOP
! .
:
]STOP [message
Arrays
. .
.
)}type array_name({lower bound in nth dimention:Upper bound in nth dimention
.
50 70 1 20:
)REAL:: temperature(50:70, 1:20
)REAL:: temperature(50:70, 20
. 77 7 .
DO
) ( .
90
. .
55 12 temp 56
13 400 .
)temp = temperature(55,12
temperature(56,13) = 400.0
.
temperature .
WRITE(*,*) temperature
, ,
) (fixed-size array
! *
) ( .
.
:
Physics Department, State University of Michigan, September ,to FORTRAN Introduction ,Aloksandra Donev
reading recommended for 1999