[ncl-talk] Save in netcdf

Soma Roy somaroy892 at gmail.com
Tue Jul 17 11:05:54 MDT 2018


It again shows the following error message;

fatal:Variable (lev) is undefined
fatal:["Execute.c":8640]:Execute: Error occurred at or near line 44 in file
TEST1.ncl

'latitude', 'longitude', 'level' and 'time' are named as variable's
dimensions in input file which is very clear from printVarSummary of the
data. I modified the code as per your hints. Modified code is attached
below. Kindly inform me where I am doing wrong again.


Thanks,
Soma

On Tue, Jul 17, 2018 at 10:09 PM, Karin Meier-Fleischer <
meier-fleischer at dkrz.de> wrote:

> Hi Soma,
>
> please, reply always to ncl-talk that everybody is able to follow.
>
> The problem is, that you changed the name of the level dimension to lev.
> ZMT has the dimension name level. Change lev to level and it should work or
>
> ZMT!1    = "lev"
> ZMT&lev = lev
>
> -Karin
>
> Am 17.07.18 um 14:06 schrieb Soma Roy:
>
> In the directory there is no file named as example.nc.
> It is created at the run time.
>
> Now I am getting the following error massage;
>
> FileAddVar, in file: NclFile.c, line: 412
> fatal:FileAddVar: Dimension (level) is not currently defined, can't add
> variable
> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 77 in
> file TEST1.ncl
>
> Kindly inform me what I am doing wrong in this.
>
> Thanking you,
> Soma
>
>
> On Tue, Jul 17, 2018, 16:31 Karin Meier-Fleischer <meier-fleischer at dkrz.de>
> wrote:
>
>> Hi Soma,
>>
>> if the file example.nc already exists NCL can't create a new one with
>> the same name. You have to remove the file, first.
>>
>>     filo = "example.nc"                    ; Output file
>> *    system("rm -rf "+filo)*
>>     fout  = addfile (filo, "c")            ; open output file
>>
>> -Karin
>>
>> Am 17.07.18 um 12:22 schrieb Soma Roy:
>>
>> I am trying to save the variable ZMT in NetCDF file following the
>> instructions at the below-mentioned link;
>>
>> http://www.ncl.ucar.edu/Applications/method_2.shtml
>>
>> Summary of the dataset is as follows;
>>
>> Variable: lat
>> Type: float
>> Total Size: 244 bytes
>>             61 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [latitude | 61]
>> Coordinates:
>>             latitude: [ 5..20]
>> Number Of Attributes: 2
>>   units :       degrees_north
>>   long_name :   latitude
>>
>> Variable: lon
>> Type: float
>> Total Size: 324 bytes
>>             81 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [longitude | 81]
>> Coordinates:
>>             longitude: [70..90]
>> Number Of Attributes: 2
>>   units :       degrees_east
>>   long_name :   longitude
>>
>> Variable: time
>> Type: integer
>> Total Size: 16 bytes
>>             4 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [time | 4]
>> Coordinates:
>>             time: [1025088..1025160]
>> Number Of Attributes: 3
>>   units :       hours since 1900-01-01 00:00:0.0
>>   long_name :   time
>>   calendar :    gregorian
>>
>>
>> Variable: pnew
>> Type: integer
>> Total Size: 112 bytes
>>             28 values
>> Number of Dimensions: 1
>> Dimensions and sizes:   [level | 28]
>> Coordinates:
>>             level: [70..1000]
>> Number Of Attributes: 2
>>   units :       Pa
>>   long_name :   pressure_level
>> (0)     7000
>> (1)     10000
>> (2)     12500
>> (3)     15000
>> ..........
>> (26)    97500
>> (27)    100000
>>
>> Variable: ZMT
>> Type: float
>> Total Size: 2213568 bytes
>>             553392 values
>> Number of Dimensions: 4
>> Dimensions and sizes:   [time | 4] x [level | 28] x [latitude | 61] x
>> [longitude | 81]
>> Coordinates:
>>             time: [1025088..1025160]
>>             level: [70..1000]
>>             latitude: [ 5..20]
>>             longitude: [70..90]
>> Number Of Attributes: 3
>>   units :       (m/s)(kg/kg)
>>   long_name :   zonal moisture transport
>>   _FillValue :  -32767
>>
>> At run-time, I am getting the following error message;
>>
>> fatal:Could not create (example.nc)
>> warning:FileSetFileOption: invalid file or format
>> fatal:["Execute.c":8640]:Execute: Error occurred at or near line 65 in
>> file TEST1.ncl
>>
>> My script is attached below.
>>
>> Please kindly inform me what is wrong with this code and how to fix it.
>>
>> Thanking you,
>> Soma
>>
>>
>> _______________________________________________
>> ncl-talk mailing listncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>> _______________________________________________
>> 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/20180717/b4289f23/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TEST1.ncl
Type: application/octet-stream
Size: 5053 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180717/b4289f23/attachment.obj>


More information about the ncl-talk mailing list