Home > Back-end >  Fortran/C Unformatted Binary File on Windows/iOS
Fortran/C Unformatted Binary File on Windows/iOS

Time:08-21

I have a Fortran program that I used f2c to convert to C because I need to run it on iOS so this would be my only option. The program relies on file reading and writing, specifically it generates an unformatted binary file that it later reads from to use to generate a human readable file of results.

When I run the C code on Windows everything works as expected, meaning the C program generates an unformatted binary file and then uses that file to generate some results. However when I take the same C code and run it through xcode as an iOS app on an iPad I get the unformatted binary file generated but it is a slightly different file size and while the contents are obviously not human readable when using various comparison tools for binary files the file is definitely not identical to what was generated on Windows. The issue becomes that the file generated by iOS causes the C code to crash with: Thread 1:EXC_BAD_ACCESS (code=2, address=0x100f79dc0) that is not helpful to me. What is also interesting is if I take the binary file to try to run it on Windows it does not work and the binary file generated by Windows does not work on iOS.

I think this leads me to a few thoughts/questions:

  • Should I expect the C version of the Fortran code to generate an identical unformatted binary file on Windows and iOS?

  • Is it possible that the Fortran code could have been setup to only handle reading an unformatted binary file generated by a specific operating system (such as Windows)?

CodePudding user response:

Should I expect the C version of the fortran code to generate an identical unformatted binary file on Windows and iOS?

No.

Is it possible that the fortran code could have been setup to only handle reading an unformatted binary file generated by a specific operating system (such as Windows)?

Yes.

  • Related