FORTRAN 77 Language Reference

Arithmetic and Mathematical Functions

This section details arithmetic, type conversion, trigonometric, and other functions. "a" stands for a function's single argument, "a1" and "a2" for the first and second arguments of a two argument function, and "ar" and "ai" for the real and imaginary parts of a function's complex argument.

Note that REAL*16 and COMPLEX*32 are SPARC only.

Arithmetic

Table 6-1 Arithmetic Functions

Intrinsic Function

Definition

No. of

Args.

Generic

Name

Specific

Names

Argument

Type

Function Type

Absolute value

See Note (6).

|a| =

(ar**2+ai**2)**.5

ABSIABS ABS DABS CABS QABS @ ZABS @ CDABS @ CQABS @INTEGER REAL DOUBLE COMPLEX REAL*16 DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32INTEGER REAL DOUBLE REAL REAL*16 DOUBLE DOUBLE REAL*16

Truncation

See Note (1).

int(a)

1AINTAINT DINT QINT @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Nearest whole number

int(a+.5) if a 0­­­­

int(a-.5) if a < 0

1ANINTANINT DNINT QNINT @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Nearest integer

int(a+.5) if a 0

int(a-.5) if a < 0

1NINTNINT IDNINT IQNINT @REAL DOUBLE REAL*16INTEGER INTEGER INTEGER

Remainder

See Note (1).

a1-int(a1/a2)*a2

MODMOD AMOD DMOD QMOD @INTEGER REAL DOUBLE REAL*16INTEGER REAL DOUBLE REAL*16

Transfer of sign

|a1| if a2 0

-|a1| if a2 < 0

SIGNISIGN SIGN DSIGN QSIGN @INTEGER REAL DOUBLE REAL*16INTEGER REAL DOUBLE REAL*16

Positive difference

a1-a2 if a1 > a2

0 if a1 £ a2

DIMIDIM DIM DDIM QDIM @INTEGER REAL DOUBLE REAL*16INTEGER REAL DOUBLE REAL*16

a1 * a2

-DPROD QPROD @REAL DOUBLEDOUBLE REAL*16

Choosing largest value

max(a1, a2, ...)

MAX MAX0 AMAX1 DMAX1 QMAX1 @INTEGER REAL DOUBLE REAL*16INTEGER REAL DOUBLE REAL*16

AMAX0AMAX0INTEGERREAL

MAX1MAX1REALINTEGER

Choosing smallest value

min(a1, a2, ...)

MIN MIN0 AMIN1 DMIN1 QMIN1 @INTEGER REAL DOUBLE REAL*16INTEGER REAL DOUBLE REAL*16

AMIN0AMIN0INTEGERREAL

MIN1MIN1REALINTEGER

Type Conversion

Table 6-2 Type Conversion Functions

Conversion to

No. of Args

Generic Name

Specific

Names

Argument Type

Function Type

INTEGER See Note (1).

INT- INT IFIX IDINT - - - IQINT @INTEGER REAL REAL DOUBLE COMPLEX COMPLEX*16 COMPLEX*32 REAL*16INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER
REAL See Note (2).

REALREAL FLOAT - SNGL SNGLQ @ - - -INTEGER INTEGER REAL DOUBLE REAL*16 COMPLEX COMPLEX*16 COMPLEX*32REAL REAL REAL REAL REAL REAL REAL REAL
DOUBLE See Note (3).

