diff --git a/mpp/include/group_update_pack.inc b/mpp/include/group_update_pack.inc index 98b7645836..de08b89e56 100644 --- a/mpp/include/group_update_pack.inc +++ b/mpp/include/group_update_pack.inc @@ -17,8 +17,9 @@ !*********************************************************************** if( group%k_loop_inside ) then -!$OMP parallel do default(none) shared(buffer,npack,group,nvector,ksize,buffer_start_pos) & -!$OMP private(buffer_pos,pos,m,is,ie,js,je,rotation,n,k) +!$OMP parallel do default(none) shared(npack,group,ptr,nvector,ksize,buffer_start_pos) & +!$OMP private(buffer_pos,pos,m,is,ie,js,je,rotation, & +!$OMP ptr_field, ptr_fieldx, ptr_fieldy,n,k) do n = 1, npack buffer_pos = group%pack_buffer_pos(n) + buffer_start_pos pos = buffer_pos @@ -29,48 +30,48 @@ if( group%k_loop_inside ) then select case( rotation ) case(ZERO) do l=1, group%nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do k = 1, ksize do j = js, je do i = is, ie pos = pos + 1 - !buffer(pos) = field(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_S, l, i, j, k) + buffer(pos) = field(i,j,k) end do end do enddo enddo case( MINUS_NINETY ) do l=1,group%nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do k = 1, ksize do i = is, ie do j = je, js, -1 pos = pos + 1 - !buffer(pos) = field(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_S, l, i, j, k) + buffer(pos) = field(i,j,k) end do end do end do end do case( NINETY ) do l=1,group%nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do k = 1, ksize do i = ie, is, -1 do j = js, je pos = pos + 1 - !buffer(pos) = field(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_S, l, i, j, k) + buffer(pos) = field(i,j,k) end do end do end do end do case( ONE_HUNDRED_EIGHTY ) do l=1,group%nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do k = 1, ksize do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = field(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_S, l, i, j, k) + buffer(pos) = field(i,j,k) end do end do end do @@ -80,12 +81,12 @@ if( group%k_loop_inside ) then select case( rotation ) case(ZERO) do l=1, nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do k = 1, ksize do j = js, je do i = is, ie pos = pos + 1 - !buffer(pos) = fieldx(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = fieldx(i,j,k) end do end do end do @@ -93,24 +94,24 @@ if( group%k_loop_inside ) then case( MINUS_NINETY ) if( BTEST(group%flags_v,SCALAR_BIT) ) then do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do k = 1, ksize do i = is, ie do j = je, js, -1 pos = pos + 1 - !buffer(pos) = fieldy(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = fieldy(i,j,k) end do end do end do end do else do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do k = 1, ksize do i = is, ie do j = je, js, -1 pos = pos + 1 - !buffer(pos) = -fieldy(i,j,k) - buffer(pos) = - GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = -fieldy(i,j,k) end do end do end do @@ -118,12 +119,12 @@ if( group%k_loop_inside ) then end if case( NINETY ) do l=1, nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do k = 1, ksize do i = ie, is, -1 do j = js, je pos = pos + 1 - !buffer(pos) = fieldy(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = fieldy(i,j,k) end do end do end do @@ -131,24 +132,24 @@ if( group%k_loop_inside ) then case( ONE_HUNDRED_EIGHTY ) if( BTEST(group%flags_v,SCALAR_BIT) ) then do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do k = 1, ksize do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = fieldx(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = fieldx(i,j,k) end do end do end do end do else do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do k = 1, ksize do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = -fieldx(i,j,k) - buffer(pos) = - GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = -fieldx(i,j,k) end do end do end do @@ -159,24 +160,24 @@ if( group%k_loop_inside ) then select case( rotation ) case(ZERO) do l=1, nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do k = 1, ksize do j = js, je do i = is, ie pos = pos + 1 - !buffer(pos) = fieldy(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = fieldy(i,j,k) end do end do end do end do case( MINUS_NINETY ) do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do k = 1, ksize do i = is, ie do j = je, js, -1 pos = pos + 1 - !buffer(pos) = fieldx(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = fieldx(i,j,k) end do end do end do @@ -184,24 +185,24 @@ if( group%k_loop_inside ) then case( NINETY ) if( BTEST(group%flags_v,SCALAR_BIT) ) then do l=1, nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do k = 1, ksize do i = ie, is, -1 do j = js, je pos = pos + 1 - !buffer(pos) = fieldx(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = fieldx(i,j,k) end do end do end do end do else do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do k = 1, ksize do i = ie, is, -1 do j = js, je pos = pos + 1 - !buffer(pos) = -fieldx(i,j,k) - buffer(pos) = - GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = -fieldx(i,j,k) end do end do end do @@ -210,24 +211,24 @@ if( group%k_loop_inside ) then case( ONE_HUNDRED_EIGHTY ) if( BTEST(group%flags_v,SCALAR_BIT) ) then do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do k = 1, ksize do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = fieldy(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = fieldy(i,j,k) end do end do end do end do else do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do k = 1, ksize do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = -fieldy(i,j,k) - buffer(pos) = - GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = -fieldy(i,j,k) end do end do end do @@ -237,8 +238,9 @@ if( group%k_loop_inside ) then endif enddo else -!$OMP parallel do default(none) shared(buffer,npack,group,nvector,ksize,buffer_start_pos) & -!$OMP private(buffer_pos,pos,m,is,ie,js,je,rotation,n,k) +!$OMP parallel do default(none) shared(npack,group,ptr,nvector,ksize,buffer_start_pos) & +!$OMP private(buffer_pos,pos,m,is,ie,js,je,rotation, & +!$OMP ptr_field, ptr_fieldx, ptr_fieldy,n,k) do nk = 1, npack*ksize n = (nk-1)/ksize + 1 k = mod((nk-1), ksize) + 1 @@ -251,41 +253,41 @@ else select case( rotation ) case(ZERO) do l=1, group%nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do j = js, je do i = is, ie pos = pos + 1 - !buffer(pos) = field(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_S, l, i, j, k) + buffer(pos) = field(i,j,k) end do end do enddo case( MINUS_NINETY ) do l=1,group%nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do i = is, ie do j = je, js, -1 pos = pos + 1 - !buffer(pos) = field(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_S, l, i, j, k) + buffer(pos) = field(i,j,k) end do end do end do case( NINETY ) do l=1,group%nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do i = ie, is, -1 do j = js, je pos = pos + 1 - !buffer(pos) = field(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_S, l, i, j, k) + buffer(pos) = field(i,j,k) end do end do end do case( ONE_HUNDRED_EIGHTY ) do l=1,group%nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = field(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_S, l, i, j, k) + buffer(pos) = field(i,j,k) end do end do end do @@ -294,64 +296,64 @@ else select case( rotation ) case(ZERO) do l=1, nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do j = js, je do i = is, ie pos = pos + 1 - !buffer(pos) = fieldx(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = fieldx(i,j,k) end do end do end do case( MINUS_NINETY ) if( BTEST(group%flags_v,SCALAR_BIT) ) then do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do i = is, ie do j = je, js, -1 pos = pos + 1 - !buffer(pos) = fieldy(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = fieldy(i,j,k) end do end do end do else do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do i = is, ie do j = je, js, -1 pos = pos + 1 - !buffer(pos) = -fieldy(i,j,k) - buffer(pos) = - GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = -fieldy(i,j,k) end do end do end do end if case( NINETY ) do l=1, nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do i = ie, is, -1 do j = js, je pos = pos + 1 - !buffer(pos) = fieldy(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = fieldy(i,j,k) end do end do end do case( ONE_HUNDRED_EIGHTY ) if( BTEST(group%flags_v,SCALAR_BIT) ) then do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = fieldx(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = fieldx(i,j,k) end do end do end do else do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = -fieldx(i,j,k) - buffer(pos) = - GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = -fieldx(i,j,k) end do end do end do @@ -361,42 +363,42 @@ else select case( rotation ) case(ZERO) do l=1, nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do j = js, je do i = is, ie pos = pos + 1 - !buffer(pos) = fieldy(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = fieldy(i,j,k) end do end do end do case( MINUS_NINETY ) do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do i = is, ie do j = je, js, -1 pos = pos + 1 - !buffer(pos) = fieldx(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = fieldx(i,j,k) end do end do end do case( NINETY ) if( BTEST(group%flags_v,SCALAR_BIT) ) then do l=1, nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do i = ie, is, -1 do j = js, je pos = pos + 1 - !buffer(pos) = fieldx(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = fieldx(i,j,k) end do end do end do else do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do i = ie, is, -1 do j = js, je pos = pos + 1 - !buffer(pos) = -fieldx(i,j,k) - buffer(pos) = - GET_VALUE_ (group, FIELD_X, l, i, j, k) + buffer(pos) = -fieldx(i,j,k) end do end do end do @@ -404,21 +406,21 @@ else case( ONE_HUNDRED_EIGHTY ) if( BTEST(group%flags_v,SCALAR_BIT) ) then do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = fieldy(i,j,k) - buffer(pos) = GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = fieldy(i,j,k) end do end do end do else do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do j = je, js, -1 do i = ie, is, -1 pos = pos + 1 - !buffer(pos) = -fieldy(i,j,k) - buffer(pos) = - GET_VALUE_ (group, FIELD_Y, l, i, j, k) + buffer(pos) = -fieldy(i,j,k) end do end do end do diff --git a/mpp/include/group_update_unpack.inc b/mpp/include/group_update_unpack.inc index 06c8a36bed..49fb2555ce 100644 --- a/mpp/include/group_update_unpack.inc +++ b/mpp/include/group_update_unpack.inc @@ -17,8 +17,9 @@ !*********************************************************************** if( group%k_loop_inside ) then -!$OMP parallel do default(none) shared(buffer,nunpack,group,nscalar,nvector,ksize,buffer_start_pos) & -!$OMP private(buffer_pos,pos,m,is, ie, js, je,rotation,n,k ) +!$OMP parallel do default(none) shared(nunpack,group,nscalar,ptr,nvector,ksize,buffer_start_pos) & +!$OMP private(buffer_pos,pos,m,is, ie, js, je,rotation, & +!$OMP ptr_field, ptr_fieldx, ptr_fieldy, n,k ) do n = nunpack, 1, -1 buffer_pos = group%unpack_buffer_pos(n) + buffer_start_pos pos = buffer_pos @@ -26,36 +27,36 @@ if( group%k_loop_inside ) then js = group%unpack_js(n); je = group%unpack_je(n) if( group%unpack_type(n) == FIELD_S ) then do l=1,nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do k = 1, ksize do j = js, je do i = is, ie pos = pos + 1 - !field(i,j,k) = buffer(pos) - call SET_VALUE_ (group, FIELD_S, l, i, j, k, buffer(pos)) + field(i,j,k) = buffer(pos) end do end do end do end do else if( group%unpack_type(n) == FIELD_X ) then do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do k = 1, ksize do j = js, je do i = is, ie pos = pos + 1 - !fieldx(i,j,k) = buffer(pos) - call SET_VALUE_ (group, FIELD_X, l, i, j, k, buffer(pos)) + fieldx(i,j,k) = buffer(pos) end do end do end do end do else if( group%unpack_type(n) == FIELD_Y ) then do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do k = 1, ksize do j = js, je do i = is, ie pos = pos + 1 - !fieldy(i,j,k) = buffer(pos) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, buffer(pos)) + fieldy(i,j,k) = buffer(pos) end do end do end do @@ -63,8 +64,9 @@ if( group%k_loop_inside ) then endif enddo else -!$OMP parallel do default(none) shared(buffer,nunpack,group,nscalar,nvector,ksize,buffer_start_pos) & -!$OMP private(buffer_pos,pos,m,is, ie, js, je,rotation,n,k) +!$OMP parallel do default(none) shared(nunpack,group,nscalar,ptr,nvector,ksize,buffer_start_pos) & +!$OMP private(buffer_pos,pos,m,is, ie, js, je,rotation, & +!$OMP ptr_field, ptr_fieldx, ptr_fieldy,n,k) do nk = nunpack*ksize, 1, -1 n = (nk-1)/ksize + 1 k = mod((nk-1), ksize) + 1 @@ -74,31 +76,31 @@ else js = group%unpack_js(n); je = group%unpack_je(n) if( group%unpack_type(n) == FIELD_S ) then do l=1,nscalar ! loop over number of fields + ptr_field = group%addrs_s(l) do j = js, je do i = is, ie pos = pos + 1 - !field(i,j,k) = buffer(pos) - call SET_VALUE_ (group, FIELD_S, l, i, j, k, buffer(pos)) + field(i,j,k) = buffer(pos) end do end do end do else if( group%unpack_type(n) == FIELD_X ) then do l=1,nvector ! loop over number of fields + ptr_fieldx = group%addrs_x(l) do j = js, je do i = is, ie pos = pos + 1 - !fieldx(i,j,k) = buffer(pos) - call SET_VALUE_ (group, FIELD_X, l, i, j, k, buffer(pos)) + fieldx(i,j,k) = buffer(pos) end do end do end do else if( group%unpack_type(n) == FIELD_Y ) then do l=1,nvector ! loop over number of fields + ptr_fieldy = group%addrs_y(l) do j = js, je do i = is, ie pos = pos + 1 - !fieldy(i,j,k) = buffer(pos) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, buffer(pos)) + fieldy(i,j,k) = buffer(pos) end do end do end do diff --git a/mpp/include/mpp_domains_misc.inc b/mpp/include/mpp_domains_misc.inc index cf26a466b2..fe13a75867 100644 --- a/mpp/include/mpp_domains_misc.inc +++ b/mpp/include/mpp_domains_misc.inc @@ -1956,46 +1956,70 @@ end subroutine init_nonblock_type #define MPP_TYPE_ real(r8_kind) #undef MPI_TYPE_ #define MPI_TYPE_ MPI_REAL8 -#undef MPP_CREATE_GROUP_UPDATE_ -#define MPP_CREATE_GROUP_UPDATE_ mpp_create_group_update_r8 -#undef MPP_CREATE_GROUP_UPDATE_V_ -#define MPP_CREATE_GROUP_UPDATE_V_ mpp_create_group_update_r8_v +#undef MPP_CREATE_GROUP_UPDATE_2D_ +#define MPP_CREATE_GROUP_UPDATE_2D_ mpp_create_group_update_r8_2d +#undef MPP_CREATE_GROUP_UPDATE_3D_ +#define MPP_CREATE_GROUP_UPDATE_3D_ mpp_create_group_update_r8_3d +#undef MPP_CREATE_GROUP_UPDATE_4D_ +#define MPP_CREATE_GROUP_UPDATE_4D_ mpp_create_group_update_r8_4d +#undef MPP_CREATE_GROUP_UPDATE_2D_V_ +#define MPP_CREATE_GROUP_UPDATE_2D_V_ mpp_create_group_update_r8_2dv +#undef MPP_CREATE_GROUP_UPDATE_3D_V_ +#define MPP_CREATE_GROUP_UPDATE_3D_V_ mpp_create_group_update_r8_3dv +#undef MPP_CREATE_GROUP_UPDATE_4D_V_ +#define MPP_CREATE_GROUP_UPDATE_4D_V_ mpp_create_group_update_r8_4dv #undef MPP_DO_GROUP_UPDATE_ #define MPP_DO_GROUP_UPDATE_ mpp_do_group_update_r8 #undef MPP_START_GROUP_UPDATE_ #define MPP_START_GROUP_UPDATE_ mpp_start_group_update_r8 #undef MPP_COMPLETE_GROUP_UPDATE_ #define MPP_COMPLETE_GROUP_UPDATE_ mpp_complete_group_update_r8 -#undef MPP_RESET_GROUP_UPDATE_FIELD_ -#define MPP_RESET_GROUP_UPDATE_FIELD_ mpp_reset_group_update_field_r8 -#undef MPP_RESET_GROUP_UPDATE_FIELD_V_ -#define MPP_RESET_GROUP_UPDATE_FIELD_V_ mpp_reset_group_update_field_r8_v -#undef GET_VALUE_ -#define GET_VALUE_ get_value_r8 -#undef SET_VALUE_ -#define SET_VALUE_ set_value_r8 +#undef MPP_RESET_GROUP_UPDATE_FIELD_2D_ +#define MPP_RESET_GROUP_UPDATE_FIELD_2D_ mpp_reset_group_update_field_r8_2d +#undef MPP_RESET_GROUP_UPDATE_FIELD_3D_ +#define MPP_RESET_GROUP_UPDATE_FIELD_3D_ mpp_reset_group_update_field_r8_3d +#undef MPP_RESET_GROUP_UPDATE_FIELD_4D_ +#define MPP_RESET_GROUP_UPDATE_FIELD_4D_ mpp_reset_group_update_field_r8_4d +#undef MPP_RESET_GROUP_UPDATE_FIELD_2D_V_ +#define MPP_RESET_GROUP_UPDATE_FIELD_2D_V_ mpp_reset_group_update_field_r8_2dv +#undef MPP_RESET_GROUP_UPDATE_FIELD_3D_V_ +#define MPP_RESET_GROUP_UPDATE_FIELD_3D_V_ mpp_reset_group_update_field_r8_3dv +#undef MPP_RESET_GROUP_UPDATE_FIELD_4D_V_ +#define MPP_RESET_GROUP_UPDATE_FIELD_4D_V_ mpp_reset_group_update_field_r8_4dv #include #undef MPP_TYPE_ #define MPP_TYPE_ real(r4_kind) #undef MPI_TYPE_ #define MPI_TYPE_ MPI_REAL4 -#undef MPP_CREATE_GROUP_UPDATE_ -#define MPP_CREATE_GROUP_UPDATE_ mpp_create_group_update_r4 -#undef MPP_CREATE_GROUP_UPDATE_V_ -#define MPP_CREATE_GROUP_UPDATE_V_ mpp_create_group_update_r4_v +#undef MPP_CREATE_GROUP_UPDATE_2D_ +#define MPP_CREATE_GROUP_UPDATE_2D_ mpp_create_group_update_r4_2d +#undef MPP_CREATE_GROUP_UPDATE_3D_ +#define MPP_CREATE_GROUP_UPDATE_3D_ mpp_create_group_update_r4_3d +#undef MPP_CREATE_GROUP_UPDATE_4D_ +#define MPP_CREATE_GROUP_UPDATE_4D_ mpp_create_group_update_r4_4d +#undef MPP_CREATE_GROUP_UPDATE_2D_V_ +#define MPP_CREATE_GROUP_UPDATE_2D_V_ mpp_create_group_update_r4_2dv +#undef MPP_CREATE_GROUP_UPDATE_3D_V_ +#define MPP_CREATE_GROUP_UPDATE_3D_V_ mpp_create_group_update_r4_3dv +#undef MPP_CREATE_GROUP_UPDATE_4D_V_ +#define MPP_CREATE_GROUP_UPDATE_4D_V_ mpp_create_group_update_r4_4dv #undef MPP_DO_GROUP_UPDATE_ #define MPP_DO_GROUP_UPDATE_ mpp_do_group_update_r4 #undef MPP_START_GROUP_UPDATE_ #define MPP_START_GROUP_UPDATE_ mpp_start_group_update_r4 #undef MPP_COMPLETE_GROUP_UPDATE_ #define MPP_COMPLETE_GROUP_UPDATE_ mpp_complete_group_update_r4 -#undef MPP_RESET_GROUP_UPDATE_FIELD_ -#define MPP_RESET_GROUP_UPDATE_FIELD_ mpp_reset_group_update_field_r4 -#undef MPP_RESET_GROUP_UPDATE_FIELD_V_ -#define MPP_RESET_GROUP_UPDATE_FIELD_V_ mpp_reset_group_update_field_r4_v -#undef GET_VALUE_ -#define GET_VALUE_ get_value_r4 -#undef SET_VALUE_ -#define SET_VALUE_ set_value_r4 +#undef MPP_RESET_GROUP_UPDATE_FIELD_2D_ +#define MPP_RESET_GROUP_UPDATE_FIELD_2D_ mpp_reset_group_update_field_r4_2d +#undef MPP_RESET_GROUP_UPDATE_FIELD_3D_ +#define MPP_RESET_GROUP_UPDATE_FIELD_3D_ mpp_reset_group_update_field_r4_3d +#undef MPP_RESET_GROUP_UPDATE_FIELD_4D_ +#define MPP_RESET_GROUP_UPDATE_FIELD_4D_ mpp_reset_group_update_field_r4_4d +#undef MPP_RESET_GROUP_UPDATE_FIELD_2D_V_ +#define MPP_RESET_GROUP_UPDATE_FIELD_2D_V_ mpp_reset_group_update_field_r4_2dv +#undef MPP_RESET_GROUP_UPDATE_FIELD_3D_V_ +#define MPP_RESET_GROUP_UPDATE_FIELD_3D_V_ mpp_reset_group_update_field_r4_3dv +#undef MPP_RESET_GROUP_UPDATE_FIELD_4D_V_ +#define MPP_RESET_GROUP_UPDATE_FIELD_4D_V_ mpp_reset_group_update_field_r4_4dv #include diff --git a/mpp/include/mpp_group_update.fh b/mpp/include/mpp_group_update.fh index c84325ac6c..8a10b1eb13 100644 --- a/mpp/include/mpp_group_update.fh +++ b/mpp/include/mpp_group_update.fh @@ -18,15 +18,34 @@ ! -*-f90-*- !> @addtogroup mpp_domains_mod !> @{ -subroutine MPP_CREATE_GROUP_UPDATE_(group, field, domain, flags, position, whalo, ehalo, shalo, nhalo, xdim, ydim) +subroutine MPP_CREATE_GROUP_UPDATE_2D_(group, field, domain, flags, position, & + whalo, ehalo, shalo, nhalo, xdim, ydim) type(mpp_group_update_type), intent(inout) :: group - MPP_TYPE_, intent(inout), target :: field(..) + MPP_TYPE_, intent(inout) :: field(:,:) + type(domain2D), intent(inout) :: domain + integer, intent(in), optional :: flags + integer, intent(in), optional :: position + integer, intent(in), optional :: whalo, ehalo, shalo, nhalo + integer, intent(in), optional :: xdim, ydim + + MPP_TYPE_ :: field3D(size(field,1),size(field,2),1) + pointer( ptr, field3D ) + ptr = LOC(field) + + call mpp_create_group_update(group, field3D, domain, flags, position, whalo, ehalo, shalo, nhalo) + + return + +end subroutine MPP_CREATE_GROUP_UPDATE_2D_ + +subroutine MPP_CREATE_GROUP_UPDATE_3D_(group, field, domain, flags, position, whalo, ehalo, shalo, nhalo, xdim, ydim) + type(mpp_group_update_type), intent(inout) :: group + MPP_TYPE_, intent(inout) :: field(:,:,:) type(domain2D), intent(inout) :: domain integer, intent(in), optional :: flags integer, intent(in), optional :: position integer, intent(in), optional :: whalo, ehalo, shalo, nhalo ! specify halo region to be updated. - integer, intent(in), optional :: xdim, ydim !< Domain-decomposed dimensions. If not specified, it is assumed - !! that the first two dimensions are x and y respectively. + integer, intent(in), optional :: xdim, ydim integer :: update_position, update_whalo, update_ehalo, update_shalo, update_nhalo integer :: update_flags, isize, jsize, ksize @@ -34,18 +53,11 @@ subroutine MPP_CREATE_GROUP_UPDATE_(group, field, domain, flags, position, whalo character(len=3) :: text logical :: set_mismatch, update_edge_only logical :: recv(8) - integer :: ix, iy if(group%initialized) then call mpp_error(FATAL, "MPP_CREATE_GROUP_UPDATE_3D: group is already initialized") endif - ix = 1 - iy = 2 - - if (present(xdim)) ix=xdim - if (present(ydim)) iy=ydim - if(present(whalo)) then update_whalo = whalo if(abs(update_whalo) > domain%whalo ) call mpp_error(FATAL, "MPP_CREATE_GROUP_UPDATE: "// & @@ -97,10 +109,9 @@ subroutine MPP_CREATE_GROUP_UPDATE_(group, field, domain, flags, position, whalo call mpp_error(FATAL,'MPP_CREATE_GROUP_UPDATE: MAX_DOMAIN_FIELDS='//text//' exceeded for group update.' ) endif - isize = size(field,ix); jsize=size(field,iy); ksize = size(field) / (isize*jsize) - - group%addrs_s(nscalar) = c_loc(field) + isize = size(field,1); jsize=size(field,2); ksize = size(field,3) + group%addrs_s(nscalar) = LOC(field) if( group%nscalar == 1 ) then group%flags_s = update_flags group%whalo_s = update_whalo @@ -111,13 +122,8 @@ subroutine MPP_CREATE_GROUP_UPDATE_(group, field, domain, flags, position, whalo group%isize_s = isize group%jsize_s = jsize group%ksize_s = ksize - group%ix_s = ix - group%iy_s = iy call mpp_get_memory_domain(domain, group%is_s, group%ie_s, group%js_s, group%je_s, position=position) - allocate (group%shape_s(rank(field))) - group%shape_s = shape(field) - update_edge_only = BTEST(update_flags, EDGEONLY) recv(1) = BTEST(update_flags,EAST) recv(3) = BTEST(update_flags,SOUTH) @@ -159,13 +165,60 @@ subroutine MPP_CREATE_GROUP_UPDATE_(group, field, domain, flags, position, whalo endif endif -end subroutine MPP_CREATE_GROUP_UPDATE_ + return + +end subroutine MPP_CREATE_GROUP_UPDATE_3D_ + + +subroutine MPP_CREATE_GROUP_UPDATE_4D_(group, field, domain, flags, position, & + whalo, ehalo, shalo, nhalo, xdim, ydim) + type(mpp_group_update_type), intent(inout) :: group + MPP_TYPE_, intent(inout) :: field(:,:,:,:) + type(domain2D), intent(inout) :: domain + integer, intent(in), optional :: flags + integer, intent(in), optional :: position + integer, intent(in), optional :: whalo, ehalo, shalo, nhalo + integer, intent(in), optional :: xdim, ydim + + MPP_TYPE_ :: field3D(size(field,1),size(field,2),size(field,3)*size(field,4)) + pointer( ptr, field3D ) + ptr = LOC(field) + + call mpp_create_group_update(group, field3D, domain, flags, position, whalo, ehalo, shalo, nhalo) + + return +end subroutine MPP_CREATE_GROUP_UPDATE_4D_ -subroutine MPP_CREATE_GROUP_UPDATE_V_( group, fieldx, fieldy, domain, flags, gridtype, & +subroutine MPP_CREATE_GROUP_UPDATE_2D_V_( group, fieldx, fieldy, domain, flags, gridtype, & + whalo, ehalo, shalo, nhalo, xdim, ydim) + + type(mpp_group_update_type), intent(inout) :: group + MPP_TYPE_, intent(inout) :: fieldx(:,:), fieldy(:,:) + type(domain2D), intent(inout) :: domain + integer, intent(in), optional :: flags, gridtype + integer, intent(in), optional :: whalo, ehalo, shalo, nhalo + integer, intent(in), optional :: xdim, ydim + MPP_TYPE_ :: field3Dx(size(fieldx,1),size(fieldx,2),1) + MPP_TYPE_ :: field3Dy(size(fieldy,1),size(fieldy,2),1) + pointer( ptrx, field3Dx ) + pointer( ptry, field3Dy ) + ptrx = LOC(fieldx) + ptry = LOC(fieldy) + + call mpp_create_group_update(group, field3Dx, field3Dy, domain, flags, gridtype, & + whalo, ehalo, shalo, nhalo) + + return + +end subroutine MPP_CREATE_GROUP_UPDATE_2D_V_ + + + +subroutine MPP_CREATE_GROUP_UPDATE_3D_V_( group, fieldx, fieldy, domain, flags, gridtype, & whalo, ehalo, shalo, nhalo, xdim, ydim) type(mpp_group_update_type), intent(inout) :: group - MPP_TYPE_, intent(inout), target :: fieldx(..), fieldy(..) + MPP_TYPE_, intent(inout) :: fieldx(:,:,:), fieldy(:,:,:) type(domain2D), intent(inout) :: domain integer, intent(in), optional :: flags, gridtype integer, intent(in), optional :: whalo, ehalo, shalo, nhalo @@ -177,19 +230,12 @@ subroutine MPP_CREATE_GROUP_UPDATE_V_( group, fieldx, fieldy, domain, flags, gri character(len=3) :: text logical :: set_mismatch, update_edge_only logical :: recv(8) - integer :: ix, iy if(group%initialized) then call mpp_error(FATAL, "MPP_CREATE_GROUP_UPDATE_V: group is already initialized") endif - ix = 1 - iy = 2 - - if (present(xdim)) ix=xdim - if (present(ydim)) iy=ydim - if(present(whalo)) then update_whalo = whalo if(abs(update_whalo) > domain%whalo ) call mpp_error(FATAL, "MPP_CREATE_GROUP_UPDATE_V: "// & @@ -243,14 +289,14 @@ subroutine MPP_CREATE_GROUP_UPDATE_V_( group, fieldx, fieldy, domain, flags, gri call mpp_error(FATAL,'MPP_CREATE_GROUP_UPDATE_V: MAX_DOMAIN_FIELDS='//text//' exceeded for group update.' ) endif - isize_x = size(fieldx,ix); jsize_x = size(fieldx,iy); ksize_x = size(fieldx) / (isize_x*jsize_x) - isize_y = size(fieldy,ix); jsize_y = size(fieldy,iy); ksize_y = size(fieldy) / (isize_y*jsize_y) + isize_x = size(fieldx,1); jsize_x = size(fieldx,2); ksize_x = size(fieldx,3) + isize_y = size(fieldy,1); jsize_y = size(fieldy,2); ksize_y = size(fieldy,3) if(ksize_x .NE. ksize_y) call mpp_error(FATAL, & 'MPP_CREATE_GROUP_UPDATE_V: mismatch of ksize between fieldx and fieldy') - group%addrs_x(nvector) = c_loc(fieldx) - group%addrs_y(nvector) = c_loc(fieldy) + group%addrs_x(nvector) = LOC(fieldx) + group%addrs_y(nvector) = LOC(fieldy) if( group%nvector == 1 ) then group%flags_v = update_flags @@ -264,8 +310,6 @@ subroutine MPP_CREATE_GROUP_UPDATE_V_( group, fieldx, fieldy, domain, flags, gri group%isize_y = isize_y group%jsize_y = jsize_y group%ksize_v = ksize_x - group%ix_v = ix - group%iy_v = iy update_edge_only = BTEST(update_flags, EDGEONLY) group%nonsym_edge = .false. @@ -332,12 +376,6 @@ subroutine MPP_CREATE_GROUP_UPDATE_V_( group, fieldx, fieldy, domain, flags, gri call mpp_get_memory_domain(domain, group%is_x, group%ie_x, group%js_x, group%je_x, position=position_x) call mpp_get_memory_domain(domain, group%is_y, group%ie_y, group%js_y, group%je_y, position=position_y) - - allocate (group%shape_x(rank(fieldx))) - group%shape_x = shape(fieldx) - - allocate (group%shape_y(rank(fieldy))) - group%shape_y = shape(fieldy) else set_mismatch = .false. set_mismatch = set_mismatch .OR. (group%flags_v .NE. update_flags) @@ -358,7 +396,32 @@ subroutine MPP_CREATE_GROUP_UPDATE_V_( group, fieldx, fieldy, domain, flags, gri endif endif -end subroutine MPP_CREATE_GROUP_UPDATE_V_ + return + +end subroutine MPP_CREATE_GROUP_UPDATE_3D_V_ + +subroutine MPP_CREATE_GROUP_UPDATE_4D_V_( group, fieldx, fieldy, domain, flags, gridtype, & + whalo, ehalo, shalo, nhalo, xdim, ydim) + + type(mpp_group_update_type), intent(inout) :: group + MPP_TYPE_, intent(inout) :: fieldx(:,:,:,:), fieldy(:,:,:,:) + type(domain2D), intent(inout) :: domain + integer, intent(in), optional :: flags, gridtype + integer, intent(in), optional :: whalo, ehalo, shalo, nhalo + integer, intent(in), optional :: xdim, ydim + MPP_TYPE_ :: field3Dx(size(fieldx,1),size(fieldx,2),size(fieldx,3)*size(fieldx,4)) + MPP_TYPE_ :: field3Dy(size(fieldy,1),size(fieldy,2),size(fieldy,3)*size(fieldy,4)) + pointer( ptrx, field3Dx ) + pointer( ptry, field3Dy ) + ptrx = LOC(fieldx) + ptry = LOC(fieldy) + + call mpp_create_group_update(group, field3Dx, field3Dy, domain, flags, gridtype, & + whalo, ehalo, shalo, nhalo) + + return + +end subroutine MPP_CREATE_GROUP_UPDATE_4D_V_ subroutine MPP_DO_GROUP_UPDATE_(group, domain, d_type) @@ -366,7 +429,7 @@ subroutine MPP_DO_GROUP_UPDATE_(group, domain, d_type) type(domain2D), intent(inout) :: domain MPP_TYPE_, intent(in) :: d_type - integer :: nscalar, nvector + integer :: nscalar, nvector, nlist logical :: recv_y(8) integer :: nsend, nrecv, flags_v integer :: msgsize @@ -375,13 +438,19 @@ subroutine MPP_DO_GROUP_UPDATE_(group, domain, d_type) integer :: n, l, m, i, j, k, buffer_start_pos, nk integer :: shift, gridtype, midpoint integer :: npack, nunpack, rotation, isd - type(c_ptr) :: stack_cptr !< Workaround for GFortran bug - MPP_TYPE_, pointer :: buffer(:) - MPP_TYPE_, parameter :: zero_ = 0. + MPP_TYPE_ :: buffer(mpp_domains_stack_size) + MPP_TYPE_ :: field (group%is_s:group%ie_s,group%js_s:group%je_s, group%ksize_s) + MPP_TYPE_ :: fieldx(group%is_x:group%ie_x,group%js_x:group%je_x, group%ksize_v) + MPP_TYPE_ :: fieldy(group%is_y:group%ie_y,group%js_y:group%je_y, group%ksize_v) + pointer(ptr, buffer ) + pointer(ptr_field, field) + pointer(ptr_fieldx, fieldx) + pointer(ptr_fieldy, fieldy) nscalar = group%nscalar nvector = group%nvector + nlist = size(domain%list(:)) gridtype = group%gridtype !--- ksize_s must equal ksize_v @@ -399,8 +468,7 @@ subroutine MPP_DO_GROUP_UPDATE_(group, domain, d_type) endif if(nvector > 0) recv_y = group%recv_y - stack_cptr = c_loc(mpp_domains_stack(1)) - call c_f_pointer(stack_cptr, buffer, [mpp_domains_stack_size]) + ptr = LOC(mpp_domains_stack) !--- set reset_index_s and reset_index_v to 0 group%reset_index_s = 0 @@ -473,9 +541,11 @@ subroutine MPP_DO_GROUP_UPDATE_(group, domain, d_type) do i = is ,ie, midpoint if( domain%x(1)%domain_data%begin.LE.i .AND. i.LE. domain%x(1)%domain_data%end+shift )then do l=1,nvector + ptr_fieldx = group%addrs_x(l) + ptr_fieldy = group%addrs_y(l) do k = 1,ksize - call SET_VALUE_ (group, FIELD_X, l, i, j, k, zero_) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, zero_) + fieldx(i,j,k) = 0. + fieldy(i,j,k) = 0. end do end do end if @@ -498,12 +568,12 @@ subroutine MPP_DO_GROUP_UPDATE_(group, domain, d_type) if( 2*is-domain%x(1)%domain_data%begin.GT.domain%x(1)%domain_data%end+shift ) & call mpp_error( FATAL, 'MPP_DO_UPDATE_V: folded-north BGRID_NE west edge ubound error.' ) do l=1,nvector + ptr_fieldx = group%addrs_x(l) + ptr_fieldy = group%addrs_y(l) do k = 1,ksize do i = domain%x(1)%domain_data%begin,is-1 - !fieldx(i,j,k) = fieldx(2*is-i,j,k) - !fieldy(i,j,k) = fieldy(2*is-i,j,k) - call SET_VALUE_ (group, FIELD_X, l, i, j, k, GET_VALUE_ (group, FIELD_X, l, 2*is-i, j, k)) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, GET_VALUE_ (group, FIELD_Y, l, 2*is-i, j, k)) + fieldx(i,j,k) = fieldx(2*is-i,j,k) + fieldy(i,j,k) = fieldy(2*is-i,j,k) end do end do end do @@ -515,10 +585,10 @@ subroutine MPP_DO_GROUP_UPDATE_(group, domain, d_type) if( 2*is-domain%x(1)%domain_data%begin-1.GT.domain%x(1)%domain_data%end ) & call mpp_error( FATAL, 'MPP_DO_UPDATE_V: folded-north CGRID_NE west edge ubound error.' ) do l=1,nvector + ptr_fieldy = group%addrs_y(l) do k = 1,ksize do i = isd,is-1 - !fieldy(i,j,k) = fieldy(2*is-i-1,j,k) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, GET_VALUE_ (group, FIELD_Y, l, 2*is-i-1, j, k)) + fieldy(i,j,k) = fieldy(2*is-i-1,j,k) end do end do end do @@ -535,21 +605,21 @@ subroutine MPP_DO_GROUP_UPDATE_(group, domain, d_type) is = is + shift ie = ie + shift do l=1,nvector + ptr_fieldx = group%addrs_x(l) + ptr_fieldy = group%addrs_y(l) do k = 1,ksize do i = is,ie - !fieldx(i,j,k) = -fieldx(i,j,k) - !fieldy(i,j,k) = -fieldy(i,j,k) - call SET_VALUE_ (group, FIELD_X, l, i, j, k, - GET_VALUE_ (group, FIELD_X, l, i, j, k)) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, - GET_VALUE_ (group, FIELD_Y, l, i, j, k)) + fieldx(i,j,k) = -fieldx(i,j,k) + fieldy(i,j,k) = -fieldy(i,j,k) end do end do end do case(CGRID_NE) do l=1,nvector + ptr_fieldy = group%addrs_y(l) do k = 1,ksize do i = is, ie - !fieldy(i,j,k) = -fieldy(i,j,k) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, - GET_VALUE_ (group, FIELD_Y, l, i, j, k)) + fieldy(i,j,k) = -fieldy(i,j,k) end do end do end do @@ -584,9 +654,15 @@ subroutine MPP_START_GROUP_UPDATE_(group, domain, d_type, reuse_buffer) integer :: n, l, m, i, j, k, buffer_start_pos, nk logical :: reuse_buf_pos character(len=8) :: text - type(c_ptr) :: stack_cptr !< Workaround for GFortran bug - MPP_TYPE_, pointer :: buffer(:) + MPP_TYPE_ :: buffer(size(mpp_domains_stack_nonblock(:))) + MPP_TYPE_ :: field (group%is_s:group%ie_s,group%js_s:group%je_s, group%ksize_s) + MPP_TYPE_ :: fieldx(group%is_x:group%ie_x,group%js_x:group%je_x, group%ksize_v) + MPP_TYPE_ :: fieldy(group%is_y:group%ie_y,group%js_y:group%je_y, group%ksize_v) + pointer( ptr, buffer ) + pointer(ptr_field, field) + pointer(ptr_fieldx, fieldx) + pointer(ptr_fieldy, fieldy) nscalar = group%nscalar nvector = group%nvector @@ -625,8 +701,7 @@ subroutine MPP_START_GROUP_UPDATE_(group, domain, d_type, reuse_buffer) nrecv = group%nrecv nsend = group%nsend - stack_cptr = c_loc(mpp_domains_stack_nonblock(1)) - call c_f_pointer(stack_cptr, buffer, [size(mpp_domains_stack_nonblock)]) + ptr = LOC(mpp_domains_stack_nonblock) ! Make sure it is not in the middle of the old version of non-blocking halo update. if(num_update>0) call mpp_error(FATAL, "MPP_START_GROUP_UPDATE: can not be called in the middle of "// & @@ -682,10 +757,14 @@ subroutine MPP_COMPLETE_GROUP_UPDATE_(group, domain, d_type) integer :: shift, gridtype, midpoint, flags_v integer :: nunpack, rotation, buffer_start_pos, nk, isd logical :: recv_y(8) - type(c_ptr) :: stack_cptr !< Workaround for GFortran bug - - MPP_TYPE_, pointer :: buffer(:) - MPP_TYPE_, parameter :: zero_ = 0. + MPP_TYPE_ :: buffer(size(mpp_domains_stack_nonblock(:))) + MPP_TYPE_ :: field (group%is_s:group%ie_s,group%js_s:group%je_s, group%ksize_s) + MPP_TYPE_ :: fieldx(group%is_x:group%ie_x,group%js_x:group%je_x, group%ksize_v) + MPP_TYPE_ :: fieldy(group%is_y:group%ie_y,group%js_y:group%je_y, group%ksize_v) + pointer(ptr, buffer ) + pointer(ptr_field, field) + pointer(ptr_fieldx, fieldx) + pointer(ptr_fieldy, fieldy) gridtype = group%gridtype flags_v = group%flags_v @@ -699,9 +778,7 @@ subroutine MPP_COMPLETE_GROUP_UPDATE_(group, domain, d_type) ksize = group%ksize_v endif if(nvector > 0) recv_y = group%recv_y - - stack_cptr = c_loc(mpp_domains_stack_nonblock(1)) - call c_f_pointer(stack_cptr, buffer, [size(mpp_domains_stack_nonblock)]) + ptr = LOC(mpp_domains_stack_nonblock) if(num_nonblock_group_update < 1) call mpp_error(FATAL, & 'mpp_start_group_update must be called before calling mpp_end_group_update') @@ -738,9 +815,11 @@ subroutine MPP_COMPLETE_GROUP_UPDATE_(group, domain, d_type) do i = is ,ie, midpoint if( domain%x(1)%domain_data%begin.LE.i .AND. i.LE. domain%x(1)%domain_data%end+shift )then do l=1,nvector + ptr_fieldx = group%addrs_x(l) + ptr_fieldy = group%addrs_y(l) do k = 1,ksize - call SET_VALUE_ (group, FIELD_X, l, i, j, k, zero_) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, zero_) + fieldx(i,j,k) = 0. + fieldy(i,j,k) = 0. end do end do end if @@ -763,12 +842,12 @@ subroutine MPP_COMPLETE_GROUP_UPDATE_(group, domain, d_type) if( 2*is-domain%x(1)%domain_data%begin.GT.domain%x(1)%domain_data%end+shift ) & call mpp_error( FATAL, 'MPP_DO_UPDATE_V: folded-north BGRID_NE west edge ubound error.' ) do l=1,nvector + ptr_fieldx = group%addrs_x(l) + ptr_fieldy = group%addrs_y(l) do k = 1,ksize do i = domain%x(1)%domain_data%begin,is-1 - !fieldx(i,j,k) = fieldx(2*is-i,j,k) - !fieldy(i,j,k) = fieldy(2*is-i,j,k) - call SET_VALUE_ (group, FIELD_X, l, i, j, k, GET_VALUE_ (group, FIELD_X, l, 2*is-i, j, k)) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, GET_VALUE_ (group, FIELD_Y, l, 2*is-i, j, k)) + fieldx(i,j,k) = fieldx(2*is-i,j,k) + fieldy(i,j,k) = fieldy(2*is-i,j,k) end do end do end do @@ -780,10 +859,10 @@ subroutine MPP_COMPLETE_GROUP_UPDATE_(group, domain, d_type) if( 2*is-domain%x(1)%domain_data%begin-1.GT.domain%x(1)%domain_data%end ) & call mpp_error( FATAL, 'MPP_DO_UPDATE_V: folded-north CGRID_NE west edge ubound error.' ) do l=1,nvector + ptr_fieldy = group%addrs_y(l) do k = 1,ksize do i = isd,is-1 - !fieldy(i,j,k) = fieldy(2*is-i-1,j,k) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, GET_VALUE_ (group, FIELD_Y, l, 2*is-i-1, j, k)) + fieldy(i,j,k) = fieldy(2*is-i-1,j,k) end do end do end do @@ -800,21 +879,21 @@ subroutine MPP_COMPLETE_GROUP_UPDATE_(group, domain, d_type) is = is + shift ie = ie + shift do l=1,nvector + ptr_fieldx = group%addrs_x(l) + ptr_fieldy = group%addrs_y(l) do k = 1,ksize do i = is,ie - !fieldx(i,j,k) = -fieldx(i,j,k) - !fieldy(i,j,k) = -fieldy(i,j,k) - call SET_VALUE_ (group, FIELD_X, l, i, j, k, - GET_VALUE_ (group, FIELD_X, l, i, j, k)) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, - GET_VALUE_ (group, FIELD_Y, l, i, j, k)) + fieldx(i,j,k) = -fieldx(i,j,k) + fieldy(i,j,k) = -fieldy(i,j,k) end do end do end do case(CGRID_NE) do l=1,nvector + ptr_fieldy = group%addrs_y(l) do k = 1,ksize do i = is, ie - !fieldy(i,j,k) = -fieldy(i,j,k) - call SET_VALUE_ (group, FIELD_Y, l, i, j, k, - GET_VALUE_ (group, FIELD_Y, l, i, j, k)) + fieldy(i,j,k) = -fieldy(i,j,k) end do end do end do @@ -838,276 +917,114 @@ subroutine MPP_COMPLETE_GROUP_UPDATE_(group, domain, d_type) end subroutine MPP_COMPLETE_GROUP_UPDATE_ -subroutine MPP_RESET_GROUP_UPDATE_FIELD_(group, field) +subroutine MPP_RESET_GROUP_UPDATE_FIELD_2D_(group, field) type(mpp_group_update_type), intent(inout) :: group - MPP_TYPE_, target, intent(in) :: field(..) - integer :: isize, jsize, ksize + MPP_TYPE_, intent(in) :: field(:,:) group%reset_index_s = group%reset_index_s + 1 if(group%reset_index_s > group%nscalar) & - call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_: group%reset_index_s > group%nscalar") + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_2D_: group%reset_index_s > group%nscalar") + if(size(field,1) .NE. group%isize_s .OR. size(field,2) .NE. group%jsize_s .OR. group%ksize_s .NE. 1) & + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_2D_: size of field does not match the size stored in group") - isize = size(field, group%ix_s) - jsize = size(field, group%iy_s) - ksize = size(field) / (isize*jsize) + group%addrs_s(group%reset_index_s) = LOC(field) - if(isize.ne.group%isize_s .or. jsize.ne.group%jsize_s .or. ksize.ne.group%ksize_s) then - call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_: size of field does not match the size stored in group") - endif +end subroutine MPP_RESET_GROUP_UPDATE_FIELD_2D_ + +subroutine MPP_RESET_GROUP_UPDATE_FIELD_3D_(group, field) + type(mpp_group_update_type), intent(inout) :: group + MPP_TYPE_, intent(in) :: field(:,:,:) + + group%reset_index_s = group%reset_index_s + 1 + + if(group%reset_index_s > group%nscalar) & + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_3D_: group%reset_index_s > group%nscalar") + if(size(field,1) .NE. group%isize_s .OR. size(field,2) .NE. group%jsize_s .OR. size(field,3) .NE. group%ksize_s) & + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_3D_: size of field does not match the size stored in group") + + group%addrs_s(group%reset_index_s) = LOC(field) + +end subroutine MPP_RESET_GROUP_UPDATE_FIELD_3D_ + +subroutine MPP_RESET_GROUP_UPDATE_FIELD_4D_(group, field) + type(mpp_group_update_type), intent(inout) :: group + MPP_TYPE_, intent(in) :: field(:,:,:,:) + + group%reset_index_s = group%reset_index_s + 1 + + if(group%reset_index_s > group%nscalar) & + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_4D_: group%reset_index_s > group%nscalar") + if(size(field,1) .NE. group%isize_s .OR. size(field,2) .NE. group%jsize_s .OR. & + size(field,3)*size(field,4) .NE. group%ksize_s) & + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_4D_: size of field does not match the size stored in group") + + group%addrs_s(group%reset_index_s) = LOC(field) + +end subroutine MPP_RESET_GROUP_UPDATE_FIELD_4D_ - group%addrs_s(group%reset_index_s) = c_loc(field) -end subroutine MPP_RESET_GROUP_UPDATE_FIELD_ -subroutine MPP_RESET_GROUP_UPDATE_FIELD_V_(group, fieldx, fieldy) +subroutine MPP_RESET_GROUP_UPDATE_FIELD_2D_V_(group, fieldx, fieldy) type(mpp_group_update_type), intent(inout) :: group - MPP_TYPE_, target, intent(in) :: fieldx(..), fieldy(..) - integer :: isize_x, jsize_x, ksize_x - integer :: isize_y, jsize_y, ksize_y + MPP_TYPE_, intent(in) :: fieldx(:,:), fieldy(:,:) group%reset_index_v = group%reset_index_v + 1 if(group%reset_index_v > group%nvector) & - call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_V_: group%reset_index_v > group%nvector") + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_2D_V_: group%reset_index_v > group%nvector") + if(size(fieldx,1) .NE. group%isize_x .OR. size(fieldx,2) .NE. group%jsize_x .OR. group%ksize_v .NE. 1) & + call mpp_error(FATAL, & + & "MPP_RESET_GROUP_UPDATE_FIELD_2D_V_: size of fieldx does not match the size stored in group") + if(size(fieldy,1) .NE. group%isize_y .OR. size(fieldy,2) .NE. group%jsize_y ) & + call mpp_error(FATAL, & + & "MPP_RESET_GROUP_UPDATE_FIELD_2D_V_: size of fieldy does not match the size stored in group") - isize_x = size(fieldx, group%ix_v) - jsize_x = size(fieldx, group%iy_v) - ksize_x = size(fieldx) / (isize_x*jsize_x) + group%addrs_x(group%reset_index_v) = LOC(fieldx) + group%addrs_y(group%reset_index_v) = LOC(fieldy) - isize_y = size(fieldy, group%ix_v) - jsize_y = size(fieldy, group%iy_v) - ksize_y = size(fieldy) / (isize_y*jsize_y) +end subroutine MPP_RESET_GROUP_UPDATE_FIELD_2D_V_ - if(isize_x.ne.group%isize_x .or. jsize_x .ne. group%jsize_x .or. ksize_x .ne. group%ksize_v) then - call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_V_: size of fieldx does not match the size stored in group") - endif - if(isize_y.ne.group%isize_y .or. jsize_y .ne. group%jsize_y .or. ksize_y .ne. group%ksize_v) then - call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_V_: size of fieldy does not match the size stored in group") - endif +subroutine MPP_RESET_GROUP_UPDATE_FIELD_3D_V_(group, fieldx, fieldy) + type(mpp_group_update_type), intent(inout) :: group + MPP_TYPE_, intent(in) :: fieldx(:,:,:), fieldy(:,:,:) - group%addrs_x(group%reset_index_v) = c_loc(fieldx) - group%addrs_y(group%reset_index_v) = c_loc(fieldy) -end subroutine MPP_RESET_GROUP_UPDATE_FIELD_V_ - -function GET_VALUE_ (group, field_type, l, i, j, k) result(res) - type(mpp_group_update_type), intent(in), target :: group - integer, intent(in) :: field_type !< FIELD_S, FIELD_X, or FIELD_Y - integer, intent(in) :: l !< Index of the field within group - integer, intent(in) :: i, j, k !< i,j,k indices of the value to retrieve - MPP_TYPE_ :: res - - integer, allocatable, dimension(:) :: lb, n, indx - MPP_TYPE_, pointer :: field2d(:,:) - MPP_TYPE_, pointer :: field3d(:,:,:) - MPP_TYPE_, pointer :: field4d(:,:,:,:) - - integer :: ix, iy !< Indices of the domain-decomposed dimensions - integer :: is, ie, js, je !< Starting and ending indices of the x and y dimensions - integer :: nd, m, kp, d - - select case (field_type) - case (FIELD_S) - ix = group%ix_s - iy = group%iy_s - is = group%is_s - ie = group%ie_s - js = group%js_s - je = group%je_s - - nd = size(group%shape_s) - allocate (lb(nd), n(nd), indx(nd)) - - lb = 1 - n = group%shape_s - - select case(nd) - case (2) - call c_f_pointer(group%addrs_s(l), field2d, group%shape_s) - case (3) - call c_f_pointer(group%addrs_s(l), field3d, group%shape_s) - case (4) - call c_f_pointer(group%addrs_s(l), field4d, group%shape_s) - end select - case (FIELD_X) - ix = group%ix_v - iy = group%iy_v - is = group%is_x - ie = group%ie_x - js = group%js_x - je = group%je_x - - nd = size(group%shape_x) - allocate (lb(nd), n(nd), indx(nd)) - - lb = 1 - n = group%shape_x - - select case(nd) - case (2) - call c_f_pointer(group%addrs_x(l), field2d, group%shape_x) - case (3) - call c_f_pointer(group%addrs_x(l), field3d, group%shape_x) - case (4) - call c_f_pointer(group%addrs_x(l), field4d, group%shape_x) - end select - case (FIELD_Y) - ix = group%ix_v - iy = group%iy_v - is = group%is_y - ie = group%ie_y - js = group%js_y - je = group%je_y - - nd = size(group%shape_y) - allocate (lb(nd), n(nd), indx(nd)) - - lb = 1 - n = group%shape_y - - select case(nd) - case (2) - call c_f_pointer(group%addrs_y(l), field2d, group%shape_y) - case (3) - call c_f_pointer(group%addrs_y(l), field3d, group%shape_y) - case (4) - call c_f_pointer(group%addrs_y(l), field4d, group%shape_y) - end select - end select - - lb(ix) = i - is + 1 - lb(iy) = j - js + 1 - - n(ix) = 1 - n(iy) = 1 - - kp = k - 1 - do d=nd,1,-1 - m = product(n(1:d-1)) ! Product of all lower dimension sizes - indx(d) = kp / m - kp = kp - indx(d)*m - enddo + group%reset_index_v = group%reset_index_v + 1 - indx = lb + indx - - select case (nd) - case (2) - res = field2d(indx(1), indx(2)) - case (3) - res = field3d(indx(1), indx(2), indx(3)) - case (4) - res = field4d(indx(1), indx(2), indx(3), indx(4)) - end select -end function GET_VALUE_ - -subroutine SET_VALUE_ (group, field_type, l, i, j, k, x) - type(mpp_group_update_type), intent(in), target :: group - integer, intent(in) :: field_type !< FIELD_S, FIELD_X, or FIELD_Y - integer, intent(in) :: l !< Index of the field within group - integer, intent(in) :: i, j, k !< i,j,k indices of the value to retrieve - MPP_TYPE_, intent(in) :: x - - integer, allocatable, dimension(:) :: lb, n, indx - MPP_TYPE_, pointer :: field2d(:,:) - MPP_TYPE_, pointer :: field3d(:,:,:) - MPP_TYPE_, pointer :: field4d(:,:,:,:) - - integer :: ix, iy !< Indices of the domain-decomposed dimensions - integer :: is, ie, js, je !< Starting and ending indices of the x and y dimensions - integer :: nd, m, kp, d - - select case (field_type) - case (FIELD_S) - ix = group%ix_s - iy = group%iy_s - is = group%is_s - ie = group%ie_s - js = group%js_s - je = group%je_s - - nd = size(group%shape_s) - allocate (lb(nd), n(nd), indx(nd)) - - lb = 1 - n = group%shape_s - - select case(nd) - case (2) - call c_f_pointer(group%addrs_s(l), field2d, group%shape_s) - case (3) - call c_f_pointer(group%addrs_s(l), field3d, group%shape_s) - case (4) - call c_f_pointer(group%addrs_s(l), field4d, group%shape_s) - end select - case (FIELD_X) - ix = group%ix_v - iy = group%iy_v - is = group%is_x - ie = group%ie_x - js = group%js_x - je = group%je_x - - nd = size(group%shape_x) - allocate (lb(nd), n(nd), indx(nd)) - - lb = 1 - n = group%shape_x - - select case(nd) - case (2) - call c_f_pointer(group%addrs_x(l), field2d, group%shape_x) - case (3) - call c_f_pointer(group%addrs_x(l), field3d, group%shape_x) - case (4) - call c_f_pointer(group%addrs_x(l), field4d, group%shape_x) - end select - case (FIELD_Y) - ix = group%ix_v - iy = group%iy_v - is = group%is_y - ie = group%ie_y - js = group%js_y - je = group%je_y - - nd = size(group%shape_y) - allocate (lb(nd), n(nd), indx(nd)) - - lb = 1 - n = group%shape_y - - select case(nd) - case (2) - call c_f_pointer(group%addrs_y(l), field2d, group%shape_y) - case (3) - call c_f_pointer(group%addrs_y(l), field3d, group%shape_y) - case (4) - call c_f_pointer(group%addrs_y(l), field4d, group%shape_y) - end select - end select - - lb(ix) = i - is + 1 - lb(iy) = j - js + 1 - - n(ix) = 1 - n(iy) = 1 - - kp = k - 1 - do d=nd,1,-1 - m = product(n(1:d-1)) ! Product of all lower dimension sizes - indx(d) = kp / m - kp = kp - indx(d)*m - enddo + if(group%reset_index_v > group%nvector) & + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_3D_V_: group%reset_index_v > group%nvector") + if(size(fieldx,1) .NE. group%isize_x .OR. size(fieldx,2) .NE. group%jsize_x .OR. size(fieldx,3) .NE. group%ksize_v) & + call mpp_error(FATAL, & + & "MPP_RESET_GROUP_UPDATE_FIELD_3D_V_: size of fieldx does not match the size stored in group") + if(size(fieldy,1) .NE. group%isize_y .OR. size(fieldy,2) .NE. group%jsize_y .OR. size(fieldy,3) .NE. group%ksize_v) & + call mpp_error(FATAL, & + & "MPP_RESET_GROUP_UPDATE_FIELD_3D_V_: size of fieldy does not match the size stored in group") - indx = lb + indx + group%addrs_x(group%reset_index_v) = LOC(fieldx) + group%addrs_y(group%reset_index_v) = LOC(fieldy) - select case (nd) - case (2) - field2d(indx(1), indx(2)) = x - case (3) - field3d(indx(1), indx(2), indx(3)) = x - case (4) - field4d(indx(1), indx(2), indx(3), indx(4)) = x - end select -end subroutine SET_VALUE_ +end subroutine MPP_RESET_GROUP_UPDATE_FIELD_3D_V_ + +subroutine MPP_RESET_GROUP_UPDATE_FIELD_4D_V_(group, fieldx, fieldy) + type(mpp_group_update_type), intent(inout) :: group + MPP_TYPE_, intent(in) :: fieldx(:,:,:,:), fieldy(:,:,:,:) + + group%reset_index_v = group%reset_index_v + 1 + + if(group%reset_index_v > group%nvector) & + call mpp_error(FATAL, "MPP_RESET_GROUP_UPDATE_FIELD_4D_V_: group%reset_index_v > group%nvector") + if(size(fieldx,1) .NE. group%isize_x .OR. size(fieldx,2) .NE. group%jsize_x .OR. & + size(fieldx,3)*size(fieldx,4) .NE. group%ksize_v) & + call mpp_error(FATAL, & + & "MPP_RESET_GROUP_UPDATE_FIELD_4D_V_: size of fieldx does not match the size stored in group") + if(size(fieldy,1) .NE. group%isize_y .OR. size(fieldy,2) .NE. group%jsize_y .OR. & + size(fieldy,3)*size(fieldy,4) .NE. group%ksize_v) & + call mpp_error(FATAL, & + & "MPP_RESET_GROUP_UPDATE_FIELD_4D_V_: size of fieldy does not match the size stored in group") + + group%addrs_x(group%reset_index_v) = LOC(fieldx) + group%addrs_y(group%reset_index_v) = LOC(fieldy) + +end subroutine MPP_RESET_GROUP_UPDATE_FIELD_4D_V_ !> @} diff --git a/mpp/mpp_domains.F90 b/mpp/mpp_domains.F90 index d09e5f262b..da9a1ff848 100644 --- a/mpp/mpp_domains.F90 +++ b/mpp/mpp_domains.F90 @@ -593,11 +593,6 @@ module mpp_domains_mod integer :: is_s=0, ie_s=0, js_s=0, je_s=0 integer :: is_x=0, ie_x=0, js_x=0, je_x=0 integer :: is_y=0, ie_y=0, js_y=0, je_y=0 - integer :: ix_s=1, iy_s=2 !< Domain-decomposed dimensions of scalar arrays - integer :: ix_v=1, iy_v=2 !< Domain-decomposed dimensions of vector arrays - integer, allocatable, dimension(:) :: shape_s !< Shapes of scalar arrays - integer, allocatable, dimension(:) :: shape_x !< Shapes of vector arrays (x-component) - integer, allocatable, dimension(:) :: shape_y !< Shapes of vector arrays (y-component) integer :: nrecv=0, nsend=0 integer :: npack=0, nunpack=0 integer :: reset_index_s = 0 @@ -625,9 +620,9 @@ module mpp_domains_mod integer :: unpack_ie(MAXOVERLAP) integer :: unpack_js(MAXOVERLAP) integer :: unpack_je(MAXOVERLAP) - type(c_ptr) :: addrs_s(MAX_DOMAIN_FIELDS) - type(c_ptr) :: addrs_x(MAX_DOMAIN_FIELDS) - type(c_ptr) :: addrs_y(MAX_DOMAIN_FIELDS) + integer(i8_kind) :: addrs_s(MAX_DOMAIN_FIELDS) + integer(i8_kind) :: addrs_x(MAX_DOMAIN_FIELDS) + integer(i8_kind) :: addrs_y(MAX_DOMAIN_FIELDS) integer :: buffer_start_pos = -1 type(mpi_request) :: request_send(MAX_REQUEST) type(mpi_request) :: request_recv(MAX_REQUEST) @@ -1320,10 +1315,18 @@ module mpp_domains_mod !> @param !> @ingroup mpp_domains_mod interface mpp_create_group_update - module procedure mpp_create_group_update_r4 - module procedure mpp_create_group_update_r4_v - module procedure mpp_create_group_update_r8 - module procedure mpp_create_group_update_r8_v + module procedure mpp_create_group_update_r4_2d + module procedure mpp_create_group_update_r4_3d + module procedure mpp_create_group_update_r4_4d + module procedure mpp_create_group_update_r4_2dv + module procedure mpp_create_group_update_r4_3dv + module procedure mpp_create_group_update_r4_4dv + module procedure mpp_create_group_update_r8_2d + module procedure mpp_create_group_update_r8_3d + module procedure mpp_create_group_update_r8_4d + module procedure mpp_create_group_update_r8_2dv + module procedure mpp_create_group_update_r8_3dv + module procedure mpp_create_group_update_r8_4dv end interface mpp_create_group_update !> @ingroup mpp_domains_mod @@ -1358,10 +1361,18 @@ module mpp_domains_mod !> @ingroup mpp_domains_mod interface mpp_reset_group_update_field - module procedure mpp_reset_group_update_field_r4 - module procedure mpp_reset_group_update_field_r4_v - module procedure mpp_reset_group_update_field_r8 - module procedure mpp_reset_group_update_field_r8_v + module procedure mpp_reset_group_update_field_r4_2d + module procedure mpp_reset_group_update_field_r4_3d + module procedure mpp_reset_group_update_field_r4_4d + module procedure mpp_reset_group_update_field_r4_2dv + module procedure mpp_reset_group_update_field_r4_3dv + module procedure mpp_reset_group_update_field_r4_4dv + module procedure mpp_reset_group_update_field_r8_2d + module procedure mpp_reset_group_update_field_r8_3d + module procedure mpp_reset_group_update_field_r8_4d + module procedure mpp_reset_group_update_field_r8_2dv + module procedure mpp_reset_group_update_field_r8_3dv + module procedure mpp_reset_group_update_field_r8_4dv end interface mpp_reset_group_update_field !> Pass the data from coarse grid to fill the buffer to be ready to be interpolated