<commit_before>#ifndef OCCA_FBASE_HEADER
#define OCCA_FBASE_HEADER

#include <stdint.h>
#include <stdio.h>
#include "occaCBase.hpp"

/*
 * The code related to fortran string handling was adapted from petsc.  The
 * license information for petsc can be found below.
 *
 *     Licensing Notification
 *
 *       Permission to use, reproduce, prepare derivative works, and to
 *       redistribute to others this software, derivatives of this software, and
 *       future versions of this software as well as its documentation is hereby
 *       granted, provided that this notice is retained thereon and on all
 *       copies or modifications. This permission is perpetual, world-wide, and
 *       provided on a royalty-free basis. UChicago Argonne, LLC and all other
 *       contributors make no representations as to the suitability and
 *       operability of this software for any purpose. It is provided "as is"
 *       without express or implied warranty.
 *
 *      Authors: http://www.mcs.anl.gov/petsc/miscellaneous/index.html
 *
 *
 *      - Mathematics and Computer Science Division
 *      - Argonne National Laboratory
 *      - Argonne IL 60439
 *
 *
 *       Portions of this software are copyright by UChicago Argonne, LLC.
 *       Argonne National Laboratory with facilities in the state of Illinois,
 *       is owned by The United States Government, and operated by UChicago
 *       Argonne, LLC under provision of a contract with the Department of
 *       Energy.
 *
 *     DISCLAIMER
 *
 *       PORTIONS OF THIS SOFTWARE WERE PREPARED AS AN ACCOUNT OF WORK SPONSORED
 *       BY AN AGENCY OF THE UNITED STATES GOVERNMENT. NEITHER THE UNITED STATES
 *       GOVERNMENT NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, NOR
 *       ANY OF THEIR EMPLOYEES OR OFFICERS, MAKES ANY WARRANTY, EXPRESS OR
 *       IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE
 *       ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS,
 *       PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT
 *       INFRINGE PRIVATELY OWNED RIGHTS. REFERENCE HEREIN TO ANY SPECIFIC
 *       COMMERCIAL PRODUCT, PROCESS, OR SERVICE BY TRADE NAME, TRADEMARK,
 *       MANUFACTURER, OR OTHERWISE, DOES NOT NECESSARILY CONSTITUTE OR IMPLY
 *       ITS ENDORSEMENT, RECOMMENDATION, OR FAVORING BY THE UNITED STATES
 *       GOVERNMENT OR ANY AGENCY THEREOF. THE VIEW AND OPINIONS OF AUTHORS
 *       EXPRESSED HEREIN DO NOT NECESSARILY STATE OR REFLECT THOSE OF THE
 *       UNITED STATES GOVERNMENT OR ANY AGENCY THEREOF.
 *
 */

#include <stdlib.h>
#include <string.h>

#define OCCA_F2C_NULL_CHARACTER_Fortran ((char *) 0)

/* --------------------------------------------------------------------*/
/*
    This lets us map the str-len argument either, immediately following
    the char argument (DVF on Win32) or at the end of the argument list
    (general unix compilers)
*/
#if defined(OCCAF_HAVE_FORTRAN_MIXED_STR_ARG)
#define OCCA_F2C_LSTR(len) ,int len
#define OCCA_F2C_RSTR(len)
#else
#define OCCA_F2C_LSTR(len)
#define OCCA_F2C_RSTR(len)   ,int len
#endif

/* --------------------------------------------------------------------*/
#define OCCA_F2C_ALLOC_STR(a,n,b)               \
  do {                                          \
    if (a == OCCA_F2C_NULL_CHARACTER_Fortran) { \
      b = 0;                                    \
    } else {                                    \
      while((n > 0) && (a[n-1] == ' ')) n--;    \
      b = (char*)malloc((n+1)*sizeof(char));    \
      if(b==NULL) abort();                      \
      strncpy(b,a,n);                           \
      b[n] = '\0';                              \
    }                                           \
  } while (0)

#define OCCA_F2C_FREE_STR(a,b)                  \
  do {                                          \
    if (a != b) free(b);                        \
  } while (0)

#define OCCA_F2C_GLOBAL_(name,NAME) name##_

