SIONlib  1.7.0
Scalable I/O library for parallel access to task-local files
sion_fortran_omp.c
Go to the documentation of this file.
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2016 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 
22 #include "sion.h"
23 #include "sion_debug.h"
24 #include "sion_fd.h"
25 #include "sion_filedesc.h"
26 #include "sion_omp.h"
27 #include "sion_fortran_omp.h"
28 
47 void fsion_paropen_omp_c(char *fname,
48  char *file_mode,
49  sion_int64 *chunksize,
50  sion_int32 *fsblksize,
51  int *globalrank,
52  char *newfname,
53  int *sid,
54  int fname_len,
55  int file_mode_len,
56  int newfname_len)
57 {
58  FILE *fileptr;
59  char *fname_tmp,*fmode_tmp;
60 
61  fname_tmp = (char *) malloc((size_t) ((fname_len + 1) * sizeof(char)));
62  fmode_tmp = (char *) malloc((size_t) ((file_mode_len + 1) * sizeof(char)));
63 
64  /* Copy the strings to the new buffers and pad with nulls */
65  strncpy(fname_tmp, fname, fname_len);
66  strncpy(fmode_tmp, file_mode, file_mode_len);
67 
68  fname_tmp[fname_len] = '\0';
69  fmode_tmp[file_mode_len] = '\0';
70 
71 #ifdef SION_DEBUG_UNUSED
72  if (*globalrank == 0){
73  fprintf(stderr,"fsion_paropen_omp: filename_len: %d\n", (int) fname_len);
74  fprintf(stderr,"fsion_paropen_omp: filename: %s\n",fname_tmp);
75 
76  fprintf(stderr,"fsion_paropen_omp: filemode_len: %d\n", (int) file_mode_len);
77  fprintf(stderr,"fsion_paropen_omp: filemode: %s\n",fmode_tmp);
78 
79  fprintf(stderr,"fsion_paropen_omp: chunksize: %lld\n",*chunksize);
80  fprintf(stderr,"fsion_paropen_omp: fsblksize: %d\n",*fsblksize);
81  }
82 #endif
83 
84  (*sid) = sion_paropen_omp(fname_tmp, fmode_tmp, chunksize, fsblksize, globalrank, &fileptr, NULL);
85 
86 
87  /* Free the used memory */
88  free(fname_tmp);
89  free(fmode_tmp);
90 
91 }
92 
103 void fsion_parclose_omp_c(int *sid,
104  int *ierr)
105 {
106  (*ierr) = sion_parclose_omp(*sid);
107 }
108 
void fsion_paropen_omp_c(char *fname, char *file_mode, sion_int64 *chunksize, sion_int32 *fsblksize, int *globalrank, char *newfname, int *sid, int fname_len, int file_mode_len, int newfname_len)
Fortran wrapper function that calls sion_paropen_omp.
void fsion_parclose_omp_c(int *sid, int *ierr)
Fortran procedure to close a sion file opened with OpenMP in parallel.