Loading...
Searching...
No Matches
method

Definition

Provides properties and instance methods for the method class. This class is a wrapper for any procedure (subroutine or function).

Note
The procedures are stored a generic compunds procedure. The explicit interface can be enforced through the use of the caller property.

Examples

The following examples demonstrate some of the main members of the method.
This example shows how to set a caller explicitly. In the present case, the caller was necessary to specify the procedure interface explicitly. This is necessary when benchmarking a function rather than a subroutine.

use benchmark_string
use benchmark_library
use utility
implicit none
integer :: i
type(runner) :: br
type(string) :: s(3)
s(1) = 'abcdefghijklmnopqrstuvwxyz'
s(2) = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
s(3) = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' // &
'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.' // &
' Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris' // &
' nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in ' // &
'reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla '// &
'pariatur. Excepteur sint occaecat cupidatat non proident, sunt in ' // &
'culpa qui officia deserunt mollit anim id est laborum'
call br%set_caller(upper_caller)
do i = 1, 3
br%name = 'upper1'; call br%run(s(i), upper1)
br%name = 'upper2'; call br%run(s(i), upper2)
br%name = 'upper3'; call br%run(s(i), upper3)
end do
read(*,*)
subroutine upper_caller(f, a)
procedure(upper_x) :: f
type(string), intent(in) :: a
block
character(len(a)) :: res
res = f(a%chars)
end block
end subroutine

Remarks

At the moment, the method class handles procedures using up to 7 dummy arguments.

Constructors

Initializes a new instance of the method class

method(integer, procedure)

type(method) function method(integer nargs, procedure f)
Parameters
[in]nargsThe number of dummy arguments
fThe procedure

Examples

type(method) :: m
m = method(2, foo)

method(procedure, procedure)

type(method) function method(procedure f, procedure caller)
Parameters
fThe procedure pointer
callerThe caller wrapper

Examples

type(method) :: m
m = method(foo)

method(procedure, class(*), procedure)

type(method) function method(procedure f, class(*) a1, procedure caller)
Parameters
fThe procedure pointer
[in]a1The method argument
caller(optional) The caller wrapper

Examples

type(method) :: m
m = method(foo, arg(1, 'a1'))

method(procedure, class(*), class(*), procedure)

type(method) function method(procedure f, class(*) a1, class(*) a2, procedure caller)
Parameters
fThe procedure pointer
[in]a1The method argument
[in]a2The method argument
caller(optional) The caller wrapper

method(procedure, class(*), class(*), class(*), procedure)

type(method) function method(procedure f, class(*) a1, class(*) a2, class(*) a3, procedure caller)
Parameters
fThe procedure pointer
[in]a1The method argument
[in]a2The method argument
[in]a3The method argument
caller(optional) The caller wrapper

method(procedure, class(*), class(*), class(*), class(*), procedure)

type(method) function method(procedure f, class(*) a1, class(*) a2, class(*) a3, class(*) a4, procedure caller)
Parameters
fThe procedure pointer
[in]a1The method argument
[in]a2The method argument
[in]a3The method argument
[in]a4The method argument
caller(optional) The caller wrapper

method(procedure, class(*), class(*), class(*), class(*), class(*), procedure)

type(method) function method(procedure f, class(*) a1, class(*) a2, class(*) a3, class(*) a4, class(*) a5, procedure caller)
Parameters
fThe procedure pointer
[in]a1The method argument
[in]a2The method argument
[in]a3The method argument
[in]a4The method argument
[in]a5The method argument
caller(optional) The caller wrapper

method(procedure, class(*), class(*), class(*), class(*), class(*), class(*), procedure)

type(method) function method(procedure f, class(*) a1, class(*) a2, class(*) a3, class(*) a4, class(*) a5, class(*) a6, procedure caller)
Parameters
fThe procedure pointer
[in]a1The method argument
[in]a2The method argument
[in]a3The method argument
[in]a4The method argument
[in]a5The method argument
[in]a6The method argument
caller(optional) The caller wrapper

