President Reagan yesterday signed an order blocking a nationwide rail strike that had been planned for Sunday night by the union representing 35,000 locomotive engineers and firemen.

The executive order forestalls a strike for a 60-day "cooling-off period" and establishes an emergency board to investigate the dispute between the Brotherhood of Locomotive Engineers and most of the nation's major rail lines.

Influenced by the potential impact on shipment of winter wheat, national defense materiel and coal as well as unemployment and intercity passenger travel, Reagan acted within hours of receiving word from a labor mediation board that the situation was "extremely critical," deputy White House press secretary Larry Speakes said in Santa Barbara, Calif.

The president "considers the railroad industry crucial to the U.S. economy," Speakes said, adding that the strike would have involved 90 percent of rail track mileage in the United States.

About 25 percent of Defense Department materials traveled by rail in the first six months of this year, Speakes said.

A strike "would have a significant impact on unemployment," adding an additional 620,000 people to already swollen rolls by the end of the second week of such a strike, he said. Of these, 300,000 would come from the railroad industry and the remainder in related industries, he said.

Because export sales of winter wheat amount to $5.5 billion, he said, a strike could be expected to have an adverse impact on the nation's balance of payments.

Robert Harris, chairman of the National Mediation Board, told the president "the overall effect of a strike would be the virtual shutdown of rail freight in the United States," Speakes said.

Earlier in the day, the board had triggered the president's emergency powers under labor law by concluding that a nationwide rail strike would have a dire effect on the U.S. economy.

The strike threat crystallized Wednesday after the engineers union, representing about 35,000 engineers and firemen, declared it had exhausted all other avenues in its contract dispute with 117 rail lines. Formal negotiations had broken off May 26.

Reagan's newly created three-person emergency board can recommend terms for settling the dispute.

The administration has expressed reluctance to interfere in private-sector collective bargaining situations. But White House officials indicated that establishing an emergency board would not go against the president's political bent, since it is viewed more as the last step in the bargaining process, rather than as interference.

Before Reagan acted yesterday, John Sytsma, president of the Brotherhood of Locomotive Engineers, said from union headquarters in Cleveland that he would welcome a presidentially-imposed cooling-off period and investigation by the emergency board.

"I think we have a good case and an impartial board would recommend the merits of our case," he said.

According to both sides, the dispute focuses on special allowances above basic pay, particularly extra pay for trips of more than 100 miles, for delays at stations and for changing locomotives.

The union wants any increases in basic pay applied to the special allowances as well, as in the past. But rail line managers insist that they cannot afford to keep paying on that basis and remain competitive in the business.

Industry analysts had estimated that a nationwide rail strike would have cost the economy more than $50 million a day.

The engineers' strike would stop virtually all of the nation's freight trains with the exception of Conrail, the subsidized freight carrier in the Northeast, which would not be affected.

About 50 percent of Amtrak's passenger trains would be affected, including most of its long distance trains, primarily in the Southeast and West, a spokesman said. Rail traffic in the Northeast corridor between Washington and Boston would remain largely unaffected.

The emergency provisions of the Railway Labor Act were last invoked by President Carter in 1978 during a strike by the Brotherhood of Railway and Airline Clerks. They were invoked by President Ford in 1975, also against the clerks' union, and by President Nixon in 1972 to stop a nationwide walkout by the Sheet Metal Workers union against all rail carriers.

Reagan may be called on to use his authority again later this month. The United Transportation Union, which represents about 80,000 rail workers, has also reached a negotiating stalemate with the rail lines but cannot strike until at least July 30.