Is there a bug for the dislin library of macOS native?

43 views
Skip to first unread message

mark jack

unread,
Apr 11, 2025, 9:06:15 AMApr 11
to dislin-users
Dear developer, 

When I test macOS native dislin library (https://www.dislin.de/macos.html, intel and arm64 has same result), it seems has issue (compiled by gfortran-14 and 13 has same result), my test code:

program dislin_3d_plot
    use dislin
    implicit none

    integer, parameter :: N = 50
    integer :: id_draw, id_but1, id_but2, id_lab2
    double precision :: xrot1 = 50.0d0, xrot2 = 40.0d0
    double precision :: xray(N), yray(N), zmat(N,N)
    integer :: ip, ip1, ip2, i, j, ival
    double precision :: step, x, y
    double precision, parameter :: fpi = 3.14159265358979323846d0 / 180.0d0

    ! Initialize data arrays
    step = 360.0d0 / dble(N-1)
    do i = 1, N
        x = dble(i-1)*step
        xray(i) = x
        do j = 1, N
            y = dble(j-1)*step
            yray(j) = y
            zmat(i,j) = 2.0d0 * sin(x*fpi) * sin(y*fpi)
        end do
    end do

    ! Create GUI widgets
    call swgtit('DISLIN 3D Plot')
    call swgopt('track', 'scroll')
    call swgopt('center', 'position')
    CALL SWGOPT("TRACK","SCROLL")
   
    call swgwth(70)
    call wgini('hori', ip)
    call wgbas(ip, 'vert', ip1)
    call swgdrw(2100D0/2970D0)
    call wglab(ip1, 'DISLIN 3D Plot:', id_lab2)
    call wgdraw(ip1, id_draw)
   
   
    call swgwth(20)
    call wgbas(ip, 'form', ip2)
    call swgwin(0, 0, 200, 100)
    call wgpbut(ip2, 'Azimuthal',id_but1)
    call swgwin(0, 120, 200, 100)
    call wgpbut(ip2, 'Polar', id_but2)
    call swgcbk(id_but1, myplot)
    call swgcbk(id_but2, myplot)
!     CALL REAWGT
    call myplot(id_but1)
    call wgfin()

contains
    subroutine myplot(id)
        integer, intent(in) :: id
        integer :: lev

        if (id == id_but1) then
            xrot1 = xrot1 + 10
        else if (id == id_but2) then
            xrot2 = xrot2 + 10
        end if
       
       
        CALL GETLEV(lev)
        write(*, "('Current level: ', I4)") lev
        if (lev /= 0) then
            write(*, *) "*******************Level ERROR*******************"
        end if
       
        call metafl('cons')
        call setxid(id_draw, 'widget')
        call scrmod('revers')
        CALL PAGE(3000,3000)
        CALL IMGFMT("RGB")
       
        write(*,*) "**************call disini()************"
        call disini()
        call erase()
        call hwfont()

        call name('X-axis', 'x')
        call name('Y-axis', 'y')
        call name('Z-axis', 'z')
        call labdig(-1, 'xyz')

        call axspos(700, 2800)
        call axslen(2100, 2100)

        call view3d(xrot1, xrot2, 6.0D0, 'angle')
        call height(40)
        call graf3d(0.0D0, 360D0, 0D0, 90D0, 0D0, 360D0, 0D0, 90D0, -3D0, 3D0, -3D0, 1D0)
        call surshd(xray, N, yray, N, zmat)
        call disfin()
        write(*,*) "**************call disfin()************"
       
    end subroutine myplot

end program dislin_3d_plot


The program maybe crash when frequently click two push button, console message:
Current level:    0
 **************call disini()************

 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 <<                END OF DISLIN / VERSION 11.5.2                <<
 <<  Date    : 11.04.2025  Time    : 12:23:24  Pageformat: PAGE  <<
 <<  Vectors : 1081        Warnings: 0         Fileformat: CONS  <<
 <<  Metafile:                                                   <<
 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

 **************call disfin()************

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:

Could not print backtrace: executable file is not an executable


If my program more complex, the report `Current level:  ` maybe  > 0,  I suspect if there's something wrong with the `disini` function.

Sincerely,
Mark

Helmut Michels

unread,
Apr 14, 2025, 5:05:06 AMApr 14
to dislin-users
Dear Mark,

thank you for the example code. I will make some tests with it.

With best regards,

Helmut

Helmut Michels

unread,
Apr 15, 2025, 7:03:45 AMApr 15
to dislin-users
Hi Mark,

I have now found a bug in the native macOS code of Dislin for Fortran, which has caused the
segmentation fault I think. Your example code is working fine now for me after the correction.
Updated Dislin distributions for macOS are available from https://www.dislin.de/macos.html

With best regards,

Helmut
Reply all
Reply to author
Forward
0 new messages