The National Maritime Union of America's surprise endorsement of Ronald Reagan Thursday in St. Louis came less than a month after the union's president condemed Reagan as "vindictive" and "frightening," writing off his chance of reaching the White House as "a prospect that is grim to contemplate."

The strong anti-Reagan statements came in a lead editorial in September issue of the union newspaper. The NMU Pilot, under a headline, "NMU endorses President Carter for reelection to second term."

The editorial's author was NMU President Shannon J. Wall. On Thursday he stood on stage with Reagan as the union's membership voted, nearly unanimously, to ignore the editorial endorsement of Carter and stand behind Reagan. The NMU was the first major maritime union (50,000 members) to endorse Carter's candidacy four years ago.

In his editorial, Wall attacked Reagan for a "penchant for putting his foot in his mouth almost every time he opens it," and stressed that the Republican had "an antilabor record" that included support for state right-to-work laws, which are anathema to organized labor.

In the same editorial, Wall wrote that "the NMU national office, on behalf of the entire NMU membership, warmly endorses Mr. Carter's campaign for reelection and calls upon the National Maritime Union membership to support him at every level with all the resources at their command."

Wall, flying back from the St. Louis convention yesterday, was not available for comment on just what happened to his ringing endorsement of Carter between publication of the Pilot last month and the national meeting of his membership Thursday.

Sources, however, indicated that the NMU Executive Board decided Wednesday in St. Louis to adopt a position of neutrality in the presidential election.That and Wall's editorial stance were upset the next day, when a New York delegate, Andy Rich, listened to Reagan's speech to the convention and then moved from the floor to endorse him.

By a voice vote, the union members overwhelmingly thundered their support of Reagan, with only a few isolated "nos" echoing in the hall. Wall, listening to the chorus, declared the vote unanimous.

Even Reagan, who was sitting on stage while the vote was taken, seemed surprised by the action. And Tom Schaaf, a Reagan maritime adviser in Washington who had helped set up a private meeting between the candidate and union leaders last month, said yesterday that the endorsement was "one of those nice little things that happen in a campaign that you don't really expect."

Union officials were not available, and Reagan staffers weren't saying just how "spontaneous" the reversal of the NMU presidential endorsement really was.

But in his editorial, Wall listed a long string of "antilabor" grievances he had with Reagan. One of them: "He is reported as saying that the leadership of organized labor is out of step with its membership."