#define  OCCAINT_FC                      OCCA_F2C_GLOBAL_(occaint_fc                    , OCCAINT_FC)
#define  OCCAINT32_FC                    OCCA_F2C_GLOBAL_(occaint32_fc                  , OCCAINT32_FC)
#define  OCCAUINT_FC                     OCCA_F2C_GLOBAL_(occauint_fc                   , OCCAUINT_FC)
#define  OCCACHAR_FC                     OCCA_F2C_GLOBAL_(occachar_fc                   , OCCACHAR_FC)
#define  OCCAUCHAR_FC                    OCCA_F2C_GLOBAL_(occauchar_fc                  , OCCAUCHAR_FC)
#define  OCCASHORT_FC                    OCCA_F2C_GLOBAL_(occashort_fc                  , OCCASHORT_FC)
#define  OCCAUSHORT_FC                   OCCA_F2C_GLOBAL_(occaushort_fc                 , OCCAUSHORT_FC)
#define  OCCALONG_FC                     OCCA_F2C_GLOBAL_(occalong_fc                   , OCCALONG_FC)
#define  OCCAULONG_FC                    OCCA_F2C_GLOBAL_(occaulong_fc                  , OCCAULONG_FC)
#define  OCCAFLOAT_FC                    OCCA_F2C_GLOBAL_(occafloat_fc                  , OCCAFLOAT_FC)
#define  OCCADOUBLE_FC                   OCCA_F2C_GLOBAL_(occadouble_fc                 , OCCADOUBLE_FC)
#define  OCCASTRING_FC                   OCCA_F2C_GLOBAL_(occastring_fc                 , OCCASTRING_FC)
#define  OCCADEVICEMODE_FC               OCCA_F2C_GLOBAL_(occadevicemode_fc             , OCCADEVICEMODE_FC)
#define  OCCADEVICESETCOMPILER_FC        OCCA_F2C_GLOBAL_(occadevicesetcompiler_fc      , OCCADEVICESETCOMPILER_FC)
#define  OCCADEVICESETCOMPILERFLAGS_FC   OCCA_F2C_GLOBAL_(occadevicesetcompilerflags_fc , OCCADEVICESETCOMPILERFLAGS_FC)
#define  OCCAGETDEVICE_FC                OCCA_F2C_GLOBAL_(occagetdevice_fc              , OCCAGETDEVICE_FC)
#define  OCCAGETDEVICEFROMARGS_FC        OCCA_F2C_GLOBAL_(occagetdevicefromargs_fc      , OCCAGETDEVICEFROMARGS_FC)
#define  OCCABUILDKERNELFROMSOURCE_FC    OCCA_F2C_GLOBAL_(occabuildkernelfromsource_fc  , OCCABUILDKERNELFROMSOURCE_FC)
#define  OCCABUILDKERNELFROMSOURCENOKERNELINFO_FC    OCCA_F2C_GLOBAL_(occabuildkernelfromsourcenokernelinfo_fc  , OCCABUILDKERNELFROMSOURCENOKERNELINFO_FC)
#define  OCCABUILDKERNELFROMBINARY_FC    OCCA_F2C_GLOBAL_(occabuildkernelfrombinary_fc  , OCCABUILDKERNELFROMBINARY_FC)
#define  OCCABUILDKERNELFROMLOOPY_FC     OCCA_F2C_GLOBAL_(occabuildkernelfromloopy_fc   , OCCABUILDKERNELFROMLOOPY_FC)
#define  OCCABUILDKERNELFROMFLOOPY_FC    OCCA_F2C_GLOBAL_(occabuildkernelfromfloopy_fc  , OCCABUILDKERNELFROMFLOOPY_FC)
#define  OCCADEVICEMALLOCNULL_FC         OCCA_F2C_GLOBAL_(occadevicemallocnull_fc       , OCCADEVICEMALLOCNULL_FC)
#define  OCCADEVICEMALLOC_FC             OCCA_F2C_GLOBAL_(occadevicemalloc_fc           , OCCADEVICEMALLOC_FC)
#define  OCCADEVICEFLUSH_FC              OCCA_F2C_GLOBAL_(occadeviceflush_fc            , OCCADEVICEFLUSH_FC)
#define  OCCADEVICEFINISH_FC             OCCA_F2C_GLOBAL_(occadevicefinish_fc           , OCCADEVICEFINISH_FC)
#define  OCCADEVICEGENSTREAM_FC          OCCA_F2C_GLOBAL_(occadevicegenstream_fc        , OCCADEVICEGENSTREAM_FC)
#define  OCCADEVICEGETSTREAM_FC          OCCA_F2C_GLOBAL_(occadevicegetstream_fc        , OCCADEVICEGETSTREAM_FC)
#define  OCCADEVICESETSTREAM_FC          OCCA_F2C_GLOBAL_(occadevicesetstream_fc        , OCCADEVICESETSTREAM_FC)
#define  OCCADEVICETAGSTREAM_FC          OCCA_F2C_GLOBAL_(occadevicetagstream_fc        , OCCADEVICETAGSTREAM_FC)
#define  OCCADEVICETIMEBETWEENTAGS_FC    OCCA_F2C_GLOBAL_(occadevicetimebetweentags_fc  , OCCADEVICETIMEBETWEENTAGS_FC)
#define  OCCADEVICESTREAMFREE_FC         OCCA_F2C_GLOBAL_(occadevicestreamfree_fc       , OCCADEVICESTREAMFREE_FC)
#define  OCCADEVICEFREE_FC               OCCA_F2C_GLOBAL_(occadevicefree_fc             , OCCADEVICEFREE_FC)
#define  OCCAKERNELMODE_FC               OCCA_F2C_GLOBAL_(occakernelmode_fc             , OCCAKERNELMODE_FC)
#define  OCCAKERNELPREFERREDDIMSIZE_FC   OCCA_F2C_GLOBAL_(occakernelpreferreddimsize_fc , OCCAKERNELPREFERREDDIMSIZE_FC)
#define  OCCAKERNELSETWORKINGDIMS_FC     OCCA_F2C_GLOBAL_(occakernelsetworkingdims_fc   , OCCAKERNELSETWORKINGDIMS_FC)
#define  OCCAKERNELSETALLWORKINGDIMS_FC  OCCA_F2C_GLOBAL_(occakernelsetallworkingdims_fc, OCCAKERNELSETALLWORKINGDIMS_FC)
#define  OCCAKERNELTIMETAKEN_FC          OCCA_F2C_GLOBAL_(occakerneltimetaken_fc        , OCCAKERNELTIMETAKEN_FC)
#define  OCCAGENARGUMENTLIST_FC          OCCA_F2C_GLOBAL_(occagenargumentlist_fc        , OCCAGENARGUMENTLIST_FC)
#define  OCCAARGUMENTLISTCLEAR_FC        OCCA_F2C_GLOBAL_(occaargumentlistclear_fc      , OCCAARGUMENTLISTCLEAR_FC)
#define  OCCAARGUMENTLISTFREE_FC         OCCA_F2C_GLOBAL_(occaargumentlistfree_fc       , OCCAARGUMENTLISTFREE_FC)
#define  OCCAARGUMENTLISTADDARGMEM_FC    OCCA_F2C_GLOBAL_(occaargumentlistaddargmem_fc  , OCCAARGUMENTLISTADDARGMEM_FC)
#define  OCCAARGUMENTLISTADDARGTYPE_FC   OCCA_F2C_GLOBAL_(occaargumentlistaddargtype_fc , OCCAARGUMENTLISTADDARGTYPE_FC)
#define  OCCAARGUMENTLISTADDARGINT4_FC   OCCA_F2C_GLOBAL_(occaargumentlistaddargint4_fc , OCCAARGUMENTLISTADDARGINT4_FC)
#define  OCCAARGUMENTLISTADDARGREAL4_FC  OCCA_F2C_GLOBAL_(occaargumentlistaddargreal4_fc, OCCAARGUMENTLISTADDARGREAL4_FC)
#define  OCCAARGUMENTLISTADDARGREAL8_FC  OCCA_F2C_GLOBAL_(occaargumentlistaddargreal8_fc, OCCAARGUMENTLISTADDARGREAL8_FC)
#define  OCCAARGUMENTLISTADDARGCHAR_FC   OCCA_F2C_GLOBAL_(occaargumentlistaddargchar_fc , OCCAARGUMENTLISTADDARGCHAR_FC)
#define  OCCAKERNELRUN__FC               OCCA_F2C_GLOBAL_(occakernelrun__fc             , OCCAKERNELRUN__FC)
#define  OCCAKERNELRUN01_FC              OCCA_F2C_GLOBAL_(occakernelrun01_fc            , OCCAKERNELRUN01_FC)
#define  OCCAKERNELRUN02_FC              OCCA_F2C_GLOBAL_(occakernelrun02_fc            , OCCAKERNELRUN02_FC)
#define  OCCAKERNELRUN03_FC              OCCA_F2C_GLOBAL_(occakernelrun03_fc            , OCCAKERNELRUN03_FC)
#define  OCCAKERNELRUN04_FC              OCCA_F2C_GLOBAL_(occakernelrun04_fc            , OCCAKERNELRUN04_FC)
#define  OCCAKERNELRUN05_FC              OCCA_F2C_GLOBAL_(occakernelrun05_fc            , OCCAKERNELRUN05_FC)
#define  OCCAKERNELRUN06_FC              OCCA_F2C_GLOBAL_(occakernelrun06_fc            , OCCAKERNELRUN06_FC)
#define  OCCAKERNELRUN07_FC              OCCA_F2C_GLOBAL_(occakernelrun07_fc            , OCCAKERNELRUN07_FC)
#define  OCCAKERNELRUN08_FC              OCCA_F2C_GLOBAL_(occakernelrun08_fc            , OCCAKERNELRUN08_FC)
#define  OCCAKERNELRUN09_FC              OCCA_F2C_GLOBAL_(occakernelrun09_fc            , OCCAKERNELRUN09_FC)
#define  OCCAKERNELRUN10_FC              OCCA_F2C_GLOBAL_(occakernelrun10_fc            , OCCAKERNELRUN10_FC)
#define  OCCAKERNELRUN11_FC              OCCA_F2C_GLOBAL_(occakernelrun11_fc            , OCCAKERNELRUN11_FC)
#define  OCCAKERNELRUN12_FC              OCCA_F2C_GLOBAL_(occakernelrun12_fc            , OCCAKERNELRUN12_FC)
#define  OCCAKERNELRUN13_FC              OCCA_F2C_GLOBAL_(occakernelrun13_fc            , OCCAKERNELRUN13_FC)
#define  OCCAKERNELRUN14_FC              OCCA_F2C_GLOBAL_(occakernelrun14_fc            , OCCAKERNELRUN14_FC)
#define  OCCAKERNELRUN15_FC              OCCA_F2C_GLOBAL_(occakernelrun15_fc            , OCCAKERNELRUN15_FC)
#define  OCCAKERNELRUN16_FC              OCCA_F2C_GLOBAL_(occakernelrun16_fc            , OCCAKERNELRUN16_FC)
#define  OCCAKERNELRUN17_FC              OCCA_F2C_GLOBAL_(occakernelrun17_fc            , OCCAKERNELRUN17_FC)
#define  OCCAKERNELRUN18_FC              OCCA_F2C_GLOBAL_(occakernelrun18_fc            , OCCAKERNELRUN18_FC)
#define  OCCAKERNELRUN19_FC              OCCA_F2C_GLOBAL_(occakernelrun19_fc            , OCCAKERNELRUN19_FC)
#define  OCCAKERNELRUN20_FC              OCCA_F2C_GLOBAL_(occakernelrun20_fc            , OCCAKERNELRUN20_FC)
#define  OCCAKERNELRUN21_FC              OCCA_F2C_GLOBAL_(occakernelrun21_fc            , OCCAKERNELRUN21_FC)
#define  OCCAKERNELRUN22_FC              OCCA_F2C_GLOBAL_(occakernelrun22_fc            , OCCAKERNELRUN22_FC)
#define  OCCAKERNELRUN24_FC              OCCA_F2C_GLOBAL_(occakernelrun24_fc            , OCCAKERNELRUN24_FC)
#define  OCCAKERNELFREE_FC               OCCA_F2C_GLOBAL_(occakernelfree_fc             , OCCAKERNELFREE_FC)
#define  OCCAGENKERNELINFO_FC            OCCA_F2C_GLOBAL_(occagenkernelinfo_fc          , OCCAGENKERNELINFO_FC)
#define  OCCAKERNELINFOADDDEFINE_FC      OCCA_F2C_GLOBAL_(occakernelinfoadddefine_fc    , OCCAKERNELINFOADDDEFINE_FC)
#define  OCCAKERNELINFOADDDEFINEINT4_FC  OCCA_F2C_GLOBAL_(occakernelinfoadddefineint4_fc, OCCAKERNELINFOADDDEFINEINT4_FC)
#define  OCCAKERNELINFOADDDEFINEREAL4_FC OCCA_F2C_GLOBAL_(occakernelinfoadddefinereal4_fc, OCCAKERNELINFOADDDEFINEREAL4_FC)
#define  OCCAKERNELINFOADDDEFINEREAL8_FC OCCA_F2C_GLOBAL_(occakernelinfoadddefinereal8_fc, OCCAKERNELINFOADDDEFINEREAL8_FC)
#define  OCCAKERNELINFOADDDEFINECHAR_FC  OCCA_F2C_GLOBAL_(occakernelinfoadddefinechar_fc, OCCAKERNELINFOADDDEFINECHAR_FC)
#define  OCCAKERNELINFOFREE_FC           OCCA_F2C_GLOBAL_(occakernelinfofree_fc         , OCCAKERNELINFOFREE_FC)
#define  OCCADEVICEWRAPMEMORY_FC         OCCA_F2C_GLOBAL_(occadevicewrapmemory_fc       , OCCADEVICEWRAPMEMORY_FC)
#define  OCCADEVICEWRAPSTREAM _FC        OCCA_F2C_GLOBAL_(occadevicewrapstream_fc       , OCCADEVICEWRAPSTREAM_FC)
#define  OCCAMEMORYMODE_FC               OCCA_F2C_GLOBAL_(occamemorymode_fc             , OCCAMEMORYMODE_FC)
#define  OCCACOPYMEMTOMEM_FC             OCCA_F2C_GLOBAL_(occacopymemtomem_fc           , OCCACOPYMEMTOMEM_FC)
#define  OCCACOPYMEMTOMEMAUTO_FC         OCCA_F2C_GLOBAL_(occacopymemtomemauto_fc       , OCCACOPYMEMTOMEMAUTO_FC)
#define  OCCACOPYPTRTOMEM_FC             OCCA_F2C_GLOBAL_(occacopyptrtomem_fc           , OCCACOPYPTRTOMEM_FC)
#define  OCCACOPYPTRTOMEMAUTO_FC         OCCA_F2C_GLOBAL_(occacopyptrtomemauto_fc       , OCCACOPYPTRTOMEMAUTO_FC)
#define  OCCACOPYMEMTOPTR_FC             OCCA_F2C_GLOBAL_(occacopymemtoptr_fc           , OCCACOPYMEMTOPTR_FC)
#define  OCCACOPYMEMTOPTRAUTO_FC         OCCA_F2C_GLOBAL_(occacopymemtoptrauto_fc       , OCCACOPYMEMTOPTRAUTO_FC)
#define  OCCAASYNCCOPYMEMTOMEM_FC        OCCA_F2C_GLOBAL_(occaasynccopymemtomem_fc      , OCCAASYNCCOPYMEMTOMEM_FC)
#define  OCCAASYNCCOPYMEMTOMEMAUTO_FC    OCCA_F2C_GLOBAL_(occaasynccopymemtomemauto_fc  , OCCAASYNCCOPYMEMTOMEMAUTO_FC)
#define  OCCAASYNCCOPYPTRTOMEM_FC        OCCA_F2C_GLOBAL_(occaasynccopyptrtomem_fc      , OCCAASYNCCOPYPTRTOMEM_FC)
#define  OCCAASYNCCOPYPTRTOMEMAUTO_FC    OCCA_F2C_GLOBAL_(occaasynccopyptrtomemauto_fc  , OCCAASYNCCOPYPTRTOMEMAUTO_FC)
#define  OCCAASYNCCOPYMEMTOPTR_FC        OCCA_F2C_GLOBAL_(occaasynccopymemtoptr_fc      , OCCAASYNCCOPYMEMTOPTR_FC)
#define  OCCAASYNCCOPYMEMTOPTRAUTO_FC    OCCA_F2C_GLOBAL_(occaasynccopymemtoptrauto_fc  , OCCAASYNCCOPYMEMTOPTRAUTO_FC)
#define  OCCAMEMORYSWAP_FC               OCCA_F2C_GLOBAL_(occamemoryswap_fc             , OCCAMEMORYSWAP_FC)
#define  OCCAMEMORYFREE_FC               OCCA_F2C_GLOBAL_(occamemoryfree_fc             , OCCAMEMORYFREE_FC)


