2 formatting questions 
Author Message
 2 formatting questions

How do I left justify the following?
Character:: charac5*5
charac5 = 'abcde'
write (1,'(a80)') charac5

'abcde' then gets printed on columns 76-80 instead of 1-5. I know the
easy solution is to just do write (1,'(a5)') charac5 but I would like
to know how to force left justification here.

How do I sort a character line into integers, reals & characters?
E.g.
Character:: charac80*80
charac80='Mary had 5 bags of flour of mass 1.0 - 5.0 kg.'
(The line is always read in as a character string, although I'm willing
to change it as necessary if it would help the sorting process!)

I would like to extract 5 as an integer, 1.0 & 5.0 as reals and perhaps
toggle some flags based on characters present in the string (e.g.
"flour", "kg"), while discarding the rest.



Wed, 23 Jul 2008 20:15:51 GMT  
 2 formatting questions
 > How do I left justify the following?
If you don't need the extra blanks, you could use

write (1,'(a)') charac5

If you want the extra blanks, you could use

write(1, '(a80') charac5//repeat(' ', 80-len(charac5))

Quote:
>  How do I sort a character line into integers, reals
> & characters?

fortran doesn't provide a pattern matching facility.
You'll need to code this up your self.

Bob Corbett



Wed, 23 Jul 2008 21:44:48 GMT  
 2 formatting questions

Quote:

>  > How do I left justify the following?
> If you don't need the extra blanks, you could use
> write (1,'(a)') charac5
> If you want the extra blanks, you could use
> write(1, '(a80') charac5//repeat(' ', 80-len(charac5))
>> How do I sort a character line into integers, reals
>>& characters?
> Fortran doesn't provide a pattern matching facility.
> You'll need to code this up your self.

Or use one of the C callable regular expression packages.
Unix systems usually include one, and similar ones have been
ported to most other systems with a C compiler.

Much of it is done with C pointers, complicating calling
them from Fortran, but it is still probably easier than writing
one from scratch.

-- glen



Thu, 24 Jul 2008 17:29:10 GMT  
 2 formatting questions


Quote:
> How do I sort a character line into integers, reals & characters?
> E.g.
> Character:: charac80*80
> charac80='Mary had 5 bags of flour of mass 1.0 - 5.0 kg.'
> (The line is always read in as a character string, although I'm willing
> to change it as necessary if it would help the sorting process!)
> I would like to extract 5 as an integer, 1.0 & 5.0 as reals and perhaps
> toggle some flags based on characters present in the string (e.g.
> "flour", "kg"), while discarding the rest.

        You'll have to do that the hard way.  Use the character intrinsics
to extract each token in turn; try to read it as a floating point number
with an internal read, if you don't get an error then perhaps scan it
for a decimal point to differentiate between float and integer.  You'll
have problems with strings like "The number of the beast was 666."!

--
Ivan Reid, Electronic & Computer Engineering,     ___     CMS  Collaboration,

        KotPT -- "for stupidity above and beyond the call of duty".



Thu, 24 Jul 2008 17:20:14 GMT  
 2 formatting questions
Thanks guys. About character recognition, would you say with near
certainty that heuristic programs don't produce as good results as a
neural network-type decoder?

After all, our brains are a high level NN and we benchmark the
performance of character recognition against ourselves.



Fri, 25 Jul 2008 17:22:25 GMT  
 2 formatting questions

Quote:

>How do I left justify the following?
>Character:: charac5*5
>charac5 = 'abcde'
>write (1,'(a80)') charac5

>'abcde' then gets printed on columns 76-80 instead of 1-5. I know the
>easy solution is to just do write (1,'(a5)') charac5 but I would like
>to know how to force left justification here.

You just did it.
What's the problem with '(a)' ?


Fri, 25 Jul 2008 23:44:14 GMT  
 2 formatting questions

Quote:

> Thanks guys. About character recognition, would you say with near
> certainty that heuristic programs don't produce as good results as a
> neural network-type decoder?

No. I wouldn't even say that at all, much less with "near certainty".
Mostly, I'd say that the statement is too broad to even have a
well-defined answer.

Quote:
> After all, our brains are a high level NN and we benchmark the
> performance of character recognition against ourselves.

That sounds more like hand-waving than "near certainty". And even as
handwaving goes, it has basic flaws in logic. That doesn't mean the
answer is wrong, but it sure doesn't follow from "reasoning" like this.

The statement "Method x is capable of producing excellent results" does
no logically result in a conclusion anywhere close to "method y doesn't
produce results as good as method x." It barely even suggests that as a
hypothesis, much less argues for it with "near certainty".

If you want anything even approaching near certainty, I'd expect to see
some actual code and benchmark measurements.

P.S. Sorry for the somewhat vehement reply. I happen to have seen far
too many cases of people selling neural nets as the solution to all the
world's problems. I regard this as unfortunate because, among other
things, the oversell gives neural nets a bad name. I recognize that they
do happen to be really good ideas for some things, but the hype makes it
hard to sell the actual useful applications as being different from the
hyped ones.

--
Richard Maine                     | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov            |       -- Mark Twain



Sat, 26 Jul 2008 00:19:25 GMT  
 2 formatting questions

Quote:
>>How do I left justify the following?
>>Character:: charac5*5
>>charac5 = 'abcde'
>>write (1,'(a80)') charac5
>>'abcde' then gets printed on columns 76-80 instead of 1-5. I know the
>>easy solution is to just do write (1,'(a5)') charac5 but I would like
>>to know how to force left justification here.
>You just did it.
>What's the problem with '(a)' ?

Assuming the question-asker REALLY (for unstated reasons) wants to use
"a80", I can think of several solutions; the simplist (quick and dirty)
would just add the following to his code:
   CHARACTER:: Spaces80*80
   Spaces80 = ' '
   WRITE (1,'(a80)') charac5 // Spaces80

--
--Myron A. Calhoun.
Five boxes preserve our freedoms:  soap, ballot, witness, jury, and cartridge
PhD EE (retired).   "Barbershop" tenor.   CDL(PTXS).  W0PBV.   (785) 539-4448
NRA Life Member and Certified Instructor (Home Firearm Safety, Rifle, Pistol)



Sat, 26 Jul 2008 03:37:23 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. format question and function question

2. Locale and date format question

3. Simple formatting question?

4. Simple formatting question?

5. pb/cc 2.11 FORMAT$ question / suggestion

6. Field Format Question?

7. Report Formatting Questions

8. Formatting Question

9. String Formatting Question

10. Date Format Question

11. Internal File Format Question

12. PUT DATA format question

 

 
Powered by phpBB® Forum Software