forked from HYCOM/HYCOM-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_momtum.F90
5593 lines (5551 loc) · 215 KB
/
mod_momtum.F90
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
#if defined(ROW_LAND)
#define SEA_P .true.
#define SEA_U .true.
#define SEA_V .true.
#define SEA_Q .true.
#elif defined(ROW_ALLSEA)
#define SEA_P allip(j).or.ip(i,j).ne.0
#define SEA_U alliu(j).or.iu(i,j).ne.0
#define SEA_V alliv(j).or.iv(i,j).ne.0
#define SEA_Q alliq(j).or.iq(i,j).ne.0
#else
#define SEA_P ip(i,j).ne.0
#define SEA_U iu(i,j).ne.0
#define SEA_V iv(i,j).ne.0
#define SEA_Q iq(i,j).ne.0
#endif
module mod_momtum
use mod_xc ! HYCOM communication interface
implicit none
!
! --- module for momtum and related routines
!
private !! default is private
public :: momtum_hs, momtum, momtum4, momtum_init
!
#if defined(RELO)
real, save, allocatable, dimension(:,:) :: &
#else
real, save, dimension(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy) :: &
#endif
stress,stresx,stresy,dpmx,thkbop, &
defor1, defor2, & ! deformation components
uflux1,vflux1, & ! mass fluxes
potvor ! potential vorticity
contains
subroutine momtum_init()
implicit none
!
! --- ----------------------------------------------
! --- Initialization of arrays for momentum equation
! --- ----------------------------------------------
!
#if defined(RELO)
allocate( &
defor1(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
defor2(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
uflux1(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
vflux1(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
potvor(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
stress(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
stresx(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
stresy(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
dpmx(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy), &
thkbop(1-nbdy:idm+nbdy,1-nbdy:jdm+nbdy) )
call mem_stat_add( 10*(idm+2*nbdy)*(jdm+2*nbdy) )
#endif
stress = 0.0
stresx = r_init
stresy = r_init
dpmx = r_init
thkbop = r_init
! --- all of these should be zero on land.
defor1 = 0.0
defor2 = 0.0
uflux1 = 0.0
vflux1 = 0.0
potvor = 0.0
return
end subroutine momtum_init
subroutine momtum_hs(m,n)
use mod_xc ! HYCOM communication interface
use mod_cb_arrays ! HYCOM saved arrays
use mod_pipe ! HYCOM debugging interface
use mod_tides ! HYCOM tides
#if defined(STOKES)
use mod_stokes ! HYCOM Stokes drift
#endif
implicit none
!
integer m,n
!
! --- -----------------------------------------
! --- hydrostatic equation (and surface stress)
! --- -----------------------------------------
!
logical, parameter :: lpipe_momtum=.false. !usually .false.
real, parameter :: dragw_rho=0.01072d0*1026.0d0 !ice-ocean drag from CICE
real, parameter :: pairc=1013.0d0*100.0d0 !air pressure (Pa)
real, parameter :: rgas=287.1d0 !gas constant (j/kg/k)
real, parameter :: tzero=273.16d0 !celsius to kelvin offset
!
character text*12
!
real dpdn,dpup,q,samo,simo,uimo,vimo,dpsur,psur,usur,vsur, &
airt,vpmx,wndx,wndy,wind,cdw,pair,rair, &
sumdp,sumth,thksur
integer i,j,k,kl,l,margin,mbdy,hlstep
! &,iffstep
! data iffstep/0/
! save iffstep
!
! real*8 wtime
! external wtime
! real*8 wtime1(10),wtime2(20,kdm),wtimes
!
# include "stmt_fns.h"
!
!
mbdy = 6
!
! --- dp has up to date halos from cnuity or mod_hycom
call xctilr(dpmixl(1-nbdy,1-nbdy, m),1, 1, 6,6, halo_ps)
call xctilr(pbavg( 1-nbdy,1-nbdy,1 ),1, 2, 6,6, halo_ps)
call xctilr(saln( 1-nbdy,1-nbdy,1,m),1, kk, 6,6, halo_ps)
call xctilr(temp( 1-nbdy,1-nbdy,1,m),1, kk, 6,6, halo_ps)
call xctilr(th3d( 1-nbdy,1-nbdy,1,m),1, kk, 6,6, halo_ps)
if (windf .and. iceflg.eq.2) then
kl=max(nsigma,1)
call xctilr(u( 1-nbdy,1-nbdy,1,n),1,kl, 1,1, halo_uv)
call xctilr(ubavg( 1-nbdy,1-nbdy, n),1, 1, 1,1, halo_uv)
call xctilr(v( 1-nbdy,1-nbdy,1,n),1,kl, 1,1, halo_vv)
call xctilr(vbavg( 1-nbdy,1-nbdy, n),1, 1, 1,1, halo_vv)
endif
!
! --- tidal forcing
!
if(tidflg.eq.2 .or. tidflg.eq.3) then
hlstep=0
call tides_force(hlstep)
endif
!
! --- hydrostatic equation (and surface stress)
!
! wtime1( 1) = wtime()
!
! --- rhs: th3d.m, temp.m, saln.m, p, pbavg.m
! --- lhs: thstar, p, oneta, montg
!
margin = mbdy
!
!$OMP PARALLEL DO PRIVATE(j,k,i) &
!$OMP SCHEDULE(STATIC,jblk)
do j=1-margin,jj+margin
do i=1-margin,ii+margin
if (SEA_P) then
sumdp = 0.0
sumth = 0.0
do k=1,kk
if (kapref.ne.0) then !thermobaric
!
! --- sigma-star is virtual potential density, as defined in
! --- Sun et.al. (1999), 'Inclusion of thermobaricity in
! --- isopycnic-coordinate ocean models', JPO 29 pp 2719-2729.
!
#if defined(KAPPAF_CENTERED)
! --- use layer centered pressure in converting sigma to sigma-star.
#else
! --- use upper interface pressure in converting sigma to sigma-star.
! --- to avoid density variations in layers intersected by bottom
#endif
!
if (kapref.gt.0) then
thstar(i,j,k,1)=th3d(i,j,k,m) &
+kappaf(temp(i,j,k,m), &
saln(i,j,k,m), &
th3d(i,j,k,m)+thbase, &
#if defined(KAPPAF_CENTERED)
0.5*(p(i,j,k+1)+p(i,j,k)), &
#else
p(i,j,k), &
#endif
kapref)
else
thstar(i,j,k,1)=th3d(i,j,k,m) &
+kappaf(temp(i,j,k,m), &
saln(i,j,k,m), &
th3d(i,j,k,m)+thbase, &
#if defined(KAPPAF_CENTERED)
0.5*(p(i,j,k+1)+p(i,j,k)), &
#else
p(i,j,k), &
#endif
2)
thstar(i,j,k,2)=th3d(i,j,k,m) &
+kappaf(temp(i,j,k,m), &
saln(i,j,k,m), &
th3d(i,j,k,m)+thbase, &
#if defined(KAPPAF_CENTERED)
0.5*(p(i,j,k+1)+p(i,j,k)), &
#else
p(i,j,k), &
#endif
kapi(i,j))
endif !kapref
else !non-thermobaric
thstar(i,j,k,1)=th3d(i,j,k,m)
endif !thermobaric:else
!
p(i,j,k+1)=p(i,j,k)+dp(i,j,k,m)
!
if (sshflg.eq.1) then
sumth = sumth + dp(i,j,k,m)*th3d(i,j,k,m)
sumdp = sumdp + dp(i,j,k,m)
endif !sshflg
enddo !k
!
if (sshflg.eq.1) then
sumth = sumth / max( sumdp, onemm ) !vertical mean of th3d
sumdp = sumdp*qonem * g !depth(m) * g
steric(i,j) = sshgmn(i,j) + &
(sshgmn(i,j) + sumdp) * &
(thmean(i,j) - sumth) / &
(1000.0+thbase+sumth)
endif !sshflg
!
! --- m_prime in lowest layer:
montg(i,j,kk,1)=psikk(i,j,1)+montg_c(i,j)+ &
( p(i,j,kk+1)*(thkk(i,j,1)-thstar(i,j,kk,1)) &
-pbavg(i,j,m)*thstar(i,j,kk,1) )*svref**2
if (kapref.eq.-1) then
montg(i,j,kk,2)=psikk(i,j,2)+montg_c(i,j)+ &
( p(i,j,kk+1)*(thkk(i,j,2)-thstar(i,j,kk,2)) &
-pbavg(i,j,m)*thstar(i,j,kk,2) )*svref**2
endif !kapref.eq.-1
!
! --- m_prime in remaining layers:
do k=kk-1,1,-1
montg(i,j,k,1)=montg(i,j,k+1,1)+p(i,j,k+1)*oneta(i,j,m) &
*(thstar(i,j,k+1,1)-thstar(i,j,k,1))*svref**2
if (kapref.eq.-1) then
montg(i,j,k,2)=montg(i,j,k+1,2)+p(i,j,k+1)*oneta(i,j,m) &
*(thstar(i,j,k+1,2)-thstar(i,j,k,2))*svref**2
endif !kapref.eq.-1
enddo !k
!
! --- srfhgt (used diagnostically, in mxmyaij and for tidal SAL).
if (kapref.ne.-1) then
montg1(i,j) = montg(i,j,1,1)
else
montg1(i,j) = skap(i,j) *montg(i,j,1,1) + &
(1.0-skap(i,j))*montg(i,j,1,2)
endif !kapref
srfhgt(i,j) = montg1(i,j) + svref*pbavg(i,j,m)
!
!diag if (sshflg.eq.1) then
!diag if (itest.gt.0 .and. jtest.gt.0) then
!diag write (lp,'(i9,2i5,3x,a,2f12.6,f12.2)') &
!diag nstep,itest+i0,jtest+j0, &
!diag 'sssh =', &
!diag steric(i,j),sshgmn(i,j),sumdp
!diag write (lp,'(i9,2i5,3x,a,3f12.6)') &
!diag nstep,itest+i0,jtest+j0, &
!diag 'thmn =', &
!diag sumth,thmean(i,j),1000.0+thbase+sumth
!diag write (lp,'(i9,2i5,3x,a,3f12.6)') &
!diag nstep,itest+i0,jtest+j0, &
!diag 'ssh =', &
!diag srfhgt(i,j),steric(i,j),srfhgt(i,j)-steric(i,j)
!diag endif !test
!diag endif !sshflg
endif !ip
enddo !i
enddo !j
!$OMP END PARALLEL DO
!
if (lpipe .and. lpipe_momtum .and. mslprf) then
! --- compare two model runs.
util4(1:ii,1:jj) = mslprs(1:ii,1:jj,l0)
write (text,'(a9,i3)') 'mslprs l=',l0
call pipe_compare_sym1(util4, ip,text)
util4(1:ii,1:jj) = mslprs(1:ii,1:jj,l1)
write (text,'(a9,i3)') 'mslprs l=',l1
call pipe_compare_sym1(util4, ip,text)
!
util4(1:ii,1:jj) = mslprs(1:ii,1:jj,l0)-mslprs(1:ii,0:jj-1,l0)
write (text,'(a9,i3)') 'mslprY l=',l0
call pipe_compare_sym1(util4, iv,text)
util4(1:ii,1:jj) = mslprs(1:ii,1:jj,l1)-mslprs(1:ii,0:jj-1,l1)
write (text,'(a9,i3)') 'mslprY l=',l1
call pipe_compare_sym1(util4, iv,text)
!
util4(1:ii,1:jj) = mslprs(1:ii,1:jj,l0)-mslprs(0:ii-1,1:jj,l0)
write (text,'(a9,i3)') 'mslprX l=',l0
call pipe_compare_sym1(util4, iu,text)
util4(1:ii,1:jj) = mslprs(1:ii,1:jj,l1)-mslprs(0:ii-1,1:jj,l1)
write (text,'(a9,i3)') 'mslprX l=',l1
call pipe_compare_sym1(util4, iu,text)
endif
!
! call dpudpv(dpu(1-nbdy,1-nbdy,1,m),
! & dpv(1-nbdy,1-nbdy,1,m),
! & p,depthu,depthv, max(0,margin-1))
!CL/RB MPI bug correction 2011-01
! call xctilr(dpu( 1-nbdy,1-nbdy,1,1),1,2*kk, 6,6, halo_us)
! call xctilr(dpv( 1-nbdy,1-nbdy,1,1),1,2*kk, 6,6, halo_vs)
!
! --- account for temporal smoothing of mid-time dpmixl. calculate the vertical
! --- excursions of the coordinates immediately above and below the mixed
! --- layer base, then vertically interpolate this motion to dpmixl(i,j,m)
!
if(hybrid .and. mxlkta) then
!
! --- rhs: dp, dpmixl.m
! --- lhs: util1, util2
!
margin = mbdy
!
!$OMP PARALLEL DO PRIVATE(j,i,k,dpup,dpdn,q) &
!$OMP SCHEDULE(STATIC,jblk)
do j=1-margin,jj+margin
do i=1-margin,ii+margin
if (SEA_P) then
util1(i,j)=0.0
util2(i,j)=0.0
do k=1,kk
util1(i,j)=util2(i,j)
util2(i,j)=util2(i,j)+dpo(i,j,k,m)
if (util2(i,j).ge.dpmixl(i,j,m).and. &
util1(i,j).lt.dpmixl(i,j,m) ) then
dpup=p(i,j,k )-util1(i,j)
dpdn=p(i,j,k+1)-util2(i,j)
q=(util2(i,j)-dpmixl(i,j,m))/max(onemm,dpo(i,j,k,m))
dpmixl(i,j,m)=dpmixl(i,j,m)+(dpdn+q*(dpup-dpdn))
endif
enddo !k
endif !ip
enddo !l
enddo !i
!$OMP END PARALLEL DO
endif
!
! --- --------------
! --- surface stress
! --- --------------
!
if (windf) then
margin =0
#if defined (USE_NUOPC_CESMBETA)
!jc weights for the coupled forcing
if(cpl_implicit) then
if(nstep2_cpl.eq.0 .or. (nstep1_cpl.eq.nstep2_cpl)) then
cpl_w2=1.
cpl_w3=0.
else
cpl_w2=(nstep-nstep1_cpl)/(nstep2_cpl-nstep1_cpl)
cpl_w3=1.-cpl_w2
endif
else
cpl_w2=1.0
cpl_w3=0.
endif
#endif
!
!$OMP PARALLEL DO PRIVATE(j,i,k, &
!$OMP dpsur,psur,usur,vsur,thksur, &
!$OMP airt,vpmx,wndx,wndy,wind,cdw,rair, &
!$OMP uimo,vimo,simo,samo) &
!$OMP SCHEDULE(STATIC,jblk)
do j=1-margin,jj+margin
do i=1-margin,ii+margin
if (SEA_P) then
if (wndflg.eq.4 .or. wndflg.eq.5 .or. &
(iceflg.eq.2 .and. si_c(i,j).gt.0.0)) then
! --- average currents over top thkcdw meters
thksur = onem*min( thkcdw, depths(i,j) )
usur = 0.0
vsur = 0.0
psur = 0.0
do k= 1,kk
dpsur = min( dpo(i,j,k,n), max( 0.0, thksur-psur ) )
usur = usur + dpsur*(u(i,j,k,n)+u(i+1,j,k,n))
vsur = vsur + dpsur*(v(i,j,k,n)+v(i,j+1,k,n))
psur = psur + dpsur
if (psur.ge.thksur) then
exit
endif
enddo !k
usur = 0.5*( usur/psur + ubavg(i, j,n) + &
ubavg(i+1,j,n) )
vsur = 0.5*( vsur/psur + vbavg(i,j, n) + &
vbavg(i,j+1,n) )
endif !usur,vsur
!
if (wndflg.eq.2 .or. wndflg.eq.3) then ! tau on p grid
#if defined (USE_NUOPC_CESMBETA)
if (cpl_taux) then
surtx(i,j) = imp_taux(i,j,1)*cpl_w2 &
+ imp_taux(i,j,2)*cpl_w3
elseif (natm.eq.2) then
surtx(i,j) = taux(i,j,l0)*w0+taux(i,j,l1)*w1
else
surtx(i,j) = taux(i,j,l0)*w0+taux(i,j,l1)*w1 &
+ taux(i,j,l2)*w2+taux(i,j,l3)*w3
endif ! cpl_taux
if (cpl_tauy) then
surty(i,j) = imp_tauy(i,j,1)*cpl_w2 &
+ imp_tauy(i,j,2)*cpl_w3
elseif (natm.eq.2) then
surty(i,j) = tauy(i,j,l0)*w0+tauy(i,j,l1)*w1
else
surty(i,j) = tauy(i,j,l0)*w0+tauy(i,j,l1)*w1 &
+ tauy(i,j,l2)*w2+tauy(i,j,l3)*w3
endif ! cpl_tauy
#else
if (natm.eq.2) then
surtx(i,j) = taux(i,j,l0)*w0+taux(i,j,l1)*w1
surty(i,j) = tauy(i,j,l0)*w0+tauy(i,j,l1)*w1
else
surtx(i,j) = taux(i,j,l0)*w0+taux(i,j,l1)*w1 &
+taux(i,j,l2)*w2+taux(i,j,l3)*w3
surty(i,j) = tauy(i,j,l0)*w0+tauy(i,j,l1)*w1 &
+tauy(i,j,l2)*w2+tauy(i,j,l3)*w3
endif !natm
#endif /* USE_NUOPC_CESMBETA */
elseif (wndflg.eq.1) then ! tau on u&v grids - NOT RECOMMEDED
#if defined (USE_NUOPC_CESMBETA)
if (mnproc.eq.1) then
write(lp,*)
write(lp,*) 'error in momtum - wndflg should be '
write(lp,*) ' eq. to 2 with NUOPC'
endif !1st tile
call xcstop('(momtum)')
stop '(momtum)'
#else
if (natm.eq.2) then
surtx(i,j) = ( (taux(i,j,l0)+taux(i+1,j,l0))*w0 &
+(taux(i,j,l1)+taux(i+1,j,l1))*w1)*0.5
surty(i,j) = ( (tauy(i,j,l0)+tauy(i,j+1,l0))*w0 &
+(tauy(i,j,l1)+tauy(i,j+1,l1))*w1)*0.5
else
surtx(i,j) = ( (taux(i,j,l0)+taux(i+1,j,l0))*w0 &
+(taux(i,j,l1)+taux(i+1,j,l1))*w1 &
+(taux(i,j,l2)+taux(i+1,j,l2))*w2 &
+(taux(i,j,l3)+taux(i+1,j,l3))*w3)*0.5
surty(i,j) = ( (tauy(i,j,l0)+tauy(i,j+1,l0))*w0 &
+(tauy(i,j,l1)+tauy(i,j+1,l1))*w1 &
+(tauy(i,j,l2)+tauy(i,j+1,l2))*w2 &
+(tauy(i,j,l3)+tauy(i,j+1,l3))*w3)*0.5
endif !natm
#endif /* USE_NUOPC_CESMBETA */
else !wndflg.eq.4,5,6
! --- calculate stress from 10m winds using cd_coare or cd_core2
! --- for cd_core2, vpmx (vapmix) is specific humidity
#if defined (USE_NUOPC_CESMBETA)
if (mnproc.eq.1) then
write(lp,*)
write(lp,*) 'error in momtum - wndflg should be '
write(lp,*) ' eq. to 2 with NUOPC'
endif !1st tile
call xcstop('(momtum)')
stop '(momtum)'
#else
if (natm.eq.2) then
airt = airtmp(i,j,l0)*w0+airtmp(i,j,l1)*w1
vpmx = vapmix(i,j,l0)*w0+vapmix(i,j,l1)*w1
wndx = taux(i,j,l0)*w0+ taux(i,j,l1)*w1
wndy = tauy(i,j,l0)*w0+ tauy(i,j,l1)*w1
else
airt = airtmp(i,j,l0)*w0+airtmp(i,j,l1)*w1 &
+airtmp(i,j,l2)*w2+airtmp(i,j,l3)*w3
vpmx = vapmix(i,j,l0)*w0+vapmix(i,j,l1)*w1 &
+vapmix(i,j,l2)*w2+vapmix(i,j,l3)*w3
wndx = taux(i,j,l0)*w0+ taux(i,j,l1)*w1 &
+taux(i,j,l2)*w2+ taux(i,j,l3)*w3
wndy = tauy(i,j,l0)*w0+ tauy(i,j,l1)*w1 &
+tauy(i,j,l2)*w2+ tauy(i,j,l3)*w3
endif !natm
wind = sqrt( wndx**2 + wndy**2 )
if (mslprf .or. flxflg.eq.6) then
if (natm.eq.2) then
pair = mslprs(i,j,l0)*w0+mslprs(i,j,l1)*w1 &
+prsbas
else
pair = mslprs(i,j,l0)*w0+mslprs(i,j,l1)*w1 &
+mslprs(i,j,l2)*w2+mslprs(i,j,l3)*w3 &
+prsbas
endif !natm
else
pair = pairc
endif
if (flxflg.eq.6) then !use virtual temperature
rair = pair / (rgas * (tzero+airt) * (1.0+0.608*vpmx))
else
rair = pair / (rgas * (tzero+airt))
endif
!
if (wndflg.eq.4 .and. flxflg.eq.6) then
! --- use wind-current in place of wind for everything
samo = sqrt( (wndx-usur)**2 + (wndy-vsur)**2 )
cdw = 1.0e-3*cd_coarep(samo,vpmx,airt,pair, &
temp(i,j,1,n))
surtx( i,j) = rair*cdw*samo*(wndx-usur)
surty( i,j) = rair*cdw*samo*(wndy-vsur)
wndocn(i,j) = samo !save for thermf
elseif (wndflg.eq.4) then
cdw = 1.0e-3*cd_coare(wind,vpmx,airt, &
temp(i,j,1,n))
! --- use wind-current magnitude and direction for stress
samo = sqrt( (wndx-usur)**2 + (wndy-vsur)**2 )
surtx(i,j) = rair*cdw*samo*(wndx-usur)
surty(i,j) = rair*cdw*samo*(wndy-vsur)
else ! wndflg.eq.5
! --- vpmx assumed to contain specific humidity
cdw = 1.0e-3*cd_core2(wind,vpmx,airt, &
temp(i,j,1,n))
! --- use U10 magnitude and direction for stress
surtx(i,j) = rair*cdw*wind*wndx
surty(i,j) = rair*cdw*wind*wndy
!*****c --- use wind-current magnitude and direction for stress
!***** samo = sqrt( (wndx-usur)**2 + (wndy-vsur)**2 )
!***** surtx(i,j) = rair*cdw*samo*(wndx-usur)
!***** surty(i,j) = rair*cdw*samo*(wndy-vsur)
endif
#endif /* USE_NUOPC_CESMBETA */
endif !wndflg
!
if (stroff) then
surtx(i,j) = surtx(i,j) + oftaux(i,j)
surty(i,j) = surty(i,j) + oftauy(i,j)
endif
!
if (ishlf(i,j).eq.0) then !under an ice shelf
surtx(i,j) = 0.0
surty(i,j) = 0.0
elseif (iceflg.eq.2 .and. si_c(i,j).gt.0.0) then
! --- allow for ice-ocean stress
#if defined (USE_NUOPC_CESMBETA)
! --- ice-ocean stress already in surtx and surty
#else
uimo = si_u(i,j) - usur
vimo = si_v(i,j) - vsur
simo = sqrt( uimo**2 + vimo**2 )
surtx(i,j) = (1.0-si_c(i,j))*surtx(i,j) + &
si_c(i,j) *dragw_rho*simo*uimo
surty(i,j) = (1.0-si_c(i,j))*surty(i,j) + &
si_c(i,j) *dragw_rho*simo*vimo
#endif /* USE_NUOPC_CESMBETA */
endif !ice-ocean stress
endif !ip
enddo !i
enddo !j
!$OMP END PARALLEL DO
!
call xctilr(surtx,1,1, 6,6, halo_pv)
call xctilr(surty,1,1, 6,6, halo_pv)
endif !windf
!
return
!
contains
include 'internal_kappaf.h'
end subroutine momtum_hs
!
real function cd_coare(wind,vpmx,airt,sst)
implicit none
!
real wind,vpmx,airt,sst
!
! --- Wind stress drag coefficient * 10^3 from an approximation
! --- to the COARE 3.0 bulk algorithm (Fairall et al. 2003).
!
! --- wind = wind speed (m/s)
! --- vpmx = water vapor mixing ratio (kg/kg)
! --- airt = air temperature (C)
! --- sst = sea temperature (C)
!
! --- Ta-Ts
! --- ==============
! --- STABLE: 7 to 0.75 degC
! --- NEUTRAL: 0.75 to -0.75 degC
! --- UNSTABLE: -0.75 to -8 degC
!
! --- Va
! --- ==============
! --- Low: 1 to 5 m/s
! --- High: 5 to 34 m/s
!
! --- vamax of 34 m/s from Sraj et al, 2013 (MWR-D-12-00228.1).
!
real tamts,q,qva,va
!
real, parameter :: vamin= 1.0, vamax=34.0
real, parameter :: tdmin= -8.0, tdmax= 7.0
real, parameter :: tzero=273.16
!
real, parameter :: &
as0_00=-0.06695, as0_10= 0.09966, as0_20=-0.02477, &
as0_01= 0.3133, as0_11=-2.116, as0_21= 0.2726, &
as0_02=-0.001473, as0_12= 4.626, as0_22=-0.5558, &
as0_03=-0.004056, as0_13=-2.680, as0_23= 0.3139
real, parameter :: &
as5_00= 0.55815, as5_10=-0.005593, as5_20= 0.0006024, &
as5_01= 0.08174, as5_11= 0.2096, as5_21=-0.02629, &
as5_02=-0.0004472, as5_12=-8.634, as5_22= 0.2121, &
as5_03= 2.666e-6, as5_13= 18.63, as5_23= 0.7755
real, parameter :: &
au0_00= 1.891, au0_10=-0.006304, au0_20= 0.0004406, &
au0_01=-0.7182, au0_11=-0.3028, au0_21=-0.01769, &
au0_02= 0.1975, au0_12= 0.3120, au0_22= 0.01303, &
au0_03=-0.01790, au0_13=-0.1210, au0_23=-0.003394
real, parameter :: &
au5_00= 0.6497, au5_10= 0.003827, au5_20=-4.83e-5, &
au5_01= 0.06993, au5_11=-0.2756, au5_21= 0.007710, &
au5_02= 3.541e-5, au5_12=-1.091, au5_22=-0.2555, &
au5_03=-3.428e-6, au5_13= 4.946, au5_23= 0.7654
real, parameter :: &
an0_00= 1.057, an5_00= 0.6825, &
an0_01=-0.06949, an5_01= 0.06945, &
an0_02= 0.01271, an5_02=-0.0001029
real, parameter :: &
ap0_10= as0_00 + as0_10*0.75 + as0_20*0.75**2, &
ap0_11= as0_11*0.75 + as0_21*0.75**2, &
ap0_12= as0_12*0.75 + as0_22*0.75**2, &
ap0_13= as0_13*0.75 + as0_23*0.75**2
real, parameter :: &
ap5_10= as5_00 + as5_10*0.75 + as5_20*0.75**2, &
ap5_11= as5_11*0.75 + as5_21*0.75**2, &
ap5_12= as5_12*0.75 + as5_22*0.75**2, &
ap5_13= as5_13*0.75 + as5_23*0.75**2
real, parameter :: &
am0_10= au0_00 - au0_10*0.75 + au0_20*0.75**2, &
am0_11= - au0_11*0.75 + au0_21*0.75**2, &
am0_12= - au0_12*0.75 + au0_22*0.75**2, &
am0_13= - au0_13*0.75 + au0_23*0.75**2
real, parameter :: &
am5_10= au5_00 - au5_10*0.75 + au5_20*0.75**2, &
am5_11= - au5_11*0.75 + au5_21*0.75**2, &
am5_12= - au5_12*0.75 + au5_22*0.75**2, &
am5_13= - au5_13*0.75 + au5_23*0.75**2
!
! --- saturation specific humidity (lowe, j.appl.met., 16, 100-103, 1976)
real qsatur,t
qsatur(t)=.622e-3*(6.107799961e+00+t*(4.436518521e-01 &
+t*(1.428945805e-02+t*(2.650648471e-04 &
+t*(3.031240396e-06+t*(2.034080948e-08 &
+t* 6.136820929e-11))))))
!
! --- correct tamts to 100% humidity
tamts = airt-sst - 0.61*(airt+tzero)*(qsatur(airt)-vpmx)
tamts = min( tdmax, max( tdmin, tamts ) )
va = max( vamin, min( vamax, wind ) )
qva = 1.0/va
if (va.le.5.0) then
if (tamts.ge. 0.75) then
cd_coare = &
(as0_00 + as0_01* va + as0_02* va**2 + as0_03* va**3) &
+ (as0_10 + as0_11*qva + as0_12*qva**2 + as0_13*qva**3) &
*tamts &
+ (as0_20 + as0_21*qva + as0_22*qva**2 + as0_23*qva**3) &
*tamts**2
elseif (tamts.le.-0.75) then
cd_coare = &
(au0_00 + au0_01* va + au0_02* va**2 + au0_03* va**3) &
+ (au0_10 + au0_11*qva + au0_12*qva**2 + au0_13*qva**3) &
*tamts &
+ (au0_20 + au0_21*qva + au0_22*qva**2 + au0_23*qva**3) &
*tamts**2
elseif (tamts.ge. -0.098) then
q = (tamts+0.098)/0.848 !linear between 0.75 and -0.098
cd_coare = q* &
( ( as0_01* va + as0_02* va**2 + as0_03* va**3) &
+ (ap0_10 + ap0_11*qva + ap0_12*qva**2 + ap0_13*qva**3) &
) + (1.0-q)* &
(an0_00 + an0_01* va + an0_02* va**2)
else
q = (-tamts-0.098)/0.652 !linear between -0.75 and -0.098
cd_coare = q* &
( ( au0_01* va + au0_02* va**2 + au0_03* va**3) &
+ (am0_10 + am0_11*qva + am0_12*qva**2 + am0_13*qva**3) &
) + (1.0-q)* &
(an0_00 + an0_01* va + an0_02* va**2)
endif !tamts
else !va>5
if (tamts.ge. 0.75) then
cd_coare = &
(as5_00 + as5_01* va + as5_02* va**2 + as5_03* va**3) &
+ (as5_10 + as5_11*qva + as5_12*qva**2 + as5_13*qva**3) &
*tamts &
+ (as5_20 + as5_21*qva + as5_22*qva**2 + as5_23*qva**3) &
*tamts**2
elseif (tamts.le.-0.75) then
cd_coare = &
(au5_00 + au5_01* va + au5_02* va**2 + au5_03* va**3) &
+ (au5_10 + au5_11*qva + au5_12*qva**2 + au5_13*qva**3) &
*tamts &
+ (au5_20 + au5_21*qva + au5_22*qva**2 + au5_23*qva**3) &
*tamts**2
elseif (tamts.ge. -0.098) then
q = (tamts+0.098)/0.848 !linear between 0.75 and -0.098
cd_coare = q* &
( ( as5_01* va + as5_02* va**2 + as5_03* va**3) &
+ (ap5_10 + ap5_11*qva + ap5_12*qva**2 + ap5_13*qva**3) &
) + (1.0-q)* &
(an5_00 + an5_01* va + an5_02* va**2)
else
q = (-tamts-0.098)/0.652 !linear between -0.75 and -0.098
cd_coare = q* &
( ( au5_01* va + au5_02* va**2 + au5_03* va**3) &
+ (am5_10 + am5_11*qva + am5_12*qva**2 + am5_13*qva**3) &
) + (1.0-q)* &
(an5_00 + an5_01* va + an5_02* va**2)
endif !tamts
endif !va
!
end function cd_coare
!
real function cd_coarep(samo,vpmx,airt,pair,sst)
implicit none
!
real samo,vpmx,airt,pair,sst
!
! --- Wind stress drag coefficient * 10^3 from an approximation
! --- to the COARE 3.0 bulk algorithm (Fairall et al. 2003).
!
! --- samo = wind-ocean speed (m/s)
! --- vpmx = water vapor mixing ratio (kg/kg)
! --- airt = air temperature (C)
! --- pair = air pressure (Pa)
! --- sst = sea temperature (C)
!
! --- Ta-Ts
! --- ==============
! --- STABLE: 7 to 0.75 degC
! --- NEUTRAL: 0.75 to -0.75 degC
! --- UNSTABLE: -0.75 to -8 degC
!
! --- Va
! --- ==============
! --- Low: 1 to 5 m/s
! --- High: 5 to 34 m/s
!
! --- vamax of 34 m/s from Sraj et al, 2013 (MWR-D-12-00228.1).
!
real tamts,q,qva,va
!
real, parameter :: vamin= 1.0, vamax=34.0
real, parameter :: tdmin= -8.0, tdmax= 7.0
real, parameter :: tzero=273.16
!
real, parameter :: &
as0_00=-0.06695, as0_10= 0.09966, as0_20=-0.02477, &
as0_01= 0.3133, as0_11=-2.116, as0_21= 0.2726, &
as0_02=-0.001473, as0_12= 4.626, as0_22=-0.5558, &
as0_03=-0.004056, as0_13=-2.680, as0_23= 0.3139
real, parameter :: &
as5_00= 0.55815, as5_10=-0.005593, as5_20= 0.0006024, &
as5_01= 0.08174, as5_11= 0.2096, as5_21=-0.02629, &
as5_02=-0.0004472, as5_12=-8.634, as5_22= 0.2121, &
as5_03= 2.666e-6, as5_13= 18.63, as5_23= 0.7755
real, parameter :: &
au0_00= 1.891, au0_10=-0.006304, au0_20= 0.0004406, &
au0_01=-0.7182, au0_11=-0.3028, au0_21=-0.01769, &
au0_02= 0.1975, au0_12= 0.3120, au0_22= 0.01303, &
au0_03=-0.01790, au0_13=-0.1210, au0_23=-0.003394
real, parameter :: &
au5_00= 0.6497, au5_10= 0.003827, au5_20=-4.83e-5, &
au5_01= 0.06993, au5_11=-0.2756, au5_21= 0.007710, &
au5_02= 3.541e-5, au5_12=-1.091, au5_22=-0.2555, &
au5_03=-3.428e-6, au5_13= 4.946, au5_23= 0.7654
real, parameter :: &
an0_00= 1.057, an5_00= 0.6825, &
an0_01=-0.06949, an5_01= 0.06945, &
an0_02= 0.01271, an5_02=-0.0001029
real, parameter :: &
ap0_10= as0_00 + as0_10*0.75 + as0_20*0.75**2, &
ap0_11= as0_11*0.75 + as0_21*0.75**2, &
ap0_12= as0_12*0.75 + as0_22*0.75**2, &
ap0_13= as0_13*0.75 + as0_23*0.75**2
real, parameter :: &
ap5_10= as5_00 + as5_10*0.75 + as5_20*0.75**2, &
ap5_11= as5_11*0.75 + as5_21*0.75**2, &
ap5_12= as5_12*0.75 + as5_22*0.75**2, &
ap5_13= as5_13*0.75 + as5_23*0.75**2
real, parameter :: &
am0_10= au0_00 - au0_10*0.75 + au0_20*0.75**2, &
am0_11= - au0_11*0.75 + au0_21*0.75**2, &
am0_12= - au0_12*0.75 + au0_22*0.75**2, &
am0_13= - au0_13*0.75 + au0_23*0.75**2
real, parameter :: &
am5_10= au5_00 - au5_10*0.75 + au5_20*0.75**2, &
am5_11= - au5_11*0.75 + au5_21*0.75**2, &
am5_12= - au5_12*0.75 + au5_22*0.75**2, &
am5_13= - au5_13*0.75 + au5_23*0.75**2
!
real satvpr,qsaturp,t,t6,p6
!
! --- saturation vapor pressure (Pa),
! --- from a polynominal approximation (lowe, j.appl.met., 16, 100-103, 1976)
satvpr(t)= 100.0*(6.107799961e+00+t*(4.436518521e-01 &
+t*(1.428945805e-02+t*(2.650648471e-04 &
+t*(3.031240396e-06+t*(2.034080948e-08 &
+t* 6.136820929e-11))))))
!
! --- pressure dependent saturation mixing ratio (kg/kg)
! --- p6 is pressure in Pa
qsaturp(t6,p6)=0.622*(satvpr(t6)/(p6-satvpr(t6)))
!
! --- correct tamts to 100% humidity
tamts = airt-sst - &
0.608*(airt+tzero)*(qsaturp(airt,pair)-vpmx)
tamts = min( tdmax, max( tdmin, tamts ) )
va = max( vamin, min( vamax, samo ) )
qva = 1.0/va
if (va.le.5.0) then
if (tamts.ge. 0.75) then
cd_coarep = &
(as0_00 + as0_01* va + as0_02* va**2 + as0_03* va**3) &
+ (as0_10 + as0_11*qva + as0_12*qva**2 + as0_13*qva**3) &
*tamts &
+ (as0_20 + as0_21*qva + as0_22*qva**2 + as0_23*qva**3) &
*tamts**2
elseif (tamts.le.-0.75) then
cd_coarep = &
(au0_00 + au0_01* va + au0_02* va**2 + au0_03* va**3) &
+ (au0_10 + au0_11*qva + au0_12*qva**2 + au0_13*qva**3) &
*tamts &
+ (au0_20 + au0_21*qva + au0_22*qva**2 + au0_23*qva**3) &
*tamts**2
elseif (tamts.ge. -0.098) then
q = (tamts+0.098)/0.848 !linear between 0.75 and -0.098
cd_coarep = q* &
( ( as0_01* va + as0_02* va**2 + as0_03* va**3) &
+ (ap0_10 + ap0_11*qva + ap0_12*qva**2 + ap0_13*qva**3) &
) + (1.0-q)* &
(an0_00 + an0_01* va + an0_02* va**2)
else
q = (-tamts-0.098)/0.652 !linear between -0.75 and -0.098
cd_coarep = q* &
( ( au0_01* va + au0_02* va**2 + au0_03* va**3) &
+ (am0_10 + am0_11*qva + am0_12*qva**2 + am0_13*qva**3) &
) + (1.0-q)* &
(an0_00 + an0_01* va + an0_02* va**2)
endif !tamts
else !va>5
if (tamts.ge. 0.75) then
cd_coarep = &
(as5_00 + as5_01* va + as5_02* va**2 + as5_03* va**3) &
+ (as5_10 + as5_11*qva + as5_12*qva**2 + as5_13*qva**3) &
*tamts &
+ (as5_20 + as5_21*qva + as5_22*qva**2 + as5_23*qva**3) &
*tamts**2
elseif (tamts.le.-0.75) then
cd_coarep = &
(au5_00 + au5_01* va + au5_02* va**2 + au5_03* va**3) &
+ (au5_10 + au5_11*qva + au5_12*qva**2 + au5_13*qva**3) &
*tamts &
+ (au5_20 + au5_21*qva + au5_22*qva**2 + au5_23*qva**3) &
*tamts**2
elseif (tamts.ge. -0.098) then
q = (tamts+0.098)/0.848 !linear between 0.75 and -0.098
cd_coarep = q* &
( ( as5_01* va + as5_02* va**2 + as5_03* va**3) &
+ (ap5_10 + ap5_11*qva + ap5_12*qva**2 + ap5_13*qva**3) &
) + (1.0-q)* &
(an5_00 + an5_01* va + an5_02* va**2)
else
q = (-tamts-0.098)/0.652 !linear between -0.75 and -0.098
cd_coarep = q* &
( ( au5_01* va + au5_02* va**2 + au5_03* va**3) &
+ (am5_10 + am5_11*qva + am5_12*qva**2 + am5_13*qva**3) &
) + (1.0-q)* &
(an5_00 + an5_01* va + an5_02* va**2)
endif !tamts
endif !va
!
end function cd_coarep
!
real function cd_core2(wind,sphm,airt,sst)
implicit none
!
real wind,sphm,airt,sst
!
! --- Wind stress drag coefficient * 10^3 from
! --- the CORE v2 bulk algorithm (Large and Yeager, 2009).
!
! --- wind = wind speed (m/s)
! --- sphm = specific humidity (kg/kg)
! --- airt = air temperature (C)
! --- sst = sea temperature (C)
!
! --- Added to HYCOM by Alexandra Bozec, FSU.
!
integer it_a
real u10,v10,uw10,uw
real cd_n10,cd_n10_rt,ce_n10,ch_n10,cd_rt,stab, &
tv,tstar,qstar,bstar,zeta,x2,x,xx, &
psi_m,psi_h,z0,rair,qrair,zi
real cd10,ce10,ch10,ustar
!
real, parameter :: vonkar= 0.4 !Von Karmann constant
real, parameter :: tzero=273.16 !celsius to kelvin offset
real, parameter :: g= 9.806 !same as HYCOM's g
!
! --- saturation specific humidity
real qsatur5,t,qra
qsatur5(t,qra)= 0.98*qra*6.40380e5*exp(-5107.4/(t+tzero))
!
! --- CORE v2 Large and Yeager 2009 Clim. Dyn.: The global climatology
! --- of an interannually varying air-sea flux dataset.
! --- The bulk formulae effectively transform the problem of specifying
! --- the turbulent surface fluxes (at zi=10m) into one of describing
! --- the near surface atmospheric state (wind, temperature and humidity).
!
! write(6,'(a,1p4g14.5)')
! & ' wind,sphm,airt,sst =',wind,sphm,airt,sst
!
rair = 1.22
qrair = 1.0/rair
zi = 10.0
tv = (airt+tzero)*(1.0+0.608*sphm) !in Kelvin
uw = max(wind, 0.5) !0.5 m/s floor on wind (undocumented NCAR)
uw10 = uw !first guess 10m wind
cd_n10 = (2.7/uw10+0.142+0.0764*uw10)*1.0e-3 !L-Y eqn. 6a
! write(6,'(a,1p4g14.5)')
! & 'cd_n10 =',cd_n10,
! & (2.7/uw10)*1.0e-3,0.142*1.0e-3,(0.0764*uw10)*1.0e-3
cd_n10_rt = sqrt(cd_n10)
ce_n10 = 34.6 *cd_n10_rt*1.0e-3 !L-Y eqn. 6b
stab = 0.5 + sign(0.5,airt-sst)
ch_n10 = (18.0*stab+32.7*(1-stab))*cd_n10_rt*1.0e-3 !L-Y eqn. 6c
cd10 = cd_n10 !first guess for exchange coeff's at z
ch10 = ch_n10
ce10 = ce_n10
! write(6,'(a,1p4g14.5)')
! & 'uw10,psi_m,cd_n10,cd10=',uw10,0.0,cd_n10,cd10
!
do it_a= 1,2 !Monin-Obukhov iteration
cd_rt = sqrt(cd10)
ustar = cd_rt*uw !L-Y eqn. 7a
tstar = (ch10/cd_rt)*(airt-sst) !L-Y eqn. 7b
qstar = (ce10/cd_rt)* &
(sphm-qsatur5(sst,qrair)) !L-Y eqn. 7c
bstar = g*(tstar/tv+qstar/(sphm+1.0/0.608))
zeta = vonkar*bstar*zi/(ustar*ustar) !L-Y eqn. 8a
zeta = sign( min(abs(zeta),10.0), zeta ) !undocumented NCAR
x2 = sqrt(abs(1.0-16.0*zeta)) !L-Y eqn. 8b
x2 = max(x2, 1.0) !undocumented NCAR
x = sqrt(x2)
if (zeta > 0.0) then
psi_m = -5.0*zeta !L-Y eqn. 8c
psi_h = -5.0*zeta !L-Y eqn. 8c
else
psi_m = log((1.0+2.0*x+x2)*(1.0+x2)/8.0) &
- 2.0*(atan(x)-atan(1.0)) !L-Y eqn. 8d
psi_h = 2.0*log((1.0+x2)/2.0) !L-Y eqn. 8e
end if
uw10 = uw/(1.0+cd_n10_rt*(log(zi/10.0)-psi_m) & !L-Y eqn. 9
/vonkar)
cd_n10 = (2.7/uw10+0.142+0.0764*uw10)*1.0e-3 !L-Y eqn. 6a again
cd_n10_rt = sqrt(cd_n10)
ce_n10 = 34.6*cd_n10_rt*1.0e-3 !L-Y eqn. 6b again
stab = 0.5 + sign(0.5,zeta)
ch_n10 =(18.0*stab+32.7*(1.0-stab))*cd_n10_rt*1.0e-3 !L-Y eqn. 6c again
z0 = 10.0*exp(-vonkar/cd_n10_rt) !diagnostic
!
xx = (log(zi/10.0)-psi_m)/vonkar
cd10 = cd_n10/(1.0+cd_n10_rt*xx)**2 !L-Y 10a
xx = (log(zi/10.0)-psi_h)/vonkar
ch10 = ch_n10/(1.0+ch_n10*xx/cd_n10_rt) * &
sqrt(cd10/cd_n10) !L-Y 10b
ce10 = ce_n10/(1.0+ce_n10*xx/cd_n10_rt) * &
sqrt(cd10/cd_n10) !L-Y 10c
! write(6,'(a,1p4g14.5)')
! & 'uw10,psi_m,cd_n10,cd10=',uw10,psi_m,cd_n10,cd10
enddo
!