Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Migrating from VMS to WIN

arthdz
Beginner
621 Views

Hi,

I'm migrating an application from a VMS environment to a Windows Environment, the code is almost done, butI got a problem reading a file created in the VMS system, the file is an unformmated file, but I have problems reading the content, the first thing readed from the file is an integer then a CHARACTER*4, but there is some blanks between the integer and the char, I guess it is because of the size of the integer in the VMS system, is this correct? and if so, what can I do to solve the problem?

Thanks in advance!

0 Kudos
3 Replies
Steven_L_Intel1
Employee
621 Views
The integer size is the same. My guess is that what you have is a 'SEGMENTED' file which is the default format for unformatted files written on VMS. Unfortunately, if you do not take care when transferring the file to another OS, you can lose the record length information and there's no obvious way to recover it (unless you had fixed-length records.)

What follows is a FAQ I wrote some time ago that covers the options. I attached the segmented_to_unix.for program.

The default SEQUENTIAL UNFORMATTED file layout on OpenVMS is called 'SEGMENTED'. A logical record may be split across multiple physical records - each has a 16-bit prefix of flags indicating whether that physical record is the first, last middle or only in the logical record. While Visual Fortran CAN read these, if the file is opened with RECORDTYPE='SEGMENTED', in practice this is difficult because you must transfer the data in such a way as to preserve the file system's record lengths, and typical methods such as FTP remove this information.

One way is to use a program on the OpenVMS system to convert the file to a format which can be easily transferred and read by Visual Fortran. To convert an OpenVMS 'SEGMENTED' file to a form which can be read by Visual Fortran, use segmented_to_unix.for (note that the Visual Fortran layout is the same as is used by UNIX systems). To convert a Visual Fortran file so that it may be read by Fortran on OpenVMS, use unix_to_segmented.for.

Another way is to prepare a SEGMENTED file for transfer by changing the file's recordtype to be fixed-length, 512 byte records, using the command:

$ SET FILE /ATTRIBUTES=(RFM=FIX,LRL=512) file.dat

This file can then be copied to the Windows system using normal FTP in binary mode. On the Windows system, open the file using RECORDTYPE='SEGMENTED'. This method cannot be used for files that were opened with RECORDTYPE='VARIABLE' explicitly specified.

If the file contains floating data and was written on a VAX or on an Alpha system with the default VAX floating types, you will need to specify CONVERT='VAXD' or 'VAXG' (as appropriate) when opening the file using Visual Fortran. This will automatically convert the data in scalars and arrays (though not in RECORD structures or derived types.)


0 Kudos
arthdz
Beginner
621 Views

Steve,

Thanks for your answer, I used the second option and works for me, now I have a doubt related to the EQUIVALENCE statemente, if I do an equivalence between an Integer and a Real, I got a different number I mean if the integer is 60 the real will be 8.4077908E-44

why I'm getting this value and not a 60.00000 instead?

Thanks a lot for the help!

0 Kudos
Steven_L_Intel1
Employee
621 Views
EQUIVALENCE means that the storage of the two variables overlaps. There is no type conversion implied. The bit pattern for an integer 60, when viewed as a single-precision real, is a very small value.

What are you trying to accomplish here?
0 Kudos
Reply