Skip to content

Commit

Permalink
Add comparison operator for boxarray and distromap. Add hdf5 to dep.py (
Browse files Browse the repository at this point in the history
AMReX-Codes#4173)

Add operator(==) for boxarray and for distromap for the Fortran
interface. Also add "hdf5" to dep.py to suppress warnings.

---------

Co-authored-by: Weiqun Zhang <[email protected]>
  • Loading branch information
dunhamsj and WeiqunZhang authored Oct 1, 2024
1 parent aba5f01 commit 8349789
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 4 deletions.
5 changes: 5 additions & 0 deletions Src/F_Interfaces/Base/AMReX_boxarray_fi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@ extern "C" {
Box bx(IntVect(lo), IntVect(hi), ba->ixType());
return ba->intersects(bx);
}

int amrex_fi_boxarray_issame (const BoxArray* baa, const BoxArray* bab)
{
return *baa == *bab;
}
}
21 changes: 19 additions & 2 deletions Src/F_Interfaces/Base/AMReX_boxarray_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ module amrex_boxarray_module

private

public :: amrex_boxarray_build, amrex_boxarray_destroy, amrex_print
public :: amrex_boxarray_build, amrex_boxarray_destroy, amrex_print, &
operator(==)

type, public :: amrex_boxarray
logical :: owner = .false.
Expand All @@ -36,6 +37,10 @@ module amrex_boxarray_module
#endif
end type amrex_boxarray

interface operator(==)
module procedure amrex_boxarray_issame
end interface operator(==)

interface amrex_boxarray_build
module procedure amrex_boxarray_build_bx
module procedure amrex_boxarray_build_bxs
Expand Down Expand Up @@ -122,12 +127,18 @@ pure function amrex_fi_boxarray_numpts (ba) bind(c)
integer(amrex_long) :: amrex_fi_boxarray_numpts
end function amrex_fi_boxarray_numpts

pure integer function amrex_fi_boxarray_intersects_box (ba, lo, hi) bind(c)
pure integer(c_int) function amrex_fi_boxarray_intersects_box (ba, lo, hi) bind(c)
import
implicit none
type(c_ptr), value, intent(in) :: ba
integer, intent(in) :: lo(*), hi(*)
end function amrex_fi_boxarray_intersects_box

pure integer(c_int) function amrex_fi_boxarray_issame (baa, bab) bind(c)
import
implicit none
type(c_ptr), value, intent(in) :: baa, bab
end function amrex_fi_boxarray_issame
end interface

contains
Expand Down Expand Up @@ -258,4 +269,10 @@ pure function amrex_boxarray_intersects_box (this, bx) result(r)
r = ir .ne. 0
end function amrex_boxarray_intersects_box

pure logical function amrex_boxarray_issame(baa, bab) result(r)
type(amrex_boxarray), intent(in) :: baa
type(amrex_boxarray), intent(in) :: bab
r = amrex_fi_boxarray_issame(baa%p, bab%p) .ne. 0
end function amrex_boxarray_issame

end module amrex_boxarray_module
5 changes: 5 additions & 0 deletions Src/F_Interfaces/Base/AMReX_distromap_fi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,9 @@ extern "C" {
{
AllPrint() << *dm;
}

int amrex_fi_distromap_issame (const DistributionMapping* dma, const DistributionMapping* dmb)
{
return *dma == *dmb;
}
}
18 changes: 17 additions & 1 deletion Src/F_Interfaces/Base/AMReX_distromap_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ module amrex_distromap_module

private

public :: amrex_distromap_build, amrex_distromap_destroy, amrex_print
public :: amrex_distromap_build, amrex_distromap_destroy, amrex_print, &
operator(==)

type, public :: amrex_distromap
logical :: owner = .false.
Expand All @@ -25,6 +26,10 @@ module amrex_distromap_module
#endif
end type amrex_distromap

interface operator(==)
module procedure amrex_distromap_issame
end interface operator(==)

interface amrex_distromap_build
module procedure amrex_distromap_build_ba
module procedure amrex_distromap_build_pmap
Expand Down Expand Up @@ -89,6 +94,12 @@ subroutine amrex_fi_print_distromap (dm) bind(c)
implicit none
type(c_ptr), value :: dm
end subroutine amrex_fi_print_distromap

pure integer(c_int) function amrex_fi_distromap_issame (dma, dmb) bind(c)
import
implicit none
type(c_ptr), value, intent(in) :: dma, dmb
end function amrex_fi_distromap_issame
end interface

contains
Expand Down Expand Up @@ -158,4 +169,9 @@ subroutine amrex_distromap_print (dm)
call amrex_fi_print_distromap(dm%p)
end subroutine amrex_distromap_print

pure logical function amrex_distromap_issame (dma, dmb) result(r)
type(amrex_distromap), intent(in) :: dma, dmb
r = amrex_fi_distromap_issame(dma%p, dmb%p) .ne. 0
end function amrex_distromap_issame

end module amrex_distromap_module
2 changes: 1 addition & 1 deletion Tools/F_scripts/dep.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import preprocess

# modules to ignore in the dependencies
IGNORES = ["iso_c_binding", "iso_fortran_env", "omp_lib", "mpi", "cudafor", "openacc", "hdf"]
IGNORES = ["iso_c_binding", "iso_fortran_env", "omp_lib", "mpi", "cudafor", "openacc", "hdf", "hdf5"]

# regular expression for "{}module{}name", where {} can be any number
# of spaces. We use 4 groups here, denoted by (), so the name of the
Expand Down

0 comments on commit 8349789

Please sign in to comment.