Hello,
I am trying to modify the diabatic heating tendency over the Indian Ocean in CAM6 (CESM2.1.3). I think I've figured out where to do it in the source codes (physpkg.F90), but I am running into some technical questions, as detailed below.
Specifically, at every physics time step, I would like to first compute the domain averaged diabatic heating (computed by CAM physics) over the Indian Ocean and then use this average value to overwrite the model-computed diabatic heating over the Indian Ocean. In the source codes physpkg.F90, these domain averaging and overwriting operations would be done inside the tphysbc/tphysac subroutines, to the physics tendency variable 'ptend%s', right before each 'call physics_update()'.
To do this, it requires that I need to first MPI_gather all chunks from each MPI process to a global field, do the averaging/overwriting, and finally MPI_scatter the modified global ptend%s field to each MPI process. However, it seems that these mpi_gather/scatter functions cannot be directly called from inside the tphysbc/tphysac subroutines, because tphysbc/tphysac are executed sequentially on the chunks of each MPI process, provided that the number of OpenMP threads is less than the number of the chunks on each MPI process (see copied codes below).
-----------------------------------------------------------------------------
!$OMP PARALLEL DO PRIVATE (C, NCOL, phys_buffer_chunk)
do c=begchunk,endchunk
ncol = get_ncols_p(c)
phys_buffer_chunk => pbuf_get_chunk(pbuf2d, c)
!
! surface diagnostics for history files
!
call t_startf('diag_surf')
call diag_surf(cam_in(c), cam_out(c), phys_state(c), phys_buffer_chunk)
call t_stopf('diag_surf')
call tphysac(ztodt, cam_in(c), &
cam_out(c), &
phys_state(c), phys_tend(c), phys_buffer_chunk)
end do ! Chunk loop
-----------------------------------------------------------------------------
I wonder if I can get around this issue by increasing the number of MPI processes (or OMP threads) and setting it equal to the total number of chunks on the physics grid, so that all chunks will be processed in a parallel way to allow the use of mpi_gather/scatter functions. If yes, how?
If not, any suggestions on how to do what I want?
Thanks a lot.
Honghai
I am trying to modify the diabatic heating tendency over the Indian Ocean in CAM6 (CESM2.1.3). I think I've figured out where to do it in the source codes (physpkg.F90), but I am running into some technical questions, as detailed below.
Specifically, at every physics time step, I would like to first compute the domain averaged diabatic heating (computed by CAM physics) over the Indian Ocean and then use this average value to overwrite the model-computed diabatic heating over the Indian Ocean. In the source codes physpkg.F90, these domain averaging and overwriting operations would be done inside the tphysbc/tphysac subroutines, to the physics tendency variable 'ptend%s', right before each 'call physics_update()'.
To do this, it requires that I need to first MPI_gather all chunks from each MPI process to a global field, do the averaging/overwriting, and finally MPI_scatter the modified global ptend%s field to each MPI process. However, it seems that these mpi_gather/scatter functions cannot be directly called from inside the tphysbc/tphysac subroutines, because tphysbc/tphysac are executed sequentially on the chunks of each MPI process, provided that the number of OpenMP threads is less than the number of the chunks on each MPI process (see copied codes below).
-----------------------------------------------------------------------------
!$OMP PARALLEL DO PRIVATE (C, NCOL, phys_buffer_chunk)
do c=begchunk,endchunk
ncol = get_ncols_p(c)
phys_buffer_chunk => pbuf_get_chunk(pbuf2d, c)
!
! surface diagnostics for history files
!
call t_startf('diag_surf')
call diag_surf(cam_in(c), cam_out(c), phys_state(c), phys_buffer_chunk)
call t_stopf('diag_surf')
call tphysac(ztodt, cam_in(c), &
cam_out(c), &
phys_state(c), phys_tend(c), phys_buffer_chunk)
end do ! Chunk loop
-----------------------------------------------------------------------------
I wonder if I can get around this issue by increasing the number of MPI processes (or OMP threads) and setting it equal to the total number of chunks on the physics grid, so that all chunks will be processed in a parallel way to allow the use of mpi_gather/scatter functions. If yes, how?
If not, any suggestions on how to do what I want?
Thanks a lot.
Honghai