Re: [netcdfgroup] Multiple-line attributes

Thanks, Larry,

That's better:

                :experimental3 = "LineOne\n",
                        "LineTwo." ;

It'd be nice to lose the '\n' though. As there isn't one in the input string, 
just the char(10) equivalent..

Cheers

Harry

On 28 Oct 2010, at 16:33, Larry D. Oolman wrote:

> The \n is the method for embedding a new line in 'C'.
> To do it in FORTRAN, you will need to do something like:
> 
> status = nf_put_att_text(ncid,nf_global,'experimental3',16,"LineOne" // 
> char(10) // "LineTwo.")
> 
> Ian Harris wrote:
>> Hi,
>> 
>> Firstly, apologies if this list isn't the closest match to my problem - I 
>> can't see one closer!
>> 
>> I'm writing NetCDF files from F77, all working nicely.. until I try to write 
>> text attributes with multiple lines.
>> 
>> As far as I can discover, I'm supposed to embed '\n' terminators in the 
>> strings, which makes sense to me. UCAR's NetCDF information includes:
>> 
>> <QUOTE>
>> The usual escape conventions for C strings are honored. For example:
>> 
>>     "a"            // ASCII 'a'
>>     "Two\nlines\n" // a 10-character string with two embedded newlines
>>     "a bell:\007"  // a string containing an ASCII bell
>>     "ab","cde"     // the same as "abcde"
>> </QUOTE>
>> 
>> (From http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html - I'm 
>> currently running NetCDF 3.6.3 according to ncdump)
>> 
>> However, when I try this, it doesn't seem to work. The library seems to add 
>> a second backslash. For example:
>> 
>> I run:
>> 
>> status = 
>> nf_put_att_text(ncid,nf_global,'experimental3',16,"LineOne\nLineTwo.")
>> 
>> ncdump -h on the result:
>> 
>>              :experimental3 = "LineOne\\nLineTwo" ;
>> 
>> I note that the full stop is missing from the end, implying to me that the 
>> '\n' has been counted as a single character, but the extra '\' has exhausted 
>> the character count (16) before the end.
>> 
>> Is this expected behaviour? If so, is there any way for me to produce 
>> multi-line attribute values?
>> 
>> Cheers
>> 
>> Harry
>> Ian "Harry" Harris
>> Climatic Research Unit
>> School of Environmental Sciences
>> University of East Anglia
>> Norwich NR4 7TJ
>> United Kingdom
>> 
>> IMPORTANT NOTICE - This email is intended for the named recipient only. It 
>> may contain privileged and confidential information. If you are not the 
>> intended recipient, notify the sender immediately and destroy this email. 
>> You must not copy, distribute or take action in reliance upon it. Whilst all 
>> efforts are made to safeguard emails, The School of Environmental Sciences 
>> cannot guarantee that attachments are virus free or compatible with your 
>> systems and does not accept liability in respect of viruses or computer 
>> problems experienced.
>> 
>> 
>> 
>> _______________________________________________
>> netcdfgroup mailing list
>> netcdfgroup@xxxxxxxxxxxxxxxx
>> For list information or to unsubscribe,  visit: 
>> http://www.unidata.ucar.edu/mailing_lists/ 
> 
> 
> -- 
> Larry Oolman
> Department of Atmospheric Science
> University of Wyoming
> Dept. 3038, 1000 E. University Ave.
> Laramie, WY 82071
> ldoolman@xxxxxxxx
> http://www-das.uwyo.edu

Ian "Harry" Harris
Climatic Research Unit
School of Environmental Sciences
University of East Anglia
Norwich NR4 7TJ
United Kingdom

IMPORTANT NOTICE - This email is intended for the named recipient only. It may 
contain privileged and confidential information. If you are not the intended 
recipient, notify the sender immediately and destroy this email. You must not 
copy, distribute or take action in reliance upon it. Whilst all efforts are 
made to safeguard emails, The School of Environmental Sciences cannot guarantee 
that attachments are virus free or compatible with your systems and does not 
accept liability in respect of viruses or computer problems experienced.





  • 2010 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: