To overcome increasingly bigger loan losses and a five-year string of declining earnings, the giant BankAmerica Corp. will be forced to take bold, drastic and painful action, according to several leading bank-industry analysts and consultants.

They say the 81-year-old San Francisco bank has several options: selling off major assets, selling a substantial stake in the company to an investor or agreeing to a merger. Any of these options would dramatically alter the bank's structure and management.

BankAmerica may consider, as another option, a public stock offering to raise badly needed capital. But many view that as a long shot, given the market environment that developed this month after BankAmerica announced an unexpected $640 million second-quarter loss, which immediately lead to lower credit ratings of the company's debt.

Above all, analysts say, BankAmerica would need to be restructured if it expects to rebuild its earning power and survive as a major financial-services company. And that, analysts add, may require a shakeup at the helm of the nation's second-largest bank company, after New York's Citicorp.

"This bank needs capital least of all; it needs management," said David Cates, president of Cates Consulting Analysts Inc. of New York.

Bank of America officials dismiss the criticism of management as unfounded. "When an earnings announcement like this comes out, analysts are obviously stung," said Arthur Miller, a BankAmerica vice president. "They don't like surprises, and we don't like surprises. Absent the last recession and the loan losses, we would have had a much different earnings picture."

Almost no one contemplates the imminent collapse of BankAmerica, a development that would have serious consequences for federal regulators and the deposit-insurance fund.

Federal regulators, following established policy, refuse to comment on BankAmerica's problems. But the consensus among analysts is that BankAmerica must act quickly.

"This is a critical period," one analyst said. "The next six months is critical whether they come out of this or lose."

Although analysts typically describe the situation at BankAmerica as "serious" and "critical," they aren't prepared yet to compare the parent company and its principal subsidiary, Bank of America, with Continental Illinois Bank, the big Chicago bank that had to be rescued by the federal government two years ago.

Like Continental Illinois, Bank of America is under severe pressure from problems in its loan portfolio. But unlike Continental Illinois, Bank of America has a huge domestic deposit base in one of the country's most lucrative markets, if not the richest. It also is much more diversified than was Continental, which heavily relied on huge foreign deposits. That strategy backfired and crippled Continental when foreign depositors, sensing trouble stemming from problem loans at the bank, panicked and withdrew millions of dollars in just a short period.

"My judgment is that foreign depositors won't get skittish about money in Bank of America," said Frederick Wightman, group vice president at Duff & Phelps. "They became alarmed when they saw no consumer-deposit cushion at Continental. Now they look at Bank of America's huge consumer-deposit base, and I think they feel more confident."

Wightman concurs with other analysts that Bank of America still has considerable strength that should enable it to pull out of its rapid slide toward disaster. "I'm sure that the economics that Bank of America has in terms of its big share of California markets will pay off if management gets its act in order," observed one analyst.

But, added another, "We're talking about turning an aircraft carrier, not a rowboat."

One measure of the size of the task ahead can be seen in an analogy drawn by a respected bank-industry consultant. Recalling that BankAmerica announced a loss of $640 million in the second quarter after increasing its reserve for losses by $600 million, he remarked, "In one quarter, they have written off the equivalent of a bank that's larger than 90 percent of all the banks in the United States." He estimated the cumulative after-tax writeoffs at approximately $1 billion. "Most banks in this country are under $1 billion in assets."

An immediate task, analysts say, is to stop the hemorrhaging at Bank of America, where loan losses have been piling up in the face of serious problems in several sectors of the economy; energy, where falling oil prices have had a devastating effect on banks, and commercial real estate and agriculture. Problem foreign loans also have taken a severe toll on Bank of America's loan portfolio.

The second-quarter loss was the second-largest ever reported by a U.S. bank company for a three-month period, exceeded only by the $1.16 billion loss reported by Continental Illinois Corp. in 1984, after its rescue by the government and other banks.

Although some analysts are optimistic about a turnaround in the second half, most believe the losses will continue unless quick and drastic measures are instituted. Indeed, Bank of America's management noted that it would have to raise its earlier estimate of a $1.2 billion loss for all of 1986 after realizing the extent of the second-quarter loss.

Bank of America's equity capital, or common stockholders' equity, is down to 2.79 percent of total assets, compared with an average 5 percent for most large banks. Its ratio of primary capital (basically equity capital, loan-loss allowances and preferred stock) to assets is less than the 6 percent level that it must have by yearend, based on a requirement from the Comptroller of the Currency. The minimum primary capital ratio is 5.5 percent, but the Comptroller may set a higher ratio depending on circumstances at individual banks.

"I think it's foolhardy to anticipate there will be any immediate bounceback" said James J. McDermott Jr., senior vice president at Keefe, Bruyette & Woods Inc.

