MinGW64 GFORTRAN Issues newer versions

In summary: The problem is that the REAL*8 in the DATA statement is actually a CHARACTER*8. When GFORTRAN tries to convert it to a REAL, it crashes. This is something that you would need to fix in the source code.
  • #1
jelanier
67
1
TL;DR Summary
Versions after 5 cause compile errors or compile to exe that doesn't work
http://www.chemroc.com/programs/NEC2Test.zip

I don't understand what has happened with newer versions of GFORTRAN/MinGW64 . This is a very old FORTRAN program that I had edited years ago to compile and run with GFORTRAN. It doesn't work with newer versions. Can anyone help? I included link to test the program. Includes batch to compile and batch to execute. Last version that works is MINGW64 v5.4

Also, The Hollerith warnings..I tried to replace them by quotes like 'example' but program will not compile that way. I also don't understand the loop error with version 8 (MinGW64_V8)

https://sourceforge.net/projects/mi...ilds/installer/mingw-w64-install.exe/download

Any help would be appreciated.

Thanks in advance,

Jim
 
Technology news on Phys.org
  • #2
I have found a way to make it compile. It seems new version doesn't like optimization options on this old code.
gfortran -fno-automatic -ffast-math nec2dxs_JL.f -static -o nec2dxs.exe
This does work. I removed -O. O2 O3 Ofast do not work.

I still have a question about Hollerith data.

Current:
DATA HPOL/6HLINEAR,5HRIGHT,4HLEFT/

I changed it to:
DATA HPOL/'LINEAR','RIGHT','LEFT'/

Will not compile. What is up with that?

Thanks,

Jim
 
  • #3
Installed gfortran and using gf.bat the thing did compile with warnings about hollerith and this loop issue.
But it crashed when run:
Code:
         - MULTIPLE WIRE JUNCTIONS -
 JUNCTION    SEGMENTS  (- FOR END 1, + FOR END 2)
     1        -1  -56 -661
     2         1   -2   -3   -4   -5   -6   -7   -8   -9  -10  -11  -12  -13  -14  -15  -16  -17  -18  -19  -20
             -21  -22  -23  -24  -25  -26  -27  -28  -29  -30  -31  -32  -33  -34  -35  -36  -37  -38  -39  -40
             -41  -42  -43  -44  -45  -46  -47  -48  -49  -50  -51  -52  -53  -54  -55  -56 -661
 CONNECT - SEGMENT CONNECTION ERROR FOR SEGMENT  417

jelanier said:
It seems new version doesn't like optimization options on this old code.
I agree, and I find it very annoying that the compiler issues a warning only. It seems to make a mess of the loop
Fortran:
      IF (NY.GT.0) GO TO 11
      MIA=MI
      GO TO 12
11    M=M+1
      MP=MP+1
      MIA=LD+1-M
12    DO 13 IX=1,4
      X(MIA)=XS+XT*S1X+YT*S2X
      Y(MIA)=YS+XT*S1Y+YT*S2Y
      Z(MIA)=ZS+XT*S1Z+YT*S2Z
      BI(MIA)=XA
      T1X(MIA)=S1X
      T1Y(MIA)=S1Y
      T1Z(MIA)=S1Z
      T2X(MIA)=S2X
      T2Y(MIA)=S2Y
      T2Z(MIA)=S2Z
      SALP(MIA)=SALN
      IF (IX.EQ.2) YT=-YT
      IF (IX.EQ.1.OR.IX.EQ.3) XT=-XT
      MIA=MIA-1
13    CONTINUE

Which is no wonder in view of the loop counter being used in IF statements only and MIA in fact secretly doing the actual loop counter work. But even then, the compiler messages are rather useless:

Code:
nec2dxs_JL.f:7923:0:

       T1X(MIA)=S1X

Warning: iteration 1 invokes undefined behavior [-Waggressive-loop-optimizations]
nec2dxs_JL.f:7918:0:

 12    DO 13 IX=1,4

note: within this loop
and breaks off abruptly.

