GridTools / serialbox

Data serialization library and tools for C/C++ and Fortran
BSD 2-Clause "Simplified" License
29 stars 29 forks source link

Not possible to read data from savepoint with metadata from Fortran? #241

Open ofuhrer opened 4 years ago

ofuhrer commented 4 years ago

It seems that the Fortran interface is mostly meant for writing and not reading. To my understanding, it is not possible to read data from a savepoint with meta-data...

call fs_create_savepoint('sfc_sice-in', ppser_savepoint)
call fs_add_savepoint_metainfo(ppser_savepoint, 'ID', 1)

...will exit with an error saying that Serialbox: ERROR: savepoint 'sfc_sice-in {}' does not exist. While the above is ok for writing (specifying meta-data after creating a savepoint is ok), for reading this does not work.

chovyy commented 4 years ago

This code is for writing. For reading there is fs_get_savepoint_metainfo.

ofuhrer commented 4 years ago

Well, the error message actually occurrs on the fs_create_savepoint('sfc_sice-in', ppser_savepoint) which tries to open a savepoint WITHOUT metadata. The fs_add_savepoint_metainfo() is never reached. So my question remains the same, how can I access a specific savepoint with a given meta-data (e.g. ID=1)?

chovyy commented 4 years ago

I think, I understand your problem now, and you're might be right that there is an issue. Have you tried to open the savepoint as 'sfc_sice-in {ID=1}' or something like that?

ofuhrer commented 4 years ago

That's my point. There's no API in Fortran for doing exactly that, afaik! Sorry for not phrasing my issue well enough...

chovyy commented 4 years ago

But how does fs_create_savepoint knows whether it is called in write or read context?

ofuhrer commented 4 years ago

I think the serializer object is either in read or write mode. But not sure...

chovyy commented 4 years ago

But the serializer object is not passed to the subroutine. Are you sure that the error is thrown by fs_create_savepoint? It's long time ago that I worked on Serialbox, but that behavior appears a bit strange to me. I think, the error should appear when you try to access some field with this savepoint.

ofuhrer commented 4 years ago

Well the Fortran API exposed via m_serialize.f90 retains state internally by retaining the current serializer and savepoint objects.

chovyy commented 4 years ago

Not afaik. The created objects are held by the client application and passed as parameters to the API routines.

chovyy commented 4 years ago

Sorry, I meant arguments not parameters. Stupid Fortran... ;-)