compas / grasp

General Relativistic Atomic Structure Package
https://compas.github.io/grasp/
MIT License
56 stars 26 forks source link

Fix argument mismatches in the code base #77

Open mortenpi opened 2 years ago

mortenpi commented 2 years ago

As evident from #46 and #76, we have some argument mismatches in the code base. GCC 10 is just finally strict enough to catch these. This leads to errors like:

/tmp/grasp/src/lib/lib9290/iniest2.f90:82:23:

   79 |          CALL DCOPY (NS, VEC(NS*(J-1)+1), 1, BASIS(NCF*(J-1)+1), 1)
      |                         2
......
   82 |       CALL DCOPY (NIV, EIGVAL, 1, BASIS(NIV*NCF+1), 1)
      |                       1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (scalar and rank-1)
make[2]: *** [src/lib/lib9290/CMakeFiles/9290.dir/iniest2.f90.o] Error 1
make[1]: *** [src/lib/lib9290/CMakeFiles/9290.dir/all] Error 2
make: *** [all] Error 2

As suggested in the GCC manual, we should investigate and fix them (rather than disabling the warning/error):

Depending on their nature, argument mismatches have the potential to cause the generation of invalid code and, hence, should be investigated.

As a workaround, however, it is still possible to build GRASP on GCC 10 if -fallow-argument-mismatch is passed. With CMake, this can be done by configuring the build as:

mkdir build/
cd build/
cmake .. -DCMAKE_Fortran_FLAGS="-fallow-argument-mismatch"

And with the Makefile-based build (ref: https://github.com/compas/grasp/issues/46#issuecomment-701397299) it should be sufficient to set the following before calling make:

export FC_FLAGS="$FC_FLAGS -fallow-argument-mismatch"