VecCreate() does not take a size argument (perhaps you mean VecCreateSeq()?) hence when you try to get the size it is confused.
Barry > On Apr 13, 2017, at 8:29 PM, Lailai Zhu <[email protected]> wrote: > > Dear petsc developers and users, > > I am currently using fortran version of petsc 3.7.*. > I tried to define Mat or Vec variables in a user-defined structure like below, > > module myMOD > type, public :: myStr > Mat A > Vec x,b > end type myStr > > interface myStr !! user-defined constructor > module procedure new_Str > end interface myStr > > contains > function new_Str() > type(myStr) :: new_Str > call VecCreate(petsc_comm_self,10,new_str%x,ierr) > call vecgetsize(new_str%x, size, ierr) > end function new_Str > > end module myMOD > > > then i define an instance of myStr in another file like below > > type(myStr),save :: mystr1 > mystr1 = myStr() > > It compiles and the veccreate executes without problem, however error occurs > on the vecgetsize part, > telling me > > [0]PETSC ERROR: --------------------- Error Message > -------------------------------------------------------------- > [0]PETSC ERROR: Null argument, when expecting valid pointer > [0]PETSC ERROR: Null Object: Parameter # 1 > [0]PETSC ERROR: See http://www.mcs.anl.gov/petsc/documentation/faq.html for > trouble shooting. > [0]PETSC ERROR: Petsc Release Version 3.7.5, Jan, 01, 2017 > [0]PETSC ERROR: ./nek5000 on a pet3.7.5-mpich-intel named quququ by user Thu > Apr 13 21:11:05 2017 > [0]PETSC ERROR: Configure options --with-c++-support > --with-shared-libraries=1 --known-mpi-shared-libraries=1 --with-batch=0 > --with-mpi=1 --with-debugging=1 -download-fblaslapack=1 --download-blacs=1 > --download-scalapack=1 --download-plapack=1 --with-cc=mpicc --with-cxx=mpicxx > --with-fc=mpifort --download-dscpack=1 > [0]PETSC ERROR: #1 VecGetSize() line 667 in > /home/user/petsc/3.7.5/mpich_intel/src/vec/vec/interface/vector.c > > It seems to me that the petsc vector x belong to the derived type variable is > recognized in the veccreate subroutine, but > not known by the vecgetsize one. Is there way to work this around? or perhaps > one cannot use petsc objects in such ways? > Thanks in advance, > > best, > lailai