Kudos for finding an incantation that works !
(and gives exactly the same result 25% faster)Re:
I changed it to:
DATA HPOL/'LINEAR','RIGHT','LEFT'/

Will not compile. What is up with that?

Can't reproduce that 🤔 !?.
(the warning for line 130 simply goes away)

##\ ##
 
  • #4
Thanks for looking into this BvU. My warning goes away also, but it does not produce an .exe. If you scroll down a bit you will see an error concerning that Hollerith edit.

BTW, I have a more extensive version of this code where I link to OpenBLAS LAPACK optimized. It increases speed by about 4x. But the base code here needs to be fixed first. I can't seem to figure out the Hollerith issue.

Later,

Jim
 
  • #5
Sorry, missed that completely (it happens on a later pass, so it isn't the first message any more )

Code:
nec2dxs_JL.f:131:12:

    DATA HPOL/'LINEAR','RIGHT','LEFT'/
            1
Error: Incompatible types in DATA statement at (1); attempted conversion of CHARACTER(1) to REAL(8)

In the source code we have
Fortran:
      REAL*8  HPOL,PNET
      DIMENSION HPOL(3)
      DATA HPOL/'LINEAR','RIGHT','LEFT'/

With
character*6 HPOL,PNET
instead of REAL*8

it compiles and runs. I haven't found a way to make this less tedious: it means a you have to find all declarations and determine a size (or bluntly use e.g. character*60 )
 
  • #6
I did that earlier this morning with the character definition and had a good result. Some of these are not declared as real, but arrays. This could get ugly. I'll try to figure out how to handle the variable in one of these arrays. I thought arrays had to be declared as a type, but I don't see it.
C***
DIMENSION X2(1), Y2(1), Z2(1), T1X(1), T1Y(1), T1Z(1), T2X(1), T2Y
1(1), T2Z(1), ATST(13), IFX(2), IFY(2), IFZ(2), CAB(1), SAB(1), IPT
2(4)

Also, I tried an experiment on the optimization. I added -O again and removed the loop. It was only 4 passes so I copied it 4 times and incremented the variable. No warning, it compiled and crashed on run. Maybe it is nested.

Thanks again,

Jim
 
  • Like
Likes BvU

1. How do I install MinGW64 GFORTRAN on my computer?

To install MinGW64 GFORTRAN, you will need to download and install the MinGW64 compiler toolchain. This can be done through the MinGW website or through a package manager like Homebrew. Once the toolchain is installed, you can then install GFORTRAN using the appropriate commands.

2. Can I use newer versions of GFORTRAN with MinGW64?

Yes, you can use newer versions of GFORTRAN with MinGW64. However, you may need to make some modifications to your code to ensure compatibility with the newer version. It is recommended to consult the GFORTRAN documentation for specific instructions.

3. What are some common issues with using newer versions of GFORTRAN with MinGW64?

Some common issues with using newer versions of GFORTRAN with MinGW64 include compatibility issues with existing code, missing libraries or dependencies, and changes in syntax or behavior. It is important to thoroughly test your code when upgrading to a newer version of GFORTRAN.

4. How can I troubleshoot GFORTRAN issues with MinGW64?

If you encounter issues with GFORTRAN and MinGW64, there are a few steps you can take to troubleshoot the problem. First, check for any error messages or warnings during compilation. Next, review your code for any potential compatibility issues. You can also try using a debugger to identify the source of the problem.

5. Is there a support forum or community for MinGW64 GFORTRAN users?

Yes, there are multiple online forums and communities where users can seek help and advice for issues with MinGW64 GFORTRAN. These include the MinGW mailing list, the GFORTRAN forum on the Intel website, and various programming forums such as Stack Overflow. It is also recommended to consult the official GFORTRAN documentation for troubleshooting and support.

Similar threads

  • Programming and Computer Science
Replies
4
Views
911
  • Programming and Computer Science
Replies
14
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
7K
  • Programming and Computer Science
Replies
1
Views
2K
  • DIY Projects
2
Replies
41
Views
19K
Back
Top