mzhelp
=main=========================================================================
Available fit functions:
  1-20 Gaussian, Lorentzian or Gaussian folded with Lorentzian
  Critical exponents, Strange peaks, User defineable functions

Data files supported:
  TASMAD, NeXus (DMC, HRPT, FOCUS, MARS, RITA)
  ASCII multicolumn format, SICS ascii,
  LNS Powder Ascii, TASCOM, Fullprof plot output
  5c2, INX, IDA, 2T, PANDA, CCL

Most fit commands can also be linked to a user FORTRAN program.

Report bugs & wishes to markus.zolliker@psi.ch

Topic                                    Available keyword
-----------------------------------------------------------------------------
Command syntax                           "commands"     
Features in plot window                  "graphics"
New features since 1990                  "history"
Programming your own user function       "user_function"  "cinfo"  "init"
Control FIT from a FORTRAN program       "callable"
Fortran interface of any FIT command     fit_X (where X is any FIT command) 
Datafile specific options                "opt"

Commands             Available keywords
-----------------------------------------------------------------------------
fitting commands:    "fit" "mig" "sim" "epsi" "vtest" "err" "pri"
function definiton:  "fun" "auto" "newpeak"
parameter handling:  "set" "lim" "fix" "cor" "rel" "fcn" "reserr"
input:               "load" "dat" "link" "next" "opt"
output:              "save" "file" "out" "list" "export"
fit region:          "win" "exclude" "include" "keep"
data manipulation:   "mon" "merge" "mul" "sub" "add" "abskor" "trans" "bgedit"
plot:                "plot" "scal" "rsc" "choose" "plog" "plin" "file"
plot style:          "bars" "connect" "style" "colors" "legend"
miscellaneous:       "help" "info" "exit" "tit" "@"
=commands=====================================================================
Syntax of an interactive command:

Command   parameter1,parameter2,parameter3,...

If you omit some parameters, usually default values are taken or,
if it is explicitly documented, the program asks for missing
parameters.
Some commands can be shortened (indicated in brackets [])
=fit=mig=sim=epsi=vtest=err=pri============================================
FIT n    Start fitting by minimum gradient method (Davidon-Fletcher-Powell
[F]      algorithm). If the algorithm fails, simplex is called.

MIG n    Start fitting by minimum gradient method. Even if the algorithm
         fails, simplex is not called.

SIM n    Start fitting by simplex method.

MIN n    Start fitting by simplex followed by gradient method
[M]
     (n: Limit for the number of function calls, default n=1000)

ERR f    Errors correspond to a FCN change of f (default: f=1.0).

         FCN = sum over { (Ycal(i)-Yobs(i)) / Sig(i) }**2
         Chi**2 = FCN / Nfree

EPSI e   Convergence criterion (Estimated distance to minimum).
         Default e=0.1*f

VTEST v  Second convergence criterion for gradient method
         (fractional change in variance matrix). Default: v=0.01

PRI i    Amount of printout during fit algorithm (i=0..5, default: i=0)
=set=lim=fix=cor=rel=fcn=reserr=============================================
FCN            Show all parameters

SET i,v,e      Set parameter i to value v with estimated error e
i=v,e          Alternative command syntax

LIM i,l,u      Set limits of parameter i to l and u.
LIM i          Remove limits of parameter i

SET i,v,e,l,u  a combination of the commands SET and LIM

FIX i,j,...    FIX parameter i and j and ... at actual value

COR i,j,f,c    Correlate parameters p(i)=p(j)*f+c
               Default: f=1.0, c=0.0

REL i,j,...    Release parameter i and j and ... from FIX or COR
               If MaxInt or IntInt is released, the other of the two will be
               correlated automatically.
REL            Release all parameters

RESERR         should be called when after an unsuccesful fit the errors are
               set to very small values. A further FIT step will then often
               be successful.
               
