SebWouters / CheMPS2

CheMPS2: a spin-adapted implementation of DMRG for ab initio quantum chemistry
GNU General Public License v2.0
70 stars 34 forks source link

How to run the code #27

Closed Wangwei-Lan closed 8 years ago

Wangwei-Lan commented 8 years ago

Dear Dr. Sebastian,

I created a Hamiltonian (by just modify test10.cpp in the /build/tests/tests). Then I hope to run the DMRG calculation, however, I don't know how to run the code. Do I just modify the Makefile and then run make?

Do you have a project template for running the code? Thanks very much.

Best regards Wangwei

SebWouters commented 8 years ago

Hi Wangwei,

In principle you should modify the test

/tests/sometest.cpp.in

in order for cmake's makefiles to work (I think).

Another and better way is to install the library somewhere, and use your own test.cpp and your own makefile. So you copy for example

/build/tests/tests/sometest.cpp

to a folder outside of the chemps2 project, modify it, and compile it on the command line with, e.g.

icpc sometest.cpp -o mybin -I/usr/include/chemps2 -I/usr/include/hdf5/serial -L/usr/lib/x86_64-linux-gnu/ -lchemps2

You can then run the test by typing

./mybin

Please also take a look at http://sebwouters.github.io/CheMPS2/index.html sections 3 to 7 before you start.

--Seb

Wangwei-Lan commented 8 years ago

Thanks very much, Sebastian. I did read the tutorial section. However, I can't understand some part in the section. I will try to read the reference there in.

Wangwei

Wangwei-Lan commented 8 years ago

Hello, Sebastian,

I tried the way you mentioned above to compile the test1.cpp. The binary was created, but when I run it, nothing happens. It just not working, no errors shown anywhere. I also tried to copy all the tests and then use cmake and then make to build binary. The same thing happens, the binaries were created, but when I run it, nothing happens.

To test the linking, I have used ldd to the binary I created and the binary created when install chemps2, the linking libraries are all the same.

Specially for test10, an errors occurs like below,

* The MPI_Comm_rank() function was called before MPI_INIT was invoked. * This is disallowed by the MPI standard. *\ Your MPI job will now abort. Can you give me a hint why this is happening? Thanks very much.

Best regards Wangwei

SebWouters commented 8 years ago

You compiled the library with MPI:

-DWITH_MPI=ON

This implies the flag

-DCHEMPS2_MPI_COMPILATION

is passed to the compiler when creating the library. For the binary test file you should then

  1. Also use an MPI compiler ( mpicxx.mpich2 or mpicxx.openmpi or mpiicpc )
  2. Pass the flag -DCHEMPS2_MPI_COMPILATION to the MPI compiler when building the file.cpp or just place the following in the beginning of the file.cpp:

    define CHEMPS2_MPI_COMPILATION

Hope it helps! Best wishes, Sebastian

Wangwei-Lan commented 8 years ago

Thanks very much, Sebastian. The code does work now. Best regards Wangwei