18 #define _XOPEN_SOURCE 700
35 #include "sion_fortran_mpi.h"
67 sion_int64 *chunksize,
68 sion_int32 *fsblksize,
76 char *fname_tmp,*fmode_tmp;
77 MPI_Comm cgComm,clComm;
80 #ifdef SION_DEBUG_BUG_OPENMPI
84 MPI_Comm_rank(MPI_COMM_WORLD,&grank);
85 fprintf(stderr,
"fsion_paropen_mpi: grank: %d\n", (
int) grank);
86 MPI_Comm_dup(MPI_COMM_WORLD,&newcomm);
87 MPI_Comm_split(MPI_COMM_WORLD,0,grank,&newcomm);
91 fname_tmp = (
char *) malloc((
size_t) ((fname_len + 1) *
sizeof(
char)));
92 fmode_tmp = (
char *) malloc((
size_t) ((file_mode_len + 1) *
sizeof(
char)));
95 strncpy(fname_tmp, fname, fname_len);
96 strncpy(fmode_tmp, file_mode, file_mode_len);
98 fname_tmp[fname_len] =
'\0';
99 fmode_tmp[file_mode_len] =
'\0';
103 cgComm = MPI_Comm_f2c(*fgComm);
104 clComm = MPI_Comm_f2c(*flComm);
106 #ifdef SION_DEBUG_UNUSED
107 if (*globalrank == 0){
108 if (cgComm == MPI_COMM_WORLD) fprintf(stderr,
"COMM_WORLD selected\n");
109 fprintf(stderr,
"fsion_paropen_mpi: filename_len: %d\n", (
int) fname_len);
110 fprintf(stderr,
"fsion_paropen_mpi: filename: %s\n",fname_tmp);
115 fprintf(stderr,
"fsion_paropen_mpi: filemode_len: %d\n", (
int) file_mode_len);
116 fprintf(stderr,
"fsion_paropen_mpi: filemode: %s\n",fmode_tmp);
118 fprintf(stderr,
"fsion_paropen_mpi: chunksize: %lld\n",*chunksize);
119 fprintf(stderr,
"fsion_paropen_mpi: fsblksize: %d\n",*fsblksize);
120 fprintf(stderr,
"fsion_paropen_mpi: numFiles: %d\n",*numFiles);
124 (*sid) =
sion_paropen_mpi(fname_tmp, fmode_tmp, numFiles, cgComm, &clComm, chunksize, fsblksize, globalrank, NULL, NULL);
168 sion_int64 *chunksize,
169 sion_int32 *fsblksize,
170 int *globalrank,
int *sid,
char *newfname,
int fname_len,
int file_mode_len,
int newfname_len)
172 MPI_Comm cgComm, clComm;
175 char *fname_tmp, *fmode_tmp, *newfname_tmp;
178 fname_tmp = (
char *) malloc((
size_t) ((fname_len + 1) *
sizeof(
char)));
179 fmode_tmp = (
char *) malloc((
size_t) ((file_mode_len + 1) *
sizeof(
char)));
180 newfname_tmp = (
char *) malloc((
size_t) ((newfname_len + 1) *
sizeof(
char)));
182 strncpy(fname_tmp, fname, fname_len);
183 strncpy(fmode_tmp, file_mode, file_mode_len);
185 fname_tmp[fname_len] =
'\0';
186 fmode_tmp[file_mode_len] =
'\0';
187 newfname_tmp[newfname_len] =
'\0';
188 strncpy(newfname_tmp, newfname, newfname_len);
190 cgComm = MPI_Comm_f2c(*fgComm);
212 (*sid) = sion_paropen_multi_mpi(fname_tmp, fmode_tmp, numFiles, cgComm, &clComm, chunksize, fsblksize, globalrank, NULL, newfname_tmp);
214 *flComm = MPI_Comm_c2f(clComm);
215 strncpy(newfname, newfname_tmp, newfname_len);
void fsion_parclose_mpi_c(int *sid, int *ierr)
Fortran procedure to close a sion file in parallel.
void fsion_paropen_mpi_c(char *fname, char *file_mode, int *numFiles, MPI_Fint *fgComm, MPI_Fint *flComm, sion_int64 *chunksize, sion_int32 *fsblksize, int *globalrank, char *newfname, int *sid, int fname_len, int file_mode_len, int newfname_len)
Wrapper function that calls fsion_paropen_multi_mpi for 1 file.
void fsion_paropen_multi_mpi_c(char *fname, char *file_mode, int *numFiles, MPI_Fint *fgComm, MPI_Fint *flComm, sion_int64 *chunksize, sion_int32 *fsblksize, int *globalrank, int *sid, char *newfname, int fname_len, int file_mode_len, int newfname_len)
Fortran procedure to open multiple sion files in parallel.
int sion_paropen_mpi(const char *fname, const char *file_mode, int *numFiles, MPI_Comm gComm, const MPI_Comm *lComm, sion_int64 *chunksize, sion_int32 *fsblksize, int *globalrank, FILE **fileptr, char **newfname)
Open a sion file using MPI.
int sion_parclose_mpi(int sid)
Close a sion file using MPI.