RE: [ncl-talk] Writing ascii data with NCL

From: O'Neill, Susan - Portland, OR <susan.oneill_at_nyahnyahspammersnyahnyah>
Date: Tue, 17 Apr 2007 15:24:06 -0600

Hi Mary,

Thank you for getting back to Jacob and I, and Jacob it was good to know
someone else had my same question!

Actually, using the system & echo commands is exactly what I am doing
currently because I am creating over 300 ascii files. WRAPIT looks
interesting so I will investigate, thank you!

        Susan

-----Original Message-----
From: Mary Haley [mailto:haley_at_ucar.edu]
Sent: Tuesday, April 17, 2007 2:16 PM
To: Jacob.Klee_at_dom.com
Cc: O'Neill, Susan - Portland, OR; ncl-talk_at_ucar.edu
Subject: Re: Writing ascii data with NCL

Jacob and Susan,

Unfortunately, none of NCL's ascii writing functions allow to
do an "append" kind of thing. You have to read the whole thing
in first.

There are a couple of work-arounds, depending on the complexity of
what you are writing to the file. If your output is fairly simple,
then you might consider using an NCL "system" call to cat
(i.e. append) that new line to the end of the file. A simple example:
Assume you have a "file.txt" with the three lines of text "one", "two",
and "three", and that you want to append "four":

   data_to_append = "four"
   filename = "file.txt"
   system("echo " + data_to_append + ">>" + filename)

If your data is more complex, then you may need to consider the more
difficult route of creating a Fortran subroutine that opens your file
and writes the data, and then use WRAPIT to allow you to interface to
this subroutine via NCL. There are some examples of using WRAPIT at:

   http://www.ncl.ucar.edu/Document/Tools/WRAPIT.shtml

Good luck,

--Mary

On Tue, 17 Apr 2007 Jacob.Klee_at_dom.com wrote:

> Susan (and all),
>
> Thank you for your email, as I literally I was about to sit down and
email
> essentially the same question and problem. As such though I'm not
able to
> offer much help.
>
> So far the only (albeit far less than ideal) solution I have is to
print to
> the screen what I want and pipe the results to a log file, then using
a
> text editor clean up the resulting ASCII file.
>
> I would similarly welcome any advice / tips.
>
> -- Jacob Klee
>
>
>
>
>
> "O'Neill, Susan -
> Portland, OR"
> <susan.oneill_at_por
To
> .usda.gov> <ncl-talk_at_ucar.edu>
> Sent by:
cc
> ncl-talk-bounces@
> ucar.edu
Subject
> [ncl-talk] Writing ascii data
with
> NCL
> 04/17/2007 12:46
> PM
>
>
>
>
>
>
>
>
> Hi Everyone,
>
> I am new to NCL and the ncl-talk list and have a question that I am
> hoping is easy to answer.
>
> Do you know if NCL can write to an ascii file in append mode? I would
> like to loop through various hours of NARR files outputting a single
> line to an ascii file with each hour. The asciiwrite function seems
to
> only do a single dump, so I have to load all the data in one big
array.
> The problem I'm running into is that that array is becoming HUGE and
my
> memory is using swap which is drastically reducing my runtime ... It
> would be nice just to output the data every hr instead. Do you know
if
> that's possible?
>
> Any insights/tips would be much appreciated, thank you!
>
> Susan
>
>
> --------------------------------------------
> Susan M. O'Neill, Ph.D.
> Air Quality Engineer
> USDA Natural Resources Conservation Service
> Air Quality and Atmospheric Change Team
> 1201 NE Lloyd Blvd., Suite 1000
> Portland, Oregon 97232-1202
> 503-273-2438 (work)
> 503-273-2401 (fax)
> susan.oneill_at_por.usda.gov
> --------------------------------------------
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> -----------------------------------------
> CONFIDENTIALITY NOTICE: This electronic message contains
> information which may be legally confidential and/or privileged and
> does not in any case represent a firm ENERGY COMMODITY bid or offer
> relating thereto which binds the sender without an additional
> express written confirmation to that effect. The information is
> intended solely for the individual or entity named above and access
> by anyone else is unauthorized. If you are not the intended
> recipient, any disclosure, copying, distribution, or use of the
> contents of this information is prohibited and may be unlawful. If
> you have received this electronic transmission in error, please
> reply immediately to the sender that you have received the message
> in error, and delete it. Thank you.
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
Received on Tue Apr 17 2007 - 15:24:06 MDT

This archive was generated by hypermail 2.2.0 : Sat Apr 21 2007 - 12:15:57 MDT