PGI User Forum
 SearchSearch   MemberlistMemberlist     RegisterRegister   ProfileProfile    Log inLog in 

Free OpenACC Webinar

logical unit numbers between f77&f90

 
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling
View previous topic :: View next topic  
Author Message
Gerard



Joined: 09 Oct 2005
Posts: 2

PostPosted: Sun Oct 09, 2005 3:28 pm    Post subject: logical unit numbers between f77&f90 Reply with quote

I'm using:
pgf77 6.0-5 64-bit target on x86-64 Linux
pgf90 6.0-5 64-bit target on x86-64 Linux
If a file is opened in an f90 subroutine, the unit number cannot be used by children subroutines written in f77. To reproduce the problem take two files:

cat > main.f90 << EOF
PROGRAM main
INTEGER::fh=8
OPEN(UNIT=fh, NAME="hello", STATUS='REPLACE')
CALL PRINT_HELLO(fh)
END PROGRAM
EOF

cat > print_hello.f << EOF
SUBROUTINE PRINT_HELLO(fh)
INTEGER fh
WRITE(fh, *) "hello"
END
EOF

:~> pgf90 print_hello.f main.f90
print_hello.f:
main.f90:
:~> ./a.out
:~> cat hello
hello

So - this is perfect. But if we instead:
:~> pgf77 -c print_hello.f
:~> pgf90 print_hello.o main.f90
:~> ./a.out
:~> cat hello
:~> cat fort.8
hello

i.e. the subroutine print_hello does not see that the file "hello" associated with logical unit number 8 is opened and so writes to fort.8.

This looks like a bug in PGI. I do not have other versions of PGI to test what else is effected.
Back to top
View user's profile
mkcolg



Joined: 30 Jun 2004
Posts: 6213
Location: The Portland Group Inc.

PostPosted: Mon Oct 10, 2005 1:08 pm    Post subject: Reply with quote

Hi Gerard,

This isn't a bug, rather its an incompatability between the two languages (F90 and F77). Each language has its own runtime library which hold I/O information such as units. This information is not shared so you can not mix I/O between languages.

Thanks,
Mat
Back to top
View user's profile
Gerard



Joined: 09 Oct 2005
Posts: 2

PostPosted: Mon Oct 10, 2005 8:53 pm    Post subject: logical unit numbers between f77&f90 Reply with quote

Thanks for the reply Mat.

I was guessing this might be the case but it's not clear from reading the FAQ:
http://www.pgroup.com/support/compile.htm - "What should I be aware of when mixing pgi fortran with g77". It might be worth clarifying this there as it was the page I arrived at when I googled for this issue.

I'm prettty new to the PGI compilers so I was surprised to find that the workaround was simply to use the pgf90 compiler to compile the f77 code. There being syntex differences between the languages (eg. line continuation and comments) - obviously pgf90 has a f77 parser. That being the case, is there a reason that pgf77 and pgf90 are still seperate and rather than there being a pgfortran? I'm just asking because I'm thinking of hardwiring this into my autoconf scripts ;)

Cheers
g
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    PGI User Forum Forum Index -> Programming and Compiling All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © phpBB Group