Discussion:
[petsc-users] Use of DMDAVecGetArrayF90 and DMDAVecRestoreArrayF90
TAY wee-beng
2015-11-10 09:27:21 UTC
Permalink
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?

Also, must the array be restored using DMDAVecRestoreArrayF90 before
calling DMLocalToLocalBegin,DMLocalToLocalEnd?
--
Thank you.

Yours sincerely,

TAY wee-beng
Matthew Knepley
2015-11-10 12:27:10 UTC
Permalink
Post by TAY wee-beng
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.
Post by TAY wee-beng
Also, must the array be restored using DMDAVecRestoreArrayF90 before
calling DMLocalToLocalBegin,DMLocalToLocalEnd?
Yes.

Matt
Post by TAY wee-beng
--
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
TAY wee-beng
2015-11-10 12:30:54 UTC
Permalink
Post by TAY wee-beng
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?
Post by TAY wee-beng
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
Matthew Knepley
2015-11-10 12:47:37 UTC
Permalink
Post by Matthew Knepley
Post by TAY wee-beng
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.

Matt
Post by Matthew Knepley
Also, must the array be restored using DMDAVecRestoreArrayF90 before
Post by TAY wee-beng
calling DMLocalToLocalBegin,DMLocalToLocalEnd?
Yes.
Matt
Post by TAY wee-beng
--
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
Loading...