UoC crest

MJR's Castep Notes

This page contains some random information about the use of Castep. It is incomplete, but contributions are welcome. It is provided mostly so that I can remember what I have done, and in the hope that it might be of some use to someone else.

Some of the background theory to Castep and DFT can be found in chapter IV of my thesis.

(I also have unmaintained notes on the ancient, Fortran77, pre-commercial version of Castep. In the unlikely event that someone wants these, they can still be found here.)


The Castep distribution provides many useful utilities. Some it does not include:


These notes should mostly apply to plane-wave codes in general, not just Castep, but I make no promises.


A simple test of Castep on an ethene molecule.

Over-riding FFT grid selection

I often find myself wanting to do this, for various strange reasons. It seems to be undocumented and unsupported, but, in a .param file, a block such as the following seems to work.

%block devel_code 
STD_GRID=50 50 45 FINE_GRID=60 60 50
%endblock devel_code

Such devel_code blocks tend to have little error-checking, and are not intended to be used saved for by developers, so you have no right to blame anyone should they not behave as expected. For my own convenience, I record here the syntax for changing the Ewald converge tolerance from its default of 100 (should never be necessary). The value below should give wrong answers most of the time. Replacing the "2" with "1000" might give one confidence that the Ewald sum was correctly converged.

%block devel_code
%endblock devel_code



The main use of this is that it magically merges MPI messages when run on a machine with multiple shared-memory nodes, and thus improves scaling. In other circumstances it is of little use, but adds C code to what is otherwise a pure Fortran project.

The source file for this which is part of Castep 17.21 (and earlier) is incompatible with ifort 17.0 (and later) when used with most versions of OpenMPI. This can be fixed by removing the
include "mpif.h"
line and uncommenting the
Use mpi
line a couple of lines earlier in Source/Utility/FreeIPC.f90.


Depending on how one's compiler is set up, adding
include 'mkl_dfti.f90'
to Source/Utility/fft.mkl.F90 may make it easier to compile this file.

Avoiding make

The Castep build system is flexible, but, for bears of little brain, verging on the incomprehensible. I tend to use a simpler shell script for compilation, an example of which is below. The script will be tied to a particular version of Castep, due to the addition of extra source files as functionality is extended. It is offered with no guarantee of functionality or correctness!



Useful Links

Castep in TCM

The c2x utility is centrally installed.

Further information about Castep itself in TCM can be found on TCM's internal Castep page.