I’ve isolated the problem, and it is not one of pass by reference, but probably an UPPERCASE / lowercase or underbar_ mangling issue.
The library I was using (netCDF) was one that I needed to build in C for x64, and the C source uses cfortran.h. This header contains a number of preprocessor directives designed to allow interplatform C/Fortran interoperability. I had naively set VISUAL_CPLUSPLUS as the preprocessor switch for this header without realizing that this would produce a library that used the old Compaq VF passing conventions. This, however, should not have prevented the PGI Visual Fortran linker from linking. (But would have caused an exception when trying to run the code because of the string length argument passing.) I believe what caused the PGI Visual Fortran linker not to link was probably an UPPERCASE or no underbar_ issue.
For some reason, however, I was able to link to this (bad CVF) library when I set the PGI Visual Studio -> Fortran-> External Procedures-> calling convention switch to ‘C by reference.’ After I did this, however, I got a few ‘unresolved external’ linker errors for some 3F functions. I believe these 3F functions could just be used directly under PGI Fortran, but for portability, the code is set up to access them using CALL statements. The linker didn’t seem to mind this when the calling convention was set to ‘default’ but it didn’t find them as external functions in the default x64 libraries when ‘C by reference’ was set.
The following sample code will illustrate the problem I had. When built for x64 using PGI Visual Fortran in Visual Studio 2008, this snippet will build OK with the Fortran-> External Procedures-> calling convention set to ‘default,’ but will throw an ‘unresolved external’ linker error when the calling convention is set to ‘C by reference.’ It will build OK for WIN32 either way, so this is only an issue for the x64 libraries. I believe x64 only passes using C by reference anyway (__fastcall), so the option in PGI Visual Fortran to set this is also a little bit confusing.
CHARACTER(LEN=80) :: TEMPSTR
end program prog
In the meantime, I’ve rebuilt my x64 netCDF libraries for pgiFortran without the obfuscating CVF stuff and everything is (momentarily) copasetic. Now I need to get MPI working under x64 for code written for UNIX. Anyone know if there’s an easy way to allow Windows to permit multiple processes to access the same open file? Not that anything is ever easy. If it were, they wouldn’t need me to do it.