Re: Dimension error

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 17 Oct 2007 11:03:53 -0600

[1] NCL is row major like C. Fortran is column major.
     In NCL/C the rightmost dimension varies fastest
     while in fortran the leftmost dimension varies fastest.
     Basically, the fastest varying dimensions map into each other.

                      NCL fortran
          x(klev,nlat,nlon) <===> x(nlon,nlat,klev)

[2] So, I think you need to change your fortran to

      REAL X(NLON,NLAT,NLEVSOI)

 

          write(1) (((X(II,JJ,KK),II=1,NLON), JJ=1,NLAT),KK=1,NLEVSOI)

or equivalently [you do not need the implied DO loops)

          write(1) X

[3] If all you are doing is writing to a binary file ....
     you can use

 http://www.ncl.ucar.edu/Document/Functions/Built-in/fbinrecwrite.shtml
 
    without going to fortran.

* fbinrecwrite* (filo, -1, tsoi(m,:,:,:) )

   where filo id some named file.

Good luck

Tummuri, Spandana wrote:
> Hello,
>
> I am getting the following error when I try to run an NCL program. I am not able to understand what the error means. Can anyone please tell me why I am getting the error and point me in the correct direction?
>
> Thanks.
> Spandana.
>
>
> Variable: levsoi
>
> Type: float
>
> Total Size: 40 bytes 10 values
>
> Number of Dimensions: 1
>
> Dimensions and sizes: [levsoi | 10]
>
> Coordinates: levsoi: [0.007100635..2.864607]
>
> Number of Attributes: 2
>
> units : m long_name : coordinate soil levels
>
> fatal:Number of elements of dimension (0) of argument (1) is (10) in function (test7), expected (1) elements
>
> fatal:Execute: Error occurred at or near line 27 in file soil-trial.ncl
>
>
>
> The relevant lines from the fortran stub test7.f are:
>
>
>
> NCLFORTSTART
>
> SUBROUTINE TEST7 (X,NLEVSOI,DS,DT,NLAT,NLON,N)
>
> INTEGER NLAT,NLON,NLEVSOI,DS,DT,H,M,S,N
>
> REAL X(NLEVSOI,NLAT,NLON)
>
>
>
> write(1)(((X(KK,JJ,II),KK=1,NLEVSOI),JJ=1,NLAT),II=1,NLON)
>
>
>
> The lines of the NCL code where this error occurs is:
>
>
>
> do m = 0, ntime-1
>
> datesec1 = datesec(m)
>
> date1 = date(m)
>
> SUBS::test7(tsoi(m,:,:,:),levsoi,datesec1,date1,lat,lon,1).......................line 27
>
> end do
>
> end
>
>
>
>
>
>

-- 
======================================================
Dennis J. Shea                  tel: 303-497-1361    |
P.O. Box 3000                   fax: 303-497-1333    |
Climate Analysis Section                             |
Climate & Global Dynamics Div.                       |
National Center for Atmospheric Research             |
Boulder, CO  80307                                   |
USA                        email: shea 'at' ucar.edu |
======================================================
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 17 2007 - 11:03:53 MDT

This archive was generated by hypermail 2.2.0 : Mon Oct 22 2007 - 14:48:45 MDT