f_memcpy_bytes#
Copy raw storage between two scalar buffer starts, with an explicit byte count, without numerical or character-code conversion.
use futile ! or:
use f_memcpy_module, only: f_memcpy_bytes
Signature#
Generated from the FYPP documentation stub doc/generated/f_memcpy_doc.f90 (emitted by
fypp/memcpy-doc.fypp from the same loops as flib/f_memcpy.f90). In the
signature, any_intrinsic is a documentation placeholder: the argument may
be of any intrinsic type, of any Futile ABI kind.
The supported combinations are listed under Supported kinds.
- interface f_memcpy_module/f_memcpy_bytes(dest, src, nbytes)#
Copy raw storage between scalar buffer starts using an explicit byte count. nbytes is mandatory integer(f_size_t), including for partial-element copies. The caller guarantees both contiguous backing capacities. Negative counts and positive transfers involving zero-width scalars raise ERR_INVALID_COPY. Zero bytes obtain no address. Overlap is safe; no conversion takes place.
- Parameters:
dest [any_intrinsic, target] :: Scalar start of the destination buffer: any intrinsic type, of any Futile ABI kind (all 13x13 type/kind pairs with
src).src [any_intrinsic, target] :: Scalar start of the source buffer: any intrinsic type, of any Futile ABI kind.
nbytes [integer, in] :: Number of bytes to copy; mandatory, may cover partial source elements. Both backing capacities are the caller’s responsibility.
Typical call#
call f_memcpy_bytes(dest=buffer(first), src=value, nbytes=f_sizeof(value))
Supported kinds#
169 specific procedures implement f_memcpy_bytes (generated by FYPP; table emitted by the documentation stub f_memcpy_doc.f90 from the same loops).
Type (kind) |
ranks of |
ranks of |
count kinds |
specifics |
|---|---|---|---|---|
|
0 |
0 |
|
13 each |
Scalar buffer starts (both arguments rank 0) accept every source type/kind with any of the 13 destination type/kinds.
Notes#
When to prefer it over f_memcpy
Use f_memcpy whenever the count is a whole number of source elements:
it checks known array capacities. f_memcpy_bytes is the escape hatch for
byte-level transfers, including partial source elements and arbitrary
type/kind pairs, where no capacity is known.
Capacity, overlap and zero bytes
Both arguments are scalar starts of larger contiguous buffers; the caller
guarantees that nbytes fits in both. The copy uses C memmove, so
partial overlap is safe. A zero-byte copy obtains no address.
Errors
A negative nbytes, or a positive transfer from or to zero-width scalar
storage, raises ERR_INVALID_COPY without changing the destination.
Examples#
Compiled and run by CI (tests/flib/memcpy_check.f90). The complex scalar
z is copied into the middle of a real array, byte for byte:
call f_memcpy_bytes(src=z,dest=pair(2),nbytes=f_sizeof(z))