Note: instead of the parameter number i you can use the short parameter name.
=load=dat=link=next===========================================================
LOAD filename     Load data and parameters.
LOAD              Ask for filename to load context.

DAT               Ask for filetype, filename/version number
                    (parameters are not loaded)
DAT filelist      Load data file(s) (syntax for filelist see below)

LINK filelist     Add more data (syntax for filelist see below)

NEXT       [N]    The same as DAT; MON; WIN; BARS; FUN

Filelist syntax examples:

101,103-105        Read numors 101,103,104,105 (actual year, actual instrument)
TASP/2000/10       Read numor 10 (year 2000 from TASP)
dmc/33             Read numor 33 from DMC (actual year, case not relevant)
2001/203,2002/10   Read numor 203 from 2001 and numor 10 from 2002
&101,103-105       Read numors 101,103,104,105 and merge them
+103-105           Read numors 103-105, conserving old data (as in the LINK command)

Example with options (see also command "OPT"):

focus/101[bank=b]  Read middle bank from numor 101 on focus
=options=======================================================================
You can preset options with the OPT command for successive data input, or
you may specify the options directly after the filename or numor enclosed
by square brackets [ ].

OPT     Show a list of options for the type of the last read
        file, show the previous selected options, and enter new options
        
OPT ?   Show a list of possible options and actually selected options
=save=file=out=list=export=====================================================
SAVE filename         Save data, fit parameters, window and scaling
SAVE                  Ask for filename before saving

FILE xstep, filename  Save two files with observed and calculated dataset
                      for other plot software (xstep for calculated dataset,
                      xstep=0: a default value of (xmax-xmin)/100 is taken).
                      Give TT as filename for output at terminal directly
FILE                  Ask for filename and step                              

LIST [L]              Listing on terminal (x, y, yfit)

OUT                   Output of listing (not a program-readable format!)

OPEN file             Open a file for output of fit results (default: fit.txt)

K par1,par2 ..        (K=keep) Write a line with values of given parameters
K                     Write parameters used last time or all parameters
                      You might use 'K' in the plot window for this command

EXPORT type,filename  export data (file types available: DMC, D1A)
EXPORT step,type,filename   export with given x step
=win=exclude=include=keep======================================================
WIN xmin,xmax            Set fit window.
WIN                      Ask for fit window
WIN 1,1                  Maximal fit window.
[W]

EXCLUDE x1,x2            Exclude range x1..x2
EXCLUDE x1,x2,y1,y2      Exclude rectangle (x1,x2,y1,y2)
EXCLUDE 1,1,y1,y2        Exclude range y1..y2
[EXCL]

INCLUDE ...              Re-include regions (syntax as for EXCLUDE)
[INCL]

KEEP                     List window and in-/excluded regions and
                           ask if they have to be kept on new data
KEEP Y                   Enable persistent window/regions
KEEP N                   Disable persistent window/regions 
=mon=merge=mul=sub=abskor=add=bgedit=usemon=trans======================================
MON m            Change Monitor
MON              Ask for Monitor

USEMON           Choose which channel to use as monitor

MERGE s          Add datapoints with same x (within a limit s).
                 If s is omitted, it is determined automatically
                 Overall monitor is changed, if appropriate

MUL s1,s2,s3...  Multiply datasets with scale factor.

ABSKOR muR,ri,ra Correct for absorption
                 muR<0 inverse correction (muR as for a full cylinder)
                 ri>0: hollow cylinder (inner radius/outer radius)
                 ra: sample radius/radial collimator fwhm

TRANS d,lambda   Transform x-axis from to d (powder diffraction)
TRANS q          Transform x-axis to q (lambda is taken from file or last cmd)
TRANS 2theta     Transform back to 2-Theta
TRANS            Ask for x-axis to transform to

SUB filename     Subtract a file from actual data

ADD constant     Add a constant to data

BGEDIT file      Edit graphically a background file
[BG]
=fun=auto=newpeak================================================================
FUN            Ask for fit function and start parameters.

