2

I'm using gfortran compiler and trying to work on parallel programming without MPI. Even though, I spent too much time on reading about Fortran, gfortran, parallel programming, I couldn't do anything to use different processors at the same time.

My purpose is to create a matrix multiplication working on different processor to reduce the time. I have many ideas to do that but first of all, I have to use different processors. But even I use written codes, my computer have only one image. For example:

program hello_image

integer::a

  write(*,*) "Hello from image ", this_image(), &
              "out of ", num_images()," total images"

    read(*,*), a

end program hello_image

This is a very simple program took from a pdf about parallel programming in Fortran. It should give the output:

Hello from image 1 out of 8
Hello from image 2 out of 8
Hello from image 3 out of 8
Hello from image 4 out of 8
Hello from image 5 out of 8
Hello from image 6 out of 8
Hello from image 7 out of 8
Hello from image 8 out of 8

But my compiler is just giving the output:

Hello from image 1 out of 1.

I use gfortran as a compiler with the command

gfortran "codename" -fcoarray=single

I spent too much time to solve this "probably simple problem" but I just couldn't solve it.

This is the output I got when I try -fcoarray=lib. That's why I was using -fcoarray=single because it is the only one that can be executed. What should I do to solve this? Thank you for help;

/tmp/ccvnPvRc.o: In function `MAIN__':
hew.f08:(.text+0x62): undefined reference to `_gfortran_caf_this_image'
hew.f08:(.text+0xa8): undefined reference to `_gfortran_caf_num_images'
/tmp/ccvnPvRc.o: In function `main':
hew.f08:(.text+0x175): undefined reference to `_gfortran_caf_init'
hew.f08:(.text+0x19f): undefined reference to `_gfortran_caf_finalize'
collect2: error: ld returned 1 exit status

Even though, I installed linuxbrew from the website of OpenCoarrays, still having the same issue. brew doctor says there is no problem at all but when I use the line

gfortran hew.f08 -fcoarray=lib -lcaf_mpi

same error appears. Should I use another package with another line? What is the package which I should download? How to download it? How to use gfortran to have a executable file? (I'm using Ubuntu)

I used

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install)"

line to install. Then, I used both of the lines for setting the path;

PATH=/home/[username]/.linuxbrew/bin:$PATH
PATH=/home/linuxbrew/.linuxbrew/bin:$PATH

Now, when I use the line

gfortran hew.f08 -fcoarray=lib -lcaf_mpi

The output is:

/usr/bin/ld: cannot find -lcaf_mpi
collect2: error: ld returned 1 exit status
Lito
  • 17
  • 2
  • 1
    You've asked for a single image by saying `-fcoarray=single` -- this is why there's only one image involved. You need to use `-fcoarray=lib`. See [here](https://gcc.gnu.org/wiki/CoarrayLib) for some details. (Note that you'll quite possibly want to use the mpi based library to enable >1 image). – d_1999 Jul 25 '17 at 15:48
  • 1
    If you look at the page I linked to you should see that when using `lib` version you probably also need to link the **lib** (rary) that you intend to use to provide the coarray functionality, for example adding `-lcaf_mpi` to the compile+link command should mean you're using the mpi "backend". You can then use `mpiexec` to launch the job. – d_1999 Jul 25 '17 at 16:24
  • You may also find [this](https://github.com/sourceryinstitute/opencoarrays/blob/master/GETTING_STARTED.md) useful – d_1999 Jul 25 '17 at 16:43
  • You hafve to get that library and link with that library. d_1999 already told you that. Have you read his link? Get OpenCoarrays http://www.opencoarrays.org/. – Vladimir F Героям слава Jul 27 '17 at 18:31
  • I edited my main question because of terminal lines. I am checking your links right now. I downloaded linuxbrew but issue continues. Is it enough to have linuxbrew for -fcoarray=lib function? – Lito Jul 28 '17 at 15:51
  • Still couldn't solve the issue. I'd appreciate any help. – Lito Jul 30 '17 at 16:28
  • What exactly did you install? Did you do the appropriate `brew install ...` – Vladimir F Героям слава Jul 30 '17 at 17:57
  • I edited the main question. Thank you for your interest. – Lito Jul 30 '17 at 18:16
  • So you did not install the OpenCoarrays. Yoou **must** install the OpenCoarrays. The linuxbrew does NOT contain them. You must install OpenCoarrays **from linuxbrew** (or any other way). Please read the documentation. The command is `brew install something`. You must find which `something` you should put there. – Vladimir F Героям слава Jul 30 '17 at 20:17
  • Why did you even chose linuxbrew? Why don't you just install the Ubuntu package? https://qa.debian.org/popcon.php?package=open-coarrays – Vladimir F Героям слава Jul 30 '17 at 20:18

0 Answers0