I have to following subroutine:
SUBROUTINE matprod(nkval, matrix, tkval, field)
implicit none
integer, allocatable, intent(in) :: matrix(:,:,:)
real, allocatable, intent(inout) :: tkval(:,:,:)
real, allocatable, intent(in) :: nkval(:,:)
integer, intent(in) ::field
integer :: temp, i, j
allocate(tkval(field,size(matrix,dim=1),3))
temp=size(matrix,dim=1)
do i=1,field
do j=1,temp
tkval(i,j,:)=matmul(matrix(j,:,:),nkval(:,i))
if (tkval(i,j,1).eq.-0.5) then
tkval(i,j,1)=0.5
endif
if (tkval(i,j,2).eq.-0.5) then
tkval(i,j,2)=0.5
endif
if (tkval(i,j,3).eq.-0.5) then
tkval(i,j,3)=0.5
endif
enddo
enddo
END SUBROUTINE matprod
Where afer matrix multiplication i have a set of 3d points, which i know for a fact contain '-0.5' and i want to catch those and turn them into positive 0.5. For some reason, my if statements don't see those. Why?
here is the output sample of "tkval" with the J counter displayed:
1
0.2500000 0.7499999 0.7499999
2
0.2500000 0.7499999 0.7499999
3
0.7499999 0.2500000 0.7499999
4
0.7499999 0.7499999 0.2500000
5
0.7499999 0.2500000 0.7499999
6
0.7499999 0.7499999 0.2500000
7
-0.5000000 0.0000000 -0.7499999
8
-0.5000000 -0.7499999 0.0000000
9
0.0000000 -0.5000000 -0.7499999
10
0.0000000 -0.7499999 -0.5000000
11
-0.5000000 0.0000000 -0.7499999
12
-0.5000000 -0.7499999 0.0000000
13
0.5000000 0.5000000 -0.2500000
14
0.5000000 -0.2500000 0.5000000
15
0.0000000 -0.5000000 -0.7499999
16
0.0000000 -0.7499999 -0.5000000
17
0.5000000 0.5000000 -0.2500000
18
0.5000000 -0.2500000 0.5000000
So this is one way that i thought of to solve my problem: