ESMF_UtilCreateCSCoordsPar Subroutine

public subroutine ESMF_UtilCreateCSCoordsPar(npts, LonEdge, LatEdge, start, count, tile, LonCenter, LatCenter, schmidtTransform, local_algorithm)

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: npts
real(kind=ESMF_KIND_R8), intent(inout), optional :: LonEdge(:,:)
real(kind=ESMF_KIND_R8), intent(inout), optional :: LatEdge(:,:)
integer, intent(in), optional :: start(:)
integer, intent(in), optional :: count(:)
integer, intent(in), optional :: tile
real(kind=ESMF_KIND_R8), intent(inout), optional :: LonCenter(:,:)
real(kind=ESMF_KIND_R8), intent(inout), optional :: LatCenter(:,:)
type(ESMF_CubedSphereTransform_Args), intent(in), optional :: schmidtTransform
logical, intent(in), optional :: local_algorithm

Calls

proc~~esmf_utilcreatecscoordspar~~CallsGraph proc~esmf_utilcreatecscoordspar ESMF_UtilCreateCSCoordsPar proc~cell_center2 cell_center2 proc~esmf_utilcreatecscoordspar->proc~cell_center2 proc~direct_transform direct_transform proc~esmf_utilcreatecscoordspar->proc~direct_transform proc~get_gnomonic_local_coords get_gnomonic_local_coords proc~esmf_utilcreatecscoordspar->proc~get_gnomonic_local_coords proc~gnomonic_grids gnomonic_grids proc~esmf_utilcreatecscoordspar->proc~gnomonic_grids proc~mirror_grid_local mirror_grid_local proc~esmf_utilcreatecscoordspar->proc~mirror_grid_local proc~mirror_grid_local_new mirror_grid_local_new proc~esmf_utilcreatecscoordspar->proc~mirror_grid_local_new proc~cart_to_latlon cart_to_latlon proc~cell_center2->proc~cart_to_latlon proc~latlon2xyz2 latlon2xyz2 proc~cell_center2->proc~latlon2xyz2 proc~get_gnomonic_angl_coords get_gnomonic_angl_coords proc~get_gnomonic_local_coords->proc~get_gnomonic_angl_coords proc~get_gnomonic_dist_coords get_gnomonic_dist_coords proc~get_gnomonic_local_coords->proc~get_gnomonic_dist_coords proc~get_gnomonic_ed_coords get_gnomonic_ed_coords proc~get_gnomonic_local_coords->proc~get_gnomonic_ed_coords proc~gnomonic_angl gnomonic_angl proc~gnomonic_grids->proc~gnomonic_angl proc~gnomonic_dist gnomonic_dist proc~gnomonic_grids->proc~gnomonic_dist proc~gnomonic_ed gnomonic_ed proc~gnomonic_grids->proc~gnomonic_ed proc~symm_ed symm_ed proc~gnomonic_grids->proc~symm_ed proc~rot_3d rot_3d proc~mirror_grid_local->proc~rot_3d proc~rot_3d_new rot_3d_new proc~mirror_grid_local_new->proc~rot_3d_new proc~cart_to_latlon_new cart_to_latlon_new proc~get_gnomonic_angl_coords->proc~cart_to_latlon_new proc~get_gnomonic_dist_coords->proc~cart_to_latlon_new proc~get_gnomonic_ed_coords->proc~cart_to_latlon_new proc~gnomonic_angl->proc~cart_to_latlon proc~gnomonic_dist->proc~cart_to_latlon proc~gnomonic_ed->proc~cart_to_latlon proc~gnomonic_ed->proc~latlon2xyz2 proc~mirror_latlon mirror_latlon proc~gnomonic_ed->proc~mirror_latlon proc~latlon2xyz latlon2xyz proc~latlon2xyz2->proc~latlon2xyz proc~cartesian_to_spherical cartesian_to_spherical proc~rot_3d->proc~cartesian_to_spherical proc~spherical_to_cartesian spherical_to_cartesian proc~rot_3d->proc~spherical_to_cartesian proc~rot_3d_new->proc~cartesian_to_spherical proc~rot_3d_new->proc~spherical_to_cartesian proc~mirror_latlon->proc~cart_to_latlon proc~mirror_latlon->proc~latlon2xyz2 proc~vect_cross vect_cross proc~mirror_latlon->proc~vect_cross

