FitSuite  2.0.0
Reading Sources

Short help for those who would like to understand the sources of simulation algorithms

After installation of the program the sources of the of simulation algorithms can be found at the path Repositories/FitSuiteProvided/standard/src relative to the main directory of the program. The documentation of these files is available at Repositories/FitSuiteProvided/standard/doc. This is still far from to be complete, but may be helpful. E.g. The ‘main routines’ belonging to X-ray reflectometry are in file synrockexD.f. There are also other files which contain essential routines called by the main routines, but we think it will not be a problem to find them starting from synrockexD.f with the help of the corresponding html file in the documentation (like Repositories/FitSuiteProvided/standard/doc/html/synrockexD_8f-source.html), where the function calls are links.

What may be a bit problematic to understand, how the parameters and the layer structure are obtained from the subroutines arguments provided by the main program FitSuite, therefore we try to give you some help here. We think it is easier to explain through examples, so let see some. In synrockexD.f you will find a lot subroutine calls like ‘call getpropertyoftype(k,pr_background,pinf,ad_background)’. Here ‘k’ is a number determining the object (FitSuite terminology e.g. layer) whose parameters you are interested in. The second argument pr_background is a constant read in from common blocks (available in Repositories/FitSuiteProvided/standard/src/structyid/), showing which parameter you are interested in, on the interface of FitSuite you will find the same parameters without the prefix pr_ (ot ipr_ in case of integers). pinf is an array provided by the FitSuite containing information about the addresses (indices) of the parameters in arrays p (real numbers) and p_i (integer numbers). These addresses are returned in the last argument, in this example ad_background. After calling getpropertyoftype(k,pr_background,pinf,ad_background) the background value will be p(ad_background).

Similarly, following the same logic, we may obtain addresses of array, using the subroutines like getinputaroftype, getoutputaroftype, getoutputaroftype, getconstaroftype, ...

To obtain the first argument of getpropertyoftype, e.g. for a layer we have some other subroutines. These number for the root (object) in the object tree hierarchy is always provided as the first argument of the ‘main’ subroutines, like in synrockexd the argument cur_scheme. Starting from this we can determine the corresponding arguments for each object with the help of the subroutines childrennumber, firstChild, nextchild and isgroup. E.g.:

call childrennumber(cur_scheme,pinf,j) ! returns in j the number of children in the root in this case the number of incoherent parts. (An incoherent part is used, when the sample, has inhomogenities (e.g.: wedged sample), that it can be divided into smaller approximately homogeneous parts, whose contribution can be taken into account by summing up them incoherently, i.e. the intensities and not the amplitudes.)
call firstChild(cur_scheme,pinf,cur_incoh) !returns in cur_incoh the address of the information block in array pinf belonging to the first incoherent part.
if(j .gt. 0)then ! there is at least one incoherent part
do i=1,j !let see each incoherent part
layernumber=0
call childrennumber(cur_incoh,pinf,laynumber) ! the incoherent parts may contain layers
if(layernumber .gt. 0)then !there is at least one layer
call firstChild(cur_incoh,pinf,cur_lay)
do v=1,layernumber
call getpropertyoftype(cur_lay,pr_thickness,pinf,ad_thickness)
thickness(i,v)=p(ad_thickness) !the thickness of the v-th layer in the i-th incoherent part.
call nextchild(cur_lay,pinf,gg) !returns in gg the address of the information block in array pinf belonging to the next layer.
cur_lay=gg !update cur_lay and continue
end do
call nextchild(cur_incoh,pinf,utemp) !returns in utemp the address of the information block in array pinf belonging to the next incoherent part.
cur_incoh=utemp !update cur_incoh and continue
end do
end if

In this example we do not have layer groups, for which we have the subroutine isgroup. E.g.: call isgroup(cur_lay,pinf,g) returns in g the group repetition number if ‘cur_lay corresponds to a layer group’ and 0 if it is a layer. If it is a group, then contains layers then after a call like call childrennumber(cur_lay,pinf,lx) lx will be the number of layers in this group. In synrockexD.f you will find code where groups may appear.