FUN n          Select fit function n (ask for start parameters, if needed)

               n=0,1  Single Gaussian/Lorentzian  (auto start parameters)
               n=2,3  Multiple (1..4) Gaussian/Lorentzian
               n=4    Gaussian+Lorentzian
               n=5    Critical exponent
               n=6    Strange peak (auto start parameters)
               n=7    User function (see topic "User_function")
               n=8    Plot only (no parameters)

AUTO           Determine start values for first peak (for function 0,1,2,3,4)

NEWPEAK        Create a new peak (for function 0,1,2,3,4).

               Delete a peak by setting intensity and error to zero.
=plot=scal=rsc=choose=plog=plin=================================================
PLOT               [P]    Plot (See also topic "Graphics")
PLOT  yes                 Plot, make hardcopy file and do not wait.
PLOT  auto                automatic plot after every command
PLOT  off                 switch off automatic plot

SCAL xmin,xmax,ymin,ymax  Set plot scale
SCAL              [SC]    Ask for scale

RSC                       Reset plot scale (auto scale).

PLOG shift                Set logarithmic mode (and set shift between datasets)
PLIN shift                Set linear mode (and set shift between datasets)

CHOOSE           [CHO]    Select printer and printer options

See also:

  "FILE"  (export for other plot software)
  "STYLE" (plot style, legend)
  "Graphics" (hot keys in plot window)
=style=bars=connect=colors=legend=ncurves=======================================
BARS Yes/No               Enable/disable error bars. 

CONNECT Yes/No   [CON]    Enable/disable lines between data points

STYLE s1,s2,s3...         Change style of dataset points
STYLE                     Ask for dataset styles

COLORS           [COL]    Use colors for different datasets
COLORS n                  Use n colors for different datasets
COLORS 0                  Use black and white

NCURVES n                 Set number of curves for User-Function

LEGEND           [LEG]    Show legend (Numor is default)
LEGEND var                Use 'var' for legend ('LEGEND Temp' for temperature)
LEGEND 0                  Do not show legend
LEGEND label1|label2|label3 ....
                          Show a customized legend
LEGEND |label4|label5|label6 ....
                          Append to a customized legend
LEGEND @x,y               Set top left coordinate of legend (percent of window
                          width/height, y is measured from the top)

See also:
  "PLOT"  (other commands related to plot)
  "Graphics" (hot keys in plot window)
=help=info=exit=quit=tit=@=======================================================
@filename              Execute commandfile

HELP            [H]    Get help
HELP command           Get help on command.

INFO                   Show additional information from the last
                       read data file.
INFO level             level is a small number controlling the amount
                       of output for the info command

INFO variable          show the value of this variable

variable=value         set a variable

EXIT           [EX]    Exit program and save parameters and datapoints.

QUIT           [QU]    Quit program without saving..

TITLE title   [TIT]    Change title.
TITLE                  Ask for title.

FULLMESS               After this command, error messages are more detailed, and
                       the program quits after an error.
=user_function=build_program=====================================================
On Unix:

  Get an example file:    myfit

  Rename fitexample.f to a name of your choice (i.e. xxx.f)
  and edit the parameters and the fit function. 

  Compile:                myfit -o xxx xxx.f
  Run:                    ./xxx

You may add any g77 option or parameter to the myfit argument list.


On VMS:

To define your own user function, type MYFIT and change the file
FIT.FOR to your own function, rename the file to your own program
name xxx, compile it, link the program with

  LINK xxx,FIT4_SHR/OPT

and start your program with 

  RUN xxx


Related keywords: init     (inititalisation of user function)
                  function ()
                  cinfo    (how to speed up complex fit functions)
=init=============================================================================
User function initialisation

You have to call FIT_USERFUN to define title and function reference, and
you have to call FIT_USERPAR to define the name of each parameter.
Short name of variables can be given before long name, separated by
a colon ':'.

Call FIT_MAIN afterwards to switch to fit command mode.

