stochasticHydroTools / SlenderBody

Slender-body hydrodynamics
11 stars 4 forks source link

Improve dependencies and building process. #2

Closed ruinianxu closed 2 years ago

ruinianxu commented 2 years ago

@omaxian Hi Ondrej,

I firstly started with Examples/BundleStress.py which gave me the error

  File "BundleStress.py", line 15, in <module>
    from DoubleEndedCrossLinkedNetwork import DoubleEndedCrossLinkedNetwork
  File "/home/ruinian/Person/Project2/SlenderBody_own/Python/Examples/../DoubleEndedCrossLinkedNetwork.py", line 6, in <module>
    from EndedCrossLinkedNetwork import EndedCrossLinkedNetwork
ImportError: libFortranHeap.so: cannot open shared object file: No such file or directory

I doubt this is caused by the makefile for compiling C++ files since EndedCrossLinkedNetwork can't find libFortranHeap. The original makefile in the folder of cppmodules involves the absolute path e.g., /home/ondrejmaxian and I simply changed it to my own. Really appreciate it if you could provide me with some hints.

Best, Ruinian Xu

omaxian commented 2 years ago

I don't know why that's happening for you. The makefile in the cppmodules folder has a command to compile the fortran. Obviously it is not doing that on your end for some reason. It is this line: https://github.com/stochasticHydroTools/SlenderBody/blob/045492bca5c784a3f07e4bd9a5ea9bb1e0f303f6/Python/cppmodules/makefile#L16 of the makefile.

Try compiling the fortran by itself, and then making sure that libFortranHeap.so lives in the right folder.

ruinianxu commented 2 years ago

This is my modified makefile

all: RPYKernelEvaluator FiberCollection DomainC CrossLinkForceEvaluator EndedCrossLinking

DomainC:
    c++ -O3 -Wall -shared DomainC.cpp -o DomainC.so -std=c++11 -fPIC -fopenmp -llapack -lblas -llapacke  `python3 -m pybind11 --includes`

RPYKernelEvaluator: 
    c++ -O3 -Wall -shared RPYKernelEvaluator.cpp -o RPYKernelEvaluator.so -std=c++11 -fPIC -fopenmp -llapack -lblas -llapacke `python3 -m pybind11 --includes`

FiberCollection: 
    c++ -O3 -Wall -shared FiberCollection.cpp -o FiberCollection.so -llapack -lblas -llapacke -std=c++11 -fPIC -fopenmp `python3 -m pybind11 --includes` 

CrossLinkForceEvaluator: 
    c++ -O3 -Wall -shared CrossLinkForceEvaluator.cpp -o CrossLinkForceEvaluator.so -std=c++11 -fPIC -fopenmp -llapack -lblas -llapacke `python3 -m pybind11 --includes`

EndedCrossLinking:
    gfortran -shared -O3 ../../Fortran/MinHeapModule.f90 -o /home/ruinian/lib/libFortranHeap.so -fPIC
    c++ -O3 -Wall -shared EndedCrossLinkers.cpp -o EndedCrossLinkedNetwork.so \
        -L/home/ruinian/lib/ -lFortranHeap -std=c++11 -fPIC -fopenmp -llapack -lblas -llapacke `python3 -m pybind11 --includes`

clean:
    rm *.so

The only difference is that I changed ondrejmaxian to ruinian and I've confirmed that libFortranHeap.so lives in the right place.

Nothing special popped out during the compilation,

c++ -O3 -Wall -shared RPYKernelEvaluator.cpp -o RPYKernelEvaluator.so -std=c++11 -fPIC -fopenmp -llapack -lblas -llapacke `python3 -m pybind11 --includes`
In file included from DomainC.cpp:5:0,
                 from RPYKernelEvaluator.cpp:6:
