diff --git a/spotpy/examples/hymod_unix/hymod_cython/hymod.pyx b/spotpy/examples/hymod_unix/hymod_cython/hymod.pyx index 1f5e7541..db53be61 100644 --- a/spotpy/examples/hymod_unix/hymod_cython/hymod.pyx +++ b/spotpy/examples/hymod_unix/hymod_cython/hymod.pyx @@ -89,7 +89,7 @@ def excess(x_loss,cmax,bexp,Pval,PETval): return ER1,ER2,xn -cdef public void hymod_run(): +cdef public void hymod_run(owd): if not hasattr(sys, 'argv'): sys.argv = [''] if len(sys.argv) != 6: @@ -102,7 +102,9 @@ cdef public void hymod_run(): x = sys.argv x.pop(0) - owd = os.path.dirname(os.path.realpath(__file__)) + # try to use path provided from cpp + # owd = os.path.dirname(os.path.realpath(__file__)) + hymod_path = owd + os.sep + 'hymod_input.csv' Precip, PET = [], [] diff --git a/spotpy/examples/hymod_unix/hymod_cython/main_hymod.cpp b/spotpy/examples/hymod_unix/hymod_cython/main_hymod.cpp index 75531f3e..b3748b13 100644 --- a/spotpy/examples/hymod_unix/hymod_cython/main_hymod.cpp +++ b/spotpy/examples/hymod_unix/hymod_cython/main_hymod.cpp @@ -1,6 +1,7 @@ #include #include "Python.h" #include "hymod.h" +#include int main(int argc, char *argv[]) { @@ -27,9 +28,22 @@ int main(int argc, char *argv[]) Py_Finalize(); return -1; //error } + + /*const std::filesystem::path owd; + std::filesystem::current_path(&owd); - hymod_run(); + getcwd(cwd, sizeof(cwd))*/ + + char cwd[256]; + if (getcwd(cwd, sizeof(cwd)) == NULL) + { + std::cout << "Error in getcwd" << std::endl; + Py_Finalize(); + return -2; //error + } + PyObject *py_cwd = Py_BuildValue("s", cwd); + hymod_run(py_cwd); Py_Finalize(); //Needed!