• ## Bainite

It's not pearlite or martensite. A blog written by Mathew Peet.

## Octave/ Matlab is fun – Enter the Matrix

f = rot90((diag((ones(5,1)))) + hankel(zeros(5,1),2*(ones(5,1))),1)
warning: hankel: column wins anti-diagonal conflict
f =

0 2 2 2 3
0 0 2 3 2
0 0 1 2 2
0 1 0 0 2
1 0 0 0 0

hess(diag((ones(4,1))))
ans =

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

eig(diag((ones(4,1))))
ans =

1
1
1
1

diag([1,2,3],4)
ans =

0 0 0 0 1 0 0
0 0 0 0 0 2 0
0 0 0 0 0 0 3
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0

rot90(shift(rot90(rand(4),1),1),3)
ans =

0.141505 0.100645 0.200515 0.552900
0.163904 0.081520 0.505508 0.356016
0.458187 0.275491 0.472148 0.434868
0.988882 0.267269 0.680475 0.424024

## My second g++/cpp program – Using a Makefile

http://www.cs.bu.edu/teaching/cpp/separate-compilation/

This demonstration explains how to compile using the make file. In this example you split up the program into separate modules, and use a make file to compile. This has the advantage that after making a change, only that part of the program needs to be recompiled.

```#ifndef POINT_H #define POINT_H /* * File: Point.h * Last Modified: January 31, 2000 * Topic: Modules, Separate Compilation, Using Make Files * ---------------------------------------------------------------- */```

``` #include // one of two using namespace std; // two of two, yay! class Point { public: Point(); Point(int xval, int yval); void move(int dx, int dy); int get_x() const; int get_y() const; private: int x; int y; }; ```

```#endif ```

otherwise you will get the error:
```g++ -c -o main.o main.cpp In file included from Rectangle.h:13, from main.cpp:9: Point.h:13: error: redefinition of 'class Point' Point.h:14: error: previous definition of 'class Point' ```

and the Makefile looks like this:
``` # Makefile for Separate Compilation Example```

``` # ***************************************************** # Parameters to control Makefile operation CXX = g++ CXXFLAGS = # **************************************************** # Entries to bring the executable up to date main: main.o Point.o Rectangle.o \$(CXX) \$(CXXFLAGS) -o main main.o Point.o Rectangle.o main.o: Point.h Rectangle.h Point.o: Point.h ```

```Rectangle.o: Rectangle.h Point.h ```

after running the make command you will have a bunch of object files (.o) and an executable. If you edit Rectangle.cpp and run make again then only Rectangle.o needs to be made again. The programs fragments of binary are linked by the .h header files.

if you run without preventing the multiple inclusion you get this error:
``` \$ make g++ -c -o main.o main.cpp In file included from Rectangle.h:13, from main.cpp:9: Point.h:13: error: redefinition of ‘class Point’ Point.h:14: error: previous definition of ‘class Point’ make: *** [main.o] Error 1 ```

After correction you get this:
``` \$ make g++ -c -o main.o main.cpp g++ -c -o Point.o Point.cpp g++ -c -o Rectangle.o Rectangle.cpp g++ -o main main.o Point.o Rectangle.o ```

Edit Rectangle.cpp and run again; (e.g. open and save to update time, or just type “`touch Rectangle.cpp`“.

``` e\$ make g++ -c -o Rectangle.o Rectangle.cpp g++ -o main main.o Point.o Rectangle.o ```

## My first g++/cpp program

test.cpp is a text file containing:
``` #include ```

``` ```

```using namespace std; int main() { cout<<"test test"<<endl; return 0; } ```

This is compiled using the command:
`g++ -o test test.cpp`

## ftnchek

One tool I picked up from Clive Page’s Page on Fortran was ftnchek. This program is a static analyser. It enables checking or Fortran77 for semantic errors (rather than syntax errors), which usually aren’t reported by compilers. Once a Program compiles you can check for syntax errors by running `ftnchek program.f`

I found most of my errors are of this type.

```    189             XTO400=XTO400+0.0001
^
Warning near line 189 col 26 file mucg83.f: promotion may not give desired
precision: dble XTO400 + real const 0.0001
```

What I should have written is

```            XTO400=XTO400+1D-04
```

Which means the fortran compiler knows the number involved is meant to be used in double precision. Since there is really no cost penalty to using ‘double’ precision rather than ‘single’ precision used with ‘Real’ numbers – and this might change depending on compiler.

I found the static analyser to be very useful for finding unused parts of a program, this might be useful to find errors, if you think those parts of the code are meant to do something! Or in cleaning up the code after making changes.

Installation
ftnchek can be downloaded from the ftnchek developers website, or installed in debian from the program repositories using apt-get, dselect or aptitude, etc.

```ftnchek --version
FTNCHEK Version 3.3 November 2004 Patch Level 1
```

## Magellan launch

The EPSRC National Service for Computational Chemistry Software (NSCCS) is pleased to announce the launch of its new machine, Magellan.

Magellan is a 224-core SGI Altix 4700, with 896GB of memory and 1TB of storage. You may not be aware that the service is also available for materials chemistry applications and supports the following codes;

CASTEP 4.0
CRYSTAL06
DL_POLY 2.17 and 3.07
SIESTA 2.0.1
GULP 3.1
CPMD 3.11.1
Quantum-ESPRESSO 3.1.1
NWChem 4.7

The NSCCS is particularly keen to attract experimental groups in the solid state area who might be interested in running simulations to help them analyse their results. These groups will be involved in a three-way collaboration with software support and hardware provided by the NSCCS, and additional scientific support provided by the Computational Materials Science group at the Daresbury and Rutherford Laboratories.

Any interested parties should contact the Service Manager, Dr Sarah Wilsey, for more information.

Further information about the NSCCS can be found on the Service website at http://www.nsccs.ac.uk.

Link to national computer centre: NSCCS.ac.uk

According to the statistics above the machine is having almost as much storage space in RAM as it is in the disk storage.