⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 phys_grid.f90

📁 CCSM Research Tools: Community Atmosphere Model (CAM)
💻 F90
📖 第 1 页 / 共 5 页
字号:
        beglcol = beglcol + gs_col_num(p-1)     endif   enddo   sendcnt = fdim*mdim*ldim*nlcols! copy into local gather 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               lfield_p(f, m, l, i) = &                  localchunks(f,lid,m,lcid,l)            end do         end do      end do   end do! gather from other processes#if ( defined TIMING_BARRIERS )   call t_startf ('sync_gath_ctof')   call mpibarrier (mpicom)   call t_stopf ('sync_gath_ctof')#endif   call mpigatherv(lfield_p, sendcnt, mpir8, &                   gfield_p, rcvcnts, displs, mpir8, 0, mpicom)   if (masterproc) then! copy gathered columns into lon/lat field      do i=1,ngcols         cid = pgcols(i)%chunk         lid = pgcols(i)%ccol         do l=1,ldim            do m=1,mdim               do f=1,fdim                  globalfield(f,chunks(cid)%lon(lid), m, &                              chunks(cid)%lat(lid),l)    &                  = gfield_p(f,m,l,i)               end do            end do         end do      end do   endif#else   ! copy chunked data structure into lon/lat field   ! (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               globalfield(f,chunks(cid)%lon(lid), m, &                           chunks(cid)%lat(lid),l)    &               = localchunks(f,lid,m,lcid,l)            end do         end do      end do   end do#endif   return   end subroutine gather_chunk_to_field!!========================================================================!   subroutine gather_chunk_to_field4 (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(r4), intent(in):: localchunks(fdim,pcols,mdim, &                                      begchunk:endchunk,ldim)                                     ! local chunks   real(r4), 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(r4) gfield_p(fdim,mdim,ldim,ngcols)                                          ! vector to be gathered   real(r4) 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        beglcol = beglcol + gs_col_num(p-1)     endif   enddo   sendcnt = fdim*mdim*ldim*nlcols! copy into local gather 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               lfield_p(f, m, l, i) = &                  localchunks(f,lid,m,lcid,l)            end do         end do      end do   end do! gather from other processes#if ( defined TIMING_BARRIERS )   call t_startf ('sync_gath_ctof')   call mpibarrier (mpicom)   call t_stopf ('sync_gath_ctof')#endif   call mpigatherv(lfield_p, sendcnt, mpir4, &                   gfield_p, rcvcnts, displs, mpir4, 0, mpicom)   if (masterproc) then! copy gathered columns into lon/lat field      do i=1,ngcols         cid = pgcols(i)%chunk         lid = pgcols(i)%ccol         do l=1,ldim            do m=1,mdim               do f=1,fdim                  globalfield(f,chunks(cid)%lon(lid), m, &                              chunks(cid)%lat(lid),l)    &                  = gfield_p(f,m,l,i)               end do            end do         end do      end do   endif#else! copy chunked data structure into lon/lat field! (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               globalfield(f,chunks(cid)%lon(lid), m, &                           chunks(cid)%lat(lid),l)    &               = localchunks(f,lid,m,lcid,l)            end do         end do      end do   end do#endif   return   end subroutine gather_chunk_to_field4!!========================================================================!   subroutine gather_chunk_to_field_int (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   integer, intent(in):: localchunks(fdim,pcols,mdim,begchunk:endchunk,ldim) ! local chunks!JR Changed globalfield to inout because slaves under lf95 pass a bogus argument, which will result!JR in trash being written to useful memory if intent(out) is specified.  THIS SHOULD BE FIXED!!!   integer, intent(inout) :: 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 )   integer gfield_p(fdim,mdim,ldim,ngcols)                                          ! vector to be gathered   integer 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        beglcol = beglcol + gs_col_num(p-1)     endif   enddo   sendcnt = fdim*mdim*ldim*nlcols! copy into local gather 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               lfield_p(f, m, l, i) = &                  localchunks(f,lid,m,lcid,l)            end do         end do      end do   end do! gather from other processes#if ( defined TIMING_BARRIERS )   call t_startf ('sync_gath_ctof')   call mpibarrier (mpicom)   call t_stopf ('sync_gath_ctof')#endif   call mpigatherv(lfield_p, sendcnt, mpiint, &                   gfield_p, rcvcnts, displs, mpiint, 0, mpicom)   if (masterproc) then! copy gathered columns into lon/lat field      do i=1,ngcols         cid = pgcols(i)%chunk         lid = pgcols(i)%ccol         do l=1,ldim            do m=1,mdim               do f=1,fdim                  globalfield(f,chunks(cid)%lon(lid), m, &                              chunks(cid)%lat(lid),l)    &                  = gfield_p(f,m,l,i)               end do            end do         end do      end do   endif#else   ! copy chunked data structure into lon/lat field   ! (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               globalfield(f,chunks(cid)%lon(lid), m, &                           chunks(cid)%lat(lid),l)    &               = localchunks(f,lid,m,lcid,l)            end do         end do      end do   end do#endif   return   end subroutine gather_chunk_to_field_int!!========================================================================!   subroutine write_field_from_chunk(iu,fdim,mdim,ldim,localchunks)!----------------------------------------------------------------------- ! !                          ! Purpose: Write longitude/latitude field from decomposed chunk data !          structure! ! Method: ! ! Author: Patrick Worley! !-----------------------------------------------------------------------   use precision   use pmgrid, only: masterproc   implicit none!------------------------------Arguments--------------------------------   integer, intent(in) :: iu        ! logical unit   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   real(r8), intent(in):: localchunks(fdim,pcols,mdim,begchunk:endchunk,ldim) ! local chunks!---------------------------Local workspace-----------------------------   integer :: ioerr                 ! error return   real(r8) :: globalfield(fdim,plon,mdim,plat,ldim)                                     ! global field!-----------------------------------------------------------------------   call g

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -