Menu

#456 Type confusion in irisubne.for detected by gfortran 10.2

next release
closed-fixed
None
5
2021-12-06
2021-11-08
No

When I

git clone git://git.code.sf.net/p/psrchive/code psrchive

and try to compiling psrchive commit b71841c29777f33ff5a47227e90e7276048f0c2f with gfortran version GNU Fortran (Debian 10.2.1-6) 10.2.1 20210110

I get

1063 | CALL REGFA1(HEF,HMF2,XE2H,NMF2,0.001,NMF1,XE2,SCHALT,HMF1)
| 2
......
1112 | CALL REGFA1(hf1,HF2,XF1,XF2,0.001,NME,XE3_1,SCHALT,HST)
| 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/INTEGER(4)).
irisubne.for:1311:45:

1063 | CALL REGFA1(HEF,HMF2,XE2H,NMF2,0.001,NMF1,XE2,SCHALT,HMF1)
| 2
......
1311 | CALL REGFA1(130.0,500.0,TI13,TI50,0.01,TI1,TEDER,SCHALT,HS)
| 1
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/INTEGER(4)).

adding -fallow-argument-mismatch allows the command

fortran -fallow-argument-mismatch -fPIC -c irisubne.for -fPIC -o .libs/irisubne.o

to succeed, but I am not sure if the type confusion between integer and floating point will lead to subtle errors.

Discussion

  • Willem van Straten

    I cannot currently reproduce this bug on my end and therefore cannot test the following proposed solution. I think that this error message will go away if HF1 is declared as REAL; e.g. by changing line 242 from

      &      NMF1,NME,NMD,MM,MLAT,MLONG,NOBO2
    

    to

      &      NMF1,NME,NMD,MM,MLAT,MLONG,NOBO2,HF1
    

    I would have commited this change, but I imagine that it will lead only to the next mismatch owing to undeclared variables.

     
  • Patrick Kilian

    Patrick Kilian - 2021-11-08

    Indeed. With that fix the same problem occurs with NMF1. Declaring that as REAL as well allows the compilation to go through.

     
  • Willem van Straten

    Thank you for confirming, Patrick. On what line did you add NMF1 to the REAL declaration? (I note that NMF1 is already declared REAL on line 242 above) ... alternatively, if you send me your version of irisubne.for that successfully compiles, I can check it in.

     
  • Patrick Kilian

    Patrick Kilian - 2021-11-08

    diff --git a/More/Polarimetry/iri2001/irisubne.for b/More/Polarimetry/iri2001/irisubne.for
    index 4d9dd7ef0..4aeb9e11a 100644
    --- a/More/Polarimetry/iri2001/irisubne.for
    +++ b/More/Polarimetry/iri2001/irisubne.for
    @@ -239,7 +239,7 @@ C*********
    C
    *********
    INTEGER DAYNR,DDO,DO2,SEASON,SEADAY
    REAL LATI,LONGI,MO2,MO,MODIP,NMF2,MAGBR,INVDIP
    - & NMF1,NME,NMD,MM,MLAT,MLONG,NOBO2,HF1
    + & NMF1,NME,NMD,MM,MLAT,MLONG,NOBO2,HF1,NMF1
    CHARACTER IRIDIR80
    INTEGER IRILEN
    CHARACTER FILNAM
    80

    But all I can say is that it compiles...

     
  • Scott Ransom

    Scott Ransom - 2021-11-16

    I just ran into this as well. I'm using Ubuntu 21.10, and so my gfortran is really new (v 11.2.0). I think that might have something to do with it.

     
    • Patrick Kilian

      Patrick Kilian - 2021-11-16

      Yeah, I ran into it when using gfortran 10.2, gfortran 9 was fine with the file.

       
  • Scott Ransom

    Scott Ransom - 2021-11-16

    And note that using Patrick's crazy diff (i.e. adding another NMF1 to the end of the declaration where it already exists!) lets the file compile. I have no idea why that is.

     
  • Willem van Straten

    Turns out there was a comma missing at the end of line 241 ... fix checked in!

     
  • Willem van Straten

    • status: open --> closed-fixed
    • assigned_to: Willem van Straten
     

Log in to post a comment.

MongoDB Logo MongoDB