11 # define OPEN_FILE open_file
12 # define CLOSE_FILE close_file
13 # define WRITE_FILE write_file
14 # define WRITE_FILE_N write_file_n
15 # define FLUSH_FILE flush_file
18 # define OPEN_FILE open_file__
19 # define CLOSE_FILE close_file__
20 # define WRITE_FILE write_file__
21 # define WRITE_FILE_N write_file_n__
22 # define FLUSH_FILE flush_file__
24 # define OPEN_FILE open_file_
25 # define CLOSE_FILE close_file_
26 # define WRITE_FILE write_file_
27 # define WRITE_FILE_N write_file_n_
28 # define FLUSH_FILE flush_file_
34 * Fortran-callable function to open/close files
36 int OPEN_FILE (char *filename
, char *permissions
, int *outfd
, int *ierr
,
37 int strlen1
, int strlen2
)
40 char permstring
[1000];
43 strncpy(filename2
,filename
,strlen1
);
44 filename2
[strlen1
]='\0';
46 strncpy(permstring
,permissions
,strlen2
);
47 permstring
[strlen2
]='\0';
49 if (strcmp(permstring
,"w") == 0) {
50 permvals
= O_CREAT
|O_WRONLY
|O_TRUNC
;
55 *outfd
= open(filename2
,permvals
,0644);
58 fprintf(stderr
,"setting ierr to -1, filename: %s\n",filename
);
70 int WRITE_FILE(int *fd
, char *buf
, int *ierr
, int strlen
)
74 nbytes
= write(*fd
,buf
,strlen
);
86 int WRITE_FILE_N(int *fd
, char *buf
, int *nbytes
, int *ierr
)
90 bytes_written
= write(*fd
,buf
,*nbytes
);
91 if (bytes_written
!= *nbytes
)
102 int CLOSE_FILE (int *fd
)
108 int FLUSH_FILE (int *fd
)