@@ -5,7 +5,7 @@ module mapl3g_FieldBundleGetPointer
55
66 use ESMF
77 use MAPL_ErrorHandling
8- use , intrinsic :: iso_fortran_env, only: real32, real64
8+ use , intrinsic :: iso_fortran_env, only: REAL64
99
1010 implicit none (type,external )
1111 private
@@ -17,6 +17,10 @@ module mapl3g_FieldBundleGetPointer
1717 module procedure FieldBundleGetPointerToDataByIndex3
1818 module procedure FieldBundleGetPointerToDataByName2
1919 module procedure FieldBundleGetPointerToDataByName3
20+ module procedure FieldBundleGetPointerToR8 DataByIndex2
21+ module procedure FieldBundleGetPointerToR8 DataByIndex3
22+ module procedure FieldBundleGetPointerToR8 DataByName2
23+ module procedure FieldBundleGetPointerToR8 DataByName3
2024 end interface FieldBundleGetPointerToData
2125
2226contains
@@ -35,10 +39,9 @@ subroutine FieldBundleGetPointerToDataByIndex2(bundle, index, ptr, rc)
3539
3640 call ESMF_FieldBundleGet(bundle, index, field, _RC)
3741 call ESMF_FieldGet(field, status= field_status, _RC)
42+ nullify(ptr)
3843 if (field_status == ESMF_FIELDSTATUS_COMPLETE) then
3944 call ESMF_FieldGet(field, 0 , ptr, _RC)
40- else
41- nullify(ptr)
4245 end if
4346
4447 _RETURN(_SUCCESS)
@@ -58,10 +61,9 @@ subroutine FieldBundleGetPointerToDataByIndex3(bundle, index, ptr, rc)
5861
5962 call ESMF_FieldBundleGet(bundle, index, field, _RC)
6063 call ESMF_FieldGet(field, status= field_status, _RC)
64+ nullify(ptr)
6165 if (field_status == ESMF_FIELDSTATUS_COMPLETE) then
6266 call ESMF_FieldGet(field, 0 , ptr, _RC)
63- else
64- nullify(ptr)
6567 end if
6668
6769 _RETURN(_SUCCESS)
@@ -79,16 +81,15 @@ subroutine FieldBundleGetPointerToDataByName2(bundle, name, ptr, rc)
7981
8082 call ESMF_FieldBundleGet(bundle, name, field= field, _RC)
8183 call ESMF_FieldGet(field, status= field_status, _RC)
84+ nullify(ptr)
8285 if (field_status == ESMF_FIELDSTATUS_COMPLETE) then
8386 call ESMF_FieldGet(field, 0 , ptr, _RC)
84- else
85- nullify(ptr)
8687 end if
8788
8889 _RETURN(_SUCCESS)
8990 end subroutine FieldBundleGetPointerToDataByName2
9091
91- subroutine FieldBundleGetPointerToDataByName3 (BUNDLE , NAME , PTR , RC )
92+ subroutine FieldBundleGetPointerToDataByName3 (bundle , name , ptr , rc )
9293 type (ESMF_FieldBundle), intent (inout ) :: bundle ! ALT: intent(in)
9394 character (len=* ), intent (in ) :: name
9495 real , pointer , intent (inout ) :: ptr(:,:,:)
@@ -100,13 +101,96 @@ subroutine FieldBundleGetPointerToDataByName3(BUNDLE,NAME,PTR,RC)
100101
101102 call ESMF_FieldBundleGet(bundle, name, field= field, _RC)
102103 call ESMF_FieldGet(field, status= field_status, _RC)
104+ nullify(ptr)
103105 if (field_status == ESMF_FIELDSTATUS_COMPLETE) then
104106 call ESMF_FieldGet(field, 0 , ptr, _RC)
105- else
106- nullify(ptr)
107107 end if
108108
109109 _RETURN(_SUCCESS)
110110 end subroutine FieldBundleGetPointerToDataByName3
111111
112+ subroutine FieldBundleGetPointerToR8DataByIndex2 (bundle , index , ptr , rc )
113+ type (ESMF_FieldBundle), intent (inout ) :: bundle ! ALT: intent(in)
114+ integer , intent (in ) :: index
115+ real (REAL64), pointer , intent (inout ) :: ptr(:,:)
116+ integer , optional , intent (out ):: rc
117+
118+ type (ESMF_Field) :: field
119+ type (ESMF_FieldStatus_Flag) :: field_status
120+ integer :: status
121+
122+ ! ESMF 5 reorders items, be careful!
123+
124+ call ESMF_FieldBundleGet(bundle, index, field, _RC)
125+ call ESMF_FieldGet(field, status= field_status, _RC)
126+ nullify(ptr)
127+ if (field_status == ESMF_FIELDSTATUS_COMPLETE) then
128+ call ESMF_FieldGet(field, 0 , ptr, _RC)
129+ end if
130+
131+ _RETURN(_SUCCESS)
132+ end subroutine FieldBundleGetPointerToR8DataByIndex2
133+
134+ subroutine FieldBundleGetPointerToR8DataByIndex3 (bundle , index , ptr , rc )
135+ type (ESMF_FieldBundle), intent (inout ) :: bundle ! ALT: intent(in)
136+ integer , intent (in ) :: index
137+ real (REAL64), pointer , intent (inout ) :: ptr(:,:,:)
138+ integer , optional , intent (out ):: rc
139+
140+ type (ESMF_Field) :: field
141+ type (ESMF_FieldStatus_Flag) :: field_status
142+ integer :: status
143+
144+ ! ESMF 5 reorders items, be careful!
145+
146+ call ESMF_FieldBundleGet(bundle, index, field, _RC)
147+ call ESMF_FieldGet(field, status= field_status, _RC)
148+ nullify(ptr)
149+ if (field_status == ESMF_FIELDSTATUS_COMPLETE) then
150+ call ESMF_FieldGet(field, 0 , ptr, _RC)
151+ end if
152+
153+ _RETURN(_SUCCESS)
154+ end subroutine FieldBundleGetPointerToR8DataByIndex3
155+
156+ subroutine FieldBundleGetPointerToR8DataByName2 (bundle , name , ptr , rc )
157+ type (ESMF_FieldBundle), intent (inout ) :: bundle ! ALT: intent(in)
158+ character (len=* ), intent (in ) :: name
159+ real (REAL64), pointer , intent (inout ) :: ptr(:,:)
160+ integer , optional , intent (out ):: rc
161+
162+ type (ESMF_Field) :: field
163+ type (ESMF_FieldStatus_Flag) :: field_status
164+ integer :: status
165+
166+ call ESMF_FieldBundleGet(bundle, name, field= field, _RC)
167+ call ESMF_FieldGet(field, status= field_status, _RC)
168+ nullify(ptr)
169+ if (field_status == ESMF_FIELDSTATUS_COMPLETE) then
170+ call ESMF_FieldGet(field, 0 , ptr, _RC)
171+ end if
172+
173+ _RETURN(_SUCCESS)
174+ end subroutine FieldBundleGetPointerToR8DataByName2
175+
176+ subroutine FieldBundleGetPointerToR8DataByName3 (bundle , name , ptr , rc )
177+ type (ESMF_FieldBundle), intent (inout ) :: bundle ! ALT: intent(in)
178+ character (len=* ), intent (in ) :: name
179+ real (REAL64), pointer , intent (inout ) :: ptr(:,:,:)
180+ integer , optional , intent (out ):: rc
181+
182+ type (ESMF_Field) :: field
183+ type (ESMF_FieldStatus_Flag) :: field_status
184+ integer :: status
185+
186+ call ESMF_FieldBundleGet(bundle, name, field= field, _RC)
187+ call ESMF_FieldGet(field, status= field_status, _RC)
188+ nullify(ptr)
189+ if (field_status == ESMF_FIELDSTATUS_COMPLETE) then
190+ call ESMF_FieldGet(field, 0 , ptr, _RC)
191+ end if
192+
193+ _RETURN(_SUCCESS)
194+ end subroutine FieldBundleGetPointerToR8DataByName3
195+
112196end module mapl3g_FieldBundleGetPointer
0 commit comments