Skip to content

Commit 0384a60

Browse files
AnandAnand
authored andcommitted
1D Spectrum corrections
1 parent a655546 commit 0384a60

File tree

1 file changed

+26
-19
lines changed

1 file changed

+26
-19
lines changed

src/post_process/m_start_up.fpp

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ contains
428428

429429
call s_mpi_FFT_fwd()
430430

431-
En_real = 0.5_wp*abs(data_cmplx_z)**2._wp/((m + 1)*(n + 1)*(p + 1))
431+
En_real = 0.5_wp*abs(data_cmplx_z)**2._wp/(Nx*Ny*Nz)**2._wp
432432

433433
do l = 0, p
434434
do k = 0, n
@@ -440,7 +440,7 @@ contains
440440

441441
call s_mpi_FFT_fwd()
442442

443-
En_real = En_real + 0.5_wp*abs(data_cmplx_z)**2._wp/((m + 1)*(n + 1)*(p + 1))
443+
En_real = En_real + 0.5_wp*abs(data_cmplx_z)**2._wp/(Nx*Ny*Nz)**2._wp
444444

445445
do l = 0, p
446446
do k = 0, n
@@ -452,7 +452,7 @@ contains
452452

453453
call s_mpi_FFT_fwd()
454454

455-
En_real = En_real + 0.5_wp*abs(data_cmplx_z)**2._wp/((m + 1)*(n + 1)*(p + 1))
455+
En_real = En_real + 0.5_wp*abs(data_cmplx_z)**2._wp/(Nx*Ny*Nz)**2._wp
456456

457457
do kf = 1, Nf
458458
En(kf) = 0._wp
@@ -494,22 +494,29 @@ contains
494494

495495
call MPI_ALLREDUCE(MPI_IN_PLACE, En, Nf, mpi_p, MPI_SUM, MPI_COMM_WORLD, ierr)
496496

497-
! do kf = 1, m +1
498-
! if(proc_rank == 0) then
499-
! !print *, "En_tot", En(kf) , proc_rank
500-
! end if
501-
! write(filename,'(a,i0,a)') 'En_tot',proc_rank,'.dat'
502-
! inquire (FILE=filename, EXIST=file_exists)
503-
! if (file_exists) then
504-
! open (1, file=filename, position='append', status='old')
505-
! write (1, *) En(kf), proc_rank, t_step
506-
! close (1)
507-
! else
508-
! open (1, file=filename, status='new')
509-
! write (1, *) En(kf), proc_rank, t_step
510-
! close (1)
511-
! end if
512-
! end do
497+
if(proc_rank == 0) then
498+
write(filename,'(a,i0,a)') 'En_tot',t_step,'.dat'
499+
inquire (FILE=filename, EXIST=file_exists)
500+
if(file_exists) then
501+
call s_delete_file(trim(case_dir)//'/'//trim(filename))
502+
end if
503+
end if
504+
505+
do kf = 1, Nf
506+
if(proc_rank == 0) then
507+
write(filename,'(a,i0,a)') 'En_tot',t_step,'.dat'
508+
inquire (FILE=filename, EXIST=file_exists)
509+
if (file_exists) then
510+
open (1, file=filename, position='append', status='old')
511+
write (1, *) En(kf), t_step
512+
close (1)
513+
else
514+
open (1, file=filename, status='new')
515+
write (1, *) En(kf), t_step
516+
close (1)
517+
end if
518+
end if
519+
end do
513520

514521
end if
515522

0 commit comments

Comments
 (0)