<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi Matt,</p>
    <p>My previous test is terminated after calling subroutine A as
      shown below. <br>
    </p>
    <p>>> In Subroutine A<br>
    </p>
    <p>      call
      DMPlexDistribute(dmda_flow%da,stencil_width,                &<br>
                                  PETSC_NULL_SF,distributedMesh,ierr)<br>
            CHKERRQ(ierr)</p>
    <p>      if (distributedMesh /= PETSC_NULL_DM) then</p>
    <p>        call DMDestroy(dmda_flow%da,ierr)<br>
              CHKERRQ(ierr)<br>
              !c set the global mesh as distributed mesh<br>
              dmda_flow%da = distributedMesh<br>
    </p>
    <p><font color="#ff0000">        call
        DMDestroy(distributedMesh,ierr)              <br>
      </font></p>
    <p><font color="#ff0000">       !If </font><font color="#ff0000"><font
          color="#ff0000">DMDestroy(distributedMesh,ierr)</font> called,
        then everything is destroyed and there is nothing output with </font><font
        color="#ff0000">-malloc_test. However, I got error in the next
        subroutine [0]PETSC ERROR: DMGetCoordinatesLocal() line 5545 in
        /home/dsu/Soft/PETSc/petsc-dev/src/dm/interface/dm.c Object
        already free: Parameter # 1</font></p>
    <p><font color="#ff0000">        CHKERRQ(ierr)</font></p>
    <p>     end if</p>
    <p>>> In Subroutine B    <br>
    </p>
    <p>      !c get local mesh DM and set coordinates<br>
      <br>
            call DMGetCoordinatesLocal(dmda_flow%da,gc,ierr)<br>
            CHKERRQ(ierr)<br>
      <br>
            call DMGetCoordinateDM(dmda_flow%da,cda,ierr)<br>
            CHKERRQ(ierr)<br>
    </p>
    <p><font color="#ff0000"><font color="#000000">Thanks,</font><br>
      </font></p>
    <p>Danyang<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 2019-10-10 6:15 p.m., Matthew
      Knepley wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAMYG4GmeJoMcUUBVxrwdcuTN9Si_GT88yRBZ_9g0+R1DR2VhXg@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">
        <div dir="ltr"><br>
          <div>On Thu, Oct 10, 2019 at 9:00 PM Danyang Su <<a
              href="mailto:danyang.su@gmail.com" moz-do-not-send="true">danyang.su@gmail.com</a>>
            wrote:<br>
          </div>
        </div>
        <div class="gmail_quote">
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            <div bgcolor="#FFFFFF">
              <blockquote type="cite">
                <div dir="ltr">
                  <div class="gmail_quote">
                    <div>Labels should be destroyed with the DM. Just
                      make a small code that does nothing but distribute
                      the mesh and end. If you</div>
                    <div>run with -malloc_test you should see if
                      everythign is destroyed properly.</div>
                    <div><br>
                    </div>
                    <div>  Thanks,</div>
                    <div><br>
                    </div>
                    <div>    Matt <br>
                    </div>
                  </div>
                </div>
              </blockquote>
              <p>Attached is the output run with -malloc_test using 2
                processor. It's a big file. How can I quick check if
                something is not properly destroyed?</p>
            </div>
          </blockquote>
          <div>Everything output has not been destroyed. It looks like
            you did not destroy the distributed DM.</div>
          <div><br>
          </div>
          <div>  Thanks,</div>
          <div><br>
          </div>
          <div>    Matt </div>
          <blockquote class="gmail_quote" style="margin:0px 0px 0px
            0.8ex;border-left:1px solid
            rgb(204,204,204);padding-left:1ex">
            <div bgcolor="#FFFFFF">
              <p>Thanks,</p>
              <p>Danyang</p>
            </div>
          </blockquote>
        </div>
        -- <br>
        <div dir="ltr" class="gmail_signature">
          <div dir="ltr">
            <div>
              <div dir="ltr">
                <div>
                  <div dir="ltr">
                    <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>
                    <div><br>
                    </div>
                    <div><a href="http://www.cse.buffalo.edu/~knepley/"
                        target="_blank" moz-do-not-send="true">https://www.cse.buffalo.edu/~knepley/</a><br>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
  </body>
</html>