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

#if defined(_BGL)
#include <rts.h>
#ifndef __USE_FILE_OFFSET64
#define __USE_FILE_OFFSET64
#endif
#endif

#ifdef SION_OMPI

struct __ompi_thread_sync_struct
{
	int grank_master_mpi;
	int grank_master_ompi;
	int lrank_master_mpi;
	int lrank_master_ompi;
	int gsize_mpi;
	int gsize_ompi;
	int lsize_mpi;
	int lsize_ompi;
	int num_threads;
	int numFiles;
	int filenumber;
};

typedef struct __ompi_thread_sync_struct __ompi_thread_sync;


int _lsion_gen_info_from_gcomm_ompi(int numFiles, MPI_Comm gComm, int *filenumber, int *lrank, int *lsize);
int _lsion_get_info_from_splitted_comm_ompi(MPI_Comm gComm, MPI_Comm lComm, int *numComm, int *CommNumber, int *lrank, int *lsize);

int _lsion_get_size_ompi(int ompi_rank, int num_threads);
int _lsion_map_rank_mpi_to_ompi(int mpi_rank, int num_threads, int thread_num);
int _lsion_map_rank_ompi_to_mpi(int ompi_rank, int num_threads);
int _lsion_map_rank_ompi_to_thread_num(int ompi_rank, int num_threads);


int _lsion_errorprint_ompi(int rc, int level, const char *format, ...);

#endif

#endif
