billgray1234
Programmer
- Mar 14, 2011
- 39
i'm a bit confused.
i'm using Fortran 90/95. i'm using modules; each module CONTAINS one (and only one) subroutine.
i want to use 'assumed shape arrays' in all of my subroutines. this means that, when declaring dummy argument arrays/matrices, i don't need to declare the dimensions of each array/matrix -- instead, the dimensions are 'assumed' to be the same as those of the actual argument.
so, for example, instead of having, say
MODULE SOME_MODULE
CONTAINS
SUBROUTINE SOME_SUBROUTINE(MATRIX,IMATRIX,JMATRIX)
REAL, DIMENSION(IMATRIX,JMATRIX), INTENT(IN) :: MATRIX
END SUBROUTINE SOME_SUBROUTINE
END MODULE SOME_MODULE
i can instead have
MODULE SOME_MODULE
CONTAINS
SUBROUTINE SOME_SUBROUTINE(MATRIX)
REAL, DIMENSION,, INTENT(IN) :: MATRIX
END SUBROUTINE SOME_SUBROUTINE
END MODULE SOME_MODULE
most books that i've read (and also the internet) say that, in order to use 'assumed shape arrays', you MUST provide an interface block. for example
INTERFACE
SUBROUTINE SOME_SUBROUTINE(MATRIX)
REAL, DIMENSION,, INTENT(IN) :: MATRIX
END SUBROUTINE SOME_SUBROUTINE
END INTERFACE
however, one source that i've read said that an interface block is not necessary -- IF (and only IF) the subroutine is 'contained' within a module (i.e. using the word CONTAINS) -- like in the above example. otherwise, an interface block IS necessary (i think, for example, like in Fortran 77).
so, my questions are:-
1) is it ALWAYS necessary to use an interface block? or, as the above source said, is it permissible to NOT use one -- IF (and only IF) the subroutine is 'contained' within a module (i.e. using the word CONTAINS)?
2) if it is permissible to NOT use an interface block (i.e. using the word CONTAINS in a module), is it STILL OK to use one, anyway? for example, for added security in programming, and good 'book-keeping'.
i'm using Fortran 90/95. i'm using modules; each module CONTAINS one (and only one) subroutine.
i want to use 'assumed shape arrays' in all of my subroutines. this means that, when declaring dummy argument arrays/matrices, i don't need to declare the dimensions of each array/matrix -- instead, the dimensions are 'assumed' to be the same as those of the actual argument.
so, for example, instead of having, say
MODULE SOME_MODULE
CONTAINS
SUBROUTINE SOME_SUBROUTINE(MATRIX,IMATRIX,JMATRIX)
REAL, DIMENSION(IMATRIX,JMATRIX), INTENT(IN) :: MATRIX
END SUBROUTINE SOME_SUBROUTINE
END MODULE SOME_MODULE
i can instead have
MODULE SOME_MODULE
CONTAINS
SUBROUTINE SOME_SUBROUTINE(MATRIX)
REAL, DIMENSION,, INTENT(IN) :: MATRIX
END SUBROUTINE SOME_SUBROUTINE
END MODULE SOME_MODULE
most books that i've read (and also the internet) say that, in order to use 'assumed shape arrays', you MUST provide an interface block. for example
INTERFACE
SUBROUTINE SOME_SUBROUTINE(MATRIX)
REAL, DIMENSION,, INTENT(IN) :: MATRIX
END SUBROUTINE SOME_SUBROUTINE
END INTERFACE
however, one source that i've read said that an interface block is not necessary -- IF (and only IF) the subroutine is 'contained' within a module (i.e. using the word CONTAINS) -- like in the above example. otherwise, an interface block IS necessary (i think, for example, like in Fortran 77).
so, my questions are:-
1) is it ALWAYS necessary to use an interface block? or, as the above source said, is it permissible to NOT use one -- IF (and only IF) the subroutine is 'contained' within a module (i.e. using the word CONTAINS)?
2) if it is permissible to NOT use an interface block (i.e. using the word CONTAINS in a module), is it STILL OK to use one, anyway? for example, for added security in programming, and good 'book-keeping'.