Skip to content

Commit

Permalink
improvements and more output
Browse files Browse the repository at this point in the history
  • Loading branch information
JanStreffing committed Jul 3, 2020
1 parent 9bce28a commit d710062
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
22 changes: 20 additions & 2 deletions src/io_meandata.F90
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,9 @@ subroutine create_new_file(entry)
endif

if (entry%ndim==1) then
entry%error_status(c) = nf_def_var_chunking(entry%ncid, entry%varID, NF_CHUNKED, (/1/)); c=c+1
entry%error_status(c) = nf_def_var_chunking(entry%ncid, entry%varID, NF_CONTIGUOUS, (/1/)); c=c+1
elseif (entry%ndim==2) then
write(*,*) "size: ", entry%glsize(1)
entry%error_status(c) = nf_def_var_chunking(entry%ncid, entry%varID, NF_CHUNKED, (/1, entry%glsize(1)/)); c=c+1
endif

Expand Down Expand Up @@ -672,13 +673,14 @@ subroutine write_mean(entry, mesh)
type(t_mesh), intent(in) , target :: mesh
integer :: i, size1, size2
integer :: c, lev
real(kind=WP) :: t0, t1, t2, t3

#include "associate_mesh.h"

! Serial output implemented so far
if (mype==0) then
c=1
write(*,*) 'writing mean record for ', trim(entry%name), '; rec. count = ', entry%rec_count
write(*,*) 'writing mean record for ', trim(entry%name), '; rec. count = ', entry%rec_count, '; bytes = ', entry%accuracy
entry%error_status(c)=nf_open(entry%filename, nf_write, entry%ncid); c=c+1
entry%error_status(c)=nf_put_vara_double(entry%ncid, entry%Tid, entry%rec_count, 1, ctime, 1); c=c+1
end if
Expand All @@ -693,16 +695,22 @@ subroutine write_mean(entry, mesh)
if (mype==0) then
entry%error_status(c)=nf_put_vara_double(entry%ncid, entry%varID, (/1, entry%rec_count/), (/size1, 1/), aux_r8, 1); c=c+1
end if

if (mype==0) deallocate(aux_r8)

!___________writing real 4 byte real _________________________________________
elseif (entry%accuracy == i_real4) then
if (mype==0) allocate(aux_r4(size1))
t0=MPI_Wtime()
if (size1==nod2D) call gather_nod (entry%local_values_r4(1:entry%lcsize(1),1), aux_r4)
if (size1==elem2D) call gather_elem(entry%local_values_r4(1:entry%lcsize(1),1), aux_r4)
t1=MPI_Wtime()
if (mype==0) then
entry%error_status(c)=nf_put_vara_real(entry%ncid, entry%varID, (/1, entry%rec_count/), (/size1, 1/), aux_r4, 1); c=c+1
end if
t2=MPI_Wtime()
if (mype==0) write(*,*) 'size: ', size1, 'gather_nod: ', t1-t0
if (mype==0) write(*,*) 'size: ', size1, 'nf_put_var: ', t2-t1
if (mype==0) deallocate(aux_r4)

