FMS 2025.01-dev
Flexible Modeling System
Loading...
Searching...
No Matches
group_update_unpack.inc
1!***********************************************************************
2!* GNU Lesser General Public License
3!*
4!* This file is part of the GFDL Flexible Modeling System (FMS).
5!*
6!* FMS is free software: you can redistribute it and/or modify it under
7!* the terms of the GNU Lesser General Public License as published by
8!* the Free Software Foundation, either version 3 of the License, or (at
9!* your option) any later version.
10!*
11!* FMS is distributed in the hope that it will be useful, but WITHOUT
12!* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13!* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14!* for more details.
15!*
16!* You should have received a copy of the GNU Lesser General Public
17!* License along with FMS. If not, see <http://www.gnu.org/licenses/>.
18!***********************************************************************
19
20if( group%k_loop_inside ) then
21!$OMP parallel do default(none) shared(nunpack,group,nscalar,ptr,nvector,ksize,buffer_start_pos) &
22!$OMP private(buffer_pos,pos,m,is, ie, js, je,rotation, &
23!$OMP ptr_field, ptr_fieldx, ptr_fieldy, n,k )
24 do n = nunpack, 1, -1
25 buffer_pos = group%unpack_buffer_pos(n) + buffer_start_pos
26 pos = buffer_pos
27 is = group%unpack_is(n); ie = group%unpack_ie(n)
28 js = group%unpack_js(n); je = group%unpack_je(n)
29 if( group%unpack_type(n) == field_s ) then
30 do l=1,nscalar ! loop over number of fields
31 ptr_field = group%addrs_s(l)
32 do k = 1, ksize
33 do j = js, je
34 do i = is, ie
35 pos = pos + 1
36 field(i,j,k) = buffer(pos)
37 end do
38 end do
39 end do
40 end do
41 else if( group%unpack_type(n) == field_x ) then
42 do l=1,nvector ! loop over number of fields
43 ptr_fieldx = group%addrs_x(l)
44 do k = 1, ksize
45 do j = js, je
46 do i = is, ie
47 pos = pos + 1
48 fieldx(i,j,k) = buffer(pos)
49 end do
50 end do
51 end do
52 end do
53 else if( group%unpack_type(n) == field_y ) then
54 do l=1,nvector ! loop over number of fields
55 ptr_fieldy = group%addrs_y(l)
56 do k = 1, ksize
57 do j = js, je
58 do i = is, ie
59 pos = pos + 1
60 fieldy(i,j,k) = buffer(pos)
61 end do
62 end do
63 end do
64 end do
65 endif
66 enddo
67else
68!$OMP parallel do default(none) shared(nunpack,group,nscalar,ptr,nvector,ksize,buffer_start_pos) &
69!$OMP private(buffer_pos,pos,m,is, ie, js, je,rotation, &
70!$OMP ptr_field, ptr_fieldx, ptr_fieldy,n,k)
71 do nk = nunpack*ksize, 1, -1
72 n = (nk-1)/ksize + 1
73 k = mod((nk-1), ksize) + 1
74 buffer_pos = group%unpack_buffer_pos(n) + buffer_start_pos
75 pos = buffer_pos + (k-1)*group%unpack_size(n)
76 is = group%unpack_is(n); ie = group%unpack_ie(n)
77 js = group%unpack_js(n); je = group%unpack_je(n)
78 if( group%unpack_type(n) == field_s ) then
79 do l=1,nscalar ! loop over number of fields
80 ptr_field = group%addrs_s(l)
81 do j = js, je
82 do i = is, ie
83 pos = pos + 1
84 field(i,j,k) = buffer(pos)
85 end do
86 end do
87 end do
88 else if( group%unpack_type(n) == field_x ) then
89 do l=1,nvector ! loop over number of fields
90 ptr_fieldx = group%addrs_x(l)
91 do j = js, je
92 do i = is, ie
93 pos = pos + 1
94 fieldx(i,j,k) = buffer(pos)
95 end do
96 end do
97 end do
98 else if( group%unpack_type(n) == field_y ) then
99 do l=1,nvector ! loop over number of fields
100 ptr_fieldy = group%addrs_y(l)
101 do j = js, je
102 do i = is, ie
103 pos = pos + 1
104 fieldy(i,j,k) = buffer(pos)
105 end do
106 end do
107 end do
108 endif
109 enddo
110endif