[petsc-users] PetscCommGetNewTag issue

Barry Smith bsmith at mcs.anl.gov
Tue Jan 6 19:57:24 CST 2015


> On Jan 6, 2015, at 7:21 PM, Jed Brown <jed at jedbrown.org> wrote:
> 
> Fande Kong <fd.kong at siat.ac.cn> writes:
> 
>> Hi all,
>> 
>> I make a very simple code, but run into some error messages.
>> 
>> Code:
>> 
>> #include <petsc.h>
>> static char help[] = " simple test.\n\n";
>> 
>> #undef __FUNCT__
>> #define __FUNCT__ "main"
>> int main(int argc,char **argv)
>> {
>>  PetscMPIInt                   tag = 0;
>>  PetscErrorCode                ierr;
>> 
>>  ierr = PetscInitialize(&argc,&argv,(char *)0,help);CHKERRQ(ierr);
> 
> The error message is not ideal, but the pattern used in PETSc is that
> each object should PetscCommDuplicate(usercomm,&mycomm,&first_tag).  If
> you need more tags, you would pass "mycomm" to PetscCommGetNewTag().

   The point is that you should never be sending messages on PETSC_COMM_WORLD, since they could collide with someone else messages, you should always send messages only on your own comm (that no one else has access to and could send message on) thus you should never be getting tags on PETSC_COMM_WORLD.

  Barry

> 
>>  ierr = PetscCommGetNewTag(PETSC_COMM_WORLD,&tag);CHKERRQ(ierr);
>>  ierr = PetscPrintf(PETSC_COMM_SELF," tag %d \n", tag);CHKERRQ(ierr);
>>  ierr = PetscFinalize();CHKERRQ(ierr);
>> }



More information about the petsc-users mailing list