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

Blank Characters

JohnNichols
Valued Contributor III
3,571 Views

If I have a character*72 Name

and Name is all blank characters coming in from a file from another program - how do I test for blankness --

Ta

John

0 Kudos
23 Replies
mecej4
Honored Contributor III
191 Views

My experience was with the 3600 first, then the 6600 (batch only) and 6400 (time-shared). Those were superb machines with easy to learn operating systems (MOMS, Kronos) and well-written manuals, the software was excellent and programs were quite easy to debug using the error dumps. By the standards of the era, and in particular in comparison to the IBM machines, the CDCs were fast and well-suited for scientific work.

0 Kudos
IanH
Honored Contributor II
191 Views

Vautier, Gilles wrote:

Sure

A character(n) Fortran string is an array of n bytes whose values range from 0 to 255.

That's at the level of implementation detail.  It won't be true if the storage for the default character kind is not a byte, or if the default character kind for the processor does not support the full range of values of a byte (e.g. ascii only uses 7 bits of the range).

0 Kudos
JohnNichols
Valued Contributor III
191 Views

ianh wrote:

Quote:

Vautier, Gilles wrote:

 

Sure

A character(n) Fortran string is an array of n bytes whose values range from 0 to 255.

 

 

That's at the level of implementation detail.  It won't be true if the storage for the default character kind is not a byte, or if the default character kind for the processor does not support the full range of values of a byte (e.g. ascii only uses 7 bits of the range).

The real problem arose when I got two blank lines on printing out the results, I did not want the two blank lines for a empty string. I used VS debug to look at the variable after it was assigned from STRAND7 and it had about 20 empty spots (possibly char(0) in a string.  I had forgotten about the char(0) - old age and tiredness, let us blame tiredness. In looking at the uninitialized Intel Fortran string it appeared to be set to char(0) - not sure if this is true or just a quirk of the debugger.

The problem is  that the sort of people I work with are likely to do anything, so the simplest method seemed to be to count the number of characters in the string, whatever they are, report the number and then return the string. It is not perfect -- but the original code was an old dog.

Complete side issue:  I ported some C# code into Mono on a Linux box.  The NET2.0 dll's from the developer of that code caused no end of problems, I could get one set running, but if I changed the C# code in VS in Windows and then ported it -- all hell broke loose. Ended up doing it all again in Mono. Works a treat, although the color change features for the screen in a cmd window do not work in Linux on Mono.  I decompiled the dll's and attempted to recompile in NET 4.5.1 and that proved to be an interesting exercise.  I am sure I can get it to work, but the VS 2103 compiler in C# is stricter than the VS 2005 that the original DLL's were compiled on and I am on a tight time constraint.

just give me Fortran so much easier.

Fun in the sun. Merry Christmas.

0 Kudos
Reply