-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
In NEMOv4 dynspg_ts.f90, this expansion changes the results:
< zsshp2_e(:,:) = za1 * sshn_e(:,:) + za2 * sshb_e(:,:) + za3 * sshbb_e(:,:)
---
> loop_stop = UBOUND(zsshp2_e, dim=2)
> loop_start = LBOUND(zsshp2_e, dim=2)
> loop_stop_1 = UBOUND(zsshp2_e, dim=1)
> loop_start_1 = LBOUND(zsshp2_e, dim=1)
> !$acc parallel
> !$acc loop independent collapse(2)
> do idx = loop_start, loop_stop, 1
> do idx_1 = loop_start_1, loop_stop_1, 1
> zsshp2_e(idx_1,idx) = za1
* sshn_e(idx_1 + (LBOUND(sshn_e, dim=1) - LBOUND(zsshp2_e, dim=1)),idx + (LBOUND(sshn_e, dim=2) - LBOUND(zsshp2_e, dim=2)))
+ za2
* sshb_e(idx_1 + (LBOUND(sshb_e, dim=1) - LBOUND(zsshp2_e, dim=1)),idx + (LBOUND(sshb_e, dim=2) - LBOUND(zsshp2_e, dim=2)))
+ za3
* sshbb_e(idx_1 + (LBOUND(sshbb_e, dim=1) - LBOUND(zsshp2_e, dim=1)),idx + (LBOUND(sshbb_e, dim=2) - LBOUND(zsshp2_e, dim=2)))
> enddo
> enddo
> !$acc end parallel
but I think the code is correct, the variables are defined as
! Local variables
real(kind=wp) :: za1
real(kind=wp) :: za2
real(kind=wp) :: za3
real(kind=wp), dimension(jpi,jpj) :: zsshp2_e
! Imported
real(kind=wp), allocatable, dimension(:,:), public :: sshn_e
real(kind=wp), allocatable, dimension(:,:), public :: sshb_e
real(kind=wp), allocatable, dimension(:,:), public :: sshbb_e
ALLOCATE( sshn_e(jpi,jpj), sshb_e(jpi,jpj), sshbb_e(jpi,jpj) ...
In the past we also had problems with LBOUND UBOUND in the loop bounds expressions (this is why they are hoisted). Maybe we should not allow them inside offloaded regions (see also https://forums.developer.nvidia.com/t/out-of-bounds-issue-when-using-lbound-ubound-inside-an-openacc-kernel-with-nvfortran/320292)
Also this may only be a problem with allocatables?
Metadata
Metadata
Assignees
Labels
No labels