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

I'm struggling with the coarray implementation in Intel Fortran Compiler (IFX) 2024 and Visual Studi

michael76
Novice
639 Views

Hello Everybody,

I'm learning Fortran and in particular try to run the coarray functionality; I'm trying to run the code available in the oneAPI tutorial but I'still in trible after two days.

Before debugging the code I have initialized oneApi with the setvars.bat command and the operation was succesful with the message SETVARS_COMPLETED=1.

I also set the environment variable PATH to the path of the compiler:  C:\Program Files (x86)\Intel\oneAPI\compiler\2024.0\bin

 

The debug options are set as follows:

In project properties -> Language:


- Use file extensions
-1 32 columns
- Enable alternate PARAMETER syntax
- Generate parallel code (/Qopenmp)
- Generate Parallel Code (/Qiopenmp)
- Enable coarray: for shared memory (/Qcoarray:shared)
- Coarray Images: 6

 

The output of debugging is the following (note the exit code at the end):

 

 

'coarray02.exe' (Win32): Loaded 'C:\Users\Z2Workstation\source\repos\coarray02\coarray02\x64\Debug\coarray02.exe'. Symbols loaded.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\ntdll.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\kernel32.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\KernelBase.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\imagehlp.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\ucrtbase.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Program Files (x86)\Intel\oneAPI\compiler\2024.0\bin\libiomp5md.dll'. Symbols loaded.
'coarray02.exe' (Win32): Loaded 'C:\Program Files (x86)\Intel\oneAPI\compiler\2024.0\bin\libicaf.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\vcruntime140.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\intel\Shared Libraries\bin\impi.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\ws2_32.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\rpcrt4.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\advapi32.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\msvcrt.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\sechost.dll'.
'coarray02.exe' (Win32): Loaded 'C:\Windows\System32\bcrypt.dll'.
The thread 20924 has exited with code 1090191 (0x10a28f).
The thread 20660 has exited with code 1090191 (0x10a28f).
The thread 25960 has exited with code 1090191 (0x10a28f).
The program '[19524] coarray02.exe' has exited with code 1090191 (0x10a28f).

 

And last the code taken from the tutorial:

 

program mcpi

! This program demonstrates using Fortran coarrays to implement the classic
! method of computing the mathematical value pi using a Monte Carlo technique.
!
! Compiler options: /Qcoarray
!                   -coarray 
!

implicit none

! Declare kind values for large integers, single and double precision
integer, parameter :: K_BIGINT = selected_int_kind(15)
integer, parameter :: K_DOUBLE = selected_real_kind(15,300)

! Number of trials per image. The bigger this is, the better the result
! This value must be evenly divisible by the number of images.
integer(K_BIGINT), parameter :: num_trials = 600000000_K_BIGINT

! Actual value of PI to 18 digits for comparison
real(K_DOUBLE), parameter :: actual_pi = 3.141592653589793238_K_DOUBLE

! Declare scalar coarray that will exist on each image
 integer(K_BIGINT) :: total[*] ! Per-image subtotal

! Local variables
real(K_DOUBLE) :: x,y
real(K_DOUBLE) :: computed_pi
integer :: i
integer(K_BIGINT) :: bigi
integer(K_BIGINT) :: clock_start,clock_end,clock_rate
integer, allocatable :: seed_array(:)
integer :: seed_size

! Image 1 initialization
if (THIS_IMAGE() == 1) then
    ! Make sure that num_trials is divisible by the number of images
    if (MOD(num_trials,INT(NUM_IMAGES(),K_BIGINT)) /= 0_K_BIGINT) &
        error stop "Number of trials not evenly divisible by number of images!"
    print '(A,I0,A,I0,A)', "Computing pi using ",num_trials," trials across ",NUM_IMAGES()," images"
    call SYSTEM_CLOCK(clock_start)
end if

! Set the initial random number seed to an unpredictable value, with a different
! sequence on each image. 
call RANDOM_INIT(.FALSE.,.TRUE.) 

! Initialize our subtotal
total = 0_K_BIGINT

! Run the trials, with each image doing its share of the trials.
!
! Get a random X and Y and see if the position is within a circle of radius 1. 
! If it is, add one to the subtotal
do bigi=1_K_BIGINT,num_trials/int(NUM_IMAGES(),K_BIGINT)
    call RANDOM_NUMBER(x)
    call RANDOM_NUMBER(y)
    if ((x*x)+(y*y) <= 1.0_K_DOUBLE) total = total + 1_K_BIGINT
end do

! Wait for everyone
sync all

! Image 1 end processing
if (this_image() == 1) then
    ! Sum subtotals of all images
    do i=2,num_images()
        total = total + total[i]
    end do

    ! total/num_trials is an approximation of pi/4
    computed_pi = 4.0_K_DOUBLE*(REAL(total,K_DOUBLE)/REAL(num_trials,K_DOUBLE))
    print '(A,G0.8,A,G0.3)', "Computed value of pi is ", computed_pi, &
        ", Relative Error: ",ABS((computed_pi-actual_pi)/actual_pi)
    ! Show elapsed time
    call SYSTEM_CLOCK(clock_end,clock_rate)
    print '(A,G0.3,A)', "Elapsed time is ", &
        REAL(clock_end-clock_start)/REAL(clock_rate)," seconds"
