Why does ncl not find netcdf files?

1k Views Asked by At

I use ncl-ncarg 6.1.2-7 from Trusty under Ubuntu 14.04. I created a soft link from usr/share/ncarg to usr/lib and set the environment and path by:

export NCARG_ROOT="/usr"
export PATH=$NCARG_ROOT/bin:$PATH

I have a simple_plot_pr.ncl which create a panel plot from 3 netCDF files.

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"

begin
   ;-- read data and set variable references
       f1 = addfile ("home/robert/Dokumenty/climatological monthly mean pr_1971-2000.nc","r")
       f2 = addfile ("home/robert/Dokumenty/climatological monthly mean pr_2021-2050.nc","r")
       f3 = addfile ("home/robert/Dokumenty/climatological monthly mean pr_2071-2100.nc","r")

       pr1 = f1->pr
       pr2 = f2->pr
       pr3 = f3->pr
;-- open a PNG file
    wks = gsn_open_wks("png","panel_plot")
;-- create plot array
    plot = new(3,graphic)
;-- set resources for contour plots
    res = True
    res@gsnMaximize = True
    res@cnFillOn = True
    res@tiMainString = "Climatological mean monthly precipitation amount"
    gsn_define_colormap(wks,"rainbow")
    plot(0) = gsn_csm_colormap(wks,pr1(:,:),res)
    res@tiMainString = ""
    plot(1) = gsn_csm_colormap(wks,pr2(:,:),res)
    res@tiMainString = ""
    plot(3) = gsn_csm_colormap(wks,pr3(:,:),res)
    ;-- create panel plot
    gsn_panel(wks,plot,(/3,1/),False)
end

When I run this .ncl file I get the following error messages:

Copyright (C) 1995-2013 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.1.2
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.
fatal:["FileSupport.c":2761]:_NclFindFileExt: Requested file <home/Dokumenty/climatological monthly mean pr_1971-2000.nc> or <home/Dokumenty/climatological monthly mean pr_1971-2000> does not exist

fatal:["FileSupport.c":3106]:(home/Dokumenty/climatological monthly mean pr_1971-2000.nc) has no file extension, can't determine type of file to open
fatal:["FileSupport.c":2761]:_NclFindFileExt: Requested file <home/robert/Dokumenty/climatological monthly mean pr_2021-2050.nc> or <home/robert/Dokumenty/climatological monthly mean pr_2021-2050> does not exist

fatal:["FileSupport.c":3106]:(home/robert/Dokumenty/climatological monthly mean pr_2021-2050.nc) has no file extension, can't determine type of file to open
fatal:["FileSupport.c":2761]:_NclFindFileExt: Requested file <home/robert/Dokumenty/climatological monthly mean pr_2071-2100.nc> or <home/robert/Dokumenty/climatological monthly mean pr_2071-2100> does not exist

fatal:["FileSupport.c":3106]:(home/robert/Dokumenty/climatological monthly mean pr_2071-2100.nc) has no file extension, can't determine type of file to open
fatal:file (f1) isn't defined
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 11 in file simple_plot_pr.ncl

I checked these files and they exist. I do not understand why ncl not find them? Can someone give me a suggestion to solve this issue?

2

There are 2 best solutions below

0
On

You can also use the forward slash before the space in the file name. For example. Instead of writing "climatological monthly mean pr_1971-2000.nc"; you cane write the file names in the following format. "climatological\ monthly\ mean\ pr_1971-2000.nc"

0
On

The error is arising definitely due to the spaces in the file names. Please rename the filename without spaces.