Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing interface for OPERATOR(/=) in ESMF_Geom.F90 #302

Open
tclune opened this issue Oct 3, 2024 · 4 comments
Open

Missing interface for OPERATOR(/=) in ESMF_Geom.F90 #302

tclune opened this issue Oct 3, 2024 · 4 comments
Assignees

Comments

@tclune
Copy link
Collaborator

tclune commented Oct 3, 2024

The file declares both OPERATOR(==) and OPERATOR(/=) to be public, but only defines an implementation for the first.

The other is not an error because other USE statements there are bringing in /= on other types.

Easy fix.

Also - documentation does not even mention OPERATOR(==) for this type, and that should be addressed at the same time.

@tclune
Copy link
Collaborator Author

tclune commented Oct 3, 2024

oops - my bad. I did not go to look at the actual implementation in the file. Here == is only comparing the types.

So my request is instead provide operators that compare whether 2 geoms are aliases for the same object.

@tclune
Copy link
Collaborator Author

tclune commented Oct 3, 2024

Being the well-intended citizen that I am, I offer this quick and dirty implementation:

   impure elemental logical function ESMF_GeomEqual(geom1, geom2)
      type(ESMF_Geom), intent(in) :: geom1, geom2

      type(ESMF_GeomType_Flag) :: geomtype1, geomtype2
      type(ESMF_Grid) :: grid1, grid2
      type(ESMF_LocStream) :: locstream1, locstream2
      type(ESMF_Mesh) :: mesh1, mesh2
      type(ESMF_XGrid) :: xgrid1, xgrid2
      
      ESMF_GeomEqual = .false.

      call ESMF_GeomGet(geom1, geomtype=geomtype1)
      call ESMF_GeomGet(geom2, geomtype=geomtype2)

      if (geomtype1 /= geomtype2) return
      
      if (geomtype1 == ESMF_GEOMTYPE_GRID) then
         call ESMF_GeomGet(geom1, grid=grid1)
         call ESMF_GeomGet(geom2, grid=grid2)
         ESMF_GeomEqual = (grid1 == grid2)
         return
      end if

      if (geomtype1 == ESMF_GEOMTYPE_LOCSTREAM) then
         call ESMF_GeomGet(geom1, locstream=locstream1)
         call ESMF_GeomGet(geom2, locstream=locstream2)
         ESMF_GeomEqual = (locstream1 == locstream2)
         return
      end if

      if (geomtype1 == ESMF_GEOMTYPE_MESH) then
         call ESMF_GeomGet(geom1, mesh=mesh1)
         call ESMF_GeomGet(geom2, mesh=mesh2)
         ESMF_GeomEqual = (mesh1 == mesh2)
         return
      end if

      if (geomtype1 == ESMF_GEOMTYPE_XGRID) then
         call ESMF_GeomGet(geom1, xgrid=xgrid1)
         call ESMF_GeomGet(geom2, xgrid=xgrid2)
         ESMF_GeomEqual = (xgrid1 == xgrid2)
         return
      end if
      
   end function ESMF_GeomEqual


   impure elemental logical function ESMF_GeomNotEqual(geom1, geom2)
      type(ESMF_Geom), intent(in) :: geom1, geom2
      ESMF_GeomNotEqual = .not. (geom1 == geom2)
   end function ESMF_GeomNotEqual

@anntsay
Copy link

anntsay commented Oct 9, 2024

Bob will follow up during his typical meeting with the NASA Team. If there is a working code from NASA, should be easy to insert into the next release.

Dan: may need a subroutine in Geom Match. possibly medium size of work.

@anntsay
Copy link

anntsay commented Oct 23, 2024

Bob had worked on this and currently in develop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants