Programs to fit Neutron Reflection Data

June 1997, Last modified 29 May 2018

These programs provide a means of making interactive, graphical fits to neutron reflection data using multilayer models calculated using optical matrix methods. The parameters may be changed manually to explore the effect of different structural models or varied using a least squares algorithm. A simple model with up to four layers can be modelled with DRYDOC and continuously varying profiles appropriate to polymers at interfaces with penetration of solvent with LPROF.

1. Versions of the Programs

General Remarks

There are three old versions of the programs that are available but only one is currently maintained. The current version is intended for operation with Windows XP and can optionally be run with a GUI. The current version of drydoc is 4.3 and is prepared using the MinGW Fortran compiler. The current version of lprof is 2.3 . The old versions are set out in the table below:

Number Operating Systems Comments Download
1 XP, Vista, Windows 7 Operates in DOS Window drydoc.zip
2 Windows 2000, XP Separate 'Input' and 'Graphics' Windows  
3 Silicon Graphics, Unix    
4 Windows XP, Vista, Windows 7 This optionally runs with a GUI. This is the current maintained version. refprog_2015.zip
5 Macintosh OSX This optionally runs with the clickfit GUI. This is a current version. RefOSX_Jul2013.zip

The DOS version of the program functions normally but is not subject to further maintenance. The installation of the programs is described separately.

The programs are written in FORTRAN and use the FITFUN fitting package and PGPLOT (T. J. Pearson, Caltech) graphics as modified by R. E. Ghosh from the ILL, Grenoble, France.

A program WETDOC is now available (for Windows and SGI Unix) that permits simultaneous fits to several data sets that may be measured under conditions of different contrast.

1.0 Current Versions for Windows XP

The current version can either be run using Prop as described in 1.2 or a further enhancement with Clickfit allows a full graphical user interface. The instructions for the Clickfit GUI are also available at the ILL WWW site. To use this GUI it will be neccesary to install Prop and to start clickfit.bat with prop. The programs drydoc.exe and lprof.exe will be started using the corresponding *.fcl file by clickfit.bat. The use of the current version is highly recommended as it provides (with Prop) an easy means to set-up all Environment variables and easy access to printing of output by means of standard Windows XP tools.

1.1 Versions for DOS or DOS Windows

The programs DRYDOC and LPROF can be run on 386, 486, Pentium and other compatible processors under DOS. They have been converted using the Microsoft patch to run on 32 bit systems (Windows 9x, Windows NT, 2000, XP). They are compiled with Microsoft PowerStation FORTRAN 1.0


It will be necessary to copy the entire contents of the zip file to an appropriate directory. It will also be necessary to edit the files RDRYDOC.BAT and RLPROF.BAT so that the directory for the PGPLOT fonts (set to A: in the file) is in the current path as well as the file DOSXMSF.EXE. If this EXE file is already in your path on the computer, the version on the distribution can be deleted. It may be convenient to copy the file to a directory that is always in the PATH such as C: or C:\DOS.

The PGPLOT library uses environment variables and it is possible that the space may need to be augmented by adding the following line to CONFIG.SYS


If other applications already use a large amount of environment space you may need to increase the current limit by 512 bytes. If there are difficulties please let the author know. Try to provide full details of operating system, error messages and the data sets and parameters used.

1.2 Old Versions for Windows (2000, XP etc.)

The programs DRYDOC and LPROF can be run on i86, and other compatible processors under NT and later versions of Microsoft Windows. They are compiled with MinGW f77.


It is recommended to run the program using the utility 'Prop' available from the ILL. Instruction for download and use of Prop are available from the ILL WWW site.

1.3 Versions for UNIX (SGI)

The programs DRYDOC and LPROF can be run on SG computers and has been compiled and linked for 32 bit processors.

Versions Use, Hints, Acknowledgements , Contact

Top of Page

2. Use of programs

Instructions on the use of FITFUNS can be found in the documentation at the ILL, Grenoble.

The main options for the program are chosen from a 'Prelude' dialogue box that allows selection of the data format, number of layers, use of resolution function etc.

The default choices in the prelude can be changed by editing the appropriate .fcl file. Once the choices are made, the main program is controlled from a different interactive window:

The individual variables can be selected with a mouse and a new dialogue box appears that allows new values for parameter and the step size to be given. Other functions can be selected from the buttons or pull down menus. When display of data or a fit is calculated, it is shown in a separate graphics window:

Older Windows/DOS Versions

The program is run with the file RDRYDOC.BAT or RLPROF.BAT which set up the necessary graphics variables and runs DRYDOC.EXE or LPROF.EXE. If the files are set up correctly the programs can be run by starting them with these BAT files from the file manager in Windows. It is often easier to diagnose problems by opening a DOS window or even running directly under DOS.

2.1 Data Files

Four ASCII data formats can be read in the current versions. These are

The data format is selected in either the opening dialogue or the Clickfit 'Prelude'. A fuller description of the data formats is available at
http://www.reflectometry.net/refdata.htm. The four column data set input has been added in August 2007. The 4th column provides information about Q resolution of the data. At present this resolution is not automatically incorporated in the calculation but information must be provided separately. The input routine is purely to provide convenience and avoid reformatting data.

Old versions of the programs had a restricted data input format. The program read data files with the extension .dat and the extension must NOT be given as part of the file name (it is taken automatically). An option at start of the program is to read histogrammed data (as from the instruments SURF or CRISP at ISIS) with the default extension .asc (again not given in the program). The format of the .dat data files is as follows:

N Number of data points (integer)

Q, R(Q), ER(Q)

Data given as Q (A-1), reflectivity and error in reflectivity (repeated N times on a new line each time)

An optional line of title

The data can be freely formatted (e.g. F or E) with space separators. If insufficient data is found a warning is given.

2.2 New Program Features

The user is invited to experiment with option J (Extras menu) in LPROF which provides an option to display the real space scattering length density profile.

Other new features include:

2 .3 Test Data

A test data set (F17246.DAT) is provided which should be modelled as a silicon/silicon oxide/D2O interface. The scattering length densities are 2.08, 3.4 and 6.35 in the units used in this program (1 x 10-6 A-2). The use of 1 layer at the interface with a thickness in the region of 10 A is a good starting point for a fit. The default options on entry to the program can be used. If the parameter files REFT.FFN and LPRF.FFN are copied to the working directory they should contain reasonable starting values.

2.4 Hints

In studies of complicated systems make sure that the model for the bare substrate fits the data measured for that system before proceeding to more complex systems. It is useful to build up from simple models (few layers) to more complex models (many layers) when trying to fit data. Check that the model is compatible with all contrasts before proceeding.

Resolution can be included in different ways: the normal function would be to assume a constant dQ/Q. A further option is either constant dQ or a combination of terms that have fixed values of dQ/Q and dQ. This resembles a function that approximates to fixed slits at various angles is available for scans made in this way (using the old version of D17 at the ILL.) Data from D17 is no longer normally collected in this way. Old versions of the program allowed definition of resolution in terms of the slit sizes etc but this. is no longer included in current versions

Users can experiment with the number of layers to make the profile in LPROF and the resolution. The default value of 50 may be slow if resolution smearing is used in the calculation. If thick films are being studied the resolution may be very important and it will not be possible to make rapid approximate fits with no resolution calculation.

The default options in these programs are for equal weighting of all data points in the fits. This is often found to be more satisfactory than weighting by the errors which are frequently not appropriately chosen. Systematic errors and variation in the resolution may be large compared with the random errors particularly at large reflectivity (small Q).

The J command (Extras) can be ued in LPROF to create a imple plot of the scattering length density profile that is used in the model.

2.5 Definitions

The program assumes that data for scattering length density is provided in units of 1 x 10-6 A-2. If the momentum transfer, Q, in the input data files is in A-1 then the thickness of layers must be given in A.

The following summary of definitions may be useful:

The following diagram indicates this arrangement schematically.

2.6 Models in LPROF

The following models for profiles are available in lprof:

  1. Exponential decay
  2. Linear profile
  3. Half-Gaussian
  4. Scaling law
  5. Complementary Gausian error function
  6. Parabolic profile (for polymer brushes).

There are references to the use of models 4 and 6 in O. Guiselin J. Phys. 50, 3407-3425 (1989) and E. P. K. Currie et al Physica B, 283 17 - 21 respectively.


2.7 References

A description of the methods used in these calculations is given in the Rutherford Appleton Laboratory Report: 'Adaptation of Methods in Multilayer Optics for the Calculation of Specular Neutron Reflection' by J. Penfold, No. RAL-88-088. Other details on the calculation of reflectivity profiles can be found in the books by O. S. Heavens, 'Optical Properties of Thin Solid Films', Dover and J. Lekner, 'Theory of Reflection', Nijhof.

Install Use, Hints, Acknowledgements , Contact

Top of Page

3. Hints on Solving Problems:

3.1 Libraries

For details on the use of the libraries (fitting and graphics) see the information on the web www.ccp14.ac.uk/exill/illarch.html#TOOL

This site provides information about other output devices for PGPLOT in particular the use of non-postscript laser printers although for many purposes, a screen dump using the 'Print screen' key may be the most convenient. Remember to use e.g. Graphics LaserJet at the DOS prompt before starting the program.

3.2 Printing Graphics

The remarks apply primarily to older versions of the programs. The current version can use Windows tools to print graphics. Th output of a Postscript file can also be used for subsequent plots.

It may be necessary to modify the command files that run the programs if non-postscript printers are used. For a HP laser printer or DeskJet try:


The postscript output can be altered to different formats (e.g. number of plots per page or orientation). See the information on the graphics library for full details.

3.3 Other Problems

(a) On some systems it may be necessary to define the graphics system and a line of the following form should be added to the .BAT files:


(or SGA16 or VGA25 or SGA25).

(b) If the program does not find the fonts, the directory of grfont.dat is not in the current path and blank plots will appear. Check that all the environment variables are correctly set with the command:


which will then show all the current variables (for the DOS window if running under windows).

4. Acknowledgements

I am extremely grateful to Dr Ron Ghosh of the ILL, Grenoble for provision of the libraries and much help in preparing the programs in the present form.

Versions Use, Hints, Acknowledgements , Contact

Top of Page

Professor Adrian R. Rennie
Uppsala University, Uppsala, Sweden

E-mail: Adrian.Rennie@physics.uu.se

Versions Use, Hints, Acknowledgements Contact

Top of Page

© Copyright A. R. Rennie Last updated 29 May 2018