Re: dimension reordering with WRAPIT

From: Dennis Shea (shea AT ucar.edu)
Date: Wed Aug 10 2005 - 23:45:42 MDT


Have you read the mini-reference manual [pdf]

    http://www.ncl.ucar.edu/Document/Manuals/index.shtml

> I am fairly confused on the dimension reording that takes place with arrays
> in NCL and when they are passed through WRAPIT.
>
> I have an array u(428,614), and when I pass it to a fortran program through
> WRAPIT i have to declare the array as (614,428) in order for it to pass
> through without an error. So, to me it seems like the dimensions become
> switched when the array is passed to the fortran program.

NCL is like C, the rightmost dimension varies fastest.
In fortran, the leftmost dimension varies fastest.

    NCL: (2,3) <===> (3,2) :Fortran

The fastest varying subscripts 'map' into one another.
Remembering that NCL is 0-based while fortran is 1-based

            (0,0) <===> (1,1)
            (0,1) <===> (2,1)
            (0,2) <===> (3,1)
            (1,0) <===> (1,2)
            (1,1) <===> (2,2)
            (1,2) <===> (3,2)

----

> > However, my objective is to access individual elements of the array, and > a print(u(428,614) gives me -8.46 while in ncl, and u(614,428) gives a > different value in the fortran program. So, I haven't been able to figure > out what is going on.

If the array in NCl has a size of (428,614), then you can not print its value via print(u(428,614)) because this is out of bounds. The last element would be print(u(427,613)) . NCL is zero based.

Since NCL is 0-based and fortran is 1-based, a fortran reference of, say, ( 202, 315) would be referenced in NCL as ( 314, 201) (fast,slow) (slow,fast)

> > I would greatly appreciate some clarification on how the dimensions are > interpreted as they go from ncl to fortran.

See above: IMHO, one fundamental thing one should know in *any* language is what dimension is the fastest varying.

> I have attached my ncl, stub, and f90 file. Also, if you would like to use > my data file, it can be found along with the other 3 files at > http://udel.edu/~micahs > > As always, thanks for your help! > > Micah Sklut micahs@udel.edu > Geography Department - University of Delaware _______________________________________________ ncl-talk mailing list ncl-talk@ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talk



This archive was generated by hypermail 2b29 : Thu Aug 11 2005 - 07:47:51 MDT