Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: How to dist...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 15 Topic 8228 of 8656
Post > Topic >>

Re: How to distinguish between numerical data and alphanumeric title

by bru <bru@[EMAIL PROTECTED] > May 13, 2008 at 03:59 PM

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
 




 15 Posts in Topic:
How to distinguish between numerical data and alphanumeric titl
bru <bru@[EMAIL PROTEC  2008-05-13 09:50:32 
Re: How to distinguish between numerical data and alphanumeric t
e p chandler <epc8@[EM  2008-05-13 02:21:11 
Re: How to distinguish between numerical data and alphanumeric t
Terence <tbwright@[EMA  2008-05-13 02:49:27 
Re: How to distinguish between numerical data and alphanumeric
glen herrmannsfeldt <g  2008-05-13 02:10:19 
Re: How to distinguish between numerical data and alphanumeric t
Arjen Markus <arjen.ma  2008-05-13 05:13:52 
Re: How to distinguish between numerical data and alphanumeric t
bru <bru@[EMAIL PROTEC  2008-05-13 15:59:51 
Re: How to distinguish between numerical data and alphanumeric t
harper@[EMAIL PROTECTED]   2008-05-14 10:12:53 
Re: How to distinguish between numerical data and alphanumeric t
glen herrmannsfeldt <g  2008-05-13 14:31:17 
Re: How to distinguish between numerical data and alphanumeric t
Arjen Markus <arjen.ma  2008-05-13 12:45:03 
Re: How to distinguish between numerical data and alphanumeric t
bru <bru@[EMAIL PROTEC  2008-05-14 12:28:36 
Re: How to distinguish between numerical data and alphanumeric t
e p chandler <epc8@[EM  2008-05-13 16:19:47 
Re: How to distinguish between numerical data and alphanumeric t
glen herrmannsfeldt <g  2008-05-13 16:28:51 
Re: How to distinguish between numerical data and alphanumeric t
Arjen Markus <arjen.ma  2008-05-13 23:29:13 
Re: How to distinguish between numerical data and alphanumeric t
GaryScott <garylscott@  2008-05-13 07:12:24 
Re: How to distinguish between numerical data and alphanumeric t
glen herrmannsfeldt <g  2008-05-13 09:18:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Aug 30 8:28:46 CDT 2008.