end if
    
end program mcpi

 

I will be very gratefull if someone can help me with this issue.

 

Fabio

0 Kudos
1 Solution
Steve_Lionel
Honored Contributor III
582 Views

As it happens, I wrote that tutorial. I can reproduce the problem if I build inside Visual Studio, whether Debug or Release. ifx or ifort. But if I build from the oneAPI build command line it runs fine:

D:\Projects\Console11>ifx /Qcoarray /Qcoarray-num-images:6 console11.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.0.2 Build 20231213
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 14.39.33522.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:console11.exe
-subsystem:console
console11.obj

D:\Projects\Console11>console11.exe
Computing pi using 600000000 trials across 6 images
Computed value of pi is 3.1416696, Relative Error: .245E-04
Elapsed time is 2.43 seconds

(I don't know why you added those other options - they're not necessary, but they are harmless.)

This problem was reported before in Coarray does not work after updating to intel fortran 2024 - Intel Community  The problem is that the Intel installer does not properly update the system PATH environment variable. To fix this:

  1. On your desktop, right click on This PC and select Properties.
  2. Under System > Related Links, click Advanced System Settings
  3. Click Environment Variables...
  4. Under System variables, select PATH and click Edit
  5. Click New.
  6. In the blank line that appears, paste: C:\Program Files (x86)\Intel\oneAPI\mpi\latest\opt\mpi\libfabric\bin
  7. Repeat steps 5-6, but paste C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin
  8. Examine the list of values and look for C:\Program Files (x86)\Intel\oneAPI\compiler\latest\bin  If you don't see it, add it as you did the others.
  9. Click OK, OK, OK.

You should now be able to run the coarray program in Visual Studio or even a bare command prompt.

View solution in original post

0 Kudos
6 Replies
Steve_Lionel
Honored Contributor III
583 Views

As it happens, I wrote that tutorial. I can reproduce the problem if I build inside Visual Studio, whether Debug or Release. ifx or ifort. But if I build from the oneAPI build command line it runs fine:

D:\Projects\Console11>ifx /Qcoarray /Qcoarray-num-images:6 console11.f90
Intel(R) Fortran Compiler for applications running on Intel(R) 64, Version 2024.0.2 Build 20231213
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.

Microsoft (R) Incremental Linker Version 14.39.33522.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:console11.exe
-subsystem:console
console11.obj

D:\Projects\Console11>console11.exe
Computing pi using 600000000 trials across 6 images
Computed value of pi is 3.1416696, Relative Error: .245E-04
Elapsed time is 2.43 seconds

(I don't know why you added those other options - they're not necessary, but they are harmless.)

This problem was reported before in Coarray does not work after updating to intel fortran 2024 - Intel Community  The problem is that the Intel installer does not properly update the system PATH environment variable. To fix this:

  1. On your desktop, right click on This PC and select Properties.
  2. Under System > Related Links, click Advanced System Settings
  3. Click Environment Variables...
  4. Under System variables, select PATH and click Edit
  5. Click New.
  6. In the blank line that appears, paste: C:\Program Files (x86)\Intel\oneAPI\mpi\latest\opt\mpi\libfabric\bin
  7. Repeat steps 5-6, but paste C:\Program Files (x86)\Intel\oneAPI\mpi\latest\bin
  8. Examine the list of values and look for C:\Program Files (x86)\Intel\oneAPI\compiler\latest\bin  If you don't see it, add it as you did the others.
  9. Click OK, OK, OK.

You should now be able to run the coarray program in Visual Studio or even a bare command prompt.

0 Kudos
michael76
Novice
505 Views

Thank you for the suggestions: after a careful re-installation, I found the PATH addresses to be already correct. Unfortunately, the issue persists: the build completes without any errors or warnings, but the executable file is not generated. Are there any other settings to verify?

 

Fabio (aka Michael76)

0 Kudos
Ron_Green
Moderator
569 Views

The earlier bug report on this is supposed to be fixed in the upcoming 2024.1 Update release. 

0 Kudos
Steve_Lionel
Honored Contributor III
546 Views

Ron, does it correctly add both RTL folders, both 64-bit MPI folders (plural), and any 32-bit folders still supported for CAF (if any)?

0 Kudos
Steve_Lionel
Honored Contributor III
491 Views

This is a new symptom - before you had an EXE. First - open the "Intel oneAPI command prompt for Intel 64" from the start menu and use the command I showed above to build the program, then try to run it. What happens?

Now do Start and type CMD - when "Command Prompt" appears, click it to open. Change default (cd command) to a folder you can write to, and type:

set path > path.txt

Attach path.txt to a reply here.

0 Kudos
michael76
Novice
490 Views

I solved the issue. After repairing Visual Studio, the (your) code run smoothly and correctly. Now I will continue my learning. Thank you again for your support.

 

Fabio (Michael76)

Reply