!___________writing real as 2 byte integer _________________________________________
Expand All @@ -729,22 +737,32 @@ subroutine write_mean(entry, mesh)
if (entry%accuracy == i_real8) then
if (mype==0) allocate(aux_r8(size2))
do lev=1, size1
t0=MPI_Wtime()
if (size1==nod2D .or. size2==nod2D) call gather_nod (entry%local_values_r8(lev,1:entry%lcsize(2)), aux_r8)
if (size1==elem2D .or. size2==elem2D) call gather_elem(entry%local_values_r8(lev,1:entry%lcsize(2)), aux_r8)
t1=MPI_Wtime()
if (mype==0) then
entry%error_status(c)=nf_put_vara_double(entry%ncid, entry%varID, (/lev, 1, entry%rec_count/), (/1, size2, 1/), aux_r8, 1); c=c+1
end if
t2=MPI_Wtime()
if (mype==0) write(*,*) 'size: ', size2, 'lev: ', lev, 'gather_nod: ',t1-t0
if (mype==0) write(*,*) 'size: ', size2, 'lev: ', lev, 'nf_put_var: ',t2-t1
end do
if (mype==0) deallocate(aux_r8)
!___________writing real 4 byte real _________________________________________
elseif (entry%accuracy == i_real4) then
if (mype==0) allocate(aux_r4(size2))
do lev=1, size1
t0=MPI_Wtime()
if (size1==nod2D .or. size2==nod2D) call gather_nod (entry%local_values_r4(lev,1:entry%lcsize(2)), aux_r4)
if (size1==elem2D .or. size2==elem2D) call gather_elem(entry%local_values_r4(lev,1:entry%lcsize(2)), aux_r4)
t1=MPI_Wtime()
if (mype==0) then
entry%error_status(c)=nf_put_vara_real(entry%ncid, entry%varID, (/lev, 1, entry%rec_count/), (/1, size2, 1/), aux_r4, 1); c=c+1
end if
t2=MPI_Wtime()
if (mype==0) write(*,*) 'size: ', size2, 'lev: ', lev, 'gather_nod: ',t1-t0
if (mype==0) write(*,*) 'size: ', size2, 'lev: ', lev, 'nf_put_var: ',t2-t1
end do
if (mype==0) deallocate(aux_r4)
!___________writing real as 2 byte integer _________________________________________
Expand Down
14 changes: 9 additions & 5 deletions src/io_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ subroutine create_new_file(id)
!write(*,*) "j",j,kdim, ' -> ', dimid(k)
end do
id%error_status(c) = nf_def_var(id%ncid, trim(id%var(j)%name), NF_DOUBLE, id%var(j)%ndim+1, (/dimid(1:n), id%rec/), id%var(j)%code); c=c+1
if (n==1) then
id%error_status(c)=nf_def_var_chunking(id%ncid, id%var(j)%code, NF_CHUNKED, (/1/)); c=c+1
elseif (n==2) then
!if (n==1) then
! id%error_status(c)=nf_def_var_chunking(id%ncid, id%var(j)%code, NF_CHUNKED, (/1/)); c=c+1
if (n==2) then
id%error_status(c)=nf_def_var_chunking(id%ncid, id%var(j)%code, NF_CHUNKED, (/1, id%dim(1)%size/)); c=c+1
end if
id%error_status(c)=nf_put_att_text(id%ncid, id%var(j)%code, 'description', len_trim(id%var(j)%longname), id%var(j)%longname); c=c+1
Expand Down Expand Up @@ -459,9 +459,13 @@ subroutine write_restart(id, istep, mesh)
t0=MPI_Wtime()
if (size1==nod2D) call gather_nod (id%var(i)%pt1, aux)
if (size1==elem2D) call gather_elem(id%var(i)%pt1, aux)
t1=MPI_Wtime()
if (mype==0) then
id%error_status(c)=nf_put_vara_double(id%ncid, id%var(i)%code, (/1, id%rec_count/), (/size1, 1/), aux, 1); c=c+1
end if
t2=MPI_Wtime()
if (mype==0) write(*,*) 'nvar: ', i, 'size: ', size1, 'gather_nod: ', t1-t0
if (mype==0) write(*,*) 'nvar: ', i, 'size: ', size1, 'nf_put_var: ', t2-t1
if (mype==0) deallocate(aux)
!_______writing 3D fields________________________________________________
elseif (shape==2) then
Expand All @@ -482,8 +486,8 @@ subroutine write_restart(id, istep, mesh)
id%error_status(c)=nf_put_vara_double(id%ncid, id%var(i)%code, (/lev, 1, id%rec_count/), (/1, size2, 1/), aux, 1); c=c+1
end if
t2=MPI_Wtime()
if (mype==0 .and. size2==nod2D) write(*,*) 'nvar: ', i, 'lev: ', lev, 'gather_nod: ', t1-t0
if (mype==0 .and. size2==nod2D) write(*,*) 'nvar: ', i, 'lev: ', lev, 'nf_put_var: ', t2-t1
if (mype==0) write(*,*) 'nvar: ', i, 'size: ', size2, 'lev: ', lev, 'gather_nod: ', t1-t0
if (mype==0) write(*,*) 'nvar: ', i, 'size: ', size2, 'lev: ', lev, 'nf_put_var: ', t2-t1
end do
deallocate(laux)
if (mype==0) deallocate(aux)
Expand Down

0 comments on commit d710062

Please sign in to comment.