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

Character String Length Problems

Gerald_R_1
Beginner
404 Views

To the Intel Forum,

I'm converting a Compaq Fortran code to compile and run under Intel Fortran XE 2013 SP1 (M/S Windows 7)  However, I seem to be having some very basic Character String length problems when using the debug tool under Intel Fortran 2013. For example:

CHARACTER ACS*5, NAME*10

ACS = 'Pitch'

give an error, or even inserting a character from one string into another with I=3,

WFILE(1:1) = NAME(I:I)

also generates an error under Debug step through.

Increasing the string length of ACS to *6 removes the problem.  Any ideas on what may be causing this 'length problem' ? ( compiler settings ?).

Thank you, Gerald Reeves.

 

0 Kudos
3 Replies
Steven_L_Intel1
Employee
404 Views

It is not clear to me, from your post, what the error says or what your program is doing. Perhaps you can come up with a small program that demonstrates all the issues, and you can also tell us the complete and exact text of the error messages?

The only difference from CVF I can think of is that Intel Fortran does better error checking of lengths of character dummy arguments.

0 Kudos
Gerald_R_1
Beginner
404 Views

To Steve Lionel, Intel,

Thank you for reply.  I think all these character string length issues are related because they generate virtually the same Stack Frame error message when running under debug:

> msvcr100d.dll!memcpy(unsigned char * dst, unsigned char * src, unsigned long count)  Line 101 Asm

The most basic occurence of this issue is for example, at the begining of a subroutine in the CVF code when it simply passes a program name into a pre-defined character string.  So at the top of the routine it has:

CHARACTER*9 PROG_NAME

PROG_NAME = 'PWII HIAT'

Stepping through the CVF code under Intel debug gives the above error message when line PROG_NAME = 'PWII HIAT' is 'executed'.

If I increase the PROG_NAME string length to *10 then the name is correctly stored in PROG_NAME, and no error message produced.

Hope this helps to illustrate the problem - the CVF code has many similar cases of this, so grateful of any suggestions.

Thank you, Gerald Reeves.
 

 

0 Kudos
Steven_L_Intel1
Employee
404 Views

That's a bit more helpful. It suggests that your program is corrupting data due to coding errors. In general it's inappropriate to declare character dummy arguments with explicit lengths if you're passing from Fortran - you should use CHARACTER(*) instead. Please enable Fortran > Diagnostics > Check Routine Interfaces and Fortran > Run-time > Check Array and String Bounds, then rebuild and run and see if you get different errors.

If this doesn't help, we'll need to see a buildable and runnable example that shows the problem.

0 Kudos
Reply