<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-cite-prefix">On 21/11/2015 9:58 PM, Matthew Knepley
      wrote:<br>
    </div>
    <blockquote
cite="mid:CAMYG4Gku4X=LwD0v_VC8hjKuDtShi1naBi5NtrLagEb+4xGTXA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">On Sat, Nov 21, 2015 at 7:47 AM, TAY
            wee-beng <span dir="ltr"><<a moz-do-not-send="true"
                href="mailto:zonexo@gmail.com" target="_blank">zonexo@gmail.com</a>></span>
            wrote:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"> <br>
                <div>On 10/11/2015 8:47 PM, Matthew Knepley wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div class="gmail_extra">
                      <div class="gmail_quote">On Tue, Nov 10, 2015 at
                        6:30 AM, TAY wee-beng <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:zonexo@gmail.com"
                            target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:zonexo@gmail.com">zonexo@gmail.com</a></a>></span>
                        wrote:<br>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000"> <br>
                            <div>On 10/11/2015 8:27 PM, Matthew Knepley
                              wrote:<br>
                            </div>
                            <blockquote type="cite">
                              <div dir="ltr">
                                <div class="gmail_extra">
                                  <div class="gmail_quote">On Tue, Nov
                                    10, 2015 at 3:27 AM, TAY wee-beng <span
                                      dir="ltr"><<a
                                        moz-do-not-send="true"
                                        href="mailto:zonexo@gmail.com"
                                        target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:zonexo@gmail.com">zonexo@gmail.com</a></a>></span>
                                    wrote:<br>
                                    <blockquote class="gmail_quote"
                                      style="margin:0 0 0
                                      .8ex;border-left:1px #ccc
                                      solid;padding-left:1ex">Hi,<br>
                                      <br>
                                      Inside my subroutine, I need to
                                      access the DA variable
                                      cu_types_array frequently.<br>
                                      <br>
                                      So I need to call
                                      DMDAVecGetArrayF90 and
                                      DMDAVecRestoreArrayF90 before and
                                      after frequently.<br>
                                      <br>
                                      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?<br>
                                      <br>
                                      Will this cause memory corruption?<br>
                                    </blockquote>
                                    <div><br>
                                    </div>
                                    <div>You cannot use any other vector
                                      operations before you have called
                                      Restore.</div>
                                  </div>
                                </div>
                              </div>
                            </blockquote>
                            <br>
                            Hi,<br>
                            <br>
                            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?</div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>While you have the array, no other
                          operation can change the values.</div>
                      </div>
                    </div>
                  </div>
                </blockquote>
                Hi,<br>
                <br>
                Let me clarify this. I declare in this way:<br>
                <br>
                DM  da_cu_types<br>
                <br>
                Vec cu_types_local,cu_types_global<br>
                <br>
                PetscScalar,pointer :: cu_types_array(:,:,:)<br>
                <br>
                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),&<br>
                <br>
                (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)<br>
                <br>
                call
                DMCreateGlobalVector(da_cu_types,cu_types_global,ierr)<br>
                <br>
                call
                DMCreateLocalVector(da_cu_types,cu_types_local,ierr)<br>
                <br>
                So when I need to change the values in DA variable
                cu_types, I call:<br>
                <br>
                call
                DMDAVecGetArrayF90(da_cu_types,cu_types_local,cu_types_array,ierr)<br>
                <br>
                .... math operations, changing the values of
                cu_types_array, such as:<br>
                <br>
                cu_types_array = 0.d0<br>
                <br>
                call
                DMDAVecRestoreArrayF90(da_cu_types,cu_types_local,cu_types_array,ierr)<br>
                <br>
                1st of all, does these DMDAVecGetArrayF90 and
                DMDAVecRestoreArrayF90 take a lot of time, especially if
                I call them many times.<br>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>No.</div>
          </div>
        </div>
      </div>
    </blockquote>
    Hi,<br>
    <br>
    Another qn is supposed the sta_ijk_uniform and end_ijk_uniform
    change every time step. Hence I need to destroy the DM etc and
    re-create at each time step.<br>
    <br>
    If that's the case, will this slow down my code?<br>
    <br>
    Thanks.<br>
    <blockquote