VectorMethods.cpp: In function ‘void plus(const vec&, double, const vec&, double, vec&)’:
VectorMethods.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i < a.size(); i++){
                   ~~^~~~~~~~~~
c++ -O3 -Wall -shared FiberCollection.cpp -o FiberCollection.so -llapack -lblas -llapacke -std=c++11 -fPIC -fopenmp `python3 -m pybind11 --includes` 
In file included from SpecialQuadratures.cpp:7:0,
                 from FiberCollection.cpp:9:
VectorMethods.cpp: In function ‘void plus(const vec&, double, const vec&, double, vec&)’:
VectorMethods.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i < a.size(); i++){
                   ~~^~~~~~~~~~
In file included from SpecialQuadratures.cpp:8:0,
                 from FiberCollection.cpp:9:
Chebyshev.cpp: In function ‘void IntegrateCoefficients(const vec&, int, double, vec&)’:
Chebyshev.cpp:82:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j=0; j < intcoefs.size(); j++){
                   ~~^~~~~~~~~~~~~~~~~
In file included from FiberCollection.cpp:9:0:
SpecialQuadratures.cpp: In function ‘complex rootfinder_initial_guess(const vec&, const vec&, const vec3&)’:
SpecialQuadratures.cpp:63:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<nodes.size(); i++) {
                   ~^~~~~~~~~~~~~
SpecialQuadratures.cpp:85:41: warning: ‘imin2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         p[d] = Points[3*i1+d] - Points[3*i2+d];
                                        ~^~~
SpecialQuadratures.cpp:85:24: warning: ‘imin1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         p[d] = Points[3*i1+d] - Points[3*i2+d];
                       ~^~~
c++ -O3 -Wall -shared DomainC.cpp -o DomainC.so -std=c++11 -fPIC -fopenmp -llapack -lblas -llapacke  `python3 -m pybind11 --includes`
In file included from DomainC.cpp:5:0:
VectorMethods.cpp: In function ‘void plus(const vec&, double, const vec&, double, vec&)’:
VectorMethods.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i < a.size(); i++){
                   ~~^~~~~~~~~~
c++ -O3 -Wall -shared CrossLinkForceEvaluator.cpp -o CrossLinkForceEvaluator.so -std=c++11 -fPIC -fopenmp -llapack -lblas -llapacke `python3 -m pybind11 --includes`
In file included from CrossLinkForceEvaluator.cpp:9:0:
Chebyshev.cpp: In function ‘void IntegrateCoefficients(const vec&, int, double, vec&)’:
Chebyshev.cpp:82:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int j=0; j < intcoefs.size(); j++){
                   ~~^~~~~~~~~~~~~~~~~
In file included from CrossLinkForceEvaluator.cpp:10:0:
VectorMethods.cpp: In function ‘void plus(const vec&, double, const vec&, double, vec&)’:
VectorMethods.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i < a.size(); i++){
                   ~~^~~~~~~~~~
CrossLinkForceEvaluator.cpp: In constructor ‘CrossLinkForceEvaluator::CrossLinkForceEvaluator(vec, intvec, intvec, vec, vec, vec, double, double, int)’:
CrossLinkForceEvaluator.cpp:47:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int i = 0; i < _NCheb.size(); i++){
                         ~~^~~~~~~~~~~~~~~
CrossLinkForceEvaluator.cpp: In member function ‘pybind11::array CrossLinkForceEvaluator::calcCLForces(const intvec&, const intvec&, npDoub, npDoub, npDoub)’:
CrossLinkForceEvaluator.cpp:82:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int iL=0; iL < iPts.size(); iL++){
                        ~~~^~~~~~~~~~~~~
CrossLinkForceEvaluator.cpp: In member function ‘double CrossLinkForceEvaluator::calcCLStress(const intvec&, const intvec&, npDoub, npDoub, npDoub)’:
CrossLinkForceEvaluator.cpp:164:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int iL=0; iL < iPts.size(); iL++){
                        ~~~^~~~~~~~~~~~~
gfortran -shared -O3 ../../Fortran/MinHeapModule.f90 -o /home/ruinian/lib/libFortranHeap.so -fPIC
c++ -O3 -Wall -shared EndedCrossLinkers.cpp -o EndedCrossLinkedNetwork.so \
    -L/home/ruinian/lib/ -lFortranHeap -std=c++11 -fPIC -fopenmp -llapack -lblas -llapacke `python3 -m pybind11 --includes`
In file included from DomainC.cpp:5:0,
                 from EndedCrossLinkers.cpp:8:
VectorMethods.cpp: In function ‘void plus(const vec&, double, const vec&, double, vec&)’:
VectorMethods.cpp:22:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i < a.size(); i++){
                   ~~^~~~~~~~~~
EndedCrossLinkers.cpp: In member function ‘void EndedCrossLinkedNetwork::deleteLinksFromSites(npInt)’:
EndedCrossLinkers.cpp:292:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int iSite = 0; iSite < SitesToDelete.size(); iSite++){
                                 ~~~~~~^~~~~~~~~~~~~~~~~~~~~~
EndedCrossLinkers.cpp:302:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int iSite = 0; iSite < SitesToDelete.size(); iSite++){
                             ~~~~~~^~~~~~~~~~~~~~~~~~~~~~

Since there is nothing wrong during the compilation, I doubted there might be something wrong with searching path when importing EndedCrossLinkedNetwork. Then I tried to add /home/ruinian/lib to PYTHONPATH but EndedCrossLinkedNetwork still can't find libFortranHeap.so. Not sure what happened. Please let me know if you have thoughts. Thanks so much!

omaxian commented 2 years ago

I would start by cd'ing into the folder where libFortranHeap.so is, and running python in interactive session in that folder. Make sure you can import it then. Then you know there is some linking problem.

ruinianxu commented 2 years ago

@omaxian When I tried to import libFortranHeap under the folder, it pops out the erorr

ImportError: dynamic module does not define module export function (PyInit_libFortranHeap)

I am not familiar with gfortran. Could you please give me some hints about it? Does it relate to the version of gfortran?

Thanks!

ruinianxu commented 2 years ago

@omaxian I did some searches and found someone says it is because .so file is linked against Python2 instead of Python3. I am using conda environment and have no Python2 installed. I am not sure if this is really the cause. Really appreciate it if you could share me with some thoughts.

ruinianxu commented 2 years ago

@omaxian The error is addressed. I need to append the path of libFortranHeap.so to LD_LIBRARY_PATH.

ruinianxu commented 2 years ago

@omaxian

  File "BundleStress.py", line 73, in <module>
    Ewald = GPUEwaldSplitter(allFibers.getaRPY()*eps*Lf,mu,xi*1.4*(fibDisc.getNumDirect()/N)**(1/3),Dom,NupsampleForDirect*nFib);
  File "/home/ruinian/Person/Project2/SlenderBody_own/Python/Examples/../RPYVelocityEvaluator.py", line 305, in __init__
    self._GPUParams = uammd.PSEParameters(psi=self._xi, viscosity=self._mu, hydrodynamicRadius=self._a, tolerance=GPUtol, \
AttributeError: module 'uammd' has no attribute 'PSEParameters'

Is there a specific version/branch of uammd I need to intsall?

RaulPPelaez commented 2 years ago

Thanks for bringing these issues into our attention. Thanks for taking the time and sorry for all the trouble! We will try to improve the compilation process. This project uses UAMMD via this repository: https://github.com/RaulPPelaez/UAMMD_PSE_Python The Makefile there will output a file called uammd.*.so, which is the file the python script is trying to import.

ruinianxu commented 2 years ago

@RaulPPelaez I add something wrong with mkl and noticed that it says

You can replace  intel's MKL by lapacke and cblas by removing -DUSE_MKL (in the include flags above) and linking with that instead

Then I modified Makefile into


UAMMD_ROOT=uammd/
PYBIND_ROOT=pybind11/
PYTHON=python3
NVCC=nvcc

#In case you prefer to import with other name
MODULE_NAME=uammd
LIBRARY_NAME:=$(MODULE_NAME)$(shell $(PYTHON)-config --extension-suffix)

#UAMMD can be quite verbose, 5 shows only some messages at initialization/exit, 0 will only print critical errors, 15will print A LOT.
VERBOSITY=0
#Uncomment for double precision, UAMMD is compiled in single by default
#DOUBLEPRECISION=-DDOUBLE_PRECISION
INCLUDE_FLAGS_GPU= -I$(UAMMD_ROOT)/src -I$(UAMMD_ROOT)/src/third_party -I$(MKLROOT)/include -L$(MKLROOT)/lib/intel64 #-DUSE_MKL

INCLUDE_FLAGS= `$(PYTHON)-config --includes` -I $(PYBIND_ROOT)/include/

#You can replace  intel's MKL by lapacke and cblas by removing -DUSE_MKL (in the include flags above) and linking with that instead
LDFLAGS_GPU= -L/usr/lib64 -lcufft -lcublas -lmkl_rt -lpthread -ldl

GPU_OPTIMIZATION= -O3
CPU_OPTIMIZATION= -O3

PYTHON_WRAPPER_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

all: $(LIBRARY_NAME) example

uammd_wrapper.o: $(PYTHON_WRAPPER_DIR)/uammd_wrapper.cu $(PYTHON_WRAPPER_DIR)/uammd_interface.h 
    $(NVCC) -w -std=c++14 -DMAXLOGLEVEL=$(VERBOSITY) $(GPU_OPTIMIZATION) $(DOUBLEPRECISION) $(INCLUDE_FLAGS_GPU) $(LDFLAGS_GPU) $(GPU_DEBUG) -Xcompiler "-fPIC -w" -c $< -o $@

uammd_python.o: $(PYTHON_WRAPPER_DIR)/uammd_python.cpp $(PYTHON_WRAPPER_DIR)/uammd_interface.h
    $(CXX) -std=c++14 -O3 $(DOUBLEPRECISION) $(CPU_DEBUG) $(CPU_OPTIMIZATION) -fPIC -w $(INCLUDE_FLAGS) -c $< -o $@

$(LIBRARY_NAME): uammd_wrapper.o uammd_python.o
    $(NVCC) $(DOUBLEPRECISION) $(GPU_OPTIMIZATION) $(GPU_DEBUG) -w -shared $^ -o $@ $(LDFLAGS_GPU)

example: example.cpp uammd_wrapper.o
    $(NVCC) $(DOUBLEPRECISION) $(GPU_OPTIMIZATION) $(GPU_DEBUG) $^ -o $@ $(LDFLAGS_GPU)
clean:
    rm -f $(LIBRARY_NAME) uammd_python.o uammd_wrapper.o example

I have nothing wrong for compilation but got the following error when I try to run example scripts in the readme:

AttributeError: module 'uammd' has no attribute 'Box'

I am not sure where the issue is. Could you give me some hints? Thanks!

RaulPPelaez commented 2 years ago

This project must have used a previous commit of my repo, sadly I have no idea which one. I think it is easier for you to fix the error here: https://github.com/stochasticHydroTools/SlenderBody/blob/87ac31a35b991fa093dbcaca8977233a4c33862f/Python/RPYVelocityEvaluator.py#L306 I replaced this "box" parameter at some point by Lx, Ly, Lz in my repo: https://github.com/RaulPPelaez/UAMMD_PSE_Python/blob/4872caa9e38998c1a7cbf4b305865fbefabb2526/example.py#L9

So I suggest you replace line 306 here by this:

Lx=self._PerLengths[0],Ly=self._PerLengths[1],Lz=self._PerLengths[2]);

I think you almost got it now.

PD: I am working with the maintainer of this repo to include the dependencies as submodules so these issues does not arise in the future. Thank you very much for your efforts!

RaulPPelaez commented 2 years ago

You will have to do the same thing in this line: https://github.com/stochasticHydroTools/SlenderBody/blob/87ac31a35b991fa093dbcaca8977233a4c33862f/Python/RPYVelocityEvaluator.py#L348

ruinianxu commented 2 years ago

@RaulPPelaez Thank you so much for your quick reply. I am almost there but there is one more error we need to conquer

Traceback (most recent call last):
  File "BundleStress.py", line 90, in <module>
    maxX, _, StressArray = TIntegrator.updateAllFibers(iT,dt,stopcount,Dom,Ewald,grav/Lf,write=1,outfile=of,stress=True);
  File "/home/ruinian/Person/Project2/SlenderBody_own/Python/Examples/../TemporalIntegrator.py", line 164, in updateAllFibers
    RHS = self._allFibers.formBlockDiagRHS(XforNL,XsforNL,tvalSolve,forceExt,lamStar,Dom,Ewald);
  File "/home/ruinian/Person/Project2/SlenderBody_own/Python/Examples/../fiberCollection.py", line 198, in formBlockDiagRHS
    nonLocal = self.nonLocalVelocity(X_nonLoc,Xs_nonLoc,totForce,Dom,RPYEval,1-FPimplicit);
  File "/home/ruinian/Person/Project2/SlenderBody_own/Python/Examples/../fiberCollection.py", line 328, in nonLocalVelocity
    RPYVelocityUp = RPYEval.calcBlobTotalVel(self._Xupsampled,forcesUp,Dom,self._SpatialDirectQuad,self._nThreads);
  File "/home/ruinian/Person/Project2/SlenderBody_own/Python/Examples/../RPYVelocityEvaluator.py", line 339, in calcBlobTotalVel
    self._GPUEwald.Mdot(positions, forcesR, self._currentDomain.getg(), MF)
AttributeError: 'uammd.UAMMD' object has no attribute 'Mdot'

Please let me know how I need to modify RPYVelocityEvaluator.py. Thanks.

ruinianxu commented 2 years ago

@omaxian @RaulPPelaez Sorry for keeping bothering you. I've been stuck in this problem for a while. Could you please give me some hints? Many thanks!

omaxian commented 2 years ago

Ruinian,

I just updated this repo with the dependencies properly accounted for. You should be able to git pull, then cd python make This will make all the dependencies. You also need to add this to your .bashrc file (I need to see if I can do this in the makefile or not) export PYTHONPATH=${PYTHONPATH}:/home/ondrejmaxian/Documents/SLENDER_FIBERS/SlenderBody/Python/Dependencies/BatchedNBodyRPY export PYTHONPATH=${PYTHONPATH}:/home/ondrejmaxian/Documents/SLENDER_FIBERS/SlenderBody/Python/Dependencies/UAMMD_PSE_Python export PYTHONPATH=${PYTHONPATH}:/home/ondrejmaxian/Documents/SLENDER_FIBERS/SlenderBody/Python/Dependencies/NeighborSearch export PYTHONPATH=${PYTHONPATH}:/home/ondrejmaxian/Documents/SLENDER_FIBERS/SlenderBody/Python/Dependencies

This will bring in all the dependencies when you run python.

You should now be able to run all of the examples. Let me know if you have any issues with this reorganization.

RaulPPelaez commented 2 years ago

@omaxian , Check the PYTHONPATH you provided, since it includes things like your personal home folder.

You do not want to use "/home/ondrejmaxian/Documents/SLENDER_FIBERS/SlenderBody" rather some variable named smth like SLENDER_ROOT=/path/to/root/of/slenderBody.

If you want to put this in the Makefile, create an "install" rule that adds these PYTHONPATH extensions to .bashrc. Although this is a bit finicky, so I would simply document it in the README: -The folders X,Y and Z need to be present in the Pythonpath

For instance:

$ git clone --recuvsive https://github.com/stochasticHydroTools/SlenderBody
$ cd SlenderBody
$ (cd Python && make)
$ export SLENDER_ROOT=$(pwd)
$ export SLENDER_PYTHON=$SLENDER_ROOT/Python/Dependencies
$ export PYTHONPATH=$SLENDER_PYTHON/BatchedNBodyRPY:$SLENDER_PYTHON/UAMMD_PSE_Python:$SLENDER_PYTHON/NeighborSearch:$SLENDER_PYTHON/:$PYTHONPATH  

Or you can place this in a script that puts this information in .bashrc. For instance, put the following script in the root of SlenderBody: ---Contents of SlenderBody/install.sh---

set -e #End script if any command fails
(cd Python && make)
#Check if slender is already present:
if grep "SLENDER_PYTHON" ~/.bashrc; then echo "Slender body already present in bashrc"; exit 0; fi
#If SLENDER_PYTHON is not present in bashrc append these lines to it
cat <<EOF >> ~/.bashrc
export SLENDER_ROOT=$(pwd)
export SLENDER_PYTHON=\$SLENDER_ROOT/Python/Dependencies
export PYTHONPATH=\$SLENDER_PYTHON/BatchedNBodyRPY:\$SLENDER_PYTHON/UAMMD_PSE_Python:\$SLENDER_PYTHON/NeighborSearch:\$SLENDER_PYTHON/:\$PYTHONPATH
EOF

Now the whole process can be:

$ git clone --recuvsive https://github.com/stochasticHydroTools/SlenderBody
$ cd SlenderBody
$ bash install.sh

And this script will fail if make was not successful.

RaulPPelaez commented 2 years ago

BTW @omaxian , there is no Makefile in the Python folder currently, and the finufft submodule is broken (you will get an empty folder if you clone the repo)

omaxian commented 2 years ago

@RaulPPelaez Great ideas - thank you Raul!

One more thing I could use your help on. In the C++ makefile: https://github.com/stochasticHydroTools/SlenderBody/blob/master/Python/cppmodules/makefile I have my home directory coded in to the fortran compilation. How would I define that as a variable so it is done automatically?

RaulPPelaez commented 2 years ago

Since the relative directory of the root of the project does not change you can define this: https://github.com/stochasticHydroTools/SlenderBody/blob/9a6907916b16a0332b8ba63037f6f3fab11c3949/Python/cppmodules/makefile#L12

I modified the makefile to build the fortran module into the same folder as the rest of the objects. Also, in order to avoid having another folder in the path for that shared library, since you do not really need a shared library for this module I just compiled it to an object (.o): https://github.com/stochasticHydroTools/SlenderBody/blob/9a6907916b16a0332b8ba63037f6f3fab11c3949/Python/cppmodules/makefile#L19-L20 In this way you link the fortran object as part of the EndedCrossLiniking shared library: https://github.com/stochasticHydroTools/SlenderBody/blob/9a6907916b16a0332b8ba63037f6f3fab11c3949/Python/cppmodules/makefile#L16-L17

This also permits not modifying the LD_LIBRARY_PATH at all (I also modified the install script and README accordingly). This works at least in my computer.

RaulPPelaez commented 2 years ago

@ruinianxu I believe you should be set now, let us know if you find some issues with the current version. You should be able to reclone the repo:

git clone  --recursive

and then running

bash install.sh

The compilation is most likely to fail because of the same reasons the first time you tried (lapacke folders and the like), so you will have to modify that again. Once you manage to fix any compilation issues and the install.sh script finishes successfully, you should be able to run the example scripts. Remember to run:

source ~/.bashrc

Or open a new terminal for the changes made by install.sh to take effect.

omaxian commented 2 years ago

@RaulPPelaez Did you try opening python and running import EndedCrossLinking That did not work for me. It gave me a fortran error.

I put up a new commit where I reverted to the old makefile. Make sure whatever changes you make you can run python FixedDynamicLinkNetwork.py 1 1 1 in the folder Python/Examples. That is a good test for everything.

ruinianxu commented 2 years ago

@RaulPPelaez I can successfully run BundleStress right now. Many thanks!

RaulPPelaez commented 2 years ago

@RaulPPelaez Did you try opening python and running import EndedCrossLinking That did not work for me. It gave me a fortran error.

@omaxian, what was the Fortran error? In my commit, I got the following error when running that line:

ImportError: dynamic module does not define module export function (PyInit_EndedCrossLinking)

This is not a Fortran error, but is related with the name of the .so being incorrect. It should be EndedCrossLinkedNetwork, which you fixed in your latest commit.

After changing that no error is produced. I commited the fix. But let me know if you still see an error, please do post it.

RaulPPelaez commented 2 years ago

@RaulPPelaez I can successfully run BundleStress right now. Many thanks!

Perfect! Let us know if something goes wrong.

RaulPPelaez commented 2 years ago

Make sure whatever changes you make you can run python FixedDynamicLinkNetwork.py 1 1 1 in the folder Python/Examples. That is a good test for everything.

@omaxian, when running that line I get a bunch of warnings like "np.dot() is faster than blablabla" Then, after a while I get the following error:

Traceback (most recent call last):
  File "SlenderBody/Python/Examples/FixedDynamicLinkNetwork.py", line 30, in <module>
    copyInput = open(InputCopyName,'w')
FileNotFoundError: [Errno 2] No such file or directory: 'BundlingBehavior/FixedNetInputFile_BundlingN32SBT1ImpFP1_1.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "SlenderBody/Python/Examples/FixedDynamicLinkNetwork.py", line 41, in <module>
    raise ValueError('This file takes three command line arguments: the seed (for CL network),\
ValueError: This file takes three command line arguments: the seed (for CL network),whether to do the finite part implicitly (0 or 1), and whether to use RPY mobility (0 or 1), in that order

Maybe there should be some txt file in the Examples folder that went missing? I do not understand the raised exception, since to me the code in the try block: https://github.com/stochasticHydroTools/SlenderBody/blob/9226b23c45b669102839dfae579346434d58d18a/Python/Examples/FixedDynamicLinkNetwork.py#L25-L39 does not appear to be reading argv.

EDIT: On second look I see that the FixedNetworkInputFile.txt contains code that is being exec() in that block (evil). I suggest you treat this line more carefully, since it can fail for absolutely any reason, not just the user forgetting to read argv in the txt file. For instance, leave only the exec() line inside the try catch block.

I do not understand where this error comes from, but it does not look like a build issue.

omaxian commented 2 years ago

@RaulPPelaez ,

2 comments: 1) For the fortran compilation, I am getting this error when I run the makefile and try to import the module import EndedCrossLinkedNetwork Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: /home/ondrejmaxian/Documents/SLENDER_FIBERS/SlenderBody/Python/cppmodules/EndedCrossLinkedNetwork.so: undefined symbol: _gfortran_transfer_integer_write 2) For your error, the program is trying to write output to a file (actually it is copying the input file into another file). I think you need a directory called BundlingBehavior to write the output. Try creating that directory inside the examples folder. If that works I should probably push an empty folder called BundlingBehavior or modify the input file somehow.

