- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi
By default the debugger does not detect the format error
print a ! instead print *,a
I have inspected the project properties and can not find how to change this
By default the debugger does not detect the format error
print a ! instead print *,a
I have inspected the project properties and can not find how to change this
Link kopiert
10 Antworten
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Quoting - Luis
Hi
By default the debugger does not detect the format error
print a ! instead print *,a
I have inspected the project properties and can not find how to change this
By default the debugger does not detect the format error
print a ! instead print *,a
I have inspected the project properties and can not find how to change this
Luis,
What compiler are you using???
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I think it will be hard for the compiler (any compiler) to detect your intentions here as the print statement has changed with standards:
print a
suggests using a as the format -- no longer do formats have to be numbers and format statements. With some compiler settings, you would probably get an error at runtime.
Linda
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I'm using ivf 10.1
The error is trivial. Simply, I was surprised that is not detected at compile time.
Perhaps an formated output can not be detected,but I thought that
print a
is an easily detectable error
The error is trivial. Simply, I was surprised that is not detected at compile time.
Perhaps an formated output can not be detected,but I thought that
print a
is an easily detectable error
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
variable a could just as easily be defined as "('type this here')"
and thus print a would produce:
type this here
on the output line.
in old style fortran, any kind of variable could hold a string. that's why i say it might be detected during runtime but not perhaps during compile time.
Linda
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
When I compile this program:
t.f90(1): error #6304: This format specifier must be of type INTEGER.
print a
------------^
compilation aborted for t.f90 (code 1)
The syntax of the PRINT statement is:
PRINT format [, output-item-list]
Now here's where it gets interesting. When you look at the F2003 standard, format is allowed to be one of:
print a
-----------^
t.f90(2): error #5503: Variable 'A' has not been assigned a label in this program unit.
print a
-----------^
But I note that if I don't ask for standards checking, I still get the second error.
So.. I assume that in Luis' program, variable a is declared character. Depending on what is in that character string, one might see almost ...
[plain] print a end[/plain]I get:
t.f90(1): error #6304: This format specifier must be of type INTEGER.
print a
------------^
compilation aborted for t.f90 (code 1)
The syntax of the PRINT statement is:
PRINT format [, output-item-list]
Now here's where it gets interesting. When you look at the F2003 standard, format is allowed to be one of:
- default-char-expr
- label
- *
print a
-----------^
t.f90(2): error #5503: Variable 'A' has not been assigned a label in this program unit.
print a
-----------^
But I note that if I don't ask for standards checking, I still get the second error.
So.. I assume that in Luis' program, variable a is declared character. Depending on what is in that character string, one might see almost ...
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Certain compilers, such as gfortran, will check the contents of a constant format string at compile time. Some of those checks happen with ifort only at run time, perhaps only when -check format has been set at compile time, and only when use of the format is attempted. The run-time check has the advantage of applying to variable as well as constant formats, but the disadvantage of not catching problems not exposed by a test run. The function of the debugger would be to help determine what led up to the problem, perhaps not needed in the present case.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I would not expect the debugger to do anything with this. The program should generate a run-time error.
Yes, in my first post I should have written compiler, not debugger
In my little program a is a character
program main
character(len=5) a; a='foo' ; print a
end program
but the compiler does not catch any error, as expected the program crash when I run it.
It really is a bug when I was writing a code, I Do not expect the statement works in a different way.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Quoting - Luis
Yes, in my first post I should have written compiler, not debugger
In my little program a is a character
program main
character(len=5) a; a='foo' ; print a
end program
but the compiler does not catch any error, as expected the program crash when I run it.
It really is a bug when I was writing a code, I Do not expect the statement works in a different way.
Oh!!... That makes a lot of difference when you say 'debugger' instead of 'complier'.
Possibly it might be expecting a namelist, while it is compiling; when you debug it gets upset since it wasnt namelist ! Thesyntax for Print for namelist is
print nml
where
nml=Is the nonkeyword form of a namelist specifier (no NML=) indicating namelist formatting.
This might be a possibility only!
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I already explained that this program is perfectly valid Fortran syntax, which is why the compiler did not complain. It thought you had a run-time format string in variable A. Since you didn't, you got an error at run-time.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
I understand
program main
character(len=5) a
a='("foo")'
print a ! foo
end program
Thank you

Antworten
Themen-Optionen
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite