From 3543571f4b053c8140c57f2e626cec90cd77bc71 Mon Sep 17 00:00:00 2001 From: Garrett Barter Date: Fri, 19 Jan 2024 13:47:07 -0700 Subject: [PATCH 1/2] need to generate f2py sources each time --- pyhams/meson.build | 65 ++++--- pyhams/src/_hams-f2pywrappers2.f90 | 12 -- pyhams/src/_hams.pyf | 28 +++ pyhams/src/_hamsmodule.c | 273 ----------------------------- 4 files changed, 60 insertions(+), 318 deletions(-) delete mode 100644 pyhams/src/_hams-f2pywrappers2.f90 create mode 100644 pyhams/src/_hams.pyf delete mode 100644 pyhams/src/_hamsmodule.c diff --git a/pyhams/meson.build b/pyhams/meson.build index a567087..28280fa 100644 --- a/pyhams/meson.build +++ b/pyhams/meson.build @@ -23,43 +23,42 @@ fortranobject_c = incdir_f2py / 'fortranobject.c' inc_np = include_directories(incdir_numpy, incdir_f2py) -#hams_connect = custom_target('_hamsmodule.c', -# input : ['src/HAMS_Prog.f90'], -# output : ['_hamsmodule.c', '_hams-f2pywrappers2.f90'], -# command: [py3, '-m', 'numpy.f2py', -# '@INPUT@', '-m', '_hams', '--lower', -# '--build-dir', 'pyhams'] -# ) +hams_connect = custom_target('_hamsmodule.c', + input : ['src/_hams.pyf'], + output : ['_hamsmodule.c', '_hams-f2pywrappers2.f90'], + command: [py3, '-m', 'numpy.f2py', + '@INPUT@', '--lower', '--build-dir', 'pyhams'] + ) + +hams_sources = ['src/WavDynMods.f90', + 'src/PatclVelct.f90', + 'src/BodyIntgr.f90', + 'src/BodyIntgr_irr.f90', + 'src/AssbMatx.f90', + 'src/AssbMatx_irr.f90', + 'src/SingularIntgr.f90', + 'src/InfGreen_Appr.f90', + 'src/FinGrnExtSubs.f90', + 'src/FinGreen3D.f90', + 'src/CalGreenFunc.f90', + 'src/HydroStatic.f90', + 'src/ImplementSubs.f90', + 'src/InputFiles.f90', + 'src/NormalProcess.f90', + 'src/ReadPanelMesh.f90', + 'src/PotentWavForce.f90', + 'src/PressureElevation.f90', + 'src/PrintOutput.f90', + 'src/SolveMotion.f90', + 'src/WavDynSubs.f90', + 'src/HAMS_Prog.f90', + ] # Source order is important for dependencies py3.extension_module('_hams', - ['src/WavDynMods.f90', - 'src/PatclVelct.f90', - 'src/BodyIntgr.f90', - 'src/BodyIntgr_irr.f90', - 'src/AssbMatx.f90', - 'src/AssbMatx_irr.f90', - 'src/SingularIntgr.f90', - 'src/InfGreen_Appr.f90', - 'src/FinGrnExtSubs.f90', - 'src/FinGreen3D.f90', - 'src/CalGreenFunc.f90', - 'src/HydroStatic.f90', - 'src/ImplementSubs.f90', - 'src/InputFiles.f90', - 'src/NormalProcess.f90', - 'src/ReadPanelMesh.f90', - 'src/PotentWavForce.f90', - 'src/PressureElevation.f90', - 'src/PrintOutput.f90', - 'src/SolveMotion.f90', - 'src/WavDynSubs.f90', - 'src/HAMS_Prog.f90', - 'src/_hams-f2pywrappers2.f90', - 'src/_hamsmodule.c', + hams_sources, + hams_connect, fortranobject_c, - ], - #hams_connect, include_directories: inc_np, dependencies : [py3_dep, lapack, omp], subdir: 'pyhams', diff --git a/pyhams/src/_hams-f2pywrappers2.f90 b/pyhams/src/_hams-f2pywrappers2.f90 deleted file mode 100644 index fad01a4..0000000 --- a/pyhams/src/_hams-f2pywrappers2.f90 +++ /dev/null @@ -1,12 +0,0 @@ -! -*- f90 -*- -! This file is autogenerated with f2py (version:1.26.2) -! It contains Fortran 90 wrappers to fortran functions. - - - subroutine f2pyinithams_full(f2pysetupfunc) - use hams_full, only : exec - external f2pysetupfunc - call f2pysetupfunc(exec) - end subroutine f2pyinithams_full - - diff --git a/pyhams/src/_hams.pyf b/pyhams/src/_hams.pyf new file mode 100644 index 0000000..a20b5aa --- /dev/null +++ b/pyhams/src/_hams.pyf @@ -0,0 +1,28 @@ +! -*- f90 -*- +! Note: the context of this file is case sensitive. + +python module _hams ! in + interface ! in :_hams + module hams_full ! in :_hams:HAMS_Prog.f90 + use assbmatx + use assbmatx_irr + use calgreenfunc + use readpanelmesh + use linearmatrix_mod + use hydrostatic + use implementsubs + use potentwavforce + use printoutput + use potentials_mod + use pressureelevation + use fieldoutput_mod + use omp_lib + subroutine exec ! in :_hams:HAMS_Prog.f90:hams_full + end subroutine exec + end module hams_full + end interface +end python module _hams + +! This file was auto-generated with f2py (version:1.26.2). +! See: +! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e diff --git a/pyhams/src/_hamsmodule.c b/pyhams/src/_hamsmodule.c deleted file mode 100644 index 0d32744..0000000 --- a/pyhams/src/_hamsmodule.c +++ /dev/null @@ -1,273 +0,0 @@ -/* File: _hamsmodule.c - * This file is auto-generated with f2py (version:1.26.2). - * f2py is a Fortran to Python Interface Generator (FPIG), Second Edition, - * written by Pearu Peterson . - * Generation date: Mon Jan 8 04:40:53 2024 - * Do not edit this file directly unless you know what you are doing!!! - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef PY_SSIZE_T_CLEAN -#define PY_SSIZE_T_CLEAN -#endif /* PY_SSIZE_T_CLEAN */ - -/* Unconditionally included */ -#include -#include - -/*********************** See f2py2e/cfuncs.py: includes ***********************/ -#include "fortranobject.h" -/*need_includes0*/ - -/**************** See f2py2e/rules.py: mod_rules['modulebody'] ****************/ -static PyObject *_hams_error; -static PyObject *_hams_module; - -/*********************** See f2py2e/cfuncs.py: typedefs ***********************/ -/*need_typedefs*/ - -/****************** See f2py2e/cfuncs.py: typedefs_generated ******************/ -/*need_typedefs_generated*/ - -/********************** See f2py2e/cfuncs.py: cppmacros **********************/ -#ifdef DEBUGCFUNCS -#define CFUNCSMESS(mess) fprintf(stderr,"debug-capi:"mess); -#define CFUNCSMESSPY(mess,obj) CFUNCSMESS(mess) \ - PyObject_Print((PyObject *)obj,stderr,Py_PRINT_RAW);\ - fprintf(stderr,"\n"); -#else -#define CFUNCSMESS(mess) -#define CFUNCSMESSPY(mess,obj) -#endif - -#ifndef max -#define max(a,b) ((a > b) ? (a) : (b)) -#endif -#ifndef min -#define min(a,b) ((a < b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a,b) ((a > b) ? (a) : (b)) -#endif -#ifndef MIN -#define MIN(a,b) ((a < b) ? (a) : (b)) -#endif - -#if defined(PREPEND_FORTRAN) -#if defined(NO_APPEND_FORTRAN) -#if defined(UPPERCASE_FORTRAN) -#define F_FUNC(f,F) _##F -#else -#define F_FUNC(f,F) _##f -#endif -#else -#if defined(UPPERCASE_FORTRAN) -#define F_FUNC(f,F) _##F##_ -#else -#define F_FUNC(f,F) _##f##_ -#endif -#endif -#else -#if defined(NO_APPEND_FORTRAN) -#if defined(UPPERCASE_FORTRAN) -#define F_FUNC(f,F) F -#else -#define F_FUNC(f,F) f -#endif -#else -#if defined(UPPERCASE_FORTRAN) -#define F_FUNC(f,F) F##_ -#else -#define F_FUNC(f,F) f##_ -#endif -#endif -#endif -#if defined(UNDERSCORE_G77) -#define F_FUNC_US(f,F) F_FUNC(f##_,F##_) -#else -#define F_FUNC_US(f,F) F_FUNC(f,F) -#endif - - -/************************ See f2py2e/cfuncs.py: cfuncs ************************/ -/*need_cfuncs*/ - -/********************* See f2py2e/cfuncs.py: userincludes *********************/ -/*need_userincludes*/ - -/********************* See f2py2e/capi_rules.py: usercode *********************/ - - -/* See f2py2e/rules.py */ -/*eof externroutines*/ - -/******************** See f2py2e/capi_rules.py: usercode1 ********************/ - - -/******************* See f2py2e/cb_rules.py: buildcallback *******************/ -/*need_callbacks*/ - -/*********************** See f2py2e/rules.py: buildapi ***********************/ - -/************************************ exec ************************************/ -static char doc_f2py_rout__hams_hams_full_exec[] = "\ -exec()\n\nWrapper for ``exec``.\ -\n"; -/* */ -static PyObject *f2py_rout__hams_hams_full_exec(const PyObject *capi_self, - PyObject *capi_args, - PyObject *capi_keywds, - void (*f2py_func)(void)) { - PyObject * volatile capi_buildvalue = NULL; - volatile int f2py_success = 1; -/*decl*/ - - static char *capi_kwlist[] = {NULL}; - -/*routdebugenter*/ -#ifdef F2PY_REPORT_ATEXIT -f2py_start_clock(); -#endif - if (!PyArg_ParseTupleAndKeywords(capi_args,capi_keywds,\ - "|:_hams.hams_full.exec",\ - capi_kwlist)) - return NULL; -/*frompyobj*/ -/*end of frompyobj*/ -#ifdef F2PY_REPORT_ATEXIT -f2py_start_call_clock(); -#endif -/*callfortranroutine*/ - (*f2py_func)(); -if (PyErr_Occurred()) - f2py_success = 0; -#ifdef F2PY_REPORT_ATEXIT -f2py_stop_call_clock(); -#endif -/*end of callfortranroutine*/ - if (f2py_success) { -/*pyobjfrom*/ -/*end of pyobjfrom*/ - CFUNCSMESS("Building return value.\n"); - capi_buildvalue = Py_BuildValue(""); -/*closepyobjfrom*/ -/*end of closepyobjfrom*/ - } /*if (f2py_success) after callfortranroutine*/ -/*cleanupfrompyobj*/ -/*end of cleanupfrompyobj*/ - if (capi_buildvalue == NULL) { -/*routdebugfailure*/ - } else { -/*routdebugleave*/ - } - CFUNCSMESS("Freeing memory.\n"); -/*freemem*/ -#ifdef F2PY_REPORT_ATEXIT -f2py_stop_clock(); -#endif - return capi_buildvalue; -} -/******************************** end of exec ********************************/ -/*eof body*/ - -/******************* See f2py2e/f90mod_rules.py: buildhooks *******************/ - -static FortranDataDef f2py_hams_full_def[] = { - {"exec",-1,{{-1}},0,0,NULL,(void *)f2py_rout__hams_hams_full_exec,doc_f2py_rout__hams_hams_full_exec}, - {NULL} -}; - -static void f2py_setup_hams_full(char *exec) { - int i_f2py=0; - f2py_hams_full_def[i_f2py++].data = exec; -} -extern void F_FUNC_US(f2pyinithams_full,F2PYINITHAMS_FULL)(void (*)(char *)); -static void f2py_init_hams_full(void) { - F_FUNC_US(f2pyinithams_full,F2PYINITHAMS_FULL)(f2py_setup_hams_full); -} - -/*need_f90modhooks*/ - -/************** See f2py2e/rules.py: module_rules['modulebody'] **************/ - -/******************* See f2py2e/common_rules.py: buildhooks *******************/ - -/*need_commonhooks*/ - -/**************************** See f2py2e/rules.py ****************************/ - -static FortranDataDef f2py_routine_defs[] = { - -/*eof routine_defs*/ - {NULL} -}; - -static PyMethodDef f2py_module_methods[] = { - - {NULL,NULL} -}; - -static struct PyModuleDef moduledef = { - PyModuleDef_HEAD_INIT, - "_hams", - NULL, - -1, - f2py_module_methods, - NULL, - NULL, - NULL, - NULL -}; - -PyMODINIT_FUNC PyInit__hams(void) { - int i; - PyObject *m,*d, *s, *tmp; - m = _hams_module = PyModule_Create(&moduledef); - Py_SET_TYPE(&PyFortran_Type, &PyType_Type); - import_array(); - if (PyErr_Occurred()) - {PyErr_SetString(PyExc_ImportError, "can't initialize module _hams (failed to import numpy)"); return m;} - d = PyModule_GetDict(m); - s = PyUnicode_FromString("1.26.2"); - PyDict_SetItemString(d, "__version__", s); - Py_DECREF(s); - s = PyUnicode_FromString( - "This module '_hams' is auto-generated with f2py (version:1.26.2).\nFunctions:\n" -"Fortran 90/95 modules:\n"" hams_full --- exec()""."); - PyDict_SetItemString(d, "__doc__", s); - Py_DECREF(s); - s = PyUnicode_FromString("1.26.2"); - PyDict_SetItemString(d, "__f2py_numpy_version__", s); - Py_DECREF(s); - _hams_error = PyErr_NewException ("_hams.error", NULL, NULL); - /* - * Store the error object inside the dict, so that it could get deallocated. - * (in practice, this is a module, so it likely will not and cannot.) - */ - PyDict_SetItemString(d, "__hams_error", _hams_error); - Py_DECREF(_hams_error); - for(i=0;f2py_routine_defs[i].name!=NULL;i++) { - tmp = PyFortranObject_NewAsAttr(&f2py_routine_defs[i]); - PyDict_SetItemString(d, f2py_routine_defs[i].name, tmp); - Py_DECREF(tmp); - } - -/*eof initf2pywraphooks*/ - PyDict_SetItemString(d, "hams_full", PyFortranObject_New(f2py_hams_full_def,f2py_init_hams_full)); -/*eof initf90modhooks*/ - -/*eof initcommonhooks*/ - - -#ifdef F2PY_REPORT_ATEXIT - if (! PyErr_Occurred()) - on_exit(f2py_report_on_exit,(void*)"_hams"); -#endif - return m; -} -#ifdef __cplusplus -} -#endif From 0f6d46364301c8dfce54bc5d605b89376f951cc5 Mon Sep 17 00:00:00 2001 From: Garrett Barter Date: Fri, 19 Jan 2024 14:04:23 -0700 Subject: [PATCH 2/2] prep for next release --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2c30d10..7aa83bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = ["meson-python", "meson>=1.1", "numpy", "ninja", "wheel"] [project] name = "pyHAMS" -version = "1.2.5" +version = "1.2.6" description = "Python module wrapping around HAMS" readme = "README.md" requires-python = ">=3.9"