0

I decided to ask this question after quite a surfing and reading through google and stackoverflow and doing some experiments in Fortran on my quad core machine with Ubuntu 12.04 and finally finding myself back to square one. So this is how the whole story goes.

Having acquired some basic knowledge about parallel computing, I decided to go for open mp. I could find a tutorial for beginner however could not proceed beyond lesson number one as my computer never created more than one thread even after using commands given in the first chapter. I then searched on stackoverflow.com and found a post which gives a solution of calling omp_set_dynamic(0). However, after typing this on my terminal, gives a following error:

bash: syntax error near unexpected token `0'

so I had to leave this too!

After this, I moved to this site and thought that this was it! But after going till first exercise, I found no way to proceed as I could not even run the model Fortran program given there as it gave the following error.

/tmp/ccaqbCe0.o: In function `MAIN__':
first_open_mp.f95:(.text+0xa): undefined reference to `omp_get_thread_num_'
first_open_mp.f95:(.text+0x9c): undefined reference to `omp_get_num_threads_'
collect2: ld returned 1 exit status

Now I find myself completely helpless about all this. Is there any way, by which I can logically learn open mp at least and make use of all cores in my machine? I am pretty desperate about learning it and any help is highly appreciated.

Thanks in advance.

Community
  • 1
  • 1
Peaceful
  • 4,920
  • 15
  • 54
  • 79

1 Answers1

0

OpenMP is not standard Fortran. You must study the manual of your compiler how to enable this extension and of whether is possible at all. Some compilers don't even support OpenMP.

You still did not specify which compiler you use so I can't be more specific. Gfortran has the -fopenmp option. Many other compilers have the -openmp option.

BTW find some less prehistoric tutorial. Specifically, something that uses Fortran 90 and the omp_lib module to call the procedures. But even more I suggest you to use the environment variables where possible. My 60 000 lines of code parallel solver needs to call this module only in very small number of places to get the number of threads and the current thread number.

  • Well I use f95 to compile my code. However, what I really want is the actual place where I can learn these things step by step. I appreciate your answer but I don't understand it. – Peaceful Dec 10 '14 at 09:03
  • Stackoverflow is not a place for tutorial recommendation. Asking just for this is a reason to close the question. – Vladimir F Героям слава Dec 10 '14 at 09:07
  • I don't know. Fortran is installed on my computer so I write my codes in fortran 95 and compile them as: f95 -o file.out file.f95. – Peaceful Dec 10 '14 at 09:11
  • It does. Using built-in specs. COLLECT_GCC=f95 COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6/lto-wrapper Target: i686-linux-gnu Thread model: posix gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) – Peaceful Dec 10 '14 at 09:13
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/66553/discussion-between-snehal-shekatkar-and-vladimir-f). – Peaceful Dec 10 '14 at 09:15
  • 1
    So it is gfortran version 4.6.3, not some "f95", remember it and reference it in your next questions. The manual for the most recent version is https://gcc.gnu.org/onlinedocs/gfortran/ , other versions are at https://gcc.gnu.org/onlinedocs/ . The OpenMP manual is https://gcc.gnu.org/onlinedocs/libgomp/ – Vladimir F Героям слава Dec 10 '14 at 09:16
  • There are numerous books and tutorials. You may try looking here http://www.ucs.cam.ac.uk/docs/course-notes/unix-courses/OpenMP – Vladimir F Героям слава Dec 10 '14 at 09:17