Hi,
I need use flag variables for intensive use in user defined types, but I'm not sure about the faster way for this. I'm considering two posibilities. The first one is use directly logical variables, as follow:
type node_t
....
logical(1), dimension(4) :: flag
...
end type
integer, parameter :: ACTIVE = 1
and the use is:
subroutine foo( node, ... )
type(node_t), intent(in) :: node
....
if( node%flag(ACTIVE) ) then
... do something ...
end if
....
end subroutine foo
The second possibility is use bit intrinsic function, with integer variables:
type node_t
....
integer(1) :: flag
...
end type
integer(1), parameter :: ACTIVE
with:
subroutine foo( node, ... )
type(node_t), intent(in) :: node
....
if( btest(node%flag,ACTIVE) ) then
... do something ...
end if
....
end subroutine foo
Someone can say something about the better way for this,
in order to obtain a good performance, I will really appreciated.
thanks
I need use flag variables for intensive use in user defined types, but I'm not sure about the faster way for this. I'm considering two posibilities. The first one is use directly logical variables, as follow:
type node_t
....
logical(1), dimension(4) :: flag
...
end type
integer, parameter :: ACTIVE = 1
and the use is:
subroutine foo( node, ... )
type(node_t), intent(in) :: node
....
if( node%flag(ACTIVE) ) then
... do something ...
end if
....
end subroutine foo
The second possibility is use bit intrinsic function, with integer variables:
type node_t
....
integer(1) :: flag
...
end type
integer(1), parameter :: ACTIVE
with:
subroutine foo( node, ... )
type(node_t), intent(in) :: node
....
if( btest(node%flag,ACTIVE) ) then
... do something ...
end if
....
end subroutine foo
Someone can say something about the better way for this,
in order to obtain a good performance, I will really appreciated.
thanks