Integrating CASTEP with M.S. Gateway under Windows

Academic CASTEP can be integrated with the Materials Studio Gateway software as a replacement for the Accelrys-supplied executable. Because the academic version uses paper/contract based licensing there is no electronic license file required. The steps are as follows
  1. Either compile the source code of CASTEP to suit your windows installation, or use the precompiled executable for Windows from the distribution at CCPForge. You should have a file named castep.exe.
  2. Find the location on your windows partition where the gateway software was installed. This is typically something like C:\Program Files\Accelrys\Materials Studio 4.3\bin, but may vary according to installation-time choices
  3. In that folder are the Accelrys CASTEP executables castepexe.exe and castepexe_mpi.exe.
  4. Keep a copy of the Accelrys executable castepexe.exe by renaming it to something else such as castepexe.exe-bak.
  5. Copy the UKCP release executable into this folder and rename it to castepexe.exe.

***NEW*** Installing the MPI executable under Windows XP

The Accelrys Materials Studio Gateway system and CASTEP executable use the commercial HP-MPI implementation of the MPI parallel libraries and runtime. If you have purchased this and compiled and linked CASTEP source against HP-MPI, then the resulting executable can be installed alongside the serial one as castepexe_mpi.exe and it should run from the Gateway. MPI executables linked against any othe MPI implementation are incompatible with the HP-MPI run-time start up and will not work by default. However it is straightforward to customise the MS Gateway to invoke an alternate runtime system which is compatible with the executable. The instructions which follow are for the MPICH-NT implementation, and there is an MPICH-NT executable castep-4.4-mpichnt.exe downloadable from CCPForge.
  1. Download the MPICH-NT installer from the ANL Mpich-NT website. This is a click-to-run Windows software installer, and will install in the standard place C:\Program Files\MPICH
  2. Install the CASTEP mpich executable in the Materials Studio bin folder, renaming it to castepexe_mpi.exe
  3. Customise the Materials Studio Gateway to invoke the MPICH-NT Mpirun command instead of the HP-MPI one.
    1. Visit http://<gateway-host>:18888 using a web browser.
    2. Select theGateway Data link from the menu of links on the left and press the Edit button at the bottom left.
    3. Input your gataway administrator login credentials (by default "gatekeeper" and no password).
    4. Find the "mpicommand" setting and change this to invoke the mpich-nt MPIRun command.
      If installed in the default place this is "C:\PROGRA~1\MPICH\mpd\bin\MPIRun.exe -np"
    5. Click the Save button.
It should now be possible to run jobs in parallel from Materials Studio on a single SMP or multicore machine using MPI.

Integrating CASTEP with M.S. Gateway under linux

The procedure follows much the same lines as installation under windows.
  1. Either compile the source code of CASTEP to suit your linux installation, or use the precompiled executable from You should have a file named castep.
  2. Find the location on your linux filesystem where the gateway software was installed. This is typically something like /opt/accelrys/MaterialsStudio43/bin/, but may vary according to installation-time choices.
  3. In that directory are the Accelrys CASTEP executables castepexe.exe and castepexe_mpi.exe.
  4. Keep a copy of the Accelrys executable castepexe.exe by renaming it to something else such as castepexe.exe-bak.
  5. Copy the UKCP release executable into this folder and rename it to castepexe.exe.
As in the windows case, a "drop-in" replacement for the MPI executable is difficult to create, and would probably need a licensed installation of the commercial HP-MPI system to function. However it is possible to use a different MPI system, such as open-mpi or mpich, provided that you modify the gateway scripts to use the correct mpi startup command. The procedure is almost the same as in the Windows case above. Simply set the "mpicommand" variable to invoke the appropriate "mpirun" command.

Using Materials Studio with a remote cluster

For reasons of security, most managers of university computer clusters will not install the Accelrys gateway software. In that case it is still possible to work using Materials Studio to generate and analyse the run using the following procedure.
  1. Use Materials Studio to set up the CASTEP parameters for the run as you would normally.
  2. Do not use the run button, but instead click the save files button. This will create a folder on the windows machine containing the .cell and.param files for the runs.
  3. Find this folder on the windows disk, and using your favourite file transfer software transfer the entire contents of the directory to the remote cluster for execution. Note that by default Materials Studio sets the attributes of a .cell file to be a hidden file. It will therefore be necessary to change the properties of the folder using windows explorer to show hidden files.
  4. In addition to the files generated by Materials Studio the pseudopotential files will be needed for the run to proceed. These may be found in the Materials Studio installation folder c:\Program Files\Accelrys\Materials Studio 4.3\share\Resources\Quantum\Castep\Potentials, or downloaded from the CCPforge distribution.
  5. One useful trick for handling pseudopotentials in a parallel cluster is to have a single directory containing the entire library. If this is called, for example /usr/local/share/pseudopotentials then in the batch job script, or shell startup file such as .bashrc set the shell environment variable PSPOT_DIR, e.g.
    export PSPOT_DIR=/usr/local/share/pseudopotentials,
    and CASTEP will look there for its pseudopotentials. (Note that different MPI systems sometimes get in the way of setting environment variables for processes and may need different recipes to set them.)
  6. In the case of a properties run, Materials Studio actually generates more than one CASTEP job. There is an initial job, <seed>.cell etc. and one or more of the form <seed>_BandStr.cell
  7. (for a bandstructure run). These should be run consecutively on the cluster, either in a single jobfile or as a consecutive sequence of jobs. The properties jobs are set up as continuation runs and expect a checkpoint file. It is therefore necessary for the job script to issue the command
    cp <seed>.check <seed>_BandStr.check
    before starting the properties calculation.
Note that Materials Studio generates some additional files with the extension .kptaux which it needs for the analysis, and that it is in general not possible to analyse a run constructed by hand using Materials Studio. Or at least it is too hard to be worth attempting.