<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Thanks, Jed.  I did think the static
      numbering looked pretty kludgy when I started messing with the
      DMShell Fortran stubs.  I'll switch to the new system.<br>
      <br>
      --Richard<br>
      <br>
      On 1/9/13 8:37 PM, Jed Brown wrote:<br>
    </div>
    <blockquote
cite="mid:CAM9tzSmKPk-hHiJRdH-yopz9njFRnP0=xN-aF0S6faS8OnxhPQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">Richard, I pushed a new Fortran callback handling
        system. It is subtype-safe and doesn't rely on crazy static
        numbering. You can see what is left to do by
        <div><br>
        </div>
        <div>$ grep AllocateFortran src/**/*.c</div>
        <div><br>
        </div>
        <div>Once these are gone, we can delete the old system.</div>
        <div><br>
        </div>
        <div>Meanwhile, you can add new functions using the system here.
          The Set call will create a callback ID if it doesn't exist yet
          and the object will automatically handle resizing and
          resetting when you change subtypes.<br>
          <div><br>
          </div>
          <div><a moz-do-not-send="true"
href="https://bitbucket.org/petsc/petsc-dev/commits/f2a68b8a037edffd463d1ee6e9014e2edcd4aad7"
              target="_blank">https://bitbucket.org/petsc/petsc-dev/commits/f2a68b8a037edffd463d1ee6e9014e2edcd4aad7</a><br>
          </div>
          <div><br>
          </div>
          <div>a couple more instances:</div>
          <div><br>
          </div>
          <div><a moz-do-not-send="true"
