Skip to content

Commit

Permalink
transi: Throw errors gracefully for known not-yet-implemented code pa…
Browse files Browse the repository at this point in the history
…ths, rather than MPL_ABORT
  • Loading branch information
wdeconinck committed Dec 19, 2024
1 parent a2f4281 commit 76eb4a2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/transi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if( HAVE_GPU )
PUBLIC_INCLUDES $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE_LIBS trans_gpu_dp
PRIVATE_DEFINITIONS ECTRANS_HAVE_MPI=${ectrans_HAVE_MPI}
PRIVATE_DEFINITIONS ECTRANS_HAVE_MPI=${ectrans_HAVE_MPI} ECTRANS_GPU_VERSION
)
if( HAVE_ACC AND CMAKE_Fortran_COMPILER_ID MATCHES NVHPC )
# Propagate flags as link options for downstream targets. Only required for NVHPC
Expand Down
2 changes: 1 addition & 1 deletion src/transi/transi.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const char* trans_error_msg(int errcode)
case TRANS_ERROR:
return "Trans: Error";
case TRANS_NOTIMPL:
return "Trans: Not (yet) implemented";
return "Trans: Not implemented";
case TRANS_MISSING_ARG:
return "Trans: Required member of the argument structure is missing or not allocated";
case TRANS_UNRECOGNIZED_ARG:
Expand Down
27 changes: 27 additions & 0 deletions src/transi/transi_module.F90
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,15 @@ function trans_setup(trans) bind(C,name="trans_setup") result(iret)
if( trans%llatlon /= 0 ) llatlon = .True.
if( trans%llatlon == 2 ) llatlonshift = .True.

#ifdef ECTRANS_GPU_VERSION
if (llatlon) then
call transi_error("trans_setup: lonlat grid input not (yet) implemented for GPU")
trans%handle = 0 ! Not created!
iret = TRANS_NOTIMPL
return
endif
#endif

if ( .not. is_init ) then
err = trans_init()
endif
Expand Down Expand Up @@ -1621,6 +1630,12 @@ function trans_dirtrans_adj(args) bind(C,name="trans_dirtrans_adj") result(iret)
RGPM => RGP
endif

#ifdef ECTRANS_GPU_VERSION
call transi_error("trans_dirtrans_adj: ERROR: Not implemented for GPU")
iret = TRANS_NOTIMPL
return
#endif

if( args%nvordiv > 0 .and. args%nscalar > 0 ) then
call DIR_TRANSAD( KRESOL=trans%handle, &
& KPROMA=args%nproma, &
Expand Down Expand Up @@ -1861,6 +1876,13 @@ function trans_invtrans_adj(args) bind(C,name="trans_invtrans_adj") result(iret)
RGPM => RGP
endif

#ifdef ECTRANS_GPU_VERSION
call transi_error("trans_invtrans_adj: ERROR: Not implemented for GPU")
iret = TRANS_NOTIMPL
return
#endif


! Note that llatlon is not an option in INV_TRANSAD unlile INV_TRANS and DIR_TRANS
if( args%nvordiv > 0 .and. args%nscalar > 0 ) then
call INV_TRANSAD( KRESOL=trans%handle, &
Expand Down Expand Up @@ -2293,6 +2315,11 @@ function trans_vordiv_to_UV(args) bind(C,name="trans_vordiv_to_UV") result(iret)
endif
call C_F_POINTER( args%rspv, RSPV, (/args%nfld,args%ncoeff/) )

#ifdef ECTRANS_GPU_VERSION
call transi_error("trans_vordiv_to_UV: ERROR: Not implemented for GPU")
iret = TRANS_NOTIMPL
return
#endif

if ( .not. is_init ) then
err = trans_init()
Expand Down

0 comments on commit 76eb4a2

Please sign in to comment.