India and Iran reached a broad understanding on trade today that will go far to allow Tehran's Islamic rulers to circumvent the effects of Western trade sanctions.

After five days of talks, the 17-man Iranian delegation left here today with an understanding that India would increase its trade in engineering goods, food, agricultural machinery and know-how, drugs and pharmaceuticals as well as consulting and management training services.

Iranian Commerce Minister Reza Sadr, who headed the trade mission, said that India had been chosen for the talks on increased trade and economic cooperation "not by accident but by design."

India manufactures a wide range of sophisticated consumer, machine tool and electrical products and also possesses a large reservoir of manpower in such fields as engineering and computers. With these resources and its close geographical proximity, it is well suited to step in and fill Iran's needs resulting from the Western embarge. India, in turn, needs oil which Iran can supply.

The Indians, who had to scramble for petroleum products following the Iranian revolution last year, offered a warm and highly visible welcome to the 17-member delegation. Indian Commerce Minister Pranab Mukherjee promised all possible cooperation since India is not taking part in the sanctions against Iran.

The economic boycott of all trade to Iran except food and medicine was organized by the United States in an effort to force Iran to release the 53 Americans held hostage since November.

Although no specific agreements were signed following the talks, India won an assurance from Sadr that Iran would try to provide long-term oil supplies instead of negotiating oil sales year by year.

India also clearly expects to get more oil from Iran, which was once its largest supplier. This year, Iran has provided 30 million barrels, but Iraq has replaced it as India's largest oil supplier with 42 million barrels. i

Indian and Western analysts noted that some of the items on Iran's lengthy shopping list are in extremely short supply here or are already imported to meet shortfalls, such as sugar, vegetable oils, cement, fertilizers, drugs and explosives.

India is anxious to correct its unfavorable, oil-skewed trade balance with Iran, now running a deficit of $301 million a year.

Observers raised the possibility that India may act as Iran's middleman in importing goods withheld from Iran under the sanctions for export to that country. They speculated India may also take essentially political decisions to supply scarce goods, risking greater shortages and higher prices at home to help out Iran and ensure a reliable oil supply. An official release said India would make efforts to meet Iran's needs "subject to our own domestic requirements."

It said India had offered to supply a wide range of engineering equipment and machinery for small scale to heavy industries and said both sides hadd identified such areas of industrial cooperation as automotive and commercial vehicles and parts, tires and tubes, refrigeration systems in oil fineries, petrochemicals, machine tools electrical systems power plants, the construction industry and the development of industrial areas.

They also agreed to strengthen their joint venture shipping line, the Iran-O-Hind shipping company.

Last year India exported $109 million worth of tea and spices, engineering goods, minerals, chemicals, iron and steel, textiles and leather goods to Iran. It bought $410 million worth of Iranian goods, virtually all of it oil or petroleum products.

Concidentally, the Indian government today released its economic survey for the 1979-1980 fiscal year that ended March 31 showing that India's overall trade gap had doubled since last year. The report highlighted declining foreign exchange reserves, a drop in the gross national product, sharp price increases and a 10 percent decline in agricultural production caused by last year's drought.