Skip to content

Commit

Permalink
copy header files into cython
Browse files Browse the repository at this point in the history
  • Loading branch information
AWehrhahn committed Jun 8, 2021
1 parent 791a14f commit 1e2ba5a
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 2 deletions.
41 changes: 41 additions & 0 deletions cython/sme_python_bridge.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef IDL_DEFINE
#define IDL_DEFINE
// Define IDL String
typedef int IDL_STRING_SLEN_T;
#define IDL_STRING_MAX_SLEN 2147483647

typedef struct { /* Define string descriptor */
IDL_STRING_SLEN_T slen; /* Length of string, 0 for null */
short stype; /* type of string, static or dynamic */
char *s; /* Addr of string */
} IDL_STRING;
#endif

// define the external methods
const char * Python_SMELibraryVersion(); /* Return SME library version */
const char * Python_GetDataFiles(); /* Return the required data files */
const char * Python_GetLibraryPath(); /* Return the current data file directory */
const char * Python_SetLibraryPath(IDL_STRING * path); /* Set the data file directory */
const char * Python_InputWaveRange(double wmin, double wmax); /* Read in Wavelength range */
const char * Python_SetVWscale(double gamma6); /* Set van der Waals scaling factor */
const char * Python_SetH2broad(); /* Set flag for H2 molecule */
const char * Python_ClearH2broad(); /* Clear flag for H2 molecule */
const char * Python_InputLineList(int nlines, IDL_STRING * species, double * atomic); /* Read in line list */
const char * Python_OutputLineList(int nlines, double * atomic); /* Return line list */
const char * Python_UpdateLineList(short nlines, IDL_STRING * species, double * atomic, short * index); /* Change line list parameters */
const char * Python_InputModel(short ndepth, double teff, double grav, double wlstd, IDL_STRING * motype, short * opflag, double * depth, double * temp, double * xne, double * xna, double * rho, double * vt, double radius, double * height); /* Read in model atmosphere */
const char * Python_InputDepartureCoefficients(double * bmat, int lineindex);
const char * Python_GetDepartureCoefficients(double * bmat, int nrhox, int line); /* Get NLTE b's for specific line */
const char * Python_GetNLTEflags(short * nlte_flags, int nlines); /* Get line list NLTE flags */
const char * Python_ResetDepartureCoefficients(); /* Reset LTE */
const char * Python_InputAbund(double * abund); /* Read in abundances */
const char * Python_Opacity(); /* Calculate opacities */
const char * Python_GetOpacity(short ifop, short length, double * result, IDL_STRING * species, IDL_STRING * key); /* Returns specific cont. opacity */
const char * Python_Ionization(short ion); /* Perfrom EOS calculations */
const char * Python_GetDensity(short length, double * result); /* Returns density in g/cm^3 */
const char * Python_GetNatom(short length, double * result); /* Returns atomic number density */
const char * Python_GetNelec(short length, double * result); /* Returns electron number density */
const char * Python_Transf(short nmu, double * mu, double * cint_seg, double * cintr_seg, int nwmax, int nw, double * wint_seg, double * sint_seg, double accrt, double accwi, short keep_lineop, short long_continuum); /* Computes spectral synthesis */
const char * Python_CentralDepth(int nmu, double * mu, int nwsize, float * table, double accrt); /* Computes line central depths */
const char * Python_GetLineOpacity(double wave, short nrhox, double * lop, double * cop, double * scr, double * tsf, double * csf); /* Returns specific line opacity */
const char * Python_GetLineRange(double * linerange, int nlines); /* Get validity range for every line */
66 changes: 66 additions & 0 deletions cython/sme_synth_faster.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

#ifdef BUILDING_SME_WIN_DLL
#define SME_DLL __declspec(dllexport)
#else
#define SME_DLL
#endif

// The SME library version (and compilation date)
#ifndef VERSION
#define VERSION "6.03, July 2019"
#endif

/* Datafile locations */
// DATA_DIR is defined in platform.h

#define DATAFILE_FE "Fe1_Bautista2017.dat.INTEL"
#define DATAFILE_NH "NH_Stancil2018.dat.INTEL"
#define DATAFILE_STEHLE "stehle_long.dat.INTEL"
#define DATAFILE_BPO "bpo_self.grid.INTEL"
#define DATAFILE_VCS "vcsbalmer.dat"

