Quantcast
Channel: Intel® Software - Intel® Visual Fortran Compiler for Windows*
Viewing all articles
Browse latest Browse all 5691

Deserialize Byte Array

$
0
0

Hi,

I have a byte array in Fortran that has been serialised in vb. I was wondering if it's possible to deserialize it in Fortran using a custom TYPE or something?

In VB the object format is:

       Public Class CustomClass
           Property1 as Double
           Property2 as Double
           Property3 as Double
       End Class

and I serialize it with: 

        Public Shared Function ObjectToByteArray(inputObject As Object) As Byte()
            Dim binaryFormatter As New BinaryFormatter()' Create new BinaryFormatter
            Dim memoryStream As New MemoryStream()' Create target memory stream
            binaryFormatter.Serialize(memoryStream, inputObject)' Serialize object to stream
            Return memoryStream.ToArray()' Return stream as byte array
        End Function

I then write it to a Memory Map File and read it into Fortran:

byte, pointer, dimension(:)    ::  BYT
...
call c_f_pointer(cdata, BYT, [4096])

Which all works fine, but now I'm stuck on how to deserialise this byte array. The Fortran structure might be something like:

      TYPE CUSTOM_CLASS
        REAL(8) :: PROPERTY1
        REAL(8) :: PROPERTY2
        REAL(8) :: PROPERTY3
      END TYPE CUSTOM_CLASS

But I'm passed the limit of my Fortran knowledge! Any help would be appreciated.

Thanks,


Viewing all articles
Browse latest Browse all 5691

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>