Management began selling off assets at least a year ago in an effort to rebuild BankAmerica's capital base. It sold its World Headquarters property last year for $660 million and unloaded its FinanceAmerica subsidiary. Negotiations are continuing for the sale of its corporate office complex in Los Angeles, and several million dollars in loans have been packaged and sold in the past year. In recent weeks, Bank of America sold about $100 million in auto loans.

The critical issue in selling assets, however, is whether BankAmerica is willing to part with one or more of its more valuable holdings. It may become necessary, some analysts suggest, for BankAmerica to sell either Seafirst Corp. -- a major bank subsidiary that it acquired in Washington state three years ago -- or its discount-brokerage firm, Charles Schwab & Co.

"They've been selling a lot of things, so they don't have much more to sell," observed one analyst. "They would have to drop $20 billion in assets" to return to an acceptable equity capital level. But to suggest selling Seafirst and Schwab, he added, implies "gutting the company."

BankAmerica has said it would not sell either Seafirst or Schwab, and some analysts tend to agree that selling Seafirst might be counterproductive. Seafirst is BankAmerica's only entry into interstate banking and extends Bank of America's reach into another lucrative regional market.

"I believe Bank of America can be a very strong West Coast retail bank, and that's a place they can make a lot of money," said a bank-industry consultant who asked that his name be withheld. "They should say, 'We are going to be the dominant West Coast Bank,' and I think they will get back in line if they follow that strategy. That might even include selling Charles Schwab."

Although Schwab's results are not reported separately, its value to the parent company is apparent in management's disclosure that the discount-brokerage firm contributed record pre-tax earnings last year to BankAmerica.

A merger with another bank is considered a remote possibility by some analysts. In the past, BankAmerica's management rebuffed a merger offer from smaller but well-run First Interstate Bancorp of Los Angeles. First Interstate, the ninth-largest bank company and owner of banks in several western states, would be a natural fit for BankAmerica, according to some analysts.

Cates strongly disagrees. "I doubt the capacity of First Interstate or any other American bank to acquire BankAmerica because BankAmerica is too large and mismanaged."

Nonetheless, the probability of a renewed merger offer from First Interstate is very strong, according to some analysts. First Interstate officials declined to comment.

If Cates' theory about the inability of a U.S. bank company to acquire BankAmerica is correct, does that open the door for a bid by a foreign bank? Most analysts think not. Foreign banks, they point out, have not had much success operating U.S. banks.

Moreover, it is unlikely that U.S. banking powers and investors would stand aside and let BankAmerica be acquired by a foreign banking operation. "The value of its assets is just a gold mine," one analyst remarked.

Rather than considering a bailout, which would bear an enormous cost to the public, federal regulators probably would push for a private settlement of BankAmerica's problems if they were to get much worse, analysts believe. "That leaves a federal trusteeship in which the government would become a temporary owner, so that it's not a takeover or nationalization," Cates suggested. But, he added, the government may not want to put Bank of America in trusteeship. "It may want to subsidize a takeover."

Some analysts believe the time is ripe for Sanford Weill, the former head of American Express Corp. to renew his offer to inject an infusion of capital into BankAmerica in exchange for a sizable stake in the company. BankAmerica rebuffed an earlier offer of $1 billion from Weill, but circumstances have changed dramatically since then.

"There's still a lot of emotion attached to Bank of America," said a former bank-regulatory official and banking consultant. "It still has a lot of cache. It's more of an institution in its marketplace than most banks are. I'm sure they will spare nothing to save that bank."

A major question, raised repeatedly by analysts, however, is whether or not that can be achieved under current management.

BankAmerica's management is frequently described as an entrenched bureaucracy, operating without tight internal controls in place, and one that has failed to keep up with the competition by not streamlining itself. Bank of America is overstaffed and weakened by high overhead, said one analyst who compared it with Citicorp. Both companies employ around 80,000 worldwide, but Citicorp has assets of $180 billion, compared with $117 billion for BankAmerica.

"The Bank of America situation is an extraordinarily complex situation," one analyst said. "You can't put your finger on a single thing and say that this caused the problems, but the problems go way back to the days of A. W. Clausen," the predecessor of BankAmerica's president and chief executive, Samuel H. Armacost.

"Both Clausen and Armacost managerial camps share the responsibility for the travails of Bank of America, but Armacost's reign has been affected more by poor managerial decisions," McDermott added.

Analysts expressed dismay upon learning of BankAmerica's $640 million second-quarter loss. Several said they had been misled by management's assessment of operations and that they had anticipated BankAmerica would break even or report a slight increase in second-quarter earnings.

"Reliance on management guidance has been very disappointing," said McDermott. "Every time management expresses optimism, they, too, have been disappointed."

Although analysts expressed surprise about the extent of BankAmerica's recent losses, its performance in the past five years grew alarming enough to cause some to raise serious questions about its asset quality and its earning power.