Called by

proc~~esmf_utilcreatecscoordspar~~CalledByGraph proc~esmf_utilcreatecscoordspar ESMF_UtilCreateCSCoordsPar proc~esmf_gridcreatecubedsphereireg ESMF_GridCreateCubedSphereIReg proc~esmf_gridcreatecubedsphereireg->proc~esmf_utilcreatecscoordspar proc~esmf_gridcreatecubedspherereg ESMF_GridCreateCubedSphereReg proc~esmf_gridcreatecubedspherereg->proc~esmf_utilcreatecscoordspar interface~esmf_gridcreatecubedsphere ESMF_GridCreateCubedSphere interface~esmf_gridcreatecubedsphere->proc~esmf_gridcreatecubedsphereireg interface~esmf_gridcreatecubedsphere->proc~esmf_gridcreatecubedspherereg proc~createfields createFields proc~createfields->interface~esmf_gridcreatecubedsphere proc~f_esmf_gridcreatecubedsphere f_esmf_gridcreatecubedsphere proc~f_esmf_gridcreatecubedsphere->interface~esmf_gridcreatecubedsphere proc~iocomputestsetup IOCompUTestSetup proc~iocomputestsetup->interface~esmf_gridcreatecubedsphere proc~test_bilinear_regrid_csgrid test_bilinear_regrid_csgrid proc~test_bilinear_regrid_csgrid->interface~esmf_gridcreatecubedsphere proc~test_bilinear_regrid_csgrid_sph_rad test_bilinear_regrid_csgrid_sph_rad proc~test_bilinear_regrid_csgrid_sph_rad->interface~esmf_gridcreatecubedsphere proc~test_conserve_regrid_csgrid test_conserve_regrid_csgrid proc~test_conserve_regrid_csgrid->interface~esmf_gridcreatecubedsphere proc~test_csgridtogrid test_CSGridToGrid proc~test_csgridtogrid->interface~esmf_gridcreatecubedsphere proc~test_csgridtogrid_2nd test_CSGridToGrid_2nd proc~test_csgridtogrid_2nd->interface~esmf_gridcreatecubedsphere proc~test_csgridtogridwmasks test_CSGridToGridWMasks proc~test_csgridtogridwmasks->interface~esmf_gridcreatecubedsphere proc~test_mesh_dual_w_bilinear test_mesh_dual_w_bilinear proc~test_mesh_dual_w_bilinear->interface~esmf_gridcreatecubedsphere proc~test_nearest_regrid_csgrid test_nearest_regrid_csgrid proc~test_nearest_regrid_csgrid->interface~esmf_gridcreatecubedsphere proc~test_nearest_regrid_csmesh test_nearest_regrid_csmesh proc~test_nearest_regrid_csmesh->interface~esmf_gridcreatecubedsphere proc~test_patch_regrid_csgrid test_patch_regrid_csgrid proc~test_patch_regrid_csgrid->interface~esmf_gridcreatecubedsphere proc~test_sph_vec_blnr_csg_to_llg test_sph_vec_blnr_csG_to_llG proc~test_sph_vec_blnr_csg_to_llg->interface~esmf_gridcreatecubedsphere proc~test_sph_vec_blnr_csg_to_llg_p test_sph_vec_blnr_csG_to_llG_p proc~test_sph_vec_blnr_csg_to_llg_p->interface~esmf_gridcreatecubedsphere program~esmf_gridcreateex ESMF_GridCreateEx program~esmf_gridcreateex->interface~esmf_gridcreatecubedsphere program~esmf_gridcreateutest ESMF_GridCreateUTest program~esmf_gridcreateutest->interface~esmf_gridcreatecubedsphere program~esmf_io_multitileutest ESMF_IO_MultitileUTest program~esmf_io_multitileutest->proc~createfields program~esmf_iocomputest ESMF_IOCompUTest program~esmf_iocomputest->proc~iocomputestsetup program~esmf_xgridutest ESMF_XGridUTest program~esmf_xgridutest->proc~test_csgridtogrid_2nd

Source Code

subroutine ESMF_UtilCreateCSCoordsPar(npts, LonEdge,LatEdge, start, count, tile, &
     LonCenter, LatCenter, schmidtTransform, local_algorithm)