If you want to keep control by program, you can call almost
every command (prefix FIT_, i.e. for plot you call FIT_PLOT).
In that case you must call FIT_INIT before calling other subroutines.

Short help is available under the name of the subroutine.
=function=========================================================================
You have to program a user function, whitch will be called from three
different places within FIT:

1.  when command FUN is called or a new function is loaded:
    MODE=-1
    all other arguments are undefined

2.  before each calculation of Chi-Square, i.e. before each Fit-Step:
    MODE=1
    X=0.0
    N:       number of parameters
    P(1..N): parameters
    CINFO:   Info about changed parameters (See Topic "CINFO")

3.  for each point of Dataset(s) and when plotting function:
    MODE=0
    X:       X-value
    N:       number of parameters
    P(1..N): parameters
    CINFO:   Dataset number or curve number
=cinfo=============================================================================
how to speed up complex fit functions

this section is useful only, if the main part of the calculation
does not depend on X, i.e. matrix diagonalisation

- split your calculation into several parts
- the subroutine FIT_USERCINFO(CINFO) determine the dependencies of the
  calc. parts and the parameters. The integer CINFO is a bit map, where
  each bit corresponds to a part of the calculation. The bit should be
  set if the part depends on the parameters named in the following calls
  to FIT_USERPAR.
- The integer CINFO within the fit user function determines, which
  part of the calculation has to be redone (corresponding
  bit set) and which part remains unchanged (bit clear)
=callable======================================================================
For example for automatic fitting of many files, you probably want
to call the fit-commands from a FORTRAN program. Before any call
to the FIT subroutines you have to call FIT_INIT.

                        for instructions on compile and link see topic "build"

Explanations for the topics below:

Specified arguments:   Call with specified arguments.
Default arguments:     For unspecified arguments, the subroutine uses
                       default values.
Ask for arguments:     The subroutine asks for unspecified arguments.
                       If you want to start your program in batch
                       mode you normally have to avoid these calls.

Available routines (use routine name as help keyword):
-------------------------------------------------------
fitting:            fit_fit fit_sim fit_min fit_chisq
                    fit_pri fit_err fit_epsi fit_vtest
function definiton: fit_fun fit_newpeak fit_auto
parameter handling: fit_set fit_fix fit_rel fit_cor fit_get_array
input / output:     fit_save fit_load fit_init fit_command fit_exit fit_range
                    fit_dat fit_link
data manipulation:  fit_win fit_mon fit_dat fit_link fit_subtract fit_merge
                    fit_auto_mon fit_multiply fit_add fit_abskor
                    fit_dat_put fit_bgedit fit_keep
                    fit_include fit_exclude
                    fit_get_array, fit_get_real, fit_get_str
                    fit_put_array, fit_put_real, fit_put_str
plot:               fit_plot fit_scale fit_rsc fit_bars fit_connect fit_title
                    fit_file
user commands:      fit_usercmd
                    arg_check_cmd arg_str arg_real arg_int arg_par arg_lit
library routines:   str_upcase, str_trim, str_append
                    sys_get_cmdpar, sys_setenv, sys_getenv
=fit_fit=fit_sim=fit_min=fit_pri=fit_err=fit_epsi=fit_vtest=fit_chisq=========
Specified arguments        Default arguments     Default value
--------------------------------------------------------------
CALL FIT_FIT(n)            CALL FIT_FIT(0)       n=1000
CALL FIT_SIM(n)            CALL FIT_SIM(0)       n=1000
CALL FIT_MIN(n)            CALL FIT_MIN(0)       n=1000
CALL FIT_PRI(n)            CALL FIT_PRI(0)       n=0
CALL FIT_ERR(err)          CALL FIT_ERR(0)       err=0.5
CALL FIT_EPSI(eps)         CALL FIT_EPSI(0)      eps=0,1*err
CALL FIT_VTEST(v)          CALL FIT_VTEST(0)     vtest=0.01

