<div dir="ltr"><div class="gmail_extra"><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"> Please clarify.<br>
<br>
1) You can successfully update to 3.8 and compile and run the code?</blockquote><div>I haven't updated all of the code to 3.8, I wanted to make sure there wasn't any tricks to maintain backwards compatibility before I change everything. I'm only in the process of changing several of the codebase's files, updating any "Amat = 0" statements or "if (Amat==0) then" statements, which do not compile with 3.8 (they need the specific PETSC_NULL_XXX instead of 0). When I make those changes, that section of the code compiles (btw, on NERSC Edison, with my own compiled petsc v3.8).</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
2) You do not have a way to support both 3.7 and 3.8 except by putting a large number of #ifdef in the code?<br></blockquote><div>If I have to change "Amat = 0" to "Amat = PETSC_NULL_MAT" for 3.8, and change all of the PETSC_NULL_OBJECT for 3.8, many of those PETSC_NULL_XXX references are not included in v3.7, correct? If not, and I want to keep backwards compatibility, everywhere there is a PETSC_NULL_OBJECT, I would have to do:</div><div>#include <petscversion.h></div><div>#if PETSC_VERSION_GE(3,8,0)</div><div>call MatNullSpaceCreate(comm, PETSC_TRUE, 0, PETSC_NULL_VEC, nullsp,ierr)</div><div>#else</div><div>call MatNullSpaceCreate(comm, PETSC_TRUE, 0, PETSC_NULL_OBJECT, nullsp,ierr)<br></div><div>#endif</div><div><br></div><div>If this is the only way to upgrade our codebase to use petsc v3.8, thats fine, I just wanted to verify that there wasn't another way, which would be cleaner (e.g. perhaps creating an include file with all of the PETSC_NULL_XXX definitions which aren't in v3.7, and thus avoid many of these #if PETSC_VERSION statements).</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Yes, 3.8 is a dramatic shift in API (to one we feel is much better), it is not simple to write code that works with both versions. We recommend just using a 3.8 version once you verify it behaves as the previous version. Note that on any computer including those at NERSc if 3.8 is not installed by default you may install it yourself.<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
Barry<br>
</font></span><div class="gmail-HOEnZb"><div class="gmail-h5"><br>
> On Oct 30, 2017, at 12:18 PM, Randy Michael Churchill <<a href="mailto:rchurchi@pppl.gov">rchurchi@pppl.gov</a>> wrote:<br>
><br>
> I'm updating my Fortran code to petsc 3.8. I have several modules with types, and often when a type is initialized in the code, there are certain Petsc variables that aren't ready to be initialized, so they are set to 0. Later, in several parts of the code, these are checked with and if statments, e.g.:<br>
><br>
> module modmat<br>
> #include <petsc/finclude/petsc.h><br>
> #include <petsc/finclude/petscmat.h><br>
> use petsc<br>
> use petscmat<br>
><br>
> type mymat<br>
> Mat :: Amat<br>
> end type mymat<br>
><br>
> contains<br>
> subroutine mymat_init(this)<br>
> this%Amat = 0<br>
> end subroutine mymat_init<br>
> end module modmat<br>
><br>
><br>
> program main<br>
> use modmat<br>
> implicit none<br>
> type(mymat)::mymat1<br>
><br>
> call mymat_init(mymat1)<br>
> call somethingamazing(mymat1)<br>
> end program main<br>
><br>
> subroutine somethingamazing(this)<br>
> use modmat<br>
> typ(mymat) :: this<br>
> if (this%Amat == 0) then<br>
> print 'Amat not initialized'<br>
> endif<br>
> end subroutine somethingamazing<br>
><br>
><br>
> However, with Petsc 3.8, if I set Amat to 0, I get the error:<br>
> error #6303: The assignment operation or the binary expression operation is invalid for the data types of the two operands.<br>
><br>
> I replaced the 0 with PETSC_NULL_MAT, but then the if statement gives an error:<br>
> error #6355: This binary operation is invalid for this data type.<br>
><br>
> I change the if statement to:<br>
> if (this%Amat == PETSC_NULL_MAT) then<br>
> and it compiles.<br>
><br>
> Is this the right way to update Fortran code to v3.8? Is there any alternative? My concern is we will have no backwards compatibility, because I believe the specific PETSC_NULL_XXX objects were only introduced in 3.8. So if we update to 3.8, we would either have to drop support for <3.8 or have a lot of #if PETSC_VERSION statements.<br>
><br>
> --<br>
> R. Michael Churchill<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">R. Michael Churchill</div></div>
</div></div>