Write portion of 2D/3D fortran array in memory to file

Thiago Quirino - NOAA Federal thiago.quirino at noaa.gov
Thu Dec 18 11:32:49 CST 2014


Nice! Thank you so much, Wei-keng!

All the best,
Thiago.

On Thu, Dec 18, 2014 at 12:21 PM, Wei-keng Liao <
wkliao at eecs.northwestern.edu> wrote:
>
> You can also use PnetCDF flexible APIs.
> First, you need to create an MPI derived data type.
> See example program in examples/F77/flexible_api.f
>
>           ! create an MPI datatype using MPI_Type_create_subarray()
>           array_of_sizes(1)    = 100
>           array_of_sizes(2)    = 100
>           array_of_subsizes(1) = 80
>           array_of_subsizes(2) = 80
>           array_of_starts(1)   = 10
>           array_of_starts(2)   = 10
>           call MPI_Type_create_subarray(2, array_of_sizes,
>      +         array_of_subsizes, array_of_starts, MPI_ORDER_FORTRAN,
>      +         MPI_REAL, buftype, err)
>           call MPI_Type_commit(buftype, err)
>
>           bufcount = 1
>           err = nfmpi_put_vara_all(ncid, varid, start, count, data,
> bufcount, buftype)
>           call MPI_Type_free(buftype, err)
>
> Wei-keng
>
> On Dec 18, 2014, at 11:08 AM, Thiago Quirino - NOAA Federal wrote:
>
> > Thank you, Wei-keng.
> >
> > Won't that result in a temporary argument array being created? The
> actual arrays in my program are very large. Is there a method to achieve
> the same effect without resulting in the creation of a temporary array.
> >
> > Again, thank you so much,
> > Thiago.
> >
> >
> > On Thu, Dec 18, 2014 at 11:55 AM, Wei-keng Liao <
> wkliao at eecs.northwestern.edu> wrote:
> > Hi, Thiago
> >
> > You can use data(10:90, 10:90). For example,
> >
> > err = nfmpi_put_vara_real_all(ncid, varid, start, count, data(10:90,
> 10:90))
> >
> > In this case, your have to make sure the write amounts are matched, i.e.
> >   count(1)*count(2) must be equal to 80*80
> >
> > Wei-keng
> >
> > On Dec 18, 2014, at 10:36 AM, Thiago Quirino - NOAA Federal wrote:
> >
> > > Hello, folks.
> > >
> > > I've reading through the Fortran examples and documentation in the
> Pnetcdf website, and it seems like all calls to nfmpi_put_var* subroutines
> will write a specified 2D/3D data array found in memory starting at
> location (1,1) of the array. Suppose that I have a 2D fortran real array of
> 100x100 elements. For example:
> > >
> > > real(4) :: data(100,100)
> > >
> > > Is it possible to write out only a portion of this 2D array to file
> without copying the desired portion to another smaller 2D array? For
> example, can all the elements between data(10,10) and data(90,90) (or 80x80
> elements) be written out to file directly, that is, ignoring 10 rows and
> columns on each side of the data array? These ignored rows and columns
> correspond to halo points in my application that don't need to be written
> out.
> > >
> > > Thank you so much,
> > > Thiago.
> > >
> > >
> > >
> > > ---------------------------------------------------
> > > Thiago Quirino, Ph.D.
> > > NOAA Hurricane Research Division
> > > Numerical Modeling Group
> > > 4301 Rickenbacker Cswy.
> > > Miami, FL 33149
> > > P: 305-361-4337
> > > E: Thiago.Quirino at noaa.gov
> > > http://hwrf.aoml.noaa.gov
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/parallel-netcdf/attachments/20141218/610bcda6/attachment-0001.html>


More information about the parallel-netcdf mailing list