[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

20040220: Hyperslab I/O of Varying Size: use of IMAP argument



Ben,

>Date: Mon, 23 Feb 2004 15:07:36 -0600
>From: Ben Howell <address@hidden>
>Organization: University of Wisconsin, Madison/SSEC
>To: Steve Emmerson <address@hidden>
>Subject: Re: 20040220: Hyperslab I/O of Varying Size
> Keywords: 200402181846.i1IIkk2N001457

The above message contained the following:

> Thanks a lot for the info on "nf_put_varm*".  I read about this
> function in the (online) NetCDF User's Guide, and tried to follow the
> instructions, but I do not understand the function of the variable
> "imap" that is one of the function arguments.  Attached is an excerpt
> from my FORTRAN code in which I am trying to write out as set of
> 250 latitudes from an array that is dimensioned 500, a set of 600
> longitudes from an array dimensioned 1200 and a set of brightness
> temperatures (250 by 600) from an array dimensioned 500 by 1200.
> 
> If you have time , and are so inclined, I would appreciate if you could 
> tell me what I'm doing wrong.
...

The key to understanding the "imap" vector is to realize that the
dot-product (alias "inner product") of the 0-based index-vector of a
point with the "imap" vector yields the 0-based, scalar offset to the
point from the start of the array in question.  Thus, the second element
of the "imap" vector gives the number of elements between successive 
increments of the second index of the array.

For example:

    real brightness(1200,500)
    integer imap(2)

    imap(1) = 1
    imap(2) = 1200

Here is your example with some modifications that might get it to work:

>       PARAMETER(MAXLINES=500, MAXELEMS=1200)
>       REAL*4 BTEMP1(MAXELEMS, MAXLINES)
>       INTEGER*4 START(2), COUNT(2), STRIDE(2), IMAP(2)
>       
>       DATA STRIDE/1,1/
> 
> 
>        .....
>        
>        NLATS=250
>        NLONS=600
>        
>        .....
>        
> 
> C ... OUTPUT LATITUDES:
>       START(1)=1
>       COUNT(1)=NLATS
> c     IMAP(1)=1
>      
> c     IRET=NF_PUT_VARM_REAL(IDCDF,IDLAT,START,COUNT,  ! no
> c    *STRIDE,IMAP,SLAT)                               ! no
>       IRET=NF_PUT_VARA_REAL(IDCDF,IDLAT,START,COUNT,  ! yes
>      *SLAT)                                           ! yes
> 
> C ... OUTPUT LONGITUDES:
>       START(1)=1
>       COUNT(1)=NLONS
> c     IMAP(1)=1                                       ! no
>       
> c     IRET=NF_PUT_VARM_REAL(IDCDF,IDLON,START,COUNT,  ! no
> c    *STRIDE,IMAP,SLON)                               ! no
>       IRET=NF_PUT_VARA_REAL(IDCDF,IDLON,START,COUNT,  ! yes
>      *SLON)                                           ! yes
> 
> C ... OUTPUT BRIGHTNESS TEMPERATURES:
>          START(1)=1
>          COUNT(1)=NLONS   ! nlons = 600
>          START(2)=1
>          COUNT(2)=NLATS   ! nlats = 250
>        IMAP(1)=1                                      ! yes
> c      IMAP(2)=NLONS                                  ! no
>        IMAP(2)=MAXELEMS       ! element count between 2nd index increments
>        
>          IRET=NF_PUT_VARM_REAL(IDCDF,IDBT,START,COUNT,
>      *   STRIDE,IMAP,BTEMP1)   

Regards,
Steve Emmerson