Close This Window

Please download official ILL logos here

 

For using on the web or on a screenFor printing in high resolutionWhite version, for dark backgrounds

Download PNG

Download AI

Download white PNG

Download JPG

 

Download white AI

Technical description

The Computing for Science (CS) group supports ILL scientists, students and visitors in a number of activities including data analysis, instrument simulation and sample simulation.

Back to ILL Homepage
English French Deutsch 

All Software

Clickfit - a GUI interface for fitfun interactive fits

for Fitfun version 7.0 onwards, R. Ghosh, ILL, 2006-2010


Summary

A file-based communications interface has been added to fitfuns to allow programs linked with this library to be driven from an external GUI program. An example, Clickfit, written in Tcl/Tk is presented below. The windows used within Clickfit are easy to modify, being configured in a separate file, which also has the basic system information required by the graphics library (PGplot).

The initial command line control options are retained, allowing rapid prototype development.


File communications with fitfun version 7

Several files are used for passing commands and information between GUI and the fitfun program. initialisation

A job sequence number is added to the command line when the fortran program is launched. Subroutine PRELUDE, either called in the main program, (or in any case at the start of the fitfun routines) checks the command line for such a jobname eg job433 as the argument after the program name, and if found assumes it must expect commands via the communication files shown below. The first command is sent to the prelude routine and is a character string of data which, like subsequent commands, is copied into a FORTRAN common/comin/bufin where bufin is character*150. This allows a flexible method of furnishing data from commands for use in the fitting program, notably for reading data and data-linked parameters. The PRELUDE routine sets up the communication files. These are deleted on normalprogram termination A sequence number is included in each command, and the corresponding number is returned in the reply file. Further information is also returned in an information file as illustrated below:

for example program fitp, sequence number 433


GUI Fitfun program

writes command m into fitp433.fcd ----> reads command
|
performs command
usual terminal output to fitp433.log
|
writes status into
fitp433.fif
|
writes reply to m in
notes updated number m in reply |
file showing command is complete <----- fitp433.frp

Polling
The GUI send its message and tests the contents of the reply file, typically every 0.1 secs. If no reply is received after ten seconds it is assumed that the calculation program has failed and that a post mortem should proceed by exmining the log files and the remaining *.fcd, *.frp and *.fif files. Similarly, once started, the fitfun calculation program scans the fitp433.fcd file for a newly numbered command, polling again after a sleep of about 0.1 secs. In this case up to 15 minutes is allowed to elapse before logging a timeout and the program terminates.

Unexpected terminations

The primary cause should be signalled in the log file. In the case of communications being lost between the two programs it is possible that the calculation program continues to run, polling for a possible command until the 15 minute timeout is reached and the program terminates. Since the sequence number for the jobs is incremented each time a subsequent program launch will not interfere with the idling program, which may be terminated manually without prejudice.


Debugging aids

A problem noted in one case specific to Vista lead to additional debugging code being added to the communications in FTPRLD.  This tests the environment variable FT_DEBUG.  if set then the communications are added to the log file.  In the main window the menu includes a debug facility which shows additional messages.  The routines are normally very robust; in the case of failure the appropriate .fcd, .frp, and .fif files, together with the log file contain a considerable amount of information and should be included with any request seeking further help.