[ncl-talk] How to print zero before the decimal point with "write_matrix" function

Karin Meier-Fleischer meier-fleischer at dkrz.de
Thu Sep 12 03:30:04 MDT 2019


Hi Jianghua,

which NCL version are you running? Using version 6.6.2 works quite well:

 > ncl
  Copyright (C) 1995-2019 - All Rights Reserved
  University Corporation for Atmospheric Research
  NCAR Command Language Version 6.6.2
  The use of this software is governed by a License Agreement.
  See http://www.ncl.ucar.edu/ for more details.
ncl 0> a=new((/2,2/),float,-999.)
ncl 1> a=0.1
ncl 2> a(0,0)=-0.1
ncl 3> write_matrix(a,"2f5.2",True)

-0.10 0.10
  0.10 0.10

ncl 4> quit

-Karin

Am 12.09.19 um 10:32 schrieb Wan Jianghua via ncl-talk:
>
> Hi all,
>
> I try to print a nicely formatted text file with “write_matrix” 
> function, but the result is not satisfactory.
>
> When the absolute value of the number is less than 1, the zero before 
> the decimal point is omitted. Is there any possible way to print it 
> out? Thanks!
>
> My test script:
>
> a=new((/2,2/),float,-999.)
>
> a=0.1
>
> a(0,0)=-0.1
>
> write_matrix(a,"2f5.2",True)
>
> the result:
>
> -.10   .10
>
> .10   .10
>
> Sincerely,
>
> Jianghua
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190912/6dfc5e8e/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 2833 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190912/6dfc5e8e/attachment.png>


More information about the ncl-talk mailing list