Solving G95 Coarray Test Code Compile Error

  • Thread starter natski
  • Start date
  • Tags
    Code Test
In summary, the conversation involves a person who is having trouble compiling code in g95 and is receiving linker errors. The problem may be due to not specifying the correct library in the command line or having multiple versions of g95.
  • #1
natski
267
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
  • #2
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.
 

What is a G95 coarray and why is it used?

A G95 coarray is a type of parallel programming construct used in Fortran. It allows for multiple copies of a program to run simultaneously and communicate with each other. This is useful for solving complex problems that require a large amount of computational power.

What is a compile error and how does it affect G95 coarray test code?

A compile error occurs when the code written by a programmer contains errors or is not compatible with the compiler being used. This can affect G95 coarray test code by preventing it from being compiled and executed properly, resulting in incorrect or incomplete results.

How can I fix a compile error in G95 coarray test code?

The best way to fix a compile error in G95 coarray test code is to carefully review the code and identify the error(s). This may involve checking for typos, missing or incorrect syntax, and ensuring that all necessary libraries and dependencies are included. It may also be helpful to consult online resources or seek assistance from other programmers.

What are some common causes of compile errors in G95 coarray test code?

Some common causes of compile errors in G95 coarray test code include typos, incorrect syntax, missing or outdated libraries, and incompatible code with the chosen compiler. It is important to carefully review the code and check for these potential issues.

How can I prevent compile errors in G95 coarray test code in the future?

To prevent compile errors in G95 coarray test code, it is important to carefully review and test the code before compiling it. This includes checking for typos and using proper syntax, as well as ensuring that all necessary libraries and dependencies are included and compatible with the chosen compiler. It may also be helpful to use a debugging tool or consult with other programmers for assistance.

Similar threads

  • Programming and Computer Science
Replies
22
Views
2K
  • Programming and Computer Science
Replies
4
Views
616
  • Programming and Computer Science
Replies
12
Views
3K
  • Computing and Technology
Replies
6
Views
1K
  • Programming and Computer Science
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • Programming and Computer Science
Replies
32
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
2
Views
3K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top