How to efficiently save complex Fortran structures into binary files?

363 views Asked by At

So, I need to implement my new project in Fortran 2008. In this project I need to store large structures and I'd like to store them in binary format. So far I've read here both about unformatted and formatted binary streams, but I'm still a little confused about how to use them to store something more complex than several numbers/strings.

Let's say I'll have my data stored in JSON format:

"net_name": "Test ANN",
"net_type": "Feed-forward",
"train_method": "Back-propagation",
"neurons":{ "1": { "inputs":["2", "3"], 
                   "outputs": ["10", "11"]},
            "2": { "inputs":["4", "5"], 
                   "outputs": ["11", "12"]}
          }

I know, that I can use some 3rd party modules for working with JSON directly (like this one), but I'd like to be able to use also binary format because file sizes can be really huge.

So, is it possible to store such structure using Fortran binary streams? Or is there any other way in Fortran, how to do it? I'm not asking about unformatted binary files exclusively, if there is some other elegant solution, I'll be glad to hear about it. Still, I prefer ones without many external dependencies.

0

There are 0 answers