The hello_image.f90 sample is a hello world application. Unlike the usual hello world, this coarray Fortran program will spawn multiple images, or processes, that will run concurrently on the host computer. Examining the source code for this application shows a simple Fortran program:
program hello_image
write(*,*) "Hello from image ", this_image(), &
"out of ", num_images()," total images"
end program hello_image
Note the function calls to this_image() and num_images(). These are new Fortran 2008 intrinsic functions. The num_images() function returns the total number of images or processes spawned for this program. The this_image() function returns a unique identifier for each image in the range 1 to N, where N is the total number of images created for this program.
To compile the sample program containing the Coarray Fortran features, use the /Qcoarray:shared compiler option. This compiler option is already set in the project property pages dialog box.
Select Project > Properties. The project property pages dialog box appears.
In the project property pages dialog box, select Configuration Properties > Fortran > Language > Enable Coarrays and verify that For Shared Memory (/Qcoarray:shared) appears in the list box. Click OK to close the property pages dialog box.
Select Build > Build Solution to compile the source code into an application.
Select Debug > Start Without Debugging to run the application.
Your output should be similar to this:
Hello from image 3 out of 4 total images Hello from image 2 out of 4 total images Hello from image 1 out of 4 total images Hello from image 4 out of 4 total images
By default, when a Coarray Fortran application is compiled with the Intel Fortran Compiler, the invocation creates as many images as there are processor cores on the host platform. The example shown above was run on a dual quad-core host system with eight total cores. As shown, each image is a separately spawned process on the system and executes asynchronously.
Do not use the /Qcoarray option with the /Qopenmp option. You cannot mix Coarray Fortran and OpenMP language extensions.
Supplemental documentation specific to a particular Intel Studio may be available at <install-dir>\<studio>\documentation\ <install-dir>/<studio>/documentation/.