Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

format syntax error

Luis2
Einsteiger
2.594Aufrufe
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
0 Kudos
10 Antworten
Peter
Einsteiger
2.594Aufrufe
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

Luis,

What compiler are you using???


lklawrie
Einsteiger
2.594Aufrufe

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
Luis2
Einsteiger
2.594Aufrufe
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


lklawrie
Einsteiger
2.594Aufrufe

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
TimP
Geehrter Beitragender III
2.594Aufrufe
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.
Luis2
Einsteiger
2.594Aufrufe
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.
Peter
Einsteiger
2.594Aufrufe
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!
Steven_L_Intel1
Mitarbeiter
2.594Aufrufe
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.
Luis2
Einsteiger
2.594Aufrufe

I understand

program main
character(len=5) a
a='("foo")'
print a ! foo
end program


Thank you

Antworten