def read_arc_MIKE(file, fileOut):
    """
    Read in a set of MIKE arc files and export to CST format compatible with
    FVCOM.

    MIKE format is:

        x, y, position, z(?), ID

    where position is 1 = along arc and 0 = end of arc.

    In the CST format, the depth is typically zero, but we'll read it from the
    MIKE z value and add it to the output file nevertheless. For the
    conversion, we don't need the ID, so we can ignore that.

    Parameters
    ----------
    file : str
        Full path to the DHI MIKE21 arc files.
    fileOut : str
        Full path to the output file.

    """
    fileRead = open(file, 'r')
    lines = fileRead.readlines()
    fileRead.close()
    fileWrite = open(fileOut, 'w')
    fileWrite.write('COAST\n')
    nArcs = 0
    for line in lines:
        x, y, pos, z, ID = line.strip().split(' ')
        if int(pos) == 0:
            nArcs += 1
    fileWrite.write('{}\n'.format(int(nArcs)))
    arc = []
    n = 1
    for line in lines:
        x, y, pos, z, ID = line.strip().split(' ')
        if int(pos) == 1:
            arc.append([x, y])
            n += 1
        elif int(pos) == 0:
            arc.append([x, y])
            fileWrite.write('{}\t{}\n'.format(int(n), float(z)))
            for arcPos in arc:
                fileWrite.write('\t{}\t{}\t{}\n'.format(float(arcPos[0]),
                    float(arcPos[1]), float(z)))
            n = 1
            arc = []
    fileWrite.close()
