comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » cross platform i/o problem
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
cross platform i/o problem [message #5861] Fri, 01 March 1996 00:00
mbastian is currently offline  mbastian
Messages: 3
Registered: March 1994
Junior Member
Hi Peter

I transfer binary back and forth between vax's and unicies all the time.

It is not clear to me if you are using formated or unformated reads/writes.

For binary files the vax fortran i/o places a two byte record delimeter at
the start of each record (0x3). Prepend these two each unformated write and
your problems should go away.

I have a few C #define to do all this for me when I want to produce unformated
fortran binary files in c.

the following is not particularly pretty but hey this is VMS after all !!!

#if defined (unix)
#define BINARY_EXTENSIONS
#define FREAD(a,b,c,d) fread (a,b,c,d)
#define FWRITE(a,b,c,d) fwrite (a,b,c,d)
#else
#include <stdlib.h>
#define BINARY_EXTENSIONS ,"rfm=var"
#define FREAD(a,b,c,d) { \
int z; \
char * ptr_1 , * ptr_2; \
ptr_1 = malloc ( b + 2 ); \
ptr_2 = ( char * ) a; \
for ( z = 0 ; z < c ; z ++ ) { \
fread ( ptr_1 , b + 2 , 1 , d ); \
memmove ( ptr_2 , ptr_1 + 2 , b ); \
ptr_2 += b; \
} \
free ( ptr_1 ); \
}
#define FWRITE(a,b,c,d) { \
int z; \
char * ptr_1 , * ptr_2; \
ptr_1 = malloc ( b + 2 ); \
* ( short * ) ptr_1 = 0x3; \
ptr_2 = ( char * ) a; \
for ( z = 0 ; z < c ; z ++ ) { \
memmove ( ptr_1 + 2 , ptr_2 , b ); \
fwrite ( ptr_1 , b + 2 , 1 , d ); \
ptr_2 += b; \
} \
free ( ptr_1 ); \
}
#endif

/* open data file */

if (( fd = fopen ( file , "rb" BINARY_EXTENSIONS)) == NULL ) {
fprintf ( stderr , "Could not open in file %s\n" , file );
exit ( -1 );
}

Hope this helps ...

--
Matthew Bastian
Institute for Aerospace Research
National Research Council of Canada

613-998-3337
Matthew.Bastian@nrc.ca
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Resize Window => Redraw contents
Next Topic: Using IDL's map database

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:42:42 PDT 2025

Total time taken to generate the page: 0.00450 seconds