#ifndef FORTRAN_H
#define FORTRAN_H

//-----------------------------------------------------------------------------
//
//  Peter Richter (prichter@princeton.edu)
//  Princeton Plasma Physics Laboratory
//  August 2000
//
//  fortran.h - Macros, prototypes, etc. for F77/C++ mixed programming.
//
//-----------------------------------------------------------------------------

#include "fpreproc/f77name.h"
#include "preact/util.h"

#define subroutine                extern "C" void
#define integer_function          extern "C" int
#define real_function             extern "C" fp_64

typedef int   integer;
typedef fp_64 real_8;

// initialize aladdin file...
subroutine F77NAME(sigalad_z)();

// compute sigma and vrel...
real_function F77NAME(sigall_z)(real_8& erel, real_8& vrel);

// compute sigma*v (impurity cross sections)
real_function F77NAME(sigv_zstop)(real_8& erel, integer& Zplas, integer& Zimp);

// compute sigma*v (electron impact, vs. Te)
real_function F77NAME(elec_sigv)(real_8& te, integer& icode);

// set kreact variable...
subroutine F77NAME(sigprep_z)(integer& ireact);

// set key variable...
subroutine F77NAME(setkey_z)(integer& ikey);

// compute integral tables...
subroutine F77NAME(comptabl_z)(real_8 *vtr, real_8 *mtx, real_8 *dom1,
			       real_8 *dom2, integer& n1, integer& n2,
			       integer& ier);

// do linear interpolation...
subroutine F77NAME(flin1_z)(real_8 *x, real_8 *f, integer& n, real_8 *vtr,
			    real_8& xmin, real_8& xmax, real_8& xlr,
			    integer& nx, integer& iwarn);

// do bilinear interpolation...
subroutine F77NAME(flint_z)(real_8 *x, real_8 *y, real_8 *f, integer& n,
			    real_8 *mtx, real_8& xmin, real_8& xmax,
			    real_8& xlr, integer& nx, real_8& ymin,
			    real_8& ymax, real_8& ylr, integer& ny,
			    integer& iwarn);

// exit with status code after error...
subroutine F77NAME(bad_exit)();

// MPI env var translation

subroutine F77NAME(cmpi_sget_env)(const char* name_in, char* value_out,
                                  integer* ierr);
//-----------------------------------------------------------------------------

#endif
