I/O issue by mixing f70 and f90

I/O issue by mixing f70 and f90

Hi all, I was wondering if someone could help me solve the issue I have with I/O when I mix f77 and f90 codes on ifort. So I have a package of f77 codes and the skeleton of the code, regarding the line at which I get the error, is like this: PROGRAM F77PRG IINPUT = 25 OPEN (IINPUT, FORM='UNFORMATTED', STATUS='UNKNOWN', FILE='input.bin') CALL FOO(IINPUT) END SUBROUTINE FOO (IINPUT) READ (IINPUT, ERR=100) INTGR END This code runs perfectly fine and the program reads the binary data from the file. Now, I want to combine this f77 program with a module written in f90, so I added the 'use' line to the top of the f77 program as: PROGRAM F77PRG use f90module ! only this line is modified IINPUT = 25 OPEN (IINPUT, FORM='UNFORMATTED', STATUS='UNKNOWN', FILE='input.bin') CALL FOO(IINPUT) END SUBROUTINE FOO (IINPUT) READ (IINPUT, ERR=100) INTGR END With this 'use' line (but not using any of the subroutines in the module), I get an error on the READ line, saying "forrtl: severe (256): unformatted I/O to unit open for formatted transfers, unit 25, file /mydirectory/input.bin." Compiling is done as follows without error: ifort -c f90module.f90 ifort -c main.f ifort -o mycode.exe f90module.o main.o Does anybody have an idea why this happens and how to get away with it? Thanks.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Seems like all the lines are connected... the following is a repost.

Hi all, I was wondering if someone could help me solve the issue I have with I/O when I mix f77 and f90 codes on ifort.

So I have a package of f77 codes and the skeleton of the code, regarding the line at which I get the error, is like this:<br>

<blockquote>

PROGRAM F77PRG

  IINPUT = 25

  OPEN (IINPUT, FORM='UNFORMATTED', STATUS='UNKNOWN', FILE='input.bin')

  CALL FOO(IINPUT)

END

SUBROUTINE FOO (IINPUT)

  READ (IINPUT, ERR=100) INTGR

END

</blockquote>

This code runs perfectly fine and the program reads the binary data from the file. Now, I want to combine this f77 program with a module written in f90, so I added the 'use' line to the top of the f77 program as:

<blockquote>

PROGRAM F77PRG

  use f90module      ! only this line is modified

  IINPUT = 25 OPEN (IINPUT, FORM='UNFORMATTED', STATUS='UNKNOWN', FILE='input.bin')

  CALL FOO(IINPUT)

END

SUBROUTINE FOO (IINPUT)

  READ (IINPUT, ERR=100) INTGR

END

</blockquote>

With this 'use' line (but not using any of the subroutines in the module), I get an error on the READ line, saying "forrtl: severe (256): unformatted I/O to unit open for formatted transfers, unit 25, file /mydirectory/input.bin."

Compiling is done as follows without error:

<blockquote>

ifort -c f90module.f90

ifort -c main.f

ifort -o mycode.exe f90module.o main.o

</blockquote>

Does anybody have an idea why this happens and how to get away with it? Thanks.

There's really no such thing as "mixing F77 and F90" here - it's all Fortran 2008, really.

You don't show what the "f90module.f90" looks like. I will comment that it is often the case that when a user provides a snippet or paraphrase of the code, the actual code is quite different and/or a critical piece was missing. Can you come up with a small but complete example that demonstrates the problem?

Steve - Intel Developer Support

Leave a Comment

Please sign in to add a comment. Not a member? Join today