For Programmers: Free Programming Magazines  


Home > Archive > Fortran > February 2005 > Backslash problem









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 Backslash problem
Dieter Britz

2005-02-16, 9:01 am

I wrote a program to help me draw curves in Latex, and I got it
to write out, into a file that I insert into the LaTeX file,
some drawing commands. These include the usual backslashes \
but Fortran refuses to output them, telling me that it is a
nonstandard character.

Is there a way to convince it to write them out? It is a bit
tedious to hand-insert them afterwards.

--
Dieter Britz, Kemisk Institut, Aarhus Universitet, Danmark.

Dieter Britz

2005-02-16, 9:01 am

Dieter Britz wrote:
> I wrote a program to help me draw curves in Latex, and I got it
> to write out, into a file that I insert into the LaTeX file,
> some drawing commands. These include the usual backslashes \
> but Fortran refuses to output them, telling me that it is a
> nonstandard character.
>
> Is there a way to convince it to write them out? It is a bit
> tedious to hand-insert them afterwards.
>


Sorry, I forgot to mention that I use the Intel Fortran 90/95 compiler.

--
Dieter Britz, Kemisk Institut, Aarhus Universitet, Danmark.

Harald Anlauf

2005-02-16, 9:01 am

Dieter Britz <britz@chem.au.dk> writes:

> These include the usual backslashes \
> but Fortran refuses to output them, telling me that it is a
> nonstandard character.


Backslashes are often considered escape characters on U*ix systems.
Just double it:

print *, "This is a backslash: '\'"
end

Works for me (tm).

> Is there a way to convince it to write them out? It is a bit
> tedious to hand-insert them afterwards.


Which compiler version of the Intel compilers did you use? And did you
try the "-nbs" option? (See ifc -help for v7.1, ifort -help for v8.1).

--
Cheers,
-ha
Arjen Markus

2005-02-16, 4:01 pm

Harald Anlauf wrote:
>
> Dieter Britz <britz@chem.au.dk> writes:
>
>
> Backslashes are often considered escape characters on U*ix systems.
> Just double it:
>
> print *, "This is a backslash: '\'"
> end
>
> Works for me (tm).
>
>
> Which compiler version of the Intel compilers did you use? And did you
> try the "-nbs" option? (See ifc -help for v7.1, ifort -help for v8.1).
>
> --
> Cheers,
> -ha


Not even that seems necessary:

program bslash
write(*,*) '\Boe'
end program

gives:
\Boe

as output ...

This is with Intel Fortran 8.0

Mind showing a piece of the code that is rejected?

Regards,

Arjen
Dieter Britz

2005-02-16, 4:01 pm

Arjen Markus wrote:
> Harald Anlauf wrote:
>
>
>
> Not even that seems necessary:
>
> program bslash
> write(*,*) '\Boe'
> end program
>
> gives:
> \Boe
>
> as output ...
>
> This is with Intel Fortran 8.0
>
> Mind showing a piece of the code that is rejected?


I have this loop:

do i = 1, N
x = arrx(i); y = a(0) + a(1)*x + a(2)*x**2 + a(3)*x**3
write(4,'("\put(", f6.2, ",10){\line(0,1){", f5.2, "}} ", &
& "\put(", f6.2, ",", f5.2, "){\circle*1{1}}")') &
x, y-10, x, y
enddo

I have a compiler version less recent than yours (I don't update
if I don't see a problem). The suggestion of using the -nbs option
made by the other responder did the trick, however.

Thanks!
--
Dieter Britz, Kemisk Institut, Aarhus Universitet, Danmark.

John Harper

2005-02-26, 3:58 am

In article <cuv80s$vt6$1@news.net.uni-c.dk>,
Dieter Britz <britz@chem.au.dk> wrote:
>I wrote a program to help me draw curves in Latex, and I got it
>to write out, into a file that I insert into the LaTeX file,
>some drawing commands. These include the usual backslashes \
>but Fortran refuses to output them, telling me that it is a
>nonstandard character.


Some systems treat \ as an escape character, others don't.
You can write Fortran that works in both kinds thus:

CHARACTER :: foobar*7, backsl*1='\'
...
foobar = 'bar'//backsl//'foo'
PRINT*, foobar

which prints bar\foo

John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045
mcalhoun@ksu.edu

2005-02-27, 4:00 pm

>>[Post regarding missing backslashes]
>Some systems treat \ as an escape character, others don't.
>You can write Fortran that works in both kinds thus:
> CHARACTER :: ... backsl*1='\'

.....[snip]....

That *1 is one "neat" solution!

Thanks for posting it.

--
--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)
Sponsored Links







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

Copyright 2008 codecomments.com