subroutine instant_write_jslice_ycoord_local(ncid, local_n, njslice_total, jslice_positions)
! Write y-coordinates for LOCAL jslice positions (round-robin assignment over myidy)
implicit none
integer, intent(in) :: ncid, local_n, njslice_total
integer, dimension(njslice_total), intent(in) :: jslice_positions
integer :: varid, ierr, j, local_idy
real, allocatable :: y_jslice_f(:), y_jslice_h(:)
integer, allocatable :: jslice_indices(:)
allocate(y_jslice_f(local_n))
allocate(y_jslice_h(local_n))
allocate(jslice_indices(local_n))
local_idy = 0
do j = 1, njslice_total
! if (jslice_positions(j) >= ystart(2) .and. jslice_positions(j) <= yend(2)) then
if (jslice_positions(j) >= zstart(2) .and. jslice_positions(j) <= zend(2)) then
local_idy = local_idy + 1
y_jslice_f(local_idy) = yf(jslice_positions(j))
y_jslice_h(local_idy) = yh(jslice_positions(j))
jslice_indices(local_idy) = jslice_positions(j)
end if
end do
ierr = nf90_inq_varid(ncid, 'yt', varid)
if (ierr == nf90_noerr) then
ierr = nf90_redef(ncid)
ierr = nf90_put_att(ncid, varid, 'jslice_indices', jslice_indices)
ierr = nf90_put_att(ncid, varid, 'long_name', 'y-coordinate of j-slices (cell center)')
ierr = nf90_enddef(ncid)
ierr = nf90_put_var(ncid, varid, y_jslice_f)
end if
ierr = nf90_inq_varid(ncid, 'ym', varid)
if (ierr == nf90_noerr) then
ierr = nf90_redef(ncid)
ierr = nf90_put_att(ncid, varid, 'jslice_indices', jslice_indices)
ierr = nf90_put_att(ncid, varid, 'long_name', 'y-coordinate of j-slices (cell edge)')
ierr = nf90_enddef(ncid)
ierr = nf90_put_var(ncid, varid, y_jslice_h)
end if
deallocate(y_jslice_f)
deallocate(y_jslice_h)
deallocate(jslice_indices)
end subroutine instant_write_jslice_ycoord_local