"Berlin Tunnel 21," a three-hour-long TV movie airing tonight at 8 on Channel 9, is a moderately interesting and quasi-dramatic escape melodrama set in Cold War Germany. It will, however, be long remembered for its ending, surely the most unnecessarily disconsolate and downright annoying of recent television history.

Richard Thomas plays a former U.S. Army lieutenant in Berlin in 1961, who is separated from his girlfriend -- an East German national -- by the erection of the Berlin Wall, an event that occurred 20 years ago this Aug. 13.

He determines to free her by digging a tunnel more than 200 feet under the wall, but first he needs some expert advice, which he finds in the person of Horst Bucholz, as a hot-tempered structural engineer. Other persons are also enlisted in the effort, and the digging gets under way.

Soon, however, it appears that one of the team has been followed, so Thomas and Bucholz take the liberty of luring the tunnel-threatening inteloper into an abandoned building so Bucholz can put a bullet through his heart at close range without even blinking.

Meanwhile, Jose Ferrer, as a rich collector of paintings, turns up in the middle of things and hangs around long enough to state over brandy and cigars the general theme of the drama, to wit:

"It's the wall -- that damned arrogant monument that keeps the German people apart. One city, one culture divided by madmen. I say damn these communists -- damn them to hell." Ferrer, as usual, is marvelous, and it is a pity there wasn't time for him to do a bit or two from "Cyrano de Bergerac." Actually, there was time, because the hour-long middle of this story exists only to separate the beginning from the end.

The tunnel is finally completed, and as any student of the dramatic arts will quickly guess, it threatens to collapse, thus providing further tension as the actual escape looms and icy fingers of suspense run up and down your spine.

A word about Richard Thomas, still hamstrung by years of success as John Boy on "The Waltons." Thomas was quite good in the recent "All Quiet on the Western Front," and he is demonstrably talented. He is not very good at violent scenes, however, and when instructed by a director to, say, pound the wall in frustration, he resembles an adolescent who has discovered his pizza pie is cold.

Thomas' problem is merely that he looks young and inexperienced, and he needn't worry, for he is sure to get older with age. Horst Bucholz had something of the same trouble when he made his American screen debut as the Mexican gunfighter in "The Magnificent Seven." He looked bony and impetuous then, but in "Berlin Tunnel 21" he has some weather showing in his face and looks like a grown-up in whom you might possibly confide or believe.

The blond on the wrong side of the fence is Ute Christensen, altogether appealing. She is said to have in fact escaped from East Germany in the hollowed-out back seat of a car just five years ago. It falls to her, as to Ferrer, to boldly state her motivation. "When the Russians came to Berlin, they raped my mother right in front of me. Then they shot my father." All right. But even Clint Eastwood has learned that audiences do not have to be hit on the head with a frying pan just to believe they're in the kitchen.

As for the ending of this tale, which is, by the way, not advertised as a true story, or based on any factual incident, the ending is execrable. It is dramatically unfortuitous and unsatisfying and infuriatingly naturalistic, which is another term for stories that leave you feeling as if you need a shower and a day off.

A love story that kills its lovers had better be art; if it's only "Berlin Tunnel 21," it's got a lot of explaining to do.