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_FLOAT) {
95 while (fgets(buf, buf_size *
sizeof(
char),
fd) != NULL) {
100 d = strtof(c, (
char **)NULL);
101 c = (
char *)strtok((
char *)NULL, sep);
102 memcpy(f +
i, &d, size_of[(*output_type)]);
103 i += size_of[(*output_type)];
106 }
else if ((*output_type) == TYPE_DOUBLE) {
109 while (fgets(buf, buf_size *
sizeof(
char),
fd) != NULL) {
110 c = strtok(buf, sep);
113 d = strtod(c, (
char **)NULL);
114 memcpy(f +
i, &d, size_of[(*output_type)]);
115 c = (
char *)strtok((
char *)NULL, sep);
116 i += size_of[(*output_type)];
125void FC_FUNC_(get_info_csv, GET_INFO_CSV)(
unsigned long *dims,
int *ierr,
126 STR_F_TYPE fname STR_ARG1) {
131 int buf_size = 65536;
132 const char sep[] =
"\n\t ,";
134 unsigned long curr_dims[3] = {0, 0, 0};
135 unsigned long prev_dims[2] = {0, 0};
137 TO_C_STR1(fname, filename);
138 fd = fopen(filename,
"r");
147 buf = (
char *)malloc(buf_size *
sizeof(
char));
149 while (fgets(buf, buf_size *
sizeof(
char),
fd) != NULL) {
150 c = strtok(buf, sep);
152 prev_dims[0] = curr_dims[0];
159 c = (
char *)strtok((
char *)NULL, sep);
165 if (prev_dims[0] > 0 && curr_dims[0] > 0)
166 assert(curr_dims[0] == prev_dims[0]);
170 if (prev_dims[0] == 0 && curr_dims[0] != 0) {
171 prev_dims[1] = curr_dims[1];
177 if (prev_dims[1] > 0 && curr_dims[1] > 0)
178 assert(prev_dims[1] == curr_dims[1]);
183 if (curr_dims[0] > 0)
187 dims[0] = curr_dims[0];
188 dims[1] = curr_dims[1];
189 dims[2] = curr_dims[2];
void * memcpy(void *__restrict __dest, const void *__restrict __src, size_t __n) __attribute__((__nothrow__
int fclose(FILE *__stream)