CALL FIT_CHISQ(chisq, istat)    get chi square and fit success status

     INTEGER n, istat
     REAL err,eps,v, chisq

=fit_set=fit_fix=fit_rel=fit_cor===============================================
Specified arguments        Default arguments        Default value
------------------------------------------------------------------
CALL FIT_SET(i,p,e,l,u)    CALL FIT_SET(i,p,e,0,0)  l=0,u=0: no limit
CALL FIT_LIM(i,l,u)
CALL FIT_FIX(i)
CALL FIT_REL(i)
CALL FIT_COR(i,j,f,c)      CALL FIT_COR(i,j,0,0)    f=1.0, c=0.0

     INTEGER i, j
     REAL p, e, l, u, f, c
=fit_get_array=fit_put_array=fit_get_real=fit_get_str=fit_put_real=fit_put_str==========
Get and put parameters and or data

CALL FIT_GET_ARRAY(name, array, ndim, nret)   
where:
     INTEGER ndim                ! dimension (input)
     REAL array(ndim)            ! resultant array (output)
     INTEGER nret                ! array length returned (output)
     CHARACTER*(*) name          ! name of array
                            ! 'P': fit parameter, 'E': parameter error
                            ! 'X','Y': data, 'S': data error, 'W': data weight

CALL FIT_PUT_ARRAY(name, array, nlen)   
where:
     INTEGER nlen                ! length of array (must match length of data)
     REAL array(nlen)            ! array (input)
     CHARACTER*(*) name          ! name of array
                            ! 'X','Y': data, 'S': data error, 'W': data weight
                            ! to change parameters use subroutine FIT_SET

CALL FIT_GET_REAL(name, value)
CALL FIT_GET_STR(name, l, str)
CALL FIT_PUT_REAL(name, value)
CALL FIT_PUT_STR(name, str)
where:
     REAL value          ! value to get or put
     INTEGER l           ! string length returned
     CHARACTER*(*) str   ! value to get or put
     CHARACTER*(*) name  ! call INFO 99 to see what variables are available
=fit_usercmd=arg_check_cmd=arg_str=arg_real=arg_int=arg_par=arg_lit=========================
User defineable commands

CALL FIT_USERCMD(cmds)        ! install command dispatch routine

logical fucntion to check command:
ARG_CHECK_CMD(command, len)   ! check for command (significant length: len)

subroutines returning arguments:

CALL ARG_REAL(value, default) ! get a real value argument from command line
CALL ARG_INT(value, default)  ! get an integer value argument from command line
CALL ARG_PAR(value)           ! get a parameter name/number as argument from ..
CALL ARG_LIT(string)          ! get a name as argument from command line
CALL ARG_STR(string)          ! get remaining arguments as string from comm...

Usage:
    external cmds
    call fit_usercmd(cmds)    ! call this within main module, after fit_init

    subroutine cmds(done)         ! subroutine to define
    logical done

    if (arg_check_cmd('DAT', 3)) then
      ... treat command dat ...
      done=.true.
    elseif (arg_check_cmd('PLOT', 1)) then ! P is accepted as well
      ... treat command plot ...
      done=.true.
    endif
    end
=fit_dat=fit_win=fit_mon=fit_link=fit_subtract=fit_merge=fit_multiply=fit_abskor=fit_bgedit=fit_auto_mon=fit_add=fit_mon=
Specified arguments        Default arguments        Ask for arguments
---------------------------------------------------------------------
CALL FIT_DAT(filename)                              CALL FIT_DAT(' ')
CALL FIT_WIN(xmin, xmax)   CALL FIT_WIN(1.,1.) (= max. window)
                                                    CALL FIT_WIN(0,0)

CALL FIT_MON(m)                                     CALL FIT_MON(0)
CALL FIT_USEMON(m)                                  CALL FIT_USEMON(0)
CALL FIT_LINK(filename)                             CALL FIT_LINK(' ')
CALL FIT_SUBTRACT(filename)                         CALL FIT_SUBTRACT(' ')

