WANtaroHP (Intrinsic functions in Fortran 95-08)

toJA

Outline of this page



Some functions in Fortran 95, 2003, 2008

CPU_TIME : CPU elapsed time in seconds (Fortran 95)

Description:

Class:

Subroutine

Syntax:

CALL CPU_TIME(TIME)

Arguments:

TIME : The type shall be REAL with INTENT(OUT).

Return value:

None

Example:

program test_cpu_time
real :: start, finish
call cpu_time(start)
! put code to test here
call cpu_time(finish)
print '("Time = ",f6.3," seconds.")',finish-start
end program test_cpu_time


COMMAND_ARGUMENT_COUNT : Get number of command line arguments (Fortran 2003)

Description:

COMMAND_ARGUMENT_COUNT returns the number of arguments passed on the command line when the containing program was invoked.

Class:

Inquiry function

Syntax:

RESULT = COMMAND_ARGUMENT_COUNT()

Arguments:

None

Return value:

The return value is an INTEGER of default kind.

Example:

program test_command_argument_count
integer :: count
count = command_argument_count()
print *, count
end program test_command_argument_count


GET_COMMAND_ARGUMENT : Get command line arguments (Fortran 2003)

Description:

Retrieve the NUMBER-th argument that was passed on the command line when the containing program was invoked.

Class:

Subroutine

Syntax:

CALL GET_COMMAND_ARGUMENT(NUMBER [, VALUE, LENGTH, STATUS])

Arguments:

Return value:

Example:

PROGRAM test_get_command_argument
INTEGER :: i
CHARACTER(len=32) :: arg
i = 0
DO
CALL get_command_argument(i, arg)
IF (LEN_TRIM(arg) == 0) EXIT
WRITE (*,*) TRIM(arg)
i = i+1
END DO
END PROGRAM


EXECUTE_COMMAND_LINE : Execute a shell command (Fortran 2008)

Description:

Class:

Subroutine

Syntax:

CALL EXECUTE_COMMAND_LINE(COMMAND [, WAIT, EXITSTAT, CMDSTAT,CMDMSG ])

Arguments:

Example:

program test_exec
integer :: i
call execute_command_line ("external_prog.exe", exitstat=i)
print *, "Exit status of external_prog.exe was ", i
call execute_command_line ("reindex_files.exe", wait=.false.)
print *, "Now reindexing files in the background"
end program test_exec

Note:



ACOSH : Inverse hyperbolic cosine function (Fortran 2008)

Description:

ACOSH(X) computes the inverse hyperbolic cosine of X.

Class:

Elemental function

Syntax:

RESULT = ACOSH(X)

Arguments:

X The type shall be REAL or COMPLEX.

Return value:

Example:

PROGRAM test_acosh
REAL(8), DIMENSION(3) :: x = (/ 1.0, 2.0, 3.0 /)
WRITE (*,*) ACOSH(x)
END PROGRAM


ASINH : Inverse hyperbolic sine function (Fortran 2008)

Description:

ASINH(X) computes the inverse hyperbolic sine of X.

Class:

Elemental function

Syntax:

RESULT = ASINH(X)

Arguments:

X The type shall be REAL or COMPLEX.

Return value:

Example:

PROGRAM test_asinh
REAL(8), DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
WRITE (*,*) ASINH(x)
END PROGRAM


ATANH : Inverse hyperbolic tangent function (Fortran 2008)

Description:

ATANH(X) computes the inverse hyperbolic tangent of X.

Class:

Elemental function

Syntax:

RESULT = ATANH(X)

Arguments:

X : The type shall be REAL or COMPLEX.

Return value:

Example:

PROGRAM test_atanh
REAL, DIMENSION(3) :: x = (/ -1.0, 0.0, 1.0 /)
WRITE (*,*) ATANH(x)
END PROGRAM


BESSEL_J0 : Bessel function of the first kind of order 0 (Fortran 2008)

Description:

BESSEL_J0(X) computes the Bessel function of the first kind of order 0 of X.

Class:

Elemental function

Syntax:

RESULT = BESSEL_J0(X)

Arguments:

