Hi everybody,
I am new to FORTRAN 90 and try to test the (good) changes since FORTRAN 77. In wanting to use character functions with length calculated at run time I ran into a problem with the compiler. I do not now whether this is due to the compiler (I am using a relatively old version: 5.0D) or whether my code is wrong. I have stripped down the code to this:
character(8) char,ch
char='bonjour'
ch=f(adjustl(char))
contains
function f(string)
character(*), intent(in) :: string
character(len(string)) f
f=string
return
end function
end
and still have an 'assertion failure' message. I read and read the code but see nothing wrong according to the FORTRAN90 manuals I have with me. Please could somebody:
- signal me any gross error,
- or tell me whether this code compiles with a more recent version of Compaq Visual Fortran.
Thanks in advance.
I am new to FORTRAN 90 and try to test the (good) changes since FORTRAN 77. In wanting to use character functions with length calculated at run time I ran into a problem with the compiler. I do not now whether this is due to the compiler (I am using a relatively old version: 5.0D) or whether my code is wrong. I have stripped down the code to this:
character(8) char,ch
char='bonjour'
ch=f(adjustl(char))
contains
function f(string)
character(*), intent(in) :: string
character(len(string)) f
f=string
return
end function
end
and still have an 'assertion failure' message. I read and read the code but see nothing wrong according to the FORTRAN90 manuals I have with me. Please could somebody:
- signal me any gross error,
- or tell me whether this code compiles with a more recent version of Compaq Visual Fortran.
Thanks in advance.
链接已复制
8 回复数
Works fine for me at 5.0D also -- pasted from here?! Where do you get
assertion failure -- at compile-time or at run-time?
----------------(few minutes later)---
Oh, it works only in Debug version -- right, it crashes in Release, even with
/optimize:1
Jugoslav
assertion failure -- at compile-time or at run-time?
----------------(few minutes later)---
Oh, it works only in Debug version -- right, it crashes in Release, even with
/optimize:1
Jugoslav
Some more details,
Within the large program the code comes from, I have the same behavior. The Release version crashes at compile time while the Debug version passes through (Jugoslav, I had not tried /optimize:1). However, it is worth knowing that I have a strange behavior at run-time with the Debug version. At some point I get a Microsoft Developer Studio message:
"User breakpoint called from code at 0x77f862e8".
If I click OK the program seems to work fine. Does this message make sense to somebody? Is this real bad?
Within the large program the code comes from, I have the same behavior. The Release version crashes at compile time while the Debug version passes through (Jugoslav, I had not tried /optimize:1). However, it is worth knowing that I have a strange behavior at run-time with the Debug version. At some point I get a Microsoft Developer Studio message:
"User breakpoint called from code at 0x77f862e8".
If I click OK the program seems to work fine. Does this message make sense to somebody? Is this real bad?
To clarify: there is no problem with your code, but with the compiler. "User breakpoint called from XXX" messages can be ignored, since as far as I know those are some kind of checkouts in run-time libraries; (kind of ASSERTs?).
By the way, my DVF 5.0D when F95 compatibility warnings are turned on warns that "Variable-length character functions are obsolescent in F95". Is it really so? I don't see a reason why they are declared obsolete?
By the way, my DVF 5.0D when F95 compatibility warnings are turned on warns that "Variable-length character functions are obsolescent in F95". Is it really so? I don't see a reason why they are declared obsolete?
The "user breakpoint" message is not a "problem" in the compiler - this is how the Run-Time Library signals I/O errors. You should get a real error message in the console window.
Assumed-length (CHARACTER*(*) functions are indeed obsolescent in Fortran 95. Not our doing, and we'll continue to support them. See my Dr. Fortran article in Visual Fortran Newsletter III.
Steve
Assumed-length (CHARACTER*(*) functions are indeed obsolescent in Fortran 95. Not our doing, and we'll continue to support them. See my Dr. Fortran article in Visual Fortran Newsletter III.
Steve
Thanks to you guys, I now know that the problem is with the compiler, not the code. Also that the code compiles with CVF6.5 and I am seriously considering upgrading. However, I am still wondering whether the bug has been truly fixed. Compiling doesn't mean running (see my previous message). I suppose that for people with an inside knowledge of the compiler it is not too difficult to identify the bug in the short code submitted. Hence my question:
Steve, has this bug been identified and fixed?
Roger
Steve, has this bug been identified and fixed?
Roger