CALL FIT_RANGE(r1, r2, filenames) ! attention: r1, r2 are REALs

CALL FIT_MERGE(step)       CALL FIT_MERGE(0.0)
CALL FIT_AUTO_MON                adjust monitor after a FIT_MERGE

CALL FIT_MULTIPLY(scale,0)       one scale factor for all data
CALL FIT_MULTIPLY(scale,n)       scale is an array of factors for each dataset

CALL FIT_ABSKOR(mur,ri)                             CALL FIT_ABSKOR(0.0,0.0)
CALL FIT_ABSKOR2(mur,ri,ra)                         CALL FIT_ABSKOR(0.0,0.0,0.0)

CALL FIT_ADD(const,0)       const to add to all data
CALL FIT_ADD(const,n)       const is an array for constants for each dataset

CALL FIT_BGEDIT(file)

CALL FIT_EXCLUDE(x1,x2,y1,y2)

CALL FIT_INCLUDE(x1,x2,y1,y2)

CALL FIT_KEEP('Y')                                  CALL FIT_KEEP(' ')
CALL FIT_KEEP('N')                                  
=fit_dat_put===========================================================================
Put new datapoints into FIT

CALL FIT_DAT_PUT(mode, x, nx, y, ny, s, ns, w, nw)
where:
     INTEGER mode   ! 0: purge before, 1: link new dataset, 2: link to existing dataset
     INTEGER nx     ! nx=1: x-values are xx(1),xx(1)+1,xx(1)+2,...,xx(1)+(nx-1)
     INTEGER ny     ! number of data points
     INTEGER ns     ! ns=1: ss(1) <> 0.0: sigma values are ss(1)
                    !       ss(1) =  0.0: sigma values are sqrt(max(1.0,yy(i)))
     INTEGER nw     ! nw=1: weights are ww(1)
     REAL xx(nx)    ! x-values
     REAL yy(ny)    ! y-values
     REAL ss(ns)    ! sigma values
     REAL ww(nw)    ! weights

! precondition: (ny>0) and (nx=ny or nx=1 or nx=2)
!           and (nx=ny or ns=1) and (nw=ny or nw=1)

=fit_fun=fit_newpeak=fit_auto==================================================
Specified/auto arguments        Ask for start parameters
----------------------------------------------------------------------
CALL FIT_FUN(0, 0, 0.0,0.0)                         Gaussian
CALL FIT_FUN(1, 0, 0.0,0.0)                         Voigtian
CALL FIT_FUN(0, 1, pos,poserr)                      Gaussian at given start pos
CALL FIT_FUN(1, 1, pos,poserr)                      Voigtian at given start pos
CALL FIT_FUN(2, n, par,err)     CALL FIT_FUN(2, 0)  Multi-Gaussian
CALL FIT_FUN(3, n, par,err)     CALL FIT_FUN(3, 0)  Multi-Voigtian
CALL FIT_FUN(4, 12,par,err)     CALL FIT_FUN(4, 0)  Gaussian+Voigtian
                                CALL FIT_FUN(5)     Crit. exponent
CALL FIT_FUN(6, 0, 0.0,0.0)                         Strange
CALL FIT_FUN(7, n, par,err)     CALL FIT_FUN(7, 0)  User function
CALL FIT_FUN(8, 0, 0.0,0.0)                         Plot only

                                Ask for function and start parameters
                                -------------------------------------
                                CALL FIT_FUN(-1, 0)

CALL FIT_NEWPEAK
CALL FIT_AUTO

where:
    REAL par(np), err(np), pos, poserr
    INTEGER n
