Building and Running the Coarray Version

The Intel® Fortran Compiler requires that the coarray features are enabled by specifying the /Qcoarray option. In Microsoft Visual Studio*, set the project property to Fortran > Language > Enable Coarrays to For Shared Memory and then click OK.

Use Build > Build Solution to build the application, then Debug > Start Without Debugging to run it. On a four-core, eight-thread processor you should see:

Computing pi using 600000000 trials across 8 images
Computed value of pi is 3.1416575, Relative Error: .206E-04
Elapsed time is 4.21 seconds

The program can be run with fewer images. Set the project property to Fortran > Language > Coarray Images to 4. (The command line option for this is: /Qcoarray-num-images:4.) Build and run the program. You should see:

Computing pi using 600000000 trials across 4 images
Computed value of pi is 3.1415352, Relative Error: .183E-04
Elapsed time is 5.53 seconds

The time goes up because the work is now spread across four physical cores.

Note

You can control the number of images through the environment variable: FOR_COARRAY_NUM_IMAGES.

For more complete information about compiler optimizations, see our Optimization Notice.