dns-hit3d-fdm/gather_4.f90

54 lines
1.1 KiB
Fortran

subroutine gather_4
! Writing out the velocities and scalars in X-space
! to the real*4 file
use m_parameters
use m_fields
use m_work
use x_fftw
use m_les
use m_fdm_calc
implicit none
integer :: n_out, n, i, j, k
real*8 :: wmag2, rkmax2
! every variable will undergo a mode truncation for all modes
! that are higher than kmax. This will ensure that the written
! variables are isotropic
rkmax2 = real(kmax,8)**2
! number of variables to write out
n_out = 3
! putting all variables in wrk array
do k = 1,nz
do j = 1,ny
do i = 1,nx+2
wmag2 = akx(i)**2 + aky(k)**2 + akz(j)**2
if (wmag2 .gt. rkmax2) then
wrk(i,j,k,1:n_out) = zip
else
wrk(i,j,k,1:n_out) = fields(i,j,k,1:n_out)
end if
end do
end do
end do
! velocities
call xFFT3d(-1,1)
call xFFT3d(-1,2)
call xFFT3d(-1,3)
u_(1:nx,1:ny,1:nz) = wrk(1:nx,1:ny,1:nz,1)
v_(1:nx,1:ny,1:nz) = wrk(1:nx,1:ny,1:nz,2)
w_(1:nx,1:ny,1:nz) = wrk(1:nx,1:ny,1:nz,3)
return
end subroutine gather_4