RaulPPelaez commented 2 years ago

@omaxian

1. For the fortran compilation, I am getting this error when I run the makefile and try to import the module
   `import EndedCrossLinkedNetwork Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: /home/ondrejmaxian/Documents/SLENDER_FIBERS/SlenderBody/Python/cppmodules/EndedCrossLinkedNetwork.so: undefined symbol: _gfortran_transfer_integer_write `

It is possible you need to add -lgfortran to the list of libraries for the linker here: https://github.com/stochasticHydroTools/SlenderBody/blob/9226b23c45b669102839dfae579346434d58d18a/Python/cppmodules/makefile#L6 For instance my machine links with gfortran automatically when linking with liblapacke and libcblas. But not when using MKL. Please check and add it if that is indeed the case.

RaulPPelaez commented 2 years ago
2. For your error, the program is trying to write output to a file (actually it is copying the input file into another file). I think you need a directory called BundlingBehavior to write the output. Try creating that directory inside the examples folder. If that works I should probably push an empty folder called BundlingBehavior or modify the input file somehow.

This fixes the error. Instead of creating an empty folder, I suggest that the python script creates it as necessary with something like:

if not os.path.exists('BundlingBehavior'):
    os.makedirs('BundlingBehavior')
omaxian commented 2 years ago

@RaulPPelaez Yes, it was the -lgfortran flag. Thank you for that. I think we are finished now! Except for the lingering FINUFFT issue. That will take some time but I will get to it. Thanks a lot for your help.