On Sat, Nov 21, 2015 at 7:47 AM, TAY wee-beng <[email protected]> wrote:
> > On 10/11/2015 8:47 PM, Matthew Knepley wrote: > > On Tue, Nov 10, 2015 at 6:30 AM, TAY wee-beng <[email protected]> wrote: > >> >> On 10/11/2015 8:27 PM, Matthew Knepley wrote: >> >> On Tue, Nov 10, 2015 at 3:27 AM, TAY wee-beng < <[email protected]> >> [email protected]> wrote: >> >>> Hi, >>> >>> Inside my subroutine, I need to access the DA variable cu_types_array >>> frequently. >>> >>> So I need to call DMDAVecGetArrayF90 and DMDAVecRestoreArrayF90 before >>> and after frequently. >>> >>> Is this necessary? Can I call DMDAVecGetArrayF90 at the start and only >>> call DMDAVecRestoreArrayF90 towards the end, where I don't need to modify >>> the values of cu_types_array anymore? >>> >>> Will this cause memory corruption? >>> >> >> You cannot use any other vector operations before you have called Restore. >> >> >> Hi, >> >> What do you mean by vector operations? I will just be doing some maths >> operation to change the values in cu_types_array. Is that fine? >> > > While you have the array, no other operation can change the values. > > Hi, > > Let me clarify this. I declare in this way: > > DM da_cu_types > > Vec cu_types_local,cu_types_global > > PetscScalar,pointer :: cu_types_array(:,:,:) > > call > DMDACreate3d(MPI_COMM_WORLD,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DM_BOUNDARY_NONE,DMDA_STENCIL_STAR,(end_ijk_uniform(1) > - sta_ijk_uniform(1) + 1),(end_ijk_uniform(2) - sta_ijk_uniform(2) + 1),& > > (end_ijk_uniform(3) - sta_ijk_uniform(3) + > 1),PETSC_DECIDE,PETSC_DECIDE,PETSC_DECIDE,1,stencil_width_IIB,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,PETSC_NULL_INTEGER,da_cu_types,ierr) > > call DMCreateGlobalVector(da_cu_types,cu_types_global,ierr) > > call DMCreateLocalVector(da_cu_types,cu_types_local,ierr) > > So when I need to change the values in DA variable cu_types, I call: > > call DMDAVecGetArrayF90(da_cu_types,cu_types_local,cu_types_array,ierr) > > .... math operations, changing the values of cu_types_array, such as: > > cu_types_array = 0.d0 > > call DMDAVecRestoreArrayF90(da_cu_types,cu_types_local,cu_types_array,ierr) > > 1st of all, does these DMDAVecGetArrayF90 and DMDAVecRestoreArrayF90 take > a lot of time, especially if I call them many times. > No. > Next qn is whether if I can call DMDAVecGetArrayF90 at the start, and > DMDAVecRestoreArrayF90 after operations similar to the one above is > finished. > You cannot do other Vec operations before you call Restore. Matt > Thanks. > > > Matt > > >> >> >> Also, must the array be restored using DMDAVecRestoreArrayF90 before >>> calling DMLocalToLocalBegin,DMLocalToLocalEnd? >> >> >> Yes. >> >> Matt >> >> >>> >>> -- >>> Thank you. >>> >>> Yours sincerely, >>> >>> TAY wee-beng >>> >>> >> >> >> -- >> 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 >> >> >> > > > -- > 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 > > > -- 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
