libAtoms / QUIP

libAtoms/QUIP molecular dynamics framework: https://libatoms.github.io
347 stars 122 forks source link

Problem with linking ScaLAPACK during QUIP library compilation #604

Open Fu-Shengjie opened 1 year ago

Fu-Shengjie commented 1 year ago

I'm trying to compile QUIP as a library with GAP potential (also gap_fit), which needs to use the ScaLAPACK package. However, ScaLAPACK can't be found during the compilation process. I'm running on Red Hat Enterprise Linux Server release 7.7 using gfortran, part of gcc version 8.2.0, and OpenMPI version 4.0.3.

Here are the steps I've followed:

  1. Cloned the QUIP repository from GitHub.
  2. Set the environment variable with export QUIP_ARCH=linux_x86_64_gfortran.
  3. Ran make config.
  4. Encountered an error message saying "cannot find -lscalapack" during the make config step.

To troubleshoot, I tried installing Scalapack manually. However, I'm unsure how to link the libscalapack.a file during QUIP's compilation process.

I would appreciate any guidance on how to properly link Scalapack during the compilation process.

During my "make config" my option were as follow: image image The error message was: image

jameskermode commented 1 year ago

You need to add a -L option before -lscalapack giving the full path to the location of libscalapack.a, e.g. -L/usr/local/lib -lscalapack if it's located in /usr/local/lib.

Fu-Shengjie commented 1 year ago

Thank you for your previous assistance. After adding the -L option with the path to libscalapack.a, I was able to successfully complete the make config step without any errors. My "make config" option was as follow:

image image

However, when I moved on to the make libquip step, I encountered a new error:

image

Any further guidance would be much appreciated.

bernstei commented 1 year ago

What compiler version are you using?

Fu-Shengjie commented 1 year ago

I am using gcc version 8.2.0, and OpenMPI version 4.0.3.

bernstei commented 1 year ago

That error is very weird, because I think that syntax has been there fore a long time [edited - I'm wrong - that syntax was added recently, and may require a newer gfortran version @Sideboard?]

Regardless, something doesn't make sense - ScaLAPACK is an MPI library, but you don't seem to be using a QUIP_ARCH that has MPI support.

What makes you think that you need ScaLAPACK? Is this for parallel fitting of GAPs? If so, could someone (@jameskermode @Sideboard ) comment on how the compilation is supposed to be done.

Sideboard commented 1 year ago

That is curious indeed. Allocatable character length is Fortran 2003 and should be supported. All the oldest compilers on Compiler Explorer can compile such a declaration, including x86-64 gfortran 4.9.4.

Besides that, the question remains whether you do want to use ScaLAPACK or not. Loading QUIP_ARCH=linux_x86_64_gfortran says you don't want to. But answering Would you like to compile with ScaLAPACK? with y says you do. There are other arch options with OpenMP and/or MPI in the $QUIP_ROOT/arch directory.

Fu-Shengjie commented 1 year ago

Thank you both for your responses.

  1. I apologize for the confusion earlier. After double-checking and reloading the modules, the previous error message no longer appears. The compilation is now proceeding as expected.

  2. Regarding the use of ScaLAPACK, my understanding is that it's necessary for training GAP potentials which is a requirement for my project.

  3. As for the QUIP_ARCH setting, I understand from your responses that my initial choice may not have been appropriate for my needs. I've now switched to linux_x86_64_gfortran_openmpi+openmp and hope this is a more suitable choice.

I have successfully compiled QUIP using the updated settings.

I have a question regarding the commands available in this build: in a previous version of QUIP compiled by a colleague, we used the teach_sparse command. I noticed this command isn't available in my current build. For training GAP potentials with a prepared training dataset, should I use gap_fit instead?

ctxu-NWPU commented 1 month ago

I have a similar problem as above, except that I report a different error after make. /home/ctxu/QUIP/src/libAtoms/MPI_context.f95:63.43:

character(len=:), allocatable :: hostname 1 Error: Deferred-length character component 'hostname' at (1) is not yet supported /home/ctxu/QUIP/src/libAtoms/MPI_context.f95:63.43:

character(len=:), allocatable :: hostname 1 Error: Deferred-length character component 'hostname' at (1) is not yet supported /home/ctxu/QUIP/src/libAtoms/MPI_context.f95:1446.13:

allocate(counts, source=my_counts)
         1

Error: Array specification required in ALLOCATE statement at (1) /home/ctxu/QUIP/src/libAtoms/MPI_context.f95:1393.13:

allocate(counts, source=my_counts)
         1

Error: Array specification required in ALLOCATE statement at (1) /home/ctxu/QUIP/src/libAtoms/MPI_context.f95:1340.13:

allocate(counts, source=my_counts)
         1

Error: Array specification required in ALLOCATE statement at (1) make[1]: [MPI_context.o] Error 1 make[1]: Leaving directory `/home/ctxu/QUIP/build/linux_x86_64_gfortran_openmpi+openmp' make: [libAtoms] Error 2 i have made some efforts on it though fail. Can you give me guidances? @bernstei @Sideboard

bernstei commented 1 month ago

Looks like you need a newer version of the fortran compiler which supports the syntax that's used in the current version of the code. What compiler are you using?

ctxu-NWPU commented 1 month ago

Looks like you need a newer version of the fortran compiler which supports the syntax that's used in the current version of the code. What compiler are you using?

from the README of QUIP, i notice the version of gfortran is 4.4 or later, maybe my version is enough? gfortran --version GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44) Copyright (C) 2015 Free Software Foundation, Inc.

GNU Fortran comes with NO WARRANTY, to the extent permitted by law. You may redistribute copies of GNU Fortran under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING

bernstei commented 1 month ago

That's ancient. I'm not surprised it's not working. I'm pretty sure the README needs to be updated. See also https://github.com/libAtoms/QUIP/issues/637

gabor1 commented 1 month ago

I have a question regarding the commands available in this build: in a previous version of QUIP compiled by a colleague, we used the teach_sparse command. I noticed this command isn't available in my current build. For training GAP potentials with a prepared training dataset, should I use gap_fit instead?

Yes we renamed teach_spare to gap_fit.

gabor1 commented 1 month ago

Regarding the use of ScaLAPACK, my understanding is that it's necessary for training GAP potentials which is a requirement for my project.

you only need Scalapack if you want to run gap_fit on multiple nodes using MPI.