X : The type shall be REAL, and it shall be scalar.

Return value:

The return value is of type REAL and lies in the range -0.4027... <= Bessel(0, x) <= 1. It has the same kind as X.

Example:

program test_besj0
real(8) :: x = 0.0_8
x = bessel_j0(x)
end program test_besj0


BESSEL_J1 : Bessel function of the first kind of order 1 (Fortran 2008)

Description:

BESSEL_J1(X) computes the Bessel function of the first kind of order 1 of X.

Class:

Elemental function

Syntax:

RESULT = BESSEL_J1(X)

Arguments:

X : The type shall be REAL, and it shall be scalar.

Return value:

The return value is of type REAL and it lies in the range -0.5818... <= Bessel(0, x) <= 0.5818. It has the same kind as X.

Example:

program test_besj1
real(8) :: x = 1.0_8
x = bessel_j1(x)
end program test_besj1


BESSEL_JN : Bessel function of the first kind (Fortran 2008)

Description:

Class:

Elemental function, except for the transformational function BESSEL_JN(N1,N2, X)

Syntax:

RESULT = BESSEL_JN(N, X)
RESULT = BESSEL_JN(N1, N2, X)

Arguments:

Return value:

The return value is a scalar of type REAL. It has the same kind as X.

Note: The transformational function uses a recurrence algorithm which might, for some values of X, lead to different results than calls to the elemental function.

Example:

program test_besjn
real(8) :: x = 1.0_8
x = bessel_jn(5,x)
end program test_besjn


BESSEL_Y0 : Bessel function of the second kind of order 0 (Fortran 2008)

Description:

BESSEL_Y0(X) computes the Bessel function of the second kind of order 0 of X.

Class:

Elemental function

Syntax:

 RESULT = BESSEL_Y0(X)

Arguments:

X The type shall be REAL, and it shall be scalar.

Return value:

The return value is a scalar of type REAL. It has the same kind as X.

Example:

program test_besy0
real(8) :: x = 0.0_8
x = bessel_y0(x)
end program test_besy0


BESSEL_Y1 : Bessel function of the second kind of order 1 (Fortran 2008)

Description:

BESSEL_Y1(X) computes the Bessel function of the second kind of order 1 of X.

Class:

Elemental function

Syntax:

 RESULT = BESSEL_Y1(X)

Arguments:

X The type shall be REAL, and it shall be scalar.

Return value:

The return value is a scalar of type REAL. It has the same kind as X.

Example:

program test_besy1
real(8) :: x = 1.0_8
x = bessel_y1(x)
end program test_besy1


BESSEL_YN : Bessel function of the second kind (Fortran 2008)

Description:

Class:

Elemental function, except for the transformational function BESSEL_YN(N1,N2, X)

Syntax:

RESULT = BESSEL_YN(N, X)
RESULT = BESSEL_YN(N1, N2, X)

Arguments:

Return value:

The return value is a scalar of type REAL. It has the same kind as X. Note: The transformational function uses a recurrence algorithm which might, for some values of X, lead to different results than calls to the elemental function.

Example:

program test_besyn
real(8) :: x = 1.0_8
x = bessel_yn(5,x)
end program test_besyn


GAMMA : Gamma function (Fortran 2008)

Description:

Class:

Elemental function

Syntax:

X = GAMMA(X)

Arguments:

X : Shall be of type REAL and neither zero nor a negative integer.

Return value:

The return value is of type REAL of the same kind as X.

Example:

program test_gamma
real :: x = 1.0
x = gamma(x) ! returns 1.0
end program test_gamma


LOG_GAMMA : Logarithm of the Gamma function (Fortran 2008)

Description:

LOG_GAMMA(X) computes the natural logarithm of the absolute value of the Gamma (Γ) function.

Class:

Elemental function

Syntax:

X = LOG_GAMMA(X)

Arguments:

X : Shall be of type REAL and neither zero nor a negative integer.

Return value:

The return value is of type REAL of the same kind as X.

Example:

program test_log_gamma
real :: x = 1.0
x = lgamma(x) ! returns 0.0
end program test_log_gamma


toJA
inserted by FC2 system