Aschoolar
Aschoolar

Reputation: 355

gfortran if statement issue with array and logical scalar

I have the following partial code that gives me an issue,

module test_module
implicit none
contains

subroutine test(x, y)

! Input parameters:
real(8), intent(in) :: x(:), y(:)
real(8) :: ay, by, sigmay(size(x))


ay = 0.34
by = 0.82
sigmay = ay * abs(x)**by * (x > 0.0)

end subroutine test
end module test_module

I am getting error message in compilation due to real value operation on logical value. My fix attempt is as follows,

if (all(x(:)>(0.0:0.0)) then 
sigmay = ay * abs(x)**by *x
else
sigmay = 0.0
end if

After the fix, I am getting another error which I have no clue what causing it. Any ideas where I am doing wrong?

Error: Expected a right parenthesis in expression at (1)

it is pointing at zero after period. The first zeros in brackets.

Upvotes: 0

Views: 22

Answers (0)

Related Questions