The union representing 35,000 locomotive engineers and firemen ordered a nationwide railroad strike beginning Sunday night unless President Reagan intervenes by calling a cooling-off period permitted under federal labor law.

The strike would halt virtually all U.S. rail traffic, except for Conrail and parts of Amtrak in the Northeast.

But the administration has been reluctant in the past to intervene directly in labor disputes.

Labor Secretary Raymond J. Donovan said earlier, as the strike threat loomed, "We have been consistent in our policy, and to date they strike situations during Reagan's term have all worked out using what I like to call the miracle of collective bargaining."

But at the Cleveland headquarters of the Brotherhood of Locomotive Engineers yesterday, official Bill Wanke spoke of impasse.

"We regret this action," he said. "We understand the state of the economy. But we've exhausted all other means of settlement . . . . The last time we went out on strike was in 1946, so you can tell we're not radicals."

The dispute is over a longstanding work rule that affects daily pay.

The president could name an emergency board that would prohibit any strike action for 60 days while it studies the dispute and recommends settlement terms.

First, however, the National Mediation Board must determine that a strike would deprive any section of the country of "essential transportation."

"No decisions have been made," one White House source said. But he added that the board is expected to recommend Reagan's intervention, and that "we're getting prepared for that eventuality."

"We're studying the situation and expect to report to the president in the next day or so," said Robert Harris, chairman of the mediation board, who has been involved in the rail negotiations.

In normal times, a railway stoppage can cost the economy as much as $100 million the first day, according to one labor specialist. The mediators are currently gathering information on the strike's likely effects on everything from California fruit to midwestern grain harvests to Kentucky coal.

The negotiations between the union and the National Railway Labor Conference, which bargains on the management side for 117 rail lines, broke down May 26.

Charles Hopkins, chairman of the conference, said recently that the strike "would be terribly disruptive in view of the other economic circumstances of the present time." He said he thought Reagan would intervene if necessary.

At stake in the dispute, he said, are work rules that "we can no longer live with . . . and remain competitive."

Those work rules involve the engineers' time-honored dual pay system based on the trains of a century ago, according to one official. This system pays the engineer based on either time or mileage: eight hours or 100 miles.

The speed of modern trains, however, skews the old system, and the railroad managers want to change it, the official said.

The argument is about whether the cost-of-living and other increases offered by management should apply not only to basic wages but also to the special payments for over 100 miles and to other special payments.

The union's Wanke said those extra payments "are an incentive to our people" to drive their trains farther, faster. "In the past, our increases have always been applied to all those. They account for 15 to 25 percent of our overall pay receipts."

Engineers doing rail yard service--nearly half the members--get $11.41 per hour for an eight-hour day. Through-freight engineers doing over-the-road work on four-unit diesels receive $10.86 an hour, switching to 79 cents a mile after they hit the first 100-mile mark.

The big United Transportation Union is the only other labor organization that has failed to reach agreement with the railroad managers. The UTU will be free under the labor law to strike after July 30.

In Santa Barbara, White House spokesman Larry Speakes said Reagan "was briefed on some of the issues . . . and some of the ramifications of the rail strike."