LBEM-CH / focus

High Throughput Electron Microscopy Image Processing Software
http://www.focus-em.org
GNU General Public License v2.0
35 stars 14 forks source link

Error compiling kernel/mrc fortran code #241

Closed sbliven closed 4 years ago

sbliven commented 4 years ago

I'm having trouble compiling focus on RHEL7 with gcc 8.3.0. I'm getting the following error:

[ 10%] Building Fortran object kernel/mrc/source/CMakeFiles/2dx_origtiltk.dir/2dx_origtiltk.for.o
f951: Warning: Nonexistent include directory ‘/usr/local/cuda-5.5/include’ [-Wmissing-include-dirs]
/var/tmp/Pmodules/bliven_s/focus-1.0.0_merlin6/src/kernel/mrc/source/2dx_origtiltk.for:4148:20:

       CALL CALCFX(N,X,F)
                    1
Error: Actual argument contains too few elements for dummy argument ‘params’ (1/4) at (1)
/var/tmp/Pmodules/bliven_s/focus-1.0.0_merlin6/src/kernel/mrc/source/2dx_origtiltk.for:4181:20:

       CALL CALCFX(N,X,F)
                    1
Error: Actual argument contains too few elements for dummy argument ‘params’ (1/4) at (1)
/var/tmp/Pmodules/bliven_s/focus-1.0.0_merlin6/src/kernel/mrc/source/2dx_origtiltk.for:4359:21:

       CALL CALCFX (N,X,F)
                     1
Error: Actual argument contains too few elements for dummy argument ‘params’ (1/4) at (1)
/var/tmp/Pmodules/bliven_s/focus-1.0.0_merlin6/src/kernel/mrc/source/2dx_origtiltk.for:4412:20:

       CALL CALCFX(N,X,F)
                    1
Error: Actual argument contains too few elements for dummy argument ‘params’ (1/4) at (1)
make[2]: *** [kernel/mrc/source/CMakeFiles/2dx_origtiltk.dir/2dx_origtiltk.for.o] Error 1
make[1]: *** [kernel/mrc/source/CMakeFiles/2dx_origtiltk.dir/all] Error 2
make: *** [all] Error 2

This looks like a legitimate error (X is defined as an array of dimension 1, but CALCFX takes a length-4 array). However my knowledge of fortran is poor.

I was surprised by the error, since I can compile focus on my mac without any problems.

sbliven commented 4 years ago

Has anyone successfully built focus on CentOS/Redhat? If so, you please report the GCC version?

rdrighetto commented 4 years ago

Dear Spencer,

Sorry for the delay. For testing, I just built FOCUS on Centos7 using GCC versions 4.8.4 and 8.2.0, and it worked without any issues. The error you described above, sounds like a more strict check done by later gfortran versions, that wasn't caught in previous versions, or perhaps a warning that is now handled as an error. Please try older versions and let us know.

sthennin commented 4 years ago

This error is in the old VA04A function, which is part of the mathematical libraries from NAG, that are included in the MRC code. This is from the 70'ies, I believe, very old F66 or F77 code. In those times, parameters could be given from a calling routine to a sub-routine, without any dimension check. If a calling routine had longer or shorter fields, the parameter name could still be given down to the sub-routine, and as long as the sub-routine would not access the n-th element of that parameter field, nothing bad would happen. This allowed sub-routines to work correctly for various calls from calling routines that worked with different lengths of parameter fields. Often, the length of the field "to be used" was also transferred to he sub-routine, to make sure no out-of-bounds access would take place. That was a very dangerous time to program.

Today's compilers check that parameter field lengths are the same in calling and called routines, which often is not the case for the old MRC programs.

Fixing those old programs is very difficult, as in many cases, one would have to replace some F66 code with new routines. For the Powell Minimizer such as VA04A, this is almost impossible. It would be much easier to change compiler flags, so that such out-of-bound errors are simply tolerated.

But that would have to be done for each compiler and system separately....

In an attempt to address the problem above, I now changed the dimension declaration DIMENSION X(4) to REAL*4 X(4) because that is the way it is defined elsewhere in that sub-routine. Let's see how that works. This is now on GitHub. Please give it a try.

Henning.

sbliven commented 4 years ago

@sthennin Thanks, I'll try building from master today.

sbliven commented 4 years ago

To follow up on this old issue, master works with GCC 9 on my system.