Solving G95 Coarray Test Code Compile Error

  • Thread starter Thread starter natski
  • Start date Start date
  • Tags Tags
    Code Test
AI Thread Summary
The discussion centers on a compilation issue with a Fortran program using coarrays in the g95 compiler. The user encounters linker errors indicating undefined references to intrinsic functions related to image handling, such as `_g95_this_image` and `_g95_sync_all`. The response highlights that these errors suggest the program compiled successfully, but the linker cannot find the necessary library containing the required functions. It is suggested that the user may have either failed to specify the correct library in the compilation command or misconfigured their g95 setup, potentially using mismatched versions of the compiler and libraries.
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.
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
12
Views
3K
Replies
22
Views
3K
Replies
8
Views
2K
Replies
2
Views
3K
Replies
1
Views
3K
Back
Top