Re: [petsc-users] Question about handling matrix
Both small and large matrix are sparse matrix. I will try following comments. Thanks, Hyung Kim 2023년 2월 1일 (수) 오후 11:30, Jed Brown 님이 작성: > Is the small matrix dense? Then you can use MatSetValues. If the small > matrix is sparse, you can assemble it with larger dimension (empty rows and > columns) and use MatAXPY. > > 김성익 writes: > > > Hello, > > > > > > I want to put small matrix to large matrix. > > The schematic of operation is as below. > > [image: image.png] > > Is there any function for put small matrix to large matrix at once? > > > > Thanks, > > Hyung Kim >
Re: [petsc-users] PETSc Fortran 64-bit
On Feb 1, 2023, at 3:50 PM, Satish Balay via petsc-users wrote: 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 Hence my suggestion to systematically use kind when passing constants! Blaise 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 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 — 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
Re: [petsc-users] PETSc Fortran 64-bit
> > 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 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 > > > > > > > > >
Re: [petsc-users] PETSc Fortran 64-bit
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 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 > > > > >
Re: [petsc-users] PETSc Fortran 64-bit
@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 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 > >
Re: [petsc-users] PETSc Fortran 64-bit
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 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
Re: [petsc-users] PETSc Fortran 64-bit
Check petsc examples You would use 'PetscErrorCode ierr' - not 'INTEGER(4) or INTEGER(8) Some routines probably don't have Interface definitions - hence compiler can't cat this issue with all functions. [but they all consistently need PetscErrorCode] Satish On Wed, 1 Feb 2023, Mike Michell 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 >
[petsc-users] PETSc Fortran 64-bit
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
Re: [petsc-users] Question about handling matrix
Is the small matrix dense? Then you can use MatSetValues. If the small matrix is sparse, you can assemble it with larger dimension (empty rows and columns) and use MatAXPY. 김성익 writes: > Hello, > > > I want to put small matrix to large matrix. > The schematic of operation is as below. > [image: image.png] > Is there any function for put small matrix to large matrix at once? > > Thanks, > Hyung Kim
Re: [petsc-users] Question about handling matrix
Maybe create the large matrix and use https://www.mcs.anl.gov/petsc/petsc-3.7/docs/manualpages/Mat/MatGetSubMatrix.html with MAT_REUSE_MATRIX. Or pad the IS arguments to MatGetSubMatrix with -1, so the size is correct and PETSc should ignore -1, and use MAT_INITIAL_MATRIX. Others may know what will work. Good luck, Mark On Wed, Feb 1, 2023 at 5:26 AM 김성익 wrote: > Hello, > > > I want to put small matrix to large matrix. > The schematic of operation is as below. > [image: image.png] > Is there any function for put small matrix to large matrix at once? > > Thanks, > Hyung Kim >
[petsc-users] Question about handling matrix
Hello, I want to put small matrix to large matrix. The schematic of operation is as below. [image: image.png] Is there any function for put small matrix to large matrix at once? Thanks, Hyung Kim