qcscine / qcmaquis

Release-only repository for SCINE QCMaquis, the DMRG software from the Reiher group.
BSD 3-Clause "New" or "Revised" License
33 stars 15 forks source link

OpenMOLCAS interface compilation error #25

Open lorisercole opened 6 months ago

lorisercole commented 6 months ago

Hello, I am trying to build the OpenMOLCAS Fortran interface with the BUILD_OPENMOLCAS_INTERFACE option, but I get these errors:

/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1071:25:

 1071 |     Call GA_Brdcst(MT_DBL, [res], storage_size(res)/8, 0)
      |                         1
Error: Symbol 'mt_dbl' at (1) has no IMPLICIT type
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:792:27:

  792 |       call GA_Brdcst(MT_DBL, [dmrg_energy%dmrg], storage_size(dmrg_energy%num_sweeps)/8, 0)
      |                           1
Error: Symbol 'mt_dbl' at (1) has no IMPLICIT type
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:797:27:

  797 |       call GA_Brdcst(MT_INT, dmrg_energy%num_sweeps, size(dmrg_energy%num_sweeps)*storage_size(dmrg_energy%num_sweeps)/8, 0)
      |                           1
Error: Symbol 'mt_int' at (1) has no IMPLICIT type
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:680:30:

  680 |         call GA_Brdcst(MT_BYTE, fiedler_order_str, len_fiedler_str, 0)
      |                              1
Error: Symbol 'mt_byte' at (1) has no IMPLICIT type
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:679:29:

  679 |         call GA_Brdcst(MT_INT, [len_fiedler_str], storage_size(len_fiedler_str)/8,0)
      |                             1
Error: Symbol 'mt_int' at (1) has no IMPLICIT type
make[2]: *** [lib/interfaces/openmolcas/CMakeFiles/qcmaquis-driver.dir/build.make:104: lib/interfaces/openmolcas/CMakeFiles/qcmaquis-driver.dir/qcmaquis_interface.f90.o] Error 1
make[2]: Leaving directory '/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-build-e4onxoy'
make[1]: *** [CMakeFiles/Makefile2:271: lib/interfaces/openmolcas/CMakeFiles/qcmaquis-driver.dir/all] Error 2

and a bunch of these warnings:

/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1225:2:

 1225 | #ifdef _MOLCAS_MPP_
      |  1
Warning: Illegal preprocessor directive
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1227:2:

 1227 | #endif
      |  1
Warning: Illegal preprocessor directive
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1235:2:

 1235 | #ifdef _MOLCAS_MPP_
      |  1
Warning: Illegal preprocessor directive
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1237:2:

 1237 | #endif
      |  1
Warning: Illegal preprocessor directive
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1258:2:

 1258 | #ifdef _MOLCAS_MPP_
      |  1
Warning: Illegal preprocessor directive
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1260:2:

 1260 | #endif
      |  1
Warning: Illegal preprocessor directive
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1272:2:

 1272 | #ifdef _MOLCAS_MPP_
      |  1
Warning: Illegal preprocessor directive
/mnt/nvme/tmpscratch/root/spack-stage/spack-stage-scine-qcmaquis-3.1.4-e4onxoy7w5qj5giziaxktohwqcsswbmu/spack-src/dmrg/lib/interfaces/openmolcas/qcmaquis_interface.f90:1274:2:

 1274 | #endif
      |  1
Warning: Illegal preprocessor directive

I tried several different compilers (GCC 9-12, Clang, Intel), but they all fail on the qcmaquis_interface.f90 file. Do you have any suggestions?

The cmake command is essentially this:

cmake -DBUILD_SYMMETRIES:STRING=SU2U1;SU2U1PG;TwoU1;TwoU1PG -DBUILD_OPENMOLCAS_INTERFACE:BOOL=ON -DQCMAQUIS_TESTS:BOOL=OFF -DLAPACK_64_BIT:BOOL=ON ../src/dmrg'

and I am using MKL libs. Thank you.

lorisercole commented 6 months ago

It seems to be a problem with the flags used by Cmake to compile these modules. The -cpp flag was not used.

kszenes commented 6 months ago

Hi Loris,

I have been unable to reproduce the errors you are having on a GCC 10 and GCC 13 compiler. However, it does seem that your Fortran compiler is not properly registering the C preprocessor macros. This is precisely what the -cpp flag is supposed to do in the Cmake file. One option could be renaming the extension of the 5 Fortran files from .f90 to .F90. This file extensions should automatically trigger the preprocessor. Since I am unable to reproduce your errors, would you mind trying this out and letting me know if this fixed your issue? (You also need to change the file extensions in dmrg/lib/interfaces/openmolcas/CMakeLists.txt). If this fixes the issue that you are experiencing, I could then propagate this down to the main branch.

Best, Kalman

lorisercole commented 6 months ago

Hi @kszenes , thanks for our help! It might be an issue with my compiler (I am actually using spack to build qcmaquis, so it takes care of setting up the compiler). Anyway, I managed to solve the issue by patching dmrg/lib/interfaces/openmolcas/CMakeLists.txt. I attach the patch here.

cmake_molcas_interface.patch

kszenes commented 6 months ago

Thanks for sharing the patch! I will look into including it directly in the main branch.

I saw that you were working with spack. Are you developing a spack package for qcmaquis? If so, would you mind sharing it with us? This was something I wanted to look into as well.

lorisercole commented 6 months ago

Yes, actually there is already a recipe available here: https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/scine-qcmaquis/package.py I am going to push a PR to update it and add this patch with it.