14 # define OPEN_FILE open_file
15 # define CLOSE_FILE close_file
16 # define WRITE_FILE write_file
17 # define WRITE_FILE_N write_file_n
18 # define FLUSH_FILE flush_file
21 # define OPEN_FILE open_file__
22 # define CLOSE_FILE close_file__
23 # define WRITE_FILE write_file__
24 # define WRITE_FILE_N write_file_n__
25 # define FLUSH_FILE flush_file__
27 # define OPEN_FILE open_file_
28 # define CLOSE_FILE close_file_
29 # define WRITE_FILE write_file_
30 # define WRITE_FILE_N write_file_n_
31 # define FLUSH_FILE flush_file_
37 * Fortran-callable function to open/close files
39 int OPEN_FILE (char *filename
, char *permissions
, int *outfd
, int *ierr
,
40 int strlen1
, int strlen2
)
43 char permstring
[1000];
46 strncpy(filename2
,filename
,strlen1
);
47 filename2
[strlen1
]='\0';
49 strncpy(permstring
,permissions
,strlen2
);
50 permstring
[strlen2
]='\0';
52 if (strcmp(permstring
,"w") == 0) {
53 permvals
= O_CREAT
|O_WRONLY
|O_TRUNC
;
58 *outfd
= open(filename2
,permvals
,0644);
61 fprintf(stderr
,"setting ierr to -1, filename: %s\n",filename
);
73 int WRITE_FILE(int *fd
, char *buf
, int *ierr
, int strlen
)
77 nbytes
= write(*fd
,buf
,strlen
);
89 int WRITE_FILE_N(int *fd
, char *buf
, int *nbytes
, int *ierr
)
93 bytes_written
= write(*fd
,buf
,*nbytes
);
94 if (bytes_written
!= *nbytes
)
105 int CLOSE_FILE (int *fd
)
111 int FLUSH_FILE (int *fd
)