DBLEDBLE DFLOAT DREAL @ DBLEQ @ - - - -INTEGER INTEGER REAL DOUBLE REAL*16 COMPLEX COMPLEX*16 COMPLEX*32DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION
REAL*16 See Note (3').

QREAL@ QEXT @QREAL @ QFLOAT @ - QEXT @ QEXTD @ - - - -INTEGER INTEGER REAL INTEGER DOUBLE REAL*16 COMPLEX COMPLEX*16 COMPLEX*32REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 REAL*16
COMPLEX See Notes (4) and (8).

1 or 2

CMPLX- - - - - - -INTEGER REAL DOUBLE REAL*16 COMPLEX COMPLEX*16 COMPLEX*32COMPLEX COMPLEX COMPLEX COMPLEX COMPLEX COMPLEX COMPLEX
DOUBLE COMPLEX See Note (8).

1 or 2

DCMPLX@- - - - - - -INTEGER REAL DOUBLE REAL*16 COMPLEX COMPLEX*16 COMPLEX*32DOUBLE COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX
COMPLEX*32 See Note (8).

1 or 2

QCMPLX@- - - - - - -INTEGER REAL DOUBLE REAL*16 COMPLEX COMPLEX*16 COMPLEX*32COMPLEX*32 COMPLEX*32 COMPLEX*32 COMPLEX*32 COMPLEX*32 COMPLEX*32 COMPLEX*32
INTEGER See Note (5).

- -ICHAR IACHAR @CHARACTERINTEGER
CHARACTER See Note (5).

- -CHAR ACHAR @INTEGERCHARACTER

On an ASCII machine, including Sun systems:

• ACHAR is a nonstandard synonym for CHAR

• IACHAR is a nonstandard synonym for ICHAR

On a non-ASCII machine, ACHAR and IACHAR were intended to provide a way to deal directly with ASCII.

Trigonometric Functions

Table 6-3 Trigonometric Functions

Intrinsic Function

Definition

Args

Generic Name

Specific

Names

Argument Type

Function Type

Sine

See Note (7).

sin(a)

SINSIN DSIN QSIN @ CSIN ZSIN @ CDSIN @ CQSIN @REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32

Sine (degrees)

See Note (7).

sin(a)

SIND @SIND @ DSIND @ QSIND @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Cosine

See Note (7).

cos(a)

COSCOS DCOS QCOS @ CCOS ZCOS @ CDCOS @ CQCOS @REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32

Cosine (degrees)

See Note (7).

cos(a)

COSD @COSD @ DCOSD @ QCOSD @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Tangent

See Note (7).

tan(a)

TANTAN DTAN QTAN @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Tangent (degrees)

See Note (7).

tan(a)

TAND @TAND @ DTAND @ QTAND @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Arcsine

See Note (7).

arcsin(a)

ASINASIN DASIN QASIN @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Arcsine (degrees)

See Note (7).

arcsin(a)

ASIND @ASIND @ DASIND @ QASIND @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Arccosine

See Note (7).

arccos(a)

ACOSACOS DACOS QACOS @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Arccosine (degrees)

See Note (7).

arccos(a)

ACOSD @ACOSD @ DACOSD @ QACOSD @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Arctangent

See Note (7).

arctan(a)

ATANATAN DATAN QATAN @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

arctan

(a1/a2)

ATAN2ATAN2 DATAN2 QATAN2 @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Arctangent (degrees)

See Note (7).

arctan(a)

ATAND @ATAND @ DATAND @ QATAND @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

arctan

(a1/a2)

ATAN2D@ATAN2D @ DATAN2D @ QATAN2D @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Hyperbolic Sine

See Note (7).

sinh(a)

SINHSINH DSINH QSINH @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Hyperbolic Cosine

See Note (7).

cosh(a)

COSHCOSH DCOSH QCOSH @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Hyperbolic Tangent

See Note (7).

tanh(a)

TANHTANH DTANH QTANH @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Other Mathematical Functions

Table 6-4 Other Mathematical Functions

Intrinsic Function

Definition

No. of Args.

Generic Name

Specific Names

Argument Type

Function Type

Imaginary part of a complex number

See Note (6).

ai

IMAGAIMAG DIMAG @ QIMAG @COMPLEX DOUBLE COMPLEX COMPLEX*32REAL DOUBLE REAL*16

Conjugate of a complex number

See Note (6).

(ar, -ai)

CONJGCONJG DCONJG @ QCONJG @COMPLEX DOUBLE COMPLEX COMPLEX*32COMPLEX DOUBLE COMPLEX COMPLEX*32

Square root

a**(1/2)

SQRTSQRT DSQRT QSQRT @ CSQRT ZSQRT @ CDSQRT @ CQSQRT @REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32

Cube root

See Note(8').

a**(1/3)

CBRTCBRT @ DCBRT @ QCBRT @ CCBRT @ ZCBRT @ CDCBRT @ CQCBRT @REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32

Exponential

e**a

EXPEXP DEXP QEXP @ CEXP ZEXP @ CDEXP @ CQEXP @REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32

Natural logarithm

log(a)

LOGALOG DLOG QLOG @ CLOG ZLOG @ CDLOG @ CQLOG @REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32REAL DOUBLE REAL*16 COMPLEX DOUBLE COMPLEX DOUBLE COMPLEX COMPLEX*32

Common logarithm

log10(a)

LOG10ALOG10 DLOG10 QLOG10 @REAL DOUBLE REAL*16REAL DOUBLE REAL*16

Error function (See note below)

erf(a)

ERFERF @ DERF @REAL DOUBLEREAL DOUBLE

Error function

1.0 - erf(a)

ERFCERFC @ DERFC @REAL DOUBLEREAL DOUBLE

• The error function: 2/sqrt(pi)* integral from 0 to a of exp(-t*t) dt