Question on writing to new netcdf files with ncl 5.0.0

From: Daran Rife <drife_at_nyahnyahspammersnyahnyah>
Date: Tue, 23 Dec 2008 18:08:22 -0700

Dear ncl-talk,

I am running an ncl script in which I read in an HDF5/NETCDF4 file with
the latest version of ncl (5.0.0), do some calculations, and write out a
netcdf file The ncl script works fine, and the output file looks that
it writes looks fine if I dump it with ncdump or view it with ncview.
However, I get an error message from the H5I.c routine when I end the
script. Here is an example:

------------------------------------------------------------------
apollo:/d1/monaghan/mfc_process> ncl calc_mfc_2d.ncl
Copyright (C) 1995-2007 - All Rights Reserved
University Corporation for Atmospheric Research
NCAR Command Language Version 5.0.0
The use of this software is governed by a License Agreement.
See http://www.ncl.ucar.edu/ for more details.
(0) -----------------------------------
(0) Done writing to output file
(0) -----------------------------------
ncl: H5I.c:1943: H5I_find_id: Assertion `type_ptr && type_ptr->count >
0' failed.
Abort
6.556u 0.544s 0:07.13 99.4% 0+0k 0+0io 0pf+0w
apollo:/d1/monaghan/mfc_process>
-------------------------------------------------------------------

I've gotten this error message despite trying several different options.
For example, I'm writing the new file as "Classic", but I get the same
error when I try to write "Netcdf4Classic".

Below is a copy of my script. Do you know what is causing this error?
It doesn't seem to be causing a critical problem, but I just want to
make sure...

;************************************************
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"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl"
;************************************************
; THIS SCRIPT WILL CONVERT MOISTURE FLUX CONVERGENCE AT
; ONE LEVEL OF A GLOBAL FIXED LAT/LON FILE
; A. MONAGHAN AND DARAN RIFE
; 12-23-2008

begin

ddstr = asciiread("plot.par",-1,"string")
print("")
print("")
print("-----------------------------------")
print("START INPUT VARIABLES")
print("-----------------------------------")
print(ddstr)
print("-----------------------------------")
print("END INPUT VARIABLES")
print("-----------------------------------")
temp = stringtochar(ddstr(0))
yr = chartostring(temp(:dimsizes(temp)-2))
delete(temp)
temp = stringtochar(ddstr(1))
mo = chartostring(temp(:dimsizes(temp)-2))
delete(temp)
temp = stringtochar(ddstr(2))
dy = chartostring(temp(:dimsizes(temp)-2))
delete(temp)
temp = stringtochar(ddstr(3))
hr = chartostring(temp(:dimsizes(temp)-2))
delete(temp)
lev = stringtointeger(ddstr(4))

; What above variables should look like in param file
; yr = 1985
; mo = 01
; dy = 02
; hr = 04
; lev = 7

   ;===============================
   ;Input data file and variables
   ;===============================

   f= addfile("GLOBAL/ncf/"+yr+mo+dy+"/"+hr+"0000.mdv.nc","r")

   LAT=f->y0
   LON=f->x0
   TIME=f->time

   U=f->U(0,lev,:,:)
   UF = (U*U_at_scale_factor) + U_at_add_offset

   V=f->V(0,lev,:,:)
   VF = (V*V_at_scale_factor) + V_at_add_offset

   RH=f->RH(0,lev,:,:)
   RHF = (RH*RH_at_scale_factor) + RH_at_add_offset

   T=f->Temp(0,lev,:,:)
   TF = (T*T_at_scale_factor) + T_at_add_offset +273.15

   P=f->pressure(0,lev,:,:)
   PF=P ; there is no scale factor for pressure

   QF=RHF ; set dummy variable for Q
   QF= mixhum_ptrh(PF,TF,RHF,2) ; calc specific humidity from P,T,RH

; calculate divergence [DIVF= Dv/Dy + Du/Dx -(v/a)*tan(phi)]
; then multiply by Q
   DIVF = uv2dv_cfd(UF,VF,LAT,LON,3)
   QDIVF = QF*DIVF

; Now calculate gradients of Q in both directions
  QF_grad_lon = QF ; create arrays to hold output,
  QF_grad_lat = QF
  gradsf (QF, QF_grad_lon, QF_grad_lat)
  QF_grad_lon_at_long_name = "longitudinal gradient (derivative)"
  QF_grad_lat_at_long_name = "latitudinal gradient (derivative)"

; Now multiply the gradients by U and V

    ; u*(-dq/dx)
    UQLON=UF*QF_grad_lon
    ; v*(-dq/dy)
    VQLAT=VF*QF_grad_lat

; Now calculate MFC=UQLON+VQLAT-QDIVF
; ...or MFC=-u*dq/dx-v*dq/dy-q*(Dv/Dy + Du/Dx -(v/a)*tan(phi))
; ...note: still missing term for q/a*tan(phi) in first term of
equation
    MFCF=QF ; set up dummy variable
    MFCF=UQLON+VQLAT-QDIVF

    ;=======================================
    ;Create 3-d MFC array and fill with MFCF
    ;=======================================
     ntime = 1
     MFC = new ( (/ntime,dimsizes(LAT),dimsizes(LON)/), "float")
     MFC(0,:,:) = MFCF
    ;=============================
    ; name dimensions of variables
    ;============================

     delete(TIME_at_bounds) ; get rid of this - it is residual
     delete(MFC@_FillValue) ; don't need - no missing values
     MFC!0 = "time"
     MFC!1 = "lat"
     MFC!2 = "lon"
     MFC&time = TIME
     MFC&lat = LAT
     MFC&lon = LON
     MFC_at_long_name = "MFC"
     MFC_at_units = "kg/kg/s"
     print("")
     print("")
     print("-----------------------------------")
     print("START MFC VARIABLE SUMMARY")
     print("-----------------------------------")
     printVarSummary(MFC)
     print("-----------------------------------")
     print("END MFC VARIABLE SUMMARY")
     print("-----------------------------------")
    ;======================
    ; Create NetCDF Ouput File of day
    ;======================
     ncout = "TEST_MFC.nc"
     system("/bin/rm -f "+ncout)
; setfileoption("nc", "Format", "NetCDF4Classic") ; turned off for
now - writes "Classic" by default
     a = addfile(ncout,"c") ; write netCDF file
     a_at_title = " MFC at Approximately 500 m AGL"
     a_at_source = "NCAR DTRA-CFDDA Dataset"
     filedimdef(a,"time",-1,True) ; make time an UNLIMITED dimension,
always recommended
    ;=============================
    ;Place Contents into NetCDF file
    ;=============================
     a->MFC = MFC
     delete(ncout)
     print("")
     print("")
     print("-----------------------------------")
     print("Done writing to output file")
     print("-----------------------------------")
end
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Dec 23 2008 - 18:08:22 MST

This archive was generated by hypermail 2.2.0 : Wed Dec 24 2008 - 09:38:50 MST