#include "ESMFPIO.h" #define __PIO_FILE__ "rearrange.F90" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! Module rearrange ! ! Provide a generic entry to the data rearrangement ! ! ! 20070919 Initial version - R. Loy ! module rearrange use pio_kinds use pio_types use pio_support #ifdef _USEMCT use mct_rearrange #endif #ifdef _USEBOX use box_rearrange #endif #ifdef TIMING use perf_mod, only : t_startf, t_stopf, t_barrierf ! _EXTERNAL #endif implicit none private save !> !! @private !< public :: rearrange_init, & rearrange_create, & rearrange_comp2io, & rearrange_io2comp, & rearrange_free interface rearrange_init module procedure rearrange_init_ end interface interface rearrange_create module procedure rearrange_create_mct_, & rearrange_create_box_ end interface interface rearrange_comp2io ! TYPE real,double,int module procedure rearrange_comp2io_{TYPE} end interface interface rearrange_io2comp ! TYPE real,double,int module procedure rearrange_io2comp_{TYPE} end interface interface rearrange_free module procedure rearrange_free_ end interface contains ! TYPE real,double,int !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! rearrange_comp2io_{TYPE} ! subroutine rearrange_comp2io_{TYPE}(Iosystem,iodesc,compbuf,iobuf) implicit none type (Iosystem_desc_t) :: Iosystem type (io_desc_t) :: iodesc {VTYPE}, intent(in) :: compbuf(:) {VTYPE}, intent(out) :: iobuf(:) #ifdef TIMING call t_barrierf("pio_rearrange_comp2io_{TYPE}",IoSystem%comp_comm) call t_startf("pio_rearrange_comp2io_{TYPE}") #endif select case (Iosystem%rearr) case (PIO_rearr_mct) #ifdef _USEMCT call mct_rearrange_comp2io(Iosystem,iodesc,compbuf,iobuf) #else call die_nomct( __PIO_FILE__,__LINE__) #endif #ifdef _USEBOX case (PIO_rearr_box) call box_rearrange_comp2io(Iosystem,iodesc,size(compbuf), compbuf,size(iobuf), iobuf) #endif case default call piodie(__PIO_FILE__,__LINE__,'Unrecognized rearranger:',Iosystem%rearr) end select #ifdef TIMING call t_stopf("pio_rearrange_comp2io_{TYPE}") #endif end subroutine rearrange_comp2io_{TYPE} ! TYPE real,double,int !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! rearrange_io2comp_{TYPE} ! subroutine rearrange_io2comp_{TYPE} (Iosystem,iodesc,iobuf,compbuf) implicit none type (Iosystem_desc_t) :: Iosystem type(io_desc_t) :: iodesc {VTYPE} :: iobuf(:) {VTYPE} :: compbuf(:) #ifdef TIMING call t_startf("pio_rearrange_io2comp_{TYPE}") #endif select case (Iosystem%rearr) case (PIO_rearr_mct) #ifdef _USEMCT call mct_rearrange_io2comp(Iosystem,iodesc,iobuf,compbuf) #else call die_nomct( __PIO_FILE__,__LINE__) #endif #ifdef _USEBOX case (PIO_rearr_box) call box_rearrange_io2comp(Iosystem,iodesc,size(iobuf),iobuf,size(compbuf),compbuf) #endif case default call piodie(__PIO_FILE__,__LINE__,'Unrecognized rearranger:',Iosystem%rearr) end select #ifdef TIMING call t_stopf("pio_rearrange_io2comp_{TYPE}") #endif end subroutine rearrange_io2comp_{TYPE} !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! rearrange_die ! subroutine die_nomct(file,line) character(len=*) :: file integer :: line call piodie(file,line, & 'the mct rearranger was specified but pio was not build with mct enabled') end subroutine die_nomct !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! rearrange_init ! ! called from initFile_ ! subroutine rearrange_init_(Iosystem) implicit none type (Iosystem_desc_t), intent(inout) :: Iosystem select case (Iosystem%rearr) case (PIO_rearr_mct) #ifdef _USEMCT call mct_rearrange_init(Iosystem) ! mctrearrange #else call die_nomct(__PIO_FILE__,__LINE__) #endif #ifdef _USEBOX case (PIO_rearr_box) ! no general init required for box rearranger #endif case default call piodie(__PIO_FILE__,__LINE__,'Unrecognized rearranger:',Iosystem%rearr) end select end subroutine rearrange_init_ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! rearrange_create_mct_ ! ! called from initDecomp ! subroutine rearrange_create_mct_(Iosystem,compDOF,ioDOF,ioDesc) implicit none type (Iosystem_desc_t), intent(in) :: Iosystem integer(i4), intent(in) :: compDOF(:) integer(i4), intent(in) :: ioDOF(:) type (IO_desc_t), intent(inout) :: ioDesc #ifdef TIMING call t_startf("pio_rearrange_create_mct") #endif if (Iosystem%rearr /= PIO_rearr_mct) then call piodie( __PIO_FILE__,__LINE__, & 'rearrange_create called with args for mct but rearranger type is not mct, Iosystem%rearr='& , Iosystem%rearr) endif #ifdef _USEMCT call mct_rearrange_create(Iosystem,compDOF,ioDOF,ioDesc) #else call die_nomct( __PIO_FILE__,__LINE__) #endif #ifdef TIMING call t_stopf("pio_rearrange_create_mct") #endif end subroutine rearrange_create_mct_ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! rearrange_create_box_ ! ! called from initDecomp ! subroutine rearrange_create_box_(Iosystem,compDOF, & dims,ndims,ioDesc) implicit none type (Iosystem_desc_t), intent(in) :: Iosystem integer (i4), intent(in) :: compDOF(:) integer, intent(in) :: dims(:) integer, intent(in) :: ndims type (IO_desc_t) :: ioDesc #ifdef TIMING call t_startf("pio_rearrange_create_box") #endif if (Iosystem%rearr /= PIO_rearr_box) then call piodie( __PIO_FILE__,__LINE__, & 'rearrange_create called with args for box but rearranger type is not box, Iosystem%rearr=',& Iosystem%rearr) endif #ifdef _USEBOX call box_rearrange_create( Iosystem,compDOF,dims,ndims,Iosystem%num_iotasks,ioDesc) #else call piodie( __PIO_FILE__,__LINE__,'pio not build with _USEBOX' ) #endif #ifdef TIMING call t_stopf("pio_rearrange_create_box") #endif end subroutine rearrange_create_box_ !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! ! rearrange_free_ ! ! called from freeDecomp subroutine rearrange_free_(Iosystem,ioDesc) implicit none type (Iosystem_desc_t), intent(in) :: Iosystem type (IO_desc_t) :: ioDesc select case (Iosystem%rearr) case (PIO_rearr_mct) #ifdef _USEMCT call mct_rearrange_free(ioDesc) ! mctrearrange #else call die_nomct( __PIO_FILE__,__LINE__) #endif #ifdef _USEBOX case (PIO_rearr_box) call box_rearrange_free(Iosystem,ioDesc) #endif case (PIO_rearr_none) ! do nothing case default call piodie(__PIO_FILE__,__LINE__,'Unrecognized rearranger:',Iosystem%rearr) end select end subroutine rearrange_free_ end module rearrange