Solving G95 Coarray Test Code Compile Error

  • Thread starter Thread starter natski
  • Start date Start date
  • Tags Tags
    Code Test
Click For Summary
SUMMARY

The forum discussion addresses a compilation error encountered while using g95 to compile Fortran code that utilizes coarrays. The specific error messages indicate undefined references to intrinsic functions such as `_g95_this_image` and `_g95_num_images`. The issue is identified as a linker error, suggesting that the necessary libraries containing these functions were not specified during the compilation process. Possible causes include improper library setup or conflicts between different versions of g95.

PREREQUISITES
  • Understanding of Fortran programming language
  • Familiarity with g95 compiler and its command-line options
  • Knowledge of coarrays in Fortran
  • Basic concepts of linking and libraries in programming
NEXT STEPS
  • Review g95 documentation on linking libraries
  • Investigate how to properly set up coarray support in g95
  • Learn about managing multiple versions of g95 and their libraries
  • Explore alternative Fortran compilers that support coarrays, such as gfortran
USEFUL FOR

This discussion is beneficial for Fortran developers, particularly those working with parallel programming and coarrays, as well as anyone troubleshooting compilation issues with the g95 compiler.

natski
Messages
262
Reaction score
2
Hi all,

I am having difficulty compiling the following code in g95, which is supposed to handle coarrays... The code is:

!
PROGRAM test

implicit none

INTEGER :: a[*]
INTEGER :: m, i

IF ( THIS_IMAGE() == 1 ) THEN
READ(*,*) m
DO i = 1,NUM_IMAGES()
a = m
END DO
END IF

SYNC ALL

END PROGRAM

!

I have been compiling with g95 -o test test.f90 and I get the following compile error:

/tmp/ccKqMbva.o: In function `MAIN_':
test.f90:(.text+0x20): undefined reference to `_g95_this_image'
test.f90:(.text+0x9b): undefined reference to `_g95_num_images'
test.f90:(.text+0xf4): undefined reference to `_g95_store_image'
test.f90:(.text+0x11c): undefined reference to `_g95_sync_all'

I don't understand what the problem is... its almost as if g95 doesn't recognize these supposedly intrinsic functions. Any ideas?

Thanks!
natski
 
Technology news on Phys.org
These are linker errors. Your program compiled fine, and the compiled code had pointers to functions like _g95_this_image. However, the linker was not told what library contains the object code for these functions, and so it complained.

Typically this would mean you forgot to specify some library in the command line when you ran your compiler/linker.


In this particular case, I speculate the problem is that when you set up g95, you either did not create the library it needs, or you did not put it someplace where g95 could find it.

Or, you have two different versions of g95 and you're running the compiler from one version, but picking up the library from a different version.
 

Similar threads

  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
4K