- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I am working on an application that is written in Fortran 77, but was upgraded to use structures based on Compaq f90. I am trying to get it as compliant as possible. I have run into cases where in a subroutine call a scalar is passed to an array. That worked with interface checking turned off, but does not with interface checking turned on. I would think a scalar would just get assigned to element one of the array.
The more problematic issue I found is when an array is passed to a subroutine that expects a scalar. No specific element is being passed. it is the entire array. In Fortran 77 this seemed to not throw any kind of error.
What are the best ways to deal with these issues.
Thaks.
Michael
- Marcas:
- Intel® Fortran Compiler
Link copiado
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
On the call you can put square brackets around the scalar e.g. [scalar_var] which constructs an array of 1 element to pass. The interface checking will then be happy. The other way you need to pass array(1) or array(1,1) to pass just the first element as a scalar.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Passing an array to a scalar, or a scalar to an array, has always been an error in the Fortran language, but, in the absence of explicit interfaces, a compiler had no way to detect the mismatch.
I discuss this in the section on Sequence Association in Doctor Fortran in "I've Come Here For An Argument"
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
One issue I am trying to fix is when the prior programmers passed a 0 into a subroutine expecting an integer. I defined a parameter zero and gave it the value 0. I am still getting a mis-match with that combination.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
First, are you sure that the corresponding argument is integer? Is there a non-default kind of integer, such as INTEGER*2 specified? Show us the subroutine argument list and all the argument declarations, as well as the call you are making. What is the exact error message?
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
kolber, Michael wrote:One issue I am trying to fix is when the prior programmers passed a 0 into a subroutine expecting an integer. I defined a parameter zero and gave it the value 0. I am still getting a mis-match with that combination.
I don't get that? Is the integer in the subprogram not declared with default kind? E.G 0 will be a default (4 byte) integer with default compiler settings. Is there any intent specified? Maybe you should show a simple example that has the call and the declarations.
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
I solved the problem. It was not one of the hard coded 0's that was causing the issue. It was a parameter that was defined as 0 being passed to a logical variable in the subroutine.
Thanks all for the help.

- Subscrever fonte RSS
- Marcar tópico como novo
- Marcar tópico como lido
- Flutuar este Tópico para o utilizador atual
- Marcador
- Subscrever
- Página amigável para impressora