Stopping at the edge of a vast field of barley on his farm in Prundu, 30 miles outside Romania’s capital city of Bucharest, Catalin Corbea pinched off a spiky flowered head from a stalk, rolled it between his hands, and then popped a seed in his mouth and bit down.“Another 10 days to two weeks,” he said, explaining how much time was needed before the crop was ready for harvest.Mr. Corbea, a farmer for nearly three decades, has rarely been through a season like this one. The Russians’ bloody creep into Ukraine, a breadbasket for the world, has caused an upheaval in global grain markets. Coastal blockades have trapped millions of tons of wheat and corn inside Ukraine. With famine stalking Africa, the Middle East and elsewhere in Asia, a frenetic scramble for new suppliers and alternate shipping routes is underway.“Because of the war, there are opportunities for Romanian farmers this year,” Mr. Corbea said through a translator.The question is whether Romania will be able to take advantage of them by expanding its own agricultural sector while helping fill the food gap left by landlocked Ukraine.Catalin Corbea, in his trophy room showing stuffed animals from hunting expeditions, said the war in Ukraine had presented opportunities to Romanian farmers.Cristian Movila for The New York TimesIn many ways, Romania is well positioned. Its port in Constanta, on the western coast of the Black Sea, has provided a critical — although tiny — transit point for Ukrainian grain since the war began. Romania’s own farm output is dwarfed by Ukraine’s, but it is one of the largest grain exporters in the European Union. Last year, it sent 60 percent of its wheat abroad, mostly to Egypt and the rest of the Middle East. This year, the government has allocated 500 million euros ($527 million) to support farming and keep production up.Still, this Eastern European nation faces many challenges: Its farmers, while benefiting from higher prices, are dealing with spiraling costs of diesel, pesticides and fertilizer. Transportation infrastructure across the country and at its ports is neglected and outdated, slowing the transit of its own exports while also stymieing Romania’s efforts to help Ukraine do an end run around Russian blockades.Even before the war, though, the global food system was under stress. Covid-19 and related supply chain blockages had bumped up prices of fuel and fertilizer, while brutal dry spells and unseasonal floods had shrunk harvests.Since the war began, roughly two dozen countries, including India, have tried to bulk up their own food supplies by limiting exports, which in turn has exacerbated global shortages. This year, droughts in Europe, the United States, North Africa and the Horn of Africa have all taken additional tolls on harvests. In Italy, water has been rationed in the farm-producing Po Valley after river levels dropped enough to reveal a barge that had sunk in World War II.Rain was not as plentiful in Prundu as Mr. Corbea would have liked it to be, but the timing was opportune when it did come. He bent down and picked up a fistful of dark, moist soil and caressed it. “This is perfect land,” he said. “This is perfect land,” Mr. Corbea said after picking a handful of soil on his farm in Prundu.Cristian Movila for The New York TimesThunderstorms are in the forecast, but this morning, the seemingly endless bristles of barley flutter under a cloudless cerulean sky.The farm is a family affair, involving Mr. Corbea’s two sons and his brother. They farm 12,355 acres or so, growing rapeseed, corn, wheat, sunflowers and soy as well as barley. Across Romania, yields are not expected to match the record grain production of 29 million metric tons from 2021, but the crop outlook is still good, with plenty available to export.Mr. Corbea slips into the driver’s seat of a white Toyota Land Cruiser and drives through Prundu to visit the cornfields, which will be harvested in the fall. He has been mayor of this town of 3,500 for 14 years and waves to every passing car and pedestrian, including his mother, who is standing in front of her house as he cruises by. The trees and splashes of red-and-pink rose bushes that line every street were planted by and are cared for by Mr. Corbea and his workers.He said he employed 50 people and brought in €10 million a year in sales. In recent years, the farm has invested heavily in technology and irrigation.Amid rows of leafy green corn, a long center-pivot irrigation system is perched like a giant skeletal pterodactyl with its wings outstretched.Because of price rises and better production from the watering equipment he installed, Mr. Corbea said, he expected revenues to increase by €5 million, or 50 percent, in 2022.Investments like Mr. Corbea’s in irrigation and technology are considered crucial for Romania’s agricultural growth to reach its potential.Cristian Movila for The New York TimesThe costs of diesel, pesticides and fertilizer have doubled or tripled, but, at least for now, the prices that Mr. Corbea said he had been able to get for his grain had more than offset those increases.But prices are volatile, he said, and farmers have to make sure that future revenues will cover their investments over the longer term.The calculus has paid off for other large players in the sector. “Profits have increased, you cannot imagine, the biggest ever,” said Ghita Pinca, general manager at Agricover, an agribusiness company in Romania. There is enormous potential for further growth, he said, though it depends on more investment by farmers in irrigation systems, storage facilities and technology.Some smaller farmers like Chipaila Mircea have had a tougher time. Mr. Mircea grows barley, corn and wheat on 1,975 acres in Poarta Alba, about 150 miles from Prundu, near the southeastern tip of Romania and along the canal that links the Black Sea with the Danube River.Drier weather means his output will fall from last year. And with the soaring prices of fertilizer and fuel, he said, he expects his profits to drop as well. Ukrainian exporters have lowered their prices, which has put pressure on what he is selling.Mr. Mircea’s farm is about 15 miles from Constanta port. Normally a major grain and trade hub, the port connects landlocked central and southeastern European countries like Serbia, Hungary, Slovakia, Moldavia and Austria with central and East Asia and the Caucasus region. Last year the port handled 67.5 million tons of cargo, more than a third of it grain. Now, with Odesa’s port closed off, some Ukrainian exports are making their way through Constanta’s complex.Grain from Ukraine being unloaded from a train car in Constanta, a Romanian port on the Black Sea.Cristian Movila for The New York TimesRailway cars, stamped “Cereale” on their sides, spilled Ukrainian corn onto underground conveyor belts, sending up billowing dust clouds last week at the terminal operated by the American food giant Cargill. At a quay operated by COFCO, the largest food and agricultural processor in China, grain was being loaded onto a cargo ship from one of the enormous silos that lined its docks. At COFCO’s entry gate, trucks that displayed Ukraine’s distinctive blue-and-yellow-striped flag on their license plates waited for their cargoes of grain to be inspected before unloading.During a visit to Kyiv last week, Romania’s president, Klaus Iohannis, said that since the beginning of the invasion more than a million tons of Ukrainian grain had passed through Constanta to locations around the world.But logistical problems prevent more grain from making the journey. Ukraine’s rail gauges are wider than those elsewhere in Europe. Shipments have to be transferred at the border to Romanian trains, or each railway car has to be lifted off a Ukrainian undercarriage and wheels to one that can be used on Romanian tracks.Truck traffic in Ukraine has been slowed by backups at border crossings — sometimes lasting days — along with gas shortages and damaged roadways. Russia has targeted export routes, according to Britain’s defense ministry.Romania has its own transit issues. High-speed rail is rare, and the country lacks an extensive highway system. Constanta and the surrounding infrastructure, too, suffer from decades of underinvestment.Bins storing corn, wheat, sunflower seeds and soybeans in Boryspil, Ukraine.Nicole Tung for The New York TimesOver the past couple of months, the Romanian government has plowed money into clearing hundreds of rusted wagons from rail lines and refurbishing tracks that were abandoned when the Communist regime fell in 1989.Still, trucks entering and exiting the port from the highway must share a single-lane roadway. An attendant mans the gate, which has to be lifted for each vehicle.When the bulk of the Romanian harvest begins to arrive at the terminals in the next couple of weeks, the congestion will get significantly worse. Each day, 3,000 to 5,000 trucks will arrive, causing backups for miles on the highway that leads into Constanta, said Cristian Taranu, general manager at the terminals run by the Romanian port operator Umex.Mr. Mircea’s farm is less than a 30-minute drive from Constanta. But “during the busiest periods, my trucks are waiting two, three days” just to enter the port’s complex so they can unload, he said through a translator.That is one reason he is less sanguine than Mr. Corbea is about Romania’s ability to take advantage of farming and export opportunities.“Port Constanta is not prepared for such an opportunity,” Mr. Mircea said. “They don’t have the infrastructure.”Constanta is bracing for backups at its port when the bulk of Romania’s harvest starts arriving in the coming weeks.Cristian Movila for The New York Times More