9 #ifndef SION_FORTRAN_H_
10 #define SION_FORTRAN_H_
23 #if defined(_FORTRANCAPS)
24 #define fsion_open_c FSION_OPEN_C
26 #elif defined(_FORTRANNOCAPS)
27 #define fsion_open_c fsion_open_c
29 #elif defined(_FORTRANUNDERSCORE)
30 #define fsion_open_c fsion_open_c_
32 #elif defined(_FORTRANDOUBLEUNDERSCORE)
33 #define fsion_open_c fsion_open_c__
35 #elif defined(_FORTRANNOUNDERSCORE)
37 #error nothing defined for fortran externals
43 sion_int64 *chunksizes,
44 sion_int32 *fsblksize,
51 #if defined(_FORTRANCAPS)
52 #define fsion_open_rank_c FSION_OPEN_RANK_C
54 #elif defined(_FORTRANNOCAPS)
55 #define fsion_open_rank_c fsion_open_rank_c
57 #elif defined(_FORTRANUNDERSCORE)
58 #define fsion_open_rank_c fsion_open_rank_c_
60 #elif defined(_FORTRANDOUBLEUNDERSCORE)
61 #define fsion_open_rank_c fsion_open_rank_c__
63 #elif defined(_FORTRANNOUNDERSCORE)
65 #error nothing defined for fortran externals
69 sion_int64 *chunksize,
70 sion_int32 *fsblksize,
77 #if defined(_FORTRANCAPS)
78 #define fsion_close_c FSION_CLOSE_C
80 #elif defined(_FORTRANNOCAPS)
81 #define fsion_close_c fsion_close_c
83 #elif defined(_FORTRANUNDERSCORE)
84 #define fsion_close_c fsion_close_c_
86 #elif defined(_FORTRANDOUBLEUNDERSCORE)
87 #define fsion_close_c fsion_close_c__
89 #elif defined(_FORTRANNOUNDERSCORE)
91 #error nothing defined for fortran externals
97 #if defined(_FORTRANCAPS)
98 #define fsion_feof_c FSION_FEOF_C
100 #elif defined(_FORTRANNOCAPS)
101 #define fsion_feof_c fsion_feof_c
103 #elif defined(_FORTRANUNDERSCORE)
104 #define fsion_feof_c fsion_feof_c_
106 #elif defined(_FORTRANDOUBLEUNDERSCORE)
107 #define fsion_feof_c fsion_feof_c__
109 #elif defined(_FORTRANNOUNDERSCORE)
111 #error nothing defined for fortran externals
117 #if defined(_FORTRANCAPS)
118 #define fsion_seek_c FSION_SEEK_C
120 #elif defined(_FORTRANNOCAPS)
121 #define fsion_seek_c fsion_seek_c
123 #elif defined(_FORTRANUNDERSCORE)
124 #define fsion_seek_c fsion_seek_c_
126 #elif defined(_FORTRANDOUBLEUNDERSCORE)
127 #define fsion_seek_c fsion_seek_C__
129 #elif defined(_FORTRANNOUNDERSCORE)
131 #error nothing defined for fortran externals
136 sion_int64 *posinblk,
140 #if defined(_FORTRANCAPS)
141 #define fsion_ensure_free_space_c FSION_ENSURE_FREE_SPACE_C
143 #elif defined(_FORTRANNOCAPS)
144 #define fsion_ensure_free_space_c fsion_ensure_free_space_c
146 #elif defined(_FORTRANUNDERSCORE)
147 #define fsion_ensure_free_space_c fsion_ensure_free_space_c_
149 #elif defined(_FORTRANDOUBLEUNDERSCORE)
150 #define fsion_ensure_free_space_c fsion_ensure_free_space_c__
152 #elif defined(_FORTRANNOUNDERSCORE)
154 #error nothing defined for fortran externals
161 #if defined(_FORTRANCAPS)
162 #define fsion_flush_c FSION_FLUSH_C
164 #elif defined(_FORTRANNOCAPS)
165 #define fsion_flush_c fsion_flush_c
167 #elif defined(_FORTRANUNDERSCORE)
168 #define fsion_flush_c fsion_flush_c_
170 #elif defined(_FORTRANDOUBLEUNDERSCORE)
171 #define fsion_flush_c fsion_flush_c__
173 #elif defined(_FORTRANNOUNDERSCORE)
175 #error nothing defined for fortran externals
181 #if defined(_FORTRANCAPS)
182 #define fsion_bytes_avail_in_block_c FSION_BYTES_AVAIL_IN_BLOCK_C
184 #elif defined(_FORTRANNOCAPS)
185 #define fsion_bytes_avail_in_block_c fsion_bytes_avail_in_block_c
187 #elif defined(_FORTRANUNDERSCORE)
188 #define fsion_bytes_avail_in_block_c fsion_bytes_avail_in_block_c_
190 #elif defined(_FORTRANDOUBLEUNDERSCORE)
191 #define fsion_bytes_avail_in_block_c fsion_bytes_avail_in_block_c__
193 #elif defined(_FORTRANNOUNDERSCORE)
195 #error nothing defined for fortran externals
200 #if defined(_FORTRANCAPS)
201 #define fsion_get_locations_c FSION_GET_LOCATIONS_C
203 #elif defined(_FORTRANNOCAPS)
204 #define fsion_get_locations_c fsion_get_locations_c
206 #elif defined(_FORTRANUNDERSCORE)
207 #define fsion_get_locations_c fsion_get_locations_c_
209 #elif defined(_FORTRANDOUBLEUNDERSCORE)
210 #define fsion_get_locations_c fsion_get_locations_c__
212 #elif defined(_FORTRANNOUNDERSCORE)
214 #error nothing defined for fortran externals
219 sion_int64 *globalskip,
220 sion_int64 *start_of_varheader,
221 sion_int64 **sion_chunksizes,
222 sion_int64 **sion_globalranks,
223 sion_int64 **sion_blockcount,
224 sion_int64 **sion_fsblksizes,
228 #if defined(_FORTRANCAPS)
229 #define fsion_get_current_locations_c FSION_GET_CURRENT_LOCATIONS_C
231 #elif defined(_FORTRANNOCAPS)
232 #define fsion_get_current_locations_c fsion_get_current_locations_c
234 #elif defined(_FORTRANUNDERSCORE)
235 #define fsion_get_current_locations_c fsion_get_current_locations_c_
237 #elif defined(_FORTRANDOUBLEUNDERSCORE)
238 #define fsion_get_current_locations_c fsion_get_current_locations_c__
240 #elif defined(_FORTRANNOUNDERSCORE)
242 #error nothing defined for fortran externals
244 void fsion_get_current_locations_c(
int *sid,
246 sion_int64 **sion_currentpos,
247 sion_int64 **sion_currentblocknr,
251 #if defined(_FORTRANCAPS)
252 #define fsion_get_chunksizes_c FSION_GET_CHUNKSIZES_C
254 #elif defined(_FORTRANNOCAPS)
255 #define fsion_get_chunksizes_c fsion_get_chunksizes_c
257 #elif defined(_FORTRANUNDERSCORE)
258 #define fsion_get_chunksizes_c fsion_get_chunksizes_c_
260 #elif defined(_FORTRANDOUBLEUNDERSCORE)
261 #define fsion_get_chunksizes_c fsion_get_chunksizes_c__
263 #elif defined(_FORTRANNOUNDERSCORE)
265 #error nothing defined for fortran externals
267 void fsion_get_chunksizes_c(
int *sid,
268 sion_int64 *chunksizes,
272 #if defined(_FORTRANCAPS)
273 #define fsion_get_globalranks_c FSION_GET_GLOBALRANKS_C
275 #elif defined(_FORTRANNOCAPS)
276 #define fsion_get_globalranks_c fsion_get_globalranks_c
278 #elif defined(_FORTRANUNDERSCORE)
279 #define fsion_get_globalranks_c fsion_get_globalranks_c_
281 #elif defined(_FORTRANDOUBLEUNDERSCORE)
282 #define fsion_get_globalranks_c fsion_get_globalranks_c__
284 #elif defined(_FORTRANNOUNDERSCORE)
286 #error nothing defined for fortran externals
288 void fsion_get_globalranks_c(
int *sid,
293 #if defined(_FORTRANCAPS)
294 #define fsion_get_mapping_spec_c FSION_GET_MAPPING_SPEC_C
296 #elif defined(_FORTRANNOCAPS)
297 #define fsion_get_mapping_spec_c fsion_get_mapping_spec_c
299 #elif defined(_FORTRANUNDERSCORE)
300 #define fsion_get_mapping_spec_c fsion_get_mapping_spec_c_
302 #elif defined(_FORTRANDOUBLEUNDERSCORE)
303 #define fsion_get_mapping_spec_c fsion_get_mapping_spec_c__
305 #elif defined(_FORTRANNOUNDERSCORE)
307 #error nothing defined for fortran externals
309 void fsion_get_mapping_spec_c(
int *sid,
315 #if defined(_FORTRANCAPS)
316 #define fsion_get_mapping_c FSION_GET_MAPPING_C
318 #elif defined(_FORTRANNOCAPS)
319 #define fsion_get_mapping_c fsion_get_mapping_c
321 #elif defined(_FORTRANUNDERSCORE)
322 #define fsion_get_mapping_c fsion_get_mapping_c_
324 #elif defined(_FORTRANDOUBLEUNDERSCORE)
325 #define fsion_get_mapping_c fsion_get_mapping_c__
327 #elif defined(_FORTRANNOUNDERSCORE)
329 #error nothing defined for fortran externals
331 void fsion_get_mapping_c(
int *sid,
336 #if defined(_FORTRANCAPS)
337 #define fsion_get_position_c FSION_GET_POSITION_C
339 #elif defined(_FORTRANNOCAPS)
340 #define fsion_get_position_c fsion_get_position_c
342 #elif defined(_FORTRANUNDERSCORE)
343 #define fsion_get_position_c fsion_get_position_c_
345 #elif defined(_FORTRANDOUBLEUNDERSCORE)
346 #define fsion_get_position_c fsion_get_position_c__
348 #elif defined(_FORTRANNOUNDERSCORE)
350 #error nothing defined for fortran externals
355 #if defined(_FORTRANCAPS)
356 #define fsion_get_fileno_c FSION_GET_FILENO_C
358 #elif defined(_FORTRANNOCAPS)
359 #define fsion_get_fileno_c fsion_get_fileno_c
361 #elif defined(_FORTRANUNDERSCORE)
362 #define fsion_get_fileno_c fsion_get_fileno_c_
364 #elif defined(_FORTRANDOUBLEUNDERSCORE)
365 #define fsion_get_fileno_c fsion_get_fileno_c__
367 #elif defined(_FORTRANNOUNDERSCORE)
369 #error nothing defined for fortran externals
375 #if defined(_FORTRANCAPS)
376 #define fsion_set_fp_closed_c FSION_SET_FP_CLOSED_C
378 #elif defined(_FORTRANNOCAPS)
379 #define fsion_set_fp_closed_c fsion_set_fp_closed_c
381 #elif defined(_FORTRANUNDERSCORE)
382 #define fsion_set_fp_closed_c fsion_set_fp_closed_c_
384 #elif defined(_FORTRANDOUBLEUNDERSCORE)
385 #define fsion_set_fp_closed_c fsion_set_fp_closed_c__
387 #elif defined(_FORTRANNOUNDERSCORE)
389 #error nothing defined for fortran externals
391 void fsion_set_fp_closed_c(
int *sid,
395 #if defined(_FORTRANCAPS)
396 #define fsion_get_file_endianness_c FSION_GET_FILE_ENDIANNESS_C
398 #elif defined(_FORTRANNOCAPS)
399 #define fsion_get_file_endianness_c fsion_get_file_endianness_c
401 #elif defined(_FORTRANUNDERSCORE)
402 #define fsion_get_file_endianness_c fsion_get_file_endianness_c_
404 #elif defined(_FORTRANDOUBLEUNDERSCORE)
405 #define fsion_get_file_endianness_c fsion_get_file_endianness_c__
407 #elif defined(_FORTRANNOUNDERSCORE)
409 #error nothing defined for fortran externals
415 #if defined(_FORTRANCAPS)
416 #define fsion_get_endianness_c FSION_GET_ENDIANNESS_C
418 #elif defined(_FORTRANNOCAPS)
419 #define fsion_get_endianness_c fsion_get_endianness_c
421 #elif defined(_FORTRANUNDERSCORE)
422 #define fsion_get_endianness_c fsion_get_endianness_c_
424 #elif defined(_FORTRANDOUBLEUNDERSCORE)
425 #define fsion_get_endianness_c fsion_get_endianness_c__
427 #elif defined(_FORTRANNOUNDERSCORE)
429 #error nothing defined for fortran externals
434 #if defined(_FORTRANCAPS)
435 #define fsion_endianness_swap_needed_c FSION_ENDIANNESS_SWAP_NEEDED_C
437 #elif defined(_FORTRANNOCAPS)
438 #define fsion_endianness_swap_needed_c fsion_endianness_swap_needed_c
440 #elif defined(_FORTRANUNDERSCORE)
441 #define fsion_endianness_swap_needed_c fsion_endianness_swap_needed_c_
443 #elif defined(_FORTRANDOUBLEUNDERSCORE)
444 #define fsion_endianness_swap_needed_c fsion_endianness_swap_needed_c__
446 #elif defined(_FORTRANNOUNDERSCORE)
448 #error nothing defined for fortran externals
454 #if defined(_FORTRANCAPS)
455 #define fsion_swap_c FSION_SWAP_C
457 #elif defined(_FORTRANNOCAPS)
458 #define fsion_swap_c fsion_swap_c
460 #elif defined(_FORTRANUNDERSCORE)
461 #define fsion_swap_c fsion_swap_c_
463 #elif defined(_FORTRANDOUBLEUNDERSCORE)
464 #define fsion_swap_c fsion_swap_c__
466 #elif defined(_FORTRANNOUNDERSCORE)
468 #error nothing defined for fortran externals
478 #define SWAP_2(x) ( (((x) & 0xff) << 8) | ((unsigned short)(x) >> 8) )
479 #define SWAP_4(x) ( ((x) << 24) | (((x) << 8) & 0x00ff0000) | \
480 (((x) >> 8) & 0x0000ff00) | ((x) >> 24) )
481 #define FIX_SHORT(x) (*(unsigned short *)&(x) = SWAP_2(*(unsigned short *)&(x)))
482 #define FIX_LONG(x) (*(unsigned *)&(x) = SWAP_4(*(unsigned *)&(x)))
483 #define FIX_FLOAT(x) FIX_LONG(x)
void fsion_feof_c(int *sid, int *eof)
Fortran function that indicates the end of file for this task.
sion_int64 fsion_bytes_avail_in_block_c(int *sid)
Fortran function that returns the number of bytes available in the current chunk.
void fsion_get_fileno_c(int *sid, int *filenumber)
Fortran function that returns the current file number.
void fsion_seek_c(int *sid, int *rank, int *currentblocknr, sion_int64 *posinblk, int *ierr)
Fortran procedure to set the file pointer to a new position.
void fsion_endianness_swap_needed_c(int *sid, int *needed)
Fortran function that returns whether or not byte swapping is needed (1 -> needed,...
void fsion_get_locations_c(int *sid, int *ntasks, int *maxblocks, sion_int64 *globalskip, sion_int64 *start_of_varheader, sion_int64 **sion_chunksizes, sion_int64 **sion_globalranks, sion_int64 **sion_blockcount, sion_int64 **sion_fsblksizes, int *ierr)
Fortran procedure that returns pointers to internal fields.
void fsion_open_c(char *fname, char *file_mode, int *ntasks, int *nfiles, sion_int64 *chunksizes, sion_int32 *fsblksize, int *globalranks, int *sid, int fname_len, int file_mode_len)
Fortran procedure to open a sion file in serial mode.
void fsion_get_file_endianness_c(int *sid, int *endianness)
Fortran function that returns endianness of a sion file (1-> big endian, 0 ->little endian)
void fsion_flush_c(int *sid, int *ierr)
Fortran procedure to flush a sion file.
void fsion_get_endianness_c(int *filenumber)
Fortran function that returns current endianness (1-> big endian, 0 ->little endian)
sion_int64 fsion_get_position_c(int *sid)
Fortran function that returns the current file position.
void fsion_open_rank_c(char *fname, char *file_mode, sion_int64 *chunksize, sion_int32 *fsblksize, int *rank, int *sid, int fname_len, int file_mode_len)
Fortran procedure to open a sion file for a specific rank.
void fsion_swap_c(void *target, void *source, int *size, int *n, int *do_swap, int *rc)
Fortran procedure to swap endianness of data.
void fsion_close_c(int *sid, int *ierr)
Fortran procedure to close a sion file.
void fsion_ensure_free_space_c(int *sid, sion_int64 *bytes, int *ierr)
Fortran procedure to ensure that enough space is available.