method(procedure, class(*), class(*), class(*), class(*), class(*), class(*), class(*), procedure)

type(method) function method(procedure f, class(*) a1, class(*) a2, class(*) a3, class(*) a4, class(*) a5, class(*) a6, class(*) a7, procedure caller)
Parameters
fThe procedure pointer
[in]a1The method argument
[in]a2The method argument
[in]a3The method argument
[in]a4The method argument
[in]a5The method argument
[in]a6The method argument
[in]a7The method argument
caller(optional) The caller wrapper

Remarks

Definition at line 141 of file Method.f90.


The documentation for this interface was generated from the following file:

Variables

integer, public nargs
 Number of dummy arguments.
type(arg), dimension(:), allocatable, public args
 Array of method arguments .

Static Public Attributes

procedure(), pointer, nopass f => null()
 Procedure pointer.
procedure(), pointer, nopass, public caller => null()
 Wrapper to call the procedure pointer. This provides a way to set the procedure interface explicitely.

Private Member Functions

procedure, pass, private invoke_a0 (this)
 Bound procedure to invoke a method.
procedure, pass, private invoke_a1 (this, a1)
 Bound procedure to invoke a method.
procedure, pass, private invoke_a2 (this, a1, a2)
 Bound procedure to invoke a method.
procedure, pass, private invoke_a3 (this, a1, a2, a3)
 Bound procedure to invoke a method.
procedure, pass, private invoke_a4 (this, a1, a2, a3, a4)
 Bound procedure to invoke a method.
procedure, pass, private invoke_a5 (this, a1, a2, a3, a4, a5)
 Bound procedure to invoke a method.
procedure, pass, private invoke_a6 (this, a1, a2, a3, a4, a5, a6)
 Bound procedure to invoke a method.
procedure, pass, private invoke_a7 (this, a1, a2, a3, a4, a5, a6, a7)
 Bound procedure to invoke a method.
procedure, pass, private method_assign_method (lhs, rhs)
 Assignment overloading. Assign a method to another method.

Methods

◆ assignment()

generic, public assignment ( class(method), intent(inout) lhs,
type(method), intent(in) rhs )

Assignment overloading. Assign a method to another method.

Parameters
[in,out]lhsThe target method
[in]rhsThe source method

Remarks

Definition at line 165 of file Method.f90.

◆ dispose()

procedure, pass, public dispose ( class(method), intent(inout) this)

Dispose resources associated with the bound type.

Parameters
[in,out]thisThe type bound to the method

Remarks

Definition at line 166 of file Method.f90.

◆ invoke() [1/8]

generic, public invoke ( class(method), intent(inout) this)

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method

Examples

type(method) :: mtd
mtd = method(f)
call mtd%invoke()

Remarks

Note
This function is either used with a 0-arguments method, or with any method whose arguments have been set in the constructor.

Remarks

Definition at line 156 of file Method.f90.

◆ invoke() [2/8]

generic, public invoke ( class(method), intent(inout) this,
class(*), intent(in) a1 )

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(1, f)
call mtd%invoke(arg(a1, 'a1'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'))
call mtd%invoke()

Remarks

Definition at line 156 of file Method.f90.

◆ invoke() [3/8]

generic, public invoke ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2 )

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(2, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'))
call mtd%invoke()

Remarks

Definition at line 156 of file Method.f90.

◆ invoke() [4/8]

generic, public invoke ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3 )

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(3, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'))
call mtd%invoke()

Remarks

Definition at line 156 of file Method.f90.

◆ invoke() [5/8]

generic, public invoke ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4 )

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument
[in]a4dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(4, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'))
call mtd%invoke()

Remarks

Definition at line 156 of file Method.f90.

◆ invoke() [6/8]

generic, public invoke ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5 )

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument
[in]a4dummy argument
[in]a5dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(5, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'))
call mtd%invoke()

Remarks

Definition at line 156 of file Method.f90.

◆ invoke() [7/8]

generic, public invoke ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5,
class(*), intent(in) a6 )

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument
[in]a4dummy argument
[in]a5dummy argument
[in]a6dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(6, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'), arg(a6, 'a6'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'), arg(a6, 'a6'))
call mtd%invoke()

