SURFEX v8.1
General documentation of Surfex
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, &
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 !! 10/2016 B. Decharme : bug surface/groundwater coupling
46 !-------------------------------------------------------------------------------
47 !
48 !* 0. DECLARATIONS
49 ! ------------
50 !
53 !
54 USE modd_surf_par, ONLY : xundef, nundef
55 !
57 !
58 USE modi_get_luout
59 !
60 USE yomhook ,ONLY : lhook, dr_hook
61 USE parkind1 ,ONLY : jprb
62 !
63 #ifdef CPLOASIS
64 USE mod_oasis
65 #endif
66 !
67 IMPLICIT NONE
68 !
69 !* 0.1 Declarations of arguments
70 ! -------------------------
71 !
72 INTEGER, INTENT(IN) :: KLUOUT
73 INTEGER, INTENT(IN) :: KI ! number of points
74 INTEGER, INTENT(IN) :: KDATE ! current coupling time step (s)
75 LOGICAL, INTENT(IN) :: OSEND_LAND
76 LOGICAL, INTENT(IN) :: OSEND_LAKE
77 LOGICAL, INTENT(IN) :: OSEND_SEA
78 !
79 REAL, DIMENSION(KI), INTENT(IN) :: PLAND_RUNOFF ! Cumulated Surface runoff (kg/m2)
80 REAL, DIMENSION(KI), INTENT(IN) :: PLAND_DRAIN ! Cumulated Deep drainage (kg/m2)
81 REAL, DIMENSION(KI), INTENT(IN) :: PLAND_CALVING ! Cumulated Calving flux (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_flood)THEN
152  ycomment='flood freshwater flux over land (P-E-I)'
153  CALL outvar(pland_srcflood,xtstep_cpl_land,zwrite(:,1))
154  CALL oasis_put(nsrcflood_id,kdate,zwrite(:,:),ierr)
155  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
156  ENDIF
157 !
158 ENDIF
159 !
160 !-------------------------------------------------------------------------------
161 !
162 !* 3. Send lake fields to OASIS :
163 ! --------------------------
164 IF(osend_lake)THEN
165 !
166 ! * Send output fields (in kg/m2/s)
167 !
168  IF(nlake_evap_id/=nundef)THEN
169  ycomment='Evaporation over lake'
170  CALL outvar(plake_evap,xtstep_cpl_lake,zwrite(:,1))
171  CALL oasis_put(nlake_evap_id,kdate,zwrite(:,:),ierr)
172  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
173  ENDIF
174 !
175  IF(nlake_rain_id/=nundef)THEN
176  ycomment='Rainfall rate over lake'
177  CALL outvar(plake_rain,xtstep_cpl_lake,zwrite(:,1))
178  CALL oasis_put(nlake_rain_id,kdate,zwrite(:,:),ierr)
179  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
180  ENDIF
181 !
182  IF(nlake_snow_id/=nundef)THEN
183  ycomment='Snowfall rate over lake'
184  CALL outvar(plake_snow,xtstep_cpl_lake,zwrite(:,1))
185  CALL oasis_put(nlake_snow_id,kdate,zwrite(:,:),ierr)
186  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
187  ENDIF
188 !
189  IF(nlake_watf_id/=nundef)THEN
190  ycomment='Freshwater flux over lake (P-E)'
191  CALL outvar(plake_watf,xtstep_cpl_lake,zwrite(:,1))
192  CALL oasis_put(nlake_watf_id,kdate,zwrite(:,:),ierr)
193  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
194  ENDIF
195 
196 
197 ENDIF
198 !
199 !-------------------------------------------------------------------------------
200 !
201 !* 4. Send sea fields to OASIS :
202 ! --------------------------
203 !
204 IF(osend_sea)THEN
205 !
206 ! * Send sea output fields (in Pa, m/s, W/m2 or kg/m2/s)
207 !
208  IF(nsea_fwsu_id/=nundef)THEN
209  ycomment='zonal wind stress over sea'
210  CALL outvar(psea_fwsu,xtstep_cpl_sea,zwrite(:,1))
211  CALL oasis_put(nsea_fwsu_id,kdate,zwrite(:,:),ierr)
212  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
213  ENDIF
214 !
215  IF(nsea_fwsv_id/=nundef)THEN
216  ycomment='meridian wind stress over sea'
217  CALL outvar(psea_fwsv,xtstep_cpl_sea,zwrite(:,1))
218  CALL oasis_put(nsea_fwsv_id,kdate,zwrite(:,:),ierr)
219  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
220  ENDIF
221 !
222  IF(nsea_heat_id/=nundef)THEN
223  ycomment='Non solar net heat flux over sea'
224  CALL outvar(psea_heat,xtstep_cpl_sea,zwrite(:,1))
225  CALL oasis_put(nsea_heat_id,kdate,zwrite(:,:),ierr)
226  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
227  ENDIF
228 !
229  IF(nsea_snet_id/=nundef)THEN
230  ycomment='Solar net heat flux over sea'
231  CALL outvar(psea_snet,xtstep_cpl_sea,zwrite(:,1))
232  CALL oasis_put(nsea_snet_id,kdate,zwrite(:,:),ierr)
233  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
234  ENDIF
235 !
236  IF(nsea_wind_id/=nundef)THEN
237  ycomment='10m wind speed over sea'
238  CALL outvar(psea_wind,xtstep_cpl_sea,zwrite(:,1))
239  CALL oasis_put(nsea_wind_id,kdate,zwrite(:,:),ierr)
240  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
241  ENDIF
242 !
243  IF(nsea_fwsm_id/=nundef)THEN
244  ycomment='wind stress over sea'
245  CALL outvar(psea_fwsm,xtstep_cpl_sea,zwrite(:,1))
246  CALL oasis_put(nsea_fwsm_id,kdate,zwrite(:,:),ierr)
247  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
248  ENDIF
249 !
250  IF(nsea_evap_id/=nundef)THEN
251  ycomment='Evaporation over sea'
252  CALL outvar(psea_evap,xtstep_cpl_sea,zwrite(:,1))
253  CALL oasis_put(nsea_evap_id,kdate,zwrite(:,:),ierr)
254  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
255  ENDIF
256 !
257  IF(nsea_rain_id/=nundef)THEN
258  ycomment='Rainfall rate over sea'
259  CALL outvar(psea_rain,xtstep_cpl_sea,zwrite(:,1))
260  CALL oasis_put(nsea_rain_id,kdate,zwrite(:,:),ierr)
261  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
262  ENDIF
263 !
264  IF(nsea_snow_id/=nundef)THEN
265  ycomment='Snowfall rate over sea'
266  CALL outvar(psea_snow,xtstep_cpl_sea,zwrite(:,1))
267  CALL oasis_put(nsea_snow_id,kdate,zwrite(:,:),ierr)
268  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
269  ENDIF
270 !
271  IF(nsea_watf_id/=nundef)THEN
272  ycomment='Freshwater flux over sea (P-E)'
273  CALL outvar(psea_watf,xtstep_cpl_sea,zwrite(:,1))
274  CALL oasis_put(nsea_watf_id,kdate,zwrite(:,:),ierr)
275  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
276  ENDIF
277 !
278 ! * Sea-ice output fields (in W/m2 or kg/m2/s)
279 !
280  IF(lcpl_seaice)THEN
281 !
282  IF(nseaice_heat_id/=nundef)THEN
283  ycomment='Sea-ice non solar net heat flux over sea-ice'
284  CALL outvar(pseaice_heat,xtstep_cpl_sea,zwrite(:,1))
285  CALL oasis_put(nseaice_heat_id,kdate,zwrite(:,:),ierr)
286  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
287  ENDIF
288 !
289  IF(nseaice_snet_id/=nundef)THEN
290  ycomment='Sea-ice solar net heat flux over sea-ice'
291  CALL outvar(pseaice_snet,xtstep_cpl_sea,zwrite(:,1))
292  CALL oasis_put(nseaice_snet_id,kdate,zwrite(:,:),ierr)
293  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
294  ENDIF
295 !
296  IF(nseaice_evap_id/=nundef)THEN
297  ycomment='Sea-ice sublimation over sea-ice'
298  CALL outvar(pseaice_evap,xtstep_cpl_sea,zwrite(:,1))
299  CALL oasis_put(nseaice_evap_id,kdate,zwrite(:,:),ierr)
300  CALL check_sfx_send(kluout,ierr,ycomment,zwrite(:,1))
301  ENDIF
302 !
303  ENDIF
304 !
305 ENDIF
306 !
307 IF (lhook) CALL dr_hook('SFX_OASIS_SEND',1,zhook_handle)
308 !
309 !-------------------------------------------------------------------------------
310 CONTAINS
311 !-------------------------------------------------------------------------------
312 !
313 SUBROUTINE check_sfx_send(KLUOUT,KERR,HCOMMENT,PWRITE)
314 !
315 USE modi_abor1_sfx
316 !
317 IMPLICIT NONE
318 !
319 INTEGER, INTENT(IN) :: KLUOUT
320 INTEGER, INTENT(IN) :: KERR
321  CHARACTER(LEN=*), INTENT(IN) :: HCOMMENT
322 !
323 REAL, DIMENSION(:), INTENT(OUT):: PWRITE
324 !
325 REAL(KIND=JPRB) :: ZHOOK_HANDLE
326 !
327 IF (lhook) CALL dr_hook('SFX_OASIS_SEND:CHECK_SFX_SEND',0,zhook_handle)
328 !
329 pwrite(:) = xundef
330 !
331 IF (kerr/=oasis_ok.AND.kerr<oasis_sent) THEN
332  WRITE(kluout,'(A,I4)')'Return OASIS code from sending '//trim(hcomment)//' : ',kerr
333  CALL abor1_sfx('SFX_OASIS_SEND: problem sending '//trim(hcomment))
334 ENDIF
335 !
336 IF (lhook) CALL dr_hook('SFX_OASIS_SEND:CHECK_SFX_SEND',1,zhook_handle)
337 !
338 END SUBROUTINE check_sfx_send
339 !
340 !-------------------------------------------------------------------------------
341 !
342 SUBROUTINE outvar(PIN,PDIV,PWRITE)
343 !
344 IMPLICIT NONE
345 !
346 REAL, DIMENSION(:), INTENT(IN) :: PIN
347 REAL, INTENT(IN) :: PDIV
348 !
349 REAL, DIMENSION(:), INTENT(OUT):: PWRITE
350 !
351 REAL(KIND=JPRB) :: ZHOOK_HANDLE
352 !
353 IF (lhook) CALL dr_hook('SFX_OASIS_SEND:OUTVAR',0,zhook_handle)
354 !
355 WHERE(pin(:)/=xundef)
356  pwrite(:)=pin(:)/pdiv
357 ELSEWHERE
358  pwrite(:)=xundef
359 ENDWHERE
360 !
361 IF (lhook) CALL dr_hook('SFX_OASIS_SEND:OUTVAR',1,zhook_handle)
362 !
363 END SUBROUTINE outvar
364 !
365 !-------------------------------------------------------------------------------
366 #endif
367 !-------------------------------------------------------------------------------
368 !
369 END SUBROUTINE sfx_oasis_send
static const char * trim(const char *name, int *n)
Definition: drhook.c:2383
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:7
real, parameter xundef
subroutine check_sfx_send(KLUOUT, KERR, HCOMMENT, PWRITE)
integer, parameter jprb
Definition: parkind1.F90:32
subroutine outvar(PIN, PDIV, PWRITE)
integer, parameter nundef
subroutine sfx_oasis_send(KLUOUT, KI, KDATE, OSEND_LAND, OSEND_LAKE, OSEND_SEA, PLAND_RUNOFF, PLAND_DRAIN, PLAND_CALVING, 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)
logical lhook
Definition: yomhook.F90:15