- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an extensive application that opens binary files on both VMS and Linux platforms. We are changing the format of our OPEN statements so that binary files created on both systems will be compatible. I have found a combination of arguments that will create a file that is identical on both systems (FORM='BINARY' on Linux, & "FORM='UNFORMATTED', RECORDTYPE='VARIABLE'" on VMS), however now I want to have the same piece of code compile on both systems. Unfortunately though, the VMS FORTRAN compiler does not recognize the FORM='BINARY' argument, and chokes while trying to compile the source file (even though it'll never execute this line......I have an "IF ( VMS )" test in the code to use the appropriate arguments).
My solution is I want to create a C wrapper that has conditional compile statements in it that calls the appropriate subroutine to open a file, but I do not know the argument list for the Intel for_open() subroutine to properly call it.
I'd conditionally-compile the FORTRAN file itself, but the VMS compiler does not support FORTRAN preprocessor directives, so unfortunately that option is off the table.
Thanks in advance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, the for_open call is considered an internal interface and should not be called directly.
When you say you want the files to be "compatible", exactly what do you mean? Do you want to be able to copy a file from VMS to Linux or the reverse and still read it?
The most compatible format would be RECORDTYPE='FIXED' with a specified RECL value. You may have to do a SET FILE/RMS on the file when copied from Linux to establish the record length. You could also try RECORDTYPE='SEGMENTED', but you have to be careful when transferring to not lose the VFC data going from VMS to Linux. (SET FILE/RMS to change the record format to FIX before copying, and set to VFC with a control size of 2 bytes (I forget the syntax for that) copying from Linux.
You might also be interested in two VMS programs I wrote that convert to and from the UNIX format (normal UNFORMATTED). I have attached them here (hope this works!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the offer, but we already actually have a utility that converts the binary files from Unix to VMS (and vice-versa). What I meant by the "same format" is that we have a program that half our clients use on VMS and half use on Linux. We have binary data input files that currently we distribute in both a VMS and Linux form, but ideally we'd like to distribute just one set of binary files that are readable on both systems. These programs also create binary files in the same method that, again, would be ideal to be able freely transfer between systems without having to convert them.
To avoid having two different code trees, all of our system, specific stuff is written in C with compiler directives to conditionally compile certain sections of code based on the system. We can't, however, do this with FORTRAN, which is why I was looking for a way around it. I didn't by any means exhaust all the possible combinations of ACCESS, MODE, RECL, etc options to pass to the OPEN command, but of the several I tried, the only mode that produced a file that had the exact same data (confirmed using the "hd" utility), were the above-mentioned modes. Ideally, there would be one set of arguments that will produce an indentical file on both systems, as that makes code maintenance much easier.
I'll try specifying a record length and see if that can get the files to match up.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I see. Fixed-length records are the most compatible I can think of. You can add your own record length if you need it. You would still need to set the RMS record type on VMS.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an extensive application that opens binary files on both VMS and Linux platforms. We are changing the format of our OPEN statements so that binary files created on both systems will be compatible. I have found a combination of arguments that will create a file that is identical on both systems (FORM='BINARY' on Linux, & "FORM='UNFORMATTED', RECORDTYPE='VARIABLE'" on VMS), however now I want to have the same piece of code compile on both systems. Unfortunately though, the VMS FORTRAN compiler does not recognize the FORM='BINARY' argument, and chokes while trying to compile the source file (even though it'll never execute this line......I have an "IF ( VMS )" test in the code to use the appropriate arguments).
My solution is I want to create a C wrapper that has conditional compile statements in it that calls the appropriate subroutine to open a file, but I do not know the argument list for the Intel for_open() subroutine to properly call it.
I'd conditionally-compile the FORTRAN file itself, but the VMS compiler does not support FORTRAN preprocessor directives, so unfortunately that option is off the table.
Thanks in advance.
Seeing that the VMS compiler does not support the FORTRAN preprocessor...
flip it around. You could write the OPEN as
Open(... or OpEn(
using the VMS parameters. (case insensitive)
Then on the IVF side, use the FPP to redirect the open (FPP is case sensitive).
Jim Dempsey

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page