Dimension Problem

From: Mike Pirhalla <glacierbayncl_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 19 2013 - 20:23:41 MST

I am getting this error when I try to store my data to a matrix:

fatal:Number of dimensions in parameter (0) of (write_matrix) is (3), (2)
dimensions were expected

fatal:Execute: Error occurred at or near line 140 in file new.ncl

 

The program is calculating multiple inversion levels and exporting the
results to a file using write_matrix. It works for one hour, but when I
increase the loop to 24 hours I get the error. It's doing the calculations
correctly, just having issues writing the data to the file.

 

What am I doing wrong?
Thanks for the help,

Mike

 

 

 

======

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"

 

begin

;=====================

; Retrieve Data

;=====================

f = addfile
("/import/archive/u1/uaf/molders/GLACIERBAY/WITH/wrfout_d01_2008-06-29_00:00
:00"+".nc", "r")

 

fout=addfile("/import/home/u1/uaf/mapirhalla/PROGRAMS/SURFACE_WRCC.nc","w")

fmtf="3F9.2"

opt=True

opt@fout= <mailto:opt@fout=%22new_data.dat> "new_data.dat"

 

tp=new((/24,14,2/),float)

tp=-999

tp!0 = "Height"

tp!1 = "Temperature"

 

 

;===Get temperature data===

T = wrf_user_getvar(f,"tc",-1)

temp = T(bottom_top|:,Time|:,south_north|45,west_east|61)

 

;==Get pressure data===

  P = wrf_user_getvar(f,"pressure",-1)

 

; This is 4 dimensions, wrap dimension quantity to 1

  P0 = dim_avg_n_Wrap(P(:,:,45,61),0)

 

; Make temp variable one dimension for calculating geoht

T0= dim_avg_n_Wrap(T(:,:,45,61),0)

 

 

ter=wrf_user_getvar(f,"HGT",-1)

terr=ter(Time|:,south_north|45,west_east|61)

 

; Calculate the height levels in meters

geoht = hydro(P0,T0+273.15,terr)

print(geoht)

 

 

;===========================

; Calculate Inversion Levels

;===========================

time=0

counter=0

 

 

do time=1,24 ;start loop time

do lev=1,15 ;start loop levels

 

counter = 0 ; reset counter for each day

if(temp(lev+1,time) .gt. temp(lev,time)) then

print(lev)

 

    height=geoht(lev+1)

    print(height)

 

tempdiff=(temp(lev+1,time))-(temp(lev,time)) ;Calc temp difference between
levels

geodiff=(geoht(lev+1))-(geoht(lev)) ;Calc height difference
between levels

difference=(tempdiff/geodiff)*1000 ;Calc dT/dz * 1000 to convert
m to km

 

tp(time,counter,0)=geoht(lev+1) ;Writes the height of the inversion
(line140)

tp(time,counter,1)=difference ;Writes dT/dz (in C/km) of inversion

 

end if

counter=counter+1 ; Counter to advance to next possible inversion
level

 

end do ;end loop levels

time = time + 1

 

end do ;end loop time

 

 

;==========================

; Generate External File

;==========================

write_matrix(tp,fmtf,opt) line 140

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 19 20:23:56 2013

This archive was generated by hypermail 2.1.8 : Thu Feb 21 2013 - 11:26:43 MST