Xref: utzoo comp.sys.dec:6087 comp.unix.ultrix:7771 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!rex!spool.mu.edu!news.cs.indiana.edu!ux1.cso.uiuc.edu!uiatma.atmos.uiuc.edu!kemp From: kemp@uiatma.atmos.uiuc.edu (John Kemp) Newsgroups: comp.sys.dec,comp.unix.ultrix Subject: REAL*4 VMS v. ULTRIX ( SOURCE PROGRAM ) Message-ID: <1991Jun20.214331.21813@ux1.cso.uiuc.edu> Date: 20 Jun 91 21:43:31 GMT Sender: usenet@ux1.cso.uiuc.edu (News) Organization: University of Illinois at Urbana Lines: 75 Originator: kemp@uiatma.atmos.uiuc.edu 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@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 FILE *infile; FILE *outfile; char *usage="usage: convert \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); }