beginning to fold in HOD code with jeremy tinker's approval

This commit is contained in:
P.M. Sutter 2013-12-30 22:48:07 -06:00
parent d8108d3a8e
commit 44cd0eb71f
95 changed files with 21950 additions and 0 deletions

38
c_tools/hod/ftwrite.c Normal file
View file

@ -0,0 +1,38 @@
/* ftwrite writes data unformatted using fortran convention --
i.e. an integer specifying the number of bytes in the record,
the data record, and another integer specifying the number of
bytes in the record. The call is identical to the standard
i/o library routine fwrite.
*/
#include <stdio.h>
int ftwrite(ptr,size,nitems,stream)
char *ptr ;
unsigned size, nitems ;
FILE *stream ;
{
int nbytes, nitem1 ;
int errno ;
errno = 0 ;
nbytes = size*nitems ;
if ( fwrite(&nbytes,sizeof(int),1,stream) != 1 ) {
errno = -10 ;
fprintf(stderr,"write error, is the file open ? \n") ;
}
nitem1 = fwrite(ptr,size,nitems,stream) ;
if ( nitem1 != nitems ) {
errno = -20 ;
fprintf(stderr,"write error, %d items requested, %d items written. \n",
nitems,nitem1) ;
}
if ( fwrite(&nbytes,sizeof(int),1,stream) != 1 ) {
errno = -30 ;
fprintf(stderr,"write error on second byte label \n") ;
}
return(errno) ;
}