There are some functions that are a part of the Fortran language. These functions are called intrinsic functions and include:
In order to make use of an intrinsic function, there are some things that need to be taken into consideration:
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 |
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.When the code above is run, the result will be as shown below:
2.00000000
0.00000000E+00
RELATED TAGS
CONTRIBUTOR
View all Courses