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

Problem with Open statement

naveed_ahmed
Beginner
758 Views
I am trying to rewrite a database file editor for windows, already existing for VMS System written in Fortran. Now one thing I need to do is that file created by windows version, must be compatible with VMS version, but I have hit a brick wall even before that.

In VMS files are opened via following statement

OPEN(ACCESS='DIRECT',DISP='SAVE',ERR=8500,FILE=galaxy.dbm,
* FORM='FORMATTED',MAXREC=5000,
* ORGANIZATION='SEQUENTIAL',RECL=96,
* RECORDTYPE='FIXED',STATUS='OLD',UNIT=1)

Now I use FTP to transfer file between VAX and PC, when I transfer galaxy.dbm file to PC using FTP, and even if I don't modify it, and FTP it back to VAX, database editor in VAX doesn't open the file, and jumps to ERR handler 8500. I can't understand what can be the problem, file is not modified on PC, just transferred from VAX to PC and vice versa. If I compare galaxy.dbm with it's exact copy galaxy2.dbm using difference utility, on VAX it finds no difference,

diff galaxy.dbm galaxy2.dbm
Number of difference sections found: 0
Number of difference records found: 0

DIFFERENCES /IGNORE=()/MERGED=1-
DKA100:[DATABASE]GALAXY.DBM;1-
DKA100:[DATABASE]GALAXY2.DBM;1

but one thing that I noted, if I take
dir/full galaxy.dbm (File sent, and returned to VAX via FTP) I get size
Size: 958/960
dir/full galaxy2.dbm (Copy of galaxy.dbm, remains on VAX) I get size
Size: 938/940

Why file size is changed, does transfer via FTP doing this? Is change in file size causing Open statement to not function?

Thanks is advance,
Naveed
0 Kudos
9 Replies
durisinm
Novice
758 Views
There have been similar questions posted in this forum before like this one, for example. The gist of the matter is that the ftp file transfer can alter the file unless you set the transfer mode to binary. You could search the forum for other similar posts.

Mike
0 Kudos
Steven_L_Intel1
Employee
758 Views
See also http://h18009.www1.hp.com/fortran/kb/q1022.html

Steve

Message Edited by intel.software.network.support on 12-09-2005 09:42 AM

0 Kudos
naveed_ahmed
Beginner
758 Views
Thanks everyone, I was missing binary transfer part, and now using binary transfer atleast I am getting file size issue resolved. But now issue remain of file attribute, as I read article you mentioned steve, it deals with unformatted files, and problem for me is that when I send file back from windows to VAX and get dir/full for
galaxy.dbm I get
Record format: Fixed length 512 byte records
Record attributes: None
and for galaxy2.dbm (original on VAX) I get
Record format: Fixed length 96 byte records
Record attributes: Fortran carriage control

Now how do I convert galaxy.dbm so that it changes from Fixed length 512 bytes record into Fixed length 96 bytes record, with Fortran carriage control. Program in that article unix_to_segment.for doesn't seem to work for me, as it quits by giving message
too few bytes remain in file For001.dat

Is there any way to create a utility for VMS to convert these kind of files to formatted sequential files, if you can point to some documentation etc. Or is there any existing solution.

Thanks in advance,
Naveed
0 Kudos
durisinm
Novice
758 Views
Why are you concerned with how the galaxy.dbm file changes during the round trip from VMS to Windows to VMS? Isn't the important thing in this case whether your Windows version of the application can read the file after it's been transferred from VMS to Windows via ftp in binary mode? Does the Windows application work when you transfer the file like that?

If for some reason you do have to move the file back to VMS from Windows, then the following commands may work. GALAXY.DBM is your original file from VMS. Issue the first command before you transfer the file from VMS to Windows.

ANALYZE/RMS_FILE/FDL GALAXY.DBM

This should produce the file GALAXY.FDL. If you don't like that name you can use whatever you want by adding the /OUTPUT= qualifier to the ANALYZE command.

After this you can transfer the GALAXY.DBM file to Windows and back to VMS using ftp in binary mode. Let's suppose that you name the transferred file GALAXY.DBMWIN on VMS. The following command may convert its attributes to that of the original GALAXY.DBM file:

CONVERT/FDL=GALAXY.FDL GALAXY.DBMWIN GALAXY.DBMVMS

The output file is GALAXY.DBMVMS. Check its attributes with DIRECTORY/FULL to see if they match those of the original GALAXY.DBM. I can't say for sure if they will, but it's worth a shot.

You might also investigate whether there are any switches for the ftp transfer that will help preserve the file attributes.

Mike
0 Kudos
james1
Beginner
758 Views
You can also use a

$ set file /attribute=(rat:ftn,lrl:96) galaxy.dbm

on the file after it has returned to the VMS system.

James
0 Kudos
naveed_ahmed
Beginner
758 Views
Thanks again everyone, I will check your solutions after weekend.
durisinm, problem I am interested in file returned to VMS is that editor I need to write in windows, must have to compatible to with VMS version i.e. DBM files created in Win version, should open in VMS because we can make huge modifications easily in Windows version, and that is the chief purpose, and then transport dbm files back to VMS and use there.
0 Kudos
durisinm
Novice
758 Views
I think that the SET FILE/ATTRIBUTE command is available in VMS 6 and higher. We have many VMS 5.5 systems where I work, and the /ATTRIBUTE qualifier for the SET FILE command doesn't work on them.

Mike
0 Kudos
james1
Beginner
758 Views
Mike, most questions are answered assuming software more recent than ten years old. :-) If you have really old versions of the OS, that is why everyone had a utility called FILE to do the same thing, it would work for that and much older versions.

James
0 Kudos
naveed_ahmed
Beginner
758 Views
Thanks James, your solution worked perfectly. I have also made a utility win2fix, to convert the files, it asks for original file, record length, maximum number of records, and output file name. It produces output file with correct specifications. It was fun to write it, but I prefer your solution.
0 Kudos
Reply