source: LMDZ6/branches/PBLSURF_GPUPORT/libf/phylmd/surf_ocean_mod.F90 @ 5934

Last change on this file since 5934 was 5934, checked in by yann meurdesoif, 3 weeks ago

forgotten dummy argument that was in klon instead knon.
YM

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 17.4 KB
Line 
1!
2! $Id: surf_ocean_mod.F90 5934 2025-12-16 18:36:28Z ymeurdesoif $
3!
4MODULE surf_ocean_mod
5
6  IMPLICIT NONE
7
8CONTAINS
9  !
10  !******************************************************************************
11  !
12  SUBROUTINE surf_ocean(rlon, rlat, swnet, lwnet, alb1, &
13       windsp, rmu0, fder, tsurf_in, &
14       itime, dtime, jour, knon, knindex, &
15       p1lay, z1lay, cdragh, cdragm, precip_rain, precip_snow, precip_bs, temp_air, spechum, &
16       AcoefH, AcoefQ, BcoefH, BcoefQ, &
17       AcoefU, AcoefV, BcoefU, BcoefV, &
18       ps, u1, v1, gustiness, rugoro, pctsrf, &
19       snow, qsurf, agesno, &
20       z0m, z0h, SFRWL, alb_dir_new, alb_dif_new, evap, fluxsens, fluxlat, &
21       tsurf_new, dflux_s, dflux_l, lmt_bils, &
22       flux_u1, flux_v1, delta_sst, delta_sal, ds_ns, dt_ns, dter, dser, &
23!GG       dt_ds, tkt, tks, taur, sss)
24       dt_ds, tkt, tks, taur, sss, &
25       dthetadz300,Ampl      &
26!GG
27#ifdef ISO
28        &       ,xtprecip_rain, xtprecip_snow,xtspechum,Roce, &
29        &       xtsnow,xtevap,h1 &
30#endif               
31        &       )
32!$gpum horizontal knon klon
33
34    use albedo_mod, only: alboc, alboc_cd
35    use bulk_flux_m, only: bulk_flux
36    USE dimphy, ONLY: klon, zmasq
37    USE surface_data, ONLY     : type_ocean
38    USE ocean_forced_mod, ONLY : ocean_forced_noice
39    USE ocean_slab_mod, ONLY   : ocean_slab_noice
40    USE ocean_cpl_mod, ONLY    : ocean_cpl_noice
41    USE indice_sol_mod, ONLY : nbsrf, is_oce
42    USE ocean_albedo_mod, ONLY : ocean_albedo
43#ifdef ISO
44    USE infotrac_phy, ONLY : ntraciso=>ntiso,niso
45#ifdef ISOVERIF
46    USE isotopes_mod, ONLY: iso_eau,ridicule
47    USE isotopes_verif_mod
48#endif
49#endif
50    USE clesphys_mod_h, ONLY: nsw, ok_bs, f_z0qh_oce, iflag_albedo, iflag_cycle_diurne, fmagic, pmagic, iflag_z0_oce, z0min
51    USE yomcst_mod_h, ONLY: rd, retv, rg, rlvtt
52    USE limit_read_mod, ONLY: limit_read_rug_alb
53    USE config_ocean_skin_m, ONLY: activate_ocean_skin
54    USE lmdz_checksum, ONLY : checksum
55    !
56    ! This subroutine will make a call to ocean_XXX_noice according to the ocean mode (force,
57    ! slab or couple). The calculations of albedo and rugosity for the ocean surface are
58    ! done in here because they are identical for the different modes of ocean.
59
60
61
62
63    ! for cycle_diurne and for iflag_z0_oce==-1 (prescribed z0)
64
65    ! Input variables
66    !******************************************************************************
67    INTEGER, INTENT(IN)                      :: itime, jour, knon
68    INTEGER, DIMENSION(knon), INTENT(IN)     :: knindex
69    REAL, INTENT(IN)                         :: dtime
70    REAL, DIMENSION(klon), INTENT(IN)        :: rlon, rlat
71    REAL, DIMENSION(knon), INTENT(IN)        :: swnet  ! net shortwave radiation at surface 
72    REAL, DIMENSION(knon), INTENT(IN)        :: lwnet  ! net longwave radiation at surface 
73    REAL, DIMENSION(knon), INTENT(IN)        :: alb1   ! albedo in visible SW interval
74    REAL, DIMENSION(knon), INTENT(IN)        :: windsp ! wind at 10 m, in m s-1
75    REAL, DIMENSION(knon), INTENT(IN)        :: rmu0 
76    REAL, DIMENSION(knon), INTENT(IN)        :: fder
77    REAL, DIMENSION(knon), INTENT(IN)        :: tsurf_in     ! defined only for subscripts 1:knon
78    REAL, DIMENSION(knon), INTENT(IN)        :: p1lay,z1lay ! pression (Pa) et altitude (m) du premier niveau
79    REAL, DIMENSION(knon), INTENT(IN)        :: cdragh
80    REAL, DIMENSION(knon), INTENT(IN)        :: cdragm
81    REAL, DIMENSION(knon), INTENT(IN)        :: precip_rain, precip_snow, precip_bs
82    REAL, DIMENSION(knon), INTENT(IN)        :: temp_air, spechum
83    REAL, DIMENSION(knon), INTENT(IN)        :: AcoefH, AcoefQ, BcoefH, BcoefQ
84    REAL, DIMENSION(knon), INTENT(IN)        :: AcoefU, AcoefV, BcoefU, BcoefV
85    REAL, DIMENSION(knon), INTENT(IN)        :: ps
86    REAL, DIMENSION(knon), INTENT(IN)        :: u1, v1, gustiness
87    REAL, DIMENSION(knon), INTENT(IN)        :: rugoro
88    REAL, DIMENSION(klon,nbsrf), INTENT(IN)  :: pctsrf
89#ifdef ISO
90    REAL, DIMENSION(ntraciso,knon), INTENT(IN) :: xtprecip_rain, xtprecip_snow
91    REAL, DIMENSION(ntraciso,knon), INTENT(IN) :: xtspechum
92#endif
93
94    ! In/Output variables
95    !******************************************************************************
96    REAL, DIMENSION(knon), INTENT(INOUT)     :: snow
97    REAL, DIMENSION(knon), INTENT(INOUT)     :: qsurf
98    REAL, DIMENSION(knon), INTENT(INOUT)     :: agesno
99    REAL, DIMENSION(knon), INTENT(inOUT)     :: z0h
100#ifdef ISO
101    REAL, DIMENSION(niso,knon), INTENT(IN)   :: xtsnow
102    REAL, DIMENSION(niso,knon), INTENT(INOUT):: Roce 
103#endif
104
105    REAL, intent(inout):: delta_sst(knon) ! (knon)
106    ! Ocean-air interface temperature minus bulk SST, in K. Defined
107    ! only if activate_ocean_skin >= 1.
108
109    real, intent(inout):: delta_sal(knon) ! (knon)
110    ! Ocean-air interface salinity minus bulk salinity, in ppt. Defined
111    ! only if activate_ocean_skin >= 1.
112
113    REAL, intent(inout):: ds_ns(knon) ! (knon)
114    ! "delta salinity near surface". Salinity variation in the
115    ! near-surface turbulent layer. That is subskin salinity minus
116    ! foundation salinity. In ppt.
117
118    REAL, intent(inout):: dt_ns(knon) ! (knon)
119    ! "delta temperature near surface". Temperature variation in the
120    ! near-surface turbulent layer. That is subskin temperature
121    ! minus foundation temperature. (Can be negative.) In K.
122
123    REAL, intent(inout):: dter(knon) ! (knon)
124    ! Temperature variation in the diffusive microlayer, that is
125    ! ocean-air interface temperature minus subskin temperature. In
126    ! K.
127
128    REAL, intent(inout):: dser(knon) ! (knon)
129    ! Salinity variation in the diffusive microlayer, that is
130    ! ocean-air interface salinity minus subskin salinity. In ppt.
131
132    real, intent(inout):: dt_ds(knon) ! (knon)
133    ! (tks / tkt) * dTer, in K
134
135!GG
136    REAL, DIMENSION(knon), INTENT(IN)        :: dthetadz300
137    REAL, DIMENSION(knon), INTENT(OUT)        :: Ampl
138!
139
140    ! Output variables
141    !**************************************************************************
142    REAL, DIMENSION(knon), INTENT(OUT)       :: z0m
143    !albedo SB >>>
144    !    REAL, DIMENSION(klon), INTENT(OUT)  :: alb1_new  ! new albedo in visible SW interval
145    !    REAL, DIMENSION(klon), INTENT(OUT)  :: alb2_new  ! new albedo in near IR interval
146    REAL, DIMENSION(6), INTENT(IN)           :: SFRWL
147    REAL, DIMENSION(knon,nsw), INTENT(OUT)   :: alb_dir_new,alb_dif_new
148    !albedo SB <<<     
149    REAL, DIMENSION(knon), INTENT(OUT)       :: evap, fluxsens, fluxlat
150    REAL, DIMENSION(knon), INTENT(OUT)       :: tsurf_new    ! sea surface temperature, in K
151    REAL, DIMENSION(knon), INTENT(OUT)       :: dflux_s, dflux_l     
152    REAL, DIMENSION(klon), INTENT(OUT)       :: lmt_bils ! ==> YM : warning variable en klon !!!
153    REAL, DIMENSION(knon), INTENT(OUT)       :: flux_u1, flux_v1
154
155    REAL, intent(out):: tkt(knon) ! (knon)
156    ! �paisseur (m) de la couche de diffusion thermique (microlayer)
157    ! cool skin thickness
158
159    REAL, intent(out):: tks(knon) ! (knon)
160    ! �paisseur (m) de la couche de diffusion de masse (microlayer)
161
162    REAL, intent(out):: taur(knon) ! (knon)
163    ! momentum flux due to rain, in Pa
164
165    real, intent(out):: sss(knon) ! (klon)
166    ! Bulk salinity of the surface layer of the ocean, in ppt. (Only
167    ! defined for subscripts 1:knon, but we have to declare it with
168    ! size klon because of the coupling machinery.)
169
170#ifdef ISO
171    REAL, DIMENSION(ntraciso,knon), INTENT(out) :: xtevap ! isotopes in surface evaporation flux
172    REAL, DIMENSION(knon), INTENT(out)          :: h1 ! just a diagnostic, not useful for the simulation   
173#endif
174
175    ! Local variables
176    !*************************************************************************
177    INTEGER               :: i, k
178    REAL                  :: tmp
179    REAL, PARAMETER       :: cepdu2=(0.1)*(0.1)
180    REAL, DIMENSION(knon) :: alb_eau, z0_lim
181    REAL, DIMENSION(knon) :: radsol
182    REAL, DIMENSION(knon) :: cdragq ! Cdrag pour l'evaporation
183    REAL, DIMENSION(knon) :: precip_totsnow
184    CHARACTER(len=20),PARAMETER :: modname="surf_ocean"
185    REAL rhoa(knon) ! density of moist air  (kg / m3)
186    REAL sens_prec_liq(knon)
187
188    REAL t_int(knon) ! ocean-air interface temperature, in K
189    REAL s_int(knon) ! ocean-air interface salinity, in ppt
190    REAL, DIMENSION(knon) :: yrlat ! compressed latitude
191    !**************************************************************************
192!$gpum nocall checksum
193
194#ifdef ISO
195#ifdef ISOVERIF
196    DO i = 1, knon
197      IF (iso_eau > 0) THEN         
198        CALL iso_verif_egalite_choix(xtspechum(iso_eau,i), &
199     &          spechum(i),'surf_ocean_mod 117', &
200     &          errmax,errmaxrel)         
201        CALL iso_verif_egalite_choix(xtsnow(iso_eau,i), &
202     &          snow(i),'surf_ocean_mod 127', &
203     &          errmax,errmaxrel)
204      ENDIF !IF (iso_eau > 0) then
205    ENDDO !DO i=1,klon
206#endif     
207#endif
208
209    !******************************************************************************
210    ! Calculate total net radiance at surface
211    !
212    !******************************************************************************
213!ym    radsol(1:klon) = 0.0 ! initialisation a priori inutile
214    radsol(1:knon) = swnet(1:knon) + lwnet(1:knon)
215
216
217    !****************************************************************************************
218    !Total solid precip
219
220    IF (ok_bs) THEN
221       precip_totsnow(:)=precip_snow(:)+precip_bs(:)
222    ELSE
223       precip_totsnow(:)=precip_snow(:)
224    ENDIF
225
226
227    !******************************************************************************
228    ! Cdragq computed from cdrag
229    ! The difference comes only from a factor (f_z0qh_oce) on z0, so that
230    ! it can be computed inside surf_ocean
231    ! More complicated appraches may require the propagation through
232    ! pbl_surface of an independant cdragq variable.
233    !******************************************************************************
234
235    IF ( f_z0qh_oce .ne. 1.) THEN
236       ! Si on suit les formulations par exemple de Tessel, on
237       ! a z0h=0.4*nu/u*, z0q=0.62*nu/u*, d'ou f_z0qh_oce=0.62/0.4=1.55
238       cdragq(1:knon)=cdragh(1:knon)*                                      &
239            log(z1lay(1:knon)/z0h(1:knon))/log(z1lay(1:knon)/(f_z0qh_oce*z0h(1:knon)))
240    ELSE
241       cdragq(1:knon)=cdragh(1:knon)
242    ENDIF
243
244    rhoa = PS(:KNON) / (Rd * temp_air(:knon) * (1. + retv * spechum(:knon)))
245    !******************************************************************************
246    ! Switch according to type of ocean (couple, slab or forced)
247    !******************************************************************************
248    SELECT CASE(type_ocean)
249    CASE('couple')
250!$gpum nocall
251       CALL ocean_cpl_noice( &
252            swnet, lwnet, alb1, &
253            windsp, fder, &
254            itime, dtime, knon, knindex, &
255            p1lay, cdragh, cdragq, cdragm, precip_rain, precip_totsnow,temp_air,spechum,&
256            AcoefH, AcoefQ, BcoefH, BcoefQ, &
257            AcoefU, AcoefV, BcoefU, BcoefV, &
258            ps, u1, v1, gustiness, tsurf_in, &
259            radsol, snow, agesno, &
260            qsurf, evap, fluxsens, fluxlat, flux_u1, flux_v1, &
261            tsurf_new, dflux_s, dflux_l, sens_prec_liq, sss, delta_sal, rhoa, &
262            delta_sst, dTer, dSer, dt_ds)
263
264    CASE('slab')
265!$gpum nocall
266       CALL ocean_slab_noice( &
267            itime, dtime, jour, knon, knindex, &
268            p1lay, cdragh, cdragq, cdragm, precip_rain, precip_totsnow, temp_air, spechum,&
269            AcoefH, AcoefQ, BcoefH, BcoefQ, &
270            AcoefU, AcoefV, BcoefU, BcoefV, &
271            ps, u1, v1, gustiness, tsurf_in, &
272            radsol, snow, &
273            qsurf, evap, fluxsens, fluxlat, flux_u1, flux_v1, &
274            tsurf_new, dflux_s, dflux_l, lmt_bils)
275
276    CASE('force')
277       CALL ocean_forced_noice( &
278            itime, dtime, jour, knon, knindex, &
279            p1lay, cdragh, cdragq, cdragm, precip_rain, precip_totsnow, &
280            temp_air, spechum, &
281            AcoefH, AcoefQ, BcoefH, BcoefQ, &
282            AcoefU, AcoefV, BcoefU, BcoefV, &
283            ps, u1, v1, gustiness, tsurf_in, &
284            radsol, snow, agesno, &
285            qsurf, evap, fluxsens, fluxlat, flux_u1, flux_v1, &
286!GG           tsurf_new, dflux_s, dflux_l, sens_prec_liq, rhoa)
287            tsurf_new, dflux_s, dflux_l, sens_prec_liq, rhoa, &
288            dthetadz300,  pctsrf, Ampl &
289!GG
290#ifdef ISO
291            ,xtprecip_rain, xtprecip_snow, xtspechum,Roce,rlat, &
292            xtsnow,xtevap,h1 & 
293#endif           
294            )
295    END SELECT
296
297    !******************************************************************************
298    ! fcodron: compute lmt_bils  forced case (same as wfbils_oce / 1.-contfracatm)
299    !******************************************************************************
300    IF (type_ocean.NE.'slab') THEN
301!ym warning uncompressed variable ==> klon
302!ym initialised outside       lmt_bils(1:klon)=0.
303!ym better to do diag outside in future
304       DO i=1,knon
305          lmt_bils(knindex(i))=(swnet(i)+lwnet(i)+fluxsens(i)+fluxlat(i)) &
306               *pctsrf(knindex(i),is_oce)/(1.-zmasq(knindex(i)))
307       END DO
308    END IF
309
310    !******************************************************************************
311    ! Calculate ocean surface albedo
312    !******************************************************************************
313    !albedo SB >>>
314    IF (iflag_albedo==0) THEN
315       !--old parametrizations of ocean surface albedo
316       !
317       IF (iflag_cycle_diurne.GE.1) THEN
318          !
319          CALL alboc_cd(knon, rmu0,alb_eau)
320          !
321          !--ad-hoc correction for model radiative balance tuning
322          !--now outside alboc_cd routine
323          alb_eau(1:knon) = fmagic*alb_eau(1:knon) + pmagic
324          alb_eau(1:knon)=MIN(MAX(alb_eau(1:knon),0.0),1.0)
325          !
326       ELSE
327          !
328          DO i =1, knon
329            yrlat(i) = rlat(knindex(i))
330          ENDDO
331
332          CALL alboc(knon, REAL(jour), yrlat, alb_eau)
333          !--ad-hoc correction for model radiative balance tuning
334          !--now outside alboc routine
335          alb_eau(1:knon) = fmagic*alb_eau(1:knon) + pmagic
336          alb_eau(1:knon)=MIN(MAX(alb_eau(1:knon),0.04),0.60)
337          !
338       ENDIF
339       !
340       DO i =1, knon
341          DO  k=1,nsw
342             alb_dir_new(i,k) = alb_eau(i)
343          ENDDO
344       ENDDO
345       !IM 09122015 next line corresponds to the old way of doing in LMDZ5A/IPSLCM5A versions
346       !albedo for diffuse radiation is taken the same as for direct radiation
347       alb_dif_new(1:knon,:)=alb_dir_new(1:knon,:)
348       !IM 09122015 end
349       !
350    ELSE IF (iflag_albedo==1) THEN
351       !--new parametrization of ocean surface albedo by Sunghye Baek
352       !--albedo for direct and diffuse radiation are different
353       !
354       CALL checksum("yalb_dir_new_ocean",alb_dir_new(1:knon,:))
355       CALL ocean_albedo(knon,rmu0,knindex,windsp,SFRWL,alb_dir_new,alb_dif_new)
356       CALL checksum("yalb_dir_new_ocean",alb_dir_new(1:knon,:))
357
358       !
359       !--ad-hoc correction for model radiative balance tuning
360       alb_dir_new(1:knon,:) = fmagic*alb_dir_new(1:knon,:) + pmagic
361       alb_dif_new(1:knon,:) = fmagic*alb_dif_new(1:knon,:) + pmagic
362       alb_dir_new(1:knon,:)=MIN(MAX(alb_dir_new(1:knon,:),0.0),1.0)
363       alb_dif_new(1:knon,:)=MIN(MAX(alb_dif_new(1:knon,:),0.0),1.0)
364       !
365    ELSE IF (iflag_albedo==2) THEN
366       ! F. Codron albedo read from limit.nc
367       CALL limit_read_rug_alb(itime, dtime, jour,&
368            knon, knindex, z0_lim, alb_eau)
369       DO i =1, knon
370          DO  k=1,nsw
371             alb_dir_new(i,k) = alb_eau(i)
372          ENDDO
373       ENDDO
374       alb_dif_new=alb_dir_new
375    ENDIF
376    !albedo SB <<<
377
378    !******************************************************************************
379    ! Calculate the rugosity
380    !******************************************************************************
381    IF (iflag_z0_oce==0) THEN
382       DO i = 1, knon
383          tmp = MAX(cepdu2,gustiness(i)+u1(i)**2+v1(i)**2)
384          z0m(i) = 0.018*cdragm(i) * (gustiness(i)+u1(i)**2+v1(i)**2)/RG  &
385               +  0.11*14e-6 / SQRT(cdragm(i) * tmp)
386          z0m(i) = MAX(1.5e-05,z0m(i))
387       ENDDO
388       z0h(1:knon)=z0m(1:knon) ! En attendant mieux
389
390    ELSE IF (iflag_z0_oce==1) THEN
391       DO i = 1, knon
392          tmp = MAX(cepdu2,gustiness(i)+u1(i)**2+v1(i)**2)
393          z0m(i) = 0.018*cdragm(i) * (gustiness(i)+u1(i)**2+v1(i)**2)/RG  &
394               + 0.11*14e-6 / SQRT(cdragm(i) * tmp)
395          z0m(i) = MAX(1.5e-05,z0m(i))
396          z0h(i)=0.4*14e-6 / SQRT(cdragm(i) * tmp)
397       ENDDO
398    ELSE IF (iflag_z0_oce==-1) THEN
399       DO i = 1, knon
400          z0m(i) = z0min
401          z0h(i) = z0min
402       ENDDO
403    ELSE
404       CALL abort_physic(modname,'version non prevue',1)
405    ENDIF
406
407    if (activate_ocean_skin >= 1) then
408!ym not porting to GPU for now     
409       if (type_ocean /= 'couple') sss(:knon) = 35.
410!$gpum nocall
411       call bulk_flux(tkt, tks, taur, dter, dser, t_int, s_int, ds_ns, dt_ns, &
412            u = windsp(:knon), t_ocean_1 = tsurf_new(:knon), s1 = sss(:knon), &
413            rain = precip_rain(:knon) + precip_totsnow(:knon), &
414            hf = - fluxsens(:knon), hlb = - fluxlat(:knon), &
415            rnl = - lwnet(:knon), &
416            tau = sqrt(flux_u1(:knon)**2 + flux_v1(:knon)**2), rhoa = rhoa, &
417            xlv = [(rlvtt, i = 1, knon)], rf = - sens_prec_liq, dtime = dtime, &
418            rns = swnet(:knon))
419       delta_sst = t_int - tsurf_new(:knon)
420       delta_sal = s_int - sss(:knon)
421
422       if (activate_ocean_skin == 2) then
423          tsurf_new(:knon) = t_int
424          if (type_ocean == 'couple') dt_ds = (tks / tkt) * dter
425       end if
426    end if
427   
428  END SUBROUTINE surf_ocean
429  !****************************************************************************
430  !
431END MODULE surf_ocean_mod
Note: See TracBrowser for help on using the repository browser.