Closed jtwhite79 closed 1 year ago
I've just put in a dimvar_c.f90 to get these constants from the DLL, e.g.
from ctypes import c_int
from pypestutils.finder import load
lib = load()
c_int.in_dll(lib, "LENMESSAGE_").value # 1500
Oh, I just noticed the develop
branch. I should probably put these efforts in that branch instead!
Update: I've put main
back to what it was before, and new stuff will go in develop
. I've added and updated src
using prep_src_dir.py
. Everything builds without too much issue. Also, I've renamed the Windows version of the library from "libpestutils.dll" (or "libppu.dll") to "pestutils.dll", which is often a Windows convention (to not have a "lib" name prefix), e.g. MSVC does this by default. I'm able to cross-compile these Windows DLLs from my Linux laptop too, so the library is looking in good shape.
awesome - I think we can rely on the constants defined in the lib then
Oh, I should mention that I've renamed these without underscore, same as the Fortran side. And I've limited them down to just LENFILENAME
, LENMESSAGE
, LENGRIDNAME
, since the others are not used on the C/Python side.
@mwtoews Ive got the latest code going on the newly created develop branch. I patched those implied do loops and seems to be working...also, if you are interested, the way I was getting the error message string was with this function: https://github.com/pypest/pypestutils/blob/798e488c390b2e80d0c19ae7fe5b77c85e5e1780/pypestutils/utils.py#L31
I was thinking, can we dynamically get the allocated max string lengths from the library at runtime? On the fortran side, they are defined statically here:
https://github.com/pypest/pypestutils/blob/develop/org_from_john_7aug2023/dimvar.f90
Maybe we could create some simple fortran functions that just return the value of these constants then use them dynamically on the python side?