=fit_plot=fit_scale=fit_rsc=fit_bars=fit_connect=fit_title=fit_file==============
Specified arguments        Default arguments      Ask for arguments
-----------------------------------------------------------------------
CALL FIT_PLOT('Y')                                CALL FIT_PLOT(' ')
CALL FIT_SCALE(x1,x2,y1,y2)
                                                  CALL FIT_SCALE(0,0,0,0)

                           CALL FIT_SCAL(1.,1.,y1,y2)   (auto x-range)
                           CALL FIT_SCAL(x1,y1,1.,1.)   (auto y-range)
CALL FIT_RSC (auto range)

CALL FIT_BARS('Y')                                CALL FIT_BARS(' ')
CALL FIT_BARS('N')
CALL FIT_CONNECT('Y')                             CALL FIT_CONNECT(' ')
CALL FIT_CONNECT('N')
CALL FIT_PLOG(log,shift) ! log=0,1
CALL FIT_TITLE(title)                             CALL FIT_TITLE(' ')
CALL FIT_FILE(xstep, filename)                    CALL FIT_FILE(0,' ')
=fit_print=fit_list=fit_out====================================================
Specified arguments    Ask for filename
---------------------------------------
CALL FIT_PRINT(1)                   (equivalent to command FCN)
CALL FIT_PRINT(0)                   (print variable parameters)
                       CALL FIT_LIST
                       CALL FIT_OUT
=fit_save=fit_load=fit_init=fit_command=fit_exit=fit_export====================
Specified arguments        Ask for arguments
--------------------------------------------
CALL FIT_SAVE(filename)    CALL FIT_SAVE(' ')
CALL FIT_LOAD(filename)    CALL FIT_LOAD(' ')
CALL FIT_EXPORT(step, type, filename)   (auto step: step=0)

