Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
MODULE sbc_phy
!!======================================================================
!! *** MODULE sbc_phy ***
!! A set of functions to compute air themodynamics parameters
!! needed by Aerodynamic Bulk Formulas
!!=====================================================================
!! 4.x ! 2020 L. Brodeau from AeroBulk package (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------
!! virt_temp : virtual (aka sensible) temperature (potential or absolute)
!! rho_air : density of (moist) air (depends on T_air, q_air and SLP
!! visc_air : kinematic viscosity (aka Nu_air) of air from temperature
!! L_vap : latent heat of vaporization of water as a function of temperature
!! cp_air : specific heat of (moist) air (depends spec. hum. q_air)
!! gamma_moist : adiabatic lapse-rate of moist air
!! One_on_L : 1. / ( Obukhov length )
!! Ri_bulk : bulk Richardson number aka BRN
!! q_sat : saturation humidity as a function of SLP and temperature
!! q_air_rh : specific humidity as a function of RH (fraction, not %), t_air and SLP
USE dom_oce ! ocean space and time domain
USE phycst ! physical constants
IMPLICIT NONE
!PRIVATE
PUBLIC !! Haleluja that was the solution
INTEGER , PARAMETER, PUBLIC :: nb_iter0 = 5 ! Default number of itterations in bulk-param algorithms (can be overriden b.m.o `nb_iter` optional argument)
!! (mainly removed from sbcblk.F90)
REAL(wp), PARAMETER, PUBLIC :: rCp_dry = 1005.0_wp !: Specic heat of dry air, constant pressure [J/K/kg]
REAL(wp), PARAMETER, PUBLIC :: rCp_vap = 1860.0_wp !: Specic heat of water vapor, constant pressure [J/K/kg]
REAL(wp), PARAMETER, PUBLIC :: R_dry = 287.05_wp !: Specific gas constant for dry air [J/K/kg]
REAL(wp), PARAMETER, PUBLIC :: R_vap = 461.495_wp !: Specific gas constant for water vapor [J/K/kg]
REAL(wp), PARAMETER, PUBLIC :: reps0 = R_dry/R_vap !: ratio of gas constant for dry air and water vapor => ~ 0.622
REAL(wp), PARAMETER, PUBLIC :: rctv0 = R_vap/R_dry - 1._wp !: for virtual temperature (== (1-eps)/eps) => ~ 0.608
REAL(wp), PARAMETER, PUBLIC :: rCp_air = 1000.5_wp !: specific heat of air (only used for ice fluxes now...)
REAL(wp), PARAMETER, PUBLIC :: albo = 0.066_wp !: ocean albedo assumed to be constant
!
REAL(wp), PARAMETER, PUBLIC :: rho0_a = 1.2_wp !: Approx. of density of air [kg/m^3]
REAL(wp), PARAMETER, PUBLIC :: rho0_w = 1025._wp !: Density of sea-water (ECMWF->1025) [kg/m^3]
REAL(wp), PARAMETER, PUBLIC :: radrw = rho0_a/rho0_w !: Density ratio
REAL(wp), PARAMETER, PUBLIC :: sq_radrw = SQRT(rho0_a/rho0_w)
REAL(wp), PARAMETER, PUBLIC :: rCp0_w = 4190._wp !: Specific heat capacity of seawater (ECMWF 4190) [J/K/kg]
REAL(wp), PARAMETER, PUBLIC :: rnu0_w = 1.e-6_wp !: kinetic viscosity of water [m^2/s]
REAL(wp), PARAMETER, PUBLIC :: rk0_w = 0.6_wp !: thermal conductivity of water (at 20C) [W/m/K]
!
REAL(wp), PARAMETER, PUBLIC :: emiss_w = 0.98_wp !: Long-wave (thermal) emissivity of sea-water []
!
REAL(wp), PARAMETER, PUBLIC :: emiss_i = 0.996_wp !: " for ice and snow => but Rees 1993 suggests can be lower in winter on fresh snow... 0.72 ...
REAL(wp), PARAMETER, PUBLIC :: wspd_thrshld_ice = 0.2_wp !: minimum scalar wind speed accepted over sea-ice... [m/s]
!
REAL(wp), PARAMETER, PUBLIC :: rdct_qsat_salt = 0.98_wp !: reduction factor on specific humidity at saturation (q_sat(T_s)) due to salt
REAL(wp), PARAMETER, PUBLIC :: rtt0 = 273.16_wp !: triple point of temperature [K]
!
REAL(wp), PARAMETER, PUBLIC :: rcst_cs = -16._wp*9.80665_wp*rho0_w*rCp0_w*rnu0_w*rnu0_w*rnu0_w/(rk0_w*rk0_w) !: for cool-skin parameterizations... (grav = 9.80665_wp)
! => see eq.(14) in Fairall et al. 1996 (eq.(6) of Zeng aand Beljaars is WRONG! (typo?)
REAL(wp), PARAMETER, PUBLIC :: z0_sea_max = 0.0025_wp !: maximum realistic value for roughness length of sea-surface... [m]
REAL(wp), PUBLIC, SAVE :: pp_cldf = 0.81 !: cloud fraction over sea ice, summer CLIO value [-]
REAL(wp), PARAMETER, PUBLIC :: Cx_min = 0.1E-3_wp ! smallest value allowed for bulk transfer coefficients (usually in stable conditions with now wind)
REAL(wp), PARAMETER :: &
!! Constants for Goff formula in the presence of ice:
& rAg_i = -9.09718_wp, &
& rBg_i = -3.56654_wp, &
& rCg_i = 0.876793_wp, &
& rDg_i = LOG10(6.1071_wp)
REAL(wp), PARAMETER :: rc_louis = 5._wp
REAL(wp), PARAMETER :: rc2_louis = rc_louis * rc_louis
REAL(wp), PARAMETER :: ram_louis = 2. * rc_louis
REAL(wp), PARAMETER :: rah_louis = 3. * rc_louis
INTERFACE virt_temp
MODULE PROCEDURE virt_temp_vctr, virt_temp_sclr
END INTERFACE virt_temp
INTERFACE visc_air
MODULE PROCEDURE visc_air_vctr, visc_air_sclr
END INTERFACE visc_air
INTERFACE gamma_moist
MODULE PROCEDURE gamma_moist_vctr, gamma_moist_sclr
END INTERFACE gamma_moist
INTERFACE e_sat
MODULE PROCEDURE e_sat_vctr, e_sat_sclr
END INTERFACE e_sat
INTERFACE e_sat_ice
MODULE PROCEDURE e_sat_ice_vctr, e_sat_ice_sclr
END INTERFACE e_sat_ice
INTERFACE de_sat_dt_ice
MODULE PROCEDURE de_sat_dt_ice_vctr, de_sat_dt_ice_sclr
END INTERFACE de_sat_dt_ice
INTERFACE Ri_bulk
MODULE PROCEDURE Ri_bulk_vctr, Ri_bulk_sclr
END INTERFACE Ri_bulk
INTERFACE q_sat
MODULE PROCEDURE q_sat_vctr, q_sat_sclr
END INTERFACE q_sat
INTERFACE dq_sat_dt_ice
MODULE PROCEDURE dq_sat_dt_ice_vctr, dq_sat_dt_ice_sclr
END INTERFACE dq_sat_dt_ice
INTERFACE L_vap
MODULE PROCEDURE L_vap_vctr, L_vap_sclr
END INTERFACE L_vap
INTERFACE rho_air
MODULE PROCEDURE rho_air_vctr, rho_air_sclr
END INTERFACE rho_air
INTERFACE cp_air
MODULE PROCEDURE cp_air_vctr, cp_air_sclr
END INTERFACE cp_air
INTERFACE alpha_sw
MODULE PROCEDURE alpha_sw_vctr, alpha_sw_sclr
END INTERFACE alpha_sw
INTERFACE bulk_formula
MODULE PROCEDURE bulk_formula_vctr, bulk_formula_sclr
END INTERFACE bulk_formula
INTERFACE qlw_net
MODULE PROCEDURE qlw_net_vctr, qlw_net_sclr
END INTERFACE qlw_net
INTERFACE f_m_louis
MODULE PROCEDURE f_m_louis_vctr, f_m_louis_sclr
END INTERFACE f_m_louis
INTERFACE f_h_louis
MODULE PROCEDURE f_h_louis_vctr, f_h_louis_sclr
END INTERFACE f_h_louis
PUBLIC virt_temp
PUBLIC rho_air
PUBLIC visc_air
PUBLIC L_vap
PUBLIC cp_air
PUBLIC gamma_moist
PUBLIC One_on_L
PUBLIC Ri_bulk
PUBLIC q_sat
PUBLIC q_air_rh
PUBLIC dq_sat_dt_ice
!:
PUBLIC update_qnsol_tau
PUBLIC alpha_sw
PUBLIC bulk_formula
PUBLIC qlw_net
!
PUBLIC f_m_louis, f_h_louis
PUBLIC z0_from_Cd
PUBLIC Cd_from_z0
PUBLIC UN10_from_ustar
PUBLIC UN10_from_CD
PUBLIC z0tq_LKB
!! * Substitutions
# include "do_loop_substitute.h90"
!!----------------------------------------------------------------------
!! NEMO/OCE 4.0 , NEMO Consortium (2018)
!! $Id: sbcblk.F90 10535 2019-01-16 17:36:47Z clem $
!! Software governed by the CeCILL license (see ./LICENSE)
!!----------------------------------------------------------------------
CONTAINS
FUNCTION virt_temp_sclr( pta, pqa )
!!------------------------------------------------------------------------
!!
!! Compute the (absolute/potential) VIRTUAL temperature, based on the
!! (absolute/potential) temperature and specific humidity
!!
!! If input temperature is absolute then output virtual temperature is absolute
!! If input temperature is potential then output virtual temperature is potential
!!
!! Author: L. Brodeau, June 2019 / AeroBulk
!! (https://github.com/brodeau/aerobulk/)
!!------------------------------------------------------------------------
REAL(wp) :: virt_temp_sclr !: virtual temperature [K]
REAL(wp), INTENT(in) :: pta !: absolute or potential air temperature [K]
REAL(wp), INTENT(in) :: pqa !: specific humidity of air [kg/kg]
!!-------------------------------------------------------------------
!
virt_temp_sclr = pta * (1._wp + rctv0*pqa)
!!
!! This is exactly the same thing as:
!! virt_temp_sclr = pta * ( pwa + reps0) / (reps0*(1.+pwa))
!! with wpa (mixing ration) defined as : pwa = pqa/(1.-pqa)
!
END FUNCTION virt_temp_sclr
!!
FUNCTION virt_temp_vctr( pta, pqa )
REAL(wp), DIMENSION(jpi,jpj) :: virt_temp_vctr !: virtual temperature [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pta !: absolute or potential air temperature [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqa !: specific humidity of air [kg/kg]
virt_temp_vctr(:,:) = pta(:,:) * (1._wp + rctv0*pqa(:,:))
END FUNCTION virt_temp_vctr
!===============================================================================================
FUNCTION rho_air_vctr( ptak, pqa, ppa )
!!-------------------------------------------------------------------------------
!! *** FUNCTION rho_air_vctr ***
!!
!! ** Purpose : compute density of (moist) air using the eq. of state of the atmosphere
!!
!! ** Author: L. Brodeau, June 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!-------------------------------------------------------------------------------
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptak ! air temperature [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqa ! air specific humidity [kg/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ppa ! pressure in [Pa]
REAL(wp), DIMENSION(jpi,jpj) :: rho_air_vctr ! density of moist air [kg/m^3]
!!-------------------------------------------------------------------------------
rho_air_vctr = MAX( ppa / (R_dry*ptak * ( 1._wp + rctv0*pqa )) , 0.8_wp )
END FUNCTION rho_air_vctr
FUNCTION rho_air_sclr( ptak, pqa, ppa )
!!-------------------------------------------------------------------------------
!! *** FUNCTION rho_air_sclr ***
!!
!! ** Purpose : compute density of (moist) air using the eq. of state of the atmosphere
!!
!! ** Author: L. Brodeau, June 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!-------------------------------------------------------------------------------
REAL(wp), INTENT(in) :: ptak ! air temperature [K]
REAL(wp), INTENT(in) :: pqa ! air specific humidity [kg/kg]
REAL(wp), INTENT(in) :: ppa ! pressure in [Pa]
REAL(wp) :: rho_air_sclr ! density of moist air [kg/m^3]
!!-------------------------------------------------------------------------------
rho_air_sclr = MAX( ppa / (R_dry*ptak * ( 1._wp + rctv0*pqa )) , 0.8_wp )
END FUNCTION rho_air_sclr
FUNCTION visc_air_sclr(ptak)
!!----------------------------------------------------------------------------------
!! Air kinetic viscosity (m^2/s) given from air temperature in Kelvin
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp) :: visc_air_sclr ! kinetic viscosity (m^2/s)
REAL(wp), INTENT(in) :: ptak ! air temperature in (K)
!
REAL(wp) :: ztc, ztc2 ! local scalar
!!----------------------------------------------------------------------------------
!
ztc = ptak - rt0 ! air temp, in deg. C
ztc2 = ztc*ztc
visc_air_sclr = 1.326e-5*(1. + 6.542E-3*ztc + 8.301e-6*ztc2 - 4.84e-9*ztc2*ztc)
!
END FUNCTION visc_air_sclr
FUNCTION visc_air_vctr(ptak)
REAL(wp), DIMENSION(jpi,jpj) :: visc_air_vctr ! kinetic viscosity (m^2/s)
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptak ! air temperature in (K)
INTEGER :: ji, jj ! dummy loop indices
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
visc_air_vctr(ji,jj) = visc_air_sclr( ptak(ji,jj) )
END_2D
END FUNCTION visc_air_vctr
FUNCTION L_vap_vctr( psst )
!!---------------------------------------------------------------------------------
!! *** FUNCTION L_vap_vctr ***
!!
!! ** Purpose : Compute the latent heat of vaporization of water from temperature
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp), DIMENSION(jpi,jpj) :: L_vap_vctr ! latent heat of vaporization [J/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: psst ! water temperature [K]
!!----------------------------------------------------------------------------------
!
L_vap_vctr = ( 2.501_wp - 0.00237_wp * ( psst(:,:) - rt0) ) * 1.e6_wp
!
END FUNCTION L_vap_vctr
FUNCTION L_vap_sclr( psst )
!!---------------------------------------------------------------------------------
!! *** FUNCTION L_vap_sclr ***
!!
!! ** Purpose : Compute the latent heat of vaporization of water from temperature
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp) :: L_vap_sclr ! latent heat of vaporization [J/kg]
REAL(wp), INTENT(in) :: psst ! water temperature [K]
!!----------------------------------------------------------------------------------
!
L_vap_sclr = ( 2.501_wp - 0.00237_wp * ( psst - rt0) ) * 1.e6_wp
!
END FUNCTION L_vap_sclr
FUNCTION cp_air_vctr( pqa )
!!-------------------------------------------------------------------------------
!! *** FUNCTION cp_air_vctr ***
!!
!! ** Purpose : Compute specific heat (Cp) of moist air
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!-------------------------------------------------------------------------------
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqa ! air specific humidity [kg/kg]
REAL(wp), DIMENSION(jpi,jpj) :: cp_air_vctr ! specific heat of moist air [J/K/kg]
!!-------------------------------------------------------------------------------
cp_air_vctr = rCp_dry + rCp_vap * pqa
END FUNCTION cp_air_vctr
FUNCTION cp_air_sclr( pqa )
!!-------------------------------------------------------------------------------
!! *** FUNCTION cp_air_sclr ***
!!
!! ** Purpose : Compute specific heat (Cp) of moist air
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!-------------------------------------------------------------------------------
REAL(wp), INTENT(in) :: pqa ! air specific humidity [kg/kg]
REAL(wp) :: cp_air_sclr ! specific heat of moist air [J/K/kg]
!!-------------------------------------------------------------------------------
cp_air_sclr = rCp_dry + rCp_vap * pqa
END FUNCTION cp_air_sclr
!===============================================================================================
FUNCTION gamma_moist_sclr( ptak, pqa )
!!----------------------------------------------------------------------------------
!! ** Purpose : Compute the moist adiabatic lapse-rate.
!! => http://glossary.ametsoc.org/wiki/Moist-adiabatic_lapse_rate
!! => http://www.geog.ucsb.edu/~joel/g266_s10/lecture_notes/chapt03/oh10_3_01/oh10_3_01.html
!!
!! ** Author: L. Brodeau, June 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp) :: gamma_moist_sclr ! [K/m]
REAL(wp), INTENT(in) :: ptak ! absolute air temperature [K] !#LB: double check it's absolute !!!
REAL(wp), INTENT(in) :: pqa ! specific humidity [kg/kg]
!
REAL(wp) :: zta, zqa, zwa, ziRT, zLvap ! local scalars
!!----------------------------------------------------------------------------------
zta = MAX( ptak, 180._wp) ! prevents screw-up over masked regions where field == 0.
zqa = MAX( pqa, 1.E-6_wp) ! " " "
!!
zwa = zqa / (1._wp - zqa) ! w is mixing ratio w = q/(1-q) | q = w/(1+w)
ziRT = 1._wp / (R_dry*zta) ! 1/RT
zLvap = L_vap_sclr( ptak )
!!
gamma_moist_sclr = grav * ( 1._wp + zLvap*zwa*ziRT ) / ( rCp_dry + zLvap*zLvap*zwa*reps0*ziRT/zta )
!!
END FUNCTION gamma_moist_sclr
!!
FUNCTION gamma_moist_vctr( ptak, pqa )
REAL(wp), DIMENSION(jpi,jpj) :: gamma_moist_vctr
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptak
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqa
INTEGER :: ji, jj
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
gamma_moist_vctr(ji,jj) = gamma_moist_sclr( ptak(ji,jj), pqa(ji,jj) )
END_2D
END FUNCTION gamma_moist_vctr
!===============================================================================================
FUNCTION One_on_L( ptha, pqa, pus, pts, pqs )
!!------------------------------------------------------------------------
!!
!! Evaluates the 1./(Obukhov length) from air temperature,
!! air specific humidity, and frictional scales u*, t* and q*
!!
!! Author: L. Brodeau, June 2019 / AeroBulk
!! (https://github.com/brodeau/aerobulk/)
!!------------------------------------------------------------------------
REAL(wp), DIMENSION(jpi,jpj) :: One_on_L !: 1./(Obukhov length) [m^-1]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptha !: reference potential temperature of air [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqa !: reference specific humidity of air [kg/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pus !: u*: friction velocity [m/s]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pts, pqs !: \theta* and q* friction aka turb. scales for temp. and spec. hum.
!
INTEGER :: ji, jj ! dummy loop indices
REAL(wp) :: zqa ! local scalar
!!-------------------------------------------------------------------
!
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
!
zqa = (1._wp + rctv0*pqa(ji,jj))
!
! The main concern is to know whether, the vertical turbulent flux of virtual temperature, < u' theta_v' > is estimated with:
! a/ -u* [ theta* (1 + 0.61 q) + 0.61 theta q* ] => this is the one that seems correct! chose this one!
! or
! b/ -u* [ theta* + 0.61 theta q* ]
!
One_on_L(ji,jj) = grav*vkarmn*( pts(ji,jj)*zqa + rctv0*ptha(ji,jj)*pqs(ji,jj) ) &
& / MAX( pus(ji,jj)*pus(ji,jj)*ptha(ji,jj)*zqa , 1.E-9_wp )
!
END_2D
!
One_on_L = SIGN( MIN(ABS(One_on_L),200._wp), One_on_L ) ! (prevent FPE from stupid values over masked regions...)
!
END FUNCTION One_on_L
!===============================================================================================
FUNCTION Ri_bulk_sclr( pz, psst, ptha, pssq, pqa, pub, pta_layer, pqa_layer )
!!----------------------------------------------------------------------------------
!! Bulk Richardson number according to "wide-spread equation"...
!!
!! Reminder: the Richardson number is the ratio "buoyancy" / "shear"
!!
!! ** Author: L. Brodeau, June 2019 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp) :: Ri_bulk_sclr
REAL(wp), INTENT(in) :: pz ! height above the sea (aka "delta z") [m]
REAL(wp), INTENT(in) :: psst ! SST [K]
REAL(wp), INTENT(in) :: ptha ! pot. air temp. at height "pz" [K]
REAL(wp), INTENT(in) :: pssq ! 0.98*q_sat(SST) [kg/kg]
REAL(wp), INTENT(in) :: pqa ! air spec. hum. at height "pz" [kg/kg]
REAL(wp), INTENT(in) :: pub ! bulk wind speed [m/s]
REAL(wp), INTENT(in), OPTIONAL :: pta_layer ! when possible, a better guess of absolute temperature WITHIN the layer [K]
REAL(wp), INTENT(in), OPTIONAL :: pqa_layer ! when possible, a better guess of specific humidity WITHIN the layer [kg/kg]
!!
LOGICAL :: l_ptqa_l_prvd = .FALSE.
REAL(wp) :: zqa, zta, zgamma, zdthv, ztv, zsstv ! local scalars
!!-------------------------------------------------------------------
IF( PRESENT(pta_layer) .AND. PRESENT(pqa_layer) ) l_ptqa_l_prvd=.TRUE.
!
zsstv = virt_temp_sclr( psst, pssq ) ! virtual SST (absolute==potential because z=0!)
!
zdthv = virt_temp_sclr( ptha, pqa ) - zsstv ! air-sea delta of "virtual potential temperature"
!
!! ztv: estimate of the ABSOLUTE virtual temp. within the layer
IF( l_ptqa_l_prvd ) THEN
ztv = virt_temp_sclr( pta_layer, pqa_layer )
ELSE
zqa = 0.5_wp*( pqa + pssq ) ! ~ mean q within the layer...
zta = 0.5_wp*( psst + ptha - gamma_moist(ptha, zqa)*pz ) ! ~ mean absolute temperature of air within the layer
zta = 0.5_wp*( psst + ptha - gamma_moist( zta, zqa)*pz ) ! ~ mean absolute temperature of air within the layer
zgamma = gamma_moist(zta, zqa) ! Adiabatic lapse-rate for moist air within the layer
ztv = 0.5_wp*( zsstv + virt_temp_sclr( ptha-zgamma*pz, pqa ) )
END IF
!
Ri_bulk_sclr = grav*zdthv*pz / ( ztv*pub*pub ) ! the usual definition of Ri_bulk_sclr
!
END FUNCTION Ri_bulk_sclr
!!
FUNCTION Ri_bulk_vctr( pz, psst, ptha, pssq, pqa, pub, pta_layer, pqa_layer )
REAL(wp), DIMENSION(jpi,jpj) :: Ri_bulk_vctr
REAL(wp) , INTENT(in) :: pz ! height above the sea (aka "delta z") [m]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: psst ! SST [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptha ! pot. air temp. at height "pz" [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pssq ! 0.98*q_sat(SST) [kg/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqa ! air spec. hum. at height "pz" [kg/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pub ! bulk wind speed [m/s]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in), OPTIONAL :: pta_layer ! when possible, a better guess of absolute temperature WITHIN the layer [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in), OPTIONAL :: pqa_layer ! when possible, a better guess of specific humidity WITHIN the layer [kg/kg]
!!
LOGICAL :: l_ptqa_l_prvd = .FALSE.
INTEGER :: ji, jj
IF( PRESENT(pta_layer) .AND. PRESENT(pqa_layer) ) l_ptqa_l_prvd=.TRUE.
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
IF( l_ptqa_l_prvd ) THEN
Ri_bulk_vctr(ji,jj) = Ri_bulk_sclr( pz, psst(ji,jj), ptha(ji,jj), pssq(ji,jj), pqa(ji,jj), pub(ji,jj), &
& pta_layer=pta_layer(ji,jj ), pqa_layer=pqa_layer(ji,jj ) )
ELSE
Ri_bulk_vctr(ji,jj) = Ri_bulk_sclr( pz, psst(ji,jj), ptha(ji,jj), pssq(ji,jj), pqa(ji,jj), pub(ji,jj) )
END IF
END_2D
END FUNCTION Ri_bulk_vctr
!===============================================================================================
!===============================================================================================
FUNCTION e_sat_sclr( ptak )
!!----------------------------------------------------------------------------------
!! *** FUNCTION e_sat_sclr ***
!! < SCALAR argument version >
!! ** Purpose : water vapor at saturation in [Pa]
!! Based on accurate estimate by Goff, 1957
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!
!! Note: what rt0 should be here, is 273.16 (triple point of water) and not 273.15 like here
!!----------------------------------------------------------------------------------
REAL(wp) :: e_sat_sclr ! water vapor at saturation [kg/kg]
REAL(wp), INTENT(in) :: ptak ! air temperature [K]
REAL(wp) :: zta, ztmp ! local scalar
!!----------------------------------------------------------------------------------
zta = MAX( ptak , 180._wp ) ! air temp., prevents fpe0 errors dute to unrealistically low values over masked regions...
ztmp = rt0 / zta !#LB: rt0 or rtt0 ???? (273.15 vs 273.16 )
!
! Vapour pressure at saturation [Pa] : WMO, (Goff, 1957)
e_sat_sclr = 100.*( 10.**( 10.79574*(1. - ztmp) - 5.028*LOG10(zta/rt0) &
& + 1.50475*10.**(-4)*(1. - 10.**(-8.2969*(zta/rt0 - 1.)) ) &
& + 0.42873*10.**(-3)*(10.**(4.76955*(1. - ztmp)) - 1.) + 0.78614) )
!
END FUNCTION e_sat_sclr
!!
FUNCTION e_sat_vctr(ptak)
REAL(wp), DIMENSION(jpi,jpj) :: e_sat_vctr !: vapour pressure at saturation [Pa]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptak !: temperature (K)
INTEGER :: ji, jj ! dummy loop indices
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
e_sat_vctr(ji,jj) = e_sat_sclr(ptak(ji,jj))
END_2D
END FUNCTION e_sat_vctr
!===============================================================================================
!===============================================================================================
FUNCTION e_sat_ice_sclr(ptak)
!!---------------------------------------------------------------------------------
!! Same as "e_sat" but over ice rather than water!
!!---------------------------------------------------------------------------------
REAL(wp) :: e_sat_ice_sclr !: vapour pressure at saturation in presence of ice [Pa]
REAL(wp), INTENT(in) :: ptak
!!
REAL(wp) :: zta, zle, ztmp
!!---------------------------------------------------------------------------------
zta = MAX( ptak , 180._wp ) ! air temp., prevents fpe0 errors dute to unrealistically low values over masked regions...
ztmp = rtt0/zta
!!
zle = rAg_i*(ztmp - 1._wp) + rBg_i*LOG10(ztmp) + rCg_i*(1._wp - zta/rtt0) + rDg_i
!!
e_sat_ice_sclr = 100._wp * 10._wp**zle
END FUNCTION e_sat_ice_sclr
!!
FUNCTION e_sat_ice_vctr(ptak)
!! Same as "e_sat" but over ice rather than water!
REAL(wp), DIMENSION(jpi,jpj) :: e_sat_ice_vctr !: vapour pressure at saturation in presence of ice [Pa]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptak
INTEGER :: ji, jj
!!----------------------------------------------------------------------------------
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
e_sat_ice_vctr(ji,jj) = e_sat_ice_sclr( ptak(ji,jj) )
END_2D
END FUNCTION e_sat_ice_vctr
!!
FUNCTION de_sat_dt_ice_sclr(ptak)
!!---------------------------------------------------------------------------------
!! d [ e_sat_ice ] / dT (derivative / temperature)
!! Analytical exact formulation: double checked!!!
!! => DOUBLE-check possible / finite-difference version with "./bin/test_phymbl.x"
!!---------------------------------------------------------------------------------
REAL(wp) :: de_sat_dt_ice_sclr !: [Pa/K]
REAL(wp), INTENT(in) :: ptak
!!
REAL(wp) :: zta, zde
!!---------------------------------------------------------------------------------
zta = MAX( ptak , 180._wp ) ! air temp., prevents fpe0 errors dute to unrealistically low values over masked regions...
!!
zde = -(rAg_i*rtt0)/(zta*zta) - rBg_i/(zta*LOG(10._wp)) - rCg_i/rtt0
!!
de_sat_dt_ice_sclr = LOG(10._wp) * zde * e_sat_ice_sclr(zta)
END FUNCTION de_sat_dt_ice_sclr
!!
FUNCTION de_sat_dt_ice_vctr(ptak)
!! Same as "e_sat" but over ice rather than water!
REAL(wp), DIMENSION(jpi,jpj) :: de_sat_dt_ice_vctr !: vapour pressure at saturation in presence of ice [Pa]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptak
INTEGER :: ji, jj
!!----------------------------------------------------------------------------------
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
de_sat_dt_ice_vctr(ji,jj) = de_sat_dt_ice_sclr( ptak(ji,jj) )
END_2D
END FUNCTION de_sat_dt_ice_vctr
!===============================================================================================
!===============================================================================================
FUNCTION q_sat_sclr( pta, ppa, l_ice )
!!---------------------------------------------------------------------------------
!! *** FUNCTION q_sat_sclr ***
!!
!! ** Purpose : Conputes specific humidity of air at saturation
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp) :: q_sat_sclr
REAL(wp), INTENT(in) :: pta !: absolute temperature of air [K]
REAL(wp), INTENT(in) :: ppa !: atmospheric pressure [Pa]
LOGICAL, INTENT(in), OPTIONAL :: l_ice !: we are above ice
REAL(wp) :: ze_s
LOGICAL :: lice
!!----------------------------------------------------------------------------------
lice = .FALSE.
IF( PRESENT(l_ice) ) lice = l_ice
IF( lice ) THEN
ze_s = e_sat_ice( pta )
ELSE
ze_s = e_sat( pta ) ! Vapour pressure at saturation (Goff) :
END IF
q_sat_sclr = reps0*ze_s/(ppa - (1._wp - reps0)*ze_s)
END FUNCTION q_sat_sclr
!!
FUNCTION q_sat_vctr( pta, ppa, l_ice )
REAL(wp), DIMENSION(jpi,jpj) :: q_sat_vctr
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pta !: absolute temperature of air [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ppa !: atmospheric pressure [Pa]
LOGICAL, INTENT(in), OPTIONAL :: l_ice !: we are above ice
LOGICAL :: lice
INTEGER :: ji, jj
!!----------------------------------------------------------------------------------
lice = .FALSE.
IF( PRESENT(l_ice) ) lice = l_ice
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
q_sat_vctr(ji,jj) = q_sat_sclr( pta(ji,jj) , ppa(ji,jj), l_ice=lice )
END_2D
END FUNCTION q_sat_vctr
!===============================================================================================
!===============================================================================================
FUNCTION dq_sat_dt_ice_sclr( pta, ppa )
!!---------------------------------------------------------------------------------
!! *** FUNCTION dq_sat_dt_ice_sclr ***
!! => d [ q_sat_ice(T) ] / dT
!! Analytical exact formulation: double checked!!!
!! => DOUBLE-check possible / finite-difference version with "./bin/test_phymbl.x"
!!----------------------------------------------------------------------------------
REAL(wp) :: dq_sat_dt_ice_sclr
REAL(wp), INTENT(in) :: pta !: absolute temperature of air [K]
REAL(wp), INTENT(in) :: ppa !: atmospheric pressure [Pa]
REAL(wp) :: ze_s, zde_s_dt, ztmp
!!----------------------------------------------------------------------------------
ze_s = e_sat_ice_sclr( pta ) ! Vapour pressure at saturation in presence of ice (Goff)
zde_s_dt = de_sat_dt_ice( pta )
!
ztmp = (reps0 - 1._wp)*ze_s + ppa
!
dq_sat_dt_ice_sclr = reps0*ppa*zde_s_dt / ( ztmp*ztmp )
!
END FUNCTION dq_sat_dt_ice_sclr
!!
FUNCTION dq_sat_dt_ice_vctr( pta, ppa )
REAL(wp), DIMENSION(jpi,jpj) :: dq_sat_dt_ice_vctr
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pta !: absolute temperature of air [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ppa !: atmospheric pressure [Pa]
INTEGER :: ji, jj
!!----------------------------------------------------------------------------------
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
dq_sat_dt_ice_vctr(ji,jj) = dq_sat_dt_ice_sclr( pta(ji,jj) , ppa(ji,jj) )
END_2D
END FUNCTION dq_sat_dt_ice_vctr
!===============================================================================================
!===============================================================================================
FUNCTION q_air_rh(prha, ptak, ppa)
!!----------------------------------------------------------------------------------
!! Specific humidity of air out of Relative Humidity
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp), DIMENSION(jpi,jpj) :: q_air_rh
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: prha !: relative humidity [fraction, not %!!!]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptak !: air temperature [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ppa !: atmospheric pressure [Pa]
!
INTEGER :: ji, jj ! dummy loop indices
REAL(wp) :: ze ! local scalar
!!----------------------------------------------------------------------------------
!
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
ze = prha(ji,jj)*e_sat_sclr(ptak(ji,jj))
q_air_rh(ji,jj) = ze*reps0/(ppa(ji,jj) - (1. - reps0)*ze)
END_2D
!
END FUNCTION q_air_rh
SUBROUTINE UPDATE_QNSOL_TAU( pzu, pTs, pqs, pTa, pqa, pust, ptst, pqst, pwnd, pUb, ppa, prlw, &
& pQns, pTau, &
& Qlat)
!!----------------------------------------------------------------------------------
!! Purpose: returns the non-solar heat flux to the ocean aka "Qlat + Qsen + Qlw"
!! and the module of the wind stress => pTau = Tau
!! ** Author: L. Brodeau, Sept. 2019 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp), INTENT(in) :: pzu ! height above the sea-level where all this takes place (normally 10m)
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pTs ! water temperature at the air-sea interface [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqs ! satur. spec. hum. at T=pTs [kg/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pTa ! potential air temperature at z=pzu [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqa ! specific humidity at z=pzu [kg/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pust ! u*
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ptst ! t*
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqst ! q*
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pwnd ! wind speed module at z=pzu [m/s]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pUb ! bulk wind speed at z=pzu (inc. pot. effect of gustiness etc) [m/s]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ppa ! sea-level atmospheric pressure [Pa]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: prlw ! downwelling longwave radiative flux [W/m^2]
!
REAL(wp), DIMENSION(jpi,jpj), INTENT(out) :: pQns ! non-solar heat flux to the ocean aka "Qlat + Qsen + Qlw" [W/m^2]]
REAL(wp), DIMENSION(jpi,jpj), INTENT(out) :: pTau ! module of the wind stress [N/m^2]
!
REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(out) :: Qlat
!
REAL(wp) :: zdt, zdq, zCd, zCh, zCe, zz0, zQlat, zQsen, zQlw
INTEGER :: ji, jj ! dummy loop indices
!!----------------------------------------------------------------------------------
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
zdt = pTa(ji,jj) - pTs(ji,jj) ; zdt = SIGN( MAX(ABS(zdt),1.E-6_wp), zdt )
zdq = pqa(ji,jj) - pqs(ji,jj) ; zdq = SIGN( MAX(ABS(zdq),1.E-9_wp), zdq )
zz0 = pust(ji,jj)/pUb(ji,jj)
zCd = zz0*zz0
zCh = zz0*ptst(ji,jj)/zdt
zCe = zz0*pqst(ji,jj)/zdq
CALL BULK_FORMULA( pzu, pTs(ji,jj), pqs(ji,jj), pTa(ji,jj), pqa(ji,jj), zCd, zCh, zCe, &
& pwnd(ji,jj), pUb(ji,jj), ppa(ji,jj), &
& pTau(ji,jj), zQsen, zQlat )
zQlw = qlw_net_sclr( prlw(ji,jj), pTs(ji,jj) ) ! Net longwave flux
pQns(ji,jj) = zQlat + zQsen + zQlw
IF( PRESENT(Qlat) ) Qlat(ji,jj) = zQlat
END_2D
END SUBROUTINE UPDATE_QNSOL_TAU
SUBROUTINE BULK_FORMULA_SCLR( pzu, pTs, pqs, pTa, pqa, &
& pCd, pCh, pCe, &
& pwnd, pUb, ppa, &
& pTau, pQsen, pQlat, &
& pEvap, prhoa, pfact_evap )
!!----------------------------------------------------------------------------------
REAL(wp), INTENT(in) :: pzu ! height above the sea-level where all this takes place (normally 10m)
REAL(wp), INTENT(in) :: pTs ! water temperature at the air-sea interface [K]
REAL(wp), INTENT(in) :: pqs ! satur. spec. hum. at T=pTs [kg/kg]
REAL(wp), INTENT(in) :: pTa ! potential air temperature at z=pzu [K]
REAL(wp), INTENT(in) :: pqa ! specific humidity at z=pzu [kg/kg]
REAL(wp), INTENT(in) :: pCd
REAL(wp), INTENT(in) :: pCh
REAL(wp), INTENT(in) :: pCe
REAL(wp), INTENT(in) :: pwnd ! wind speed module at z=pzu [m/s]
REAL(wp), INTENT(in) :: pUb ! bulk wind speed at z=pzu (inc. pot. effect of gustiness etc) [m/s]
REAL(wp), INTENT(in) :: ppa ! sea-level atmospheric pressure [Pa]
!!
REAL(wp), INTENT(out) :: pTau ! module of the wind stress [N/m^2]
REAL(wp), INTENT(out) :: pQsen ! [W/m^2]
REAL(wp), INTENT(out) :: pQlat ! [W/m^2]
!!
REAL(wp), INTENT(out), OPTIONAL :: pEvap ! Evaporation [kg/m^2/s]
REAL(wp), INTENT(out), OPTIONAL :: prhoa ! Air density at z=pzu [kg/m^3]
REAL(wp), INTENT(in) , OPTIONAL :: pfact_evap ! ABOMINATION: corrective factor for evaporation (doing this against my will! /laurent)
!!
REAL(wp) :: ztaa, zgamma, zrho, zUrho, zevap, zfact_evap
INTEGER :: jq
!!----------------------------------------------------------------------------------
zfact_evap = 1._wp
IF( PRESENT(pfact_evap) ) zfact_evap = pfact_evap
!! Need ztaa, absolute temperature at pzu (formula to estimate rho_air needs absolute temperature, not the potential temperature "pTa")
ztaa = pTa ! first guess...
DO jq = 1, 4
zgamma = gamma_moist( 0.5*(ztaa+pTs) , pqa ) !#LB: why not "0.5*(pqs+pqa)" rather then "pqa" ???
ztaa = pTa - zgamma*pzu ! Absolute temp. is slightly colder...
END DO
zrho = rho_air(ztaa, pqa, ppa)
zrho = rho_air(ztaa, pqa, ppa-zrho*grav*pzu) ! taking into account that we are pzu m above the sea level where SLP is given!
zUrho = pUb*MAX(zrho, 1._wp) ! rho*U10
pTau = zUrho * pCd * pwnd ! Wind stress module
zevap = zUrho * pCe * (pqa - pqs)
pQsen = zUrho * pCh * (pTa - pTs) * cp_air(pqa)
pQlat = L_vap(pTs) * zevap
IF( PRESENT(pEvap) ) pEvap = - zfact_evap * zevap
IF( PRESENT(prhoa) ) prhoa = zrho
END SUBROUTINE BULK_FORMULA_SCLR
!!
SUBROUTINE BULK_FORMULA_VCTR( pzu, pTs, pqs, pTa, pqa, &
& pCd, pCh, pCe, &
& pwnd, pUb, ppa, &
& pTau, pQsen, pQlat, &
& pEvap, prhoa, pfact_evap )
!!----------------------------------------------------------------------------------
REAL(wp), INTENT(in) :: pzu ! height above the sea-level where all this takes place (normally 10m)
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pTs ! water temperature at the air-sea interface [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqs ! satur. spec. hum. at T=pTs [kg/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pTa ! potential air temperature at z=pzu [K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pqa ! specific humidity at z=pzu [kg/kg]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pCd
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pCh
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pCe
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pwnd ! wind speed module at z=pzu [m/s]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pUb ! bulk wind speed at z=pzu (inc. pot. effect of gustiness etc) [m/s]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: ppa ! sea-level atmospheric pressure [Pa]
!!
REAL(wp), DIMENSION(jpi,jpj), INTENT(out) :: pTau ! module of the wind stress [N/m^2]
REAL(wp), DIMENSION(jpi,jpj), INTENT(out) :: pQsen ! [W/m^2]
REAL(wp), DIMENSION(jpi,jpj), INTENT(out) :: pQlat ! [W/m^2]
!!
REAL(wp), DIMENSION(jpi,jpj), INTENT(out), OPTIONAL :: pEvap ! Evaporation [kg/m^2/s]
REAL(wp), DIMENSION(jpi,jpj), INTENT(out), OPTIONAL :: prhoa ! Air density at z=pzu [kg/m^3]
REAL(wp), INTENT(in) , OPTIONAL :: pfact_evap ! ABOMINATION: corrective factor for evaporation (doing this against my will! /laurent)
!!
REAL(wp) :: ztaa, zgamma, zrho, zUrho, zevap, zfact_evap
INTEGER :: ji, jj
!!----------------------------------------------------------------------------------
zfact_evap = 1._wp
IF( PRESENT(pfact_evap) ) zfact_evap = pfact_evap
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
CALL BULK_FORMULA_SCLR( pzu, pTs(ji,jj), pqs(ji,jj), pTa(ji,jj), pqa(ji,jj), &
& pCd(ji,jj), pCh(ji,jj), pCe(ji,jj), &
& pwnd(ji,jj), pUb(ji,jj), ppa(ji,jj), &
& pTau(ji,jj), pQsen(ji,jj), pQlat(ji,jj), &
& pEvap=zevap, prhoa=zrho, pfact_evap=zfact_evap )
IF( PRESENT(pEvap) ) pEvap(ji,jj) = zevap
IF( PRESENT(prhoa) ) prhoa(ji,jj) = zrho
END_2D
END SUBROUTINE BULK_FORMULA_VCTR
FUNCTION alpha_sw_vctr( psst )
!!---------------------------------------------------------------------------------
!! *** FUNCTION alpha_sw_vctr ***
!!
!! ** Purpose : ROUGH estimate of the thermal expansion coefficient of sea-water at the surface (P =~ 1010 hpa)
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp), DIMENSION(jpi,jpj) :: alpha_sw_vctr ! thermal expansion coefficient of sea-water [1/K]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: psst ! water temperature [K]
!!----------------------------------------------------------------------------------
alpha_sw_vctr = 2.1e-5_wp * MAX(psst(:,:)-rt0 + 3.2_wp, 0._wp)**0.79
END FUNCTION alpha_sw_vctr
FUNCTION alpha_sw_sclr( psst )
!!---------------------------------------------------------------------------------
!! *** FUNCTION alpha_sw_sclr ***
!!
!! ** Purpose : ROUGH estimate of the thermal expansion coefficient of sea-water at the surface (P =~ 1010 hpa)
!!
!! ** Author: L. Brodeau, june 2016 / AeroBulk (https://github.com/brodeau/aerobulk/)
!!----------------------------------------------------------------------------------
REAL(wp) :: alpha_sw_sclr ! thermal expansion coefficient of sea-water [1/K]
REAL(wp), INTENT(in) :: psst ! sea-water temperature [K]
!!----------------------------------------------------------------------------------
alpha_sw_sclr = 2.1e-5_wp * MAX(psst-rt0 + 3.2_wp, 0._wp)**0.79
END FUNCTION alpha_sw_sclr
!===============================================================================================
FUNCTION qlw_net_sclr( pdwlw, pts, l_ice )
!!---------------------------------------------------------------------------------
!! *** FUNCTION qlw_net_sclr ***
!!
!! ** Purpose : Estimate of the net longwave flux at the surface
!!----------------------------------------------------------------------------------
REAL(wp) :: qlw_net_sclr
REAL(wp), INTENT(in) :: pdwlw !: downwelling longwave (aka infrared, aka thermal) radiation [W/m^2]
REAL(wp), INTENT(in) :: pts !: surface temperature [K]
LOGICAL, INTENT(in), OPTIONAL :: l_ice !: we are above ice
REAL(wp) :: zemiss, zt2
LOGICAL :: lice
!!----------------------------------------------------------------------------------
lice = .FALSE.
IF( PRESENT(l_ice) ) lice = l_ice
IF( lice ) THEN
zemiss = emiss_i
ELSE
zemiss = emiss_w
END IF
zt2 = pts*pts
qlw_net_sclr = zemiss*( pdwlw - stefan*zt2*zt2) ! zemiss used both as the IR albedo and IR emissivity...
END FUNCTION qlw_net_sclr
!!
FUNCTION qlw_net_vctr( pdwlw, pts, l_ice )
REAL(wp), DIMENSION(jpi,jpj) :: qlw_net_vctr
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pdwlw !: downwelling longwave (aka infrared, aka thermal) radiation [W/m^2]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pts !: surface temperature [K]
LOGICAL, INTENT(in), OPTIONAL :: l_ice !: we are above ice
LOGICAL :: lice
INTEGER :: ji, jj
!!----------------------------------------------------------------------------------
lice = .FALSE.
IF( PRESENT(l_ice) ) lice = l_ice
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
qlw_net_vctr(ji,jj) = qlw_net_sclr( pdwlw(ji,jj) , pts(ji,jj), l_ice=lice )
END_2D
END FUNCTION qlw_net_vctr
!===============================================================================================
FUNCTION z0_from_Cd( pzu, pCd, ppsi )
REAL(wp), DIMENSION(jpi,jpj) :: z0_from_Cd !: roughness length [m]
REAL(wp) , INTENT(in) :: pzu !: reference height zu [m]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pCd !: (neutral or non-neutral) drag coefficient []
REAL(wp), DIMENSION(jpi,jpj), INTENT(in), OPTIONAL :: ppsi !: "Psi_m(pzu/L)" stability correction profile for momentum []
!!
!! If pCd is the NEUTRAL-STABILITY drag coefficient then ppsi must be 0 or not given
!! If pCd is the drag coefficient (in stable or unstable conditions) then pssi must be provided
!!----------------------------------------------------------------------------------
IF( PRESENT(ppsi) ) THEN
!! Cd provided is the actual Cd (not the neutral-stability CdN) :
z0_from_Cd = pzu * EXP( - ( vkarmn/SQRT(pCd(:,:)) + ppsi(:,:) ) ) !LB: ok, double-checked!
ELSE
!! Cd provided is the neutral-stability Cd, aka CdN :
z0_from_Cd = pzu * EXP( - vkarmn/SQRT(pCd(:,:)) ) !LB: ok, double-checked!
END IF
END FUNCTION z0_from_Cd
FUNCTION Cd_from_z0( pzu, pz0, ppsi )
REAL(wp), DIMENSION(jpi,jpj) :: Cd_from_z0 !: (neutral or non-neutral) drag coefficient []
REAL(wp) , INTENT(in) :: pzu !: reference height zu [m]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pz0 !: roughness length [m]
REAL(wp), DIMENSION(jpi,jpj), INTENT(in), OPTIONAL :: ppsi !: "Psi_m(pzu/L)" stability correction profile for momentum []
!!
!! If we want to return the NEUTRAL-STABILITY drag coefficient then ppsi must be 0 or not given
!! If we want to return the stability-corrected Cd (i.e. in stable or unstable conditions) then pssi must be provided
!!----------------------------------------------------------------------------------
IF( PRESENT(ppsi) ) THEN
!! The Cd we return is the actual Cd (not the neutral-stability CdN) :
Cd_from_z0 = 1._wp / ( LOG( pzu / pz0(:,:) ) - ppsi(:,:) )
ELSE
!! The Cd we return is the neutral-stability Cd, aka CdN :
Cd_from_z0 = 1._wp / LOG( pzu / pz0(:,:) )
END IF
Cd_from_z0 = vkarmn2 * Cd_from_z0 * Cd_from_z0
END FUNCTION Cd_from_z0
FUNCTION f_m_louis_sclr( pzu, pRib, pCdn, pz0 )
!!----------------------------------------------------------------------------------
!! Stability correction function for MOMENTUM
!! Louis (1979)
!!----------------------------------------------------------------------------------
REAL(wp) :: f_m_louis_sclr ! term "f_m" in Eq.(6) when option "Louis" rather than "Psi(zeta) is chosen, Lupkes & Gryanik (2015),
REAL(wp), INTENT(in) :: pzu ! reference height (height for pwnd) [m]
REAL(wp), INTENT(in) :: pRib ! Bulk Richardson number
REAL(wp), INTENT(in) :: pCdn ! neutral drag coefficient
REAL(wp), INTENT(in) :: pz0 ! roughness length [m]
!!----------------------------------------------------------------------------------
REAL(wp) :: ztu, zts, zstab
!!----------------------------------------------------------------------------------
zstab = 0.5 + SIGN(0.5_wp, pRib) ; ! Unstable (Ri<0) => zstab = 0 | Stable (Ri>0) => zstab = 1
!
ztu = pRib / ( 1._wp + 3._wp * rc2_louis * pCdn * SQRT( ABS( -pRib * ( pzu / pz0 + 1._wp) ) ) ) ! ABS is just here for when it's stable conditions and ztu is not used anyways
zts = pRib / SQRT( ABS( 1._wp + pRib ) ) ! ABS is just here for when it's UNstable conditions and zts is not used anyways
!
f_m_louis_sclr = (1._wp - zstab) * ( 1._wp - ram_louis * ztu ) & ! Unstable Eq.(A6)
& + zstab * 1._wp / ( 1._wp + ram_louis * zts ) ! Stable Eq.(A7)
!
END FUNCTION f_m_louis_sclr
!!
FUNCTION f_m_louis_vctr( pzu, pRib, pCdn, pz0 )
REAL(wp), DIMENSION(jpi,jpj) :: f_m_louis_vctr
REAL(wp), INTENT(in) :: pzu
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pRib
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pCdn
REAL(wp), DIMENSION(jpi,jpj), INTENT(in) :: pz0
INTEGER :: ji, jj
DO_2D( nn_hls, nn_hls, nn_hls, nn_hls )
f_m_louis_vctr(ji,jj) = f_m_louis_sclr( pzu, pRib(ji,jj), pCdn(ji,jj), pz0(ji,jj) )
END_2D
END FUNCTION f_m_louis_vctr
FUNCTION f_h_louis_sclr( pzu, pRib, pChn, pz0 )
!!----------------------------------------------------------------------------------
!! Stability correction function for HEAT
!! Louis (1979)
!!----------------------------------------------------------------------------------
REAL(wp) :: f_h_louis_sclr ! term "f_h" in Eq.(6) when option "Louis" rather than "Psi(zeta) is chosen, Lupkes & Gryanik (2015),
REAL(wp), INTENT(in) :: pzu ! reference height (height for pwnd) [m]
REAL(wp), INTENT(in) :: pRib ! Bulk Richardson number
REAL(wp), INTENT(in) :: pChn ! neutral heat transfer coefficient
REAL(wp), INTENT(in) :: pz0 ! roughness length [m]
!!----------------------------------------------------------------------------------
REAL(wp) :: ztu, zts, zstab
!!----------------------------------------------------------------------------------
zstab = 0.5 + SIGN(0.5_wp, pRib) ; ! Unstable (Ri<0) => zstab = 0 | Stable (Ri>0) => zstab = 1
!
ztu = pRib / ( 1._wp + 3._wp * rc2_louis * pChn * SQRT( ABS(-pRib * ( pzu / pz0 + 1._wp) ) ) )
zts = pRib / SQRT( ABS( 1._wp + pRib ) )
!
f_h_louis_sclr = (1._wp - zstab) * ( 1._wp - rah_louis * ztu ) & ! Unstable Eq.(A6)
& + zstab * 1._wp / ( 1._wp + rah_louis * zts ) ! Stable Eq.(A7) !#LB: in paper it's "ram_louis" and not "rah_louis" typo or what????