How to continue a string to the next line? How to continue a string to the next line? Author | Message | | How to continue a string to the next line? I have an output statement for debugging that shows the formula used and then the numbers in the formula. The formula is a string and because of indention sometimes needs to be continued on the next line. To continue a string, do you: a) terminate the first line with a ', use a continuation character and begin the rest of the string with a ' like: WRITE (75,*) 'AK2=4.*RC*R(J)/((RC+R(J))**2+(ZT-ZC(N))**2) ' + ': ',AK2,'=4.*', RC,'*',R(J),'/((',RC+R(J),')**2+(',ZT, + '-',ZC(N),')**2), N=',N b) put a comma after the first ' in the sample above to make two consecutive strings? c) do nothing and the first non-space after the continuation character will be the remainder of the string? I can't find any help on this anywhere! Thanks in advance, Shelli --== Sent via Deja.com http://www.*-*-*.com/ ---Share what you know. Learn what you don't.--- | Wed, 18 Jun 1902 08:00:00 GMT | | | Jerry A Gree #2 / 6 | How to continue a string to the next line? Quote: > I have an output statement for debugging that shows the formula used > and then the numbers in the formula. The formula is a string and > because of indention sometimes needs to be continued on the next line. > To continue a string, do you: > a) terminate the first line with a ', use a continuation character and > begin the rest of the string with a ' like: > WRITE (75,*) 'AK2=4.*RC*R(J)/((RC+R(J))**2+(ZT-ZC(N))**2) ' > + ': ',AK2,'=4.*', RC,'*',R(J),'/((',RC+R(J),')**2+(',ZT, > + '-',ZC(N),')**2), N=',N > b) put a comma after the first ' in the sample above to make two > consecutive strings? > c) do nothing and the first non-space after the continuation character > will be the remainder of the string? > I can't find any help on this anywhere! > Thanks in advance, > Shelli > --== Sent via Deja.com http://www.deja.com/ ==-- > ---Share what you know. Learn what you don't.--- Hello Shelli: Put a comma after the break. Note that if you are using an F77 compiler that List Directed output of Character Data is an extension to the F77 Standard. WRITE (75,*) 'AK2=4.*RC*R(J)/((RC+R(J))**2+(ZT-ZC(N))**2) ', <-- comma here + ': ',AK2,'=4.*', RC,'*',R(J),'/((',RC+R(J),')**2+(',ZT, + '-',ZC(N),')**2), N=',N An alternative, which is Standard F77, but that not all F77 compilers support correctly is to use the append operator which concatenates the two strings into one: WRITE (75,*) 'AK2=4.*RC*R(J)/((RC+R(J))**2+(ZT-ZC(N))**2) '// <-- append operator + ': ',AK2,'=4.*', RC,'*',R(J),'/((',RC+R(J),')**2+(',ZT, + '-',ZC(N),')**2), N=',N Jerry . . . -- Custom Solutions http://www.cs-software.com/ 209 Bayberry Run Summerville, SC 29485-8778 Your source for discounted Voice: (843) 871 9081 fortran compilers and Fax: (843) 873 8626 related software | Wed, 18 Jun 1902 08:00:00 GMT | | | Richard Main #3 / 6 | How to continue a string to the next line? Quote: > I have an output statement for debugging that shows the formula used > and then the numbers in the formula. The formula is a string and > because of indention sometimes needs to be continued on the next line. > To continue a string, do you: Real simillar to another recently asked question, although that one was more about f90 free source form. Quote: > a) terminate the first line with a ', use a continuation character and > begin the rest of the string with a ' like: > WRITE (75,*) 'AK2=4.*RC*R(J)/((RC+R(J))**2+(ZT-ZC(N))**2) ' > + ': ',AK2,'=4.*', RC,'*',R(J),'/((',RC+R(J),')**2+(',ZT, > + '-',ZC(N),')**2), N=',N Nope. Won't work. The line continuation isn't at issue here. That would be just like writing the 2 strings on the same line, with no punctuation other than blanks between them. I.E. like write (*,*) 'Some stuff' ' and some more stuff' which isn't legal. Quote: > b) put a comma after the first ' in the sample above to make two > consecutive strings? That will work. It is 2 separate strings, which can matter in some contexts. Probably doesn't matter in this case. In cases where it does matter, you can use a concatenation operator to combine the two strings into one, as in write (*,*) 'Some stuff' // + ' and some more stuff' (Doesn't matter whether the concatenation operator is at the end of the first line or beginning of the second - whichever style seems better to you). Quote: > c) do nothing and the first non-space after the continuation character > will be the remainder of the string? This sometimes works, but there are subtleties that make it vary from system to system. The main issue here involves determing where the first line ends and thus how many blanks end up in the middle of your string. Are all lines implicitly padded to exactly 72 columns? Does the line end at the last explicitly typed blank? Are all trailing blanks implicitly ignored? Something else. I recommend avoiding this, even if it appears to work like you need on your current compiler. There are too many portability issues with it. Including such "amusing" things as finding that your source files don't work any more after you have used some editors or copied them to another machine via some methods (because trailing blanks got deleted). -- Richard Maine | Wed, 18 Jun 1902 08:00:00 GMT | | | Richard Main #4 / 6 | How to continue a string to the next line? Quote: > Put a comma after the break. Note that if you are using an F77 compiler > that List Directed output of Character Data is an extension to the F77 > Standard. Eh? The only thing I can think of that you might be referring to is that in standard f77 the data for list-directed character input must be enclosed in quotes. Some vendors (and the f90 standard) allow the quotes to be omitted in simple cases where it makes sense. But this has nothing to do with list-directed output. And even for input, its not that list-directed character input is illegal - rather that its requirements are inconvenient and not what many applications would want. Quote: > An alternative, which is Standard F77, but that not all F77 compilers > support correctly is to use the append operator which concatenates the > two strings into one: You have run into an f77 compiler that doesn't support concatenation? I suppose I might once have seen such a beast maybe 15-20 years ago (when the first few f77 compilers came out and some perhaps didn't really support the full language). I guess I heard once (but never used) an f77 compiler that conformed only to the f77 subset instead of the full language. Whatever it was, it was either something really obscure or a figment of my imagination. (And an f77 subset compiler would be missing an awful lot more than just this). I'd be interested in knowing what f77 compiler of any practical current interest doesn't support concatenation correctly. I'm not referring to the tricky non-standard cases involving concatenation of character*(*) things. Yes, there are some compilers that are more liberal than the standard, and other compilers that won't accept the same extensions. I'm asking about standard-conforming concatenation. Indeed, the case here is the simplest form of concatenation - two literal character strings - pretty hard to get that one wrong if the compiler has any pretext of supporting concatenation. I could more easily imagine compiler bugs in tricky cases. I can't imagine worrying about portability of this. I've certainly never had problems with it within the last 15 years or so. -- Richard Maine | Wed, 18 Jun 1902 08:00:00 GMT | | | Bob Well #5 / 6 | How to continue a string to the next line? Quote: > I suppose I might once have seen such a beast maybe 15-20 years ago > (when the first few f77 compilers came out and some perhaps didn't > really support the full language). I guess I heard once (but never > used) an f77 compiler that conformed only to the f77 subset instead > of the full language. Whatever it was, it was either something > really obscure or a figment of my imagination. (And an f77 subset > compiler would be missing an awful lot more than just this). DEC's FORTRAN for PDP11/23 under RSX11M+ was an f77 subset compiler. Certainly old and possibly obscure but definitely not a figment of my imagination. Working with this gave me an strong aversion to subset compilers which I still retain.. If I had charged all the users to whom I explained the existence of the ANSI-approved subset and for whom I translated their full-standard programs I would not now be reading c.l.f.. | Wed, 18 Jun 1902 08:00:00 GMT | | | Ron Shepa #6 / 6 | How to continue a string to the next line? Quote: >> Put a comma after the break. Note that if you are using an F77 compiler >> that List Directed output of Character Data is an extension to the F77 >> Standard. >Eh? The only thing I can think of that you might be referring to is >that in standard f77 the data for list-directed character input must >be enclosed in quotes. Some vendors (and the f90 standard) allow >the quotes to be omitted in simple cases where it makes sense. But >this has nothing to do with list-directed output. And even for >input, its not that list-directed character input is illegal - rather >that its requirements are inconvenient and not what many applications >would want. Standard f77 did not allow list-directed internal I/O of any kind, character data or otherwise. Perhaps some memory wires got crossed and the original poster thought that restriction applied to this situation? BTW, this is legal now since f90. Another possibility is that the spacing before and after character data in list-directed I/O was not defined in f77. This means that simple text comparisons of output from different machines that used this could be different, but still correct. Of course, spacings were not defined for numeric data either, but I think most people expected those differences. $.02 -Ron Shepard | Wed, 18 Jun 1902 08:00:00 GMT | | | Powered by phpBB® Forum Software |
0 Response to "How to Continue Long Equation in Fortran"
Post a Comment