Skip to content

Commit

Permalink
Merge pull request #273 from sjsprecious/fix_gpu_error
Browse files Browse the repository at this point in the history
Fix GPU runtime error on NVIDIA A100 with nvhpc/24.3, thanks to @sjsprecious
  • Loading branch information
RobertPincus authored Mar 23, 2024
2 parents dc88744 + f6d4a63 commit 1b75505
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions rrtmgp-frontend/mo_gas_optics_rrtmgp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ function set_tsi(this, tsi) result(error_msg)
character(len=128) :: error_msg !! Empty if successful

real(wp) :: norm
integer :: igpt, length
! ----------------------------------------------------------
error_msg = ""
if(tsi < 0._wp) then
Expand All @@ -809,12 +810,21 @@ function set_tsi(this, tsi) result(error_msg)
!
! Scale the solar source function to the input tsi
!
!$acc kernels
!$omp target
norm = 1._wp/sum(this%solar_source(:))
this%solar_source(:) = this%solar_source(:) * tsi * norm
!$acc end kernels
!$omp end target
norm = 0._wp
length = size(this%solar_source)
!$acc parallel loop gang vector reduction(+:norm)
!$omp target teams distribute parallel do simd reduction(+:norm)
do igpt = 1, length
norm = norm + this%solar_source(igpt)
end do

norm = 1._wp/norm

!$acc parallel loop gang vector
!$omp target teams distribute parallel do simd
do igpt = 1, length
this%solar_source(igpt) = this%solar_source(igpt) * tsi * norm
end do
end if

end function set_tsi
Expand Down

0 comments on commit 1b75505

Please sign in to comment.