#ifndef IDL_DEFINE
#define IDL_DEFINE
// Define IDL String
typedef int IDL_STRING_SLEN_T;
#define IDL_STRING_MAX_SLEN 2147483647

typedef struct { /* Define string descriptor */
IDL_STRING_SLEN_T slen; /* Length of string, 0 for null */
short stype; /* type of string, static or dynamic */
char *s; /* Addr of string */
} IDL_STRING;
#endif
// define global parameter access
extern "C" int SME_DLL GetNLINES(void);
extern "C" short SME_DLL GetNRHOX(void);
extern "C" char * SME_DLL GetSPNAME(void);

// define the external methods
extern "C" const char * SME_DLL SMELibraryVersion(int n, void *arg[]); /* Return SME library version */
extern "C" const char * SME_DLL GetDataFiles(int n, void *arg[]); /* Return the required data files */
extern "C" const char * SME_DLL GetLibraryPath(int n, void *arg[]); /* Return the current data file directory */
extern "C" const char * SME_DLL SetLibraryPath(int n, void *arg[]); /* Set the data file directory */
extern "C" const char * SME_DLL InputWaveRange(int n, void *arg[]); /* Read in Wavelength range */
extern "C" const char * SME_DLL SetVWscale(int n, void *arg[]); /* Set van der Waals scaling factor */
extern "C" const char * SME_DLL SetH2broad(int n, void *arg[]); /* Set flag for H2 molecule */
extern "C" const char * SME_DLL ClearH2broad(int n, void *arg[]); /* Clear flag for H2 molecule */
extern "C" const char * SME_DLL InputLineList(int n, void *arg[]); /* Read in line list */
extern "C" const char * SME_DLL OutputLineList(int n, void *arg[]); /* Return line list */
extern "C" const char * SME_DLL UpdateLineList(int n, void *arg[]); /* Change line list parameters */
extern "C" const char * SME_DLL InputModel(int n, void *arg[]); /* Read in model atmosphere */
extern "C" const char * SME_DLL InputDepartureCoefficients(int n, void *arg[]);
extern "C" const char * SME_DLL GetDepartureCoefficients(int n, void *arg[]); /* Get NLTE b's for specific line */
extern "C" const char * SME_DLL GetNLTEflags(int n, void *arg[]); /* Get line list NLTE flags */
extern "C" const char * SME_DLL ResetDepartureCoefficients(int n, void *arg[]); /* Reset LTE */
extern "C" const char * SME_DLL InputAbund(int n, void *arg[]); /* Read in abundances */
extern "C" const char * SME_DLL Opacity(int n, void *arg[]); /* Calculate opacities */
extern "C" const char * SME_DLL GetOpacity(int n, void *arg[]); /* Returns specific cont. opacity */
extern "C" const char * SME_DLL Ionization(int n, void *arg[]); /* Perfrom EOS calculations */
extern "C" const char * SME_DLL GetDensity(int n, void *arg[]); /* Returns density in g/cm^3 */
extern "C" const char * SME_DLL GetNatom(int n, void *arg[]); /* Returns atomic number density */
extern "C" const char * SME_DLL GetNelec(int n, void *arg[]); /* Returns electron number density */
extern "C" const char * SME_DLL Transf(int n, void *arg[]); /* Computes spectral synthesis */
extern "C" const char * SME_DLL CentralDepth(int n, void *arg[]); /* Computes line central depths */
extern "C" const char * SME_DLL GetLineOpacity(int n, void *arg[]); /* Returns specific line opacity */
extern "C" const char * SME_DLL GetLineRange(int n, void *arg[]); /* Get validity range for every line */
4 changes: 2 additions & 2 deletions cython/smelib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ctypedef short np_short_t
ctypedef float np_float_t
ctypedef long np_long_t

cdef extern from "../src/sme/sme_python_bridge.h":
cdef extern from "sme_python_bridge.h":
cdef struct s_IDL_STRING:
int slen
short stype
Expand Down Expand Up @@ -56,7 +56,7 @@ cdef extern from "../src/sme/sme_python_bridge.h":
const char * Python_GetLineOpacity(double wave, short nmu, double * lop, double * cop, double * scr, double * tsf, double * csf)
const char * Python_GetLineRange(double * linerange, int nlines)

cdef extern from "../src/sme/sme_synth_faster.h":
cdef extern from "sme_synth_faster.h":
int GetNLINES()
short GetNRHOX()
char * GetSPNAME()
Expand Down

0 comments on commit 1e2ba5a

Please sign in to comment.