@@ -50,63 +50,62 @@ while OpenCoarrays supports the same program's calls to collective subrouine suc
50
50
Inserting the "bin" directory of the chosen installation path into the user's PATH enables the following
51
51
CAF program compilation and execution workflow:
52
52
53
- $ cat sum_image_numbers.f90
54
- program main
55
- use iso_c_binding, only : c_int
56
- use iso_fortran_env, only : error_unit
57
- implicit none
58
- integer(c_int) :: tally
59
- tally = this_image() ! this image's contribution
60
- call co_sum(tally)
61
- verify: block
62
- integer(c_int) :: image
63
- if (tally/=[ (image,image=1,num_images())] ) then
64
- write(error_unit,'(a,i5)') "Incorrect tally on image ",this_image()
65
- erro stop
66
- end if
67
- end block verify
68
- ! Wait for all images to pass the test
69
- sync all
70
- if (this_image()==1) print * ,"Test passed"
71
- end program
72
-
73
- $ caf sum_image_numbers.f90
74
- $ cafrun -np 4 ./sum_image_numbers
75
- Test passed.
76
-
77
- where "4" is the number of images to be launched at program star-up.
78
-
79
- ### <a name =" advancedworkflow " >Sample advanced workflows</a > ###
80
-
81
- 1 . <a name =" aware " >Use with an OpenCoarrays-aware compiler</a > (e.g., GCC 5.1.0):
82
- A hello.f90 program can compiled in a single step using the following string:
83
-
84
- mpif90 -fcoarray=lib -L/opt/opencoarrays/ hello.f90 \ -lcaf_mpi -o hello
85
-
86
- For running the program:
87
-
88
- mpirun -np m ./hello
89
-
90
- 2 . <a name =" noncaf " >Use with an non-OpenCoarrays-aware compiler</a > (e.g., gfortran 4.9):
91
- If a user's compiler provides limited or no coarray support, the user can directly reference a
92
- subset of the OpenCoarrays procedures and types through a Fortran module named "opencoararys"
93
- in the "mod" subdirectory of the user's chosen OpenCoarrays installation path. The module
94
- provides wrappers for some basic Fortran 2008 parallel programming capabilities along with some
95
- more advanced features that have been proposed for Fortran 2015 in the draft Technical
96
- Specification TS18508 Additional Parallel Features in Fortran (visit www.opencoarrays.org for a
97
- link to this document, which gets updated periodically). An example of the use of the opencoarrays
98
- Fortran module is in the tally_images_numbers.F90 file in the test suite. The following commands
99
- compile that program:
100
-
101
- cd src/tests/integration/extensions/
102
- mpif90 -L /opt/opencoarrays/lib/ -I /opt/opencoarrays/mod/ -fcoarray=lib tally_image_numbers.f90 -lcaf_mpi -o tally
103
- mpirun -np 8 ./tally
104
-
105
- 3 . <a name =" nonaware " >Use with an non-OpenCoarrays-aware compiler</a > (e.g., Intel or Cray):
106
-
107
- <a name =" executing-a-caf-program " >
108
- ## Executing a CAF Program ##
109
- </a >
53
+ $ cat sum_image_numbers.f90
54
+ program main
55
+ use iso_c_binding, only : c_int
56
+ use iso_fortran_env, only : error_unit
57
+ implicit none
58
+ integer(c_int) :: tally
59
+ tally = this_image() ! this image's contribution
60
+ call co_sum(tally)
61
+ verify: block
62
+ integer(c_int) :: image
63
+ if (tally/=[(image,image=1,num_images())]) then
64
+ write(error_unit,'(a,i5)') "Incorrect tally on image ",this_image()
65
+ error stop
66
+ end if
67
+ end block verify
68
+ ! Wait for all images to pass the test
69
+ sync all
70
+ if (this_image()==1) print *,"Test passed"
71
+ end program
72
+
73
+ ```
74
+ $ caf sum_image_numbers.f90
75
+ $ caf sum_image_numbers.f90
76
+ $ cafrun -np 4 ./sum_image_numbers
77
+ Test passed.
78
+ ```
79
+ where "4" is the number of images to be launched at program start-up.
80
+
81
+ <a name =" sample-advanced-workflow " >
82
+ ### Sample advanced workflows</a > ###
83
+
84
+ <a name="Extending a non-OCA CAF COmpiler
85
+ ## Extending a Non-OCA CAF Compiler</a > ##
86
+
87
+ To extend the capabilities of a non-OCA CAF compiler (e.g., the Intel or Cray compilers)
88
+ or a non-CAF compiler (e.g., GCC 4.9), access the types and procedures of the
89
+ [ opencoarrays module] by use assocication. For example, insert the following at line 2
90
+ in the above example:
91
+
92
+ use opencoarrays, only : co_sum
93
+
94
+ Then compile with the "caf" compiler wrapper and launch with "cafrun" program launcher.
95
+
96
+ <a name =" compiling-without-caf " >
97
+ ## Sample Advanced Workflow</a > ##
98
+
99
+ If the "caf" compiler wrapper cannot process the source code in question, invoke
100
+ the underlying communication library directly:
101
+
102
+ mpif90 -fcoarray=lib -L/opt/opencoarrays/ hello.f90 \ -lcaf_mpi -o hello -I<OpenCoarrays-install-path>/mod
103
+
104
+ and also run the program with the lower-level commnication library:
105
+
106
+ mpirun -np <number-of-images> ./hello
107
+
108
+
110
109
111
110
[ Sourcery Store ] : http://www.sourceryinstitute.org/store
112
111
[ Virtualbox ] : http://www.virtualbox.org
0 commit comments