Remarks

Definition at line 156 of file Method.f90.

◆ invoke() [8/8]

generic, public invoke ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5,
class(*), intent(in) a6,
class(*), intent(in) a7 )

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument
[in]a4dummy argument
[in]a5dummy argument
[in]a6dummy argument
[in]a7dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(7, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'), arg(a6, 'a6'), arg(a7, 'a7'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'), arg(a6, 'a6'), arg(a7, 'a7'))
call mtd%invoke()

Remarks

Definition at line 156 of file Method.f90.

◆ invoke_a0()

procedure, pass, private invoke_a0 ( class(method), intent(inout) this)
private

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method

Examples

type(method) :: mtd
mtd = method(f)
call mtd%invoke()

Remarks

Note
This function is either used with a 0-arguments method, or with any method whose arguments have been set in the constructor.

Remarks

Definition at line 148 of file Method.f90.

◆ invoke_a1()

procedure, pass, private invoke_a1 ( class(method), intent(inout) this,
class(*), intent(in) a1 )
private

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(1, f)
call mtd%invoke(arg(a1, 'a1'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'))
call mtd%invoke()

Remarks

Definition at line 149 of file Method.f90.

◆ invoke_a2()

procedure, pass, private invoke_a2 ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2 )
private

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(2, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'))
call mtd%invoke()

Remarks

Definition at line 150 of file Method.f90.

◆ invoke_a3()

procedure, pass, private invoke_a3 ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3 )
private

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(3, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'))
call mtd%invoke()

Remarks

Definition at line 151 of file Method.f90.

◆ invoke_a4()

procedure, pass, private invoke_a4 ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4 )
private

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument
[in]a4dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(4, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'))
call mtd%invoke()

Remarks

Definition at line 152 of file Method.f90.

◆ invoke_a5()

procedure, pass, private invoke_a5 ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5 )
private

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument
[in]a4dummy argument
[in]a5dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(5, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'))
call mtd%invoke()

Remarks

Definition at line 153 of file Method.f90.

◆ invoke_a6()

procedure, pass, private invoke_a6 ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5,
class(*), intent(in) a6 )
private

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument
[in]a4dummy argument
[in]a5dummy argument
[in]a6dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(6, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'), arg(a6, 'a6'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'), arg(a6, 'a6'))
call mtd%invoke()

Remarks

Definition at line 154 of file Method.f90.

◆ invoke_a7()

procedure, pass, private invoke_a7 ( class(method), intent(inout) this,
class(*), intent(in) a1,
class(*), intent(in) a2,
class(*), intent(in) a3,
class(*), intent(in) a4,
class(*), intent(in) a5,
class(*), intent(in) a6,
class(*), intent(in) a7 )
private

Bound procedure to invoke a method.

Parameters
[in]thisThe type bound to the method
[in]a1dummy argument
[in]a2dummy argument
[in]a3dummy argument
[in]a4dummy argument
[in]a5dummy argument
[in]a6dummy argument
[in]a7dummy argument

Examples

The first example demonstrate how to invoke the method by passing the arguments to the invoke procedure.

type(method) :: mtd
mtd = method(7, f)
call mtd%invoke(arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'), arg(a6, 'a6'), arg(a7, 'a7'))

Alternatively, on can also set the arguments directly from the method constructor.

type(method) :: mtd
mtd = method(f, arg(a1, 'a1'), arg(a2, 'a2'), arg(a3, 'a3'), &
arg(a4, 'a4'), arg(a5, 'a5'), arg(a6, 'a6'), arg(a7, 'a7'))
call mtd%invoke()

Remarks

Definition at line 155 of file Method.f90.

◆ method_assign_method()

procedure, pass, private method_assign_method ( class(method), intent(inout) lhs,
type(method), intent(in) rhs )
private

Assignment overloading. Assign a method to another method.

Parameters
[in,out]lhsThe target method
[in]rhsThe source method

Remarks

Definition at line 164 of file Method.f90.