Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

for_open syntax

ereisch
New Contributor II
1,045 Views

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.

0 Kudos
4 Replies
Steven_L_Intel1
Employee
1,045 Views

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!)

0 Kudos
ereisch
New Contributor II
1,045 Views

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.

0 Kudos
Steven_L_Intel1
Employee
1,045 Views

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.

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,045 Views
Quoting - ereisch

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

0 Kudos
Reply