subroutine chkdiv use modglobal, only : ib,ie,jb,je,ke,kb,dx,dxi,dy,dyi,dzf,dzfi use modfields, only : u0,v0,w0!,divergentie use modmpi, only : myid,comm3d,mpi_sum,mpi_max,my_real,mpierr implicit none real div, divmax, divtot real divmaxl, divtotl integer i, j, k divmax = 0. divtot = 0. divmaxl= 0. divtotl= 0. do k=kb,ke do j=jb,je do i=ib,ie div = & (u0(i+1,j,k) - u0(i,j,k) )*dxi + & (v0(i,j+1,k) - v0(i,j,k) )*dyi + & (w0(i,j,k+1) - w0(i,j,k) )*dzfi(k) ! divergentie(i,j,k)=div divmaxl = max(divmaxl,abs(div)) divtotl = divtotl + div*dx*dy*dzf(k) end do end do end do call MPI_ALLREDUCE(divtotl, divtot, 1, MY_REAL, & MPI_SUM, comm3d,mpierr) call MPI_ALLREDUCE(divmaxl, divmax, 1, MY_REAL, & MPI_MAX, comm3d,mpierr) if(myid==0)then write(6,'(A,2ES11.2)')'divmax, divtot = ', divmax, divtot end if return end subroutine chkdiv