# Fortran內部函數

• 數值函數
• 數學函數
• 數字查詢函數
• 浮點操作函數
• 位操作函數
• 字符函數
• 類函數
• 邏輯函數
• 數組函數

• A 代表任何類型的數值變量
• R 代表一個真實的或整型變量
• X 和 Y 代表實際變量
• Z 代表複數變量
• W 表示實數或複數變量

## 數值函數

Function

ABS (A)

AIMAG (Z)

AINT (A [, KIND])

ANINT (A [, KIND])

CEILING (A [, KIND])

CMPLX (X [, Y, KIND])

CONJG (Z)

DBLE (A)

DIM (X, Y)

DPROD (X, Y)

FLOOR (A [, KIND])

INT (A [, KIND])

MAX (A1, A2 [, A3,...])

MIN (A1, A2 [, A3,...])

MOD (A, P)

MODULO (A, P)

NINT (A [, KIND])

REAL (A [, KIND])

SIGN (A, B)

program numericFunctions implicit none ! define constants ! define variables
real :: a, b
complex :: z ! values for a, b
a = 15.2345 b = -20.7689 write(*,*) 'abs(a): ',abs(a),' abs(b): ',abs(b) write(*,*) 'aint(a): ',aint(a),' aint(b): ',aint(b) write(*,*) 'ceiling(a): ',ceiling(a),' ceiling(b): ',ceiling(b) write(*,*) 'floor(a): ',floor(a),' floor(b): ',floor(b) z = cmplx(a, b) write(*,*) 'z: ',z end program numericFunctions

abs(a): 15.2344999 abs(b): 20.7688999
aint(a): 15.0000000 aint(b): -20.0000000
ceiling(a): 16 ceiling(b): -20
floor(a): 15 floor(b): -21
z: (15.2344999, -20.7688999)

## 數學函數

ACOS (X)

ASIN (X)

ATAN (X)

ATAN2 (Y, X)

COS (X)

COSH (X)

EXP (X)

LOG (X)

LOG10 (X)

SIN (X)

SINH (X)

SQRT (X)

TAN (X)

TANH (X)

program projectileMotion implicit none ! define constants
real, parameter :: g = 9.8 real, parameter :: pi = 3.1415927 !define variables
real :: a, t, u, x, y !values for a, t, and u
a = 45.0 t = 20.0 u = 10.0 ! convert angle to radians
a = a * pi / 180.0 x = u * cos(a) * t
y = u * sin(a) * t - 0.5 * g * t * t

write(*,*) 'x: ',x,' y: ',y end program projectileMotion

x: 141.421356 y: -1818.57861

DIGITS (X)

EPSILON (X)

HUGE (X)

MAXEXPONENT (X)

MINEXPONENT (X)

PRECISION (X)

RANGE (X)

TINY (X)

## 浮點操作函數

EXPONENT (X)

FRACTION (X)

NEAREST (X, S)

RRSPACING (X)

SCALE (X, I)

SET_EXPONENT (X, I)

SPACING (X)

## 位操作函數

BIT_SIZE (I)

BTEST (I, POS)

IAND (I, J)

IBCLR (I, POS)

IBITS (I, POS, LEN)

IBSET (I, POS)

IEOR (I, J)

IOR (I, J)

ISHFT (I, SHIFT)

ISHFTC (I, SHIFT [, SIZE])

NOT (I)

## 字符函數

ACHAR (I)

CHAR (I [, KIND])

IACHAR (C)

ICHAR (C)

INDEX (STRING, SUBSTRING [, BACK])

LEN (STRING)

LEN_TRIM (STRING)

LGE (STRING_A, STRING_B)

LGT (STRING_A, STRING_B)

LLE (STRING_A, STRING_B)

LLT (STRING_A, STRING_B)

REPEAT (STRING, NCOPIES)

SCAN (STRING, SET [, BACK])

TRIM (STRING)

VERIFY (STRING, SET [, BACK])

## 類型函數

KIND (X)

SELECTED_INT_KIND (R)

SELECTED_REAL_KIND ([P, R])

## 邏輯函數

Function

LOGICAL (L [, KIND])