There are two methods to control the number of images created for a Coarray Fortran application. First, you can use the -coarray-num-images=N compiler option to compile the application, where N is the number of images. This option sets the number of images created for the application during run time. For example, use the -coarray-num-images=2 option to the limit the number of images of the hello_image.f90 program to exactly two:
ifort -coarray -coarray-num-images=2 hello_image.f90 -o hello_image
Hello from image 2 out of 2 total images Hello from image 1 out of 2 total images
The second way to control the number of images is to use the environment variable FOR_COARRAY_NUM_IMAGES, setting this to the number of images you want to spawn.
As an example, recompile hello_image.f90 without the -coarray-num-images option. Instead, before we run the executable hello_image, set the environment variable FOR_COARRAY_NUM_IMAGES to the number of images you want created during the program run.
For bash shell users, set the environment variable with this command: export FOR_COARRAY_NUM_IMAGES=4
For csh/tcsh shell users, set the environment variable with this command: setenv FOR_COARRAY_NUM_IMAGES 4
For example, assuming bash shell:
ifort -coarray hello_image.f90 -o hello_image
export FOR_COARRAY_NUM_IMAGES=4
Hello from image 1 out of 4 total images Hello from image 3 out of 4 total images Hello from image 2 out of 4 total images Hello from image 4 out of 4 total images
export FOR_COARRAY_NUM_IMAGES=3
Hello from image 3 out of 3 total images Hello from image 2 out of 3 total images Hello from image 1 out of 3 total images
Setting FOR_COARRAY_NUM_IMAGES=N overrides the -coarray_num_images compiler option.
Copyright © 2011, Intel Corporation. All rights reserved.