I have code that uses the low and low I / O system calls read and write , as described on page 170 of the Kernighan and Ritchie C Programming Book. Function prototypes are
int n_read = read ( int fd, char *buf, int n ) int n_read = write ( int fd, char *buf, int n )
now two .c files that use these read and write are called by the larger fortran program to read and write large amounts of data.
C code is just this, without #include any type, having an underscore after the function name and following the link:
int read_ ( int *descriptor, char *buffer, int *nbyte ) { return ( read( *descriptor, buffer, *nbyte ) ); } int write_ ( int *descriptor, char *buffer, int *nbyte ) { return ( write( *descriptor, buffer, *nbyte ) ); }
and the larger fortran program will do something like this
INTEGER nbyte COMPLEX*16 matrix(*) INTEGER READ, WRITE EXTERNAL READ, WRITE status = READ( fd, matrix, nbyte ) if ( status .eq. -1 ) then CALL ERROR('C call read failure') stop endif
As you may have guessed, this is great for nbyte values ββless than 2 ^ 31. I need to read more than 2 GB of data, so I need nbyte to be a long integer and INTEGER * 8 in fortran.
Are there equivalent read64 and write64, for example, is lseek64 provided by unistd.h and features.h?
What is the best way to transcode this? Should I use fread and fwrite? is int fd from low level write the same as FILE *stream from fread() ?
My requirement is to pass a long integer of 8 bytes in order to have values ββfrom 100 to 500 gigabytes or an integer having 12 digits, which is for nbyte
Am I getting something or losing using currently read and write , which is identified as a system call? "What does this mean?