fdds_printf - append definition to DDS dictionary


SYNOPSIS

#include <fdds.h> (fixed-format sources)
#include <f90dds.h> (free-format sources)

integer function fdds_printf(alias, fmt,...)

character*(*) alias
character*(*) fmt

DESCRIPTION

fdds_printf appends a definition to a dictionary. The "print" dictionary must have been previously selected by fdds_dict, fddx_dict, or fddx_out.

One definition name may be specified by alias. If specified, a new definition is appended to the "print" dictionary. If alias is blank, information is appended to the value of the current definition.

fdds_printf is controlled by the format string fmt and optional arguments. fmt is an ANSI C standard format string for the stdio sprintf function. It converts optional arguments "..." following the rules of the ANSI C standard for sprintf. Format strings are typically terminated with "\n\0" ("newlineNULL").

Format strings MUST be terminated with a null character ("\0").

Optional arguments "..." should not contain '=' (unless escaped).

The following table summarizes conversion specifiers for fdds_printf by Fortran type. See ANSI standard C printf for more details.

fmt     -------- Sun --------     
char   Fortran       modifier 
                   h    l    L      
d, i   integer     *2   *4   *4 
o      integer     *2   *4   *4
x, X   integer     *2   *4   *4 
u      integer     *2   *4   *4
c      integer     *2   *4   *4
s      character   NA   NA   NA
f      real        NA   dp   NA
e, E   real        NA   dp   NA
g, G   real        NA   dp   NA
p      not char    NA   NA   NA
n      integer     *2   *4   *4
%      NA          NA   NA   NA
    
The printf type modifiers for floating point arguments must be extended by fdds_printf to support Fortran. "C" always promotes real arguments (Fortran real) to double (precision), therefore C doesn't distinguish between them in printf formats. The type modifiers used by scanf are also honored by fdds_printf; the default is real (Fortran real), 'l' implies double (precision), and 'L' long double (for extensions).
      real f
      double precision d
      long double precision ld
      ...
      j = fdds_printf('foo',  '%f  %lf  %Lf\n\0',  f,  d,  ld)
    
fdds_printf strips trailing blanks from character arguments during '%s' conversion. Like "C", it also assumes the '%c' conversion argument is an integer.

OUTPUT

The contents of the current "print" dictionary may be changed.

No function is provided to redefine existing definitions -- history can't be changed. An existing name can be appended again, which effectively redefines its value.

The return value is the number of characters written, or negative (EOF) if an error occurred. Zero is returned, if an output dictionary is not open.

EXAMPLES

c     append "beta" definition to output dictionary
      ier = fdds_printf('beta', ' %f\n\0', 3.14)
            
c     append mixed data types (string, integer, float)
      ier = fdds_printf('gamma', ' %s %d %f\n\0', 'green', 5, 7.3)
            
c     append an array of float values
      ier = fdds_printf('omega', ' ')
      do i=1,count
         ier = fdds_printf(' ', ' %f\0', omega(i))
      enddo
      ier = fdds_printf(' ', '\n\0')

c     append an alias definition
      ier = fdds_printf('alias:zeta', ' zeta ZETA Zeta\n\0')

c     append an alias to undefine "gamma"
      ier = fdds_printf('alias:gamma',' \n\0')
    

SEE ALSO

fdds_dict Set dictionary mode
fddx_dict Set dictionary mode
fddx_out Open output
    

AUTHOR

R. L. Selzler, EPTG (May, 1994)