mirror of
https://github.com/sfilippone/psblas3.git
synced 2026-10-19 04:12:09 +00:00
Added generation of mask vector for constraint tests psb_mask
This commit is contained in:
@@ -523,4 +523,5 @@ module psb_c_psblas_mod
|
||||
end subroutine psb_ccmp_vect
|
||||
end interface
|
||||
|
||||
|
||||
end module psb_c_psblas_mod
|
||||
|
||||
@@ -523,4 +523,17 @@ module psb_d_psblas_mod
|
||||
end subroutine psb_dcmp_vect
|
||||
end interface
|
||||
|
||||
interface psb_mask
|
||||
subroutine psb_dmask_vect(c,x,m,t,desc_a,info)
|
||||
import :: psb_desc_type, psb_ipk_, &
|
||||
& psb_d_vect_type, psb_dpk_
|
||||
type(psb_d_vect_type), intent (inout) :: c
|
||||
type(psb_d_vect_type), intent (inout) :: x
|
||||
type(psb_d_vect_type), intent (inout) :: m
|
||||
logical, intent(out) :: t
|
||||
type(psb_desc_type), intent (in) :: desc_a
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
end subroutine psb_dmask_vect
|
||||
end interface
|
||||
|
||||
end module psb_d_psblas_mod
|
||||
|
||||
@@ -523,4 +523,17 @@ module psb_s_psblas_mod
|
||||
end subroutine psb_scmp_vect
|
||||
end interface
|
||||
|
||||
interface psb_mask
|
||||
subroutine psb_smask_vect(c,x,m,t,desc_a,info)
|
||||
import :: psb_desc_type, psb_ipk_, &
|
||||
& psb_s_vect_type, psb_spk_
|
||||
type(psb_s_vect_type), intent (inout) :: c
|
||||
type(psb_s_vect_type), intent (inout) :: x
|
||||
type(psb_s_vect_type), intent (inout) :: m
|
||||
logical, intent(out) :: t
|
||||
type(psb_desc_type), intent (in) :: desc_a
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
end subroutine psb_smask_vect
|
||||
end interface
|
||||
|
||||
end module psb_s_psblas_mod
|
||||
|
||||
@@ -523,4 +523,5 @@ module psb_z_psblas_mod
|
||||
end subroutine psb_zcmp_vect
|
||||
end interface
|
||||
|
||||
|
||||
end module psb_z_psblas_mod
|
||||
|
||||
@@ -194,6 +194,7 @@ module psb_c_base_vect_mod
|
||||
procedure, pass(z) :: acmp_v2 => c_base_acmp_v2
|
||||
generic, public :: acmp => acmp_a2,acmp_v2
|
||||
|
||||
|
||||
end type psb_c_base_vect_type
|
||||
|
||||
public :: psb_c_base_vect
|
||||
@@ -1718,6 +1719,7 @@ contains
|
||||
|
||||
end subroutine c_base_sctb_buf
|
||||
|
||||
|
||||
end module psb_c_base_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ module psb_c_vect_mod
|
||||
procedure, pass(z) :: acmp_v2 => c_vect_acmp_v2
|
||||
generic, public :: acmp => acmp_a2, acmp_v2
|
||||
|
||||
|
||||
end type psb_c_vect_type
|
||||
|
||||
public :: psb_c_vect
|
||||
@@ -1002,6 +1003,7 @@ contains
|
||||
end function c_vect_asum
|
||||
|
||||
|
||||
|
||||
end module psb_c_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -194,6 +194,10 @@ module psb_d_base_vect_mod
|
||||
procedure, pass(z) :: acmp_v2 => d_base_acmp_v2
|
||||
generic, public :: acmp => acmp_a2,acmp_v2
|
||||
|
||||
procedure, pass(m) :: mask_v => d_base_mask_v
|
||||
procedure, pass(m) :: mask_a => d_base_mask_a
|
||||
generic, public :: mask => mask_a, mask_v
|
||||
|
||||
end type psb_d_base_vect_type
|
||||
|
||||
public :: psb_d_base_vect
|
||||
@@ -1718,6 +1722,99 @@ contains
|
||||
|
||||
end subroutine d_base_sctb_buf
|
||||
|
||||
!
|
||||
!> Function base_mask_a
|
||||
!! \memberof psb_d_base_vect_type
|
||||
!! \brief Peform constraint tests looking at the value of c
|
||||
!! \param x The array to be compared
|
||||
!! \param c The array containing the information on the type of test to be
|
||||
!! performed, if c(i) = 2 ">0", if c(i) = 1 ">=0", if c(i) = 0 no test, if
|
||||
!! c(i) =-1 "<=0", if c(i) = -2 "< 0"
|
||||
!! \param m The vector containing the result of the comparison 1.0 for a
|
||||
!! failed test, and 0.0 for a passed one.
|
||||
!! \param t logical resulting from an and operation on all the tests
|
||||
!! \param info return code
|
||||
!
|
||||
subroutine d_base_mask_a(c,x,m,t,info)
|
||||
use psi_serial_mod
|
||||
implicit none
|
||||
real(psb_dpk_), intent(inout) :: c(:)
|
||||
real(psb_dpk_), intent(inout) :: x(:)
|
||||
class(psb_d_base_vect_type), intent(inout) :: m
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
logical, intent(out) :: t
|
||||
integer(psb_ipk_) :: i, n
|
||||
|
||||
if (m%is_dev()) call m%sync()
|
||||
t = .true.
|
||||
|
||||
n = size(x)
|
||||
do i = 1, n, 1
|
||||
if (c(i).eq.2_psb_dpk_) then
|
||||
if ( x(i) > dzero ) then
|
||||
m%v(i) = 0_psb_dpk_
|
||||
else
|
||||
m%v(i) = 1_psb_dpk_
|
||||
t = .false.
|
||||
end if
|
||||
elseif (c(i).eq.1_psb_dpk_) then
|
||||
if ( x(i) >= dzero ) then
|
||||
m%v(i) = 0_psb_dpk_
|
||||
else
|
||||
m%v(i) = 1_psb_dpk_
|
||||
t = .false.
|
||||
end if
|
||||
elseif (c(i).eq.-1_psb_dpk_) then
|
||||
if ( x(i) <= dzero ) then
|
||||
m%v(i) = 0_psb_dpk_
|
||||
else
|
||||
m%v(i) = 1_psb_dpk_
|
||||
t = .false.
|
||||
end if
|
||||
elseif (c(i).eq.-2_psb_dpk_) then
|
||||
if ( x(i) < dzero ) then
|
||||
m%v(i) = 0_psb_dpk_
|
||||
else
|
||||
m%v(i) = 1_psb_dpk_
|
||||
t = .false.
|
||||
end if
|
||||
else
|
||||
m%v(i) = 0_psb_dpk_
|
||||
end if
|
||||
end do
|
||||
info = 0
|
||||
|
||||
end subroutine d_base_mask_a
|
||||
!
|
||||
!> Function base_mask_v
|
||||
!! \memberof psb_d_base_vect_type
|
||||
!! \brief Peform constraint tests looking at the value of c
|
||||
!! \param x The vector to be compared
|
||||
!! \param c The vector containing the information on the type of test to be
|
||||
!! performed, if c(i) = 2 ">0", if c(i) = 1 ">=0", if c(i) = 0 no test, if
|
||||
!! c(i) =-1 "<=0", if c(i) = -2 "< 0"
|
||||
!! \param m The vector containing the result of the comparison 1.0 for a
|
||||
!! failed test, and 0.0 for a passed one.
|
||||
!! \param t logical resulting from an and operation on all the tests
|
||||
!! \param info return code
|
||||
!
|
||||
subroutine d_base_mask_v(c,x,m,t,info)
|
||||
use psi_serial_mod
|
||||
implicit none
|
||||
class(psb_d_base_vect_type), intent(inout) :: c
|
||||
class(psb_d_base_vect_type), intent(inout) :: x
|
||||
class(psb_d_base_vect_type), intent(inout) :: m
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
logical, intent(out) :: t
|
||||
|
||||
info = 0
|
||||
if (x%is_dev()) call x%sync()
|
||||
if (c%is_dev()) call c%sync()
|
||||
|
||||
call m%mask(x%v,c%v,t,info)
|
||||
end subroutine d_base_mask_v
|
||||
|
||||
|
||||
end module psb_d_base_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -118,6 +118,10 @@ module psb_d_vect_mod
|
||||
procedure, pass(z) :: acmp_v2 => d_vect_acmp_v2
|
||||
generic, public :: acmp => acmp_a2, acmp_v2
|
||||
|
||||
procedure, pass(m) :: mask_v => d_vect_mask_v
|
||||
procedure, pass(m) :: mask_a => d_vect_mask_a
|
||||
generic, public :: mask => mask_a, mask_v
|
||||
|
||||
end type psb_d_vect_type
|
||||
|
||||
public :: psb_d_vect
|
||||
@@ -1002,6 +1006,36 @@ contains
|
||||
end function d_vect_asum
|
||||
|
||||
|
||||
subroutine d_vect_mask_a(c,x,m,t,info)
|
||||
use psi_serial_mod
|
||||
implicit none
|
||||
real(psb_dpk_), intent(inout) :: c(:)
|
||||
real(psb_dpk_), intent(inout) :: x(:)
|
||||
logical, intent(out) :: t;
|
||||
class(psb_d_vect_type), intent(inout) :: m
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
|
||||
info = 0
|
||||
if (allocated(m%v)) &
|
||||
& call m%mask(c,x,t,info)
|
||||
|
||||
end subroutine d_vect_mask_a
|
||||
|
||||
subroutine d_vect_mask_v(c,x,m,t,info)
|
||||
use psi_serial_mod
|
||||
implicit none
|
||||
class(psb_d_vect_type), intent(inout) :: c
|
||||
class(psb_d_vect_type), intent(inout) :: x
|
||||
class(psb_d_vect_type), intent(inout) :: m
|
||||
logical, intent(out) :: t;
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
|
||||
info = 0
|
||||
if (allocated(x%v).and.allocated(c%v)) &
|
||||
& call m%v%mask(x%v,c%v,t,info)
|
||||
|
||||
end subroutine d_vect_mask_v
|
||||
|
||||
end module psb_d_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ module psb_i_base_vect_mod
|
||||
|
||||
|
||||
|
||||
|
||||
end type psb_i_base_vect_type
|
||||
|
||||
public :: psb_i_base_vect
|
||||
@@ -974,6 +975,7 @@ contains
|
||||
|
||||
end subroutine i_base_sctb_buf
|
||||
|
||||
|
||||
end module psb_i_base_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ module psb_i_vect_mod
|
||||
procedure, pass(x) :: set_sync => i_vect_set_sync
|
||||
|
||||
|
||||
|
||||
end type psb_i_vect_type
|
||||
|
||||
public :: psb_i_vect
|
||||
@@ -551,6 +552,7 @@ contains
|
||||
end function i_vect_is_dev
|
||||
|
||||
|
||||
|
||||
end module psb_i_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -144,6 +144,7 @@ module psb_l_base_vect_mod
|
||||
|
||||
|
||||
|
||||
|
||||
end type psb_l_base_vect_type
|
||||
|
||||
public :: psb_l_base_vect
|
||||
@@ -975,6 +976,7 @@ contains
|
||||
|
||||
end subroutine l_base_sctb_buf
|
||||
|
||||
|
||||
end module psb_l_base_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ module psb_l_vect_mod
|
||||
procedure, pass(x) :: set_sync => l_vect_set_sync
|
||||
|
||||
|
||||
|
||||
end type psb_l_vect_type
|
||||
|
||||
public :: psb_l_vect
|
||||
@@ -552,6 +553,7 @@ contains
|
||||
end function l_vect_is_dev
|
||||
|
||||
|
||||
|
||||
end module psb_l_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -194,6 +194,10 @@ module psb_s_base_vect_mod
|
||||
procedure, pass(z) :: acmp_v2 => s_base_acmp_v2
|
||||
generic, public :: acmp => acmp_a2,acmp_v2
|
||||
|
||||
procedure, pass(m) :: mask_v => s_base_mask_v
|
||||
procedure, pass(m) :: mask_a => s_base_mask_a
|
||||
generic, public :: mask => mask_a, mask_v
|
||||
|
||||
end type psb_s_base_vect_type
|
||||
|
||||
public :: psb_s_base_vect
|
||||
@@ -1718,6 +1722,99 @@ contains
|
||||
|
||||
end subroutine s_base_sctb_buf
|
||||
|
||||
!
|
||||
!> Function base_mask_a
|
||||
!! \memberof psb_s_base_vect_type
|
||||
!! \brief Peform constraint tests looking at the value of c
|
||||
!! \param x The array to be compared
|
||||
!! \param c The array containing the information on the type of test to be
|
||||
!! performed, if c(i) = 2 ">0", if c(i) = 1 ">=0", if c(i) = 0 no test, if
|
||||
!! c(i) =-1 "<=0", if c(i) = -2 "< 0"
|
||||
!! \param m The vector containing the result of the comparison 1.0 for a
|
||||
!! failed test, and 0.0 for a passed one.
|
||||
!! \param t logical resulting from an and operation on all the tests
|
||||
!! \param info return code
|
||||
!
|
||||
subroutine s_base_mask_a(c,x,m,t,info)
|
||||
use psi_serial_mod
|
||||
implicit none
|
||||
real(psb_spk_), intent(inout) :: c(:)
|
||||
real(psb_spk_), intent(inout) :: x(:)
|
||||
class(psb_s_base_vect_type), intent(inout) :: m
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
logical, intent(out) :: t
|
||||
integer(psb_ipk_) :: i, n
|
||||
|
||||
if (m%is_dev()) call m%sync()
|
||||
t = .true.
|
||||
|
||||
n = size(x)
|
||||
do i = 1, n, 1
|
||||
if (c(i).eq.2_psb_spk_) then
|
||||
if ( x(i) > szero ) then
|
||||
m%v(i) = 0_psb_spk_
|
||||
else
|
||||
m%v(i) = 1_psb_spk_
|
||||
t = .false.
|
||||
end if
|
||||
elseif (c(i).eq.1_psb_spk_) then
|
||||
if ( x(i) >= szero ) then
|
||||
m%v(i) = 0_psb_spk_
|
||||
else
|
||||
m%v(i) = 1_psb_spk_
|
||||
t = .false.
|
||||
end if
|
||||
elseif (c(i).eq.-1_psb_spk_) then
|
||||
if ( x(i) <= szero ) then
|
||||
m%v(i) = 0_psb_spk_
|
||||
else
|
||||
m%v(i) = 1_psb_spk_
|
||||
t = .false.
|
||||
end if
|
||||
elseif (c(i).eq.-2_psb_spk_) then
|
||||
if ( x(i) < szero ) then
|
||||
m%v(i) = 0_psb_spk_
|
||||
else
|
||||
m%v(i) = 1_psb_spk_
|
||||
t = .false.
|
||||
end if
|
||||
else
|
||||
m%v(i) = 0_psb_spk_
|
||||
end if
|
||||
end do
|
||||
info = 0
|
||||
|
||||
end subroutine s_base_mask_a
|
||||
!
|
||||
!> Function base_mask_v
|
||||
!! \memberof psb_s_base_vect_type
|
||||
!! \brief Peform constraint tests looking at the value of c
|
||||
!! \param x The vector to be compared
|
||||
!! \param c The vector containing the information on the type of test to be
|
||||
!! performed, if c(i) = 2 ">0", if c(i) = 1 ">=0", if c(i) = 0 no test, if
|
||||
!! c(i) =-1 "<=0", if c(i) = -2 "< 0"
|
||||
!! \param m The vector containing the result of the comparison 1.0 for a
|
||||
!! failed test, and 0.0 for a passed one.
|
||||
!! \param t logical resulting from an and operation on all the tests
|
||||
!! \param info return code
|
||||
!
|
||||
subroutine s_base_mask_v(c,x,m,t,info)
|
||||
use psi_serial_mod
|
||||
implicit none
|
||||
class(psb_s_base_vect_type), intent(inout) :: c
|
||||
class(psb_s_base_vect_type), intent(inout) :: x
|
||||
class(psb_s_base_vect_type), intent(inout) :: m
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
logical, intent(out) :: t
|
||||
|
||||
info = 0
|
||||
if (x%is_dev()) call x%sync()
|
||||
if (c%is_dev()) call c%sync()
|
||||
|
||||
call m%mask(x%v,c%v,t,info)
|
||||
end subroutine s_base_mask_v
|
||||
|
||||
|
||||
end module psb_s_base_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -118,6 +118,10 @@ module psb_s_vect_mod
|
||||
procedure, pass(z) :: acmp_v2 => s_vect_acmp_v2
|
||||
generic, public :: acmp => acmp_a2, acmp_v2
|
||||
|
||||
procedure, pass(m) :: mask_v => s_vect_mask_v
|
||||
procedure, pass(m) :: mask_a => s_vect_mask_a
|
||||
generic, public :: mask => mask_a, mask_v
|
||||
|
||||
end type psb_s_vect_type
|
||||
|
||||
public :: psb_s_vect
|
||||
@@ -1002,6 +1006,36 @@ contains
|
||||
end function s_vect_asum
|
||||
|
||||
|
||||
subroutine s_vect_mask_a(c,x,m,t,info)
|
||||
use psi_serial_mod
|
||||
implicit none
|
||||
real(psb_spk_), intent(inout) :: c(:)
|
||||
real(psb_spk_), intent(inout) :: x(:)
|
||||
logical, intent(out) :: t;
|
||||
class(psb_s_vect_type), intent(inout) :: m
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
|
||||
info = 0
|
||||
if (allocated(m%v)) &
|
||||
& call m%mask(c,x,t,info)
|
||||
|
||||
end subroutine s_vect_mask_a
|
||||
|
||||
subroutine s_vect_mask_v(c,x,m,t,info)
|
||||
use psi_serial_mod
|
||||
implicit none
|
||||
class(psb_s_vect_type), intent(inout) :: c
|
||||
class(psb_s_vect_type), intent(inout) :: x
|
||||
class(psb_s_vect_type), intent(inout) :: m
|
||||
logical, intent(out) :: t;
|
||||
integer(psb_ipk_), intent(out) :: info
|
||||
|
||||
info = 0
|
||||
if (allocated(x%v).and.allocated(c%v)) &
|
||||
& call m%v%mask(x%v,c%v,t,info)
|
||||
|
||||
end subroutine s_vect_mask_v
|
||||
|
||||
end module psb_s_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -194,6 +194,7 @@ module psb_z_base_vect_mod
|
||||
procedure, pass(z) :: acmp_v2 => z_base_acmp_v2
|
||||
generic, public :: acmp => acmp_a2,acmp_v2
|
||||
|
||||
|
||||
end type psb_z_base_vect_type
|
||||
|
||||
public :: psb_z_base_vect
|
||||
@@ -1718,6 +1719,7 @@ contains
|
||||
|
||||
end subroutine z_base_sctb_buf
|
||||
|
||||
|
||||
end module psb_z_base_vect_mod
|
||||
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ module psb_z_vect_mod
|
||||
procedure, pass(z) :: acmp_v2 => z_vect_acmp_v2
|
||||
generic, public :: acmp => acmp_a2, acmp_v2
|
||||
|
||||
|
||||
end type psb_z_vect_type
|
||||
|
||||
public :: psb_z_vect
|
||||
@@ -1002,6 +1003,7 @@ contains
|
||||
end function z_vect_asum
|
||||
|
||||
|
||||
|
||||
end module psb_z_vect_mod
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user