SIONlib  2.0.0-rc.2
Scalable I/O library for parallel access to task-local files
sion_mpi_file_check.c
1 /****************************************************************************
2 ** SIONLIB http://www.fz-juelich.de/jsc/sionlib **
3 *****************************************************************************
4 ** Copyright (c) 2008-2019 **
5 ** Forschungszentrum Juelich, Juelich Supercomputing Centre **
6 ** **
7 ** See the file COPYRIGHT in the package base directory for details **
8 ****************************************************************************/
9 
10 #define _XOPEN_SOURCE 700
11 
12 #include <mpi.h>
13 #include <stdlib.h>
14 
15 #include "sion_const.h"
16 #include "sion_debug.h"
17 #include "sion_enums.h"
18 #include "sion_error_handler.h"
19 
20 #ifdef SION_MPI
21 
22 #include "sion_mpi.h"
23 #include "sion_mpi_internal_gen.h"
24 
26  sion_open_mode mode;
27  MPI_Comm comm;
28  sion_mpi_options options;
29 };
30 
31 sion_file_check_par_args_mpi *sion_file_check_par_args_init_mpi(
32  sion_open_mode mode, MPI_Comm comm, const sion_mpi_options *options)
33 {
35 
36  if (cb_args) {
37  cb_args->mode = mode;
38  cb_args->comm = comm;
39  cb_args->options = (options) ? *options : SION_MPI_OPTIONS_INIT;
40  } else {
41  _sion_errorprint(SION_NOT_SUCCESS, _SION_ERROR_RETURN,
42  "cannot allocate cb_args structure of size %lu (sion_file_check_par_args), aborting ...\n",
43  (unsigned long)sizeof(sion_file_check_par_args_mpi));
44  }
45 
46  return cb_args;
47 }
48 
49 void sion_file_check_par_args_free_mpi(sion_file_check_par_args_mpi *cb_args)
50 {
51  free(cb_args);
52 }
53 
54 int sion_file_check_par_cb_mpi(char *fname, void *v_args)
55 {
56  sion_file_check_par_args_mpi *cb_args = v_args;
57  int grank;
58  MPI_Comm_rank(cb_args->comm, &grank);
59 
60  // FIXME
61  // DPRINTFP((1, __func__, grank, "enter parallel check of file %s with mode %s\n", fname, cb_args->file_mode));
62  DPRINTFP((1, __func__, grank, "enter parallel check of file %s\n", fname));
63 
64  _sion_errorprint_set_flag(_SION_ERROR_FLAG_SUPPRESS_MSG);
65  int sid = sion_paropen_mpi(fname, cb_args->mode, cb_args->comm, &cb_args->options);
66  _sion_errorprint_set_flag(_SION_ERROR_FLAG_NONE);
67  int rc;
68  if (sid < 0) {
69  rc = SION_NOT_SUCCESS;
70  } else {
71  rc = SION_SUCCESS;
72  sion_parclose_mpi(sid);
73  }
74 
75  // FIXME
76  // DPRINTFP((1, __func__, grank, "leave parallel check of file %s with mode %s rc=%d\n", fname, cb_args->file_mode, rc));
77  DPRINTFP((1, __func__, grank, "leave parallel check of file %s rc=%d\n", fname, rc));
78  return rc;
79 }
80 
81 #endif
int sion_paropen_mpi(const char *filename, sion_open_mode mode, MPI_Comm communicator, const sion_mpi_options *options)
Open a SIONlib file from multiple MPI processes.
Definition: sion_mpi_gen.c:237
int sion_parclose_mpi(int sid)
Close a SIONlib file using MPI.
Definition: sion_mpi_gen.c:34
sion_open_mode
specifies for what type of access to open a file
Definition: sion_enums.h:27
struct sion_mpi_options sion_mpi_options
Holds non-essential arguments for sion_paropen_mpi().
Definition: sion_mpi.h:44