The Costa Rican government announced today that it has informed President Fidel Castro of its willingness to receive all of the 10,000 Cubans waiting to leave this country.

In one of several diplomatic efforts to revive the flow of refugees, virtually closed off Friday by Castro, the Foreign Ministry of the small Central American nation said it "had decided beginning today to authorize the entry of all these persons" and would take them permanently if necessary.

While this offer appeared to meet Castro's initial requirement for permission to leave -- that the persons who claimed asylum in the Peruvian Embassy two weeks ago have an assured destination -- the unofficial Cuban reaction reportedly was to call the offer a maneuver.

On Friday, Cuba stopped the flights that had carried about 700 refugees to Costa Rica, saying the flights could not go to the staging base there but should be arranged directly with the countries giving a permanent home to the Cubans.

Castro reportedly was angered by anti-Cuban propaganda generated by the arrival of the first flight in San Jose on Wednesday.

Costa Rican President Rodrigo Carazo, a Christian Democrat, embraced the Cubans at the airport and described the flights as a "bridge to freedom." At that time, Costa Rica was committed to receiving only 300 Cubans permanently. Many of the initial arrivals have since moved on to Peru.

Among the countries asking Castro to clarify his changing position is the United States, which has promised to take 3,500 of the refugees.

For the United States, the new Cuban rules may mean moving the team of immigration officials to Havana from Costa Rica, where they are already in operation.

"Processing can be done here if we get help," said a diplomat in the U.S. Interests Section here, "but people have to be cleared. This is not a Dunkirk operation where you simply put people on the beach."

While U.S. relations here fall short of formal diplomatic ties, many of the countries that have agreed to take refugees have very small legations or none at all. Their ability to arrange the flights asked by Castro is severely limited.

Spain, however, with an active embassy, has already made arrangements for the 500 refugees it has promised to take. This evening, 32 Cubans choosing exile in Spain went to the airport to board an Iberia flight. The Spanish airline is expected to land a jumbo jet Monday to take another 380 persons.

Cubans relations with Peru and Venezuela have been severely strained by the role of those South American nations' embassies in receiving discontented Cubans. Now Costa Rica has fallen into the same category.

Many Latin American countries resumed ties with Cuba three years ago after the Organization of American States voted to lift a boycott of the communist country initiated by the United States in 1964. Costa Rica is represented in Havana by a consul general, who was recalled today as a consequence of Castro's cutoff of the refugee flights.

So far, Cuba has provided 8,400 safe-conduct passes and passports for the 10,000 people who originally jammed into the Peruvian Embassy. Holders of these papers may not return to the embassy but have been assured that they will be allowed to leave when their turn comes.

About 700 have changed their mind about emigrating and now want to stay here, officials say. According to Peru's charge d'affaries, about 1,500 people are still within the embassy compound, where conditions remain very difficult. He said the Cuban government continued to supply water and food. A number of people were "sick, but not serious, because of the unhygenic conditions," he said, adding that about 40 people wounded by trampling and fights among themseleves last week had been taken to a hospital.

Today, most of the refugees were in the compound garden. For security reasons, they were moved indoors yesterday during a massive pro-Castro demonstration. Almost a million people attended, the government said.

The foreign press, given entry visas to report on the demonstration, still is refused access to the embassy area.

A local journalist who was allowed inside on Friday said the the "place is in ruins. People have ripped wood from the building to make fires for making coffee and tea. They pulled out whole doors to sleep on to avoid lying down on the filthy ground."

Other embassies, particularly those that have asylum agreements with Cuba, continue to be well guarded. The embassy of Mexico, a country that is famous for receiving political exiles, has four guards with heavy arms and telephones on each corner of its compound. But Mexico has let it be known that it will refuse anti-Castro refugees.

A week ago, as Castro was under heavy political attack throughout Latin America, Mexican President Jose Lopez Portillo announced that he will come here on a three-day state visit on July 31.

The Mexican decision had been made before , but Mexico carefully timed its announcemet, a well-informed diplomat said.

"Cuba did not press Mexico into this kind of support, but needless to say it is very grateful," the diplomat said.

Castro was seen driving past the Peruvian embassy before the demonstration yesterday. So far, he has declined the numerous requests for interviews by the foreign press.