📄 phys_grid.f90
字号:
end do end do endif! scatter to other processes! (pgcols ordering consistent with begchunk:endchunk ! local ordering)#if ( defined TIMING_BARRIERS ) call t_startf ('sync_scat_ftoc') call mpibarrier (mpicom) call t_stopf ('sync_scat_ftoc')#endif call mpiscatterv(gfield_p, sndcnts, displs, mpir8, & lfield_p, recvcnt, mpir8, 0, mpicom)! copy into local chunked data structure do i=1,nlcols cid = pgcols(beglcol+i)%chunk lcid = chunks(cid)%lchunk lid = pgcols(beglcol+i)%ccol do l=1,ldim do m=1,mdim do f=1,fdim localchunks(f,lid,m,lcid,l) = & lfield_p(f, m, l, i) end do end do end do end do#else! copy field into chunked data structure! (pgcol ordering chosen to reflect begchunk:endchunk ! local ordering) do l=1,ldim do i=1,ngcols cid = pgcols(i)%chunk lcid = chunks(cid)%lchunk lid = pgcols(i)%ccol do m=1,mdim do f=1,fdim localchunks(f,lid,m,lcid,l) = & globalfield(f,chunks(cid)%lon(lid), m, & chunks(cid)%lat(lid),l) end do end do end do end do#endif return end subroutine scatter_field_to_chunk!======================================================================== subroutine scatter_field_to_chunk4(fdim,mdim,ldim, & nlond,globalfield,localchunks)!----------------------------------------------------------------------- ! ! Purpose: Distribute longitude/latitude field! to decomposed chunk data structure! ! Method: ! ! Author: Patrick Worley! !----------------------------------------------------------------------- use precision use pmgrid, only: iam, masterproc implicit none!------------------------------Arguments-------------------------------- integer, intent(in) :: fdim ! declared length of first dimension integer, intent(in) :: mdim ! declared length of middle dimension integer, intent(in) :: ldim ! declared length of last dimension integer, intent(in) :: nlond ! declared number of longitudes real(r4), intent(in) :: globalfield(fdim,nlond,mdim,plat,ldim) ! global field real(r4), intent(out):: localchunks(fdim,pcols,mdim, & begchunk:endchunk,ldim) ! local chunks!---------------------------Local workspace----------------------------- integer :: f,i,m,l,p ! loop indices integer :: cid ! global chunk id integer :: lcid ! local chunk id integer :: lid ! local longitude index#if ( defined SPMD ) real(r4) gfield_p(fdim,mdim,ldim,ngcols) ! vector to be scattered real(r4) lfield_p(fdim,mdim,ldim,nlcols) ! local component of scattered ! vector integer :: displs(0:npes-1) ! scatter displacements integer :: sndcnts(0:npes-1) ! scatter send counts integer :: recvcnt ! scatter receive count integer :: beglcol ! beginning index for local columns ! in global column ordering#endif!-----------------------------------------------------------------------#if ( defined SPMD ) displs(0) = 0 sndcnts(0) = fdim*mdim*ldim*gs_col_num(0) beglcol = 0 do p=1,npes-1 displs(p) = displs(p-1) + sndcnts(p-1) sndcnts(p) = fdim*mdim*ldim*gs_col_num(p) if (p <= iam) then beglcol = beglcol + gs_col_num(p-1) endif enddo recvcnt = fdim*mdim*ldim*nlcols if (masterproc) then ! copy field into global (process-ordered) chunked data structure do i=1,ngcols cid = pgcols(i)%chunk lid = pgcols(i)%ccol do l=1,ldim do m=1,mdim do f=1,fdim gfield_p(f,m,l,i) = & globalfield(f,chunks(cid)%lon(lid), m, & chunks(cid)%lat(lid),l) end do end do end do end do endif! scatter to other processes! (pgcols ordering consistent with begchunk:endchunk ! local ordering)#if ( defined TIMING_BARRIERS ) call t_startf ('sync_scat_ftoc') call mpibarrier (mpicom) call t_stopf ('sync_scat_ftoc')#endif call mpiscatterv(gfield_p, sndcnts, displs, mpir4, & lfield_p, recvcnt, mpir4, 0, mpicom)! copy into local chunked data structure do i=1,nlcols cid = pgcols(beglcol+i)%chunk lcid = chunks(cid)%lchunk lid = pgcols(beglcol+i)%ccol do l=1,ldim do m=1,mdim do f=1,fdim localchunks(f,lid,m,lcid,l) = & lfield_p(f, m, l, i) end do end do end do end do#else ! copy field into chunked data structure ! (pgcol ordering chosen to reflect begchunk:endchunk ! local ordering) do l=1,ldim do i=1,ngcols cid = pgcols(i)%chunk lcid = chunks(cid)%lchunk lid = pgcols(i)%ccol do m=1,mdim do f=1,fdim localchunks(f,lid,m,lcid,l) = & globalfield(f,chunks(cid)%lon(lid), m, & chunks(cid)%lat(lid),l) end do end do end do end do#endif return end subroutine scatter_field_to_chunk4!======================================================================== subroutine scatter_field_to_chunk_int(fdim,mdim,ldim, & nlond,globalfield,localchunks)!----------------------------------------------------------------------- ! ! Purpose: Distribute longitude/latitude field! to decomposed chunk data structure! ! Method: ! ! Author: Patrick Worley! !----------------------------------------------------------------------- use precision use pmgrid, only: iam, masterproc implicit none!------------------------------Arguments-------------------------------- integer, intent(in) :: fdim ! declared length of first dimension integer, intent(in) :: mdim ! declared length of middle dimension integer, intent(in) :: ldim ! declared length of last dimension integer, intent(in) :: nlond ! declared number of longitudes integer, intent(in) :: globalfield(fdim,nlond,mdim,plat,ldim) ! global field integer, intent(out):: localchunks(fdim,pcols,mdim, & begchunk:endchunk,ldim) ! local chunks!---------------------------Local workspace----------------------------- integer :: f,i,m,l,p ! loop indices integer :: cid ! global chunk id integer :: lcid ! local chunk id integer :: lid ! local longitude index#if ( defined SPMD ) integer gfield_p(fdim,mdim,ldim,ngcols) ! vector to be scattered integer lfield_p(fdim,mdim,ldim,nlcols) ! local component of scattered ! vector integer :: displs(0:npes-1) ! scatter displacements integer :: sndcnts(0:npes-1) ! scatter send counts integer :: recvcnt ! scatter receive count integer :: beglcol ! beginning index for local columns ! in global column ordering#endif!-----------------------------------------------------------------------#if ( defined SPMD ) displs(0) = 0 sndcnts(0) = fdim*mdim*ldim*gs_col_num(0) beglcol = 0 do p=1,npes-1 displs(p) = displs(p-1) + sndcnts(p-1) sndcnts(p) = fdim*mdim*ldim*gs_col_num(p) if (p <= iam) then beglcol = beglcol + gs_col_num(p-1) endif enddo recvcnt = fdim*mdim*ldim*nlcols if (masterproc) then! copy field into global (process-ordered) chunked data structure do i=1,ngcols cid = pgcols(i)%chunk lid = pgcols(i)%ccol do l=1,ldim do m=1,mdim do f=1,fdim gfield_p(f,m,l,i) = & globalfield(f,chunks(cid)%lon(lid), m, & chunks(cid)%lat(lid),l) end do end do end do end do endif! scatter to other processes! (pgcols ordering consistent with begchunk:endchunk ! local ordering)#if ( defined TIMING_BARRIERS ) call t_startf ('sync_scat_ftoc') call mpibarrier (mpicom) call t_stopf ('sync_scat_ftoc')#endif call mpiscatterv(gfield_p, sndcnts, displs, mpiint, & lfield_p, recvcnt, mpiint, 0, mpicom)! copy into local chunked data structure do i=1,nlcols cid = pgcols(beglcol+i)%chunk lcid = chunks(cid)%lchunk lid = pgcols(beglcol+i)%ccol do l=1,ldim do m=1,mdim do f=1,fdim localchunks(f,lid,m,lcid,l) = & lfield_p(f, m, l, i) end do end do end do end do#else! copy field into chunked data structure! (pgcol ordering chosen to reflect begchunk:endchunk ! local ordering) do l=1,ldim do i=1,ngcols cid = pgcols(i)%chunk lcid = chunks(cid)%lchunk lid = pgcols(i)%ccol do m=1,mdim do f=1,fdim localchunks(f,lid,m,lcid,l) = & globalfield(f,chunks(cid)%lon(lid), m, & chunks(cid)%lat(lid),l) end do end do end do end do#endif return end subroutine scatter_field_to_chunk_int!!========================================================================! subroutine gather_chunk_to_field(fdim,mdim,ldim, & nlond,localchunks,globalfield)!----------------------------------------------------------------------- ! ! Purpose: Reconstruct longitude/latitude field! from decomposed chunk data structure! ! Method: ! ! Author: Patrick Worley! !----------------------------------------------------------------------- use precision use pmgrid, only: iam, masterproc implicit none!------------------------------Arguments-------------------------------- integer, intent(in) :: fdim ! declared length of first dimension integer, intent(in) :: mdim ! declared length of middle dimension integer, intent(in) :: ldim ! declared length of last dimension integer, intent(in) :: nlond ! declared number of longitudes real(r8), intent(in):: localchunks(fdim,pcols,mdim, & begchunk:endchunk,ldim) ! local chunks real(r8), intent(out) :: globalfield(fdim,nlond,mdim,plat,ldim) ! global field!---------------------------Local workspace----------------------------- integer :: f,i,m,l,p ! loop indices integer :: cid ! global chunk id integer :: lcid ! local chunk id integer :: lid ! local longitude index#if ( defined SPMD ) real(r8) gfield_p(fdim,mdim,ldim,ngcols) ! vector to be gathered real(r8) lfield_p(fdim,mdim,ldim,nlcols) ! local component of gather ! vector integer :: displs(0:npes-1) ! gather displacements integer :: rcvcnts(0:npes-1) ! gather receive count integer :: sendcnt ! gather send counts integer :: beglcol ! beginning index for local columns ! in global column ordering#endif!-----------------------------------------------------------------------#if ( defined SPMD ) displs(0) = 0 rcvcnts(0) = fdim*mdim*ldim*gs_col_num(0) beglcol = 0 do p=1,npes-1 displs(p) = displs(p-1) + rcvcnts(p-1) rcvcnts(p) = fdim*mdim*ldim*gs_col_num(p) if (p <= iam) then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -