Skip to content

Commit

Permalink
ENH: Add r283 in pywrapper and in library.
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Nov 25, 2023
1 parent 448083e commit a3a5556
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 13 deletions.
2 changes: 1 addition & 1 deletion example/example_in_c.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <string.h>
#include <stdio.h>
#include "iapws_g704.h"
#include "iapws.h"

int main(void){

Expand Down
2 changes: 1 addition & 1 deletion example/example_in_f.f90
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
program example_in_f
use iso_fortran_env
use iapws__g704
use iapws
implicit none
integer(int32) :: i, ngas
real(real64) :: T(1), kh(1), kd(1)
Expand Down
1 change: 1 addition & 0 deletions include/iapws.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
#ifndef IAPWS_H
#define IAPWS_H
#include "iapws_g704.h"
#include "iapws_r283.h"
#endif
4 changes: 2 additions & 2 deletions include/iapws_r283.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ extern const double iapws_r283_capi_Tc_D2O;
extern const double iapws_r283_capi_pc_H2O;
extern const double iapws_r283_capi_pc_D2O;

extern const double iapws_r283_rhoc_H2O;
extern const double iapws_r283_rhoc_D2O;
extern const double iapws_r283_capi_rhoc_H2O;
extern const double iapws_r283_capi_rhoc_D2O;

#endif
2 changes: 1 addition & 1 deletion pywrapper/pyiapws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Python wrapper of the (Modern Fortran) iapws library."""
from .version import *
from . import g704
from . import g704, r283
58 changes: 58 additions & 0 deletions pywrapper/pyiapws/iapws_r283.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <stdio.h>
#include <string.h>
#include "iapws_r283.h"

PyDoc_STRVAR(module_docstring, "C extension wrapping the iapws_r283 module of the Fortran iapws library.");


static PyMethodDef myMethods[] = {
{ NULL, NULL, 0, NULL }
};

// Our Module Definition struct
static struct PyModuleDef r283 = {
PyModuleDef_HEAD_INIT,
"r283",
module_docstring,
-1,
myMethods
};

// Initializes our module using our above struct
PyMODINIT_FUNC PyInit_r283(void)
{
PyObject *m;
PyObject *d;
PyObject *v;

m = PyModule_Create(&r283);
d = PyModule_GetDict(m);

v = PyFloat_FromDouble(iapws_r283_capi_Tc_H2O);
PyDict_SetItemString(d, "Tc_H2O", v);
Py_INCREF(v);
v = PyFloat_FromDouble(iapws_r283_capi_Tc_D2O);
PyDict_SetItemString(d, "Tc_D2O", v);
Py_INCREF(v);

v = PyFloat_FromDouble(iapws_r283_capi_pc_H2O);
PyDict_SetItemString(d, "pc_H2O", v);
Py_INCREF(v);
v = PyFloat_FromDouble(iapws_r283_capi_pc_D2O);
PyDict_SetItemString(d, "pc_D2O", v);
Py_INCREF(v);

v = PyFloat_FromDouble(iapws_r283_capi_rhoc_H2O);
PyDict_SetItemString(d, "rho_H2O", v);
Py_INCREF(v);
v = PyFloat_FromDouble(iapws_r283_capi_rhoc_D2O);
PyDict_SetItemString(d, "rho_D2O", v);
Py_INCREF(v);


return m;
}


6 changes: 6 additions & 0 deletions pywrapper/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects)
mod_ext = Extension(name="pyiapws.r283",
sources=["./pyiapws/iapws_r283.c"],
libraries=libraries,
library_dirs=library_dirs,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects)

setup(ext_modules=[mod_ext])

3 changes: 2 additions & 1 deletion src/iapws.f90
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
module iapws
!! Main module for the IAPWS library.
use iapws__g704
use iapws__r797
use iapws__g704_capi
use iapws__r283
use iapws__r283_capi


end module
14 changes: 7 additions & 7 deletions src/iapws_r283_capi.f90
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ module iapws__r283_capi

real(c_double), protected, bind(C, name="iapws_r283_capi_Tc_H2O") &
:: iapws_r283_capi_Tc_H2O = iapws_r283_Tc_H2O
real(c_double), protected, bind(C, name="iapws_r283_capi_Tc_H2O") &
real(c_double), protected, bind(C, name="iapws_r283_capi_Tc_D2O") &
:: iapws_r283_capi_Tc_D2O = iapws_r283_Tc_D2O

real(c_double), protected, bind(C, name="iapws_r283_pc_H2O") &
real(c_double), protected, bind(C, name="iapws_r283_capi_pc_H2O") &
:: iapws_r283_capi_pc_H2O = iapws_r283_pc_H2O
real(c_double), protected, bind(C, name="iapws_r283_pc_D2O") &
real(c_double), protected, bind(C, name="iapws_r283_capi_pc_D2O") &
:: iapws_r283_capi_pc_D2O = iapws_r283_pc_D2O

real(c_double), protected, bind(C, name="iapws_r283_rhoc_H2O") &
:: iapws_r283_rhoc_H2O = iapws_r283_rhoc_H2O
real(c_double), protected, bind(C, name="iapws_r283_rhoc_D2O") &
:: iapws_r283_rhoc_D2O = iapws_r283_rhoc_D2O
real(c_double), protected, bind(C, name="iapws_r283_capi_rhoc_H2O") &
:: iapws_r283_capi_rhoc_H2O = iapws_r283_rhoc_H2O
real(c_double), protected, bind(C, name="iapws_r283_capi_rhoc_D2O") &
:: iapws_r283_capi_rhoc_D2O = iapws_r283_rhoc_D2O


end module

0 comments on commit a3a5556

Please sign in to comment.