/****************************************************************************
**  SIONLIB     http://www.fz-juelich.de/jsc/sionlib                       **
*****************************************************************************
**  Copyright (c) 2008-2019                                                **
**  Forschungszentrum Juelich, Juelich Supercomputing Centre               **
**                                                                         **
**  See the file COPYRIGHT in the package base directory for details       **
****************************************************************************/

/*!
 * \cond sion_internal
 * \file
 */

#ifndef SION_SION_GENERIC_PAR_MAPPED_H
#define SION_SION_GENERIC_PAR_MAPPED_H

#include <stdint.h>
#include <stdio.h>

#include "sion_const.h"
#include "sion_generic_apidesc.h"

/*!\brief Generic parallel open of one direct access file.
          Mapping sion files to environment with less tasks.
 * @param  sid              sion file handle
 * @param  fname            filename to use
 * @param  file_mode_flags  flags from already parsed file_mode (see also sion_internal.h)
 * @param  numFiles         Number of files to open
 * @param  nlocaltasks      FIXME
 * @param  globalranks      FIXME
 * @param  chunksizes       chunksizes for all tasks
 * @param  mapping_filenrs  FIXME
 * @param  mapping_lranks   FIXME
 * @param  fsblksize        blocksize of filesystem (must be equal on all processors)
 * @param  rank             rank of the current process
 * @param  ntasks           number of processes
 * @param  flag             sion options flag
 * @param  fileptr          filepointer for this task
 * @param  sion_gendata     FIXME
 *
 * @return  sion file handle
 *          -1 if error occured
 */
int _sion_paropen_mapped_generic(int sid, char *fname, int64_t file_mode_flags, int *numFiles, int *nlocaltasks,
  int **globalranks, int64_t **chunksizes, int **mapping_filenrs, int **mapping_lranks, int32_t *fsblksize, int rank, int ntasks,
  int flag, FILE **fileptr, _sion_generic_gendata *sion_gendata);

int _sion_parclose_mapped_generic(int sid, int rank, int ntasks, _sion_generic_gendata *sion_gendata);
#endif

/// \endcond
