REAL*4 VMS v. ULTRIX ( SOURCE PROGRAM )
John Kemp
kemp at uiatma.atmos.uiuc.edu
Fri Jun 21 07:43:31 AEST 1991
Following up on the Q&A's we had about converting
VAX/VMS binaries to RISC/Ultrix binaries, I wrote a little
"C" program to call ftoi() to process our files. It
works fairly well, so I thought I would post it for other
people who are making the move from VAX/VMS to RISC/Ultrix.
This is just for 4-byte floats, but there are a number of
other conversion routines in RISC/Ultrix. Type "man ftoi"
for more information.
In addition, one DEC person says that the latest version of
the RISC Fortran Compiler V3.0 has an open statement for
VAX/VMS binary files, which would make this little program
irrelevant.
Hope someone finds it of use. If nothing else, it is good
to know that the "ftoi()" subroutine exists.
-------- john kemp ( ( )_ internet - kemp at uiatma.atmos.uiuc.edu
----- ( ( __) decnet - uiatmb::kemp
--- univ of illinois (_ ( __) bitnet - {uunet,convex}
-- dept of atmos sci .(____). !uiucuxc!uiatma!kemp
- 105 s gregory ave ... phone - (217) 333-6881
- urbana, il 61801 ... fax - (217) 244-4393
------------------- cut here -----------------------
/*
* convert -- convert VAX/VMS binary to RISC/Ultrix binary
*
* To convert a VMS binary file full of 4-byte floating point
* numbers, ftp the file to the RISC Ultrix machine in binary
* mode, then run this program. It will make a copy of the
* original binary file, but in Ultrix floating point format.
*
* John Kemp
* UIUC Atmospheric Sciences
* June 20, 1991
*/
#include <stdio.h>
FILE *infile;
FILE *outfile;
char *usage="usage: convert <infile> <outfile>\n\t this program converts VAX/VMS binary float files to RISC/Ultrix float\n\t format using the ftoi(f) subroutine. remove the old VAX binary file\n\t after you perform the conversion.";
main(argc,argv)
int argc;
char *argv[];
{
float f;
int res=1, fres, cntr=0, size, nitems=1;
if ( argc != 3 ) {
fprintf(stderr,"%s\n",usage);
exit(1);
}
/* open files */
infile = fopen(argv[1],"r+");
outfile = fopen(argv[2],"w+");
/* read floats and convert */
size = sizeof(f);
while ( (res = fread(&f,size,nitems,infile)) > 0 ) {
cntr++;
fres = ftoi(&f);
if ( fres != 0 )
fprintf(stderr,"ftoi failed on num %d value %04x\n",cntr,f);
else
fwrite(&f,size,nitems,outfile);
}
/* close files */
fclose(infile);
fclose(outfile);
}
More information about the Comp.unix.ultrix
mailing list