Re: problem opening indexed files within loop?

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed, 24 Sep 2008 13:00:15 -0600

Hi Leslie,

I am guessing that each cruise has a different number of timesteps,
which is causing the code to crash when it tries to put time (from
cruise 2) into a predefined time array set from cruise 1.

Simply delete the time array at the end of your do loop via a:
delete(time)
. You might have to delete the lat and lon arrays if those are different
from cruise to cruise as well.
Adan

Leslie Hartten wrote:
> Hi All,
>
> I am modifying some working code. The original code read in
> time/lat/lon from a file & plotted the ship track on a map. This
> version loops through cruises and each time reads in data from that
> cruise's file. If I've only got a 1-element array of cruises (1 cruise)
> it works fine; when I go to 3 cruises, I get
>
> "fatal:Dimension sizes of left hand side and right hand side of
> assignment do not match" at or near the indicated line below
>
> The relevant bits seems to be:
> =====
> nyearmax = 3
> year = (/2006,2007,2008/) ; create year variable & fill
> year!0 = "year" ; name its dimension
> year&year = year ; assign coordinate variable
>
> diri = "/Users/lhartten/Documents/AMMA/data/"
> cruise = year
> fili =
> (/"flux_30hf_AMMA06.nc","flux_30hf_AMMA07.nc","flux_30hf_AMMA08.nc"/)
> fili!0 = "year"
> fili&year = year
>
> ; ncruise = 1 ; ** must be edited by hand
> ; cruise = (/2006/) ; ** must be edited by hand, # years = ncruise
> ncruise = 3 ; ** must be edited by hand
> cruise = (/2006,2007,2008/); **must be edited by hand, #years=ncruise
>
> [other stuff cut out]
>
> do icruise = 0, ncruise-1
>
> fi = addfile( diri+fili({cruise(icruise)}), "r")
>
> time = fi->time ; **** Fatal Error at or near here ****
> lat = fi->lat
> lon = fi->lon
> =====
> Do "time", "lat", "lon" need to be somehow undefined if I'm going to
> use them in this way? how would I do that?
>
> Cheers,
> Leslie
> --
> Dr. Leslie M. Hartten
> CIRES, Univ. of Colorado email: Leslie.M.Hartten_at_noaa.gov
> 216 UCB web: http://cires.colorado.edu/~hartten
> Boulder CO 80309-0216 phone: (303)497-7052 fax: 497-6181
> --
> Disclaimer: The contents of this message are mine personally and do not
> necessarily reflect any position of the Government of the United States
> of America, the National Oceanic and Atmospheric Administration, or the
> University of Colorado.
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Sep 24 2008 - 13:00:15 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 29 2008 - 13:35:43 MDT