Adjusting all depth data in a file by some elevation
Minor issues

You have some minor funny business going on:


Repurposing f in writing_TS() makes the code harder to follow:


with open(f, 'r') as f:


In writing_TS(), you do


TS.append(x)



… where you are modifying TS, which is a global variable.  But then you return TS as well, which makes it pointless to communicate via a global variable.
On the other hand, you also have a global variable ND, which is initially an empty list, but becomes a float, but you actually want it to be an int.  But why bother initializing n = 0 at all?


Performance

Your ELEVATION.dat is a small file, and your DEPTH.dat is a huge file.  So don't process DEPTH.dat twice!  You want to run through DEPTH.dat linearly, in a single pass.

When performance is a problem, just keep it as simple as possible.  The core of the solution should "ideally" resemble this:

with open('DEPTH.dat') as depth, open('OUTPUT.dat', 'w') as out:
    for line in depth:
        out.write(line)


Of course, that doesn't do anything useful — it just copies the file line by line.  But it gives you the outline of the code to strive for, and it also establishes a lower bound on the running time.  (Try it.  If you aren't satisfied with the performance, then you know that your task cannot be accomplished satisfactorily using Python.)

With that in mind, how can we modify the skeleton to actually do the work?  I would make two assumptions:


DEPTH.dat consists of repeated blocks resembling the structure of ELEVATION.dat.
The lines of DEPTH.dat should be copied verbatim, except the numeric lines, which should be summed with their counterpart in ELEVATION.dat.


Here is how I would express those two ideas in code:

import itertools

def read_elevation(filename):
    """
    Read elevation data.  Lines in the file that consist only of a float are
    converted to a float; all other lines are preserved.
    """
    def try_parse_float(line):
        try:
            return float(line)
        except ValueError:
            return line

    with open(filename) as f:
        return [try_parse_float(line) for line in f]


elevation_cycle = itertools.cycle(read_elevation('ELEVATION_LHP.dat'))
with open('DEPTH.dat') as depth, \
     open('OUTPUT.dat', 'w') as out:
    for depth_line, elev in zip(depth, elevation_cycle):
        if isinstance(elev, float):
            print(elev + float(depth_line), file=out)
        else:
            out.write(depth_line)


This is simpler than your original code, in that I'm not trying as hard to "make sense" of the data by parsing ND.  It's not assuming that there are four header lines per group, namely SCALAR, ND, ST, and TS.  There isn't even any grouping involved: it just blindly assumes that DEPTH.dat contains many repetitions of blocks resembling ELEVATION.dat.