When the four young black athletes arrived for practice at the chic Tiete Regatta Club here a few months ago, they were barred at the door. To the shock and anger of the black players, though, their white teammates were promptly admitted to the club's gymnasium, pool and locker rooms.

The result was a routine police investigation - and the first racial protest demonstration in memory in Brazil, which has the largest black population of any country outside Africa. On July 7, an estimated 5,000 persons met under the banner of the newly formed Unified Black Movement Against Racial Discrimination at the main square here and charged that the Tiete incident was part of a systematic pattern of racism.

To those Brazilians who stumbled across tiny stories on the demonstration in a few newspapers the next day, such allegations undoubtedly came as a surprise. Black and white Brazilians are taught from birth that their country is a "racial democracy." To outward appearances, at least, relations between the races here are as friendly and open as anywhere in the world.

Officially, Brazil is proclaimed a mixed society in which prejudice and race problems are absent, where the peoples and cultures of Europe and Africa have blended freely and harmoniously. In the words of President Ernesto Geisel, Brazilian society is "the widest experiment in racial integration that the world has ever known."

Yet the realities, as indicated by the Tiete incident and others like it, are far more complicated than the official ideology is willing to admit. Relations between the races in Brazil - where slavery began a century earlier and lasted 25 years longer than in the United States - are based on a welter of beliefs and attitudes, in which theory is often contradicted by practice.

On the one hand, African culture has survived on a wide scale here and has been accepted as part of the daily routine. Brazilian cuisine, music, religion and folk practices all are predominantly African-derived, and the national ideal of beauty and sex appeal is the mulata , a woman born of white and black parents.

On the other hand, sociological studies have revealed that Brazil's black population, twice the size of its American counterpart, is often excluded from political office, the military officer corps, business and other key decision-making positions. On an individual level, many black Brazilians tells tales of discrimination that is sometimes subtle, sometimes blatant.

Brazilians acquiring a subconscious awareness of racial gradations and classifications. The Portuguese spoken here contains dozens of terms to describe different shades of black skin - ranging from crioulo for an extremely dark person to brancarao for a mixed race individual who appears to be white.

Publicly, however, discussion of any Brazilian racial "problem" is nearly nonexistent. All but a handful of the population - black as well as white - appears to accept the traditional rationale that black poverty and backwardness are due to class rather than racial factors.

"Black Brazilians have always felt that they have no racial problem," said John Henrik Clarke, professor of African world history at Hunter college in New York and a recent visitor here. "And that in itself is the problem."

Any attempt to analyze the role of blacks here is hindered by the fact that no one knows just how many there really are. Race has not been included as a question on census forms since 1950, when statistics disclosed that three of every eight Brazilians were blacks or mulattos.

Black activists such Abdias do Nascimento, author of "Racial Democracy in Brazil: Myth or Reality?" charge that race has been left off subsequent census surveys because the government fears that blacks are now a majority. The 1950 figures showed black majorities of up to two-thirds in three states and near majorities in several others.

Discussion of the racial situation here has also been discouraged by the official policies of the right-wing military government, which has said it considers black-activist efforts to be "subversion of the established order." All but the briefest and most innocuous references to race are censored from the news media.

"We has a stroy planned not too long ago on the situation of the black in Brazil," said a reporter at the nation's leading newsmagazine. "In fact, we got as far as researching the story, taking the photos and writing the text.

"But then the word came down from on high in Brasilia that it would be 'inopportune' to publish the story. So of course that meant we either had to back off or suffer the consequences. You know what the decision was."

In recent months, the government has attempted to publicize examples of black achievement. When the Foreign Ministry, traditionally the "whitest" of all government agencies, accepted its first black woman diplomat in August, the appointment was accompanied by a well-orchestrated blitz of publicity - aimed, critics said, at soothing African nations whose trade and friendship Brazil seeks but which have been concerned about Brazilian racial attitudes.

The reaction of the young woman diplomat itself provided an interesting index of the racial attitudes. "I've been turned into a black overnight," she complained to a reporter. "Before, I used to ba mulata."

In other efforts to argue that racial discrimination does not exist in Brazil, whites frequently cite black athletes and entertainment figures, such Pele. But to some young activists, who argue that blacks are allowed to succeed only in these two fields, Pele is sarcastically dismissed as um or ioulo bomzinho - the Brazilian equivalent of an Uncle Tom.

Even Pele, the most popular sports idol, and other black celebrities have their tales of racial discrimination. In a famous incident in 1974, when the soccer star was invited to participate in a civic ceremony in a small town in the interior, he was called "a dirty black bum" by a city official after declining an offer to ride in a car with local politicians.

Other top black soccer stars playing for leading teams in Rio, all of which are owned by elegant social clubs, say that though they are more than welcome on the playing fields, they are prohibited from using the club's social facilities or pursuing contacts with white club members or guests.

Pop star Milton Nascimento, a black who was adopted at an early age by a white family, a common pratice here, has similar recollections. "We'd all go somewhere together, my sisters and I," he said, "and when we'd get there, they'd be allowed in while I would be kept out. It happened a lot."

Recently Nascimento, perhaps Brazil's most prominent black singer and composer, returned his home town for a "day" in his honor and had another brush with racial insentivity. In a ceremony televised all over Brazil, a city official, in an attempt to praise Nascimento, described the singer as being "a black man with a white soul."

Nascimento shrugs off such episodes as "isolated instances of individual stupidity." A small, but vocal group of young black here and in Rio think otherwise, though, and have begun exploring their own history and origins in black study groups or adopting the pan-African rhetoric and lifestyle of foreign black activists such as Jamaica's Rastafarians.

Other young blacks who have turned to the United States are attempting to adapt the "black power" movement of the 1960s and are talking about improving the position of Brazilian blacks through collective action.

Although "Roots" has not yet been shown here, a recent exhibition from the series at U.S. consulates attracted large numbers of young Brazilian blacks eager to learn about a topic that is ignored here.

But a full-scale "Roots"-like search through family genealogies is unlikely for Brazilian blacks. Soon after slavery was outlawed here in 1888, a government official ordered that millions of pages of slavery records be burned - an action that was taken, according to the government proclamation issued at the time, to erase "this black stain" on Brazilian history.