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

bugfix for fortran logical overread #797

Merged
merged 3 commits into from
Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ and this project aspires to adhere to [Semantic Versioning](https://semver.org/s
#### General
- Avoid compile issue with using `_Pragma()` with Python 3.8 on Windows
- `conduit_node` and `conduit_datatype` in the C API are no longer aliases to `void` so that callers cannot pass just any pointer to the APIs.
- Fixed overread issue with Fortran API due to int vs bool binding error. Fortran API still provides logical returns for methods like conduit_node_has_path() however the binding implementation now properly translates C_INT return codes into logical values.

#### Blueprint
- Added the `blueprint::mesh::examples::polychain` example. It is an example of a polyhedral mesh. See Mesh Blueprint Examples docs (https://llnl-conduit.readthedocs.io/en/latest/blueprint_mesh.html#polychain) for more details.
- Fixed a bug that was causing the `conduit::blueprint::mesh::topology::unstructured::generate_*` functions to produce bad results for polyhedral input topologies with heterogeneous elements (e.g. tets and hexs).
- Added a new function signature for `blueprint::mesh::topology::unstructured::generated_sides`, which performs the same task as the original and also takes fields from the original topology and maps them onto the new topology.


## [0.7.2] - Released 2021-05-19

### Added
Expand Down
224 changes: 190 additions & 34 deletions src/libs/conduit/fortran/conduit_fortran.F90
Original file line number Diff line number Diff line change
Expand Up @@ -174,23 +174,22 @@ end function c_conduit_node_child_by_name
!--------------------------------------------------------------------------

!--------------------------------------------------------------------------
function conduit_node_is_root(cnode) result(res) &
function c_conduit_node_is_root(cnode) result(res) &
bind(C, name="conduit_node_is_root")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
logical(C_BOOL) :: res
end function conduit_node_is_root

integer(C_INT) :: res
end function c_conduit_node_is_root

!--------------------------------------------------------------------------
function conduit_node_is_data_external(cnode) result(res) &
bind(C, name="conduit_node_is_data_external")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
logical(C_BOOL) :: res
end function conduit_node_is_data_external
!--------------------------------------------------------------------------
function c_conduit_node_is_data_external(cnode) result(res) &
bind(C, name="conduit_node_is_data_external")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
integer(C_INT) :: res
end function c_conduit_node_is_data_external

!--------------------------------------------------------------------------
function conduit_node_parent(cnode) result(res) &
Expand Down Expand Up @@ -226,7 +225,7 @@ function c_conduit_node_has_child(cnode,name) result(res) &
implicit none
type(C_PTR), value, intent(IN) :: cnode
character(kind=C_CHAR), intent(IN) :: name(*)
logical(C_BOOL) :: res
integer(C_INT) :: res
end function c_conduit_node_has_child

!--------------------------------------------------------------------------
Expand Down Expand Up @@ -282,7 +281,7 @@ function c_conduit_node_has_path(cnode,path) result(res) &
implicit none
type(C_PTR), value, intent(IN) :: cnode
character(kind=C_CHAR), intent(IN) :: path(*)
logical(C_BOOL) :: res
integer(C_INT) :: res
end function c_conduit_node_has_path

!--------------------------------------------------------------------------
Expand Down Expand Up @@ -313,32 +312,32 @@ function conduit_node_total_bytes_compact(cnode) result(res) &
end function conduit_node_total_bytes_compact

!--------------------------------------------------------------------------
function conduit_node_is_compact(cnode) result(res) &
function c_conduit_node_is_compact(cnode) result(res) &
bind(C, name="conduit_node_is_compact")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
logical(C_BOOL) :: res
end function conduit_node_is_compact
integer(C_INT) :: res
end function c_conduit_node_is_compact

!--------------------------------------------------------------------------
function conduit_node_is_contiguous(cnode) result(res) &
function c_conduit_node_is_contiguous(cnode) result(res) &
bind(C, name="conduit_node_is_contiguous")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
logical(C_BOOL) :: res
end function conduit_node_is_contiguous
integer(C_INT) :: res
end function c_conduit_node_is_contiguous

!--------------------------------------------------------------------------
function conduit_node_contiguous_with_node(cnode,cother) result(res) &
function c_conduit_node_contiguous_with_node(cnode,cother) result(res) &
bind(C, name="conduit_node_contiguous_with_node")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
type(C_PTR), value, intent(IN) :: cother
logical(C_BOOL) :: res
end function conduit_node_contiguous_with_node
integer(C_INT) :: res
end function c_conduit_node_contiguous_with_node

!--------------------------------------------------------------------------
subroutine conduit_node_compact_to(cnode,cdest) &
Expand All @@ -350,38 +349,38 @@ subroutine conduit_node_compact_to(cnode,cdest) &
end subroutine conduit_node_compact_to

!--------------------------------------------------------------------------
function conduit_node_diff(cnode,cother,cinfo,epsilon) result(res) &
function c_conduit_node_diff(cnode,cother,cinfo,epsilon) result(res) &
bind(C, name="conduit_node_diff")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
type(C_PTR), value, intent(IN) :: cother
type(C_PTR), value, intent(IN) :: cinfo
real(8), value, intent(IN) :: epsilon
logical(C_BOOL) :: res
end function conduit_node_diff
integer(C_INT) :: res
end function c_conduit_node_diff

!--------------------------------------------------------------------------
function conduit_node_diff_compatible(cnode,cother,cinfo,epsilon) result(res) &
function c_conduit_node_diff_compatible(cnode,cother,cinfo,epsilon) result(res) &
bind(C, name="conduit_node_diff_compatible")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
type(C_PTR), value, intent(IN) :: cother
type(C_PTR), value, intent(IN) :: cinfo
real(8), value, intent(IN) :: epsilon
logical(C_BOOL) :: res
end function conduit_node_diff_compatible
integer(C_INT) :: res
end function c_conduit_node_diff_compatible

!--------------------------------------------------------------------------
function conduit_node_compatible(cnode,cother) result(res) &
function c_conduit_node_compatible(cnode,cother) result(res) &
bind(C, name="conduit_node_compatible")
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
type(C_PTR), value, intent(IN) :: cother
logical(C_BOOL) :: res
end function conduit_node_compatible
integer(C_INT) :: res
end function c_conduit_node_compatible

!--------------------------------------------------------------------------
subroutine conduit_node_info(cnode,cdest) &
Expand Down Expand Up @@ -1163,6 +1162,149 @@ end function conduit_node_as_double
contains
!
!------------------------------------------------------------------------------
!--------------------------------------------------------------------------
function conduit_node_is_root(cnode) result(res)
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
c_res = c_conduit_node_is_root(cnode)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_is_root

!--------------------------------------------------------------------------
function conduit_node_is_data_external(cnode) result(res)
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
c_res = c_conduit_node_is_data_external(cnode)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_is_data_external

!--------------------------------------------------------------------------
function conduit_node_is_compact(cnode) result(res)
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
c_res = c_conduit_node_is_compact(cnode)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_is_compact

!--------------------------------------------------------------------------
function conduit_node_is_contiguous(cnode) result(res)
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
c_res = c_conduit_node_is_contiguous(cnode)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_is_contiguous

!--------------------------------------------------------------------------
function conduit_node_contiguous_with_node(cnode,cother) result(res)
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
type(C_PTR), value, intent(IN) :: cother
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
c_res = c_conduit_node_contiguous_with_node(cnode,cother)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_contiguous_with_node

!--------------------------------------------------------------------------
function conduit_node_diff(cnode,cother,cinfo,epsilon) result(res)
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
type(C_PTR), value, intent(IN) :: cother
type(C_PTR), value, intent(IN) :: cinfo
real(8), value, intent(IN) :: epsilon
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
c_res = c_conduit_node_diff(cnode,cother,cinfo,epsilon)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_diff

!--------------------------------------------------------------------------
function conduit_node_diff_compatible(cnode,cother,cinfo,epsilon) result(res)
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
type(C_PTR), value, intent(IN) :: cother
type(C_PTR), value, intent(IN) :: cinfo
real(8), value, intent(IN) :: epsilon
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
c_res = c_conduit_node_diff_compatible(cnode,cother,cinfo,epsilon)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_diff_compatible

!--------------------------------------------------------------------------
function conduit_node_compatible(cnode,cother) result(res)
use iso_c_binding
implicit none
type(C_PTR), value, intent(IN) :: cnode
type(C_PTR), value, intent(IN) :: cother
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
c_res = c_conduit_node_compatible(cnode,cother)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_compatible

!--------------------------------------------------------------------------
function conduit_node_fetch(cnode, path) result(res)
Expand Down Expand Up @@ -1193,8 +1335,15 @@ function conduit_node_has_child(cnode, name) result(res)
type(C_PTR), value, intent(IN) :: cnode
character(*), intent(IN) :: name
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
res = c_conduit_node_has_child(cnode, trim(name) // C_NULL_CHAR)
c_res = c_conduit_node_has_child(cnode, trim(name) // C_NULL_CHAR)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_has_child

!--------------------------------------------------------------------------
Expand Down Expand Up @@ -1290,8 +1439,15 @@ function conduit_node_has_path(cnode, path) result(res)
type(C_PTR), value, intent(IN) :: cnode
character(*), intent(IN) :: path
logical(C_BOOL) :: res
!-- c interface returns an int, we convert to logical here
integer(C_INT) :: c_res
!---
res = c_conduit_node_has_path(cnode, trim(path) // C_NULL_CHAR)
c_res = c_conduit_node_has_path(cnode, trim(path) // C_NULL_CHAR)
if (c_res .EQ. 1) then
res = .true.
else
res = .false.
endif
end function conduit_node_has_path

!--------------------------------------------------------------------------
Expand Down