I'm having a bit of trouble getting some code to 1) run and 2) parallelize. First, I started running a bit of code with the Intel Fortran (ifort, the most recent) compiler and there was an issue (core dump). The Intel help pages informed me that I need to run the openmp with dynamic linking (even though that seems to be the default). So, in all of my make files where I saw -openmp, I put in
since I'm running this through a Mac terminal. Now, I start running the program and everything is merry until I decide to add in parallelization sites. The bottom line is, it's not parallelizing with the "-link=dynamic" added. I also checked this on another computer to check if my source files were heading to the right place.
So, my question to all of the far more expert programmers is how do I get the program to run correctly and parallelize? If I take out the "-link=dynamic" everything works splendidly (i.e. numbers other than zeros come up for the thread number in the sample program below and the system usage application lights up like a pinball machine). But in the other, larger program, I can't get rid of the dynamic linking libraries and get it to parallelize and work...so there's a bit of a dilemma.
Below is a sample test code I've been running to see if things are working. When the code is parallelized, it will post from which thread the print command was made. If it's not parallelized, then everything is zeros or the number of threads. If there's some other way to avoid the problem (I apologize for not keeping the link) other than to add "-link=dynamic" then we should try that too.
I can't thank you enough for just reading this. I definitely appreciate any thoughts you might have. Please let me know if there's something else that might help solve this.
Ifort defaults to linking against the dynamic OpenMP library, so your openmp-link flag is redundant (if spelled correctly). If misspelled, it will be taken as an unintended over-ride for your output file name, which no doubt is confusing you. I suspect that the -openmp-link flag doesn't cause -openmp option to be set implicitly. -liomp5 -lpthread options also are redundant when you use ifort -openmp to link. The linux/mac Fortran forum is the place to ask questions which may not be covered adequately in the docs, if your subject fits there. You really should stick closer to the recommendations of the compiler and MKL docs (including the link advisor at the top of the MKL forum), at least until you have a working base to depart from.