<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<br>
<div><br>
<blockquote type="cite">
<div>On Feb 1, 2023, at 3:50 PM, Satish Balay via petsc-users <petsc-users@mcs.anl.gov> wrote:</div>
<br class="Apple-interchange-newline">
<div>
<div>
<blockquote type="cite">
<blockquote type="cite">call DMPlexGetDepthStratum(dm, 0, vst, vend, ierr);CHKERRA(ierr) gives an<br>
error regarding the datatype of ierr. The error basically leads:<br>
Error: Type mismatch in argument ‘b’ at (1); passed INTEGER(4) to<br>
INTEGER(8)<br>
</blockquote>
</blockquote>
<br>
Ok - I think the error here is with '0' - not ierr.<br>
<br>
Use:<br>
<br>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite"><br>
</blockquote>
</blockquote>
</blockquote>
PetscInt zero<br>
zero = 0<br>
call DMPlexGetDepthStratum(dm, zero, vst, vend, ierr);CHKERRA(ierr)<br>
<<<<br>
<br>
Satish<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div><br>
</div>
Hence my suggestion to systematically use kind when passing constants!</div>
<div><br>
</div>
<div>Blaise</div>
<div><br>
</div>
<div>
<blockquote type="cite">
<div>
<div><br>
On Wed, 1 Feb 2023, Satish Balay via petsc-users wrote:<br>
<br>
<blockquote type="cite">On Wed, 1 Feb 2023, Mike Michell wrote:<br>
<br>
<blockquote type="cite">@Satish and Blaise - Thank you for the notes.<br>
<br>
@Satish - When you say: "Some routines probably don't have Interface<br>
definitions - hence compiler can't cat this issue with all functions."<br>
</blockquote>
<br>
sorry - meant to say 'catch' [not cat]<br>
<br>
<blockquote type="cite">Does it mean that I cannot use 64-bit option for those routines, which do<br>
not have the interface definitions?<br>
</blockquote>
<br>
All routines are usable. Its just that compiler treats routines<br>
without interface definitions as F77 - and it won't verify the<br>
data-types of arguments passed in. [i.e F77 mode..]<br>
<br>
But I do see interface defs for both DMPlexGetDepthStratum() and<br>
DMPlexGetChart() so don't know why they behave differently for you.<br>
<br>
src/dm/f90-mod/ftn-auto-interfaces/petscdmplex.h90<br>
<br>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite"><br>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
subroutine DMPlexGetDepthStratum(a,b,c,d,z)<br>
import tDM<br>
DM a ! DM<br>
PetscInt b ! PetscInt<br>
PetscInt c ! PetscInt<br>
PetscInt d ! PetscInt<br>
PetscErrorCode z<br>
end subroutine DMPlexGetDepthStratum<br>
<br>
subroutine DMPlexGetChart(a,b,c,z)<br>
import tDM<br>
DM a ! DM<br>
PetscInt b ! PetscInt<br>
PetscInt c ! PetscInt<br>
PetscErrorCode z<br>
end subroutine DMPlexGetChart<br>
<br>
Satish<br>
<br>
<br>
<blockquote type="cite">Thanks,<br>
Mike<br>
<br>
<br>
<blockquote type="cite">I use the following I all my fortran codes (inspired by a post from<br>
Michael Metcalf on comp.lang.fortran many many moons ago):<br>
<br>
PetscReal,Parameter :: PReal = 1.0<br>
Integer,Parameter,Public :: Kr = Selected_Real_Kind(Precision(PReal))<br>
PetscInt,Parameter :: PInt = 1<br>
Integer,Parameter,Public :: Ki = kind(PInt)<br>
<br>
You will need to pass constant with their kind (i.e. 1_Ki instead of 1)<br>
<br>
<br>
The advantage of this approach over explicitly trying to figure out the<br>
proper type of integer ois that the same code will automatically work with<br>
32 and 64 bit indices.<br>
<br>
I’ve been wondering if petsc should include these definitions (perhaps<br>
under another name).<br>
<br>
Blaise<br>
<br>
<br>
On Feb 1, 2023, at 2:58 PM, Mike Michell <mi.mike1021@gmail.com> wrote:<br>
<br>
Hi all,<br>
<br>
I want to use PETSc with 64-bit indices with a Fortran90 code. It seems<br>
some PETSc functions have no problem, but some of the others do not accept<br>
32-bit error code integer (e.g., "ierr" declared as PetscErrorCode type).<br>
<br>
For example,<br>
<br>
call DMPlexGetChart(dm, pst, pend, ierr);CHKERRA(ierr) works okay,<br>
<br>
but<br>
<br>
call DMPlexGetDepthStratum(dm, 0, vst, vend, ierr);CHKERRA(ierr) gives an<br>
error regarding the datatype of ierr. The error basically leads:<br>
Error: Type mismatch in argument ‘b’ at (1); passed INTEGER(4) to<br>
INTEGER(8)<br>
<br>
I tried to declare ierr as integer(kind=8) type, but there are still some<br>
problems. If PETSc is configured with 32-bit indices, the Fortran code<br>
works without problem.<br>
<br>
What surprising to me is that as mentioned above, DMPlexGetChart() works<br>
okay, but DMPlexGetDepthStratum() does not work with "ierr (PetscErrorCode<br>
type)" variable with 64-bit indices.<br>
<br>
Can I get any comments on it?<br>
<br>
Thanks,<br>
Mike<br>
<br>
<br>
—<br>
Canada Research Chair in Mathematical and Computational Aspects of Solid<br>
Mechanics (Tier 1)<br>
Professor, Department of Mathematics & Statistics<br>
Hamilton Hall room 409A, McMaster University<br>
1280 Main Street West, Hamilton, Ontario L8S 4K1, Canada<br>
https://www.math.mcmaster.ca/bourdin | +1 (905) 525 9140 ext. 27243<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
</div>
</div>
</blockquote>
</div>
<br>
<div>
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div dir="auto" style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div>— <br>
Canada Research Chair in Mathematical and Computational Aspects of Solid Mechanics (Tier 1)</div>
<div>Professor, Department of Mathematics & Statistics<br>
Hamilton Hall room 409A, McMaster University<br>
1280 Main Street West, Hamilton, Ontario L8S 4K1, Canada <br>
https://www.math.mcmaster.ca/bourdin | +1 (905) 525 9140 ext. 27243</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
</body>
</html>