Do Loops & Saving in External file

From: Mike Pirhalla <glacierbayncl_at_nyahnyahspammersnyahnyah>
Date: Tue Jan 29 2013 - 19:15:29 MST

Hello,

 

I need some help/guidance with my current program. Right now, the program
pulls WRF pressure and temperature data for one hour at one grid cell. I
have a variable called "slice" which has temperatures on 16 levels, as well
as "PO" with pressures on the corresponding levels. I need the DO LOOP to
cycle through the temperatures. If the temperature of one level is warmer
than the last, I need the program to print that level. However, there may be
more than one inversion. For my case, I have 2 inversions and am finding
this loop does not record both. It overwrites the last value and only
records one. This is then same for the corresponding temperature.

Do I need to use a write_matrix instead?

Thanks, any help would be greatly appreciated!

 

 

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-07-15_00:00
:00"+".nc", "r")

 

;===Get temperature data===

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

 

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

 

;===Get pressure data===

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

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

 

printVarSummary(P0)

print(P0)

print(slice)

 

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

; Calculate Inversion Levels

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

time=0

do lev=0,15

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

print(lev)

    pressure=P0(lev+1)

    print(pressure)

 

   temp=slice(lev+1,:)

   print(temp)

 

end if

end do

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

; Generate External File

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

asciiwrite("inversion_data.txt",pressure)

end

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jan 29 19:15:45 2013

This archive was generated by hypermail 2.1.8 : Tue Jan 29 2013 - 22:44:26 MST