- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
CHARACTER*100 RIGA,FMT,KEY
KEY='123'
RIGA=''
IT FAILS WITH THE FOLLOWING ERROR:
KEY='123'
RIGA=''
IT FAILS WITH THE FOLLOWING ERROR:
KEY='123'
RIGA=''
IT FAILS WITH THE FOLLOWING ERROR:
DUMMY CHARACTER KEY HAS LENGTH 100 WICH IS GREATHER THAN ACTUAL VARIABLE LENGTH 3
SAME PROBLEM IF I USE INTERNAL WRITE WITH PROPER FORMAT
THIS WORKED FINE IN COMPAQ VISUAL FORTRAN
ANY IDEA HOW TO MANAGE WITH DINAMIC LENGTH CHARACTER VARIABLES WITH INTEL VISUAL FORTRAN?
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The pieces of code that you showed do not show that KEY is a dummy argument, and we do not know what the actual argument is other than what the compiler error message indicates.
If you subroutine uses only KEY(1:3), why not declare KEY as character(3), or, even better, CHARACTER(*) ?
On the other hand, if in other places in the subroutine (which you did not show) you access KEY as if it was longer than the actual argument, the code is illegal and should be fixed, even if by a fluke it used to give expected results with another compiler.
The variable KEY has the length that it had at the point of calling, if it is not ALLOCATABLE or has the POINTER attribute. It is not a dynamic string. Perhaps this fact makes it easier to understand why it should not be treated as an indefinitely extensible string.
If you subroutine uses only KEY(1:3), why not declare KEY as character(3), or, even better, CHARACTER(*) ?
On the other hand, if in other places in the subroutine (which you did not show) you access KEY as if it was longer than the actual argument, the code is illegal and should be fixed, even if by a fluke it used to give expected results with another compiler.
The variable KEY has the length that it had at the point of calling, if it is not ALLOCATABLE or has the POINTER attribute. It is not a dynamic string. Perhaps this fact makes it easier to understand why it should not be treated as an indefinitely extensible string.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If RIGA is a dummy argument it should be declared CHARACTER(*). The error message you describe will occur if you have declared a dummy argument of an explicit length but pass an actual argument which is shorter than that length. This is not legal Fortran and can lead to unexpected results.
In general you should always use CHARACTER(*) for dummy arguments unless you have a good reason not to do so.
In general you should always use CHARACTER(*) for dummy arguments unless you have a good reason not to do so.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page