The Soviet Union published what amounted to a balance sheet on its relations with Iran's Islamic government today, showing gains in the economic field but blaming political losses on "right-wing groups around" Iranian revolutionary leader Ayatollah Ruhollah Khomeini who are trying to block improved relations.

The commentary in Pravda, the official Communist Party newspaper, warned these elements in the Iranian leadership that they "want to stop the development of Iranian-Soviet relations even if this damages the economy of their country and Iran's ability to withstand imperialist pressure."

The two-column commentary was the first substantive discussion of Soviet-Iranian relations in nearly two years, according to diplomats. Its publication at this time was linked to leadership problems in Tehran and possibly also in anticipation of changes expected after Khomeini's departure from the scene.

Criticism of the Iranian leadership has been very rare in the Soviet media. The Soviets during the past three years have sought to cultivate economic ties while skirting around political and ideological differences. Bilateral trade last year reached a record $1.2 billion, or about 30 percent higher than in 1978, the last year of the shah's government.

The two countries recently signed a protocol to accelerate technical and economic cooperation.

On the credit side, Pravda noted today that bilateral economic relations had improved and that Soviet firms were engaged in the construction of a number of projects in Iran. It also reminded Tehran that Iran had been able to circumvent the American blockade of its Persian Gulf ports by using Soviet land and water routes.

The commentary suggested that there were tangible aspects of Soviet support for the Iranian revolution and that they have to be taken into consideration in evaluating the bilateral relationship.

A catalogue of Soviet grievances on the debit side, however, suggested unhappiness here with the political relationship. The grievances ranged from the closure of a Soviet consulate and the Soviet cultural center to the denial of visas to Soviet journalists. They also included "the termination of activities" of the Soviet-Iranian bank and anti-Soviet propaganda in the Iranian media.

Pravda also complained about anti-Soviet demonstrations in Iran and said a group of visiting Soviet Moslem leaders had to listen to people chanting hostile slogans. All of this, it said, was taking place in an atmosphere of "intense anti-Soviet propaganda" by the Iranian authorities.

The paper noted that the first Soviet government had annulled a treaty about a division of Persia in 1917 and that Soviet President Leonid Brezhnev's warning to the West in the fall of 1978 had dissuaded "hotheads" in Washington from an American military intervention to save the shah.

Although Pravda's commentary was moderate in tone and avoided vitriolic attacks, the message to the Iranian leadership appeared to be that there are political boundaries beyond which they cannot go without jeopardizing the relationship that has benefited the revolution.

Today's commentary had an injured tone and specifically complained that despite all Soviet measures, Tehran has made no attempt to improve political ties.

Diplomats, nevertheless, interpreted the article as an attempt to pressure the Iranian authorities to assume a more conciliatory stance toward Moscow and presumably to encourage elements in Iran favoring greater cooperation with the Soviet Union.

Pravda also made references to the continued presence of U.S. forces in the Persian Gulf and said that "another attempt" to use this force against Iran cannot be excluded.

The commentary said the Soviets wanted to improve relations with Iran. "Objective conditions" for such development already exist with the two countries' economies "complementing" each other, the article explained.

The paper attacked unnamed right-wing forces in Iran asserting that communism and Islam are incompatible, saying this view is "totally unacceptable."