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

Moving data from Linux to VMS

pnaecker
Beginner
379 Views
Consider a pair of simple programs like these:

 program test_write
! Test reading and writing interchange between VMS and UNIX
! Write an upper triangular array where the array value is the column number
!
 integer lun/1/
integer i, j
parameter (N=10)

real*4 x(N)
real*4 A /10/
real*8 B /20/

open (lun, file='test.dat',status='new',form='unformatted')

write (lun) i
write (lun) A, B
 do i=1,N
x(i) = i
do j=1,i
write (lun) x(1:j)
enddo
enddo

stop
end

 program test_read
! Test reading and writing interchange between VMS and UNIX
! Write an upper triangular array where the array value is the column number
!
 integer lun/1/
integer i, j
parameter (N=10)

real*4 x(N)
real*4 A /10/
real*8 B /20/

open (lun, file='test.dat',status='old',form='unformatted')
read (lun) i
print *, i
read (lun) A, B
print *, A, B
 do i=1,N
do j=1,i
read (lun) x(1:j)
enddo
print *, i, x(1), x(i)
enddo
 stop
end

(A rather silly set of programs, but it does seem to work in the sense that we get out the data we wrote in.)

We would like to be able to write this data on Linux and read the data on VMS. But it seems that RMS "gets in the way" when we try to move the file to VMS. Is there a set of file attributes or other magic that will make the file such that the same (or a similar) program will read the file on VMS?

Thanks.

P
0 Kudos
2 Replies
Steven_L_Intel1
Employee
379 Views
Try this. On Linux, open the file for write using RECORDTYPE='SEGMENTED'. Copy the file to VMS using a "binary" file transfer method. Once on VMS, do this:

$ SET FILE /ATTRIBUTES=(RFM=VAR) file.dat

Now you should be able to open the file on VMS using RECORDTYPE='SEGMENTED' (which is the default for sequential unformatted files there).

What may be easier is if you know the records are all the same length, then use RECORDTYPE='FIXED' with the appropriate RECL value. Copy the file to VMS and do:

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

where the "72" is the actual length in bytes of the record. Remember that RECL= is in 4-byte "longword" units by default on both systems. Read the file as fixed records.
0 Kudos
Steven_L_Intel1
Employee
379 Views
Here's another approach. Simply copy the file as you are already writing it on Linux to VMS and then run the attached program on it to convert it to a 'SEGMENTED' file that the VMS Fortran will read directly. Caveat: I wrote this code 11 years ago and can't promise that it still works.
0 Kudos
Reply