!
! Copyright (C) 2022, MaX CoE
! Distributed under the MIT License 
! (license terms are at http://opensource.org/licenses/MIT).
!
!--
!
! Utility functions to check allocation status on the device
! using CUDA-Fortran, OpenACC or OpenMP Offload
!
!==================================================================
!==================================================================
! *DO NOT EDIT*: automatically generated from devxlib_malloc_allocated.jf90
!==================================================================
!==================================================================
!
#include<devxlib_macros.h>
#include<devxlib_defs.h>
!
!=======================================
!
submodule (devxlib_malloc) devxlib_malloc_allocated

   implicit none

   contains
{%- for t in types %}
{%- for p in kinds[t] %}
{%- for d in range(1,dimensions+1) %}
      module function {{p.name}}_devxlib_malloc_allocated_{{t[0]|lower}}{{d}}d(array) result(res)
          implicit none
          !
          logical :: res
          {{t}}({{p.val}}), allocatable, intent(in) DEV_ATTR :: array({% for dd in range(d) %}:{% if not loop.last %}, {%- endif %}{% endfor %})
          res=allocated(array)
          return
      end function {{p.name}}_devxlib_malloc_allocated_{{t[0]|lower}}{{d}}d
      !
{%- endfor %}
{%- endfor %}
{%- endfor %}

{%- for t in types %}
{%- for p in kinds[t] %}
{%- for d in range(1,dimensions+1) %}
      module function {{p.name}}_devxlib_malloc_allocated_{{t[0]|lower}}{{d}}d_p(dev_ptr) result(res)
          implicit none
          !
          logical :: res
          {{t}}({{p.val}}), pointer, intent(in) DEV_ATTR :: dev_ptr({% for dd in range(d) %}:{% if not loop.last %}, {%- endif %}{% endfor %})
          res=associated(dev_ptr)
          return
      end function {{p.name}}_devxlib_malloc_allocated_{{t[0]|lower}}{{d}}d_p
      !
{%- endfor %}
{%- endfor %}
{%- endfor %}

endsubmodule devxlib_malloc_allocated
