Skip to content

Commit

Permalink
working on nf_free_decomp
Browse files Browse the repository at this point in the history
  • Loading branch information
edhartnett committed Jul 18, 2019
1 parent bc125f8 commit f47f9b1
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/clib/pioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,10 +705,10 @@ PIOc_InitDecomp(int iosysid, int pio_type, int ndims, const int *gdimlen, int ma
/* Broadcast next ioid to all tasks from io root.*/
if (ios->async)
{
PLOG((3, "createfile bcasting pio_next_ioid %d", pio_next_ioid));
PLOG((3, "initdecomp bcasting pio_next_ioid %d", pio_next_ioid));
if ((mpierr = MPI_Bcast(&pio_next_ioid, 1, MPI_INT, ios->ioroot, ios->my_comm)))
return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__);
PLOG((3, "createfile bcast pio_next_ioid %d", pio_next_ioid));
PLOG((3, "initdecomp bcast pio_next_ioid %d", pio_next_ioid));
}

/* Set the decomposition ID. */
Expand Down
48 changes: 47 additions & 1 deletion src/flib/ncint_mod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module ncint_mod
include 'mpif.h' ! _EXTERNAL
#endif

public :: nf_def_iosystem, nf_free_iosystem
public :: nf_def_iosystem, nf_free_iosystem, nf_free_decomp

contains

Expand Down Expand Up @@ -123,6 +123,52 @@ end function PIOc_finalize
status = ierr
end function nf_free_iosystem

!>
!! @public
!! @ingroup PIO_finalize
!! Free a decomposition.
!!
!! @param decompid the decompostion ID.
!! @author Ed Hartnett
!<
function nf_free_decomp(decompid) result(status)
integer, intent(in) :: decompid
integer(C_INT) :: cdecompid
integer(i4) :: iosysid;
integer(i4) :: ierr
integer :: status

interface
integer(C_INT) function nc_get_iosystem(iosysid) &
bind(C, name="nc_get_iosystem")
use iso_c_binding
integer(C_INT), intent(out) :: iosysid
end function nc_get_iosystem
end interface

interface
integer(C_INT) function PIOc_freedecomp(iosysid, ioid) &
bind(C,name="PIOc_freedecomp")
use iso_c_binding
integer(C_INT), intent(in), value :: iosysid, ioid
end function PIOc_freedecomp
end interface

interface
integer(C_INT) function nc_free_decomp(decompid) &
bind(C, name="nc_free_decomp")
use iso_c_binding
integer(C_INT), intent(in), value :: decompid
end function nc_free_decomp
end interface

ierr = nc_get_iosystem(iosysid)
cdecompid = decompid
! ierr = PIOc_freedecomp(iosysid, cdecompid)
ierr = nc_free_decomp(cdecompid)
status = ierr
end function nf_free_decomp

! !>
! !! @public
! !! @ingroup PIO_initdecomp
Expand Down
2 changes: 1 addition & 1 deletion src/flib/pio.F90
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module pio
pio_set_rearr_opts

#ifdef NETCDF_INTEGRATION
use ncint_mod, only: nf_def_iosystem, nf_free_iosystem
use ncint_mod, only: nf_def_iosystem, nf_free_iosystem, nf_free_decomp
#endif

use pio_types, only : io_desc_t, file_desc_t, var_desc_t, iosystem_desc_t, &
Expand Down
1 change: 1 addition & 0 deletions src/ncint/ncint_pio.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,6 @@ nc_def_decomp(int iosysid, int pio_type, int ndims, const int *gdimlen,
int
nc_free_decomp(int ioid)
{
PLOG((1, "nc_free_decomp ioid %d", ioid));
return PIOc_freedecomp(diosysid, ioid);
}
11 changes: 7 additions & 4 deletions tests/fncint/ftst_pio.f90
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ program ftst_pio
parameter (FILE_NAME='ftst_pio.nc')
integer, dimension(3) :: data_buffer, compdof
integer, dimension(1) :: dims
type(io_desc_t) :: iodesc_nCells
type(io_desc_t) :: iodesc
integer :: decompid
integer :: ierr

! Set up MPI.
Expand All @@ -24,7 +25,7 @@ program ftst_pio
call MPI_Comm_size(MPI_COMM_WORLD, ntasks, ierr)

! These control logging in the PIO and netCDF libraries.
ierr = pio_set_log_level(2)
ierr = pio_set_log_level(3)
ierr = nf_set_log_level(2)

! Define an IOSystem.
Expand All @@ -34,7 +35,8 @@ program ftst_pio
! Define a decomposition.
dims(1) = 3 * ntasks
compdof = 3 * myRank + (/1, 2, 3/) ! Where in the global array each task writes
call PIO_initdecomp(ioSystem, PIO_int, dims, compdof, iodesc_nCells)
call PIO_initdecomp(ioSystem, PIO_int, dims, compdof, iodesc)
decompid = iodesc%ioid

! Create a file.
ierr = nf_create(FILE_NAME, 64, ncid)
Expand All @@ -45,7 +47,8 @@ program ftst_pio
ierr = nf_close(ncid)

! Free resources.
call PIO_freedecomp(ioSystem, iodesc_nCells)
ierr = nf_free_decomp(decompid)
! call PIO_freedecomp(ioSystem, iodesc_nCells)
ierr = nf_free_iosystem()

! We're done!
Expand Down

0 comments on commit f47f9b1

Please sign in to comment.