[petsc-users] VecGetArray vs. VecGetArrayReadF90

Smith, Barry F. bsmith at mcs.anl.gov
Mon Apr 9 16:57:02 CDT 2018



> On Apr 9, 2018, at 4:51 PM, Sanjay Govindjee <s_g at berkeley.edu> wrote:
> 
> I am wondering about a change in behavior that I noticed with v3.8.3 (versus 3.7.6).
> 
> I have a Vec object which in 3.7.6 was stored in a common block. For 3.8.3 we have moved it to a module since gfortran was unhappy about having it in a common block.
> 
> In our code, we extract values from the vector using VecGetArray( ).  With ifort the behavior is the same (and correct) for both versions of our code.  With gfortran, we are seeing incorrect values when using VecGetArray( ) when the Vec is contained in a module as needed for 3.8.3.  If we switch over to VecGetArrayReadF90( ) gfortran once again produces correct results.
> 
> Is there a good reason to expect this behavior?

    I have no explanation for why this should happen.

>  I'm am trying to understand the underlying concepts that are a play here.

   VecGetArray() "cheats" and simply returns the index that one must shift that array address to access the values in the array. The F90 version uses F90 features to access the values.

    Moving forward we always recommend using the F90 versions, they are simpler to use, the non-F90 versions are hacks that one must use if one does not have F90 (but everyone has F90 now).

   Barry

The only reason we don't remove the non-F90 is for legacy codes where the users haven't updated yet.


   
> 
> -sanjay
> 
> 



More information about the petsc-users mailing list