Re: To read multiple arrays in a loop

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Thu Jan 24 2013 - 13:46:16 MST

Hi Noel,

It seems like what you want to use is a List type:

    var_arr = [/ sim_pr, sim_pet, …, sim_cn /]

Note the [/ /] notation for lists vs. arrays. Also note that you want the actual variable names, not quoted strings that happen to be the same as the variable names.

Then inside your inner loop:

  P1 = varr_arr[j]

(again noting square-bracket notation).

Hope that helps…
Rick

On Jan 24, 2013, at 11:30 AM, Noel Aloysius <noel.aloysius@gmail.com> wrote:

> Hello NCL,
>
> I have a list of arrays, dimensioned (/24,1800,47,47/) == (/ensembles, time, lat, lon/), as follows,
>
> var_arr = (/"sim_pr","sim_pet","sim_et","sim_swi","sim_swe","sim_perc", \
> "sim_gwrchg","sim_darchg","sim_revap","sim_sast","sim_surqgen", \
> "sim_surqcnt","sim_tloss","sim_latq","sim_gwq","sim_wyld","sim_cn"/) ; list of 17 arrays
>
> I defined a new array to store monthly climatology of each variable listed in var_arr as follows,
>
> sim_clim = new ((/24,17,12,nlat,nlon/),"float",1e+20) ; where array size (/24,17,12,nlat,nlon/) == (/ensembles, variable, months, nlat, nlon/)
>
> I want to compute the climatologies with a loop as follows,
>
> do i=0,23 ; loop through ensembles
> do j=0,16 ; loop through variables
>
> P1 = var_arr(j) ; I can't point to an array this way, but want to know how I can point to the correct array listed in var_arr
> sim_clim(i,j,:,:,:) = (/ clmMonTLL(P1(i,{197101:200012},:,:) /)
> delete(P1)
>
> end do
> end do
>
> I would like to know how I can point the correct array from the list var_arr and pass it to P1.
>
> Thanks,
> Noel
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jan 24 13:46:41 2013

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