SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
sfx_oasis_send.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 !#########
6 SUBROUTINE sfx_oasis_send(KLUOUT,KI,KDATE,OSEND_LAND,OSEND_LAKE,OSEND_SEA, &
7  pland_runoff,pland_drain,pland_calving,pland_recharge,&
8  pland_srcflood, &
9  plake_evap,plake_rain,plake_snow,plake_watf, &
10  psea_fwsu,psea_fwsv,psea_heat,psea_snet,psea_wind, &
11  psea_fwsm,psea_evap,psea_rain,psea_snow,psea_watf, &
12  pseaice_heat,pseaice_snet,pseaice_evap )
13 !###########################################
14 !
15 !!**** *SFX_OASIS_SEND* - Send coupling fields
16 !!
17 !! PURPOSE
18 !! -------
19 !!
20 !! Attention : all fields are sent in Pa, m/s, W/m2 or kg/m2/s
21 !!
22 !!
23 !!
24 !!** METHOD
25 !! ------
26 !!
27 !! EXTERNAL
28 !! --------
29 !!
30 !!
31 !! IMPLICIT ARGUMENTS
32 !! ------------------
33 !!
34 !! REFERENCE
35 !! ---------
36 !!
37 !!
38 !! AUTHOR
39 !! ------
40 !! B. Decharme *Meteo France*
41 !!
42 !! MODIFICATIONS
43 !! -------------
44 !! Original 10/2013
45 !-------------------------------------------------------------------------------
46 !
47 !* 0. DECLARATIONS
48 ! ------------
49 !
50 USE modn_sfx_oasis, ONLY : xtstep_cpl_sea, xtstep_cpl_lake, &
51  xtstep_cpl_land
52 !
53 USE modd_surf_par, ONLY : xundef, nundef
54 !
56 !
57 USE modi_get_luout
58 !
59 USE yomhook ,ONLY : lhook, dr_hook
60 USE parkind1 ,ONLY : jprb
61 !
62 #ifdef CPLOASIS
63 USE mod_oasis
64 #endif
65 !
66 IMPLICIT NONE
67 !
68 !* 0.1 Declarations of arguments
69 ! -------------------------
70 !
71 INTEGER, INTENT(IN) :: kluout
72 INTEGER, INTENT(IN) :: ki ! number of points
73 INTEGER, INTENT(IN) :: kdate ! current coupling time step (s)
74 LOGICAL, INTENT(IN) :: osend_land
75 LOGICAL, INTENT(IN) :: osend_lake
76 LOGICAL, INTENT(IN) :: osend_sea
77 !
78 REAL, DIMENSION(KI), INTENT(IN) :: pland_runoff ! Cumulated Surface runoff (kg/m2)
79 REAL, DIMENSION(KI), INTENT(IN) :: pland_drain ! Cumulated Deep drainage (kg/m2)
80 REAL, DIMENSION(KI), INTENT(IN) :: pland_calving ! Cumulated Calving flux (kg/m2)
81 REAL, DIMENSION(KI), INTENT(IN) :: pland_recharge ! Cumulated Recharge to groundwater (kg/m2)
82 REAL, DIMENSION(KI), INTENT(IN) :: pland_srcflood ! Cumulated flood freshwater flux (kg/m2)
83 !
84 REAL, DIMENSION(KI), INTENT(IN) :: plake_evap ! Cumulated Evaporation (kg/m2)
85 REAL, DIMENSION(KI), INTENT(IN) :: plake_rain ! Cumulated Rainfall rate (kg/m2)
86 REAL, DIMENSION(KI), INTENT(IN) :: plake_snow ! Cumulated Snowfall rate (kg/m2)
87 REAL, DIMENSION(KI), INTENT(IN) :: plake_watf ! Cumulated freshwater flux (kg/m2)
88 !
89 REAL, DIMENSION(KI), INTENT(IN) :: psea_fwsu ! Cumulated zonal wind stress (Pa.s)
90 REAL, DIMENSION(KI), INTENT(IN) :: psea_fwsv ! Cumulated meridian wind stress (Pa.s)
91 REAL, DIMENSION(KI), INTENT(IN) :: psea_heat ! Cumulated Non solar net heat flux (J/m2)
92 REAL, DIMENSION(KI), INTENT(IN) :: psea_snet ! Cumulated Solar net heat flux (J/m2)
93 REAL, DIMENSION(KI), INTENT(IN) :: psea_wind ! Cumulated 10m wind speed (m)
94 REAL, DIMENSION(KI), INTENT(IN) :: psea_fwsm ! Cumulated wind stress (Pa.s)
95 REAL, DIMENSION(KI), INTENT(IN) :: psea_evap ! Cumulated Evaporation (kg/m2)
96 REAL, DIMENSION(KI), INTENT(IN) :: psea_rain ! Cumulated Rainfall rate (kg/m2)
97 REAL, DIMENSION(KI), INTENT(IN) :: psea_snow ! Cumulated Snowfall rate (kg/m2)
98 REAL, DIMENSION(KI), INTENT(IN) :: psea_watf ! Cumulated freshwater flux (kg/m2)
99 !
100 REAL, DIMENSION(KI), INTENT(IN) :: pseaice_heat ! Cumulated Sea-ice non solar net heat flux (J/m2)
101 REAL, DIMENSION(KI), INTENT(IN) :: pseaice_snet ! Cumulated Sea-ice solar net heat flux (J/m2)
102 REAL, DIMENSION(KI), INTENT(IN) :: pseaice_evap ! Cumulated Sea-ice sublimation (kg/m2)
103 !
104 !* 0.2 Declarations of local variables
105 ! -------------------------------
106 !
107 REAL, DIMENSION(KI,1) :: zwrite ! Mean flux send to OASIS (Pa, m/s, W/m2 or kg/m2/s)
108 !
109  CHARACTER(LEN=50) :: ycomment
110 INTEGER :: ierr ! Error info
111 !
112 REAL(KIND=JPRB) :: zhook_handle
113 !
114 !-------------------------------------------------------------------------------
115 #ifdef CPLOASIS
116 !-------------------------------------------------------------------------------
117 !
118 IF (lhook) CALL dr_hook('SFX_OASIS_SEND',0,zhook_handle)
119 !
120 !* 1. Initialize :
121 ! ------------
122 !
123 zwrite(:,:) = xundef
124 !
125 !-------------------------------------------------------------------------------
126 !
127 !* 2. Send land fields to OASIS:
128 ! --------------------------
129 !
130 IF(osend_land)THEN
131 !
132 ! * Send river output fields
133 !
134  ycomment='Surface runoff over land'
135  CALL outvar(pland_runoff,xtstep_cpl_land,zwrite(:,1))
136  CALL oasis_put(nrunoff_id,kdate,zwrite(:,:),ierr)
137  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
138 !
139  ycomment='Deep drainage over land'
140  CALL outvar(pland_drain,xtstep_cpl_land,zwrite(:,1))
141  CALL oasis_put(ndrain_id,kdate,zwrite(:,:),ierr)
142  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
143 !
144  IF(lcpl_calving)THEN
145  ycomment='calving flux over land'
146  CALL outvar(pland_calving,xtstep_cpl_land,zwrite(:,1))
147  CALL oasis_put(ncalving_id,kdate,zwrite(:,:),ierr)
148  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
149  ENDIF
150 !
151  IF(lcpl_gw)THEN
152  ycomment='groundwater recharge over land'
153  CALL outvar(pland_recharge,xtstep_cpl_land,zwrite(:,1))
154  CALL oasis_put(nrecharge_id,kdate,zwrite(:,:),ierr)
155  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
156  ENDIF
157 !
158  IF(lcpl_flood)THEN
159  ycomment='flood freshwater flux over land (P-E-I)'
160  CALL outvar(pland_srcflood,xtstep_cpl_land,zwrite(:,1))
161  CALL oasis_put(nsrcflood_id,kdate,zwrite(:,:),ierr)
162  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
163  ENDIF
164 !
165 ENDIF
166 !
167 !-------------------------------------------------------------------------------
168 !
169 !* 3. Send lake fields to OASIS :
170 ! --------------------------
171 IF(osend_lake)THEN
172 !
173 ! * Send output fields (in kg/m2/s)
174 !
175  IF(nlake_evap_id/=nundef)THEN
176  ycomment='Evaporation over lake'
177  CALL outvar(plake_evap,xtstep_cpl_lake,zwrite(:,1))
178  CALL oasis_put(nlake_evap_id,kdate,zwrite(:,:),ierr)
179  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
180  ENDIF
181 !
182  IF(nlake_rain_id/=nundef)THEN
183  ycomment='Rainfall rate over lake'
184  CALL outvar(plake_rain,xtstep_cpl_lake,zwrite(:,1))
185  CALL oasis_put(nlake_rain_id,kdate,zwrite(:,:),ierr)
186  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
187  ENDIF
188 !
189  IF(nlake_snow_id/=nundef)THEN
190  ycomment='Snowfall rate over lake'
191  CALL outvar(plake_snow,xtstep_cpl_lake,zwrite(:,1))
192  CALL oasis_put(nlake_snow_id,kdate,zwrite(:,:),ierr)
193  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
194  ENDIF
195 !
196  IF(nlake_watf_id/=nundef)THEN
197  ycomment='Freshwater flux over lake (P-E)'
198  CALL outvar(plake_watf,xtstep_cpl_lake,zwrite(:,1))
199  CALL oasis_put(nlake_watf_id,kdate,zwrite(:,:),ierr)
200  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
201  ENDIF
202 
203 
204 ENDIF
205 !
206 !-------------------------------------------------------------------------------
207 !
208 !* 4. Send sea fields to OASIS :
209 ! --------------------------
210 !
211 IF(osend_sea)THEN
212 !
213 ! * Send sea output fields (in Pa, m/s, W/m2 or kg/m2/s)
214 !
215  IF(nsea_fwsu_id/=nundef)THEN
216  ycomment='zonal wind stress over sea'
217  CALL outvar(psea_fwsu,xtstep_cpl_sea,zwrite(:,1))
218  CALL oasis_put(nsea_fwsu_id,kdate,zwrite(:,:),ierr)
219  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
220  ENDIF
221 !
222  IF(nsea_fwsv_id/=nundef)THEN
223  ycomment='meridian wind stress over sea'
224  CALL outvar(psea_fwsv,xtstep_cpl_sea,zwrite(:,1))
225  CALL oasis_put(nsea_fwsv_id,kdate,zwrite(:,:),ierr)
226  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
227  ENDIF
228 !
229  IF(nsea_heat_id/=nundef)THEN
230  ycomment='Non solar net heat flux over sea'
231  CALL outvar(psea_heat,xtstep_cpl_sea,zwrite(:,1))
232  CALL oasis_put(nsea_heat_id,kdate,zwrite(:,:),ierr)
233  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
234  ENDIF
235 !
236  IF(nsea_snet_id/=nundef)THEN
237  ycomment='Solar net heat flux over sea'
238  CALL outvar(psea_snet,xtstep_cpl_sea,zwrite(:,1))
239  CALL oasis_put(nsea_snet_id,kdate,zwrite(:,:),ierr)
240  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
241  ENDIF
242 !
243  IF(nsea_wind_id/=nundef)THEN
244  ycomment='10m wind speed over sea'
245  CALL outvar(psea_wind,xtstep_cpl_sea,zwrite(:,1))
246  CALL oasis_put(nsea_wind_id,kdate,zwrite(:,:),ierr)
247  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
248  ENDIF
249 !
250  IF(nsea_fwsm_id/=nundef)THEN
251  ycomment='wind stress over sea'
252  CALL outvar(psea_fwsm,xtstep_cpl_sea,zwrite(:,1))
253  CALL oasis_put(nsea_fwsm_id,kdate,zwrite(:,:),ierr)
254  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
255  ENDIF
256 !
257  IF(nsea_evap_id/=nundef)THEN
258  ycomment='Evaporation over sea'
259  CALL outvar(psea_evap,xtstep_cpl_sea,zwrite(:,1))
260  CALL oasis_put(nsea_evap_id,kdate,zwrite(:,:),ierr)
261  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
262  ENDIF
263 !
264  IF(nsea_rain_id/=nundef)THEN
265  ycomment='Rainfall rate over sea'
266  CALL outvar(psea_rain,xtstep_cpl_sea,zwrite(:,1))
267  CALL oasis_put(nsea_rain_id,kdate,zwrite(:,:),ierr)
268  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
269  ENDIF
270 !
271  IF(nsea_snow_id/=nundef)THEN
272  ycomment='Snowfall rate over sea'
273  CALL outvar(psea_snow,xtstep_cpl_sea,zwrite(:,1))
274  CALL oasis_put(nsea_snow_id,kdate,zwrite(:,:),ierr)
275  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
276  ENDIF
277 !
278  IF(nsea_watf_id/=nundef)THEN
279  ycomment='Freshwater flux over sea (P-E)'
280  CALL outvar(psea_watf,xtstep_cpl_sea,zwrite(:,1))
281  CALL oasis_put(nsea_watf_id,kdate,zwrite(:,:),ierr)
282  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
283  ENDIF
284 !
285 ! * Sea-ice output fields (in W/m2 or kg/m2/s)
286 !
287  IF(lcpl_seaice)THEN
288 !
289  IF(nseaice_heat_id/=nundef)THEN
290  ycomment='Sea-ice non solar net heat flux over sea-ice'
291  CALL outvar(pseaice_heat,xtstep_cpl_sea,zwrite(:,1))
292  CALL oasis_put(nseaice_heat_id,kdate,zwrite(:,:),ierr)
293  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
294  ENDIF
295 !
296  IF(nseaice_snet_id/=nundef)THEN
297  ycomment='Sea-ice solar net heat flux over sea-ice'
298  CALL outvar(pseaice_snet,xtstep_cpl_sea,zwrite(:,1))
299  CALL oasis_put(nseaice_snet_id,kdate,zwrite(:,:),ierr)
300  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
301  ENDIF
302 !
303  IF(nseaice_evap_id/=nundef)THEN
304  ycomment='Sea-ice sublimation over sea-ice'
305  CALL outvar(pseaice_evap,xtstep_cpl_sea,zwrite(:,1))
306  CALL oasis_put(nseaice_evap_id,kdate,zwrite(:,:),ierr)
307  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
308  ENDIF
309 !
310  ENDIF
311 !
312 ENDIF
313 !
314 IF (lhook) CALL dr_hook('SFX_OASIS_SEND',1,zhook_handle)
315 !
316 !-------------------------------------------------------------------------------
317  CONTAINS
318 !-------------------------------------------------------------------------------
319 !
320 SUBROUTINE check_sfx_send(KLUOUT,KERR,HCOMMENT,PWRITE)
321 !
322 USE modi_abor1_sfx
323 !
324 IMPLICIT NONE
325 !
326 INTEGER, INTENT(IN) :: kluout
327 INTEGER, INTENT(IN) :: kerr
328  CHARACTER(LEN=*), INTENT(IN) :: hcomment
329 !
330 REAL, DIMENSION(:), INTENT(OUT):: pwrite
331 !
332 REAL(KIND=JPRB) :: zhook_handle
333 !
334 IF (lhook) CALL dr_hook('SFX_OASIS_SEND:CHECK_SFX_SEND',0,zhook_handle)
335 !
336 pwrite(:) = xundef
337 !
338 IF (kerr/=oasis_ok.AND.kerr<oasis_sent) THEN
339  WRITE(kluout,'(A,I4)')'Return OASIS code from sending '//trim(hcomment)//' : ',kerr
340  CALL abor1_sfx('SFX_OASIS_SEND: problem sending '//trim(hcomment))
341 ENDIF
342 !
343 IF (lhook) CALL dr_hook('SFX_OASIS_SEND:CHECK_SFX_SEND',1,zhook_handle)
344 !
345 END SUBROUTINE check_sfx_send
346 !
347 !-------------------------------------------------------------------------------
348 !
349 SUBROUTINE outvar(PIN,PDIV,PWRITE)
350 !
351 IMPLICIT NONE
352 !
353 REAL, DIMENSION(:), INTENT(IN) :: pin
354 REAL, INTENT(IN) :: pdiv
355 !
356 REAL, DIMENSION(:), INTENT(OUT):: pwrite
357 !
358 REAL(KIND=JPRB) :: zhook_handle
359 !
360 IF (lhook) CALL dr_hook('SFX_OASIS_SEND:OUTVAR',0,zhook_handle)
361 !
362 WHERE(pin(:)/=xundef)
363  pwrite(:)=pin(:)/pdiv
364 ELSEWHERE
365  pwrite(:)=xundef
366 ENDWHERE
367 !
368 IF (lhook) CALL dr_hook('SFX_OASIS_SEND:OUTVAR',1,zhook_handle)
369 !
370 END SUBROUTINE outvar
371 !
372 !-------------------------------------------------------------------------------
373 #endif
374 !-------------------------------------------------------------------------------
375 !
376 END SUBROUTINE sfx_oasis_send
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine check_sfx_send(KLUOUT, KERR, HCOMMENT, PWRITE)
subroutine outvar(PIN, PDIV, PWRITE)
subroutine sfx_oasis_send(KLUOUT, KI, KDATE, OSEND_LAND, OSEND_LAKE, OSEND_SEA, PLAND_RUNOFF, PLAND_DRAIN, PLAND_CALVING, PLAND_RECHARGE, PLAND_SRCFLOOD, PLAKE_EVAP, PLAKE_RAIN, PLAKE_SNOW, PLAKE_WATF, PSEA_FWSU, PSEA_FWSV, PSEA_HEAT, PSEA_SNET, PSEA_WIND, PSEA_FWSM, PSEA_EVAP, PSEA_RAIN, PSEA_SNOW, PSEA_WATF, PSEAICE_HEAT, PSEAICE_SNET, PSEAICE_EVAP)