- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
Hello,
I would like to give anarray as a formal parameter to a subroutine in the following way
subroutine sub(b)
double precision, dimension(:) :: b
write(*,*) b
end subroutine sub
program arrayDelivery
double precision, dimension(3) :: a
a=987654.321
call sub(a)
end
Althoughifort compiles the code without any errors,the program does not deliver the correct results. Instead of the values for b it prints only a blank line. I think, that the delivery of the formal parameter is not correct.
Please can anyone explain to me the reason.
Thanks
dino
- Marcas:
- Intel® Fortran Compiler
Link copiado
1 Responder
- Marcar como novo
- Marcador
- Subscrever
- Silenciar
- Subscrever fonte RSS
- Destacar
- Imprimir
- Denunciar conteúdo inapropriado
That's not an adjustable array (where you would pass the bound as a separate parameterr and declare it in the subroutine as a(n)), it's an assumed-shape array and an explicit interface is required to be visible to the caller. If you make sub a "contained" procedure of the main program, that would do it, otherwise sub needs to be in a module or you have to write an INTERFACE block.

Responder
Opções do tópico
- 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