/* Automatically generated by make_fint.c, don't edit! */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#if !defined(CDIPIO_H_)
#include "cdipio.h"
#endif

#if defined(HAVE_CF_INTERFACE)

#include <limits.h>
#include <assert.h>

#if !defined(__CFORTRAN_LOADED)
#if defined __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#endif
#include "cfortran.h"
#if defined __clang__
#pragma GCC diagnostic pop
#endif
#endif
/* These functions are meant to be called from Fortran and don't
 * need an interface declaration in a C header. */
#if defined __clang__
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#endif

static inline int
size_t_c2f(size_t value_size_t)
{
  assert(value_size_t < INT_MAX);
  return (int) value_size_t;
}

/*  parallel IO IOMode  */

/*  parallel IO routines  */

FCALLSCSUB0(pioEndDef, PIOENDDEF, pioenddef)
FCALLSCSUB0(pioEndTimestepping, PIOENDTIMESTEPPING, pioendtimestepping)
FCALLSCSUB0(pioFinalize, PIOFINALIZE, piofinalize)
FCALLSCSUB0(cdiPioNoPostCommSetup, CDIPIONOPOSTCOMMSETUP, cdipionopostcommsetup)

#undef ROUTINE_6
#define ROUTINE_6 (void (*)(void))
static int
pioInit_fwrap(int commSuper, int nProcsIO, int IOMode, int *pioNamespace, float partInflate, void (*postCommSetupActions)(void))
{
  MPI_Comm v;
  v = pioInit(MPI_Comm_f2c(commSuper), nProcsIO, IOMode, pioNamespace, partInflate, postCommSetupActions);
  return MPI_Comm_c2f(v);
}
FCALLSCFUN6(INT, pioInit_fwrap, PIOINIT, pioinit, INT, INT, INT, PINT, FLOAT, ROUTINE)
static int
cdiPioInit_fwrap(int commSuper, int confResH, int *pioNamespace)
{
  MPI_Comm v;
  v = cdiPioInit(MPI_Comm_f2c(commSuper), confResH, pioNamespace);
  return MPI_Comm_c2f(v);
}
FCALLSCFUN3(INT, cdiPioInit_fwrap, CDIPIOINIT, cdipioinit, INT, INT, PINT)
FCALLSCSUB0(pioWriteTimestep, PIOWRITETIMESTEP, piowritetimestep)
FCALLSCSUB0(cdiPioRDMAProgress, CDIPIORDMAPROGRESS, cdipiordmaprogress)
static void
streamWriteVarPart_fwrap(int streamID, int varID, const void *data, int nmiss, void *partDesc)
{
  streamWriteVarPart(streamID, varID, data, (size_t) nmiss, (*(Xt_idxlist *) partDesc));
}
FCALLSCSUB5(streamWriteVarPart_fwrap, STREAMWRITEVARPART, streamwritevarpart, INT, INT, PVOID, INT, PVOID)
static void
streamWriteScatteredVarPart_fwrap(int streamID, int varID, const void *data, int numBlocks, const int blocklengths[],
                                  const int displacements[], int nmiss, void *partDesc)
{
  streamWriteScatteredVarPart(streamID, varID, data, numBlocks, blocklengths, displacements, (size_t) nmiss,
                              (*(Xt_idxlist *) partDesc));
}
FCALLSCSUB8(streamWriteScatteredVarPart_fwrap, STREAMWRITESCATTEREDVARPART, streamwritescatteredvarpart, INT, INT, PVOID, INT, INTV,
            INTV, INT, PVOID)
