[petsc-users] DMGlobalToLocal acting weird

Smith, Barry F. bsmith at mcs.anl.gov
Mon Jul 2 17:04:51 CDT 2018


   First make sure that getCenterInfo(daScalars,  xstart, ystart, zstart, xend, yend, zend) returns what it should. 

   remove the 99 business and print out the arrtemp() and TO() values. Are they correct?

   What is DimTemperature? Shouldn't it be LocTempature?

   Print out the values in tdim().

   Barry




> On Jul 2, 2018, at 2:58 PM, Manuel Valera <mvalera-w at sdsu.edu> wrote:
> 
> Hi guys,
> 
> I've noticed a bug in my code that seems to happen right after a call to DMGlobalToLocalBegin/End and i can't seem to find a reason, it goes like this:
> 
> I create the DMDA (daScalars) with the following: 
> 
>  bx = DM_BOUNDARY_GHOSTED
>  by = DM_BOUNDARY_PERIODIC
>  bz = DM_BOUNDARY_GHOSTED
>  dof = 1
>  stw = 3
> call DMDACreate3d(PETSC_COMM_WORLD,bx,by,bz,DMDA_STENCIL_BOX,gridx,gridy,gridz,PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE, &                                dof,stw,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,daScalars,ierr)
> call DMSetFromOptions(daScalars,ierr)
> call DMSetUp(daScalars,ierr)
> 
> Then i read from a file the temperature and salinity fields of my problems, those two are giving the trouble, i do it with this template:
> 
> call DMCreateGlobalVector(daScalars,gTemperature,ierr)
> call DMDAVecGetArrayF90(daScalars,gTemperature,arrtemp,ierr)
>    arrtemp = 99.0d0      !no idea why this fixes the problem -mv 62518
> call getCenterInfo(daScalars,  xstart, ystart, zstart, xend, yend, zend)
>             do k=zstart,zend-1
>                 do j=ystart,yend-1
>                     do i=xstart,xend-1
>                         arrtemp(i,j,k) = T0(i+1,j+1,k+1)
>                     enddo
>                 enddo
>             enddo
> call DMDAVecRestoreArrayF90(daScalars,gTemperature,arrtemp,ierr)
> call DMCreateLocalVector(daScalars,LocTemperature,ierr)
> call DMGlobalToLocalBegin(daScalars,gTemperature,INSERT_VALUES,LocTemperature,ierr)
> call DMGlobalToLocalEnd(daScalars,gTemperature,INSERT_VALUES,LocTemperature,ierr)
> 
> 
> Now here is the first weirdness, if i assign a number to my array it does behave as it should for the global quantity, but it must be a greater number than the maximum of the field for this to happen, so i assign 99.0 arbitrarily, otherwise it doesn't read the array correctly, but it does as of now,
> 
> Next, the last two lines communicate the array to the local counterparts, but when i read LocTemperature with:
> 
>     call DMDAVecGetArrayReadF90(daScalars,DimTemperature,tdim,ierr)
>     print*,'Copied MinT0: ', minval(tdim)
>     call DMDAVecRestoreArrayReadF90(daScalars,DimTemperature,tdim,ierr)
> 
> That array minimum doesn't coincide with the global minimum, it should be 1.000 but it is just 0.000, the same happens with the Salinity following an identical approach,
> 
> Any ideas on where to start looking? i have last month's PETSc build,
> 
> I'm running in 1 processor for now,
> 
> Thanks,
> 
> Manuel
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 



More information about the petsc-users mailing list