Commit bc8a449e authored by Kochunas, Brendan M.'s avatar Kochunas, Brendan M. Committed by Henderson, Shane
Browse files

Fixing more C interface problems for libpng

Squash branch 'hotfix_libpng2' into 'master'

* Fixing more C interface problems for libpng

Description:
These were not caught in the previous hotfix because they were
masked by the other bugs.

Confirmed that testTPLPNGf and testFileType_PNG are both passing
now in the environment for which they were previously failing.

<!-- Replace this a detailed description of changes -->

<!-- Include a link to VERA development issues if appropriate, or delete this line -->

**Developer Checklist:**
- [x] Have you done a self-review after creating the merge request?
- [x] Have you filled in the Merge Request information (title, description) thoroughly?
- [x] Have you updated the relevant tickets (if this MR is linked to any VERA-dev tickets)?
- [x] Have you addressed all suggested feedback and commented on it to let the reviewer know? (Do not resolve discussions that the reviewer started)

**Reviewer Checklist:**
- [x] Have you confirmed all discussions were adequately addressed and resolved them all?
- [x] Does it conform to formatting guidelines?
- [x] Are there adequate and clear comments?
- [x] Is the design clean and sensible?
- [x] Are the changes optimal/efficient?
- [x] Were sufficient DBC checks added?
- [x] Are there unit tests? (if necessary)
- [x] Is the MR description clear, including a link to the VERA-Dev issue if appropriate?

**PSM Checklist**
- [x] Have you confirmed that all discussions were addressed, or that follow-on issues have been created for them?
- [x] Have you confirmed sufficient testing was conducted?
- [x] Does this impact other repositories?
- [x] Does the MR have an adequate description?
- [x] If the MR has multiple commits, did you set the MR to squash merge?

See merge request https://code.ornl.gov/futility/Futility/-/merge_requests/424
parent f27fc94c
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -489,9 +489,9 @@ SUBROUTINE readImageData_PNGFileType(this,image)
    ENDSUBROUTINE C_png_read_image

    !Destroy PNG read structure
    SUBROUTINE C_png_destroy_read_struct(png_ptr,info_ptr_ptr,end_info_ptr_ptr) BIND(C,NAME="png_destroy_read_struct")
    SUBROUTINE C_png_destroy_read_struct(png_ptr_ptr,info_ptr_ptr,end_info_ptr_ptr) BIND(C,NAME="png_destroy_read_struct")
      IMPORT :: C_PTR
      TYPE(C_PTR),VALUE :: png_ptr
      TYPE(C_PTR) :: png_ptr_ptr
      TYPE(C_PTR) :: info_ptr_ptr
      TYPE(C_PTR) :: end_info_ptr_ptr
    ENDSUBROUTINE C_png_destroy_read_struct
+12 −3
Original line number Diff line number Diff line
@@ -96,9 +96,9 @@ PROGRAM testTPLPNGf
    ! Declare variables
    INTEGER :: i,j
    INTEGER :: ioerr
    TYPE(C_PTR) :: png_ptr,info_ptr,fp
    TYPE(C_PTR) :: png_ptr,info_ptr,fp,ver_ptr
    TYPE(C_PTR),POINTER :: row_pointers(:)
    CHARACTER(LEN=1),POINTER :: image(:,:,:)
    CHARACTER(KIND=C_CHAR,LEN=1),POINTER :: image(:,:,:),png_ver(:)

    ! Allocate memory for the image (3 bytes per pixel for RGB)
    ALLOCATE(image(3,width,height))
@@ -112,8 +112,17 @@ PROGRAM testTPLPNGf
      ENDDO
    ENDDO

    ver_ptr=C_png_get_libpng_ver(C_NULL_PTR)
    CALL C_F_POINTER(ver_ptr,png_ver,(/16/)) !This is for the length of the version string
                                             !16 is chosen as it should always be
                                             !long enough
                                             !7 is more likely, but going to 16
                                             !doesn't seem
                                             !cause an issue.


    ! Create the PNG write structure
    png_ptr=C_png_create_write_struct("1.6.37"//C_NULL_CHAR,C_NULL_PTR,C_NULL_PTR,C_NULL_PTR)
    png_ptr=C_png_create_write_struct(png_ver,C_NULL_PTR,C_NULL_PTR,C_NULL_PTR)
    IF(C_ASSOCIATED(png_ptr,C_NULL_PTR)) THEN
      WRITE(ERROR_UNIT,*) "Error creating PNG write struct!"
      STOP -1