Skip to content

Latest Fortran interface crashes in fio_eval_field_f #1

@rhager

Description

@rhager

I encountered a problem with the latest version of the Fortran interface on the Greene cluster. When trying to read a field with fit_eval_field_f, the my code crashes.

I think the problem is that the C-version of fio_eval_field is called with a constant (0):

subroutine fio_eval_field_f(ifield, x, v, ierr)
integer, intent(in) :: ifield
real, intent(in), dimension(*) :: x
real, intent(out), dimension(*) :: v
integer, intent(out) :: ierr
call fio_eval_field(ifield, x, v, 0, ierr)
end subroutine fio_eval_field_f
subroutine fio_eval_field_deriv_f(ifield, x, v, ierr)
integer, intent(in) :: ifield
real, intent(in), dimension(*) :: x
real, intent(out), dimension(*) :: v
integer, intent(out) :: ierr
call fio_eval_field_deriv(ifield, x, v, 0, ierr)
end subroutine fio_eval_field_deriv_f

I modified the code slightly by declaring an integer variable s and setting s=0

  subroutine fio_eval_field_f(ifield, x, v, ierr)
    integer, intent(in) :: ifield
    real, intent(in), dimension(*) :: x
    real, intent(out), dimension(*) :: v
    integer, intent(out) :: ierr
    integer :: s
    s=0
    call fio_eval_field(ifield, x, v, s, ierr)
  end subroutine fio_eval_field_f

  subroutine fio_eval_field_deriv_f(ifield, x, v, ierr)
    integer, intent(in) :: ifield
    real, intent(in), dimension(*) :: x
    real, intent(out), dimension(*) :: v
    integer, intent(out) :: ierr
    integer :: s
    s=0
    call fio_eval_field_deriv(ifield, x, v, s, ierr)
  end subroutine fio_eval_field_deriv_f

This turned out to work. The only way I can make sense of this is that somewhere down the call-tree, a program tries to write into s, which results in a segfault if s is a constant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions