Fortran Intrinsic Functions Tutorialspoint
Fortran Intrinsic Functions Tutorialspoint
Intrinsic functions are some common and important functions that are provided as a part of the
Fortran language. We have already discussed some of these functions in the Arrays, Characters
and String chapters.
Intrinsic functions can be categorised as −
Numeric Functions
Mathematical Functions
Numeric Inquiry Functions
Floating-Point Manipulation Functions
Bit Manipulation Functions
Character Functions
Kind Functions
Logical Functions
Array Functions.
We have discussed the array functions in the Arrays chapter. In the following section we provide
brief descriptions of all these functions from other categories.
In the function name column,
A represents any type of numeric variable
R represents a real or integer variable
X and Y represent real variables
Z represents complex variable
W represents real or complex variable
Numeric Functions
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 1/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
1
ABS (A)
It returns the absolute value of A
2
AIMAG (Z)
It returns the imaginary part of a complex number Z
3 AINT (A [, KIND])
It truncates fractional part of A towards zero, returning a real, whole number.
4
ANINT (A [, KIND])
It returns a real value, the nearest integer or whole number.
5 CEILING (A [, KIND])
6
CMPLX (X [, Y, KIND])
It converts the real variables X and Y to a complex number X+iY; if Y is absent, 0 is
used.
7
CONJG (Z)
It returns the complex conjugate of any complex number Z.
8 DBLE (A)
9 DIM (X, Y)
10 DPROD (X, Y)
11
FLOOR (A [, KIND])
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 2/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
12 INT (A [, KIND])
It converts a number (real or integer) to integer, truncating the real part towards zero.
It returns the maximum value from the arguments, all being of same type.
14
MIN (A1, A2 [, A3,...])
It returns the minimum value from the arguments, all being of same type.
15
MOD (A, P)
It returns the remainder of A on division by P, both arguments being of the same type (A-
INT(A/P)*P)
16 MODULO (A, P)
17 NINT (A [, KIND])
18 REAL (A [, KIND])
19
SIGN (A, B)
It returns the absolute value of A multiplied by the sign of P. Basically it transfers the of
sign of B to A.
Example
Live Demo
program numericFunctions
implicit none
! define constants
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 3/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
! define variables
real :: a, b
complex :: z
! values for a, b
a = 15.2345
b = -20.7689
z = cmplx(a, b)
write(*,*) 'z: ',z
When you compile and execute the above program, it produces the following result −
Mathematical Functions
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 4/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
1
ACOS (X)
It returns the inverse cosine in the range (0, π), in radians.
2
ASIN (X)
It returns the inverse sine in the range (-π/2, π/2), in radians.
3 ATAN (X)
It returns the inverse tangent in the range (-π/2, π/2), in radians.
4 ATAN2 (Y, X)
5 COS (X)
6 COSH (X)
7 EXP (X)
8 LOG (X)
9 LOG10 (X)
10 SIN (X)
11 SINH (X)
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 5/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
12 SQRT (X)
13 TAN (X)
14 TANH (X)
Example
The following program computes the horizontal and vertical position x and y respectively of a
projectile after a time, t −
Live Demo
program projectileMotion
implicit none
! define constants
real, parameter :: g = 9.8
real, parameter :: pi = 3.1415927
!define variables
real :: a, t, u, x, y
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 6/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
When you compile and execute the above program, it produces the following result −
x: 141.421356 y: -1818.57861
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 7/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
1 DIGITS (X)
It returns the number of significant digits of the model.
2 EPSILON (X)
It returns the number that is almost negligible compared to one. In other words, it returns
the smallest value such that REAL( 1.0, KIND(X)) + EPSILON(X) is not equal to REAL(
1.0, KIND(X)).
3 HUGE (X)
It returns the largest number of the model
4 MAXEXPONENT (X)
It returns the maximum exponent of the model
5 MINEXPONENT (X)
It returns the minimum exponent of the model
6 PRECISION (X)
It returns the decimal precision
7 RADIX (X)
It returns the base of the model
8 RANGE (X)
It returns the decimal exponent range
9 TINY (X)
It returns the smallest positive number of the model
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 8/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
1 EXPONENT (X)
It returns the exponent part of a model number
2 FRACTION (X)
It returns the fractional part of a number
3 NEAREST (X, S)
It returns the nearest different processor number in given direction
4 RRSPACING (X)
It returns the reciprocal of the relative spacing of model numbers near given number
5 SCALE (X, I)
It multiplies a real by its base to an integer power
6 SET_EXPONENT (X, I)
it returns the exponent part of a number
7 SPACING (X)
It returns the absolute spacing of model numbers near given number
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 9/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
1 BIT_SIZE (I)
Bit testing
3 IAND (I, J)
Logical AND
Clear bit
Bit extraction
Set bit
7
IEOR (I, J)
Exclusive OR
8
IOR (I, J)
Inclusive OR
11 NOT (I)
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 10/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
Logical complement
Character Functions
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 11/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
1 ACHAR (I)
2 ADJUSTL (STRING)
It adjusts string left by removing any leading blanks and inserting trailing blanks
3 ADJUSTR (STRING)
It adjusts string right by removing trailing blanks and inserting leading blanks.
4 CHAR (I [, KIND])
5 IACHAR (C)
It returns the position of the character in the ASCII collating sequence.
6 ICHAR (C)
It returns the position of the character in the machine (processor) specific collating
sequence.
8 LEN (STRING)
It returns the length of a string.
9 LEN_TRIM (STRING)
It returns the length of a string without trailing blank characters.
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 12/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
16 TRIM (STRING)
Removes trailing blank characters
Kind Functions
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 13/14
2/21/2021 Fortran - Intrinsic Functions - Tutorialspoint
1 KIND (X)
2 SELECTED_INT_KIND (R)
It returns kind of type parameter for specified exponent range.
Logical Function
1 LOGICAL (L [, KIND])
Convert between objects of type logical with different kind type parameters
https://www.tutorialspoint.com/fortran/fortran_intrinsic_functions.htm 14/14