/*
!===============================================================================
!
! ildg.h
!
!-------------------------------------------------------------------------------
!
! Copyright (C) 2007-2017 Hinnerk Stueben
!
! This file is part of BQCD -- Berlin Quantum ChromoDynamics program
!
! BQCD is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
!
! BQCD is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with BQCD.  If not, see <http://www.gnu.org/licenses/>.
!
!-------------------------------------------------------------------------------
*/

/* naming coventions for C function called from Fortran */

#ifdef NamesToLower
# define ILDG_OPEN_R ildg_open_r
# define ILDG_OPEN_W ildg_open_w
# define ILDG_READ   ildg_read
# define ILDG_WRITE  ildg_write
# define ILDG_CLOSE_R  ildg_close_r
# define ILDG_CLOSE_W  ildg_close_w
# define ILDG_READ_INFO ildg_read_info
# define ILDG_OPEN_W_LEMON ildg_open_w_lemon
# define ILDG_OPEN_R_LEMON ildg_open_r_lemon
# define ILDG_CLOSE_W_LEMON  ildg_close_w_lemon
# define ILDG_CLOSE_R_LEMON  ildg_close_r_lemon
# define ILDG_WRITE_LEMON  ildg_write_lemon
# define ILDG_READ_LEMON  ildg_read_lemon
# define QCDSF_U1_R qcdsf_u1_r
# define QCDSF_U1_W qcdsf_u1_w
# define ILDG_FIND_U1_BINARY_DATA ildg_find_u1_binary_data
# define QCDSF_AXION_R qcdsf_axion_r
# define QCDSF_AXION_W qcdsf_axion_w
# define ILDG_FIND_AXION_BINARY_DATA ildg_find_axion_binary_data
# define ILDG_LANDAU_R ildg_landau_r
# define ILDG_LANDAU_W ildg_landau_w
#endif

#ifdef NamesToLower_
# define ILDG_OPEN_R ildg_open_r_
# define ILDG_OPEN_W ildg_open_w_
# define ILDG_READ   ildg_read_
# define ILDG_WRITE  ildg_write_
# define ILDG_CLOSE_R  ildg_close_r_
# define ILDG_CLOSE_W  ildg_close_w_
# define ILDG_READ_INFO ildg_read_info_
# define ILDG_OPEN_W_LEMON ildg_open_w_lemon_
# define ILDG_OPEN_R_LEMON ildg_open_r_lemon_
# define ILDG_CLOSE_W_LEMON  ildg_close_w_lemon_
# define ILDG_CLOSE_R_LEMON  ildg_close_r_lemon_
# define ILDG_WRITE_LEMON  ildg_write_lemon_
# define ILDG_READ_LEMON  ildg_read_lemon_
# define QCDSF_U1_R qcdsf_u1_r_
# define QCDSF_U1_W qcdsf_u1_w_
# define ILDG_FIND_U1_BINARY_DATA ildg_find_u1_binary_data_
# define QCDSF_AXION_R qcdsf_axion_r_
# define QCDSF_AXION_W qcdsf_axion_w_
# define ILDG_FIND_AXION_BINARY_DATA ildg_find_axion_binary_data_
# define ILDG_LANDAU_R ildg_landau_r_
# define ILDG_LANDAU_W ildg_landau_w_
#endif

#ifdef NamesToLower__
# define ILDG_OPEN_R ildg_open_r__
# define ILDG_OPEN_W ildg_open_w__
# define ILDG_READ   ildg_read__
# define ILDG_WRITE  ildg_write__
# define ILDG_CLOSE_R  ildg_close_r__
# define ILDG_CLOSE_W  ildg_close_w__
# define ILDG_READ_INFO ildg_read_info__
# define ILDG_OPEN_W_LEMON ildg_open_w_lemon__
# define ILDG_OPEN_R_LEMON ildg_open_r_lemon__
# define ILDG_CLOSE_W_LEMON  ildg_close_w_lemon__
# define ILDG_CLOSE_R_LEMON  ildg_close_r_lemon__
# define ILDG_WRITE_LEMON  ildg_write_lemon__
# define ILDG_READ_LEMON  ildg_read_lemon__
# define QCDSF_U1_R qcdsf_u1_r__
# define QCDSF_U1_W qcdsf_u1_w__
# define ILDG_FIND_U1_BINARY_DATA ildg_find_u1_binary_data__
# define QCDSF_AXION_R qcdsf_axion_r__
# define QCDSF_AXION_W qcdsf_axion_w__
# define ILDG_FIND_AXION_BINARY_DATA ildg_find_axion_binary_data__
# define ILDG_LANDAU_R ildg_landau_r__
# define ILDG_LANDAU_W ildg_landau_w__
#endif


/* prototypes for those functions */

void ILDG_OPEN_R(char *filename,
		 int *Lx, int *Ly, int *Lz, int *Lt,
		 int *precision,
		 INT8 *bytes_total);
void ILDG_OPEN_W(char *filename,
		 int *Lx, int *Ly, int *Lz, int *Lt,
		 int *precision,
		 INT8 *bytes_total);
void ILDG_OPEN_R_LEMON(char *filename,
		 int *Lx, int *Ly, int *Lz, int *Lt,
		 int npe[4], int *precision,
		 INT8 *bytes_total);
void ILDG_OPEN_W_LEMON(char *filename,
		 int *Lx, int *Ly, int *Lz, int *Lt,
		 int npe[4], int *precision,
		 INT8 *bytes_total);
void QCSF_U1_R(  int *Lx, int *Ly, int *Lz, int *Lt,
		 int *precision,
		 INT8 *bytes_total);
void QCDSF_U1_W( int *Lx, int *Ly, int *Lz, int *Lt,
		 int *precision,
		 INT8 *bytes_total);
void QCSF_AXION_R(  int *Lx, int *Ly, int *Lz, int *Lt,
		 int *precision,
		 INT8 *bytes_total);
void QCDSF_AXION_W( int *Lx, int *Ly, int *Lz, int *Lt,
		 int *precision,
		 INT8 *bytes_total);


void ILDG_READ(void *buffer, INT8 *bytes);
void ILDG_WRITE(void *buffer, INT8 *bytes);
void ILDG_READ_LEMON(void *buffer,int L[4], int *vol, int *precision);
void ILDG_WRITE_LEMON(void *buffer,int L[4], int *vol, int *precision);
void ILDG_CLOSE_R(INT8 *cksum, INT8 *bytes_total, char *lfn, int *len);
void ILDG_CLOSE_W(INT8 *cksum, INT8 *bytes_total, char *lfn);
void ILDG_CLOSE_R_LEMON(INT8 *cksum, INT8 *bytes_total, char *lfn, int *len);
void ILDG_CLOSE_W_LEMON(INT8 *cksum, INT8 *bytes_total, char *lfn);
void ILDG_RESTART_INFO(char *filename);

void ILDG_FIND_U1_BINARY_DATA(void);
void ILDG_FIND_AXION_BINARY_DATA(void);

/* prototypes for C functions called from C */

int ildg_try_record(char *record);
void ildg_find_record(char *record);
void ildg_read_string(char *record, char *s, int len);
void ildg_find_record_lemon(char *record);
void ildg_read_string_lemon(char *record, char *s, int len);

/*===========================================================================*/
