mirror of
https://bitbucket.org/cosmicvoids/vide_public.git
synced 2025-07-05 07:41:11 +00:00
beginning to fold in HOD code with jeremy tinker's approval
This commit is contained in:
parent
d8108d3a8e
commit
44cd0eb71f
95 changed files with 21950 additions and 0 deletions
38
c_tools/hod/ftwrite.c
Normal file
38
c_tools/hod/ftwrite.c
Normal 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) ;
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue