ccornchip2
Programmer
Hi,
I was looking over some fortran code that I am working with, and I've noticed that the functions and subroutines are all "declared" in an interface block.
However, through some of my own testing, I've noticed that not declaring a subroutine in an interface block does NOT cause a compiler error as I thought it should have. But, I did observe some unexpected behaviour and runtime errors (e.g. seg-fault).
Googling around, I found that this was perfectly normal, but it does lead me to my first question:
Why did it not cause a compiler error (or even warning)?
Secondly, I've noticed that subroutines that have no arguments don't appear in the interface block, even if the sub is defined in a different .f90 file. Why is this so?
Is there a rule saying "declare all functions and subs that you will use in your interface block *except* the ones that don't have arguments ... and if you forget to, the compiler won't pick it up" ?
My background is in C, so I'm a bit naive to all this fortran stuff.
I was looking over some fortran code that I am working with, and I've noticed that the functions and subroutines are all "declared" in an interface block.
However, through some of my own testing, I've noticed that not declaring a subroutine in an interface block does NOT cause a compiler error as I thought it should have. But, I did observe some unexpected behaviour and runtime errors (e.g. seg-fault).
Googling around, I found that this was perfectly normal, but it does lead me to my first question:
Why did it not cause a compiler error (or even warning)?
Secondly, I've noticed that subroutines that have no arguments don't appear in the interface block, even if the sub is defined in a different .f90 file. Why is this so?
Is there a rule saying "declare all functions and subs that you will use in your interface block *except* the ones that don't have arguments ... and if you forget to, the compiler won't pick it up" ?
My background is in C, so I'm a bit naive to all this fortran stuff.