I have a 3D domain with bottom hill topography, and I am trying to extract 1D profile of a horizontal integral (over xy-plane) as a function of z for some variables (dissipation, for example). I have been successful at using planar_avg routine, but that outputs a 3D array, not 1D.
I looked up previous examples that have been given in forums, but the results that I am getting don't make sense - I tried to get the average z value, i.e. Z(z) as well, and the output that I get makes no sense given my domain. Below is part of the code that I am using in userchk().
I would appreciate if someone could point out where my problems are with computing these averages.
common /fbar/ fbar(lz1,lelz),wght(lz1,lelz)
common /depth/ dpth(lz1,lelz),work2(lz1,lelz)
call rzero(fbar,nz1*nelz)
call rzero(wght,nz1*nelz)
call rzero(dpth,nz1*nelz)
do e=1,nelv
eg = lglel(e)
call get_exyz(ex,ey,ez,eg,nelxy,1,nelz)
do k=1,nz1
do in=1,nx1*ny1
fbar(k,ez) = fbar(k,ez)+area(in,1,f,e)*dke2(in,1,k,e)
wght(k,ez) = wght(k,ez)+area(in,1,f,e)
dpth(k,ez) = dpth(k,ez)+zm1(in,1,k,e)
enddo
enddo
enddo
call gop(fbar,work2,'+ ',nz1*nelz)
call gop(wght,work2,'+ ',nz1*nelz)
call gop(dpth,work2,'+ ',nz1*nelz)
do in=1,nz1*nelz
dpth(in,1)=dpth(in,1)/wght(in,1)
enddo
do k=1,nelz
do in=1,nz1
write(1,*) dpth(in,k),wght(in,k),fbar(in,k)
enddo
enddo