- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
What are you trying to accomplish here?

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