For Programmers: Free Programming Magazines  


Home > Archive > Fortran > January 2006 > Test for Control M in Fortran?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Test for Control M in Fortran?
stocksami@earthlink.net

2006-01-23, 7:04 pm

My unix program sometimes gets input files from the PC world that have
those evil control M characters. Is there an easy way to test for that
from within Fortran?

thanks

Erik Edelmann

2006-01-23, 7:04 pm

On 2006-01-23, stocksami@earthlink.net <stocksami@earthlink.net> wrote:
> My unix program sometimes gets input files from the PC world that have
> those evil control M characters. Is there an easy way to test for that
> from within Fortran?


I haven't tested this, but one possibility that comes to mind is to check
if iachar(character_variable) == 13 (the ASCII code of control-M is 13).

Another possibility is to remove the evil control-M:s from the file before
you feed your file to the fortran program. This can be done e.g. using the
command

tr -d '\015' < orig-file > new-file



Erik
Colin Watters

2006-01-23, 7:04 pm

How about


character*80 line
stocksami@earthlink.net

2006-01-23, 9:56 pm

The function iachar looks good. I'll give it a try.

Some of the input files are humungous, that's a technical term, so I
hate to add any unncessary processing.

Thanks,

Clark

stocksami@earthlink.net

2006-01-23, 9:56 pm

iachar did the job

thanks!!

Michel OLAGNON

2006-01-24, 3:57 am

stocksami@earthlink.net wrote:
> My unix program sometimes gets input files from the PC world that have
> those evil control M characters. Is there an easy way to test for that
> from within Fortran?
>


IIRC, ('^M' == ACHAR(13))

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com