The Reagan high command knows what it thinks about right-thinking stalwarts of the Western world. It knows a Marxist-Leninist when it sees one--anywhere. It can cut through criminal human-rights records to find the virtue of alliances with authoritarian regimes that stand between us and a surging Red tide.

Like one of those gadgets for checking the chemistry of swimming pools, the Reagan tests when it comes to foreigners are simple--too simple, some would say, for the likes of this week's White House visitor, Felipe Gonzalez, the new prime minister of Spain.

You have to wonder what Ronald Reagan will make of a socialist, young enough (40) to be his son, who cut his teeth on Marx as an underground enemy of the Franco regime and then helped turn his party away from doctrinaire Marxist-Leninism in the course of his agile climb to leadership; who supports U.S. base rights in Spain and stands to the right of those in his own party who would put an end to Spain's phased entry into the North Atlantic Treaty Organization; but who shares (as a longtime member) the Socialist International's strong affinity with the Latin America left--an affinity that just two weeks ago prompted him, while touring Central America, to call the Reagan administration's deepening involvement "fundamentally harmful."

How Reagan perceives Gonzalez--his internal political problems and their influence on his sense of Spain's best external interests--will test Reagan's tests. Gonzalez is tough, but with an easy, charismatic way about him. By now you know how gracefully Reagan accentuates the positive with foreign leaders who don't share his world view. So you can pretty much count on the two men shaking hands and coming out smiling after their meeting tomorrow. Both sides are billing it as one of those first, warm, getting-to-know-you encounters.

But the occasion will have been squandered if the opportunity isn't taken for a free and frank exchange about the cross-purposes at work in current relations between the United States and Spain. For there is more to it than the nuts and bolts of how to redress bilateral trade imbalances or the precise extent of U.S. rights to use Spanish military bases.

There's the bigger question: how does Gonzalez reconcile domestic pressure for "neutrality" with his own sense of Spain's dependency for security on the United States under an administration with strong demands on its allies and thin tolerance for those who would traffic with communists?

For Secretary of Defense Weinberger, it's simple: you don't. When last seen in Madrid in late March, Weinberger was exhorting Gonzalez's government to stop dithering and get on with full NATO membership "as a natural outgrowth of your democratic evolution."

But there's this hitch, of which Weinberger sounded unaware. Spain, which already sits in on NATO councils, was committed by Gonzalez's predecessor to proceed toward full military integration into the alliance. But Gonzalez must also live with a commitment in his party's platform to a nationwide referendum on whether Spain should be a member of NATO at all. And Spanish polls show a substantial majority against the idea.

So he has postponed the referendum, apparently hoping that a government "information" campaign on NATO's value to Spain may turn the public around. But just last week there were protest marches demanding not only withdrawal from NATO but an end to the U.S. base rights. With the NATO connection a question mark, Gonzalez is said to put a high premium on a close U.S. connection.

And there lies what one knowledgeable diplomat calls the "Catch 22 for Gonzalez." He cannot take out security insurance by making bilateral arrangements (including base rights and the purchase of F-18 aircraft) with a U.S. government whose policies in Central America profoundly offend the very elements on the Spanish left (and most importantly within his party) that want Spain out of NATO.

What's more, Gonzalez is on the spot with would-be peacemakers (Mexico, Colombia, Venezuela, Panama) who seek multilateral negotiations to end the strife. They see in a European socialist leader, dedicated to democracy and representing a constitutional monarchy, just the man to take their case to Ronald Reagan. Hence Gonzalez's harsh words about U.S. policy from Bogota two weeks ago; they were for Central American as well as home consumption.

The Reagan administration is far from ready to leave matters to the locals. But, even while expanding the U.S. military effort, it does profess regularly its sincerity in pursuit of a negotiated Central American settlement. If Ronald Reagan can convey that sincerity persuasively to Gonzalez, it would give the prime minister something to show his critics back home that would be a lot more useful than Cap Weinberger's rallying cries on the blessings of full NATO partnership.