Dan, I think that you are still tilting at windmills, as you can see with these tiny example programs. Both write a 64 MByte 'binary' file. I ran the programs on a laptop with an i5-4200U CPU and a 128 MB ramdisk.
The Fortran code:
program writebinbuf
integer, parameter :: I2 = selected_int_kind(4), I4 = selected_int_kind(9), &
I8 = selected_int_kind(18)
integer, parameter :: BSIZ = Z'4000000' ! 64 megabytes
character (Len=1) :: buf(BSIZ)
integer (I2) :: hndl, ecode
integer (I8) :: nbytes = BSIZ
real :: t1,t2
!
call openw@('big.bin',hndl,ecode)
if(ecode /= 0)stop 'Error opening file BIG.BIN for writing'
call cpu_time(t1)
call writef@(buf,hndl,nbytes,ecode)
call cpu_time(t2)
if(ecode /= 0)stop 'Error writing file BIG.BIN'
call closef@(hndl,ecode)
if(ecode /= 0)stop 'Error closing file'
write(*,'(A,2x,F7.3,A)')'Time for writing 64 MB file: ',t2-t1,' s'
write(*,'(A,6x,F6.0,A)')'Estimated throughput = ',64.0/(t2-t1),' MB/s'
end program
The equivalent C program:
#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <fcntl.h>
#include <time.h>
#include <sys/stat.h>
#define BSIZ 0x4000000
int main(){
char *buf; int fid,bsiz=BSIZ; clock_t t1,t2;
float te;
buf=(char *)malloc(bsiz);
fid=open('BIG.BIN', O_CREAT | O_WRONLY | O_BINARY); //, S_IWRITE | S_IREAD);
t1=clock();
write(fid,buf,bsiz);
t2=clock(); te=(t2-t1)/(float)CLOCKS_PER_SEC;
printf('Time for writing 64 MB to file: %6.3f s\nEstimated throughput = %.1f MB/s\n',
te,64.0/te);
close(fid);
}
We run the first with FTN95:
s:\FTN95>ftn95 /no_banner fwrfil.f90 & slink fwrfil.obj & fwrfil
Creating executable: s:\FTN95\fwrfil.exe
Time for writing 64 MB file: 0.047 s
Estimated throughput = 1365. MB/s
We run the second with SCC:
s:\FTN95>scc /no_banner cwrfil.c & slink cwrfil.obj & cwrfil
Creating executable: s:\FTN95\cwrfil.exe
Time for writing 64 MB to file: 0.047 s
Estimated throughput = 1361.7 MB/s
Vive la non-différence! And, please drink those 12 beers on my behalf.
It would be interesting to see what numbers you get on your terabyte cruncher of a machine with these small test programs.
Once you run one of these two programs you will have a 64 MB file that you can use with similar read tests. Change writef@ to readf@, and so on. I see more or less the same speeds for reads as I did for writes.
Having done that, compare the read throughput (1.36 GB/s on my laptop) with the value that you gave in #3 (counting from 0 for the initial post), 0.0003 GB/s. The difference must be investigated, and it will be found to be explained by the throughput of your I/O devices and by the rate and complexity of processing the data in your application, and not at all by differences between C and Fortran, because the grunt work of the I/O is done in the MS system DLLs.