I’m struggling to figure out *undefined reference to `vectorset_*. I’ve
included both  petscvec.h and petscvec.h90 but the error appears again.
I’m attaching makefile and code. any help will be appreciated.

On Thu, Jan 14, 2016 at 9:39 PM, Matthew Knepley <[email protected]> wrote:

> On Thu, Jan 14, 2016 at 12:03 AM, praveen kumar <[email protected]>
> wrote:
>
>> I’ve written a fortan code (F90)  for domain decomposition.* I've
>> specified **the paths of include files and libraries, but the
>> compiler/linker still *
>>
>>
>> *complained about undefined references.undefined reference to
>> `vectorset_'*
>>
>
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Vec/VecSet.html
>
>
>>
>> *undefined reference to `dmdagetlocalinfo_'*
>>
>
> This function is not supported in Fortran since it takes a structure.
>
>   Thanks,
>
>     Matt
>
>
>> I’m attaching makefile and code. any help will be appreciated.
>>
>
>
>
> --
> What most experimenters take for granted before they begin their
> experiments is infinitely more interesting than any results to which their
> experiments lead.
> -- Norbert Wiener
>

Attachment: makefile
Description: Binary data

       program main
       implicit none
#include <petsc/finclude/petscsys.h>
#include <petsc/finclude/petscvec.h>
#include <petsc/finclude/petscvecdef.h>
#include <petsc/finclude/petscmat.h>
#include <petsc/finclude/petscpc.h>
#include <petsc/finclude/petscksp.h>
#include <petsc/finclude/petscdmda.h>
#include <petsc/finclude/petscdm.h>
#include <petsc/finclude/petscdmda.h90>
#include <petsc/finclude/petscvec.h90>
#include <petsc/finclude/petscmat.h90>
	 
       PetscErrorCode ierr
       PetscScalar v, one
       Vec x, b
       Mat A
       DM da
       KSP ksp
       DMDALocalInfo info 
       MPI_Comm comm
       
       !integer :: stw,dof 
       PetscInt  i,j,II,JJ,m,n,its
       PetscInt  Istart,Iend,ione
       !PetscReal aione
       PetscBool   flg

	
       call PetscInitialize(PETSC_NULL_CHARACTER,ierr)
       comm = PETSC_COMM_WORLD
       m = 3
       n = 3
       ione = 1
       one = 0
       call PetscOptionsGetInt(PETSC_NULL_CHARACTER,'-m',m,flg,ierr)
       call PetscOptionsGetInt(PETSC_NULL_CHARACTER,'-n',n,flg,ierr)
       !stw=1
       !dof=1

	!!DMDA
       
       CALL DMDACreate2d(comm,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,m,n,PETSC_DECIDE,PETSC_DECIDE,1,1,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da,ierr)
       
	
       CALL DMDASetUniformCoordinates(da,0,1,0,1,0,0,ierr)
	
       !call DMDAGetLocalInfo(da,info,ierr)
       !double hx = 1/info.m
       !double hy = 1/info.n
	
	!!MATRIX
       call MatCreate(PETSC_COMM_WORLD,A,ierr)
       call MatSetSizes(A,PETSC_DECIDE,PETSC_DECIDE,m*n,m*n,ierr)
       call MatSetFromOptions(A,ierr)
       call MatSetUp(A,ierr)
       call MatGetOwnershipRange(A,Istart,Iend,ierr)
       do 10, II=Istart,Iend-1
       v = -1.0
       i = II/n
       j = II - i*n
       if (i.gt.0) then
          JJ = II - n
          call MatSetValues(A,ione,II,ione,JJ,v,INSERT_VALUES,ierr)
       endif
       if (i.lt.m-1) then
          JJ = II + n
          call MatSetValues(A,ione,II,ione,JJ,v,INSERT_VALUES,ierr)
       endif
       if (j.gt.0) then
          JJ = II - 1
          call MatSetValues(A,ione,II,ione,JJ,v,INSERT_VALUES,ierr)
       endif
       if (j.lt.n-1) then
          JJ = II + 1
          call MatSetValues(A,ione,II,ione,JJ,v,INSERT_VALUES,ierr)
       endif
        v = 4.0
       call  MatSetValues(A,ione,II,ione,II,v,INSERT_VALUES,ierr)
 10   continue

       call MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY,ierr)
       call MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY,ierr)

	!!VECTOR

       call DMCreateGlobalVector(da,x,ierr)
       call DMCreateGlobalVector(da,b,ierr)
       call VectorSet(b,one,ierr)

	!!KSP

       call KSPCreate(comm,ksp,ierr)
       call KSPSetOperators(ksp,A,A,DIFFERENT_NONZERO_PATTERN,ierr)
       call KSPSetFromOptions(ksp,ierr)
       call KSPSolve(ksp,b,x,ierr)
	!save("u.vtk",da,x,ierr)
       call KSPGetIterationNumber(ksp,its,ierr)
	!KSPPrint(comm,
	
	!!Destroy

       call KSPDestroy(ksp,ierr)
       call VecDestroy(x,ierr)
       call VecDestroy(b,ierr)
       call MatDestroy(A,ierr)
       call DMDestroy(da,ierr)
	
	


	
       call PetscFinalize(ierr)
       
       end program main

Reply via email to