[petsc-users] PETSc Fortran 64-bit
Mike Michell
mi.mike1021 at gmail.com
Wed Feb 1 14:25:36 CST 2023
@Satish and Blaise - Thank you for the notes.
@Satish - When you say: "Some routines probably don't have Interface
definitions - hence compiler can't cat this issue with all functions."
Does it mean that I cannot use 64-bit option for those routines, which do
not have the interface definitions?
Thanks,
Mike
> I use the following I all my fortran codes (inspired by a post from
> Michael Metcalf on comp.lang.fortran many many moons ago):
>
> PetscReal,Parameter :: PReal = 1.0
> Integer,Parameter,Public :: Kr = Selected_Real_Kind(Precision(PReal))
> PetscInt,Parameter :: PInt = 1
> Integer,Parameter,Public :: Ki = kind(PInt)
>
> You will need to pass constant with their kind (i.e. 1_Ki instead of 1)
>
>
> The advantage of this approach over explicitly trying to figure out the
> proper type of integer ois that the same code will automatically work with
> 32 and 64 bit indices.
>
> I’ve been wondering if petsc should include these definitions (perhaps
> under another name).
>
> Blaise
>
>
> On Feb 1, 2023, at 2:58 PM, Mike Michell <mi.mike1021 at gmail.com> wrote:
>
> Hi all,
>
> I want to use PETSc with 64-bit indices with a Fortran90 code. It seems
> some PETSc functions have no problem, but some of the others do not accept
> 32-bit error code integer (e.g., "ierr" declared as PetscErrorCode type).
>
> For example,
>
> call DMPlexGetChart(dm, pst, pend, ierr);CHKERRA(ierr) works okay,
>
> but
>
> call DMPlexGetDepthStratum(dm, 0, vst, vend, ierr);CHKERRA(ierr) gives an
> error regarding the datatype of ierr. The error basically leads:
> Error: Type mismatch in argument ‘b’ at (1); passed INTEGER(4) to
> INTEGER(8)
>
> I tried to declare ierr as integer(kind=8) type, but there are still some
> problems. If PETSc is configured with 32-bit indices, the Fortran code
> works without problem.
>
> What surprising to me is that as mentioned above, DMPlexGetChart() works
> okay, but DMPlexGetDepthStratum() does not work with "ierr (PetscErrorCode
> type)" variable with 64-bit indices.
>
> Can I get any comments on it?
>
> Thanks,
> Mike
>
>
> —
> Canada Research Chair in Mathematical and Computational Aspects of Solid
> Mechanics (Tier 1)
> Professor, Department of Mathematics & Statistics
> Hamilton Hall room 409A, McMaster University
> 1280 Main Street West, Hamilton, Ontario L8S 4K1, Canada
> https://www.math.mcmaster.ca/bourdin | +1 (905) 525 9140 ext. 27243
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20230201/c099f290/attachment.html>
More information about the petsc-users
mailing list