12.07.2015 Views

PGI User's Guide

PGI User's Guide

PGI User's Guide

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 13. Programming Considerations for 64-Bit Environments!$omp parallel!$omp dodo i = 1, mdo j = 1, nc(i,j) = a(i,j) + b(i,j)enddoenddo!$omp dodo i=1,mdo j = 1, nd = 30000.0D0*dble(i)+dble(j)+dble(j)if(d .ne. c(i,j)) thenprint *,"err i=",i,"j=",jprint *,"c(i,j)=",c(i,j)print *,"d=",dstopendifenddoenddo!$omp end parallelprint *, "M =",M,", N =",Nprint *, "c(M,N) = ", c(m,n)endWhen compiled with the PGFORTRAN compiler using –mcmodel=medium:% pgfortran –mp –o mat mat.f –i8 –mcmodel=medium% setenv OMP_NUM_THREADS 2% matM = 16000 , N = 16000c(M,N) = 480032000.0000000Large Array and Small Memory Model in FortranThe following example uses large, dynamically-allocated arrays. The code is divided into a main andsubroutine so you could put the subroutine into a shared library. Dynamic allocation of large arrays savesspace in the size of executable and saves time initializing data. Further, the routines can be compiled with 32-bit compilers, by just decreasing the parameter size.Example 13.3. Large Array and Small Memory Model in Fortran% cat mat_allo.f90program mat_allointeger i, jinteger size, m, nparameter (size=16000)parameter (m=size,n=size)double precision, allocatable::a(:,:),b(:,:),c(:,:)allocate(a(m,n), b(m,n), c(m,n))do i = 100, m, 1do j = 100, n, 1a(i,j) = 10000.0D0 * dble(i) + dble(j)b(i,j) = 20000.0D0 * dble(i) + dble(j)enddoenddocall mat_add(a,b,c,m,n)print *, "M =",m,",N =",n173

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!