-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbabyEULAG.SDs.for
3419 lines (3047 loc) · 91.3 KB
/
babyEULAG.SDs.for
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
program bubble_sd
cc
include 'param.grid'
include 'param.sds'
cc nember of time steps:
parameter(ntime0=10*60)
cc major dimensions
cc HAVE TO BE CHANGED IN ALL ROUTINES:
cc grid (for regular dzeta isosurfaces)
cc small time step required for SDs:
data dx,dz,dt /20.,20.,1.0/
common/grid/ time,dt,dx,dz,dti,dxi,dzi
dimension xx(nx),zz(nz)
dimension xcntrm(ntime0),zcntrm(ntime0),cntti(ntime0)
dimension qcav(ntime0),qcst(ntime0)
dimension concm(ntime0),radcm(ntime0),stdcm(ntime0)
c SD atributes: two-time level
c SD atributes: position
dimension xp(np),zp(np)
dimension xpn(np),zpn(np)
c number of SDs, cloud water, multiplicity, radius
dimension qcp(np),plic(np),radp(np)
dimension qcpn(np),plicn(np),radpn(np)
CC MODEL VARIABLES
cc thermodynamics
dimension theta(nx,nz),qv(nx,nz),qc(nx,nz),nc(nx,nz)
dimension t(nx,nz)
cc limiting through S; routine adjust
dimension sup(nx,nz),fsup(nx,nz),dpdz(nz)
common /p_deriv/ dpdz
cc dynamics
dimension ux(nx,nz),uz(nx,nz) ! current time level
dimension uxp(nx,nz),uzp(nx,nz) ! previous time level
cc forces for model variables
dimension ft(nx,nz),fx(nx,nz),fy(nx,nz),fz(nx,nz),fqv(nx,nz)
cc advective velocities:
dimension uxa(nx+1,nz),uza(nx,nz+1)
cc profiles
common /strtch/ height(nz),gac(nz)
common /prof_d/ rho0(nz),th0(nz),th_e(nz),ux_e(nz),uy_e(nz)
common /prof_m/ qv_e(nz),tm_e(nz)
common /prof_a/ tau(nz)
cc arrays for w diagnosis; adjust scheme...
real wdum(nx,nz)
real thwd(nx,nz),twd(nx,nz) ! for w doagnosis...
real thwd0(nx,nz),twd0(nx,nz) ! for w doagnosis...
cc required variables:
dimension den(nx,nz),p(nx,nz),scr1(nx,nz),scr2(nx,nz)
cc constants
common /const/ gg,cp,rg,rv
common/reference/ tt0,ee0
common/latent/hlatv,hlats
c grid in supers to get the same mulitplicity
dimension sup_sdb(nppg),rad_sdb(nppg)
c parameters for activation:
common /activ/ sup_sdb,rad_sdb,dcon
call opngks
call gsclip(0)
cc adjustment as in Grabowski and Morrison (MWR 2008):
cc 1 - use adjust
cc 0 - no adjust
iadjust=1
c iadjust=0
cc w for adjustment: uz (0) or diagnosed through T and theta (1):
c iwdiag=1
iwdiag=0
cc grid:
time=0.
dxi=1./dx
dzi=1./dz
dti=1./dt
do i=1,nx
xx(i)=float(i-1)*dx
enddo
cc zz is regular (ustretched) dzeta grid
do k=1,nz
zz(k)=float(k-1)*dz
enddo
call zstrtch(zz,nz,dz)
cc initialize moisture parameters:
call moist_init
cc initialize model profiles:
call prof_init
if(iadjust.eq.1) then
e=-cp/rg
do k=2,nz-1
thetmep=th_e(k+1)/tm_e(k+1)
prekp=1.e5*thetmep**e
thetmem=th_e(k-1)/tm_e(k-1)
prekm=1.e5*thetmem**e
dpdz(k)=(prekp-prekm)/(height(k+1)-height(k-1))
enddo
dpdz(1)=dpdz(2)
dpdz(nz)=dpdz(nz-1)
endif
cc read in and initialize CCN info:
call activat(0.,0.,0)
sup00=ssmax*1.e-2
call activat(sup00,conmax,1)
print*,'CCN: max conc (kg**-1): ',conmax
dcon=conmax/nppg
cc grid in S for SDs:
do ip=1,nppg
con=float(ip)*dcon
call activat(supsat,con,2)
sup_sdb(ip)=supsat
rad_sdb(ip)=8.e-10/supsat
print*,'--ip,con,sup(%),r(mic): ',
1 ip,dcon,con,sup_sdb(ip)*1.e2,rad_sdb(ip)*1.e6
enddo
do k=1,nz
do i=1,nx
den(i,k)=rho0(k)*gac(k)
enddo
enddo
cc initial fields
a=rg/rv
c=hlatv/cp
b=hlatv/(rv*tt0)
d=hlatv/rv
e=-cp/rg
zcen=800.
xcen=(nx-1)*dx/2.
c rad1=200.
c rad2=300.
rad1=250.
rad2=350.
pi=4.*atan(1.)
do k=1,nz
thetme=th_e(k)/tm_e(k)
prek=1.e5*thetme**e
do i=1,nx
radd=(xx(i)-xcen)**2+(zz(k)-zcen)**2
radd=sqrt(radd)
if(radd.gt.rad2) rh=0.2
if(radd.le.rad1) rh=1.
if(radd.gt.rad1 .and. radd.le.rad2)
1 rh=.2 + .8*(cos(pi/2. * (radd-rad1)/(rad2-rad1)))**2.
theta(i,k)=th_e(k)
thi=1./theta(i,k)
y=b*thetme*tt0*thi
ees=ee0*exp(b-y)
qvs=a*ees/(prek-ees)
del=rh*qvs - qv_e(k)
qv(i,k)=qv_e(k) + del
sup(i,k)=qv(i,k)/qvs - 1.
qc(i,k)=0.
ux(i,k)=ux_e(k)
uz(i,k)=0.
uxp(i,k)=ux_e(k)
uzp(i,k)=0.
ft(i,k)=0.
fx(i,k)=0.
fy(i,k)=0.
fz(i,k)=0.
fqv(i,k)=0.
fsup(i,k)=0.
p(i,k)=0.
enddo
enddo
npx=0
cc initial SDs:
do ip=1,np
xp(ip)=0.
zp(ip)=0.
qcp(ip)=0.
plic(ip)=0.
radp(ip)=0.
qcpn(ip)=0.
plicn(ip)=0.
radpn(ip)=0.
enddo
cc total water and mse:
sum=0.
sum1=0.
sum2=0.
do i=1,nx-1
do k=1,nz
thetme=th_e(k)/tm_e(k)
coe=1.
if(k.eq.1 .or. k.eq.nz) coe=0.5
sum=sum+coe*den(i,k)*(qv(i,k)+qc(i,k))
ttt=theta(i,k)/thetme
amse=cp*ttt + g*height(k) + hlatv*qv(i,k)
thee=theta(i,k) + hlatv/cp*thetme*qv(i,k)
sum1=sum1+amse
sum2=sum2+thee
enddo
enddo
print*,'------ total water,mse,the:',sum,sum1,sum2
cc plot initial fields:
call diagno_1(ux,uz,theta,nx,nz,scr1,scr2,den)
call diagno_2(qv,qc,nx,nz,scr1,scr2,den)
call diagno_3(theta,qv,scr1)
call plot_1(ux,uz,theta)
call plot_2(theta,qv,qc)
ccc save initial data:
write(17) time,nx,nz,nppg,np
write(17) ux,uz,theta,qv,qc
CCCC MARCH FORWARD IN TIME:
ccc different random number realization:
ccc commented: run1
c do ir=1,1171 ! run2
cc do ir=1,133171 ! run3
c r1=rand()
c enddo
ntime=ntime0
do itime=1,ntime ! TIME LOOP
print*,'*** itime, time: ',itime,time
cc extrapolate in time to get advective momentums:
call velprd_1(ux,uxp,uxa,uz,uzp,uza,nx,nz,den)
cc transport SDs:
call sd_adv(ux,uxp,uz,uzp,xp,zp,npx)
cc save previous velocities:
do i=1,nxz
uxp(i,1)=ux(i,1)
uzp(i,1)=uz(i,1)
enddo
if(iadjust.eq.1) then
cc derive new absolute S
do k=1,nz
thetme=th_e(k)/tm_e(k)
prek=1.e5*thetme**e
do i=1,nx
thi=1./theta(i,k)
y=b*thetme*tt0*thi
ees=ee0*exp(b-y)
qvs=a*ees/(prek-ees)
sup(i,k)=qv(i,k)-qvs ! absolute S
c
if(sup(i,k)/qvs.gt.ssmax*1.e-2) then
print*,'sup(i,k).gt.ssmax'
print*,'i,k,s,smax: ',i,k,sup(i,k),ssmax
call clsgks
stop 'sup(i,k).gt.ssmax'
endif
c
sup(i,k)=sup(i,k)+dt*fsup(i,k)
enddo
enddo
endif
cc add half of the force for velocities:
do i=1,nxz
ux(i,1) = ux(i,1)+.5*dt*fx(i,1)
uz(i,1) = uz(i,1)+.5*dt*fz(i,1)
cc theta and qv: 1st order
theta(i,1)=theta(i,1)+dt*ft(i,1)
qv(i,1) = qv(i,1)+dt*fqv(i,1)
enddo
CC ADVECTION:
c liner: 1-iord=1, 0-iord prescribed inside mpdata
liner=0
c if(itime/10*10.eq.itime) liner=1
cc advect velocities:
call mpdat_2d(uxa,uza, ux,den,1,liner)
call mpdat_2d(uxa,uza, uz,den,2,liner)
cc get new thermodynamic variables:
call mpdat_2d(uxa,uza,theta,den,3,liner)
call mpdat_2d(uxa,uza, qv,den,4,liner)
if(iadjust.eq.1) then
call mpdat_2d(uxa,uza, sup,den,4,liner)
if(iwdiag.eq.1) then
cc w diagnosis for adjustment...
do k=1,nz
thetme=th_e(k)/tm_e(k)
do i=1,nx
thwd(i,k)=theta(i,k)
twd(i,k)=theta(i,k)/thetme
thwd0(i,k)=theta(i,k)
twd0(i,k)=twd(i,k)
enddo
enddo
call mpdat_2d(uxa,uza,thwd,den,3,liner)
call mpdat_2d(uxa,uza,twd,den,3,liner)
do i=1,nxz
thwd(i,1)=(thwd(i,1)-thwd0(i,1))/dt
twd(i,1)=(twd(i,1)-twd0(i,1))/dt
enddo
c wdum = grid-scale vertical velocity
do k=1,nz
thetme=th_e(k)/tm_e(k)
do i=1,nx
wdum(i,k)=cp/gg * (-thwd(i,k)/thetme + twd(i,k))
enddo
enddo
else ! if(iwdiag.eq.1) then
do k=1,nz
do i=1,nx
wdum(i,k)=uz(i,k)
enddo
enddo
endif ! if(iwdiag.eq.1) then
endif ! iadjust
ccc 1st, finish dynamics...
cc save velocities after advection into advective velocities:
do i=1,nx
do k=1,nz
uxa(i,k)=ux(i,k)
uza(i,k)=uz(i,k)
enddo
enddo
cc derive qc for buoyancy:
do i=1,nxz
qc(i,1)=0.
enddo
do ip=1,npx
i=(xp(ip)+dx/2.)/dx + 1
k=(zp(ip)+dz/2.)/dz + 1
qc(i,k)=qc(i,k)+qcp(ip)
enddo
cc add buoyancy
epsb=rv/rg-1.
do k=1,nz
do i=1,nx
scr1(i,k)=gg*( (theta(i,k)-th_e(k))/th0(k)
* + epsb*(qv(i,k)-qv_e(k))-qc(i,k) )
enddo
enddo
cc filter in vertical
cc call integz(scr1,scr2,nx,nz)
call integxz(scr1,scr2,nx,nz)
cc apply
do i=1,nxz
uz(i,1) = uz(i,1)+.5*dt*scr1(i,1)
enddo
cc calculate pressure gradient force:
c epp=1.e-6
epp=1.e-7
itp=100
call gcrk_1(p,scr1,scr2,ux,uz,nx,nz,itp,epp)
call prforc_1(p,scr1,scr2,ux,uz,nx,nz)
do i=1,nxz
ux(i,1)=scr1(i,1)
uz(i,1)=scr2(i,1)
enddo
cc calculate velocity forces (using saved velocities after advection):
do k=1,nz
do i=1,nx
fx(i,k)=(ux(i,k)-uxa(i,k)) *2./dt
fz(i,k)=(uz(i,k)-uza(i,k)) *2./dt
enddo
enddo
ccc 2nd, derive new forces for thermodynamics
cc adjust temp and qv to match sss:
if(iadjust.eq.1)
1 call adjust(theta,qv,qc,sup,npx,xp,zp,qcp,plic,radp)
cc derive new S:
if(iadjust.eq.0) then
do k=1,nz
thetme=th_e(k)/tm_e(k)
prek=1.e5*thetme**e
do i=1,nx
thi=1./theta(i,k)
y=b*thetme*tt0*thi
ees=ee0*exp(b-y)
qvs=a*ees/(prek-ees)
sup(i,k)=qv(i,k)/qvs-1.
if(sup(i,k).gt.ssmax*1.e-2) then
print*,'sup(i,k).gt.ssmax'
print*,'i,k,s,smax: ',i,k,sup(i,k),ssmax
call clsgks
stop 'sup(i,k).gt.ssmax'
endif
enddo
enddo
endif ! iadjust
if(iadjust.eq.1) then
do k=1,nz
thetme=th_e(k)/tm_e(k)
prek=1.e5*thetme**e
do i=1,nx
thi=1./theta(i,k)
y=b*thetme*tt0*thi
ees=ee0*exp(b-y)
qvs=a*ees/(prek-ees)
sup(i,k)=qv(i,k)-qvs
if(sup(i,k)/qvs.gt.ssmax*1.e-2) then
print*,'sup(i,k).gt.ssmax'
print*,'i,k,s,smax: ',i,k,sup(i,k),ssmax
call clsgks
stop 'sup(i,k).gt.ssmax'
endif
enddo
enddo
endif ! iadjust
cc set forces to zero:
do i=1,nxz
ft(i,1)=0.
fqv(i,1)=0.
fsup(i,1)=0.
enddo
cc SDs thermodynamics; NOTE: theta and qv tendencies are brought back,
cc SD properties are imediately updated...
call sd_phy(theta,qv,sup,fsup,wdum,ft,fqv,
1 npx,xp,zp,qcp,plic,radp,iadjust)
cc randomly re-position droplets
cc or every drep sec
c drep=dt
c drep=60.
drep=600000000. ! never...
irep=nint(drep/dt)
if(itime/irep*irep.eq.itime) call sd_rep(xp,zp,npx)
cc update clock (in minutes...)
time = float(itime)*dt/60.
ccc diagno every time step
c call diagno_1(ux,uz,theta,nx,nz,scr1,scr2,den)
c call diagno_2(qv,qc,nx,nz,scr1,scr2,den)
c call diagno_3(theta,qv,scr1)
c call diagno_4(npx,xp,zp,qcp,plic,radp)
cc output and plot:
dtout=1. ! in min
dtape=1. ! in min
if(amod(time+.1*dt/60.,dtout).lt.0.5*dt/60.) then
ccc plot selected fields:
call plot_1(ux,uz,theta)
call plot_2(theta,qv,qc,npx)
call plot_3(qc,xp,zp,qcp,plic,radp,npx)
cc analysis of output:
print*,' '
call diagno_1(ux,uz,theta,nx,nz,scr1,scr2,den)
call diagno_2(qv,qc,nx,nz,scr1,scr2,den)
call diagno_3(theta,qv,scr1)
call diagno_4(npx,xp,zp,qcp,plic,radp)
cc
cc total water and mse:
sum=0.
sum1=0.
sum2=0.
do i=1,nx-1
do k=1,nz
thetme=th_e(k)/tm_e(k)
coe=1.
if(k.eq.1 .or. k.eq.nz) coe=0.5
sum=sum+coe*den(i,k)*(qv(i,k)+qc(i,k))
ttt=theta(i,k)/thetme
amse=cp*ttt + g*height(k) + hlatv*qv(i,k)
thee=theta(i,k) + hlatv/cp*thetme*qv(i,k)
sum1=sum1+amse
sum2=sum2+thee
enddo
enddo
print*,'------ total water,mse,the:',sum,sum1,sum2
cccc mean qc and S in cloudy volumes:
sum1=0.
sum2=0.
sum3=0.
sum4=0.
do i=1,nx-1
do k=1,nz
if(qc(i,k).gt.1.e-5) then
sum1=sum1+qc(i,k)
sum2=sum2+1.
endif
if(qc(i,k).gt.1.e-4) then
sum3=sum3+sup(i,k)*100.
sum4=sum4+1.
endif
enddo
enddo
if(sum2.gt.0.) then
qcmean=sum1/sum2*1.e3
else
qcmean=0.
endif
if(sum4.gt.0.) then
smean=sum3/sum4
else
smean=0.
endif
print*,'------ mean qc in cloudy(10**-5) volumes:',qcmean
print*,'------ mean S(%) in cloudy(10**-4) volumes:',smean
endif
if(amod(time+.1*dt/60.,dtape).lt.0.5*dt/60.) then
write(17) time,nx,nz,nppg,np
write(17) ux,uz,theta,qv,qc
write(17) npx
do ip=1,npx
write(17) xp(ip),zp(ip)
write(17) qcp(ip),plic(ip),radp(ip)
enddo
print*,'wrote tape for t = ',time
endif
cntti(itime)=time
cc center of mass of qc:
sum1=0.
sum2=0.
sum3=0.
do i=1,nx
xxx=float(i-1)*dx
do k=1,nz
sum1=sum1 + qc(i,k)
sum2=sum2 + height(k)*qc(i,k)
sum3=sum3 + xxx*qc(i,k)
enddo
enddo
if(sum1.gt.1.e-3) then
zcntrm(itime)=sum2/sum1 *1.e-3
xcntrm(itime)=sum3/sum1 *1.e-3
else
zcntrm(itime)=0.
xcntrm(itime)=xx(nx)/2. * 1.e-3
endif
cc conditionally-averaged qc:
sum1=0.
sum2=0.
do i=1,nx
do k=1,nz
if(qc(i,k).ge.1.e-5) then
sum1=sum1 + 1.
sum2=sum2 + qc(i,k)
endif
enddo
enddo
if(sum1.gt.1.) then
qcav(itime)=sum2/sum1 *1.e3
else
qcav(itime)=0.
endif
cc std dev:
sum1=0.
sum2=0.
do i=1,nx
do k=1,nz
if(qc(i,k).ge.1.e-5) then
sum1=sum1 + 1.
sum2=sum2 + (qc(i,k)*1.e3-qcav(itime))**2
endif
enddo
enddo
if(sum1.gt.1.) then
qcst(itime)=sqrt(sum2/sum1) /qcav(itime)
else
qcst(itime)=0.
endif
sum1=0.
sum2=0.
ic=(xcntrm(itime)*1.e3 + dx/2.)/dz + 1
kc=(zcntrm(itime)*1.e3 + dz/2.)/dz + 1
do ip=1,npx
i=(xp(ip)+dx/2.)/dx + 1
k=(zp(ip)+dz/2.)/dz + 1
if(i.eq.ic .and. k.eq.kc) then
con=plic(ip)
sum1=sum1 + con
sum2=sum2 + radp(ip)*con
endif
enddo
if(sum1.gt.1.) then
concm(itime)=sum1
radcm(itime)=sum2/sum1
else
concm(itime)=0.
radcm(itime)=0.
endif
sum1=0.
sum2=0.
ic=(xcntrm(itime)*1.e3 + dx/2.)/dz + 1
kc=(zcntrm(itime)*1.e3 + dz/2.)/dz + 1
do ip=1,npx
i=(xp(ip)+dx/2.)/dx + 1
k=(zp(ip)+dz/2.)/dz + 1
if(i.eq.ic .and. k.eq.kc) then
sum1=sum1 + 1.
sum2=sum2 + (radp(ip)-radcm(itime))**2
endif
enddo
if(sum1.gt.1.) then
stdcm(itime)=sqrt(sum2/sum1)
else
stdcm(itime)=0.
endif
concm(itime)=concm(itime)*1.e-6
radcm(itime)=radcm(itime)*1.e6
stdcm(itime)=stdcm(itime)*1.e6
print*,'conc,rad,std: ',concm(itime),radcm(itime),stdcm(itime)
enddo ! TIME LOOP
cc finished...
cc plot cntrm:
call setusv('LW',2000)
call set(.12,.52,.1,.5,0.,10.,0.,2.,1)
call labmod('(f3.0)','(f3.0)',4,4,2,2,20,20,0)
call periml(2,5,2,5)
call dashdc('$$$$$$$$$$$$$$$$$$$$',10,12)
call curved(cntti,zcntrm,ntime)
call set(.58,.98,.1,.5,0.,10.,1.,2.,1)
call labmod('(f3.0)','(f3.1)',4,4,2,2,20,20,0)
call periml(2,5,2,5)
call dashdc('$$$$$$$$$$$$$$$$$$$$',10,12)
call curved(cntti,xcntrm,ntime)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.32,0.03, 'time (min)', 0.014,0.,0)
CALL plchhq(.78,0.03, 'time (min)', 0.014,0.,0)
CALL plchhq(.03,0.30, 'x,z qc center of mass (km)', 0.014,90.,0)
cc plot qcav:
call setusv('LW',2000)
call set(.12,.52,.55,.95,0.,10.,0.,1.,1)
call labmod('(f3.0)','(f3.0)',4,4,2,2,20,20,0)
call periml(2,5,2,5)
call dashdc('$$$$$$$$$$$$$$$$$$$$',10,12)
call curved(cntti,qcav,ntime)
call set(.58,.98,.55,.95,0.,10.,0.,1.,1)
call labmod('(f3.0)','(f3.1)',4,4,2,2,20,20,0)
call periml(2,5,2,5)
call dashdc('$$$$$$$$$$$$$$$$$$$$',10,12)
call curved(cntti,qcst,ntime)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.03,0.75, 'av and st dev qc (g/kg)', 0.014,90.,0)
call frame
call clsgks
stop
end
subroutine noise(ff,nx,nz,nzn)
dimension ff(nx,nz)
c double precision rand
do i=1,nx
do k=1,nz
ff(i,k)=0.
enddo
enddo
do i=1,nx-1
do k=2,nzn
ff(i,k)=2.*(rand()-.5)
enddo
enddo
do k=1,nzn
ff(nx,k)=ff(1,k)
enddo
return
end
subroutine velprd_1(ux,uxp,uxa,uz,uzp,uza,nx,nz,rho)
dimension ux(nx,nz),uz(nx,nz)
dimension uxp(nx,nz),uzp(nx,nz)
dimension uxa(nx+1,nz),uza(nx,nz+1),rho(nx,nz)
common/grid/ time,dt,dx,dz,dti,dxi,dzi
do k=1,nz
do i=2,nx
uxa(i,k) =(0.75*(ux(i-1,k)*rho(i-1,k)+ux(i,k)*rho(i,k))
. - 0.25*(uxp(i-1,k)*rho(i-1,k)+uxp(i,k)*rho(i,k)) )*dt/dx
enddo
cc cyclic in horizontal
uxa(1,k) = uxa(nx,k)
uxa(nx+1,k) = uxa(2,k)
enddo
do i=1,nx
do k=2,nz
uza(i,k) =(0.75*(uz(i,k-1)*rho(i,k-1)+uz(i,k)*rho(i,k))
. - 0.25*(uzp(i,k-1)*rho(i,k-1)+uzp(i,k)*rho(i,k)) )*dt/dz
enddo
cc zero flux in vertical
uza(i,1) = - uza(i,2)
uza(i,nz+1) = - uza(i,nz)
enddo
return
end
subroutine mpdat_2d(u1,u2,x,h,iflg,liner)
include 'param.grid'
parameter(n1=nx+1,n2=nz+1)
parameter(n1m=n1-1,n2m=n2-1)
dimension u1(n1,n2m),u2(n1m,n2),x(n1m,n2m),h(n1m,n2m)
common// v1(n1,n2m),v2(n1m,n2),f1(n1,n2m),f2(n1m,n2),
* cp(n1m,n2m),cn(n1m,n2m),
* mx(n1m,n2m),mn(n1m,n2m)
real mx,mn
parameter(iord0=2,isor=1,nonos=1,idiv=0)
data ep/1.e-12/
c
donor(y1,y2,a)=cvmgm(y2,y1,a)*a
vdyf(x1,x2,a,r)=(abs(a)-a**2/r)*(abs(x2)-abs(x1))
1 /(abs(x2)+abs(x1)+ep)
vcorr(a,b,y1,y2,r)=-0.125*a*b*y1/(y2*r)
vcor31(a,x0,x1,x2,x3,r)= -(a -3.*abs(a)*a/r+2.*a**3/r**2)/3.
1 *(abs(x0)+abs(x3)-abs(x1)-abs(x2))
2 /(abs(x0)+abs(x3)+abs(x1)+abs(x2)+ep)
vcor32(a,b,y1,y2,r)=0.25*b/r*(abs(a)-2.*a**2/r)*y1/y2
vdiv1(a1,a2,a3,r)=0.25*a2*(a3-a1)/r
vdiv2(a,b1,b2,b3,b4,r)=0.25*a*(b1+b2-b3-b4)/r
pp(y)= amax1(0.,y)
pn(y)=-amin1(0.,y)
iord=iord0
if(isor.eq.3) iord=max0(iord,3)
if(liner.eq.1) iord=1
do j=1,n2-1
do i=1,n1
v1(i,j) = u1(i,j)
end do
end do
do i=1,n1-1
do j=1,n2
v2(i,j) = u2(i,j)
end do
enddo
if(nonos.eq.1) then
do j=1,n2m
jm=max0(j-1,1 )
jp=min0(j+1,n2m)
do i=1,n1m
im=(i-1+(n1-i)/n1m*(n1-2))
ip=(i+1 -i /n1m*(n1-2))
mx(i,j)=amax1(x(im,j),x(i,j),x(ip,j),x(i,jm),x(i,jp))
mn(i,j)=amin1(x(im,j),x(i,j),x(ip,j),x(i,jm),x(i,jp))
end do
end do
endif
do 3 k=1,iord
do 331 j=1,n2-1
do 331 i=2,n1-1
331 f1(i,j)=donor(x(i-1,j),x(i,j),v1(i,j))
do j=1,n2-1
f1(1 ,j)=f1(n1-1,j)
f1(n1,j)=f1(2,j)
enddo
do 332 j=2,n2-1
do 332 i=1,n1-1
332 f2(i,j)=donor(x(i,j-1),x(i,j),v2(i,j))
if (iflg.eq.6) then
do i=1,n1m
f2(i, 1)=donor(x(i, 1),x(i, 1),v2(i, 1))
f2(i,n2)=donor(x(i,n2m),x(i,n2m),v2(i,n2))
end do
else
do i=1,n1m
f2(i, 1)=-f2(i, 2)
f2(i,n2)=-f2(i,n2m)
end do
end if
do 333 j=1,n2-1
do 333 i=1,n1-1
333 x(i,j)=x(i,j)-(f1(i+1,j)-f1(i,j)+f2(i,j+1)-f2(i,j))/h(i,j)
if(k.eq.iord) go to 6
do 49 j=1,n2-1
do 49 i=1,n1
f1(i,j)=v1(i,j)
49 v1(i,j)=0.
do 50 j=1,n2
do 50 i=1,n1-1
f2(i,j)=v2(i,j)
50 v2(i,j)=0.
do 51 j=2,n2-2
do 51 i=2,n1-1
51 v1(i,j)=vdyf(x(i-1,j),x(i,j),f1(i,j),.5*(h(i-1,j)+h(i,j)))
* +vcorr(f1(i,j), f2(i-1,j)+f2(i-1,j+1)+f2(i,j+1)+f2(i,j),
* abs(x(i-1,j+1))+abs(x(i,j+1))-abs(x(i-1,j-1))-abs(x(i,j-1)),
* abs(x(i-1,j+1))+abs(x(i,j+1))+abs(x(i-1,j-1))+abs(x(i,j-1))+ep,
* .5*(h(i-1,j)+h(i,j)))
if(idiv.eq.1) then
do 511 j=2,n2-2
do 511 i=2,n1-1
511 v1(i,j)=v1(i,j)
* -vdiv1(f1(i-1,j),f1(i,j),f1(i+1,j),.5*(h(i-1,j)+h(i,j)))
* -vdiv2(f1(i,j),f2(i-1,j+1),f2(i,j+1),f2(i-1,j),f2(i,j),
* .5*(h(i-1,j)+h(i,j)))
endif
do 52 j=2,n2-1
do 52 i=2,n1-2
52 v2(i,j)=vdyf(x(i,j-1),x(i,j),f2(i,j),.5*(h(i,j-1)+h(i,j)))
* +vcorr(f2(i,j), f1(i,j-1)+f1(i,j)+f1(i+1,j)+f1(i+1,j-1),
* abs(x(i+1,j-1))+abs(x(i+1,j))-abs(x(i-1,j-1))-abs(x(i-1,j)),
* abs(x(i+1,j-1))+abs(x(i+1,j))+abs(x(i-1,j-1))+abs(x(i-1,j))+ep,
* .5*(h(i,j-1)+h(i,j)))
i0=n1-2
do j=2,n2-1
v2(1,j)=vdyf(x(1,j-1),x(1,j),f2(1,j),.5*(h(1,j-1)+h(1,j)))
* +vcorr(f2(1,j), f1(1,j-1)+f1(1,j)+f1(2,j)+f1(2,j-1),
* abs(x(2,j-1))+abs(x(2,j))-abs(x(i0,j-1))-abs(x(i0,j)),
* abs(x(2,j-1))+abs(x(2,j))+abs(x(i0,j-1))+abs(x(i0,j))+ep,
* .5*(h(1,j-1)+h(1,j)))
v2(n1-1,j)=v2(1,j)
enddo
if(idiv.eq.1) then
do 521 j=2,n2-1
do 521 i=1,n1-1
521 v2(i,j)=v2(i,j)
* -vdiv1(f2(i,j-1),f2(i,j),f2(i,j+1),.5*(h(i,j-1)+h(i,j)))
* -vdiv2(f2(i,j),f1(i+1,j),f1(i+1,j-1),f1(i,j-1),f1(i,j),
* .5*(h(i,j-1)+h(i,j)))
endif
if(isor.eq.3) then
do 61 j=2,n2-2
do 61 i=3,n1-2
61 v1(i,j)=v1(i,j) +vcor31(f1(i,j),
1 x(i-2,j),x(i-1,j),x(i,j),x(i+1,j),.5*(h(i-1,j)+h(i,j)))
do j=2,n2-2
v1(2,j)=v1(2,j) +vcor31(f1(2,j),
1 x(n1-2,j),x(1,j),x(2,j),x(3,j),.5*(h(1,j)+h(2,j)))
v1(n1-1,j)=v1(n1-1,j) +vcor31(f1(n1-1,j),x(n1-3,j),x(n1-2,j),
1 x(n1-1,j),x(2,j),.5*(h(n1-2,j)+h(n1-1,j)))
enddo
do 62 j=2,n2-2
do 62 i=2,n1-1
62 v1(i,j)=v1(i,j)
1 +vcor32(f1(i,j),f2(i-1,j)+f2(i-1,j+1)+f2(i,j+1)+f2(i,j),
* abs(x(i,j+1))-abs(x(i,j-1))-abs(x(i-1,j+1))+abs(x(i-1,j-1)),
* abs(x(i,j+1))+abs(x(i,j-1))+abs(x(i-1,j+1))+abs(x(i-1,j-1))+ep,
* .5*(h(i-1,j)+h(i,j)))
do 63 j=3,n2-2
do 63 i=1,n1-1
63 v2(i,j)=v2(i,j) +vcor31(f2(i,j),
1 x(i,j-2),x(i,j-1),x(i,j),x(i,j+1),.5*(h(i,j-1)+h(i,j)))
do 64 j=3,n2-2
do 64 i=2,n1-2
64 v2(i,j)=v2(i,j)
1 +vcor32(f2(i,j),f1(i,j-1)+f1(i+1,j-1)+f1(i+1,j)+f1(i,j),
* abs(x(i+1,j))-abs(x(i-1,j))-abs(x(i+1,j-1))+abs(x(i-1,j-1)),
* abs(x(i+1,j))+abs(x(i-1,j))+abs(x(i+1,j-1))+abs(x(i-1,j-1))+ep,
* .5*(h(i,j-1)+h(i,j)))
do 641 j=3,n2-2
v2(1,j)=v2(1,j)
1 +vcor32(f2(1,j),f1(1,j-1)+f1(2,j-1)+f1(2,j)+f1(1,j),
* abs(x(2,j))-abs(x(n1-2,j))-abs(x(2,j-1))+abs(x(n1-2,j-1)),
* abs(x(2,j))+abs(x(n1-2,j))+abs(x(2,j-1))+abs(x(n1-2,j-1))+ep,
* .5*(h(1,j-1)+h(1,j)))
641 v2(n1-1,j)=v2(1,j)
endif
do j=1,n2m
v1( 1,j)=v1(n1m,j)
v1(n1,j)=v1( 2,j)
end do
if (iflg.ne.6) then
do i=1,n1m
v2(i, 1)=-v2(i, 2)
v2(i,n2)=-v2(i,n2m)
end do
end if
if(nonos.eq.1) then
c non-osscilatory option
do 401 j=1,n2m
jm=max0(j-1,1 )
jp=min0(j+1,n2m)
do 401 i=1,n1m
im=(i-1+(n1-i)/n1m*(n1-2))
ip=(i+1 -i /n1m*(n1-2))
mx(i,j)=amax1(x(im,j),x(i,j),x(ip,j),x(i,jm),x(i,jp),mx(i,j))
401 mn(i,j)=amin1(x(im,j),x(i,j),x(ip,j),x(i,jm),x(i,jp),mn(i,j))
do 402 j=1,n2m
do 4021 i=2,n1-1
4021 f1(i,j)=donor(x(i-1,j),x(i,j),v1(i,j))
f1(1 ,j)=f1(n1m,j)
f1(n1,j)=f1(2 ,j)
402 continue
do 403 i=1,n1m
do 4031 j=2,n2m
4031 f2(i,j)=donor(x(i,j-1),x(i,j),v2(i,j))
if(iflg.ne.6) then
f2(i, 1)=-f2(i, 2)
f2(i,n2)=-f2(i,n2m)
else
f2(i, 1)=0.
f2(i,n2)=0.
endif
403 continue
do 404 j=1,n2m
do 404 i=1,n1m
cp(i,j)=(mx(i,j)-x(i,j))*h(i,j)/
1(pn(f1(i+1,j))+pp(f1(i,j))+pn(f2(i,j+1))+pp(f2(i,j))+ep)
cn(i,j)=(x(i,j)-mn(i,j))*h(i,j)/
1(pp(f1(i+1,j))+pn(f1(i,j))+pp(f2(i,j+1))+pn(f2(i,j))+ep)
404 continue
do 405 j=1,n2m
do 4051 i=2,n1m
4051 v1(i,j)=pp(v1(i,j))*
1 ( amin1(1.,cp(i,j),cn(i-1,j))*pp(sign(1., x(i-1,j)))
1 +amin1(1.,cp(i-1,j),cn(i,j))*pp(sign(1.,-x(i-1,j))) )
2 -pn(v1(i,j))*
2 ( amin1(1.,cp(i-1,j),cn(i,j))*pp(sign(1., x(i ,j )))
2 +amin1(1.,cp(i,j),cn(i-1,j))*pp(sign(1.,-x(i ,j ))) )
v1( 1,j)=v1(n1m,j)
v1(n1,j)=v1( 2 ,j)
405 continue
do 406 i=1,n1m
do 406 j=2,n2m
406 v2(i,j)=pp(v2(i,j))*
1 ( amin1(1.,cp(i,j),cn(i,j-1))*pp(sign(1., x(i,j-1)))
1 +amin1(1.,cp(i,j-1),cn(i,j))*pp(sign(1.,-x(i,j-1))) )
1 -pn(v2(i,j))*
2 ( amin1(1.,cp(i,j-1),cn(i,j))*pp(sign(1., x(i ,j )))
2 +amin1(1.,cp(i,j),cn(i,j-1))*pp(sign(1.,-x(i ,j ))) )
endif
3 continue
6 continue
return
end
subroutine gcrk_1(p,pfx,pfz,u,w,n1,n3,itr,eps0)
real p(*),pfx(*),pfz(*),u(*),w(*)
include 'param.grid'
parameter(n=nx,l=nz)
parameter(nn=n*l,nl=n*l)
common// r(nn),qr(nn),ar(nn)
common/grid/ time,dt,dx,dz,dti,dxi,dzi
common /prof_d/ rho0(nz),th0(nz),th_e(nz),ux_e(nz),uy_e(nz)
common /strtch/ height(nz),gac(nz)
common/itero/ niter,nitsm,icount,eer,eem
parameter (lord=3)
dimension x(nn,lord),ax(nn,lord),ax2(lord),axar(lord),del(lord)
dimension rho2d(nx,nz)
convergence test modes **************************************************
logical ctest *