[petsc-users] (no subject)

Peter Wang pengxwang at hotmail.com
Fri Oct 8 21:33:40 CDT 2010


I am trying to modify the example code in  {PETSc_Dir}\src\vec\vec\examples\tests\ex19f.F . Only three lines are added into the original code.   However, if the three lines are added, there is error coming out when it is compiled.  Why it cannot be compiled when the lines are added?  I am using gfortran 4.4.3 and openMPI 1.3.2  and petsc 3.1-p5-v1.  The error infomation is as following:
*********************************************************
 
 
ex19f.F:29.5:
    call MPI_COMM_RANK(MPI_COMM_WORLD,myid,rc)
     1
Error: Non-numeric character in statement label at (1)
ex19f.F:29.5:
    call MPI_COMM_RANK(MPI_COMM_WORLD,myid,rc)
     1
Error: Unclassifiable statement at (1)
ex19f.F:30.5:
    call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,rc)
     1
Error: Non-numeric character in statement label at (1)
ex19f.F:30.5:
    call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,rc)
     1
Error: Unclassifiable statement at (1)
make: *** [ex19f.o] Error 1

*********************************************************
Following is the code I modified. The lines followed by !***************Added for MPI are added by me for MPI subroutine.
*********************************************************
!
!
      program main
!  include 'mpif.h'
#include "finclude/petscsys.h"
#include "finclude/petscvec.h"
!
!  This example demonstrates basic use of the PETSc Fortran interface
!  to vectors.
!
 
       integer myid,numprocs,namelen,rc  !***************Added for MPI
       PetscInt  n
       PetscErrorCode ierr
       PetscTruth flg
       PetscScalar      one,two,three,dot
       PetscReal        norm,rdot
       Vec              x,y,w
 
       n     = 20
       one   = 1.0
       two   = 2.0
       three = 3.0
       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)                  
       call PetscOptionsGetInt(PETSC_NULL_CHARACTER,'-n',n,flg,ierr)
 
    call MPI_COMM_RANK(MPI_COMM_WORLD,myid,rc)      !***************Added for MPI
    call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,rc)  !***************Added for MPI
  
   

! Create a vector, then duplicate it
       call VecCreate(PETSC_COMM_WORLD,x,ierr)
       call VecSetSizes(x,PETSC_DECIDE,n,ierr)
       call VecSetFromOptions(x,ierr)
       call VecDuplicate(x,y,ierr)
       call VecDuplicate(x,w,ierr)
       call VecSet(x,one,ierr)
       call VecSet(y,two,ierr)
       call VecDot(x,y,dot,ierr)
       rdot = PetscRealPart(dot)
       write(6,100) rdot
  100  format('Result of inner product ',f10.4)
       call VecScale(x,two,ierr)
       call VecNorm(x,NORM_2,norm,ierr)
       write(6,110) norm
  110  format('Result of scaling ',f10.4)
       call VecCopy(x,w,ierr)
       call VecNorm(w,NORM_2,norm,ierr)
       write(6,120) norm
  120  format('Result of copy ',f10.4)
       call VecAXPY(y,three,x,ierr)
       call VecNorm(y,NORM_2,norm,ierr)
       write(6,130) norm
  130  format('Result of axpy ',f10.4)
       call VecDestroy(x,ierr)
       call VecDestroy(y,ierr)
       call VecDestroy(w,ierr)
       call PetscFinalize(ierr)
       end
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20101008/c1851dc8/attachment.htm>


More information about the petsc-users mailing list