cite="mid:CAMYG4Gku4X=LwD0v_VC8hjKuDtShi1naBi5NtrLagEb+4xGTXA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div class="gmail_extra">
          <div class="gmail_quote">
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"> Next qn is whether
                if I can call DMDAVecGetArrayF90 at the start, and
                DMDAVecRestoreArrayF90 after operations similar to the
                one above is finished.<br>
              </div>
            </blockquote>
            <div><br>
            </div>
            <div>You cannot do other Vec operations before you call
              Restore.</div>
            <div><br>
            </div>
            <div>  Matt</div>
            <div> </div>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div bgcolor="#FFFFFF" text="#000000"> Thanks.<br>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div class="gmail_extra">
                      <div class="gmail_quote">
                        <div><br>
                        </div>
                        <div>   Matt</div>
                        <div> </div>
                        <blockquote class="gmail_quote" style="margin:0
                          0 0 .8ex;border-left:1px #ccc
                          solid;padding-left:1ex">
                          <div bgcolor="#FFFFFF" text="#000000"> 
                            <blockquote type="cite">
                              <div dir="ltr">
                                <div class="gmail_extra">
                                  <div class="gmail_quote">
                                    <blockquote class="gmail_quote"
                                      style="margin:0 0 0
                                      .8ex;border-left:1px #ccc
                                      solid;padding-left:1ex"> Also,
                                      must the array be restored using
                                      DMDAVecRestoreArrayF90 before
                                      calling
                                      DMLocalToLocalBegin,DMLocalToLocalEnd?</blockquote>
                                    <div><br>
                                    </div>
                                    <div>Yes.</div>
                                    <div><br>
                                    </div>
                                    <div>  Matt</div>
                                    <div> </div>
                                    <blockquote class="gmail_quote"
                                      style="margin:0 0 0
                                      .8ex;border-left:1px #ccc
                                      solid;padding-left:1ex"><span><font
                                          color="#888888"><br>
                                          <span><font color="#888888">
                                              -- <br>
                                              Thank you.<br>
                                              <br>
                                              Yours sincerely,<br>
                                              <br>
                                              TAY wee-beng<br>
                                              <br>
                                            </font></span></font></span></blockquote>
                                    <span><font color="#888888"> </font></span></div>
                                  <span><font color="#888888"> <br>
                                      <br clear="all">
                                      <span class="HOEnZb"><font
                                          color="#888888">
                                          <div><br>
                                          </div>
                                          -- <br>
                                          <div>What most experimenters
                                            take for granted before they
                                            begin their experiments is
                                            infinitely more interesting
                                            than any results to which
                                            their experiments lead.<br>
                                            -- Norbert Wiener</div>
                                        </font></span></font></span></div>
                                <span class="HOEnZb"><font
                                    color="#888888"> </font></span></div>
                              <span class="HOEnZb"><font color="#888888">
                                </font></span></blockquote>
                            <span class="HOEnZb"><font color="#888888">
                                <br>
                              </font></span></div>
                          <span class="HOEnZb"><font color="#888888"> </font></span></blockquote>
                        <span class="HOEnZb"><font color="#888888"> </font></span></div>
                      <span class="HOEnZb"><font color="#888888"> <br>
                          <br clear="all">
                          <div><br>
                          </div>
                          -- <br>
                          <div>What most experimenters take for granted
                            before they begin their experiments is
                            infinitely more interesting than any results
                            to which their experiments lead.<br>
                            -- Norbert Wiener</div>
                        </font></span></div>
                  </div>
                </blockquote>
                <br>
              </div>
            </blockquote>
          </div>
          <br>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div class="gmail_signature">What most experimenters take for
            granted before they begin their experiments is infinitely
            more interesting than any results to which their experiments
            lead.<br>
            -- Norbert Wiener</div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>