diff --git a/examples/arkode/CXX_parallel/ark_brusselator1D.h b/examples/arkode/CXX_parallel/ark_brusselator1D.h index 38cc6ee7a4..b95390bc4a 100644 --- a/examples/arkode/CXX_parallel/ark_brusselator1D.h +++ b/examples/arkode/CXX_parallel/ark_brusselator1D.h @@ -12,6 +12,9 @@ * SUNDIALS Copyright End * ---------------------------------------------------------------------------*/ +#ifndef _ARK_BRUSSELATOR1D_H +#define _ARK_BRUSSELATOR1D_H + #include #include #include @@ -266,3 +269,5 @@ static int check_retval(void* returnvalue, const char* funcname, int opt); static void gpuAssert(GPU_PREFIX(Error_t) code, const char* file, int line, int abort); #endif + +#endif diff --git a/examples/nvector/test_nvector.h b/examples/nvector/test_nvector.h index 9ff1c6163e..7984712649 100644 --- a/examples/nvector/test_nvector.h +++ b/examples/nvector/test_nvector.h @@ -15,6 +15,9 @@ * test an NVECTOR module implementation. * -----------------------------------------------------------------*/ +#ifndef _TEST_NVECTOR_H +#define _TEST_NVECTOR_H + #include #include @@ -146,3 +149,5 @@ void SetTiming(int onoff, int myid); #ifdef __cplusplus } #endif + +#endif diff --git a/examples/utilities/custom_memory_helper_gpu.h b/examples/utilities/custom_memory_helper_gpu.h index ca5950a7f9..08872f983e 100644 --- a/examples/utilities/custom_memory_helper_gpu.h +++ b/examples/utilities/custom_memory_helper_gpu.h @@ -15,6 +15,9 @@ * unmanaged memory only and synchronous copies. * -----------------------------------------------------------------*/ +#ifndef _CUSTOM_MEMORY_HELPER_GPU_H +#define _CUSTOM_MEMORY_HELPER_GPU_H + #include #include #if defined(__NVCC__) @@ -157,3 +160,5 @@ SUNMemoryHelper MyMemoryHelper(SUNContext sunctx) return helper; } + +#endif diff --git a/examples/utilities/custom_memory_helper_sycl.h b/examples/utilities/custom_memory_helper_sycl.h index 6af7c0d435..3135f3ad5d 100644 --- a/examples/utilities/custom_memory_helper_sycl.h +++ b/examples/utilities/custom_memory_helper_sycl.h @@ -15,6 +15,9 @@ * unmanaged memory only and synchronous copies. * -----------------------------------------------------------------*/ +#ifndef _CUSTOM_MEMORY_HELPER_SYCL_H +#define _CUSTOM_MEMORY_HELPER_SYCL_H + #include #include #include @@ -116,3 +119,5 @@ SUNMemoryHelper MyMemoryHelper(SUNContext sunctx) return helper; } + +#endif diff --git a/src/arkode/arkode.c b/src/arkode/arkode.c index 69ec2d37fe..eac2af4222 100644 --- a/src/arkode/arkode.c +++ b/src/arkode/arkode.c @@ -133,6 +133,7 @@ ARKodeMem arkCreate(SUNContext sunctx) { arkProcessError(NULL, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, "Allocation of step adaptivity structure failed"); + arkFree((void**)&ark_mem); return (NULL); } ark_mem->lrw += ARK_ADAPT_LRW; @@ -144,6 +145,7 @@ ARKodeMem arkCreate(SUNContext sunctx) { arkProcessError(NULL, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, "Allocation of step controller object failed"); + arkFree((void**)&ark_mem); return (NULL); } ark_mem->hadapt_mem->owncontroller = SUNTRUE; @@ -180,6 +182,7 @@ ARKodeMem arkCreate(SUNContext sunctx) { arkProcessError(NULL, 0, __LINE__, __func__, __FILE__, "Error setting default solver options"); + arkFree((void**)&ark_mem); return (NULL); } diff --git a/src/arkode/arkode_arkstep.c b/src/arkode/arkode_arkstep.c index 7e4361c516..0d7fc94394 100644 --- a/src/arkode/arkode_arkstep.c +++ b/src/arkode/arkode_arkstep.c @@ -89,6 +89,7 @@ void* ARKStepCreate(ARKRhsFn fe, ARKRhsFn fi, sunrealtype t0, N_Vector y0, { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_ARKMEM_FAIL); + ARKStepFree((void**)&ark_mem); return (NULL); } memset(step_mem, 0, sizeof(struct ARKodeARKStepMemRec)); diff --git a/src/arkode/arkode_erkstep.c b/src/arkode/arkode_erkstep.c index 1e80ea0f20..8fec869acf 100644 --- a/src/arkode/arkode_erkstep.c +++ b/src/arkode/arkode_erkstep.c @@ -85,6 +85,7 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) { arkProcessError(ark_mem, ARK_MEM_FAIL, __LINE__, __func__, __FILE__, MSG_ARK_ARKMEM_FAIL); + ERKStepFree((void**)&ark_mem); return (NULL); } memset(step_mem, 0, sizeof(struct ARKodeERKStepMemRec)); @@ -101,6 +102,7 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Error setting default solver options"); + ERKStepFree((void**)&ark_mem); return (NULL); } @@ -124,6 +126,7 @@ void* ERKStepCreate(ARKRhsFn f, sunrealtype t0, N_Vector y0, SUNContext sunctx) { arkProcessError(ark_mem, retval, __LINE__, __func__, __FILE__, "Unable to initialize main ARKODE infrastructure"); + ERKStepFree((void**)&ark_mem); return (NULL); } diff --git a/src/sundials/sundials_adiak_metadata.h b/src/sundials/sundials_adiak_metadata.h index 8013dbdc6b..4e7e908a66 100644 --- a/src/sundials/sundials_adiak_metadata.h +++ b/src/sundials/sundials_adiak_metadata.h @@ -12,6 +12,9 @@ * SUNDIALS Copyright End * ----------------------------------------------------------------*/ +#ifndef _SUNDIALS_ADIAK_METADATA_H +#define _SUNDIALS_ADIAK_METADATA_H + #ifdef SUNDIALS_ADIAK_ENABLED #include @@ -142,3 +145,5 @@ static void sunAdiakCollectMetadata() #endif } #endif + +#endif diff --git a/src/sundials/sundials_iterative_impl.h b/src/sundials/sundials_iterative_impl.h index 5ebf796761..ea6c17c10e 100644 --- a/src/sundials/sundials_iterative_impl.h +++ b/src/sundials/sundials_iterative_impl.h @@ -15,6 +15,9 @@ * different iterative solvers. * ---------------------------------------------------------------------------*/ +#ifndef _SUNDIALS_ITERATIVE_IMPL_H +#define _SUNDIALS_ITERATIVE_IMPL_H + #include /* ----------------------------------------------------------------------------- @@ -33,3 +36,5 @@ struct _SUNQRData N_Vector vtemp2; sunrealtype* temp_array; }; + +#endif