! !ARGUMENTS:
    integer,           intent(IN)     :: npts
    real(ESMF_KIND_R8), optional, intent(inout) :: LonEdge(:,:)
    real(ESMF_KIND_R8), optional, intent(inout) :: LatEdge(:,:)
    integer, optional, intent(in)     :: start(:)
    integer, optional, intent(in)     :: count(:)
    integer, optional, intent(in)     :: tile
    real(ESMF_KIND_R8), optional, intent(inout) :: LonCenter(:,:)
    real(ESMF_KIND_R8), optional, intent(inout) :: LatCenter(:,:)
    type(ESMF_CubedSphereTransform_Args), optional, intent(in) :: schmidtTransform
    logical, optional, intent(in) :: local_algorithm

 integer                      :: STATUS

! Local variables
!-----------------
  integer, parameter            :: grid_type = 0
  integer                       :: ntiles=6
  integer                       :: ndims=2
  integer                       :: I, J, N
  integer                       :: IG, JG
  real(ESMF_KIND_R8)                          :: alocs(2)
  real(ESMF_KIND_R8), allocatable             :: tile1(:,:,:)
  integer                       :: rc
  real(ESMF_KIND_R8), allocatable             :: tile_local(:,:,:)
  real(ESMF_KIND_R8), allocatable, save       :: global_tile1(:,:,:)
  integer                       :: shapLon(2), shapLat(2)
  logical :: local_algorithm_

  local_algorithm_ = .false.
  if (present(local_algorithm)) local_algorithm_ = local_algorithm

  allocate(tile_local(count(1)+1,count(2)+1,ndims) )

  if (local_algorithm_) then
     call get_gnomonic_local_coords(grid_type, npts, start, tile_local(:,:,1), tile_local(:,:,2))
     call mirror_grid_local_new(tile_local, tile)
  else ! legacy algorithm using global sized tile
     allocate(global_tile1(npts+1,npts+1,ndims))
     call gnomonic_grids(grid_type, npts, global_tile1(:,:,1), global_tile1(:,:,2))
     call mirror_grid_local(tile_local, global_tile1, start, count, 2, tile)
     deallocate(global_tile1)
  end if

    ! mirror_grid assumes that the tile=1 is centered on equator and greenwich meridian Lon[-pi,pi]

!---------------------------------
! Shift the corner away from Japan for global tile #1
!---------------------------------
! This will result in the corner close to east coast of China

    ! fix the values in the local tile
    do j=1,count(2)+1
       do i=1,count(1)+1
           if (.not.present(schmidtTransform)) tile_local(i,j,1) = tile_local(i,j,1) - JAPAN_SHIFT
           if ( tile_local(i,j,1) < 0. )              &
                tile_local(i,j,1) = tile_local(i,j,1) + 2.*pi
           if (ABS(tile_local(i,j,1)) < 1.e-10) tile_local(i,j,1) = 0.0
           if (ABS(tile_local(i,j,2)) < 1.e-10) tile_local(i,j,2) = 0.0
       enddo
    enddo

    if (present(schmidtTransform)) then
     call direct_transform(schmidtTransform%stretch_factor,schmidtTransform%target_lon,&
          schmidtTransform%target_lat,tile_local(:,:,1),tile_local(:,:,2))
    end if
    
    if (present(LonEdge) .and. present(LatEdge)) then
       shapLon=shape(LonEdge)
       shapLat=shape(LatEdge)
       LonEdge=tile_local(1:shapLon(1),1:shapLon(2),1)
       LatEdge=tile_local(1:shapLat(1),1:shapLat(2),2)
    endif


    if (present(LonCenter) .and. present(LatCenter)) then
        do j=1, count(2)
           do i=1,count(1)
              call cell_center2(tile_local(i,j,  1), tile_local(i,j,    2),   &
                                tile_local(i+1,j,1), tile_local(i+1,j,  2),   &
                                tile_local(i,j+1,1), tile_local(i,j+1,  2),   &
                                tile_local(i+1,j+1,1), tile_local(i+1,j+1,2),   &
                                alocs)
              LonCenter(i,j) = alocs(1)
              LatCenter(i,j) = alocs(2)
           enddo
        enddo
     end if

     deallocate(tile_local)

     return

  end subroutine ESMF_UtilCreateCSCoordsPar