def write_sms_bathy(triangles, nodes, z, filename):
    """
    Writes out the additional bathymetry file sometimes output by SMS. Not sure
    why this is necessary as it's possible to put the depths in the other file,
    but hey ho, it is obviously sometimes necessary.

    Parameters
    ----------
    triangles : np.ndarray
        Integer array of shape (ntri, 3). Each triangle is composed of
        three points and this contains the three node numbers (stored in
    nodes) which refer to the coordinates in `x' and `y' (see below). Give as
        a zero-indexed array.
    nodes : np.ndarray
        Integer number assigned to each node.
    z : np.ndarray
        Depth values at each node location.
    filename : str
        Full path of the output file name.

    """
    fname = open(filename, 'w')
    node_number = len(nodes)
    element_number = len(triangles[:, (0)])
    header = (
        """DATASET
OBJTYEP = "mesh2d"
BEGSCL
ND  {:<6d}
NC  {:<6d}
NAME "Z_interp"
TS 0 0
"""
        .format(int(node_number), int(element_number)))
    fname.write(header)
    for depth in z:
        fname.write('{:.5f}\n'.format(float(depth)))
    fname.write('ENDDS\n')
    fname.close()
