Arjen Markus wrote:
> On 13 mei, 12:10, glen herrmannsfeldt <g...@[EMAIL PROTECTED]
> wrote:
>
>>bru wrote:
>>
>>>My data file contains one or more blocks composed of a title and a set
>>>of numerical data. After one block it reads an other:
>>> how to stop the calculation if I encounter a line of numerical data
>>>instead of a title. I consider a title as it contains at least one non
>>>numerical character (for example Case Nr3 a=1.2, b=6., c=80.)
>>
>>If you already know when it should be data and title, and
>>are reading the title into a CHARACTER variable, all you need
>>to do is check that variable. Note that you should be careful
>>what is a non-numeric character, through. Especially, D and E
>>are often numeric characters, and maybe other letters.
>>(Q for quad precision on some systems.)
>>
>> DO I=1,LEN_TRIM(S)
>> IF((S(I:I).GT.'9'.OR.S(I:I).LT.'0') .AND.
>> # (S(I:I).NE.'+'.AND.S(I:I).NE.'-'.AND.S(I:I).NE.'.'
>> # .AND.S(I:I).NE.'E')) GOTO 999
>> ENDDO
>>
>>or use a table and index with ACHAR(S(I:I)) to test for
>>non-numeric characters.
>>
>>-- glen
>
>
> That should be easier with verify(). For instance:
>
> if ( verify(line, ' -+.1234567890eEdDqQ') > 0 ) then
> write(*,*) 'line contains characters that can''t appear in purely
> numerical data'
> endif
>
> (Mind you: depending on how you want to read the data,
> formatted or via list-directed format, you may need to
> include * and , as well)
>
> Regards,
>
> Arjen
Thanks very much; your solution using VERIFY function is elegant though
it is a Fortran 90 one!
Bernard


|