#  ifdef __cplusplus
extern "C" {
#  endif


  //---[ TypeCasting ]------------------
  void OCCAINT32_FC(occaType *type, int32_t *value){
    if(sizeof(int) == 4)
      *type = occaInt(*value);
    else {<commit_msg>[Core] Updated Fortran, had wrong APi name<commit_after>#ifndef OCCA_FBASE_HEADER
#define OCCA_FBASE_HEADER

#include <stdint.h>
#include <stdio.h>
#include "occaCBase.hpp"

/*
 * The code related to fortran string handling was adapted from petsc.  The
 * license information for petsc can be found below.
 *
 *     Licensing Notification
 *
 *       Permission to use, reproduce, prepare derivative works, and to
 *       redistribute to others this software, derivatives of this software, and
 *       future versions of this software as well as its documentation is hereby
 *       granted, provided that this notice is retained thereon and on all
 *       copies or modifications. This permission is perpetual, world-wide, and
 *       provided on a royalty-free basis. UChicago Argonne, LLC and all other
 *       contributors make no representations as to the suitability and
 *       operability of this software for any purpose. It is provided "as is"
 *       without express or implied warranty.
 *
 *      Authors: http://www.mcs.anl.gov/petsc/miscellaneous/index.html
 *
 *
 *      - Mathematics and Computer Science Division
 *      - Argonne National Laboratory
 *      - Argonne IL 60439
 *
 *
 *       Portions of this software are copyright by UChicago Argonne, LLC.
 *       Argonne National Laboratory with facilities in the state of Illinois,
 *       is owned by The United States Government, and operated by UChicago
 *       Argonne, LLC under provision of a contract with the Department of
 *       Energy.
 *
 *     DISCLAIMER
 *
 *       PORTIONS OF THIS SOFTWARE WERE PREPARED AS AN ACCOUNT OF WORK SPONSORED
 *       BY AN AGENCY OF THE UNITED STATES GOVERNMENT. NEITHER THE UNITED STATES
 *       GOVERNMENT NOR ANY AGENCY THEREOF, NOR THE UNIVERSITY OF CHICAGO, NOR
 *       ANY OF THEIR EMPLOYEES OR OFFICERS, MAKES ANY WARRANTY, EXPRESS OR
 *       IMPLIED, OR ASSUMES ANY LEGAL LIABILITY OR RESPONSIBILITY FOR THE
 *       ACCURACY, COMPLETENESS, OR USEFULNESS OF ANY INFORMATION, APPARATUS,
 *       PRODUCT, OR PROCESS DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT
 *       INFRINGE PRIVATELY OWNED RIGHTS. REFERENCE HEREIN TO ANY SPECIFIC
 *       COMMERCIAL PRODUCT, PROCESS, OR SERVICE BY TRADE NAME, TRADEMARK,
 *       MANUFACTURER, OR OTHERWISE, DOES NOT NECESSARILY CONSTITUTE OR IMPLY
 *       ITS ENDORSEMENT, RECOMMENDATION, OR FAVORING BY THE UNITED STATES
 *       GOVERNMENT OR ANY AGENCY THEREOF. THE VIEW AND OPINIONS OF AUTHORS
 *       EXPRESSED HEREIN DO NOT NECESSARILY STATE OR REFLECT THOSE OF THE
 *       UNITED STATES GOVERNMENT OR ANY AGENCY THEREOF.
 *
 */

#include <stdlib.h>
#include <string.h>

#define OCCA_F2C_NULL_CHARACTER_Fortran ((char *) 0)

/* --------------------------------------------------------------------*/
/*
    This lets us map the str-len argument either, immediately following
    the char argument (DVF on Win32) or at the end of the argument list
    (general unix compilers)
*/
#if defined(OCCAF_HAVE_FORTRAN_MIXED_STR_ARG)
#define OCCA_F2C_LSTR(len) ,int len
#define OCCA_F2C_RSTR(len)
#else
#define OCCA_F2C_LSTR(len)
#define OCCA_F2C_RSTR(len)   ,int len
#endif

/* --------------------------------------------------------------------*/
#define OCCA_F2C_ALLOC_STR(a,n,b)               \
  do {                                          \
    if (a == OCCA_F2C_NULL_CHARACTER_Fortran) { \
      b = 0;                                    \
    } else {                                    \
      while((n > 0) && (a[n-1] == ' ')) n--;    \
      b = (char*)malloc((n+1)*sizeof(char));    \
      if(b==NULL) abort();                      \
      strncpy(b,a,n);                           \
      b[n] = '\0';                              \
    }                                           \
  } while (0)

#define OCCA_F2C_FREE_STR(a,b)                  \
  do {                                          \
    if (a != b) free(b);                        \
  } while (0)

#define OCCA_F2C_GLOBAL_(name,NAME) name##_

#define  OCCAINT_FC                      OCCA_F2C_GLOBAL_(occaint_fc                    , OCCAINT_FC)
#define  OCCAINT32_FC                    OCCA_F2C_GLOBAL_(occaint32_fc                  , OCCAINT32_FC)
#define  OCCAUINT_FC                     OCCA_F2C_GLOBAL_(occauint_fc                   , OCCAUINT_FC)
#define  OCCACHAR_FC                     OCCA_F2C_GLOBAL_(occachar_fc                   , OCCACHAR_FC)
#define  OCCAUCHAR_FC                    OCCA_F2C_GLOBAL_(occauchar_fc                  , OCCAUCHAR_FC)
#define  OCCASHORT_FC                    OCCA_F2C_GLOBAL_(occashort_fc                  , OCCASHORT_FC)
#define  OCCAUSHORT_FC                   OCCA_F2C_GLOBAL_(occaushort_fc                 , OCCAUSHORT_FC)
#define  OCCALONG_FC                     OCCA_F2C_GLOBAL_(occalong_fc                   , OCCALONG_FC)
#define  OCCAULONG_FC                    OCCA_F2C_GLOBAL_(occaulong_fc                  , OCCAULONG_FC)
#define  OCCAFLOAT_FC                    OCCA_F2C_GLOBAL_(occafloat_fc                  , OCCAFLOAT_FC)
#define  OCCADOUBLE_FC                   OCCA_F2C_GLOBAL_(occadouble_fc                 , OCCADOUBLE_FC)
#define  OCCASTRING_FC                   OCCA_F2C_GLOBAL_(occastring_fc                 , OCCASTRING_FC)
#define  OCCADEVICEMODE_FC               OCCA_F2C_GLOBAL_(occadevicemode_fc             , OCCADEVICEMODE_FC)
#define  OCCADEVICESETCOMPILER_FC        OCCA_F2C_GLOBAL_(occadevicesetcompiler_fc      , OCCADEVICESETCOMPILER_FC)
#define  OCCADEVICESETCOMPILERFLAGS_FC   OCCA_F2C_GLOBAL_(occadevicesetcompilerflags_fc , OCCADEVICESETCOMPILERFLAGS_FC)
#define  OCCAGETDEVICE_FC                OCCA_F2C_GLOBAL_(occagetdevice_fc              , OCCAGETDEVICE_FC)
#define  OCCAGETDEVICEFROMARGS_FC        OCCA_F2C_GLOBAL_(occagetdevicefromargs_fc      , OCCAGETDEVICEFROMARGS_FC)
#define  OCCABUILDKERNELFROMSOURCE_FC    OCCA_F2C_GLOBAL_(occabuildkernelfromsource_fc  , OCCABUILDKERNELFROMSOURCE_FC)
#define  OCCABUILDKERNELFROMSOURCENOKERNELINFO_FC    OCCA_F2C_GLOBAL_(occabuildkernelfromsourcenokernelinfo_fc  , OCCABUILDKERNELFROMSOURCENOKERNELINFO_FC)
#define  OCCABUILDKERNELFROMBINARY_FC    OCCA_F2C_GLOBAL_(occabuildkernelfrombinary_fc  , OCCABUILDKERNELFROMBINARY_FC)
#define  OCCABUILDKERNELFROMLOOPY_FC     OCCA_F2C_GLOBAL_(occabuildkernelfromloopy_fc   , OCCABUILDKERNELFROMLOOPY_FC)
#define  OCCABUILDKERNELFROMFLOOPY_FC    OCCA_F2C_GLOBAL_(occabuildkernelfromfloopy_fc  , OCCABUILDKERNELFROMFLOOPY_FC)
#define  OCCADEVICEMALLOCNULL_FC         OCCA_F2C_GLOBAL_(occadevicemallocnull_fc       , OCCADEVICEMALLOCNULL_FC)
#define  OCCADEVICEMALLOC_FC             OCCA_F2C_GLOBAL_(occadevicemalloc_fc           , OCCADEVICEMALLOC_FC)
#define  OCCADEVICEFLUSH_FC              OCCA_F2C_GLOBAL_(occadeviceflush_fc            , OCCADEVICEFLUSH_FC)
#define  OCCADEVICEFINISH_FC             OCCA_F2C_GLOBAL_(occadevicefinish_fc           , OCCADEVICEFINISH_FC)
#define  OCCADEVICEGENSTREAM_FC          OCCA_F2C_GLOBAL_(occadevicegenstream_fc        , OCCADEVICEGENSTREAM_FC)
#define  OCCADEVICEGETSTREAM_FC          OCCA_F2C_GLOBAL_(occadevicegetstream_fc        , OCCADEVICEGETSTREAM_FC)
#define  OCCADEVICESETSTREAM_FC          OCCA_F2C_GLOBAL_(occadevicesetstream_fc        , OCCADEVICESETSTREAM_FC)
#define  OCCADEVICETAGSTREAM_FC          OCCA_F2C_GLOBAL_(occadevicetagstream_fc        , OCCADEVICETAGSTREAM_FC)
#define  OCCADEVICETIMEBETWEENTAGS_FC    OCCA_F2C_GLOBAL_(occadevicetimebetweentags_fc  , OCCADEVICETIMEBETWEENTAGS_FC)
#define  OCCADEVICESTREAMFREE_FC         OCCA_F2C_GLOBAL_(occadevicestreamfree_fc       , OCCADEVICESTREAMFREE_FC)
#define  OCCADEVICEFREE_FC               OCCA_F2C_GLOBAL_(occadevicefree_fc             , OCCADEVICEFREE_FC)
#define  OCCAKERNELMODE_FC               OCCA_F2C_GLOBAL_(occakernelmode_fc             , OCCAKERNELMODE_FC)
#define  OCCAKERNELPREFERREDDIMSIZE_FC   OCCA_F2C_GLOBAL_(occakernelpreferreddimsize_fc , OCCAKERNELPREFERREDDIMSIZE_FC)
#define  OCCAKERNELSETWORKINGDIMS_FC     OCCA_F2C_GLOBAL_(occakernelsetworkingdims_fc   , OCCAKERNELSETWORKINGDIMS_FC)
#define  OCCAKERNELSETALLWORKINGDIMS_FC  OCCA_F2C_GLOBAL_(occakernelsetallworkingdims_fc, OCCAKERNELSETALLWORKINGDIMS_FC)
#define  OCCAKERNELTIMETAKEN_FC          OCCA_F2C_GLOBAL_(occakerneltimetaken_fc        , OCCAKERNELTIMETAKEN_FC)
#define  OCCAGENARGUMENTLIST_FC          OCCA_F2C_GLOBAL_(occagenargumentlist_fc        , OCCAGENARGUMENTLIST_FC)
#define  OCCAARGUMENTLISTCLEAR_FC        OCCA_F2C_GLOBAL_(occaargumentlistclear_fc      , OCCAARGUMENTLISTCLEAR_FC)
#define  OCCAARGUMENTLISTFREE_FC         OCCA_F2C_GLOBAL_(occaargumentlistfree_fc       , OCCAARGUMENTLISTFREE_FC)
#define  OCCAARGUMENTLISTADDARGMEM_FC    OCCA_F2C_GLOBAL_(occaargumentlistaddargmem_fc  , OCCAARGUMENTLISTADDARGMEM_FC)
#define  OCCAARGUMENTLISTADDARGTYPE_FC   OCCA_F2C_GLOBAL_(occaargumentlistaddargtype_fc , OCCAARGUMENTLISTADDARGTYPE_FC)
#define  OCCAARGUMENTLISTADDARGINT4_FC   OCCA_F2C_GLOBAL_(occaargumentlistaddargint4_fc , OCCAARGUMENTLISTADDARGINT4_FC)
#define  OCCAARGUMENTLISTADDARGREAL4_FC  OCCA_F2C_GLOBAL_(occaargumentlistaddargreal4_fc, OCCAARGUMENTLISTADDARGREAL4_FC)
#define  OCCAARGUMENTLISTADDARGREAL8_FC  OCCA_F2C_GLOBAL_(occaargumentlistaddargreal8_fc, OCCAARGUMENTLISTADDARGREAL8_FC)
#define  OCCAARGUMENTLISTADDARGCHAR_FC   OCCA_F2C_GLOBAL_(occaargumentlistaddargchar_fc , OCCAARGUMENTLISTADDARGCHAR_FC)
#define  OCCAKERNELRUN__FC               OCCA_F2C_GLOBAL_(occakernelrun__fc             , OCCAKERNELRUN__FC)
#define  OCCAKERNELRUN01_FC              OCCA_F2C_GLOBAL_(occakernelrun01_fc            , OCCAKERNELRUN01_FC)
#define  OCCAKERNELRUN02_FC              OCCA_F2C_GLOBAL_(occakernelrun02_fc            , OCCAKERNELRUN02_FC)
#define  OCCAKERNELRUN03_FC              OCCA_F2C_GLOBAL_(occakernelrun03_fc            , OCCAKERNELRUN03_FC)
#define  OCCAKERNELRUN04_FC              OCCA_F2C_GLOBAL_(occakernelrun04_fc            , OCCAKERNELRUN04_FC)
#define  OCCAKERNELRUN05_FC              OCCA_F2C_GLOBAL_(occakernelrun05_fc            , OCCAKERNELRUN05_FC)
#define  OCCAKERNELRUN06_FC              OCCA_F2C_GLOBAL_(occakernelrun06_fc            , OCCAKERNELRUN06_FC)
#define  OCCAKERNELRUN07_FC              OCCA_F2C_GLOBAL_(occakernelrun07_fc            , OCCAKERNELRUN07_FC)
#define  OCCAKERNELRUN08_FC              OCCA_F2C_GLOBAL_(occakernelrun08_fc            , OCCAKERNELRUN08_FC)
#define  OCCAKERNELRUN09_FC              OCCA_F2C_GLOBAL_(occakernelrun09_fc            , OCCAKERNELRUN09_FC)
#define  OCCAKERNELRUN10_FC              OCCA_F2C_GLOBAL_(occakernelrun10_fc            , OCCAKERNELRUN10_FC)
#define  OCCAKERNELRUN11_FC              OCCA_F2C_GLOBAL_(occakernelrun11_fc            , OCCAKERNELRUN11_FC)
#define  OCCAKERNELRUN12_FC              OCCA_F2C_GLOBAL_(occakernelrun12_fc            , OCCAKERNELRUN12_FC)
#define  OCCAKERNELRUN13_FC              OCCA_F2C_GLOBAL_(occakernelrun13_fc            , OCCAKERNELRUN13_FC)
#define  OCCAKERNELRUN14_FC              OCCA_F2C_GLOBAL_(occakernelrun14_fc            , OCCAKERNELRUN14_FC)
#define  OCCAKERNELRUN15_FC              OCCA_F2C_GLOBAL_(occakernelrun15_fc            , OCCAKERNELRUN15_FC)
#define  OCCAKERNELRUN16_FC              OCCA_F2C_GLOBAL_(occakernelrun16_fc            , OCCAKERNELRUN16_FC)
#define  OCCAKERNELRUN17_FC              OCCA_F2C_GLOBAL_(occakernelrun17_fc            , OCCAKERNELRUN17_FC)
#define  OCCAKERNELRUN18_FC              OCCA_F2C_GLOBAL_(occakernelrun18_fc            , OCCAKERNELRUN18_FC)
#define  OCCAKERNELRUN19_FC              OCCA_F2C_GLOBAL_(occakernelrun19_fc            , OCCAKERNELRUN19_FC)
#define  OCCAKERNELRUN20_FC              OCCA_F2C_GLOBAL_(occakernelrun20_fc            , OCCAKERNELRUN20_FC)
#define  OCCAKERNELRUN21_FC              OCCA_F2C_GLOBAL_(occakernelrun21_fc            , OCCAKERNELRUN21_FC)
#define  OCCAKERNELRUN22_FC              OCCA_F2C_GLOBAL_(occakernelrun22_fc            , OCCAKERNELRUN22_FC)
#define  OCCAKERNELRUN24_FC              OCCA_F2C_GLOBAL_(occakernelrun24_fc            , OCCAKERNELRUN24_FC)
#define  OCCAKERNELFREE_FC               OCCA_F2C_GLOBAL_(occakernelfree_fc             , OCCAKERNELFREE_FC)
#define  OCCAGENKERNELINFO_FC            OCCA_F2C_GLOBAL_(occagenkernelinfo_fc          , OCCAGENKERNELINFO_FC)
#define  OCCAKERNELINFOADDDEFINE_FC      OCCA_F2C_GLOBAL_(occakernelinfoadddefine_fc    , OCCAKERNELINFOADDDEFINE_FC)
#define  OCCAKERNELINFOADDDEFINEINT4_FC  OCCA_F2C_GLOBAL_(occakernelinfoadddefineint4_fc, OCCAKERNELINFOADDDEFINEINT4_FC)
#define  OCCAKERNELINFOADDDEFINEREAL4_FC OCCA_F2C_GLOBAL_(occakernelinfoadddefinereal4_fc, OCCAKERNELINFOADDDEFINEREAL4_FC)
#define  OCCAKERNELINFOADDDEFINEREAL8_FC OCCA_F2C_GLOBAL_(occakernelinfoadddefinereal8_fc, OCCAKERNELINFOADDDEFINEREAL8_FC)
#define  OCCAKERNELINFOADDDEFINECHAR_FC  OCCA_F2C_GLOBAL_(occakernelinfoadddefinechar_fc, OCCAKERNELINFOADDDEFINECHAR_FC)
#define  OCCAKERNELINFOFREE_FC           OCCA_F2C_GLOBAL_(occakernelinfofree_fc         , OCCAKERNELINFOFREE_FC)
#define  OCCADEVICEWRAPMEMORY_FC         OCCA_F2C_GLOBAL_(occadevicewrapmemory_fc       , OCCADEVICEWRAPMEMORY_FC)
#define  OCCADEVICEWRAPSTREAM_FC         OCCA_F2C_GLOBAL_(occadevicewrapstream_fc       , OCCADEVICEWRAPSTREAM_FC)
#define  OCCAMEMORYMODE_FC               OCCA_F2C_GLOBAL_(occamemorymode_fc             , OCCAMEMORYMODE_FC)
#define  OCCACOPYMEMTOMEM_FC             OCCA_F2C_GLOBAL_(occacopymemtomem_fc           , OCCACOPYMEMTOMEM_FC)
#define  OCCACOPYMEMTOMEMAUTO_FC         OCCA_F2C_GLOBAL_(occacopymemtomemauto_fc       , OCCACOPYMEMTOMEMAUTO_FC)
#define  OCCACOPYPTRTOMEM_FC             OCCA_F2C_GLOBAL_(occacopyptrtomem_fc           , OCCACOPYPTRTOMEM_FC)
#define  OCCACOPYPTRTOMEMAUTO_FC         OCCA_F2C_GLOBAL_(occacopyptrtomemauto_fc       , OCCACOPYPTRTOMEMAUTO_FC)
#define  OCCACOPYMEMTOPTR_FC             OCCA_F2C_GLOBAL_(occacopymemtoptr_fc           , OCCACOPYMEMTOPTR_FC)
#define  OCCACOPYMEMTOPTRAUTO_FC         OCCA_F2C_GLOBAL_(occacopymemtoptrauto_fc       , OCCACOPYMEMTOPTRAUTO_FC)
#define  OCCAASYNCCOPYMEMTOMEM_FC        OCCA_F2C_GLOBAL_(occaasynccopymemtomem_fc      , OCCAASYNCCOPYMEMTOMEM_FC)
#define  OCCAASYNCCOPYMEMTOMEMAUTO_FC    OCCA_F2C_GLOBAL_(occaasynccopymemtomemauto_fc  , OCCAASYNCCOPYMEMTOMEMAUTO_FC)
#define  OCCAASYNCCOPYPTRTOMEM_FC        OCCA_F2C_GLOBAL_(occaasynccopyptrtomem_fc      , OCCAASYNCCOPYPTRTOMEM_FC)
#define  OCCAASYNCCOPYPTRTOMEMAUTO_FC    OCCA_F2C_GLOBAL_(occaasynccopyptrtomemauto_fc  , OCCAASYNCCOPYPTRTOMEMAUTO_FC)
#define  OCCAASYNCCOPYMEMTOPTR_FC        OCCA_F2C_GLOBAL_(occaasynccopymemtoptr_fc      , OCCAASYNCCOPYMEMTOPTR_FC)
#define  OCCAASYNCCOPYMEMTOPTRAUTO_FC    OCCA_F2C_GLOBAL_(occaasynccopymemtoptrauto_fc  , OCCAASYNCCOPYMEMTOPTRAUTO_FC)
#define  OCCAMEMORYSWAP_FC               OCCA_F2C_GLOBAL_(occamemoryswap_fc             , OCCAMEMORYSWAP_FC)
#define  OCCAMEMORYFREE_FC               OCCA_F2C_GLOBAL_(occamemoryfree_fc             , OCCAMEMORYFREE_FC)


#  ifdef __cplusplus
extern "C" {
#  endif


  //---[ TypeCasting ]------------------
  void OCCAINT32_FC(occaType *type, int32_t *value){
    if(sizeof(int) == 4)
      *type = occaInt(*value);
    else {
{'fraction_non_alphanumeric': 0.05673265028681322, 'fraction_numerical': 0.01903246128850426, 'mean_word_length': 3.040187541862023, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3046132', 'n_tokens_mistral': 11610, 'n_tokens_neox': 11150, 'n_words': 1611}