Loading...
Searching...
No Matches
method Module Reference

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 explicitely. In the present case, the caller was necessary to specify the procedure interface explicitely. 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 173 of file Method.f90.


The documentation for this module 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.
 

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 168 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 169 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 159 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 159 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 159 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 159 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 159 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 159 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 159 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 159 of file Method.f90.

Finalizer

◆ finalize()

final finalize ( type(method), intent(inout) this)
final

Definition at line 170 of file Method.f90.