Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Fortran Parallel Computing

ZeeshanKhan
Beginner
1,412 Views

Hi, Everybody

 

I am positing on this forum to seek some help, about the Parallel Computing with Fortran. I am a new student to this Language and wanted to use for doing some fluid simulations. To quick our simulations we are focusing on learning Fortran in Parallel Computing and have started from some basic. I am using the Visual Studio 2019 with API basic and HPC toolkit. I am running a simple program which would print Hello word from each processor in my PC. I am getting some errors and if you guys could help and let me know where I am doing the mistake. Please find the attached program 

 

" PROGRAM test
 use MPI

integer process_Rank, size_Of_Cluster, ierror

call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size_Of_Cluster, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, process_Rank, ierror)

DO i = 0, 3, 1
IF(i == process_Rank) THEN
print *, 'Hello World from process: ', process_Rank, 'of ', size_Of_Cluster
END IF
END DO

call MPI_FINALIZE(ierror)
END PROGRAM

"

 

Now I would illustrate the steps, I followed the link which "Configuring a Microsoft Visual Studion Project"  which is given on this link "https://www.intel.com/content/www/us/en/docs/mpi-library/developer-guide-windows/2021-6/configuring-a-microsoft-visual-studio-project.html"

 

I will outline the steps as 

  • At first I ran setvars.bat file
  • Then I did not make file for naming the nodes because I am not using a cluster, I am just using my own PC. 
  • Then after that I completed the frist three main steps which are given below 

    Command: $(I_MPI_ONEAPI_ROOT)\bin\mpiexec.exe

    Command arguments: -n <processes-number> "$(TargetPath)"

    Environment: PATH=$(I_MPI_ONEAPI_ROOT)\bin\$(ConfigurationName);$(I_MPI_ONEAPI_ROOT)\libfabric\bin;$(PATH)

 

   

  • In the foruth steps I did not find Intel MPI libraries and clicked it to yes because I installed VS community edition. therefore I went to the the following steps

 

  1. In Configuration Properties > C/C++ or Fortran, as appropriate, set the following parameter:

    Additional Include Directories: $(I_MPI_ONEAPI_ROOT)\include

  2. In Configuration Properties > Linker, set the following parameter:

    Additional Library Directories: $(I_MPI_ONEAPI_ROOT)\lib\$(ConfigurationName);$(I_MPI_ONEAPI_ROOT)\lib

  3. In Configuration Properties > Linker > Input, set the following parameters:

    • For Fortran, set Additional Dependencies: impi.lib
    • For C++, set Additional Dependencies: impi.lib and impicxx.lib

 

However, I am getting the following errors,

 

Severity Code Description Project File Line Suppression State
Error Compilation Aborted (code 1) C:\Users\zakmt\source\repos\test\test\test.f90 1

 

Severity Code Description Project File Line Suppression State
Error error #7881: This module file was generated for a different platform or by an incompatible compiler or compiler release. It cannot be read. [MPI] C:\Users\zakmt\source\repos\test\test\test.f90 2

 

 

if some one could help me and provide me a good guide lines, I would be extremely grateful. Also, if some one could give me a link to a book thorugh which I can learn.

 

Kind Regards

Zeeshan 

0 Kudos
7 Replies
jimdempseyatthecove
Honored Contributor III
1,399 Views

>> seek some help, about the Parallel Computing with Fortran...

>> I am running a simple program which would print Hello word from each processor in my PC....

 

Are you specifically interested in parallel computing on a single platform such as your PC. This would be on either your single CPU PC (with multiple cores/hardware threads), as well as a single workstation or server that may have multiple CPUs, each with multiple cores/hardware threads?

Or... multiple PC's and/or Workstations and/or servers networked together in a cluster?

 

In the former case, select OpenMP as opposed to MPI

In the latter case, even if initially on you single CPU PC for development, then select MPI (or combination of both).

 

The error message: Error error #7881: This module file was generated for a different platform...

Indicates that you INCLUDE path points to a folder containing modules (filenamenere.mod) that were built for a different platform (e.g. 32-bit verses 64-bit or possibly Intel architectures verses ARM architectures or Macintosh M-series).

It is likely that your environment for compiling test.f90 is using one of the bit nesses while the INCLUDE path contains the folder holding the other bit nesses files.

 

Jim Dempsey

