tem_commbuf_int_fillmpimem Subroutine

private subroutine tem_commbuf_int_fillmpimem(me, pos, nvals)

fill the positions that describe how the data in the state vector relates to the entries in the buffer use memory that is allocated by mpi for the buffer.

Arguments

Type IntentOptional Attributes Name
type(tem_intbuffer_type), intent(inout) :: me
integer, intent(in) :: pos(nvals)
integer, intent(in) :: nvals

Source Code

  subroutine tem_commbuf_int_fillmpimem( me, pos, nvals )
    ! -------------------------------------------------------------------- !
    type(tem_intbuffer_type), intent(inout) :: me
    integer, intent(in) :: nvals
    integer, intent(in) :: pos(nvals)
    ! -------------------------------------------------------------------- !
    integer :: typesample
    integer(kind=mpi_address_kind) :: typelen
    ! -------------------------------------------------------------------- !

    typelen = int(c_sizeof(typesample), kind=mpi_address_kind)

    me%nvals = nvals

    if ( allocated(me%pos) ) deallocate(me%pos)
    allocate(me%pos(nvals))
    me%pos = pos

    if ( associated(me%val) ) then
      nullify(me%val)
      call free_mpif_mem(me%mem_mpi)
    end if
    call alloc_mpif_mem( asize   = nvals*typelen, &
      &                  baseptr = me%mem_mpi     )
    call c_f_pointer(me%mem_mpi, me%val, [me%nvals])

  end subroutine tem_commbuf_int_fillmpimem