CALL FIT_INIT                        (has to be called first)
CALL FIT_COMMAND(filename)           (equivalent to command @filename)
CALL FIT_COMMAND('  ')               (switch to interactive mode)
CALL FIT_EXIT
=fit_userfun=fit_userpar=fit_usercinfo=fit_main================================
CALL FIT_USERFUN(title,function)  define user function (has to be called
                                  before FIT_USERPAR
CALL FIT_USERPAR(name)            define user parameter name (call once
                                  for each parameter)
CALL FIT_USERCINFO(mask)          define user calculation info mask for
                                  following calls to FIT_USERPAR
CALL FIT_MAIN                     start fit command mode
=str_upcase=str_append=str_trim=sys_get_cmdpar=sys_setenv=sys_getenv===========
CALL STR_UPCASE(out, in)           convert to upper case
CALL STR_TRIM(out, in, length)     determine string length without trailing space
CALL STR_APPEND(inout, length, in) append in to inout(1:length)

CALL SYS_GET_CMDPAR(out, length)   get command line parameters
CALL SYS_SETENV(name, value)       set environment variable
CALL SYS_GETENV(name, value)       get environment variable
=graphics======================================================================
Within the graphic window, you hit a key for a command:

Command        Shortcut 

Print          P     Printing Graphics
Insert         I     Insert peak at the actual x/y position.
                     the halfwidth is determined automaticaly.
                     (BGEDIT: insert point)
Delete         D     Delete peak (BGEDIT: delete point)
Repaint        R     Repaint graph
Zoom in        Z     Zoom in*.
Zoom out       O     Zoom out by a factor 2:1
Jump           J     Center graph at cursor position without changing scale
max.Scale      X     Automatic scaling (observed data fits the data window)
Window         W     Set fit window*
Exclude        E     Mark excluded region*
Include        N     Mark region to re-include*
Log/Lin        L     Switch between log and lin
Colors         C     Switch between colors and b/w
Show Coord.    S     Show (X,Y) value of cursor
Quit           Q     Leave graphic user-interface

* move to the first corner, click the correspoding key, move to the second
  corner, press the key again. If you want to perform the command only in one
  dimension, move to locations below the x-axis or left to the y-axis.
=history=======================================================================
Version 2.0
- FIT saves all parameters and the data file name on exit.
- You can now enter directly to command mode by pressing RETURN at the
    first prompt.
- The parameters of most commands can now be passed directly via
    command line.
- Command line editing (recall of previous 20 commands).
- Command-files can be executed.
- Old command WIN is now separated into the commands WIN, MON and BARS.
- New command MIG (call migrad only)
- Abort of fit algorithm by pressing <Ctrl-C> (return to command level).
- All commands of FIT are now callable FORTRAN subroutines.
- Enhanced user fit-function definition.
- Extended HELP

Version 3.0
- All peak functions (Gaussian, Lorentzian, Voigtian) have now the same
    parameters and switching between them can be done by changing parameters
    (If fwhm L = 0: Gaussian, if fwhm G =0: pure Lorentzian, else Voigtian)
- Graphics package is changed from PLOT10 to GRAPHX. FIT runs now on most
    graphic devices, including X-Window.
- Graphic user-interface: zoom, edit peaks, create new peaks, delete peaks.
- New peaks can be created by command NEWPEAK
- Peaks can be deleted by setting intensity to 0
- New command CHOOSE (printer options)
- COR i1,i2,f no longer has the restriction i1>i2

Version 3.3
- Load multiple data files
- Command LINK to load additional data
- Data from different files are plotted with different symbols
- Command MERGE to add points with same X-value
- New data file types available: IN3, D1A5, D1A6, 3-column

Version 3.5
- MULtiply data with scale factor
- SUBtract datafiles
- D2B-files readable

Version 3.6
- Data can be saved as DMC or D1A format
     use command SAVE with extension .DMC (or .D1A respectively)
- Command ABSKOR for absorption correction
- Parameter can be given as name instead of number (Example: FIX P1 = FIX 3)
- Short form for SET command. Example:  G1=0.4
- Command STYLE to set marker symbols or to connect points
- Enhanced output for Mac Plot Software (Kaleidagraph, ProFit...)
     use command FILE TT and Copy-Table in VersaTerm
- New command AUTO: determine start-values for Gaussian Fit without loosing
     FIX and COR settings.
- Bug corrected: Sometimes fit was not correct and errors were very small
     after a DAT command. This is now corrected.

Version 3.7
- Command CONNECT Y to connect data points

Version 4.0
- Now available on Digital Unix
- PGPLOT Graphics package instead of GRAPHX

Version 4.1
- Background editing command BGEDIT (replaces GEDIT program)
- Export command (actually supporting DMC and D1A datafile type)
- Enhanced Fortran-Interface

Version 4.2
- ADD a constant do data
- new data types: INX, CCL
- RANGE command for 2D data and multi-dataset files like INX or CCL
- subroutine FIT_DAT_PUT: load data from memory of calling program
- subroutines FIT_GET_ARRAY, FIT_GET_REAL and FIT_GET_STR: inquire data
    and parameters
- subroutines FIT_PUT_ARRAY, FIT_PUT_REAL and FIT_PUT_STR: modifiy data
- subroutine FIT_USERCMD: plug-in commands
- subroutine FIT_DAT_MERGE: fit_dat and fit_merge in one command
    (to avoid memory overflow)
- made available some library soutines: STR_UPCASE, STR_TRIM, STR_APPEND
    SYS_GET_CMDPAR, SYS_SETENV, SYS_GETENV
- subroutine FIT_VERS: get actual version

Version 4.3
- new commands EXCLUDE, INCLUDE: excluded regions
- new command KEEP: persistent fit-window (select if fit window and
    excluded regions are kept on DAT command)

Version 4.4
- new commands PLOG and PLIN for logarithmic plots and shifted
  datasets
- new commands LEGEND and COLORS
- can read RITA single detector files

Version 4.5
- absorption correction for hollow cylinders
- plot fullprof output files
- new command TRANS (transform x-axis between 2theta/d/q for powder diffraction)
- more options for calibration of powder diffraction data
- user function may be folded with gaussian (example: program BOSE)
- can read HDF5 files (TriCS NeXus files)