static int
cdiPioCSRLastN_fwrap(int commSuper, int IOMode, int nProcsIO)
{
  int v;
  v = cdiPioCSRLastN(MPI_Comm_f2c(commSuper), IOMode, nProcsIO);
  return v;
}
FCALLSCFUN3(INT, cdiPioCSRLastN_fwrap, CDIPIOCSRLASTN, cdipiocsrlastn, INT, INT, INT)
static int
cdiPioCSRFirstN_fwrap(int commSuper, int IOMode, int nProcsIO)
{
  int v;
  v = cdiPioCSRFirstN(MPI_Comm_f2c(commSuper), IOMode, nProcsIO);
  return v;
}
FCALLSCFUN3(INT, cdiPioCSRFirstN_fwrap, CDIPIOCSRFIRSTN, cdipiocsrfirstn, INT, INT, INT)
static int
cdiPioCSRBalanced_fwrap(int commSuper, int IOMode, int nProcsIO)
{
  int v;
  v = cdiPioCSRBalanced(MPI_Comm_f2c(commSuper), IOMode, nProcsIO);
  return v;
}
FCALLSCFUN3(INT, cdiPioCSRBalanced_fwrap, CDIPIOCSRBALANCED, cdipiocsrbalanced, INT, INT, INT)
FCALLSCFUN1(INT, cdiPioStr2IOMode, CDIPIOSTR2IOMODE, cdipiostr2iomode, STRING)
FCALLSCFUN0(INT, cdiPioConfCreate, CDIPIOCONFCREATE, cdipioconfcreate)
FCALLSCSUB1(cdiPioConfDestroy, CDIPIOCONFDESTROY, cdipioconfdestroy, INT)
FCALLSCSUB2(cdiPioConfSetPartInflate, CDIPIOCONFSETPARTINFLATE, cdipioconfsetpartinflate, INT, FLOAT)
FCALLSCFUN1(FLOAT, cdiPioConfGetPartInflate, CDIPIOCONFGETPARTINFLATE, cdipioconfgetpartinflate, INT)
FCALLSCSUB2(cdiPioConfSetIOMode, CDIPIOCONFSETIOMODE, cdipioconfsetiomode, INT, INT)
FCALLSCFUN1(INT, cdiPioConfGetIOMode, CDIPIOCONFGETIOMODE, cdipioconfgetiomode, INT)
FCALLSCSUB2(cdiPioConfSetCSRole, CDIPIOCONFSETCSROLE, cdipioconfsetcsrole, INT, INT)
FCALLSCFUN1(INT, cdiPioConfGetCSRole, CDIPIOCONFGETCSROLE, cdipioconfgetcsrole, INT)

#undef ROUTINE_2
#define ROUTINE_2 (void (*)(void))
FCALLSCSUB2(cdiPioConfSetPostCommSetupActions, CDIPIOCONFSETPOSTCOMMSETUPACTIONS, cdipioconfsetpostcommsetupactions, INT, ROUTINE)

/*  cdiPioConfSetLargePageAlign should block buffer be aligned to
 * large pages instead of normal pages?  */

FCALLSCSUB2(cdiPioConfSetLargePageAlign, CDIPIOCONFSETLARGEPAGEALIGN, cdipioconfsetlargepagealign, INT, INT)
FCALLSCFUN1(INT, cdiPioConfGetLargePageAlign, CDIPIOCONFGETLARGEPAGEALIGN, cdipioconfgetlargepagealign, INT)
FCALLSCSUB2(cdiPioConfSetRedistCache, CDIPIOCONFSETREDISTCACHE, cdipioconfsetredistcache, INT, INT)
FCALLSCFUN1(INT, cdiPioConfGetRedistCache, CDIPIOCONFGETREDISTCACHE, cdipioconfgetredistcache, INT)

/*  convert index lists to stripes prior to intersection computation,
 * defaults to true  */

FCALLSCSUB2(cdiPioConfSetStripeConversion, CDIPIOCONFSETSTRIPECONVERSION, cdipioconfsetstripeconversion, INT, INT)

/*  are index lists of parts converted stripes before being passed
 * to the xmap constructor?  */

FCALLSCFUN1(INT, cdiPioConfGetStripeConversion, CDIPIOCONFGETSTRIPECONVERSION, cdipioconfgetstripeconversion, INT)

#if defined __clang__
#pragma GCC diagnostic pop
#endif
#endif
