Skip to content

Array support #1

Description

@szaghi

Hi Chris,
Nice project, congrats!

I have just give it a very superficial read, but the type_guard method is a very nice idea.

I read that you are searching a way to support array. I have used in the past unlimited polymorphic and transfer... thus I underdtand the problems hidden in this kind of stuffs. I find a solution that works for my case. The key of my solution was to use something like the smallest variable available (hopefully 1 byte) for the storage. You are using characters: I am not sure but I think that 1 character is, in the most cases, larger than 1 byte (I guess 4 bytes). My solution was to exploit the kind selection of integer in order to find the smallest integer that hopefully is 1 byte in the most architectures, thus my storage is something like

integer, parameter:: I1P  = selected_int_kind(2)
integer(I1P), alloatable :: storage(:)

Now storage can be allocated with the rigth dimension exploiting just the transfer function:

np = size(transfer(input, storage)) ; allocate(storage(1:np)) ; storage = transfer(input, storage)

I use such a strategy in some project like this
https://github.com/szaghi/BeFoR64/blob/master/src/Lib_Pack_Data.f90#L88

I hope to be on topic... I have to study with more details your great container.

See you soon.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions