MYSTRAN icon indicating copy to clipboard operation
MYSTRAN copied to clipboard

Compile error: "Index variable ‘k’ redefined in procedure ‘param_prtcord_output’"

Open gmargari opened this issue 2 years ago • 5 comments

Hi there, I just tried to compile MYSTRAN on Linux with Cmake / make, and got this error:

$ cmake .
$ make -j 4
Consolidate compiler generated dependencies of target arithchk
[  0%] Building C object CMakeFiles/arithchk.dir/f2c/arithchk.c.o
/tmp/mystran/f2c/arithchk.c: In function ‘ccheck’:
/tmp/mystran/f2c/arithchk.c:127:9: warning: format not a string literal and no format arguments [-Wformat-security]
  127 |         Cray1 = printf(emptyfmt) < 0 ? 0 : 4617762;
      |         ^~~~~
[  0%] Linking C executable f2c/arithchk
[  0%] Built target arithchk
[  0%] Generating f2c/include/arith.h
Consolidate compiler generated dependencies of target f2c
[  0%] Building C object CMakeFiles/f2c.dir/f2c/abort_.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/arithchk.c.o
/tmp/mystran/f2c/arithchk.c: In function ‘ccheck’:
/tmp/mystran/f2c/arithchk.c:127:9: warning: format not a string literal and no format arguments [-Wformat-security]
  127 |         Cray1 = printf(emptyfmt) < 0 ? 0 : 4617762;
      |         ^~~~~
[  0%] Building C object CMakeFiles/f2c.dir/f2c/backspac.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/c_abs.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/c_cos.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/c_div.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/c_exp.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/c_log.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/c_sin.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/c_sqrt.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/cabs.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/close.c.o
[  0%] Building C object CMakeFiles/f2c.dir/f2c/ctype.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_abs.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_acos.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_asin.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_atan.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_atn2.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_cnjg.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_cos.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_cosh.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_dim.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_exp.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_imag.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_int.c.o
[  1%] Building C object CMakeFiles/f2c.dir/f2c/d_lg10.c.o

.
.
.


[ 43%] Building Fortran object CMakeFiles/LK1.dir/Source/LK1/L1B/CORD_PROC.f90.o
/tmp/mystran/Source/LK1/L1B/CORD_PROC.f90:1447:59:

  408 |                               IF (PRTCORD == 2) CALL PARAM_PRTCORD_OUTPUT ( '33' )
      |                                                                                  2
......
 1447 |          WRITE(F06,7302) CID, GA(J), CIDA, (RGA(J,K),K=1,3)
      |                                                           1
Error: Index variable ‘k’ redefined at (1) in procedure ‘param_prtcord_output’ called from within DO loop at (2)
/tmp/mystran/Source/LK1/L1B/CORD_PROC.f90:1448:59:

  408 |                               IF (PRTCORD == 2) CALL PARAM_PRTCORD_OUTPUT ( '33' )
      |                                                                                  2
......
 1448 |          WRITE(F06,7302) CID, GB(J), CIDB, (RGB(J,K),K=1,3)
      |                                                           1
Error: Index variable ‘k’ redefined at (1) in procedure ‘param_prtcord_output’ called from within DO loop at (2)
/tmp/mystran/Source/LK1/L1B/CORD_PROC.f90:1449:59:

  408 |                               IF (PRTCORD == 2) CALL PARAM_PRTCORD_OUTPUT ( '33' )
      |                                                                                  2
......
 1449 |          WRITE(F06,7302) CID, GC(J), CIDC, (RGC(J,K),K=1,3)
      |                                                           1
Error: Index variable ‘k’ redefined at (1) in procedure ‘param_prtcord_output’ called from within DO loop at (2)
make[2]: *** [CMakeFiles/LK1.dir/build.make:1999: CMakeFiles/LK1.dir/Source/LK1/L1B/CORD_PROC.f90.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:360: CMakeFiles/LK1.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Info:

$ gcc --version
gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0

$ cmake --version
cmake version 3.22.1

$ make --version
GNU Make 4.3

$ f2c --version
f2c (Fortran to C Translator) version 20200916.

$ lsb_release -a
Distributor ID:	Linuxmint
Description:	Linux Mint 21
Release:	21
Codename:	vanessa

Thanks!

gmargari avatar Aug 15 '22 19:08 gmargari

Hello! I'm sorry it took me this long to reply and I'm terribly sorry about the compilation error.

It's caused by a slight change in gfortran behavior regarding implicit behavior for loop indices inside subfunctions. Here's a patched version of the code that's still in testing. mystran_with_fixed_indices_bug.zip

My apologies that its' not an official github hosted repair, but it's still in testing at the moment. Our project lead has been on a long vacation for a while and he's not yet back to finalizing the testing for this build.

One way to get it to compile is by using an older version of gfortran, but this should work with whatever you are using.

Terribly sorry for the inconvenience.

  • Z

zchlrnr avatar Aug 19 '22 03:08 zchlrnr

Hi @zchlrnr,

Thanks for quick feedback!

I tried getting an older gfortran -at least an old enough gfortran that did not cause this error- but was not easy.

Your code should do the trick, thanks a lot.

gmargari avatar Aug 19 '22 07:08 gmargari

Hi z, I'm just confirming that the patch indeed works, thanks.

gmargari avatar Aug 27 '22 13:08 gmargari

I'm elated to hear that. I'm leaving this one issue open until we are finished testing to push this update through. Thank you very much for confirming that it functions.

  • Z

zchlrnr avatar Aug 29 '22 01:08 zchlrnr

Ready to finally close this.

zchlrnr avatar Sep 08 '22 03:09 zchlrnr