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
Beginner
2,597 Views
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 Replies
Peter
Beginner
2,597 Views
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???


0 Kudos
lklawrie
Beginner
2,597 Views

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
0 Kudos
Luis2
Beginner
2,597 Views
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


0 Kudos
lklawrie
Beginner
2,597 Views

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
0 Kudos
TimP
Honored Contributor III
2,597 Views
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.
0 Kudos
Luis2
Beginner
2,597 Views
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.
0 Kudos
Peter
Beginner
2,597 Views
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!
0 Kudos
Steven_L_Intel1
Employee
2,597 Views
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.
0 Kudos
Luis2
Beginner
2,597 Views

I understand

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


Thank you

0 Kudos
Reply