Is it possible to skip the WRITE'ing of an item in an output list by
modifying the FORMAT? For example, to print elements [1,2,4] of array
ivec(1:4) I can just write
write (*,"(100i6)") ivec((/1,2,4/))
but I would like to do it as
write (*,fmt_skip) ivec
where fmt_skip tells the compiler to skip printing ivec(3). I want to
be able to change the output of a program by changing the format
string, which can be read from a text file, rather than changing the
source code. It would be nice if something like
write (*,"(2i6,-,100i6)") ivec
worked, where the '-' indicates that one item is to be skipped.
The real goal to print arrays of times (stored as a derived type with
integer components hour, minute, second), easily switching between
printing or not printing seconds. I would like to get output of
12:10:00 12:20:00 12:30:00
OR
12:10 12:20 12:30
with the decision made at run time. I know it is possible using IF
statements.
|
|
0
|
|
|
|
Reply
|
beliavsky (2207)
|
12/8/2004 4:45:49 PM |
|
In article <1102524349.769695.131020@c13g2000cwb.googlegroups.com>,
beliavsky@aol.com writes:
> Is it possible to skip the WRITE'ing of an item in an output list by
> modifying the FORMAT? For example, to print elements [1,2,4] of array
> ivec(1:4) I can just write
>
> write (*,"(100i6)") ivec((/1,2,4/))
>
> but I would like to do it as
>
> write (*,fmt_skip) ivec
>
> where fmt_skip tells the compiler to skip printing ivec(3). I want to
> be able to change the output of a program by changing the format
> string, which can be read from a text file, rather than changing the
> source code. It would be nice if something like
The FORMAT can be a character variable, which of course you can read
from a text file. Or am I missing something?
|
|
0
|
|
|
|
Reply
|
helbig (4874)
|
12/8/2004 6:45:48 PM
|
|
helbig@astro.multiCLOTHESvax.de (Phillip Helbig---remove CLOTHES to reply)
wrote:
>In article <1102524349.769695.131020@c13g2000cwb.googlegroups.com>,
>beliavsky@aol.com writes:
>
>> Is it possible to skip the WRITE'ing of an item in an output list by
>> modifying the FORMAT? For example, to print elements [1,2,4] of array
>> ivec(1:4) I can just write
>>
>> write (*,"(100i6)") ivec((/1,2,4/))
>>
>> but I would like to do it as
>>
>> write (*,fmt_skip) ivec
>>
>> where fmt_skip tells the compiler to skip printing ivec(3). I want to
>> be able to change the output of a program by changing the format
>> string, which can be read from a text file, rather than changing the
>> source code. It would be nice if something like
>
>The FORMAT can be a character variable, which of course you can read
>from a text file. Or am I missing something?
>
I was asking what FORMAT to use to skip element 3. I have since devised an
inelegant solution that overwrites the 2nd element with the 3rd (note the
repeated use of t6):
write (*,"(t2,i4,t6,i4,t6,i4,t10,i4)") ivec
I still wonder if there is a better way -- my code would look like a bug
to the reader.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
|
|
0
|
|
|
|
Reply
|
beliavsky (2207)
|
12/8/2004 7:01:16 PM
|
|
beliavsky@aol.com wrote:
> helbig@astro.multiCLOTHESvax.de (Phillip Helbig---remove CLOTHES to reply)
> wrote:
>
>>In article <1102524349.769695.131020@c13g2000cwb.googlegroups.com>,
>>beliavsky@aol.com writes:
>>
>>
>>>Is it possible to skip the WRITE'ing of an item in an output list by
>>>modifying the FORMAT? For example, to print elements [1,2,4] of array
>>>ivec(1:4) I can just write
>>>
>>>write (*,"(100i6)") ivec((/1,2,4/))
>>>
>>>but I would like to do it as
>>>
>>>write (*,fmt_skip) ivec
>>>
>>>where fmt_skip tells the compiler to skip printing ivec(3). I want to
>>>be able to change the output of a program by changing the format
>>>string, which can be read from a text file, rather than changing the
>>>source code. It would be nice if something like
Have you tried writing the whole list to a character
variable and then using a vector substript to only actually
output the parts you want? You'd need to EQUIVALENCE
an array and a string to use the VVS. Or maybe write
the list to an array of character(len=3 or so) elements and
only print selected elements.
>>
>>The FORMAT can be a character variable, which of course you can read
>
>>from a text file. Or am I missing something?
>
>
> I was asking what FORMAT to use to skip element 3. I have since devised an
> inelegant solution that overwrites the 2nd element with the 3rd (note the
???Are sure that's inelegant? It was going to be my first
suggestion, so the odds are that it's quite elegant! ;)
> repeated use of t6):
>
> write (*,"(t2,i4,t6,i4,t6,i4,t10,i4)") ivec
>
> I still wonder if there is a better way -- my code would look like a bug
> to the reader.
>
Ah yes, but most Fortran codes have bugs, so they will
be surprised when this isn't ;(
Dick Hendrickson
>
>
> ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
> http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
> ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
|
|
0
|
|
|
|
Reply
|
dick.hendrickson (1286)
|
12/8/2004 8:33:03 PM
|
|
|
3 Replies
45 Views
(page loaded in 0.466 seconds)
Similiar Articles: Arena - Reading Formatted Input from File - comp.simulation ...... don't want to read it (i.e. want to skip it). The C format ... for reading the text (via Read-Write module), is giving errors (says invalid format). I also tried using %g ... Load CSV file ignoring 2 header lines - comp.soft-sys.matlab ...... of those examples to suit the specific format of ... the end - comp.soft-sys.matlab ..... and writing ... For example, you can use IGNORE 1 LINES to skip over an initial ... formatting a blank DVD on Solaris 10 (x86) - comp.unix.solaris ...... in the "This Computer" folder etc) . > > How do I change the DVD into something that can be written onto ?? Skip format, it's not needed/doable. Use cdrecord to write. Help needed: read 3-dimensional array from a MAT-file in Fortran ...A quick'n dirty solution is to skip the .mat format alltogether, and instead write the array to a text file from matla, that is read from fortran. Convert getFullYear to 2-digit format - comp.lang.javascript ...... demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items ... command while using proc sql to change the format ... If you're using ... value into 10 decimal digits ... about writing a ... How to print (write) an arraw in excel from Matlab in colors ...... export the array to Excel and then format it with Excel macro which may be started using ... Sheets; currentSheet = sheets.Item ... Michal, I have one doubt about writing ... Writing a outlook msg file using java - comp.lang.java.programmer ...... format specs - comp.mail.misc XML Public/Private Keys - comp.lang.java.security MSG / EML file ... for the EML Format or is ... write an EML ... [MS-OXMSG]: Outlook Item ... Random access to content of archived files without extraction ...Am I right here to learn from this, that bzip2 format is not ... along with the expected uncompressed size s), write the s byte of uncompressed data. Or, to skip a block ... MC: 4th power with no small digits - comp.sys.hp48Mini-challenge: Write a User-RPL program that finds the ... Use programming tricks, and/or math tricks (e.g. number ... Now look at the command TEVAL. Input is an item to ... Skip or interrupt startup script - comp.databases.filemaker ...... Whoops.fp7 from the Show Hidden menu item ... does not skip the initial check, even if I use a more efficient ... Skip ... All I am new to *NIX and I am thinking of writing ... How to Use MLA Formatting | eHow.comHow to Use MLA Formatting. There are a number ... and be sure to begin each item on a new ... How to Use the MLA Works Cited Format. Writing a research paper of any kind is ... Purdue OWL: APA Formatting and Style Guide... of the APA manual, offers examples for the general format ... Skip Navigation ... Beginning with the next line, write a concise summary of ... 7/18/2012 10:23:41 AM
|