Calculate the derivative of f w.r.t. R, Z - dfm(:,:,1) is deriv w.r.t. R - dfm(:,:,2) is deriv w.r.t. Z
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(abstract_eqfile_cart_geo_type), | intent(in) | :: | self | |||
real, | intent(in), | dimension(:,:) | :: | f | ||
real, | intent(out), | dimension(:,:,:) | :: | dfm | ||
character(len=1), | intent(in) | :: | char |
pure subroutine derm_cart(self, f, dfm, char)
use constants, only: pi
implicit none
class(abstract_eqfile_cart_geo_type), intent(in) :: self
real, dimension(:,:), intent(in) :: f
real, dimension(:,:,:), intent(out) :: dfm
character(1), intent(in) :: char
integer :: i, j, nw, nh
nw = self%nw ; nh = self%nh
i = 1
dfm(i,:,1) = -0.5 * (3 * f(i,:) - 4 * f(i+1,:) + f(i+2,:))
i = nw
dfm(i,:,1) = 0.5 * (3 * f(i,:) - 4 * f(i-1,:) + f(i-2,:))
j = 1
dfm(:,j,2) = -0.5 * (3 * f(:,j) - 4 * f(:,j+1) + f(:,j+2))
j = nh
dfm(:,j,2) = 0.5 * (3 * f(:,j)-4 * f(:,j-1) + f(:,j-2))
do i = 2, nw-1
dfm(i,:,1) = 0.5 * (f(i+1,:) - f(i-1,:))
end do
do j = 2, nh-1
dfm(:,j,2) = 0.5 * (f(:, j+1) - f(:, j-1))
end do
if (char == 'T') then !Could a similar approach be ported to derm_eqfile?
where(dfm(:, :, 2) > pi * 0.5)
dfm(:, :, 2) = dfm(:, :, 2) - pi
end where
end if
end subroutine derm_cart