[ncl-talk] 答复: How to print zero before the decimal point with "write_matrix" function
Dave Allured - NOAA Affiliate
dave.allured at noaa.gov
Mon Sep 16 20:51:35 MDT 2019
Jianghua,
The write_matrix procedure actually calls fortran to make formatted lines
of text. Therefore the zero before the decimal point depends on which
fortran compiler is actually linked to your installed version of NCL.
Fortran standards say that the zero before the decimal point is
"optional". I think this is unfortunate because this choice has been made
both ways, resulting in this inconsistent behavior between compilers. Some
programmers, including me, would like to control this behavior precisely.
It would be interesting to find out which fortran compiler and version is
linked with NCL on your IBM_AIX machine, if you would like to look into
this. Perhaps just ask your computer support department.
On Thu, Sep 12, 2019 at 4:34 AM Wan Jianghua via ncl-talk <ncl-talk at ucar.edu>
wrote:
> Hi Karin,
>
> Thank you for your reply. I tried several versions of ncl (6.1.2, 6.2.0,
> 6.3.0). They all got the same results.
>
> But I run the same script on other two Linux machines with ncl V6.1.2 and
> V6.2.0, and the zero appear.
>
> I guess the problem might be related to the IBM_AIX machine I was using.
>
>
>
> Best,
>
> Jianghua
>
>
>
> Karin Meier-Fleischer via ncl-talk
> *发送时间:* 2019年9月12日 17:30
>
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190916/629b7bb5/attachment.html>
More information about the ncl-talk
mailing list