279 lines
5 KiB
Fortran
279 lines
5 KiB
Fortran
module m_calculate
|
|
|
|
use Compact
|
|
use m_parameters
|
|
|
|
implicit none
|
|
|
|
real*8, allocatable, dimension(:,:) :: xsrc
|
|
real*8, allocatable, dimension(:,:) :: xdst
|
|
|
|
real*8, allocatable, dimension(:,:) :: rsrc
|
|
real*8, allocatable, dimension(:,:) :: rdst
|
|
|
|
integer, parameter :: nb = BLOCKSIZE
|
|
|
|
private :: nb
|
|
private :: xsrc, xdst, rsrc, rdst
|
|
|
|
contains
|
|
|
|
subroutine m_calculate_init
|
|
|
|
integer :: ierr
|
|
|
|
call ludcmp(nxp,nyp,nzp,1,0,0) ! 1,1,0
|
|
|
|
allocate(xsrc(nb, nxp), stat=ierr)
|
|
allocate(xdst(nb, nxp), stat=ierr)
|
|
|
|
allocate(rsrc(nxp, nzp), stat=ierr)
|
|
allocate(rdst(nxp, nzp), stat=ierr)
|
|
|
|
end subroutine m_calculate_init
|
|
|
|
|
|
subroutine m_calculate_finalize
|
|
|
|
deallocate(xsrc)
|
|
deallocate(xdst)
|
|
|
|
deallocate(rsrc)
|
|
deallocate(rdst)
|
|
|
|
end subroutine m_calculate_finalize
|
|
|
|
|
|
subroutine ddx(dst, src)
|
|
|
|
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
|
|
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
|
|
|
|
integer :: i, j ,k
|
|
integer :: ju
|
|
|
|
|
|
do k = 1,nzp
|
|
do j = 1,nyp,nb
|
|
|
|
ju = min(j+nb-1,nyp)
|
|
|
|
call tp2(xsrc, src(:,j:ju,k), nb, nxp)
|
|
|
|
call dfnonp(nxp, hxp, xsrc, xdst, nb, 1)
|
|
|
|
call tp2(dst(:,j:ju,k), xdst, nxp, nb)
|
|
|
|
end do
|
|
end do
|
|
|
|
end subroutine ddx
|
|
|
|
|
|
subroutine ddy(dst, src)
|
|
|
|
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
|
|
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
|
|
|
|
integer :: i, j ,k
|
|
|
|
|
|
do k = 1,nzp
|
|
|
|
call dfp(nyp, hyp, src(:,:,k), dst(:,:,k), nxp, 2)
|
|
|
|
end do
|
|
|
|
end subroutine ddy
|
|
|
|
|
|
subroutine ddz(dst, src)
|
|
|
|
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
|
|
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
|
|
|
|
integer :: i, j ,k
|
|
|
|
do j = 1,nyp
|
|
|
|
do k = 1,nzp
|
|
rsrc(:,k) = src(:,j,k)
|
|
end do
|
|
|
|
call dfp(nzp, hzp, rsrc, rdst, nxp, 3)
|
|
|
|
do k = 1,nzp
|
|
dst(:,j,k) = rdst(:,k)
|
|
end do
|
|
|
|
end do
|
|
|
|
end subroutine ddz
|
|
|
|
|
|
subroutine d2dx(dst, src)
|
|
|
|
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
|
|
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
|
|
|
|
integer :: i, j ,k
|
|
integer :: ju
|
|
|
|
|
|
do k = 1,nzp
|
|
do j = 1,nyp,nb
|
|
|
|
ju = min(j+nb-1,nyp)
|
|
|
|
call tp2(xsrc, src(:,j:ju,k), nb, nxp)
|
|
|
|
call d2fnonp(nxp, hxp, xsrc, xdst, nb, 1)
|
|
|
|
call tp2(dst(:,j:ju,k), xdst, nxp, nb)
|
|
|
|
end do
|
|
end do
|
|
|
|
end subroutine d2dx
|
|
|
|
|
|
subroutine d2dy(dst, src)
|
|
|
|
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
|
|
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
|
|
|
|
integer :: i, j ,k
|
|
|
|
|
|
do k = 1,nzp
|
|
|
|
call d2fp(nyp, hyp, src(:,:,k), dst(:,:,k), nxp, 2)
|
|
|
|
end do
|
|
|
|
end subroutine d2dy
|
|
|
|
|
|
subroutine d2dz(dst, src)
|
|
|
|
real*8, dimension(nxp,nyp,nzp), intent(in) :: src
|
|
real*8, dimension(nxp,nyp,nzp), intent(out) :: dst
|
|
|
|
integer :: i, j ,k
|
|
|
|
do j = 1,nyp
|
|
|
|
do k = 1,nzp
|
|
rsrc(:,k) = src(:,j,k)
|
|
end do
|
|
|
|
call d2fp(nzp, hzp, rsrc, rdst, nxp, 3)
|
|
|
|
do k = 1,nzp
|
|
dst(:,j,k) = rdst(:,k)
|
|
end do
|
|
|
|
end do
|
|
|
|
end subroutine d2dz
|
|
|
|
|
|
subroutine tp(a, b, nx)
|
|
! a(nb,nx) = transpose(b(nx,nb))
|
|
|
|
integer,intent(in) :: nx
|
|
|
|
real*8,intent(out) :: a(nb,nx)
|
|
real*8,intent(in) :: b(nx,nb)
|
|
|
|
call tp2(a, b, nb, nx)
|
|
|
|
end subroutine tp
|
|
|
|
subroutine tp2 (a, b, n1, n2)
|
|
! a = transpose(b)
|
|
|
|
implicit none
|
|
|
|
integer,intent(in) :: n1, n2
|
|
real*8,intent(out) :: a(n1,n2)
|
|
real*8,intent(in) :: b(n2,n1)
|
|
integer :: i,j,ii,jj
|
|
|
|
DO jj=1,n2,nb
|
|
DO ii=1,n1,nb
|
|
|
|
DO j=jj,min(jj+nb-1,n2)
|
|
DO i=ii,min(ii+nb-1,n1)
|
|
a(i,j) = b(j,i)
|
|
ENDDO
|
|
ENDDO
|
|
|
|
ENDDO
|
|
ENDDO
|
|
|
|
end subroutine tp2
|
|
|
|
real function rxn_rate (c)
|
|
|
|
real :: c
|
|
|
|
if(c.lt.0.) c=0.
|
|
if(c.gt.1.) c=1.
|
|
|
|
if (c.le.c_cut) then
|
|
|
|
rxn_rate = min_wr
|
|
|
|
else if (c.gt.c_ref) then
|
|
|
|
rxn_rate = pre*(1.-c)*exp(-ac/(1.+bc*c))
|
|
|
|
else
|
|
|
|
rxn_rate = &
|
|
((refwr-min_wr)*exp(prof_wr*(c-c_ref)) + min_wr - refwr*exp(prof_wr*(c_cut-c_ref))) &
|
|
/ (1.-exp(prof_wr*(c_cut-c_ref)))
|
|
|
|
endif
|
|
|
|
end function rxn_rate
|
|
|
|
real function threshold_min_max (c, minc, maxc)
|
|
|
|
real :: c
|
|
real :: minc, maxc
|
|
|
|
if ((c.lt.minc) .or. (c.gt.maxc)) then
|
|
threshold_min_max = 0.
|
|
else
|
|
threshold_min_max = 1.0
|
|
end if
|
|
|
|
end function threshold_min_max
|
|
|
|
real function positive (c)
|
|
|
|
real :: c
|
|
|
|
if (c > 0.0d0) then
|
|
positive = c
|
|
else
|
|
positive = 0.
|
|
end if
|
|
|
|
end function positive
|
|
|
|
real function negative (c)
|
|
|
|
real :: c
|
|
|
|
if (c < 0.0d0) then
|
|
negative = c
|
|
else
|
|
negative = 0.
|
|
end if
|
|
|
|
end function negative
|
|
|
|
end module m_calculate
|