subroutine stats_write_pedestrian_wind(ncid, record)
implicit none
integer, intent(in) :: ncid, record
real, allocatable :: fld2d(:,:), fld3d(:,:,:)
if (size(wind_heights) == 1) then
allocate(fld2d(ib:ie,jb:je))
fld2d = ws_localt(:,:,1)
where (.not. ws_local_valid(:,:,1)) fld2d = nc_fillvalue
call writeoffset_2d(ncid, 'ws_local', fld2d, record, xdim, ydim)
deallocate(fld2d)
else
allocate(fld3d(ib:ie,jb:je,1:size(wind_heights)))
fld3d = ws_localt
where (.not. ws_local_valid) fld3d = nc_fillvalue
call writeoffset(ncid, 'ws_local', fld3d, record, xdim, ydim, size(wind_heights))
deallocate(fld3d)
end if
allocate(fld2d(ib:ie,jb:je))
fld2d = ws_10t
where (.not. ws_10_valid) fld2d = nc_fillvalue
call writeoffset_2d(ncid, 'ws_10', fld2d, record, xdim, ydim)
deallocate(fld2d)
end subroutine stats_write_pedestrian_wind