- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Do I always have to declare the variables with fortran? Is there a way not to declare it such as MATLAB? Do I always have to declare it at the beginning of the subroutine?
Thank you,
Emre
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Fortran has always allowed implicit typing. By default, variables with names starting with 'I' - 'N' are integers and all others are REAL. If you need variables of other types (LOGICAL, CHARACTER, etc.), you must declare them. If you want a variable name to represent an array, you need a suitable declaration, either in a DIMENSION or a type declaration.
Fortran and Matlab are different languages. Do not attempt to draw inferences about one based on what you know about the other.
You should read the Fortran documentation in order to become more effective at using Fortran.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Emre,
Despite the implicit typing of variables, I would encourage you to always use IMPLICIT NONE in every routine, and define all variables as you need them.
This helps protect you from spelling mistakes which could result in defining new variables separate to the ones you planned to use - if the compiler switch is set to warn for uninitialised and unused variables, you will soon find your mistakes.. It is a good programming practice to adopt, and one which was not available in the older versions of Fortran.
Regards,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you. I figured implicit typing is possible. However, soon I have noticed its disadvantages. In fact, I am right now having a problem. Some of the vectors and matrices do not pass from one subroutine to another. It says undefined pointer/array. Even though I went back to "implicit none", i am still having this problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Can you upload your code?
David
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page