HP-MPI User's Guide (11th Edition)
Example applications
multi_par.f
Appendix A 259
c*************************************************************
*********
subroutine compcolumn(nrow,ncol,array,rbs,rbe,cbs,cbe)
c
c This subroutine:
c does summations of columns in a thread.
c
implicit none
integer nrow ! # of rows
integer ncol ! # of columns
double precision array(nrow,ncol) ! compute region
integer rbs ! row block start
subscript
integer rbe ! row block end
subscript
integer cbs ! column block start
subscript
integer cbe ! column block end
subscript
c
c Local variables
c
integer i,j
c
c The OPENMP directive below allows the compiler to split
the
c values for "j" between a number of threads. By making i
and j
c private, each thread works on its own range of columns
"j",
c and works down each column at its own pace "i".
c
c Note no data dependency problems arise by having the
threads all
c working on different columns simultaneously.
c
C$OMP PARALLEL DO PRIVATE(i,j)
do j=cbs,cbe
do i=max(2,rbs),rbe
array(i,j)=array(i-1,j)+array(i,j)
enddo
enddo
C$OMP END PARALLEL DO
end
c*************************************************************
*********
subroutine comprow(nrow,ncol,array,rbs,rbe,cbs,cbe)
c
c This subroutine:
c does summations of rows in a thread.
c