0 Kudos
ZeeshanKhan
Beginner
1,389 Views

Hi,

 

I am using my single PC which is having the following specification and I have attached it. I am using my PC which is having 16 CPUS and I want to print that " Hellow Word" on all those processor. I have attached the specifications. Also how in which portion of I can select the libraries such as Open MP or MPI, coz I did not fine them. Can you please attach some snap from visual studion. I would be very thankful. Thank you so much for your help.

 

Kind Regards

Zeeshan Khan PC Specifications.png

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,344 Views

1) Launch MS Visual Studio

2) Select Fortran Main Code (then click Next)'

3) Optional: change name of program and/or location of program (default is OK for this simple test), click Create

You will see a single threaded Hello World.

4) Test it to confirm it builds and works

4.1) Place break point at end of program by clicking on the grey (colored) bar immediately to the left of the end program line. A red dot (or colored dot) will appear in the bar to indicate break.

4.2) Click the Tool Bar Start button. This should compile and run to the break point. The output will appear in the (black) pop-up console window. Note, had you not inserted a break point this console window would have popped-up, displayed, then closed when program terminated. IOW before you have a chance to see its output.

4.3) Click on the toolbar "Stop Debugging" button (usually red square button)

5) Edit the program such that it reads:

    program Console18
    use omp_lib
    implicit none

    ! Variables

    ! Body of Console18
    !$omp parallel
    print *, 'Hello World from thread:', omp_get_thread_num()
    !$omp end parallel

    end program Console18

Note, your program name may differ - leave your program name alone.

6) "But wait, there's more..."

7) Right click on the Project Name in the Solution Explorer pane (On my system this is the [Fo] Console18 line)

In the pop-up, select Properties (last entry)

9) Expand: |> Fortran

10) Select Language

11) Select "Process OpenMP Directives" (currently Disabled), then click Pull-Down button, select Generate Parallel Code

12) Click Apply, Click OK, Click Start button on tool bar

jimdempseyatthecove_0-1692101167381.png

 

13) make the following edits to make a simple example of doing some work:

program Console18
    use omp_lib
    implicit none
    ! Variables
    integer, parameter :: nX=100, nY=100, nZ=100
    integer :: iX, iY, iZ
    real, allocatable, dimension(:,:,:) :: pos
    ! Body of Console18
    allocate(pos(nX,nY,nZ))
    call RANDOM_NUMBER(pos)
    print *,"sum(pos):)", sum(pos)
    !$omp parallel do
    do iZ = 1, nZ
        do iY = 1, nY
            do iX = 1, nZ
                pos(iX, iY, iZ) = sqrt(pos(iX, iY, iZ))
            end do
        end do
    end do
    !$omp end parallel do
    print *,"sum(pos):)", sum(pos)

end program Console18

Note, with Fortran, the last dimension has the largest stride. Do your parallel partitioning using the last dimention .AND. have the first dimension be the inner most DO loop. As to provide best cache line usage as well as potential for vectorization optimizations.

 

Jim Dempsey

0 Kudos
JohnNichols
Valued Contributor III
1,325 Views

LOL, the super user of all super users just provided the best method, of course you could as the average user (me) does and make a cup a tea and wait for it to run in real time.

Just a thought.  

 

0 Kudos
Ron_Green
Moderator
1,308 Views

Intel MPI is only available for 64bit project types.  No 32bit.

In your Visual Studio, Change your configuration for x86 or ia32 to x64

0 Kudos
ZeeshanKhan
Beginner
1,305 Views

Hi Ron-Green,

 

Thank you so much for your kind response, I am working on it but after I follow your suggestion this is what I get. Could you guide me regarding this. I am also working on suggestions of other moderators and will mark accept as solution soon. 

 

Best 

Zeeshan Khan

 

Severity Code Description Project File Line Suppression State
Error error #7002: Error in opening the compiled module file. Check INCLUDE paths. [MPI] C:\Users\zakmt\source\repos\test\test\test.f90 2

0 Kudos
jimdempseyatthecove
Honored Contributor III
1,293 Views

Compiled module files (the output files with the .mod file type) are somewhat analogous to C++ pre-compiled headers.

This means that the folder that you generate the .mod files (and those provided in other libraries), must be in one of the INCLUDE paths.

 

Jim Dempsey

0 Kudos
Reply