Skip to content

Commit

Permalink
Work around NVHPC/PGI issue with procedure pointers inside type used by
Browse files Browse the repository at this point in the history
ESMX_Driver implementation.
  • Loading branch information
theurich committed Aug 23, 2023
1 parent 6dad975 commit 99d1bf3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 4 deletions.
30 changes: 28 additions & 2 deletions src/addon/ESMX/Driver/ESMX_Driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,37 @@ module ESMX_Driver

public SetServices, SetVM, HConfigCreateFoundNode

#if defined (__NVCOMPILER) || defined (__PGI)
!TODO: remove once NVHPC and PGI compilers work correctly w/o work-around

abstract interface
recursive subroutine SetServicesRoutine(gridcomp, rc)
use ESMF
implicit none
type(ESMF_GridComp) :: gridcomp ! must not be optional
integer, intent(out) :: rc ! must not be optional
end subroutine
recursive subroutine SetVMRoutine(gridcomp, rc)
use ESMF
implicit none
type(ESMF_GridComp) :: gridcomp ! must not be optional
integer, intent(out) :: rc ! must not be optional
end subroutine
end interface

type type_CompDef
procedure(SetServicesRoutine), pointer, nopass :: ssPtr => null()
procedure(SetVMRoutine), pointer, nopass :: svPtr => null()
character(ESMF_MAXSTR) :: name = "__uninitialized__"
end type

#else
type type_CompDef
procedure(SetServices), pointer, nopass :: ssPtr => null()
procedure(SetVM), pointer, nopass :: svPtr => null()
character(ESMF_MAXSTR) :: name = "__uninitialized__"
end type
#endif

include "compCnt.inc"

Expand Down Expand Up @@ -261,8 +287,8 @@ subroutine SetModelServices(driver, rc)

if (inCompDef) then
! add child component with SetVM and SetServices in CompDef
#ifdef __INTEL_LLVM_COMPILER
!TODO: remove once IFX works correctly and does not require this work-around
#if defined (__INTEL_LLVM_COMPILER) || (__NVCOMPILER) || defined (__PGI)
!TODO: remove once IFX, NVHPC, and PGI compilers work correctly w/o work-around
call NUOPC_DriverAddGridCompPtr(driver, trim(compLabel), config=config, &
compSetServicesRoutine=CompDef(j)%ssPtr, compSetVMRoutine=CompDef(j)%svPtr, &
info=info, petList=petList, comp=comp, rc=rc)
Expand Down
4 changes: 2 additions & 2 deletions src/addon/NUOPC/src/NUOPC_Driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module NUOPC_Driver

! Generic methods
public NUOPC_DriverAddComp
#ifdef __INTEL_LLVM_COMPILER
#if defined (__INTEL_LLVM_COMPILER) || (__NVCOMPILER) || defined (__PGI)
public NUOPC_DriverAddGridCompPtr !TODO: remove once IFX works correctly
#endif
public NUOPC_DriverAddRunElement
Expand Down Expand Up @@ -4522,7 +4522,7 @@ recursive subroutine FinalizeReset(driver, importState, exportState, clock, rc)
!-----------------------------------------------------------------------------
!-----------------------------------------------------------------------------

#ifdef __INTEL_LLVM_COMPILER
#if defined (__INTEL_LLVM_COMPILER) || defined (__NVCOMPILER) || defined (__PGI)
!-----------------------------------------------------------------------------
!BOPI
! !IROUTINE: NUOPC_DriverAddComp - Add a GridComp child to a Driver using procedure pointers
Expand Down

0 comments on commit 99d1bf3

Please sign in to comment.