Related Tags

fortran
communitycreator

# What are some intrinsic functions in Fortran?

okwudili onyejiaku

### Overview

There are some functions that are a part of the Fortran language. These functions are called intrinsic functions and include:

• Mathematical functions
• Array functions
• Logical functions
• Character functions, etc.

In order to make use of an intrinsic function, there are some things that need to be taken into consideration:

• The name and meaning of the function
• The argument(s) it takes
• The range of arguments(s) it takes
• The data type of the arguments
• The value it returns

### Common intrinsic functions in Fortran

Intrinsic functions Description
ABS(argument) Returns the absolute value of the argument
SQRT(argument) Returns the square root of the argument
COS (argument) Returns the cosine of the argument
EXP (argument) Returns the exponential value of the argument
REAL (argument) Converts the argument to REAL
MAX (argumen1, argument2,…,argumentn) Returns the maximum number out of all the arguments

### Code

Let’s use one of the intrinsic functions, SQRT(), to find the square root of a number.

program test_sqrt
real :: x = 4.00
complex :: z = (1.0, 2.0)
x = sqrt(x)
z = sqrt(z)

!print values of x and z
print *, x
print *, y
end program test_sqrt


In the code above:

• sqrt() computes the square root of the argument passed to it.
• The argument type should be non-negative REAL.
• The return value is of type REAL.

When the code above is run, the result will be as shown below:

2.00000000
0.00000000E+00


RELATED TAGS

fortran
communitycreator

CONTRIBUTOR

okwudili onyejiaku
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time 