The celebrated marriage of Carl Bernstein and Nora Ephron ended in divorce last Thursday in D.C. Superior Court, but the drama continues. At the heart of the separation agreement between former Washington Post investigative reporter Bernstein and author Ephron is how Bernstein and the couple's children will be presented in the Mike Nichols movie based on Ephron's best-selling novel "Heartburn." Meryl Streep and Mandy Patinkin have been cast in the leading roles.

The book is generally viewed as a thinly disguised account of the breakup of their 1976 marriage.

In an unusual agreement, Nichols, Ephron and Paramount Pictures Corp. state that Bernstein may read the screenplay and any subsequent drafts written for the movie, view one of the first cuts of the film and submit any concerns. He also will meet with Nichols. The agreement stipulates that Ephron will not write about Bernstein or the family and says that her name will not appear on any future production of "Heartburn," such as a TV series. It also sets aside a percentage of profits from the film in trust for their children.

The question of fact and fiction has been pivotal during the legal maneuvering. The book includes a number of acerbic Ephron portrayals, such as the Bernstein character (newspaper columnist Mark Feldman), described as "a piece of work in the sack" who is nevertheless "capable of having sex with a Venetian blind." Her description of the other woman (Thelma Rice) is believed patterned after Margaret Jay, the wife of Peter Jay, former British ambassador to the United States. Rice (Washingtonian Karen Akers has been cast for the movie) is portrayed as a woman with "a neck as long as an arm and a nose as long as a thumb and you should see her legs, never mind her feet, which are sort of splayed."

Nichols and Paramount Senior Vice President Ralph Kamon say in a letter that Bernstein should not infer any right to control the film's "content, script, characterizations, final cut, release or distribution." But Nichols and Paramount agree that they will be "sensitive" to objections raised by Bernstein.

According to a Hollywood source close to the agreement, permitting the review of a film script is not an unusual courtesy. "What is unusual," the source adds, "is that it comes up in the context of a domestic situation in a film property Paramount views as total fiction."

Ephron states in an attachment to the couple's separation agreement that "the father in the movie 'Heartburn' will be portrayed at all times as a caring, loving and conscientious father in any screenplay prepared or executed with my name attached to it." In a direct reference to Bernstein, she also says that "from the birth of our first son, through the birth of our second and to this day, my husband has consistently been a loving and devoted father to our children . . ."

Ephron said she was aware a movie based upon the book "raises the possibility of causing our children harm, however slight." Ephron and Bernstein have joint custody of their sons.

Ephron's lawyer, Judith Richards Hope, described the divorce settlement as "a complete victory . . . She is totally vindicated on all counts. She is delighted that after 5 1/2 years she was finally able to get a divorce from Carl without a contested trial. Nora's paramount interest is the children and she is thrilled she could get divorced and spare them a messy trial and that the filming of 'Heartburn' can go on without any further interference."

Ephron considers it a victory that Bernstein has given up his threats to stop the filming of "Heartburn" and has signed away all rights to the film.

While pleased with the terms of the agreement, Bernstein indicated yesterday that he is still not satisfied with the present "Heartburn" script. His lawyer, Robert Liotta, said yesterday that Bernstein could still take legal action to block the film.

In issuing a response, Bernstein said yesterday that the screenplay "continues the tasteless exploitation and public circus Nora has made out of our lives and what should have been our family's private sadness. Nonetheless, I hope we can resolve this situation quietly and without further court actions."

When the book was published, Bernstein said only, "Obviously I wish Nora hadn't written the book. But I've always known she writes about her life. Nora goes to the supermarket and she uses it for material."

Bernstein had a different attitude after the dramatically successful book was sold to the movies. The difference, he said during his heated attempts to block the movie, is how a potentially vast movie audience might affect the couple's sons, Jacob, 6, and Max, 5. "That's the reason," he said then, "I made demands about how my role as a father be portrayed accurately in the film."

Ephron, who was not available for comment, maintains that the book is fiction, though she adds in the settlement agreement dated May 2 that "some of the events described in the book are based loosely upon certain events that occurred in the lives of my husband, myself and our children."

Bernstein doubts that the movie will be seen as fiction and has told friends that actor Patinkin has called him for help in researching the Feldman role and has talked to friends and newspaper colleagues.