@@ -172,18 +172,66 @@ subroutine forcing_field_calculate(self, file_index, result_array)
172
172
integer , intent (in ) :: file_index
173
173
real , dimension (:, :), intent (inout ) :: result_array
174
174
175
+ real , dimension (:, :), allocatable , target :: tmp1, tmp2
176
+ real , dimension (:, :), allocatable :: E
177
+ real , dimension (:, :), pointer :: Td, sp
178
+
179
+ integer :: nx, ny
180
+ real , parameter :: RDRY = 287.0597
181
+ real , parameter :: RVAP = 461.5250
182
+ real , parameter :: A1 = 611.21
183
+ real , parameter :: A3 = 17.502
184
+ real , parameter :: A4 = 32.19
185
+ real , parameter :: T0 = 273.16
186
+
175
187
if (trim (self% product_name) == ' ERA5' ) then
188
+
189
+ nx = self% ncvars(1 )% nx
190
+ ny = self% ncvars(1 )% ny
191
+ allocate (tmp1(nx, ny), tmp2(nx, ny))
192
+
176
193
if (trim (self% coupling_name) == ' rain_ai' ) then
177
- ! Rain is calculated as total precipitation - snow
178
- ! FIXME: do calculation with field name checks
179
- call self% ncvars(1 )% read_data(file_index, result_array)
194
+ ! Rain is calculated as mcpr
195
+ ! (mean convective precipitation rate [kg m**-2 s**-1]) plus
196
+ ! mlspr (mean large-scale precipitation rate [kg m**-2 s**-1])
197
+ call self% ncvars(1 )% read_data(file_index, tmp1)
198
+ call self% ncvars(2 )% read_data(file_index, tmp2)
199
+ result_array(:, :) = tmp1(:, :) + tmp2(:, :)
200
+
201
+ elseif (trim (self% coupling_name) == ' runof_ai' ) then
202
+ ! Runoff is calculated as msror
203
+ ! (mean surface runoff rate [kg m**-2 s**-1]) plus
204
+ ! mssror (mean sub-surface runoff rate [kg m**-2 s**-1])
205
+
206
+ call self% ncvars(1 )% read_data(file_index, tmp1)
207
+ call self% ncvars(2 )% read_data(file_index, tmp2)
208
+ result_array(:, :) = tmp1(:, :) + tmp2(:, :)
209
+
180
210
elseif (trim (self% coupling_name) == ' qair_ai' ) then
181
- ! Humidity is calculated using surface temperature and dew point
182
- ! FIXME: do calculation with field name checks
183
- call self% ncvars(1 )% read_data(file_index, result_array)
211
+ ! Specific humidity at 2m
212
+
213
+ call assert(self% ncvars(1 )% name == ' d2m' , &
214
+ ' Unexpected name for in huss calculation' )
215
+ call assert(self% ncvars(2 )% name == ' sp' , &
216
+ ' Unexpected name for surface pressure' )
217
+
218
+ call self% ncvars(1 )% read_data(file_index, tmp1)
219
+ call self% ncvars(2 )% read_data(file_index, tmp2)
220
+ Td = > tmp1
221
+ sp = > tmp2
222
+
223
+ ! Saturation water vapour from Teten's formula
224
+ allocate (E(nx, ny))
225
+ E = A1* exp (A3* (Td- T0)/ (Td- A4))
226
+
227
+ ! Saturation specific humidity at 2m
228
+ result_array(:, :) = (RDRY/ RVAP)* E / (sp- ((1 - RDRY/ RVAP)* E))
229
+ deallocate (E)
184
230
else
185
231
call self% ncvars(1 )% read_data(file_index, result_array)
186
232
endif
233
+
234
+ deallocate (tmp1, tmp2)
187
235
elseif (trim (self% product_name) == ' JRA55-do' ) then
188
236
call self% ncvars(1 )% read_data(file_index, result_array)
189
237
else
0 commit comments