href="https://bitbucket.org/petsc/petsc-dev/commits/bc94ac15bf5a75c3290770efe7e624a46ddcad37"
              target="_blank">https://bitbucket.org/petsc/petsc-dev/commits/bc94ac15bf5a75c3290770efe7e624a46ddcad37</a><br>
          </div>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Mon, Jan 7, 2013 at 5:48 PM, Jed
          Brown <span dir="ltr"><<a moz-do-not-send="true"
              href="mailto:jedbrown@mcs.anl.gov" target="_blank">jedbrown@mcs.anl.gov</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Richard, it's better to mail the list. No, we
              haven't reworked subtype Fortran pointers yet, but I think
              we know what needs to be done.</div>
            <div class="HOEnZb">
              <div class="h5">
                <div class="gmail_extra"><br>
                  <br>
                  <div class="gmail_quote">
                    On Mon, Jan 7, 2013 at 1:42 PM, Richard Tran Mills <span
                      dir="ltr"><<a moz-do-not-send="true"
                        href="mailto:rtm@eecs.utk.edu" target="_blank">rtm@eecs.utk.edu</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">
                        <div>Hi Jed,<br>
                          <br>
                          I am back at work after some extended time
                          away and I need to start messing with DMShell
                          so that I can use it to set operations like
                          LocalToGlobal and GlobalToLocal updates from
                          inside PFLOTRAN.<br>
                          <br>
                          Did this issue of handling the Fortran
                          function pointers get resolved somehow?  Is
                          there something I need to change in how I am
                          doing the Fortran bindings?<br>
                          <br>
                          Cheers,<br>
                          Richard
                          <div>
                            <div><br>
                              <br>
                              On 12/4/12 5:43 PM, Jed Brown wrote:<br>
                            </div>
                          </div>
                        </div>
                        <div>
                          <div>
                            <blockquote type="cite">
                              <div>As usual, anything that is duplicated
                                and not checked by the compiler is
                                broken.<br>
                                <br>
                                <font face="courier new, monospace">$
                                  grep
                                  PetscObjectAllocateFortranPointers
                                  src/**/*.c                            
                                                                       
                                                                       
                                           </font></div>
                              <div><font face="courier new, monospace">src/dm/impls/da/ftn-custom/zda2f.c:

 PetscObjectAllocateFortranPointers(*da,6);</font></div>
                              <div><font face="courier new, monospace">src/dm/impls/da/ftn-custom/zda2f.c:

 PetscObjectAllocateFortranPointers(*da,6);</font></div>
                              <div><font face="courier new, monospace">src/dm/impls/shell/ftn-custom/zdmshellf.c:

 PetscObjectAllocateFortranPointers(*dm,2);</font></div>
                              <div><font face="courier new, monospace">src/dm/impls/shell/ftn-custom/zdmshellf.c:

 PetscObjectAllocateFortranPointers(*dm,2);</font></div>
                              <div><br>
                              </div>
                              <div>Note that changing the type does not
                                reset the function pointers, thus having
                                a DMSHELL, calling DMSetType(dm,DMDA),
                                and then setting a DMDA local function
                                will cause memory corruption.</div>
                              <div><br>
                              </div>
                              <div>I cannot express how much I hate this
                                system. The full-blown solution is that
                                for each type, we register a (global)
                                token which is the index of that
                                function pointer. That doesn't have any
                                false dependencies, but is more
                                "initialize" code.</div>
                              <div><br>
                              </div>
                              <div>An alternative, used in the TS and
                                KSP code below, is to have a common enum
                                that lists all the Fortran functions.
                                It's a false header dependency, but not
                                a binary dependency.</div>
                              <div><br>
                              </div>
                              <div> What should we do? The current state
                                is a disaster.</div>
                              <div><br>
                              </div>
                              <div><font face="courier new, monospace">src/ksp/ksp/impls/gmres/fgmres/ftn-custom/zmodpcff.c:

 PetscObjectAllocateFortranPointers(*ksp,3);</font></div>
                              <div><font face="courier new, monospace">src/ksp/ksp/interface/ftn-custom/zitfuncf.c:

 PetscObjectAllocateFortranPointers(*ksp,FTN_MAX);</font></div>
                              <div><font face="courier new, monospace">src/ksp/ksp/interface/ftn-custom/zitfuncf.c:

 PetscObjectAllocateFortranPointers(*ksp,FTN_MAX);</font></div>
                              <div><font face="courier new, monospace">src/ksp/pc/impls/mg/ftn-custom/zmgfuncf.c:

                                   
                                   PetscObjectAllocateFortranPointers(*mat,1);</font></div>
                              <div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:

 PetscObjectAllocateFortranPointers(*pc,5);</font></div>
                              <div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:

 PetscObjectAllocateFortranPointers(*pc,5);</font></div>
                              <div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:

 PetscObjectAllocateFortranPointers(*pc,5);</font></div>
                              <div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:

 PetscObjectAllocateFortranPointers(*pc,5);</font></div>
                              <div><font face="courier new, monospace">src/ksp/pc/impls/shell/ftn-custom/zshellpcf.c:

 PetscObjectAllocateFortranPointers(*pc,5);</font></div>
                              <div><font face="courier new, monospace">src/mat/impls/mffd/ftn-custom/zmffdf.c:

 PetscObjectAllocateFortranPointers(*mat,2);</font></div>
                              <div><font face="courier new, monospace">src/mat/impls/shell/ftn-custom/zshellf.c:

 PetscObjectAllocateFortranPointers(*mat,11);</font></div>
                              <div><font face="courier new, monospace">src/mat/interface/ftn-custom/zmatrixf.c:

 PetscObjectAllocateFortranPointers(*sp,1);</font></div>
                              <div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:

 PetscObjectAllocateFortranPointers(*snes,14);</font></div>
                              <div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:

 PetscObjectAllocateFortranPointers(*snes,14);</font></div>
                              <div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:

 PetscObjectAllocateFortranPointers(*snes,14);</font></div>
                              <div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:

 PetscObjectAllocateFortranPointers(*snes,14);</font></div>
                              <div><font face="courier new, monospace">src/snes/interface/ftn-custom/zsnesf.c:

 PetscObjectAllocateFortranPointers(*snes,14);</font></div>
                              <div><font face="courier new, monospace">src/snes/linesearch/impls/shell/ftn-custom/zlinesearchshellf.c:

 PetscObjectAllocateFortranPointers(*linesearch,3);</font></div>
                              <div><font face="courier new, monospace">src/snes/linesearch/interface/ftn-custom/zlinesearchf.c:

 PetscObjectAllocateFortranPointers(*linesearch,3);</font></div>
                              <div><font face="courier new, monospace">src/snes/linesearch/interface/ftn-custom/zlinesearchf.c:

 PetscObjectAllocateFortranPointers(*linesearch,3);</font></div>
                              <div><font face="courier new, monospace">src/sys/draw/utils/ftn-custom/zzoomf.c:

 PetscObjectAllocateFortranPointers(*draw,1);</font></div>
                              <div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:

 PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
                              <div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:

 PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
                              <div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:

                                   
                                   PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
                              <div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:

                                   
                                   PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
                              <div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:

 PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
                              <div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:

 PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
                              <div><font face="courier new, monospace">src/ts/interface/ftn-custom/ztsf.c:

 PetscObjectAllocateFortranPointers(*ts,OUR_COUNT);</font></div>
                            </blockquote>
                            <br>
                            <br>
                          </div>
                        </div>
                        <span><font color="#888888">
                            <pre cols="74">-- 
Richard Tran Mills, Ph.D.
Computational Earth Scientist      | Joint Assistant Professor
Hydrogeochemical Dynamics Team     | EECS and Earth & Planetary Sciences
Oak Ridge National Laboratory      | University of Tennessee, Knoxville
E-mail: <a moz-do-not-send="true" href="mailto:rmills@ornl.gov" target="_blank">rmills@ornl.gov</a>  V: <a moz-do-not-send="true" href="tel:865-241-3198" value="+18652413198" target="_blank">865-241-3198</a> <a moz-do-not-send="true" href="http://climate.ornl.gov/%7Ermills" target="_blank">http://climate.ornl.gov/~rmills</a>
</pre>
                          </font></span></div>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </div>
            </div>
          </blockquote>
        </div>
        <br>
      </div>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Richard Tran Mills, Ph.D.
Computational Earth Scientist      | Joint Assistant Professor
Hydrogeochemical Dynamics Team     | EECS and Earth & Planetary Sciences
Oak Ridge National Laboratory      | University of Tennessee, Knoxville
E-mail: <a class="moz-txt-link-abbreviated" href="mailto:rmills@ornl.gov">rmills@ornl.gov</a>  V: 865-241-3198 <a class="moz-txt-link-freetext" href="http://climate.ornl.gov/~rmills">http://climate.ornl.gov/~rmills</a>
</pre>
  </body>
</html>