68static const int size_of[6] = {4, 8, 8, 16, 4, 8};
70void FC_FUNC_(read_csv, READ_CSV)(
unsigned long *np,
void *f,
int *output_type,
71 int *ierr, STR_F_TYPE fname STR_ARG1) {
77 const char sep[] =
"\t\n ,";
80 TO_C_STR1(fname, filename);
81 fd = fopen(filename,
"r");
90 buf = (
char *)malloc(buf_size *
sizeof(
char));
93 if ((*output_type) == TYPE_DOUBLE) {
96 while (fgets(buf, buf_size *
sizeof(
char),
fd) != NULL) {
100 d = strtod(c, (
char **)NULL);
101 memcpy(f +
i, &d, size_of[(*output_type)]);
102 c = (
char *)strtok((
char *)NULL, sep);
103 i += size_of[(*output_type)];
112void FC_FUNC_(get_info_csv, GET_INFO_CSV)(
unsigned long *dims,
int *ierr,
113 STR_F_TYPE fname STR_ARG1) {
118 int buf_size = 65536;
119 const char sep[] =
"\n\t ,";
121 unsigned long curr_dims[3] = {0, 0, 0};
122 unsigned long prev_dims[2] = {0, 0};
124 TO_C_STR1(fname, filename);
125 fd = fopen(filename,
"r");
134 buf = (
char *)malloc(buf_size *
sizeof(
char));
136 while (fgets(buf, buf_size *
sizeof(
char),
fd) != NULL) {
137 c = strtok(buf, sep);
139 prev_dims[0] = curr_dims[0];
146 c = (
char *)strtok((
char *)NULL, sep);
152 if (prev_dims[0] > 0 && curr_dims[0] > 0)
153 assert(curr_dims[0] == prev_dims[0]);
157 if (prev_dims[0] == 0 && curr_dims[0] != 0) {
158 prev_dims[1] = curr_dims[1];
164 if (prev_dims[1] > 0 && curr_dims[1] > 0)
165 assert(prev_dims[1] == curr_dims[1]);
170 if (curr_dims[0] > 0)
174 dims[0] = curr_dims[0];
175 dims[1] = curr_dims[1];
176 dims[2] = curr_dims[2];
void * memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__((__nothrow__
int fclose(FILE *__stream)