0

I am trying to compile a fortran code which was last compiled in early 90's on Windows machine using Lahey Fortran . Now, I am compiling with gfortran on ubuntu 64x.

I am getting following error

$ gfortran 3RINGS.FOR /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0xc10): undefined reference to _mmbsk0_' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0xc3d): undefined reference tommbsk1' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0xc6a): undefined reference to _mmbsi0_' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0xc97): undefined reference tommbsi1' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0xcc4): undefined reference to _mmbsk0_' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0xcf1): undefined reference tommbsk1' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0xd1e): undefined reference to _mmbsi0_' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0xd4b): undefined reference tommbsi1' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0x1182): undefined reference to _mmbsk0_' /tmp/ccjCDh8B.o:3RINGS.FOR:(.text+0x11a5): undefined reference tommbsi0' collect2: ld returned 1 exit status

The error is regarding following variable declaration in code

REAL*8 MMBSK0,MMBSK1,MMBSI0,MMBSI1

I will appreciate any suggestion to solve this problem and compile this code. I will be happy to upload the entire code (263 lines) if anybody need that.

  • Are those `MMBSK0` used as arrays? In that case there should be a dimension statement somewhere as well. – steabert May 24 '13 at 06:29

1 Answers1

0

(Unrelated to your problem - note that REAL*8 is an extension to standard Fortran. The correct syntax is REAL(8), where the meaning of "8" depends on your compiler.)

The compiler thinks those MM... names declare functions, rather than variables. It usually deduces that a name references a function based on the way the name is used later in the code.

I'd guess that there's more to your program than the single source file - perhaps other source files that you need to compile and link in with your main program.

IanH
  • 21,026
  • 2
  • 37
  • 59
  • 4
    While `real*8` an extension, it is better to use it than `real(8)` with the numeric value `8`. Compilers will "understand" `real*8` consistently as an 8-byte real. `real(8)` is kind type value 8, which could have different meanings on different compilers. See http://stackoverflow.com/questions/10520819/what-does-real8-mean – M. S. B. May 24 '13 at 05:28
  • I disagree with the accepted answer in that question. For some compilers, that may be what it supposedly means; for other compilers it may well mean something different - after all - it is an extension. Are there realistically compilers that accept real*n and interpret that as anything other than a synonym for real(n)? I have at least one compiler that gives an outright syntax error for real*8 form but accepts real(8). – IanH May 24 '13 at 07:01
  • At least real*8 is rejected. If accepted, I've never heard of a compiler that processes real*n as other than an n-byte real. While uncommon, there are compilers that process real(n) as different from an n-byte real. – M. S. B. May 24 '13 at 08:18
  • 1
    I believe NAG and g77 would be examples of compilers where those are not synonyms. – Vladimir F Героям слава May 24 '13 at 08:21