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