Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Dinhle__Anh
Beginner
1,136 Views

Run a Serial Fortran code with multiple cores?

Hi experts, 

I make a CFD code by fortran language, a serial code.

I just build a worstation with 2 Xeon E5-26xxv3. So, I want to run the code with multiple cores/threads. I know there is the auto parallel command: "ifort -parallel name-of-program.f"

I'm a new bird using fortan compiler. So, I would like to ask you some questions:

1. Can a serial code run with multiple cores?

2. Can submit the batch job to specify the number of cores use for serial code?

Thank you very much,

0 Kudos
25 Replies
Steve_Lionel
Black Belt Retired Employee
98 Views

John Campbell wrote:
I think the reason you are not getting OMP performance is your "!$OMP" might not be recognised in a fixed format file. (I no longer use fixed format)

This is not the case - !$OMP works fine in fixed-form.

John_Campbell
New Contributor II
98 Views

Steve,

For fixed format, should !$OMP be in columns 1:5 and !$OMP& in columns 1:6 ?

Also, can the command extend beyond column 72 ?

Steve_Lionel
Black Belt Retired Employee
98 Views

The Language Reference is quite explicit about the rules:

In fixed form, the first line of the directive {initial line} has the directive prefix is in columns 1 through 5 and has a blank, a tab, or a zero in column 6; each continued line of the directive has the directive prefix in columns 1 through 5 and has a character other than a blank, a tab, or a zero in column 6.

And, no, the directive cannot extend past column 72 in fixed-form unless you have used /extend_source.

Dinhle__Anh
Beginner
98 Views

John,

I am so surprised that you tried to run above sample code, because it is not full code with missing of many parts (sorry I cannot upload the full code). Thank you very much for your time.

I modified my real full code with some optimization on the code structure, do loop in subroutines. The calculation time increased (not much) in serial run (from 4~5 minutes/20000 iterations to 2~3 minutes/20000 iterations). Here I care about the calculation speed because the time to use the workstation are limited for each user.

After that, I run with openMP code based on your suggestions. The calculation speed was still almost same. Maybe the parallel calculation cannot show the improvement for such small number of grid point (279 x 70) or maybe I made the wrong BATCH job for openMP.

Next, I will try a test run with larger grid point. If it is still no difference, I would try to make a better code structure (change the index position as Jim's comment in Quote #16).

Thank John and Jim,

Best regards,

Le

jimdempseyatthecove
Black Belt
98 Views

>>change the index position

That will affect vectorization not parallelization. Meaning single thread code as well as parallel code will run faster in those sections. It may also mean that the parallel code portion (now running faster) becomes a smaller portion of time of the total runtime.

Figure out the cause for the peculiarity with parallel vs serial before you make the additional optimization changes.

Jim Dempsey

Reply