Exact size in bytes of the stream a container of n elements writes.
Returns -1 when n is negative or a field kind is unknown. Useful to
reserve space up front, and it lets a test pin the on-disk layout
against the real file size.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| character(len=*), | intent(in) | :: | schema |
The container’s schema string. |
||
| integer(kind=default_int), | intent(in) | :: | n |
Number of live elements. |
||
| integer(kind=int32), | intent(in) | :: | field_kinds(:) |
One |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | i | ||||
| integer(kind=int32), | private | :: | tag |
pure function soa_stream_bytes(schema, n, field_kinds) result(nbytes) !! Exact size in bytes of the stream a container of `n` elements writes. !! !! Returns -1 when `n` is negative or a field kind is unknown. Useful to !! reserve space up front, and it lets a test pin the on-disk layout !! against the real file size. character(len=*), intent(in) :: schema !! The container's schema string. integer(default_int), intent(in) :: n !! Number of live elements. integer(int32), intent(in) :: field_kinds(:) !! One `SOA_FIELD_*` code per field, in declaration order. integer(int64) :: nbytes integer(default_int) :: i integer(int32) :: tag if (n < 0) then nbytes = -1_int64 return end if nbytes = PIC_HEADER_BYTES + record_bytes(PIC_TAG_CHAR, int(len(schema), int64)) & + record_bytes(PIC_TAG_INT64, 1_int64) do i = 1, size(field_kinds, kind=default_int) tag = soa_field_tag(field_kinds(i)) if (tag < 0_int32) then nbytes = -1_int64 return end if nbytes = nbytes + record_bytes(tag, int(n, int64)) end do end function soa_stream_bytes