! (C) Copyright 2013 ECMWF. ! ! This software is licensed under the terms of the Apache Licence Version 2.0 ! which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. ! In applying this licence, ECMWF does not waive the privileges and immunities ! granted to it by virtue of its status as an intergovernmental organisation nor ! does it submit to any jurisdiction. #include "atlas/atlas_f.h" #:include "atlas/atlas_f.fypp" #:include "internals/atlas_generics.fypp" module atlas_FieldSet_module use fckit_owned_object_module, only: fckit_owned_object use atlas_field_module, only: atlas_field, array_c_to_f use atlas_kinds_module, only : ATLAS_KIND_IDX implicit none private :: fckit_owned_object public :: atlas_FieldSet private !------------------------------------------------------------------------------ TYPE, extends(fckit_owned_object) :: atlas_FieldSet ! Purpose : ! ------- ! *FieldSet* : Object that groups Fields that go together ! Fields can belong to several fieldsets simultaneously. ! The actual ownership of the field lies in a FunctionSpace ! Methods : ! ------- ! add_field : The name or tag this field was created with ! field : Return the field as a fortran array of specified shape ! Author : ! ------ ! 20-Nov-2013 Willem Deconinck *ECMWF* !------------------------------------------------------------------------------ contains procedure, public :: name => FieldSet__name procedure, public :: size => FieldSet__size procedure, public :: has procedure, private :: field_by_name procedure, private :: field_by_idx_int procedure, private :: field_by_idx_long procedure, public :: add_field procedure, public :: add_fieldset generic :: add => add_field, add_fieldset generic :: field => field_by_name, field_by_idx_int, field_by_idx_long procedure, public :: set_dirty procedure, public :: halo_exchange #:for rank in ranks #:for dtype in dtypes procedure, private :: access_data_${dtype}$_r${rank}$_by_name procedure, private :: access_data_${dtype}$_r${rank}$_by_idx procedure, private :: access_data_${dtype}$_r${rank}$_slice_by_name procedure, private :: access_data_${dtype}$_r${rank}$_slice_by_idx procedure, private :: access_device_data_${dtype}$_r${rank}$_by_name procedure, private :: access_device_data_${dtype}$_r${rank}$_by_idx #:endfor #:endfor generic, public :: data => & #:for rank in ranks #:for dtype in dtypes & access_data_${dtype}$_r${rank}$_by_name, & & access_data_${dtype}$_r${rank}$_by_idx, & & access_data_${dtype}$_r${rank}$_slice_by_name, & & access_data_${dtype}$_r${rank}$_slice_by_idx, & #:endfor #:endfor & dummy generic, public :: device_data => & #:for rank in ranks #:for dtype in dtypes & access_device_data_${dtype}$_r${rank}$_by_name, & & access_device_data_${dtype}$_r${rank}$_by_idx, & #:endfor #:endfor & dummy procedure, private :: dummy procedure, public :: set_host_needs_update_idx procedure, public :: set_host_needs_update_value procedure, public :: set_host_needs_update_name generic :: set_host_needs_update => set_host_needs_update_idx, set_host_needs_update_value, & set_host_needs_update_name procedure, public :: set_device_needs_update_idx procedure, public :: set_device_needs_update_value procedure, public :: set_device_needs_update_name generic :: set_device_needs_update => set_device_needs_update_idx, set_device_needs_update_value, & set_device_needs_update_name procedure, public :: sync_host_device_idx procedure, public :: sync_host_device_name generic :: sync_host_device => sync_host_device_idx, sync_host_device_name procedure, public :: sync_host_idx procedure, public :: sync_host_name generic :: sync_host => sync_host_idx, sync_host_name procedure, public :: sync_device_idx procedure, public :: sync_device_name generic :: sync_device => sync_device_idx, sync_device_name procedure, public :: allocate_device_idx procedure, public :: allocate_device_name generic :: allocate_device => allocate_device_idx, allocate_device_name procedure, public :: update_device_idx procedure, public :: update_device_name generic :: update_device => update_device_idx, update_device_name procedure, public :: update_host_idx procedure, public :: update_host_name generic :: update_host => update_host_idx, update_host_name procedure, public :: deallocate_device_idx procedure, public :: deallocate_device_name generic :: deallocate_device => deallocate_device_idx, deallocate_device_name #if FCKIT_FINAL_NOT_INHERITING final :: atlas_FieldSet__final_auto #endif procedure, public :: has_field => has ! deprecated ! END TYPE atlas_FieldSet !------------------------------------------------------------------------------ interface atlas_FieldSet module procedure atlas_FieldSet__cptr module procedure atlas_FieldSet__ctor end interface !------------------------------------------------------------------------------ !======================================================== contains !======================================================== ! ----------------------------------------------------------------------------- ! FieldSet routines #:for rank in ranks #:for dtype,ftype,ctype in types subroutine access_data_${dtype}$_r${rank}$_by_name(this, name, field) use fckit_c_interop_module, only: c_str use atlas_fieldset_c_binding use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_long, c_float, c_double class(atlas_FieldSet), intent(in) :: this character(len=*), intent(in) :: name ${ftype}$, pointer, intent(inout) :: field(${dim[rank]}$) type(c_ptr) :: field_cptr type(c_ptr) :: shape_cptr type(c_ptr) :: strides_cptr integer(c_int) :: rank call atlas__FieldSet__data_${ctype}$_specf(this%CPTR_PGIBUG_A, c_str(name), field_cptr, rank, shape_cptr, strides_cptr) call array_c_to_f(field_cptr, rank, shape_cptr, strides_cptr, field) end subroutine subroutine access_data_${dtype}$_r${rank}$_by_idx(this, idx, field) use fckit_c_interop_module, only: c_str use atlas_fieldset_c_binding use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_long, c_float, c_double class(atlas_FieldSet), intent(in) :: this integer, intent(in) :: idx ${ftype}$, pointer, intent(inout) :: field(${dim[rank]}$) type(c_ptr) :: field_cptr type(c_ptr) :: shape_cptr type(c_ptr) :: strides_cptr integer(c_int) :: rank call atlas__FieldSet__data_${ctype}$_specf_by_idx(this%CPTR_PGIBUG_A, idx-1, field_cptr, rank, shape_cptr, strides_cptr) call array_c_to_f(field_cptr, rank, shape_cptr, strides_cptr, field) end subroutine subroutine access_data_${dtype}$_r${rank}$_slice_by_name(this, name, slice, iblk) use fckit_c_interop_module, only: c_str use atlas_fieldset_c_binding use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_long, c_float, c_double class(atlas_FieldSet), intent(in) :: this character(len=*), intent(in) :: name #:if rank > 1 ${ftype}$, pointer, intent(inout) :: slice(${dimr[rank]}$) #:else ${ftype}$, pointer, intent(inout) :: slice #:endif integer, intent(in) :: iblk ${ftype}$, pointer :: field(${dim[rank]}$) call access_data_${dtype}$_r${rank}$_by_name(this, c_str(name), field) #:if rank > 1 slice => field(${dimr[rank]}$, iblk) #:else slice => field(iblk) #:endif end subroutine subroutine access_data_${dtype}$_r${rank}$_slice_by_idx(this, idx, slice, iblk) use fckit_c_interop_module, only: c_str use atlas_fieldset_c_binding use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_long, c_float, c_double class(atlas_FieldSet), intent(in) :: this integer, intent(in) :: idx #:if rank > 1 ${ftype}$, pointer, intent(inout) :: slice(${dimr[rank]}$) #:else ${ftype}$, pointer, intent(inout) :: slice #:endif integer, intent(in) :: iblk ${ftype}$, pointer :: field(${dim[rank]}$) call access_data_${dtype}$_r${rank}$_by_idx(this, idx, field) #:if rank > 1 slice => field(${dimr[rank]}$, iblk) #:else slice => field(iblk) #:endif end subroutine !------------------------------------------------------------------------------- subroutine access_device_data_${dtype}$_r${rank}$_by_name(this, name, field) use fckit_c_interop_module, only: c_str use atlas_field_c_binding use atlas_Field_module, only: atlas_Field use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_long, c_float, c_double class(atlas_FieldSet), intent(in) :: this character(len=*), intent(in) :: name ${ftype}$, pointer, intent(inout) :: field(${dim[rank]}$) type(c_ptr) :: field_cptr type(c_ptr) :: shape_cptr type(c_ptr) :: strides_cptr integer(c_int) :: rank type(atlas_Field) :: field_sel field_sel = this%field(name) call atlas__Field__device_data_${ctype}$_specf(field_sel%CPTR_PGIBUG_A, field_cptr, rank, shape_cptr, strides_cptr) call array_c_to_f(field_cptr, rank, shape_cptr, strides_cptr, field) end subroutine !------------------------------------------------------------------------------- subroutine access_device_data_${dtype}$_r${rank}$_by_idx(this, idx, field) use fckit_c_interop_module, only: c_str use atlas_field_c_binding use atlas_Field_module, only: atlas_Field use, intrinsic :: iso_c_binding, only : c_ptr, c_int, c_long, c_float, c_double class(atlas_FieldSet), intent(in) :: this integer, intent(in) :: idx ${ftype}$, pointer, intent(inout) :: field(${dim[rank]}$) type(c_ptr) :: field_cptr type(c_ptr) :: shape_cptr type(c_ptr) :: strides_cptr integer(c_int) :: rank type(atlas_Field) :: field_loc field_loc = this%field(idx) call atlas__Field__device_data_${ctype}$_specf(field_loc%CPTR_PGIBUG_A, field_cptr, rank, shape_cptr, strides_cptr) call array_c_to_f(field_cptr, rank, shape_cptr, strides_cptr, field) end subroutine !------------------------------------------------------------------------------- #:endfor #:endfor subroutine dummy(this) use atlas_fieldset_c_binding class(atlas_FieldSet), intent(in) :: this FCKIT_SUPPRESS_UNUSED(this) end subroutine function atlas_FieldSet__cptr(cptr) result(fieldset) use, intrinsic :: iso_c_binding, only: c_ptr type(atlas_FieldSet) :: fieldset type(c_ptr), intent(in) :: cptr call fieldset%reset_c_ptr( cptr ) call fieldset%return() end function function atlas_FieldSet__ctor(name) result(fieldset) use fckit_c_interop_module, only: c_str use atlas_fieldset_c_binding character(len=*), intent(in), optional :: name type(atlas_FieldSet) :: fieldset if( present(name) ) then fieldset = atlas_FieldSet__cptr( atlas__FieldSet__new( c_str(name) ) ) else fieldset = atlas_FieldSet__cptr( atlas__FieldSet__new( c_str("") ) ) endif call fieldset%return() end function function FieldSet__name(this) result(fieldset_name) use, intrinsic :: iso_c_binding, only : c_ptr use fckit_c_interop_module, only : c_ptr_to_string, c_str use atlas_fieldset_c_binding class(atlas_FieldSet), intent(in) :: this character(len=:), allocatable :: fieldset_name type(c_ptr) :: fieldset_name_c_str fieldset_name_c_str = atlas__FieldSet__name(this%CPTR_PGIBUG_A) fieldset_name = c_ptr_to_string(fieldset_name_c_str) end function FieldSet__name subroutine add_field(this,field) use atlas_fieldset_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(in) :: this type(atlas_Field), intent(in) :: field call atlas__FieldSet__add_field(this%CPTR_PGIBUG_A, field%CPTR_PGIBUG_A) end subroutine subroutine add_fieldset(this,fset) use atlas_fieldset_c_binding class(atlas_FieldSet), intent(inout) :: this class(atlas_FieldSet), intent(in) :: fset call atlas__FieldSet__add_fieldset(this%CPTR_PGIBUG_A, fset%CPTR_PGIBUG_A) end subroutine function has(this,name) result(flag) use, intrinsic :: iso_c_binding, only: c_int use fckit_c_interop_module, only: c_str use atlas_fieldset_c_binding class(atlas_FieldSet), intent(in) :: this character(len=*), intent(in) :: name logical :: flag integer(c_int) :: rc rc = atlas__FieldSet__has_field(this%CPTR_PGIBUG_A, c_str(name)) if( rc == 0 ) then flag = .False. else flag = .True. end if end function function FieldSet__size(this) result(nb_fields) use atlas_fieldset_c_binding class(atlas_FieldSet), intent(in) :: this integer(ATLAS_KIND_IDX) :: nb_fields nb_fields = atlas__FieldSet__size(this%CPTR_PGIBUG_A) end function function field_by_name(this,name) result(field) use fckit_c_interop_module, only: c_str use atlas_fieldset_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(in) :: this character(len=*), intent(in) :: name type(atlas_Field) :: field field = atlas_Field( atlas__FieldSet__field_by_name(this%CPTR_PGIBUG_A, c_str(name) ) ) call field%return() end function function field_by_idx_long(this,idx) result(field) use, intrinsic :: iso_c_binding, only: c_long use atlas_fieldset_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(in) :: this integer(c_long), intent(in) :: idx type(atlas_Field) :: field field = atlas_Field( atlas__FieldSet__field_by_idx(this%CPTR_PGIBUG_A, int(idx-1_c_long,ATLAS_KIND_IDX) ) ) ! C index call field%return() end function function field_by_idx_int(this,idx) result(field) use, intrinsic :: iso_c_binding, only: c_int use atlas_fieldset_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(in) :: this integer(c_int), intent(in) :: idx type(atlas_Field) :: field field = atlas_Field( atlas__FieldSet__field_by_idx(this%CPTR_PGIBUG_A, int(idx-1_c_int,ATLAS_KIND_IDX) ) ) ! C index call field%return() end function !------------------------------------------------------------------------------- subroutine halo_exchange(this,on_device) use, intrinsic :: iso_c_binding, only : c_int use atlas_fieldset_c_binding class(atlas_FieldSet), intent(inout) :: this logical, optional :: on_device integer(c_int) :: on_device_int on_device_int = 0 if( present(on_device) ) then if( on_device ) on_device_int = 1 endif call atlas__FieldSet__halo_exchange(this%CPTR_PGIBUG_A, on_device_int) end subroutine !------------------------------------------------------------------------------- subroutine set_host_needs_update_value(this, value) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this logical, intent(in), optional :: value type(atlas_Field) :: field integer(c_int) :: i, value_int value_int = 1 if (present(value)) then if (.not. value) then value_int = 0 end if end if do i = 1, this%size() field = this%field(i) call atlas__Field__set_host_needs_update(field%CPTR_PGIBUG_A, value_int) end do end subroutine !------------------------------------------------------------------------------- subroutine set_host_needs_update_idx(this, field_indices, value) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, intent(in) :: field_indices(:) logical, intent(in), optional :: value type(atlas_Field) :: field integer(c_int) :: i, value_int value_int = 1 if (present(value)) then if (.not. value) then value_int = 0 end if end if do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__set_host_needs_update(field%CPTR_PGIBUG_A, value_int) end do end subroutine !------------------------------------------------------------------------------- subroutine set_host_needs_update_name(this, field_names, value) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) logical, intent(in), optional :: value type(atlas_Field) :: field integer(c_int) :: i, value_int value_int = 1 if (present(value)) then if (.not. value) then value_int = 0 end if end if do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__set_host_needs_update(field%CPTR_PGIBUG_A, value_int) end do end subroutine !------------------------------------------------------------------------------- subroutine set_device_needs_update_value(this, value) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this logical, intent(in), optional :: value type(atlas_Field) :: field integer(c_int) :: i, value_int value_int = 1 if (present(value)) then if (.not. value) then value_int = 0 end if end if do i = 1, this%size() field = this%field(i) call atlas__Field__set_device_needs_update(field%CPTR_PGIBUG_A, value_int) end do end subroutine !------------------------------------------------------------------------------- subroutine set_device_needs_update_idx(this, field_indices, value) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, intent(in) :: field_indices(:) logical, intent(in), optional :: value type(atlas_Field) :: field integer(c_int) :: i, value_int value_int = 1 if (present(value)) then if (.not. value) then value_int = 0 end if end if do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__set_device_needs_update(field%CPTR_PGIBUG_A, value_int) end do end subroutine !------------------------------------------------------------------------------- subroutine set_device_needs_update_name(this, field_names, value) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) logical, intent(in), optional :: value type(atlas_Field) :: field integer(c_int) :: i, value_int value_int = 1 if (present(value)) then if (.not. value) then value_int = 0 end if end if do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__set_device_needs_update(field%CPTR_PGIBUG_A, value_int) end do end subroutine !------------------------------------------------------------------------------- subroutine sync_host_device_idx(this, field_indices) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, intent(in), optional :: field_indices(:) type(atlas_Field) :: field integer(c_int) :: i if (present(field_indices)) then do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__sync_host_device(field%CPTR_PGIBUG_A) end do else do i = 1, this%size() field = this%field(i) call atlas__Field__sync_host_device(field%CPTR_PGIBUG_A) end do end if end subroutine !------------------------------------------------------------------------------- subroutine sync_host_device_name(this, field_names) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) type(atlas_Field) :: field integer(c_int) :: i do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__sync_host_device(field%CPTR_PGIBUG_A) end do end subroutine !------------------------------------------------------------------------------- subroutine sync_host_idx(this, field_indices) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, intent(in), optional :: field_indices(:) type(atlas_Field) :: field integer(c_int) :: i if (present(field_indices)) then do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__sync_host(field%CPTR_PGIBUG_A) end do else do i = 1, this%size() field = this%field(i) call atlas__Field__sync_host(field%CPTR_PGIBUG_A) end do end if end subroutine !------------------------------------------------------------------------------- subroutine sync_host_name(this, field_names) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) type(atlas_Field) :: field integer(c_int) :: i do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__sync_host(field%CPTR_PGIBUG_A) end do end subroutine !------------------------------------------------------------------------------- subroutine sync_device_idx(this, field_indices) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, intent(in), optional :: field_indices(:) type(atlas_Field) :: field integer(c_int) :: i if (present(field_indices)) then do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__sync_device(field%CPTR_PGIBUG_A) end do else do i = 1, this%size() field = this%field(i) call atlas__Field__sync_device(field%CPTR_PGIBUG_A) end do end if end subroutine !------------------------------------------------------------------------------- subroutine sync_device_name(this, field_names) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) type(atlas_Field) :: field integer(c_int) :: i do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__sync_device(field%CPTR_PGIBUG_A) end do end subroutine !------------------------------------------------------------------------------- subroutine allocate_device_idx(this, field_indices) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, intent(in), optional :: field_indices(:) type(atlas_Field) :: field integer(c_int) :: i if (present(field_indices)) then do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__allocate_device(field%CPTR_PGIBUG_A) end do else do i = 1, this%size() field = this%field(i) call atlas__Field__allocate_device(field%CPTR_PGIBUG_A) end do end if end subroutine !------------------------------------------------------------------------------- subroutine allocate_device_name(this, field_names) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) type(atlas_Field) :: field integer(c_int) :: i do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__allocate_device(field%CPTR_PGIBUG_A) end do end subroutine !------------------------------------------------------------------------------- subroutine update_device_idx(this, field_indices) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, intent(in), optional :: field_indices(:) type(atlas_Field) :: field integer(c_int) :: i if (present(field_indices)) then do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__update_device(field%CPTR_PGIBUG_A) end do else do i = 1, this%size() field = this%field(i) call atlas__Field__update_device(field%CPTR_PGIBUG_A) end do end if end subroutine !------------------------------------------------------------------------------- subroutine update_device_name(this, field_names) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) type(atlas_Field) :: field integer(c_int) :: i do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__update_device(field%CPTR_PGIBUG_A) end do end subroutine !------------------------------------------------------------------------------- subroutine update_host_idx(this, field_indices) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, intent(in), optional :: field_indices(:) type(atlas_Field) :: field integer(c_int) :: i if (present(field_indices)) then do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__update_host(field%CPTR_PGIBUG_A) end do else do i = 1, this%size() field = this%field(i) call atlas__Field__update_host(field%CPTR_PGIBUG_A) end do end if end subroutine !------------------------------------------------------------------------------- subroutine update_host_name(this, field_names) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) type(atlas_Field) :: field integer(c_int) :: i do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__update_host(field%CPTR_PGIBUG_A) end do end subroutine !------------------------------------------------------------------------------- subroutine deallocate_device_idx(this, field_indices) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this integer, optional :: field_indices(:) type(atlas_Field) :: field integer(c_int) :: i if (present(field_indices)) then do i = 1, size(field_indices) field = this%field(field_indices(i)) call atlas__Field__deallocate_device(field%CPTR_PGIBUG_A) end do else do i = 1, this%size() field = this%field(i) call atlas__Field__deallocate_device(field%CPTR_PGIBUG_A) end do end if end subroutine !------------------------------------------------------------------------------- subroutine deallocate_device_name(this, field_names) use, intrinsic :: iso_c_binding, only : c_int use atlas_field_c_binding use atlas_Field_module, only: atlas_Field class(atlas_FieldSet), intent(inout) :: this character(*), intent(in) :: field_names(:) type(atlas_Field) :: field integer(c_int) :: i do i = 1, size(field_names) field = this%field(field_names(i)) call atlas__Field__deallocate_device(field%CPTR_PGIBUG_A) end do end subroutine !------------------------------------------------------------------------------- subroutine set_dirty(this,value) use, intrinsic :: iso_c_binding, only : c_int use atlas_fieldset_c_binding class(atlas_FieldSet), intent(inout) :: this logical, optional, intent(in) :: value integer(c_int) :: value_int if( present(value) ) then if( value ) then value_int = 1 else value_int = 0 endif else value_int = 1 endif call atlas__FieldSet__set_dirty(this%CPTR_PGIBUG_A, value_int) end subroutine !------------------------------------------------------------------------------- #if FCKIT_FINAL_NOT_INHERITING ATLAS_FINAL subroutine atlas_FieldSet__final_auto(this) type(atlas_FieldSet), intent(inout) :: this #if FCKIT_FINAL_DEBUGGING write(0,*) "atlas_FieldSet__final_auto" #endif #if FCKIT_FINAL_NOT_PROPAGATING call this%final() #endif FCKIT_SUPPRESS_UNUSED( this ) end subroutine #endif ! ---------------------------------------------------------------------------------------- end module atlas_FieldSet_module