[petsc-users] PETSc Fortran 64-bit

Mike Michell mi.mike1021 at gmail.com
Fri Feb 3 08:48:52 CST 2023


That was the real problem indeed! Thanks a lot for the help.

Mike


> > > 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)
>
> Ok - I think the error here is with '0' - not ierr.
>
> Use:
>
> >>>
> PetscInt zero
> zero = 0
> call DMPlexGetDepthStratum(dm, zero, vst, vend, ierr);CHKERRA(ierr)
> <<<
>
> Satish
>
> On Wed, 1 Feb 2023, Satish Balay via petsc-users wrote:
>
> > On Wed, 1 Feb 2023, Mike Michell wrote:
> >
> > > @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."
> >
> > sorry - meant to say 'catch' [not cat]
> >
> > > Does it mean that I cannot use 64-bit option for those routines, which
> do
> > > not have the interface definitions?
> >
> > All routines are usable. Its just that compiler treats routines
> > without interface definitions as F77 - and it won't verify the
> > data-types of arguments passed in. [i.e F77 mode..]
> >
> > But I do see interface defs for both DMPlexGetDepthStratum() and
> > DMPlexGetChart() so don't know why they behave differently for you.
> >
> > src/dm/f90-mod/ftn-auto-interfaces/petscdmplex.h90
> >
> > >>>>>
> >       subroutine DMPlexGetDepthStratum(a,b,c,d,z)
> >        import tDM
> >        DM a ! DM
> >        PetscInt b ! PetscInt
> >        PetscInt c ! PetscInt
> >        PetscInt d ! PetscInt
> >        PetscErrorCode z
> >        end subroutine DMPlexGetDepthStratum
> >
> >       subroutine DMPlexGetChart(a,b,c,z)
> >        import tDM
> >        DM a ! DM
> >        PetscInt b ! PetscInt
> >        PetscInt c ! PetscInt
> >        PetscErrorCode z
> >        end subroutine DMPlexGetChart
> >
> > Satish
> >
> >
> > > 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/20230203/24f54475/attachment.html>


More information about the petsc-users mailing list