Skip to content

Commit

Permalink
Fix: dmUpdate nvhpc compile error (#1473)
Browse files Browse the repository at this point in the history
  • Loading branch information
rem1776 authored Mar 19, 2024
1 parent c7c0ffd commit 2ace945
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
5 changes: 4 additions & 1 deletion diag_manager/diag_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,10 @@ subroutine fms_add_attribute(this, att_name, att_value)
this%att_value = att_value
type is (character(len=*))
allocate(character(len=len(att_value)) :: this%att_value(natt))
this%att_value = att_value
select type(aval => this%att_value)
type is (character(len=*))
aval = att_value
end select
end select
end subroutine fms_add_attribute

Expand Down
27 changes: 22 additions & 5 deletions exchange/xgrid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,7 @@ end subroutine get_ocean_model_area_elements
!> @brief Sets up exchange grid connectivity using grid specification file and
!! processor domain decomposition.
subroutine setup_xmap(xmap, grid_ids, grid_domains, grid_file, atm_grid, lnd_ug_domain)
type (xmap_type), intent(inout) :: xmap
type(xmap_type), intent(inout) :: xmap
character(len=3), dimension(:), intent(in ) :: grid_ids
type(Domain2d), dimension(:), intent(in ) :: grid_domains
character(len=*), intent(in ) :: grid_file
Expand All @@ -1524,7 +1524,8 @@ subroutine setup_xmap(xmap, grid_ids, grid_domains, grid_file, atm_grid, lnd_ug_
integer :: g, p, i
integer :: nxgrid_file, i1, i2, i3, tile1, tile2, j
integer :: nxc, nyc, out_unit
type (grid_type), pointer, save :: grid =>NULL(), grid1 =>NULL()
type(grid_type), pointer :: grid => NULL()!< pointer to loop through grid_type's in list
type(grid_type), pointer, save :: grid1 => NULL() !< saved pointer to the first grid in the list
real(r8_kind), dimension(3) :: xxx
real(r8_kind), dimension(:,:), allocatable :: check_data
real(r8_kind), dimension(:,:,:), allocatable :: check_data_3D
Expand All @@ -1541,6 +1542,8 @@ subroutine setup_xmap(xmap, grid_ids, grid_domains, grid_file, atm_grid, lnd_ug_
integer :: lnd_ug_id, l
integer, allocatable :: grid_index(:)
type(FmsNetcdfFile_t) :: gridfileobj, mosaicfileobj, fileobj
type(grid_type), allocatable, target :: grids_tmp(:) !< added for nvhpc workaround, stores xmap's
!! grid_type array so we can safely point to it

call mpp_clock_begin(id_setup_xmap)

Expand Down Expand Up @@ -1593,9 +1596,17 @@ subroutine setup_xmap(xmap, grid_ids, grid_domains, grid_file, atm_grid, lnd_ug_
endif

call mpp_clock_begin(id_load_xgrid)
do g=1,size(grid_ids(:))
grid => xmap%grids(g)
if (g==1) grid1 => xmap%grids(g)

! nvhpc compiler workaround
! saves grid array as an allocatable and points to that to avoid error from pointing to xmap%grids in loop
grids_tmp = xmap%grids

grid1 => xmap%grids(1)

do g=1, size(grid_ids(:))

grid => grids_tmp(g)

grid%id = grid_ids (g)
grid%domain = grid_domains(g)
grid%on_this_pe = mpp_domain_is_initialized(grid_domains(g))
Expand Down Expand Up @@ -1855,6 +1866,9 @@ subroutine setup_xmap(xmap, grid_ids, grid_domains, grid_file, atm_grid, lnd_ug_
grid%frac_area = 1.0_r8_kind
endif

! nvhpc workaround, needs to save the grid pointer since its allocatable
xmap%grids(g) = grid

! load exchange cells, sum grid cell areas, set your1my2/your2my1
select case(xmap%version)
case(VERSION1)
Expand Down Expand Up @@ -1960,6 +1974,9 @@ subroutine setup_xmap(xmap, grid_ids, grid_domains, grid_file, atm_grid, lnd_ug_
where (grid%area>0.0_r8_kind) grid%area_inv = 1.0_r8_kind/grid%area
endif
end if

! nvhpc workaround, needs to save the grid pointer since its allocatable
xmap%grids(g) = grid
end do

if(xmap%version == VERSION2) call close_file(gridfileobj)
Expand Down

0 comments on commit 2ace945

Please sign in to comment.