rwesson / ALFA

Automated Line Fitting Algorithm
http://www.nebulousresearch.org/codes/alfa/
GNU General Public License v3.0
12 stars 6 forks source link

Compilation failed with gfortran 9 #26

Closed kakirastern closed 4 years ago

kakirastern commented 4 years ago

While trying to run make on my MacBook Pro with gcc installed using brew, I ran into some errors as follows:

gfortran -cpp -DPREFIX=\"/usr/local\" -DVERSION=\"v2.0-46-gbb53ad2-dirty\" -ffree-line-length-0 -Jsource/ -fopenmp -O3 -fno-backtrace source/rnglib.f90 -c -o source/rnglib.o
gfortran -cpp -DPREFIX=\"/usr/local\" -DVERSION=\"v2.0-46-gbb53ad2-dirty\" -ffree-line-length-0 -Jsource/ -fopenmp -O3 -fno-backtrace source/types.f90 -c -o source/types.o
gfortran -cpp -DPREFIX=\"/usr/local\" -DVERSION=\"v2.0-46-gbb53ad2-dirty\" -ffree-line-length-0 -Jsource/ -fopenmp -O3 -fno-backtrace source/globals.f90 -c -o source/globals.o
gfortran -cpp -DPREFIX=\"/usr/local\" -DVERSION=\"v2.0-46-gbb53ad2-dirty\" -ffree-line-length-0 -Jsource/ -fopenmp -O3 -fno-backtrace source/functions.f90 -c -o source/functions.o
gfortran -cpp -DPREFIX=\"/usr/local\" -DVERSION=\"v2.0-46-gbb53ad2-dirty\" -ffree-line-length-0 -Jsource/ -fopenmp -O3 -fno-backtrace source/output.f90 -c -o source/output.o
source/output.f90:504:37:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  504 |     call ftpcle(unit,1,rownumber,1,1,3630.0,status)
      |                                     1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:505:37:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  505 |     call ftpcle(unit,2,rownumber,1,1,3630.0,status)
      |                                     1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:513:37:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  513 |     call ftpcle(unit,1,rownumber,1,1,3700.0,status)
      |                                     1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:514:37:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  514 |     call ftpcle(unit,2,rownumber,1,1,3700.0,status)
      |                                     1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:522:37:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  522 |     call ftpcle(unit,1,rownumber,1,1,8100.0,status)
      |                                     1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:523:37:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  523 |     call ftpcle(unit,2,rownumber,1,1,8100.0,status)
      |                                     1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:531:37:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  531 |     call ftpcle(unit,1,rownumber,1,1,8400.0,status)
      |                                     1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:532:37:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  532 |     call ftpcle(unit,2,rownumber,1,1,8400.0,status)
      |                                     1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:557:27:

  495 |   call ftpclj(unit,11,1,1,totallines,fittedlines%g1,status)
      |                                     2
......
  557 |   call ftpclj(unit,1,1,1,1,detectedlines,status)
      |                           1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:558:27:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  558 |   call ftpcle(unit,2,1,1,1,hbetaflux,status)
      |                           1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:559:27:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  559 |   call ftpcle(unit,3,1,1,1,c*(redshiftguess_overall-1),status)
      |                           1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
source/output.f90:560:27:

  422 |   call ftpcle(unit,1,1,1,spectrumlength,fittedspectrum%wavelength,status)
      |                                        2
......
  560 |   call ftpcle(unit,4,1,1,1,resolutionguess,status)
      |                           1
Error: Rank mismatch between actual argument at (1) and actual argument at (2) (rank-1 and scalar)
make: *** [Makefile:78: source/output.o] Error 1

I would like to know if the issue is with the code, or if the issue is on the client side. Any help would be much appreciated.

rwesson commented 4 years ago

I do not see this error when I compile on linux with gfortran 5.4. Which version of gfortran are you using? It could be that more recent versions apply the standard more strictly.

kakirastern commented 4 years ago

Hi @rwesson I am using gcc@9 installed with homebrew. I tried something to the effect of

export FCFLAGS="-w -fallow-argument-mismatch"
export FFLAGS="-w -fallow-argument-mismatch"

and that seemed to have been able to suppress the errors, but now am seeing another error

ld: library not found for -lcfitsio

I am wondering if by chance you know where I can locate this cfitsio library?

kakirastern commented 4 years ago

No worries, it is weird. I tried updating the CFITSIOFLAGS path in the Makefile, but that did not seem to have worked. So I tried using

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib

which did the trick.

Thanks for your help!

kakirastern commented 4 years ago

Finally, is there any reason why alfa is writing all the outputs to a single FITS file's 3 different extensions FIT, LINES, and QC instead of three separate files like it used to do? And, is there any way to change this?

rwesson commented 4 years ago

Thanks for the extra information! I will try to update the code to compile properly with later GCC versions.

I changed the default output format to FITS starting from version 2.0, as it is much easier to handle within the code, and it avoids a problem where the output format can overflow, resulting in "***" instead of numbers in the text outputs. Text output is still available though - specify "--output-format text" in the command.

kakirastern commented 4 years ago

Ah, I see... Thanks for the info!

rwesson commented 4 years ago

I've fixed this now (commit 5b1f1a2a0c4e93c619a209975e1a2809904c745a). The strict typing standards applied by the latest gfortran meant that I had to change some values from simple numbers to a single-valued array containing the number. I've verified successful compilation with gfortran versions 5.4, 9.3 and 10.01 now.

kakirastern commented 4 years ago

Thanks @rwesson Appreciate your message