[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Use of GTEXT in GUI and _nc and _gf linked programs



Steve and Scott,

I had included a _gf version of sfgram in my build/distribution. You
don't have a link script for this, so not a particular problem
for your distribution.

I found that the sfgram_gf routine would occasionally core dump most
noticeably under linux (g77) and not duplicated with the standard 
version that used gplt. I found:

in programs/sf/sfgram/sfxgst.f, the call to GTEXT uses a constant 'G'.

The source/device/plot/dtext.f routine modifies the cchar passed
variable in line 114. 

When GTEXT uses the gplt interface, the mailbox is copying the string
passed, so this is not a problem, but when the device driver is
linked directly, the modification of cchar in dtext.f is changing the
constant string in the GTEXT call. The results are variable depending on
g77 and optimization etc, but with FC3 Linux and g77, I had core dumps.

My short term solution for sfxgst.f is to add a gchar character string
and pass that to GTEXT. I've attached the updated routine.

I haven't yet searched the distribution for other GTEXT calls using 
constant strings- but either they should pass variables, or GTEXT
could copy the passed string for passing to DTEXT. Either way, I 
thought it might be useful for you to know as any GUI use of 
a routine that uses GTEXT would be vulnerable if a constant was passed.

Steve

        SUBROUTINE SFXGST  ( parms, icolor, data, ntime, xval, iret )
C************************************************************************
C* SFXGST                                                               *
C*                                                                      *
C* This subroutine plots character data for SFGRAM.                     *
C*                                                                      *
C* SFXGST  ( PARMS, ICOLOR, DATA, NTIME, XVAL, IRET )                   *
C*                                                                      *
C* Input parameters:                                                    *
C*      PARMS           CHAR*           Parm*condition                  *
C*      ICOLOR          INTEGER         Color                           *
C*      DATA (NTIME)    REAL            Data                            *
C*      NTIME           INTEGER         Number of times                 *
C*      XVAL (NTIME)    REAL            Points on x axis                *
C*                                                                      *
C* Output parameters:                                                   *
C*      IRET            INTEGER         Return code                     *
C*                                        0 = normal return             *
C**                                                                     *
C* Log:                                                                 *
C* M. desJardins/GSFC    5/90                                           *
C* S. Jacobs/NCEP        9/97   Changed call to GQTEXT and GSTEXT       *
C* S. Chiswell/Unidata   5/05   Changed GTEXT call to avoid const passed*
C************************************************************************
        INCLUDE         'GEMPRM.PRM'
C*
        CHARACTER*(*)   parms
        REAL            xval (*), data (*)
C*
        CHARACTER       condtn*8, ppp*4, gchar*1
C*
        INCLUDE         'ERMISS.FNC'
C*
        DATA            gchar / 'G' /
C------------------------------------------------------------------------
        iret = 0
C
C*      Get the condition and parameter parts.
C
        condtn = parms (5: )
        ppp    = parms
C
C*      Set color.
C
        CALL GSCOLR  ( icolor, ier )
C
C*      Get conditions.
C
        CALL SFXCND  ( condtn, size, iwidth, ier )
C
C*      Set the character size and width.
C
        CALL GQTEXT  ( itxfn, itxhw, sztext, itxwid,
     +                 ibrdr, irrotn, ijust, ier )
        CALL GSTEXT  ( 0, 0, size, iwidth, 0, 0, 0, ier )
C
C*      Loop through points writing text.
C
        DO  i = 1, ntime
            IF  ( .not. ERMISS ( data (i) ) .and. 
     +            ( data (i) .gt. 0. ) )  THEN
                CALL GTEXT  ( 'M', xval (i), data (i), gchar, 0., 0, 0, 
     +                                  ier )
            END IF
        END DO
C
C*      Reset text attributes.
C
        CALL GSTEXT  ( 0, 0, sztext, itxwid, 0, 0, 0, ier )
C*
        RETURN
        END