Re: How to quote the " character in a format statement?
- From: Mirko.Vukovic@xxxxxxxxx
- Date: Thu, 31 Jan 2008 06:27:09 -0800 (PST)
On Jan 30, 6:10 pm, ka...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx (Steven G.
Kargl) wrote:
In article <c706bb0b-6fc4-409f-b487-8519cf232...@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Mirko.Vuko...@xxxxxxxxx writes:
Hi,
This is a follow-up on my previous post, as it relates to generating
valid TecPlot files.
Given a vector of strings, I need to print out a string of the
following form (with the quote characters in it).
"string1" "string2" "string3"
I was trying along the lines of
"4('magic'A5'magic')"
but I could not quite figure out what the magic would be.
My other alternative is to modify the string's by prepending and
appending the quotes.
Any other opinions?
character(len=5) :: s = 'abcde'
write(*,'(A)') '"' // trim(s) // '"'
write(*,1) trim(s)
1 format('"',A,'"')
end
--
Stevehttp://troutmask.apl.washington.edu/~kargl/
Thank you to both.
Since the number of repeats is not determined at compile time, I ended
up building up the format string in a loop:
character(len=500)::sFormatVar
....
sFormatVar="('Variables= "
add_var_names: do iProf=1,cProfs
sFormatVar=trim(sFormatVar)//' "'//trim(vsProfs(iProf))//'"'
end do add_var_names
sFormatVar=trim(sFormatVar)//"')"
write (self%lu,sFormatVar)
I am sure this can be compacted, but my limited fortran knowledge,
small comfort zone, and time constraints limit further optimization at
this point.
Thanks again,
Mirko
.
- References:
- How to quote the " character in a format statement?
- From: Mirko . Vukovic
- Re: How to quote the " character in a format statement?
- From: Steven G. Kargl
- How to quote the " character in a format statement?
- Prev by Date: Re: computing Bernoulli numbers
- Next by Date: Re: Did anyone manage to get MATRAN compiled with g95?
- Previous by thread: Re: How to quote the " character in a format statement?
- Next by thread: Automatically transform or expand do loop in a subroutine
- Index(es):