爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 12325|回复: 18

如何用ncl将wrf结果输出成按高度输出的nc文件

[复制链接]

新浪微博达人勋

发表于 2015-1-6 22:40:10 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
初学ncl,遇到问题不会了,求大神指点!!
程序:
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/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
a = addfile("wrfout_d01_2014-04-01_00:00:00","r")
U=wrf_user_getvar(a,"U",-1)      
nz=27
ny=90
nx=90   
ntim = -1
U_in=new((/nz,ny,nx/),"float")
H=wrf_user_getvar(a,"height",ntim)
U_in=wrf_user_intrp3d(U,H,"h",100,0.,False)
ncf = addfile("wrf.nc","c")
;filedimdef( ncf, "time", -1,Ture )
  dim_names = (/ "lon",  "lat",  "lev", "time" /)
  dim_sizes = (/ nx ,  ny ,  nz ,  ntim  /)
  dimUnlim = (/ False , False,  False ,  True  /)
  filedimdef( ncf, dim_names, dim_sizes, dimUnlim )

结果:
warning:"/home/pub" tmp dir does not exist or is not writable: NCL functionality may be limited -- check TMPDIR environment variable
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:syntax error: line -1 before or near  
^
fatal:error in statement



密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-1-7 08:45:33 | 显示全部楼层
warning貌似是权限问题;
如果贴出的是全部程序,fatal可能是因为只有begin,没有end。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-1-7 11:06:19 | 显示全部楼层
longlivehj 发表于 2015-1-7 08:45
warning貌似是权限问题;
如果贴出的是全部程序,fatal可能是因为只有begin,没有end。

确实是忘记end 了,不过,加了还是不对
warning:"/home/pub" tmp dir does not exist or is not writable: NCL
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:Undefined identifier: (wrf_user_getvar) is undefined, can't
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 7
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-1-7 11:26:47 | 显示全部楼层
longlivehj 发表于 2015-1-7 08:45
warning貌似是权限问题;
如果贴出的是全部程序,fatal可能是因为只有begin,没有end。

权限好像是账号的原因,我换了一个就不是权限问题了
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:Dimension size mismatch, dimension (3) of left hand side reference does not have the same size as the right hand side reference after subscripting.
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 245 in file $NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl

fatal:["Execute.c":8128]:Execute: Error occurred at or near line 14 in file read.ncl
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-1-7 11:51:04 | 显示全部楼层
听雨残荷 发表于 2015-1-7 11:26
权限好像是账号的原因,我换了一个就不是权限问题了
Copyright (C) 1995-2013 - All Rights Reserved
  ...

U_in=new((/nz,ny,nx/),"float")少了个时间维!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-1-7 16:21:51 | 显示全部楼层
longlivehj 发表于 2015-1-7 11:51
U_in=new((/nz,ny,nx/),"float")少了个时间维!

改了还是不对,请问有没有用ncl 输出数据的程序例子,我参考一下
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-1-7 17:07:50 | 显示全部楼层
听雨残荷 发表于 2015-1-7 16:21
改了还是不对,请问有没有用ncl 输出数据的程序例子,我参考一下

错误不是输出时产生的,是插值函数没有用对。最好能将最新修改的代码和完整的错误信息帖出来。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-1-7 18:57:22 | 显示全部楼层
longlivehj 发表于 2015-1-7 17:07
错误不是输出时产生的,是插值函数没有用对。最好能将最新修改的代码和完整的错误信息帖出来。

应该是输出有问题,我把差值的那部分去掉,还是不可以
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/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
a = addfile("wrfout_d01_2014-04-01_00:00:00.nc","r")
U=wrf_user_getvar(a,"tc",-1)
nz=27
ny=90
nx=90
nt=493
ntim = -1
;U_in=new((/nz,ny,nx,nt/),"float")
;H=wrf_user_getvar(a,"height",ntim)
;U_in=wrf_user_intrp3d(U,H,"h",100,0.,False)

ncf = addfile("wrf.nc","c")
;filedimdef( ncf, "time", -1,Ture )
  dim_names = (/ "lon",  "lat",  "lev", "time" /)
  dim_sizes = (/ nx ,  ny ,  nz ,  nt  /)
  dimUnlim = (/ False , False,  False ,  False  /)
  filedimdef( ncf, dim_names, dim_sizes, dimUnlim )
printVarSummary(U_in)

end

错误:
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:Could not create (wrf.nc)
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 22 in file read.ncl
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-1-8 08:43:36 | 显示全部楼层
听雨残荷 发表于 2015-1-7 18:57
应该是输出有问题,我把差值的那部分去掉,还是不可以
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn ...

wrf.nc已经存在了!
手动或者程序删除。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2015-1-8 16:16:50 | 显示全部楼层
longlivehj 发表于 2015-1-8 08:43
wrf.nc已经存在了!
手动或者程序删除。

非常不好意思,真是刚刚学。但是我改过了以后,生成的wrf.nc里面没有数据(如果不做插值)。做插值后就不生成wrf.nc了
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/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
begin
a = addfile("wrfout_d01_2014-04-01_00:00:00.nc","r")
U=wrf_user_getvar(a,"tc",-1)
nz=38
ny=90
nx=90
nt=493
ntim = -1
U_in=new((/nz,ny,nx,nt/),"float")
H=wrf_user_getvar(a,"height",ntim)
U_in=wrf_user_intrp3d(U,H,"h",100,0.,False)
;nz=30
ncf = addfile("wrf.nc","c")
;filedimdef( ncf, "time", -1,Ture )
  dim_names = (/ "lon",  "lat",  "lev", "time" /)
  dim_sizes = (/ nx ,  ny ,  nz ,  nt  /)
  dimUnlim = (/ False , False,  False ,  False  /)
  filedimdef( ncf, dim_names, dim_sizes, dimUnlim )
;printVarSummary(U_in)


end

错误
fatal:Number of dimensions on right hand side do not match number of dimension in left hand side
fatal:["Execute.c":8128]:Execute: Error occurred at or near line 15 in file read.ncl
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表