jchelly / gadgetviewer

Simple tool for interactive visualisation of Gadget and SWIFT N-body simulations
GNU General Public License v3.0
24 stars 9 forks source link

does not compile with gfortran 10.2.0 #11

Closed BenWibking closed 3 years ago

BenWibking commented 3 years ago

I am trying to compile gadgetviewer on my macOS machine. I have installed gfortran via homebrew. I run ./autogen.sh and ./configure successfully, but make fails with a compile error on key_file.F90 when using gfortran version 10.2.0:

libtool: compile:  gfortran -DHAVE_CONFIG_H -I. -I../../. -g -O2 -c key_file.F90  -fno-common -o .libs/key_file.o
key_file.F90:401:9:

  401 |          c_value, n, int(1, kind=C_INT))
      |         1
......
  423 |          c_value, n, int(size(c_value), kind=C_INT))
      |         2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
key_file.F90:322:9:

  322 |          c_value, n, &
      |         1
......
  343 |          c_value, n, int(size(c_value), kind=C_INT))
      |         2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
key_file.F90:279:9:

  279 |          c_value, n, &
      |         1
......
  423 |          c_value, n, int(size(c_value), kind=C_INT))
      |         2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
key_file.F90:235:9:

  235 |          c_value, int(1, kind=C_INT))
      |         1
......
  261 |          c_value, int(size(c_value), kind=C_INT))
      |         2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
key_file.F90:151:9:

  151 |          c_value, int(1, kind=C_INT))
      |         1
......
  170 |          c_value, int(size(c_value), kind=C_INT))
      |         2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
key_file.F90:113:9:

  113 |          c_value, int(1, kind=C_INT))
      |         1
......
  261 |          c_value, int(size(c_value), kind=C_INT))
      |         2
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
BenWibking commented 3 years ago

My configuration looks like this:

  Gadgetviewer v1.1.1 configuration
  --------------------------------------

  Compilers

    Fortran compiler: gfortran
    Fortran flags   : -fopenmp  -O3 -g -O2
    C compiler      : gcc
    C flags         : -g -O2

  Plotting library (only need one of these)

    PLPlot          : no
    Cairo           : yes

  Other libraries

    HDF5            : yes
    PNG             : yes

  Internal precision of particle data

    Positions                     : 4 bytes
    Velocities                    : 4 bytes
    Floating point properties     : 4 bytes
    Integer properties (e.g. IDs) : 8 bytes
    Particle array indexes        : 8 bytes
jchelly commented 3 years ago

Thanks for reporting this. I think the problem is that the code is calling the same C function with a scalar argument in some places and an array in others. That's probably not strictly allowed, but older compilers didn't check.

jchelly commented 3 years ago

I've pushed a workaround for this to master. If you download the latest master and run ./autogen.sh in the source directory then configure and compile as normal it should work. The configure script now checks if the compiler accepts the flag "-fallow-argument-mismatch", which downgrades the error to a warning.

If you can't run autogen.sh (e.g. no autotools installed) then you could try compiling the 1.1.1 release with "-fallow-argument-mismatch" added to the FCFLAGS variable. E.g.

./configure FCFLAGS="-O2 -g -fopenmp -fallow-argument-mismatch"

The right way to fix this would be to use the iso_c_binding module to call C functions, but I probably wont have time to do that in the next few weeks. Most compilers didn't support iso_c_binding when I originally wrote gadgetviewer.

BenWibking commented 3 years ago

Thanks, that problem is fixed now. I now get a new error I've added in a separate issue (#12).