Technical and program details.


Technical information:


An early version of Fortran was used in 1971 for the program for the first paper in which the Boundary Element Method was used for charged particle optics.  Later Fortran 90 and later versions of Fortran were used.  When the programs began to be commercialised in the 1990’s C++ was used for the necessary user interface.  The programs have been in continual development since then, with Fortran, as a higher level language, used for the complicated mathematical parts of the programs, and C++ for the parts connected with editing and the user interface.  The Salfor compiler has been used.

The CPO programs are almost alone in using the Boundary Element Method, which (1) gives extremely high accuracy, (2) allows small or sharp electrodes to be easily simulated and (3) is ideally suitable for space-charge and cathode problems.  The BEM also allows the definition of electrode shapes by user-supplied equations, if necessary.

Size of programs

The total number of non-blank lines in the program files is greater than 173,000.  

Comment lines and Reports

The programs are well documented.  Approximately 36% of the program lines are comment lines or contain comments added at their ends.  In addition there are 47 ‘reports’ that deal with some of the more mathematical aspects of the programs.  These are hand-written and are referred to in the program comment lines.  The more important mathematical developments have also been published in the international literature.  Please contact CPO L td if you are interested in these reports.

On-line Help and Users Guide

Approximately 95% of users never contact CPO Ltd more than once or twice after purchasing programs, which has always indicated to us that the users are satisfied that they can find what they want in the on-line Help, which is large, comprehensive and extensively cross-referenced.  It can be accessed on the top toolbar, and almost every editing screen has a Help button for more specific help.  It contains over 275,000 words, over 600 topics and over 1500 items (keywords) in the index.  A clear style is used and jargon is avoided.  The Users Guide contains over 19,000 words.  It is useful as an initial guide, but everything in it is also in the on-line Help.

General structure of the programs

The main data files and associated actions are as follows.

  1. The user’s data file, which might initially be one of the 267 example data files or might be a data file that the user has previously edited.  This is referred to as the ‘primary data file’.  It is named by the user but for the present purposes let us name it primary.dat.
  2. The ‘processed data file’, which is again named by the user, but for the present purposes let us call it processed.dat.  Only a tiny minority of users will want to read this, so in the CPO literature it is referred to as a ‘hidden file’.  In fact all the files except primary.dat are hidden files.  When a new primary.dat is run the program creates processed.dat.  The first part of this is a copy of primary.dat, call it 'processed1'.  The second part is the processed data that follow from the actions of subdivision, symmetry planes, etc on the electrodes, call it 'processed2'.  These data are then in the correct format for the creation of the electrodes.  The non-electrode data (ray data, space-charge data etc) are not processed.
  3. An early action in a run is to compare primary.dat with processed1, if it exists.  If they are the same then the data saved in 'processed2' can be used.  Otherwise 'primary.dat' is read as a new file. 
  4. A copy of primary.dat is used for editing.   Binary files are also created and are available for the storage of space-charge information.

Editing using the data-builder.

When databuilder is opened a string f1 starts as the contents of primary.dat and is shared with the rest of the program via a common block.  Characters are extracted from f1 by a ‘fgets’ instruction (in C++) and are added by a ‘fprintf’ instruction, (see pre3d.cpp for more details). 


The sizes of the various parts of the program were approximately as follows, at Aug 2003 (and the size has obviously increased since then):


Part Number of lines Number of files


Charged particle optics 34510 

User interface 18838 

Examples of user-supplied programs 3241 

Test, example, shape, files    72 (increased to 96 by Sept 2016)


Charged particle optics 44292 

User interface 28112 

Exampes of user-supplied programs 5525 

Test, example, shape files    110 (increased to 182 by Sept 2016)

Totals: CPO2D,3D 134518 

Help system 27596 

Users Guide 1995 

Grand total 164109 


Help (at Sept 2016):

612 topics

1536 index items (keywords)

Intellectual Property Rights.

CPO Ltd holds the IP rights of the material comprising the source code and associated material.


CPO Ltd and its directors give no warranty that all errors have been removed from this or any related software or any documentation associated with the software, and neither the Company nor any of its employees, contractors or agents, nor the authors of the software give any warranty or representation as to the suitability or fitness of such software or any such program for any particular purpose nor shall be liable for  any loss of profit or any loss of opportunity or for any losses, whether they be direct, indirect, consequential, from damages, costs, expenses, claims or fees of any nature or kind resulting from any deficiencies, defects or errors in the software or the documentation or any related product.

CPO Ltd and its directors take no responsibility for the software and/or programming/source code and/or the supporting material and shall not be held in any way liable for the same and/or responsible for the use made of the programmes and the source code and the supporting material.

CPO Ltd and its directors give no warranty that the comments in the coding of the source code or associated material are comprehensible or comprehensive or correct, nor that the associated handwritten reports mentioned above are legible or comprehensible or comprehensive or correct. 


See also memory space requirements.