With the 7.0-4 version of the PGI compiler, I have met a problem to use the FORTRAN compilation option –byteswapio.
When the main program is coded with C++ and the link edition line done with the PGCC compiler, the –byteswapio FORTRAN compilation option (used for the FORTRAN code) is not effective.
I am looking for a solution (perhaps a specific FORTRAN library adding to the link command) to make the –byteswapio compilation option effective even when the main program is coded in an other language than FORTRAN.
I have to precise that with the 6.0 version of the PGI compiler, this problem does not occur.
You should only need to compile the Fortran portions of your code with “-byteswapio” and not need the flag on the link line. So it’s unclear to me what the problem might be. Can you please send an example to PGI Customer Service at trs@pgroup.com?
I sent an example to PGI Customer Service. But I want to give more explanations compared with my last message in the forum. I compiled only the fortran portions of my code with the byteswapio option but when the main program is coded with C++ and the link done with the pgCC compiler, -byteswapio compilation option is not effective.
When the main program is coded with fortran and the link done with pgf90 compiler, -byteswapio is effective.
What can i do to make this fortran compilation option effective even when the main program is coded with C++ and when i use the PGCC compiler to link? Thank you for your help
As I said before, this should not be the case so we’ll need to do some investigation to determine the cause. Thank for sending an example to Customer Service.
Hi,
Thank you for your answer but i think that, perhaps, i did not explain the problem enough clearly.
In your test you did not use -byteswapio for the compilation of littest.f (which do not call the function defined in litmain.f because it don’t need it as you can see in the program). If you compile littest.f with -byteswapio you will get the result expected.
Your tests , both, did not take into account the fortran compilation option -byteswapio.
You can see the next three examples and note that the second one does not behave as expected. You will find in attached files all programs i used in the three cases.
Thank you for your help.
Boussad.
First Case
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgf90 -c -byteswapio littest.f
NOTE: your trial license will expire in 3 days, 11.4 hours.
NOTE: your trial license will expire in 3 days, 11.4 hours.
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgf90 -o testmainfort littest.o
dev-p4:/gtmp/amarouch/mainCC>./testmainfort
err1 0
err110 219
ligne
In this example, the fortran compilation option is effective and the result is expected
Second Case : C++ main
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgf90 -c -byteswapio litmain.f
NOTE: your trial license will expire in 3 days, 11.3 hours.
NOTE: your trial license will expire in 3 days, 11.3 hours.
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgCC -c maintest.cpp
NOTE: your trial license will expire in 3 days, 11.3 hours.
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgCC -o testmaincpp litmain.o maintest.o -pgf90libs
dev-p4:/gtmp/amarouch/mainCC>./testmaincpp
erreur open 0
erreur read 0
ligne
.DIMENSIONS PPNBNOE= 1444,NBELT= 6723,NBFAC= 1200,NBNFR= 602,LBG= 10 PP.DESCRIPTION_ELT
In this example, the fortran compilation option is not effective even we used the byteswapio option.
Third case : fortran main program which call a C++ function wich call a fortran fuction
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgf90 -c -byteswapio litmain.f
NOTE: your trial license will expire in 3 days, 11.1 hours.
NOTE: your trial license will expire in 3 days, 11.1 hours.
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgCC -c maincpp.cpp
NOTE: your trial license will expire in 3 days, 11.1 hours.
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgf90 -c pricipal.f
NOTE: your trial license will expire in 3 days, 11.1 hours.
NOTE: your trial license will expire in 3 days, 11.1 hours.
dev-p4:/gtmp/amarouch/mainCC>/usr/local/pgi/linux86/7.0-4/bin/pgf90 -o testmainfort_call pricipal.o litmain.o maincpp.o -lpgc -lm -ldl -lstd -lrt -lc -lC-pgf90libs
dev-p4:/gtmp/amarouch/mainCC>./testmainfort_call
erreur open 0
err110 219
ligne
In this example, the fortran compilation option is effective and the result is expected
David M BORER a écrit :
Here is my experience with 7.0-4 -I get the same results in either case.
I have attached the tests I created.
% pgf90 -c -byteswapio litmain.f -V
pgf90 7.0-4 32-bit target on x86 Linux
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
PGF90/x86 Linux 7.0-4
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
PGF90/x86 Linux 7.0-4
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved
pgf90 7.0-4 32-bit target on x86 Linux
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
littest.f:
PGF90/x86 Linux 7.0-4
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
PGF90/x86 Linux 7.0-4
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2007, STMicroelectronics, Inc. All Rights Reserved.
First I am sorry for my mistake… My name is boussad (and not p&c). I join you five files. the first one (maintest.cpp) is a main program coded with C++ which call a fortran function defined in the second file (litmain.f). The third file (command lines) involve compilation and link commands (of course, we use -byteswapio only for litmain.f). The fourth file (littest.f) is a fortran main program where is defined the same function coded in the second file (litmain.f). The compilation of this fortran file with the option -byteswapio give a different result than the last case (maintest.cpp and litmain.f). When the main program is coded with fortran and the link done with fortran compiler, the compilation option -byteswapio is taken to account and effective. When the main program is coded with C++ (for example) and the link done with PGCC compiler, the fortran compilation option -byteswapio used for the fortran subroutine called by the main program (in our example) is not effective. The fifth file (piece.may) is the binary file (in big endian format data file) read by litmain.f and by littest.f . I did the same operation with fortran main program wich call a C++ function wich call the function defined in litmain.f; in this case, -byteswapio is effective (because the main program is coded in fortran?). This problem does not occur with PGI 6.0 version. I hope that my message explain clearly the problematic. Thank you for your help.
int main()
{
// cout<<" Appel à la fonction fortran lit binaire “<<endl;
litbinaire_();
// cout<<” Fin d’appel de la fonction fortran litbinaire "<<endl; return(0);
}
subroutine litbinaire
character ligne*256
integer err1,erreur
ligne=' '
open(unit=50,file="piece.may",form='unformatted',
& status='old',
& iostat=err1 )
write(*,*)' erreur open ',err1
read (unit=50,iostat=erreur, err=110, end=200 ) ligne
write(*,*)' erreur read ',erreur
write(*,*)' ligne ',ligne
write(500,*)ligne
goto 20
110 write(,)’ err110 ‘,erreur
write(,)’ ligne ',ligne
write(510,*)ligne
goto 20
200 write(,)’ err200 ‘,erreur
write(,)’ ligne ',ligne
C
write(520,*)ligne
extern “C” int maincpp_();
extern “C” void litbinaire_();
int maincpp_(void)
{
// cout<<" Appel à la fonction fortran lit binaire “<<endl;
litbinaire_();
// cout<<” Fin d’appel de la fonction fortran litbinaire "<<endl;
return(0);
}