<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
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:<BR>
*********************************************************<BR>
<BR>
<BR>
ex19f.F:29.5:<BR>
call MPI_COMM_RANK(MPI_COMM_WORLD,myid,rc)<BR> 1<BR>Error: Non-numeric character in statement label at (1)<BR>ex19f.F:29.5:<BR>
call MPI_COMM_RANK(MPI_COMM_WORLD,myid,rc)<BR> 1<BR>Error: Unclassifiable statement at (1)<BR>ex19f.F:30.5:<BR>
call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,rc)<BR> 1<BR>Error: Non-numeric character in statement label at (1)<BR>ex19f.F:30.5:<BR>
call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,rc)<BR> 1<BR>Error: Unclassifiable statement at (1)<BR>make: *** [ex19f.o] Error 1<BR><BR>
*********************************************************<BR>
Following is the code I modified. The lines followed by !***************Added for MPI are added by me for MPI subroutine.<BR>
*********************************************************<BR>
!<BR>!<BR> program main<BR>! include 'mpif.h'<BR>#include "finclude/petscsys.h"<BR>#include "finclude/petscvec.h"<BR>!<BR>! This example demonstrates basic use of the PETSc Fortran interface<BR>! to vectors.<BR>!<BR> <BR> integer myid,numprocs,namelen,rc !***************Added for MPI<BR> PetscInt n<BR> PetscErrorCode ierr<BR> PetscTruth flg<BR> PetscScalar one,two,three,dot<BR> PetscReal norm,rdot<BR> Vec x,y,w<BR> <BR>
n = 20<BR> one = 1.0<BR> two = 2.0<BR> three = 3.0<BR>
call PetscInitialize(PETSC_NULL_CHARACTER,ierr) <BR> call PetscOptionsGetInt(PETSC_NULL_CHARACTER,'-n',n,flg,ierr)<BR> <BR> call MPI_COMM_RANK(MPI_COMM_WORLD,myid,rc) !***************Added for MPI<BR> call MPI_COMM_SIZE(MPI_COMM_WORLD,numprocs,rc) !***************Added for MPI<BR> <BR> <BR>
<BR>! Create a vector, then duplicate it<BR> call VecCreate(PETSC_COMM_WORLD,x,ierr)<BR> call VecSetSizes(x,PETSC_DECIDE,n,ierr)<BR> call VecSetFromOptions(x,ierr)<BR> call VecDuplicate(x,y,ierr)<BR> call VecDuplicate(x,w,ierr)<BR>
call VecSet(x,one,ierr)<BR> call VecSet(y,two,ierr)<BR>
call VecDot(x,y,dot,ierr)<BR> rdot = PetscRealPart(dot)<BR> write(6,100) rdot<BR> 100 format('Result of inner product ',f10.4)<BR>
call VecScale(x,two,ierr)<BR> call VecNorm(x,NORM_2,norm,ierr)<BR> write(6,110) norm<BR> 110 format('Result of scaling ',f10.4)<BR>
call VecCopy(x,w,ierr)<BR> call VecNorm(w,NORM_2,norm,ierr)<BR> write(6,120) norm<BR> 120 format('Result of copy ',f10.4)<BR>
call VecAXPY(y,three,x,ierr)<BR> call VecNorm(y,NORM_2,norm,ierr)<BR> write(6,130) norm<BR> 130 format('Result of axpy ',f10.4)<BR>
call VecDestroy(x,ierr)<BR> call VecDestroy(y,ierr)<BR> call VecDestroy(w,ierr)<BR> call PetscFinalize(ierr)<BR> end<BR><BR>                                            </body>
</html>