-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkinematic_wrain.vocals.f
1113 lines (1056 loc) · 35.5 KB
/
kinematic_wrain.vocals.f
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 kinematic
C
C AUTHORS: WOJCIECH GRABOWSKI ([email protected], 303-497-8974)
C with 2D MPDATA routine written by P. Smolarkiewicz (NCAR)
C
C
c This program can be used in the 2D kinematic tests of the warm
c rain microphysics. The airflow is prescribed using streamfunction
c subroutine that calculates anelastic flow pattern at every
c timestep. Standard stagerred C-grid is assumed, i.e., velocities
c are shifted half the distance from the thermodynamic fields. The
c diagram below shows a sample of the grid for the 4 by 4 setup;
c Xs mark positions of thermodynamic fields, Ws and Us - positions
c of velocity components, and 'o's mark positions of the stream-
c function that is used to calculate nondivergent velocities.
c Note that the grid requires 5 by 4 horizontal velocity points,
c 4 by 5 vertical velocity points, and 5 by 5 streamfunction points.
c
c o----W----o----W----o----W----o----W----o
c | | | | |
c U X U X U X U X U
c | | | | |
c o----W----o----W----o----W----o----W----o
c | | | | |
c U X U X U X U X U
c | | | | |
c o----W----o----W----o----W----o----W----o
c | | | | |
c U X U X U X U X U
c | | | | |
c o----W----o----W----o----W----o----W----o
c | | | | |
c U X U X U X U X U
c | | | | |
c o----W----o----W----o----W----o----W----o
c
c
c
c Bulk model is used in this example. If more sophisticated
c thermodynamics is to be used (e.g., detailed microphysics)
c changes to this code have to be introduced. For example,
c in a detailed microphysics case, every class of cloud
c droplets and raindrops has to be advected independently. Also,
c terminal velocities have to be added to the airflow velo-
c cities for every class to account for particle sedimentation.
c Once the logic of this test is understood, these changes
c should be simple to make.
c
c NOTE: there is considerable number of comments both in the main
c program and in subroutines that should help to understand
c details of this program
c
c THIS CODE HAS BEEN WRITTEN WITHOUT EFFICIENCY CONSIDERATIONS;
c IT CAN BE SIGNIFICANTLY ENHANCED IF REQUIRED.
c
c
c basic parameters of the model
parameter(nx=75,nz=75,dx=20.,dz=20.)
parameter(nxp=nx+1,nxm=nx-1,nzp=nz+1,nzm=nz-1)
c
c potential temperature, water vapor mixing ratio, cloud water
c mixing ratio, rain water mixing ratio:
c IN THE DETAILED CASE: qc and qr should be replaced with
c qq(nx,nz,ncl) where ncl is number of droplet classes considered
dimension theta(nx,nz),qv(nx,nz),qc(nx,nz),qr(nx,nz)
c
c surface precipitation rate (used in analysis of model data)
dimension sprec(nx)
c Jacobian used in advection (required in runs with topo, here
c redundant)
dimension gac(nx,nz)
c
c velocity fields needed for advection:
c uxa,uza are air velocities, uzam is used to include sedimentation
c uz for printout
dimension uxa(nxp,nz),uza(nx,nzp),uzam(nx,nzp),uz(nx,nz)
c velocity for ploting
dimension uxpl(nx,nz),uzpl(nx,nz)
c
c environmental temperature, potential temperature, pressure and
c water vapor mixing ratio
common /environ2/ temp_e(nz),theta_e(nz),pres_e(nz),
1 qv_e(nz),qc_e(nz)
c base state density profile
common /environ1/ rho(nz)
ccc
c time step used in the model, number of time steps
data dt,ntstp /4.,3600/
c
character*50 lhead
c statement function to define rain terminal velocity:
vterm(qq,rro)=36.34*sqrt(1./rro)*(rro*1.e-3*qq)**.1346
c
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
call opngks
call gsclip(0)
xl=nx*dx*1.e-3
zl=nz*dz*1.e-3
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
C
cc parameters for the MPDATA routine:
iord=2
isor=1
nonos=0
idiv=0
c INSERT INITIAL FIELDS AND WRITE TO HISTORY TAPE (fort.22):
c -------> prescribe initial fields
call init(nz,dz)
do k=1,nz
do i=1,nx
theta(i,k)=theta_e(k)
qv(i,k) =qv_e(k)
qc(i,k) =qc_e(k)
qr(i,k) =0.
gac(i,k) =rho(k)
enddo
enddo
c -------> call microphysical adjustement routine:
C write(22) temp_e,theta_e,pres_e,qv_e,qc_e
C write(22) rho
C
C write(22) theta
C write(22) qv
C write(22) qc
C write(22) qr
C write(22) qr !<-- qr in place of updraft
ccc plot of initial conditions:
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
time=0.
c theta
call setusv('LW',3000)
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call perim (3,5,3,5)
cmx=300.
cmn=260.
cnt=.2
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(theta,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc negative values
ct=-cnt
call cpcnrc(theta,nx,nx,nz,cmn,ct,cnt,-1,-1,-682)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.50,0.85, 'potential temperature (K)', 0.016,0.,0)
CALL plchhq(.50,0.16, 'x (km)', 0.016,0.,0)
CALL plchhq(.14,0.50, 'z (km)', 0.016,90.,0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.20,0.16, '0.0', 0.016,0.,0)
CALL plchhq(.80,0.16, '1.5', 0.016,0.,0)
CALL plchhq(.15,0.20, '0.0', 0.016,0.,0)
CALL plchhq(.15,0.80, '1.5', 0.016,0.,0)
call frame
cc qv
c call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
c call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
c call periml(3,5,3,5)
c cmx=20.*1.e-3
c cmn=2.*1.e-3
c cnt=0.25*1.e-3
ccc positive values
c ct=cnt
c call cpsetc('ILT',' ')
c call cpcnrc(qv,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
ccc negative values
c ct=-cnt
c call cpcnrc(qv,nx,nx,nz,cmn,ct,cnt,-1,-1,-682)
write(lhead,351) time
351 format(' QV (kg/kg) ',f6.0)
c call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
c CALL plchmq(.50,0.85, lhead(1:50), 0.016,0.,0)
c CALL plchhq(.50,0.12, 'X (km)', 0.016,0.,0)
c CALL plchhq(.12,0.50, 'Z (km)', 0.016,90.,0)
c call frame
c qc
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call perim (3,5,3,5)
cmx=10.*1.e-3
cmn=.1 *1.e-3
cnt=cmn
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(qc,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc trace:
call cpcnrc(qc,nx,nx,nz,1.e-5,1.1e-5,1.e-5,-1,-1,682)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.50,0.85, 'cloud water (g/kg)', 0.016,0.,0)
CALL plchhq(.50,0.16, 'x (km)', 0.016,0.,0)
CALL plchhq(.14,0.50, 'z (km)', 0.016,90.,0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.20,0.16, '0.0', 0.016,0.,0)
CALL plchhq(.80,0.16, '1.5', 0.016,0.,0)
CALL plchhq(.15,0.20, '0.0', 0.016,0.,0)
CALL plchhq(.15,0.80, '1.5', 0.016,0.,0)
call frame
cc qr
c call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
c call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
c call perim (3,5,3,5)
c cmx=10.*1.e-3
c cmn=.002*1.e-3
c cnt=cmn
ccc positive values
c ct=cnt
c call cpsetc('ILT',' ')
c call cpcnrc(qr,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
ccc trace:
c call cpcnrc(qr,nx,nx,nz,1.e-6,1.1e-6,1.e-6,-1,-1,682)
write(lhead,353) time
353 format(' QR (kg/kg) ',f6.0)
c call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
c CALL plchmq(.50,0.85, lhead(1:50), 0.016,0.,0)
c CALL plchhq(.50,0.12, 'x (km)', 0.016,0.,0)
c CALL plchhq(.12,0.50, 'z (km)', 0.016,90.,0)
c call frame
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
c -------> get advective Courant numbers:
cc FLOW DOES NOT CHANGE IN TIME....
call adv_vel(uxa,uza,nx,nz,dx,dz,dt)
cc plot of the flow field:
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
ax1=-1.e7
ax2=-1.e7
an1= 1.e7
an2= 1.e7
do i=1,nx
do k=1,nz
uxpl(i,k)=.5*(uxa(i,k)+uxa(i+1,k)) /dt*dx /rho(k)
uzpl(i,k)=.5*(uza(i,k)+uza(i,k+1)) /dt*dz /rho(k)
ax1=amax1(ax1,uxpl(i,k))
ax2=amax1(ax2,uzpl(i,k))
an1=amin1(an1,uxpl(i,k))
an2=amin1(an2,uzpl(i,k))
enddo
enddo
print*,'ux: min,max: ',an1,ax1
print*,'uz: min,max: ',an2,ax2
c u
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call perim (3,5,3,5)
cc positive values
call cpsetc('ILT',' ')
call cpcnrc(uxpl,nx,nx,nz,0.1,5.,0.1,-1,-1,1)
cc negative values
call cpcnrc(uxpl,nx,nx,nz,-5.,-0.1,0.1,-1,-1,-682)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.50,0.85,'horizontal flow', 0.016,0.,0)
CALL plchhq(.50,0.16, 'x (km)', 0.016,0.,0)
CALL plchhq(.14,0.50, 'z (km)', 0.016,90.,0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.20,0.16, '0.0', 0.016,0.,0)
CALL plchhq(.80,0.16, '1.5', 0.016,0.,0)
CALL plchhq(.15,0.20, '0.0', 0.016,0.,0)
CALL plchhq(.15,0.80, '1.5', 0.016,0.,0)
call frame
c w
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call perim (3,5,3,5)
call cpsetc('ILT',' ')
call cpcnrc(uzpl,nx,nx,nz,.2,5.,.2,-1,-1,1)
call cpcnrc(uzpl,nx,nx,nz,-5.,-.2,.2,-1,-1,-682)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.50,0.85,'vertical flow', 0.016,0.,0)
CALL plchhq(.50,0.16, 'x (km)', 0.016,0.,0)
CALL plchhq(.14,0.50, 'z (km)', 0.016,90.,0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.20,0.16, '0.0', 0.016,0.,0)
CALL plchhq(.80,0.16, '1.5', 0.016,0.,0)
CALL plchhq(.15,0.20, '0.0', 0.016,0.,0)
CALL plchhq(.15,0.80, '1.5', 0.016,0.,0)
call frame
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
c MAIN TIME LOOP STARTS HERE:
cc
do it=1,ntstp
time=it*dt
cccccc add relaxation to initial profiles in the lower part of the domain
relax_depth=200. ! e-folding relaxation depth
relax_time=5. * 60. ! relaxation time scale
do k=1,nz
zz=float(k-1)*dz
tau=relax_time * exp(zz/relax_depth)
do i=1,nx
theta(i,k)=theta(i,k) - (theta(i,k)-theta_e(k))*dt/tau
qv(i,k)= qv(i,k) - ( qv(i,k)- qv_e(k))*dt/tau
enddo
enddo
c
c -------> call 2D advection for all fields that move
c with the air
call mpdata2d(uxa,uza ,theta,gac,nx,nz,iord,isor,nonos,idiv,1)
call mpdata2d(uxa,uza , qv ,gac,nx,nz,iord,isor,nonos,idiv,2)
call mpdata2d(uxa,uza , qc ,gac,nx,nz,iord,isor,nonos,idiv,3)
c
c -------> modify vertical Courant numbers for precipitating field(s):
c (only rain in this case):
do k=2,nz
rho_shift=.5*(rho(k)+rho(k-1))
do i=1,nx
qr_shift=amax1(0.,.5*(qr(i,k)+qr(i,k-1)))
vt=vterm(qr_shift,rho_shift)
uzam(i,k)=uza(i,k)-rho_shift*vt*dt/dz
enddo
enddo
c extrapolate k=1:
rho_shift=1.5*rho(1)-.5*rho(2)
do i=1,nx
qr_shift=amax1(0.,1.5*qr(i,1)-.5*qr(i,2))
vt=vterm(qr_shift,rho_shift)
uzam(i,1)=uza(i,1)-rho_shift*vt*dt/dz
enddo
c
call mpdata2d(uxa,uzam, qr ,gac,nx,nz,iord,isor,nonos,idiv,4)
c
c -------> call microphysical adjustement routine:
call micro(theta,qv,qc,qr,nx,nz,dt)
cc
if(amod(time,300.).eq.0.) then
cc calculate and output diagnostics:
qcmx=-10.
qcmn= 10.
qrmx=-10.
qrmn= 10.
iqc=1
kqc=1
iqr=1
kqr=1
do i=1,nx
do k=1,nz
qcmx=amax1(qcmx,qc(i,k))
qcmn=amin1(qcmn,qc(i,k))
qrmx=amax1(qrmx,qr(i,k))
qrmn=amin1(qrmn,qr(i,k))
if(qcmx.eq.qc(i,k)) then
iqc=i
kqc=k
endif
if(qrmx.eq.qr(i,k)) then
iqr=i
kqr=k
endif
enddo
enddo
print*,time,' ******** TIME *******'
print*,qcmx,qcmn,' **** qcmx,qcmn: '
print*,iqc,kqc,' i,k position of the qcmx'
print*,qrmx,qrmn,' **** qrmx,qrmn: '
print*,iqr,kqr,' i,k position of the qrmx'
vt=vterm(qr(iqr,kqr),rho(kqr))
prec=qr(iqr,kqr)*rho(kqr)*vt
prec=prec*3600. ! convert from kg/m**2/s to mm/hr
print*,prec,' corresponding precip (mm/hr)'
cc k=1 precipitation:
k=1
do i=1,nx
vt=vterm(qr(i,k),rho(k))
prec=qr(i,k)*rho(k)*vt
prec=prec*3600. ! convert from kg/m**2/s to mm/hr
sprec(i)=prec
enddo
sum=0.
imx=1
amx=-1000.
do i=1,nx
sum=sum+sprec(i)
amx=amax1(amx,sprec(i))
if(amx.eq.sprec(i)) imx=i
enddo
sum=sum/float(nx)
print*,amx,imx,sum,' SURF PREC: max,imax,aver'
endif
c -------> write and plot thermodynamic fields:
print*,' *** done with minute: ',time/60.
Ccc write data every 15 minutes...
C if(amod(time,900.).eq.0.) then
C write(22) theta
C write(22) qv
C write(22) qc
C write(22) qr
C do i=1,nx
C do k=1,nz
C uz(i,k)=.5*(uza(i,k)+uza(i,k+1))
C enddo
C enddo
C write(22) uz
C endif
cc
if(amod(time,300.).eq.0.) then
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
c theta
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call periml(3,5,3,5)
cmx=300.
cmn=260.
cnt=.1
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(theta,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc negative values
ct=-cnt
call cpcnrc(theta,nx,nx,nz,cmn,ct,cnt,-1,-1,-682)
write(lhead,350) time
350 format(' Theta (K) ',f6.0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchmq(.50,0.85, lhead(1:50), 0.016,0.,0)
CALL plchhq(.50,0.12, 'X (km)', 0.016,0.,0)
CALL plchhq(.12,0.50, 'Z (km)', 0.016,90.,0)
call frame
c qv
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call periml(3,5,3,5)
cmx=20.*1.e-3
cmn=2.*1.e-3
cnt=0.25*1.e-3
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(qv,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc negative values
ct=-cnt
call cpcnrc(qv,nx,nx,nz,cmn,ct,cnt,-1,-1,-682)
write(lhead,351) time
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchmq(.50,0.85, lhead(1:50), 0.016,0.,0)
CALL plchhq(.50,0.12, 'X (km)', 0.016,0.,0)
CALL plchhq(.12,0.50, 'Z (km)', 0.016,90.,0)
call frame
c qc
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call periml(3,5,3,5)
cmx=10.*1.e-3
cmn=.1 *1.e-3
cnt=cmn
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(qc,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc trace:
call cpcnrc(qc,nx,nx,nz,1.e-5,1.1e-5,1.e-5,-1,-1,682)
write(lhead,352) time
352 format(' QC (kg/kg) ',f6.0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchmq(.50,0.85, lhead(1:50), 0.016,0.,0)
CALL plchhq(.50,0.12, 'X (km)', 0.016,0.,0)
CALL plchhq(.12,0.50, 'Z (km)', 0.016,90.,0)
call frame
c qr
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call periml(3,5,3,5)
cmx=10.*1.e-3
cmn=.002*1.e-3
cnt=cmn
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(qr,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc trace:
call cpcnrc(qr,nx,nx,nz,1.e-6,1.1e-6,1.e-6,-1,-1,682)
write(lhead,353) time
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchmq(.50,0.85, lhead(1:50), 0.016,0.,0)
CALL plchhq(.50,0.12, 'X (km)', 0.016,0.,0)
CALL plchhq(.12,0.50, 'Z (km)', 0.016,90.,0)
call frame
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
endif
c MAIN TIME LOOP ENDS HERE:
enddo
ccc final solution
c theta
call setusv('LW',3000)
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call perim (3,5,3,5)
cmx=300.
cmn=260.
cnt=.2
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(theta,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc negative values
ct=-cnt
call cpcnrc(theta,nx,nx,nz,cmn,ct,cnt,-1,-1,-682)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.50,0.85, 'potential temperature (K)', 0.016,0.,0)
CALL plchhq(.50,0.16, 'x (km)', 0.016,0.,0)
CALL plchhq(.14,0.50, 'z (km)', 0.016,90.,0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.20,0.16, '0.0', 0.016,0.,0)
CALL plchhq(.80,0.16, '1.5', 0.016,0.,0)
CALL plchhq(.15,0.20, '0.0', 0.016,0.,0)
CALL plchhq(.15,0.80, '1.5', 0.016,0.,0)
call frame
c qv
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call periml(3,5,3,5)
cmx=20.*1.e-3
cmn=2.*1.e-3
cnt=0.25*1.e-3
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(qv,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc negative values
ct=-cnt
call cpcnrc(qv,nx,nx,nz,cmn,ct,cnt,-1,-1,-682)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.50,0.85, 'water vapor (g/kg)', 0.016,0.,0)
CALL plchhq(.50,0.16, 'x (km)', 0.016,0.,0)
CALL plchhq(.14,0.50, 'z (km)', 0.016,90.,0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.20,0.16, '0.0', 0.016,0.,0)
CALL plchhq(.80,0.16, '1.5', 0.016,0.,0)
CALL plchhq(.15,0.20, '0.0', 0.016,0.,0)
CALL plchhq(.15,0.80, '1.5', 0.016,0.,0)
call frame
c qc
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call perim (3,5,3,5)
cmx=10.*1.e-3
cmn=.1 *1.e-3
cnt=cmn
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(qc,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc trace:
call cpcnrc(qc,nx,nx,nz,1.e-5,1.1e-5,1.e-5,-1,-1,682)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.50,0.85, 'cloud water (g/kg)', 0.016,0.,0)
CALL plchhq(.50,0.16, 'x (km)', 0.016,0.,0)
CALL plchhq(.14,0.50, 'z (km)', 0.016,90.,0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.20,0.16, '0.0', 0.016,0.,0)
CALL plchhq(.80,0.16, '1.5', 0.016,0.,0)
CALL plchhq(.15,0.20, '0.0', 0.016,0.,0)
CALL plchhq(.15,0.80, '1.5', 0.016,0.,0)
call frame
c qr
call set(.2,.8,.2,.8, 0.,xl,0.,zl,1)
call labmod('(f4.1)','(f4.1)',4,4,2,2,20,20,0)
call perim (3,5,3,5)
cmx=10.*1.e-3
cmn=.002*1.e-3
cnt=cmn
cc positive values
ct=cnt
call cpsetc('ILT',' ')
call cpcnrc(qr,nx,nx,nz,ct,cmx,cnt,-1,-1,1)
cc trace:
call cpcnrc(qr,nx,nx,nz,1.e-6,1.1e-6,1.e-6,-1,-1,682)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.50,0.85, 'drizzle water (g/kg)', 0.016,0.,0)
CALL plchhq(.50,0.16, 'x (km)', 0.016,0.,0)
CALL plchhq(.14,0.50, 'z (km)', 0.016,90.,0)
call set(0.,1.,0.,1.,0.,1.,0.,1.,1)
CALL plchhq(.20,0.16, '0.0', 0.016,0.,0)
CALL plchhq(.80,0.16, '1.5', 0.016,0.,0)
CALL plchhq(.15,0.20, '0.0', 0.016,0.,0)
CALL plchhq(.15,0.80, '1.5', 0.016,0.,0)
call frame
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
call clsgks
C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS C NCAR GRAPHICS
stop
end
subroutine init(nz1,dz1)
parameter(nz=75,dz=20.)
common /environ1/ rho(nz)
common /environ2/ temp_e(nz),theta_e(nz),pres_e(nz),
1 qv_e(nz),qc_e(nz)
data g /9.72/
cc note that saturated water vapor pressure and latent heat
cc of vaporozation are given for the reference temperature
cc of 20/10 deg C.
data rg,cp,rv,t00,e00,hlat
cc 20 deg C
c 1 /287.,1005.,461.,293.16,2337.,2.45e6/
cc 10 deg C
1 /287.,1005.,461.,283.16,1228.,2.45e6/
PARAMETER(NPIN=nz)
DIMENSION press(npin),theta_l(npin),q_tot(npin),zin(npin)
DIMENSION temp(npin),vap(npin),qcin(npin)
cccc check consistency:
if(nz.ne.nz1.or.dz.ne.dz1) then
print*,' *** inconsistent setup in init, stop'
stop 'init'
endif
cc
cc initial theta_l and q_tot profiles:
do k=1,npin
zin(k)=float(k-1)*dz
theta_l(k)=289.
q_tot(k)=7.5e-3
enddo
cc we assume that the first level is undersaturated
cc (no cloud), temp is potential temp here
press(1)=1015. ! surface pressure in hPa
vap(1)=q_tot(1)*1.e3 ! in g/kg
qcin(1)=0.
temp(1)=theta_l(1)
cc decompose theta_l and q_tot to get cloud water at higher levels:
cc predictor-corrector approach to get pressure
a=rg/rv
b=hlat/(rv*t00)
c=hlat/cp
d=hlat/rv
e=-cp/rg
f=rg/cp
do k=2,nz
cc inital guess for pressure:
km=k-1
tempkm=temp(km)*(1.e3/press(km))**(-rg/cp)
1 * (1.+.6e-3*vap(km))
rhokm=press(km)*1.e2/(rg*tempkm)
press(k)=press(km)*1.e2 - g*dz*rhokm
press(k)=press(k)/1.e2
temp(k)=theta_l(k)
vap(k)=q_tot(k)*1.e3 ! in g/kg
cc iterate pressure and theta_l/q_tot decomposition
qcin(k)=0.
do iter=1,5
pre=press(k)*1.e2
thetme=(1.e5/pre)**f
thi=1./temp(k)
y=b*thetme*t00*thi
ees=e00*exp(b-y)
qvs=a*ees/(pre-ees)
ccc linearized condensation rate is next:
cf1=thetme*thetme*thi*thi
cf1=c*cf1*pre/(pre-ees)*d
delta=(vap(k)*1.e-3-qvs)/(1.+qvs*cf1)
c--->
delta=amax1(0.,delta)
vap(k)=vap(k)-delta*1.e3
qcin(k)=qcin(k)+delta
temp(k)=temp(k)+c*thetme*delta
pressa=(press(km)+press(k))/2.
tempk=temp(k)*(1.e3/press(k))**(-rg/cp)
1 * (1.+.6e-3*vap(k))
tempa=(tempkm+tempk)/2.
rhoa=pressa*1.e2/(rg*tempa)
press(k)=press(km)*1.e2 - g*dz*rhoa
press(k)=press(k)/1.e2
enddo ! iter
print*,'z,t,vap,qc: ',(k-0.5)*dz,temp(k),vap(k),qcin(k)
enddo ! levels
compute environmental profiles from input sounding:
do 64 k=1,nz
theta_e(k)=temp(k)
qv_e(k)=vap(k)*1.e-3
qc_e(k)=qcin(k)
presnl=press(k)
pres_e(k)=presnl*1.e2
temp_e(k)=theta_e(k) * (1000./presnl)**(-rg/cp)
te_virt=temp_e(k)*(1.+.6*qv_e(k))
rho(k)=pres_e(k)/(rg*te_virt)
cccccccc
print 284,k,theta_e(k),temp_e(k),qv_e(k)*1.e3,qc_e(k)*1.e3,
1 pres_e(k)*1.e-2,rho(k)
284 format(1x,'k,ts,qs,pre,rho: ',i4,6f10.3)
cccccccc
64 continue
return
end
subroutine adv_vel(ux,uz,mx,mz,dx,dz,dt)
c this routine provides flow input to the model
c ON INPUT:
c mx - x dimension of scalar arrays
c mz - z dimension of scalar arrays
c dx,dz - grid intervals in x and z direction
c ON OUTPUT:
c ux,uz - rho times velocity components normalized
c by dx/dt or dz/dt
c
C
parameter(nx=75,nz=75)
parameter(nxp=nx+1,nzp=nz+1)
cc streamfunction and positions of its gridpoints:
dimension phi(nxp,nzp),xp(nxp),zp(nzp)
cc arrays with velocities
dimension ux(mx+1,mz),uz(mx,mz+1)
C
C CHECK DIMENSIONS:
if(mx.ne.nx.or.mz.ne.nz) then
print*,' *** dimensions do not match in adv_vel, stop'
stop
endif
C
C CALCULATE X AND Z DISTANCES (IN METERS)
do k=1,nzp
zp(k)=(k-1)*dz
enddo
do i=1,nxp
xp(i)=(i-1)*dx
enddo
XSCALE=xp(nxp)
ZSCALE=zp(nzp)
pi=4.*atan(1.)
C
CC INITIAL DATA FOR THE STREAMFUNCTION. AMPL IS WMAX IN M/S,
C
c AMPL=1.0
AMPL=0.6
C
C ADOPT THE AMPL FOR STREAMFUNCTION CALCULATION TO BE W_MAX/K_x
AMPL=AMPL/pi*XSCALE
C
C DEFINE STREAMFUNCTION AS A FUNCTION OF HEIGHT
C ALSO, CENTRALIZE THE UPDRAFT TO OCCUPY ONLY THE INNER XSCALE
C OF THE DOMAIN
C
ZTOP=zp(nzp)/ZSCALE
XCEN=.5*xp(nxp)
X0=(xp(nxp)-XSCALE)/2.
DO 1 I=1,NXP
DO 1 K=1,NZP
PHI(i,k)=-cos(2.*pi*(xp(i)-X0)/XSCALE)*sin(pi*zp(k)/ZSCALE)
PHI(i,k)=PHI(i,k)*AMPL
1 CONTINUE
C
cc calculate rho*vel by derivation of streamfunction and normalize
cc rho*ux velocity:
do i=1,nxp
do k=1,nz
ux(i,k)=-(phi(i,k+1)-phi(i,k))/dz *dt/dx
enddo
enddo
cc rho*uz velocity
do k=1,nzp
do i=1,nx
uz(i,k)=(phi(i+1,k)-phi(i,k))/dx *dt/dz
enddo
enddo
ccc
return
end
SUBROUTINE MPDATA2D(U1,U2,X,H,N,M,IORD,ISOR,NONOS,IDIV,IFL)
C THIS SUBROUTINE SOLVES 2-D ADVECTIVE TRANSPORT IN CARTESIAN GEOMETRY
C ON STAGGERRED GRID (X,Y VELOCITIES SHIFTED HALF GRID IN X, Y DIR, RESP)
C*************************************************************************
C ADVECTION ALGORITHM: IORD - NUMBER OF ITERATIONS (IORD=1 OVERWRITES
C CALLS TO OTHER OPTIONS AND GIVES SIMPLE UPSTREAM SCHEME); ISOR=1 2ND ORDER
C COMPUTATIONS WHEREAS ISOR=3 AND IORD=3 3D ORDER SCHEME; IDIV=1 ACTIVATES
C CORRECTION FOR DIVERGENT FLOW; NONOS=1 STRICTLY MONOTONE ADVECTION
C N O T E: idiv MUST be 0 for a nondivergent flow
C A GOOD POINT TO START WOULD BE:
C PARAMETER(IORD0=2,ISOR0=1,IDIV0=0,NONO=0)
C IFL IS THE FLAG TO DISTINGUISH BETWEEN FIELDS THAT ARE BEING ADVECTED;
C THAT IS NECESSARY TO PROVIDE LATERAL BOUNDARY CONDITIONS ON INLFOW
C AND LOWER BC FOR SEDIMENTING FIELDS
C!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
C ** NOTE THAT THIS ROUTINE WILL WORK FOR FIELD WITH VARIABLE SIGN **
C ** (AS MOMENTUM) SINCE ABSOLUTE VALUES ARE USE IN THE DEFINITION **
C ** OF ANTIDIFFUSIVE VELOCITIES **
C!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
C AUTHOR: Piotr Smolarkiewicz ([email protected]), (303)-497-8972
C modified for this test by Wojciech Grabowski ([email protected])
C*************************************************************************
PARAMETER(N1=76,N2=76)
PARAMETER(N1M=N1-1,N2M=N2-1)
DIMENSION U1(N+1,M),U2(N,M+1),X(N,M),H(N,M)
DIMENSION V1(N1,N2M),V2(N1M,N2),F1(N1,N2M),F2(N1M,N2)
* ,CP(N1M,N2M),CN(N1M,N2M)
REAL MX(N1M,N2M),MN(N1M,N2M)
DATA EP/1.E-10/
C
ccc for use NOT on a CRAY computer you have to replace CVMGM
ccc with a substitute which gives the same result: below is
ccc an example of something that will work:
ccc CVMGM(a,b,c)= a if c.lt.0 or b if c.ge.0
aneg(d)=.5*(1.-sign(1.,d))
apos(d)=.5*(1.+sign(1.,d))
cvmgm(a,b,c)=aneg(c)*a + apos(c)*b
ccc
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)
C
cc test dimensions:
if(n1m.ne.n.or.n2m.ne.m) then
print*,' dimensions do not match in advection. stop'
stop 'mpdata'
endif
IF(ISOR.EQ.3) IORD=MAX0(IORD,3)
C
DO 1 J=1,N2-1
DO 1 I=1,N1
1 V1(I,J)=U1(I,J)
DO 2 J=1,N2
DO 2 I=1,N1-1
2 V2(I,J)=U2(I,J)
C
IF(NONOS.EQ.1) THEN
DO 400 J=2,N2-2
DO 400 I=2,N1-2
MX(I,J)=AMAX1(X(I-1,J),X(I,J),X(I+1,J),X(I,J-1),X(I,J+1))
400 MN(I,J)=AMIN1(X(I-1,J),X(I,J),X(I+1,J),X(I,J-1),X(I,J+1))
ENDIF
C
DO 3 K=1,IORD
C
DO 337 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))
if(k.eq.1) then
F1( 1,J)=DONOR(X(N1-1,J),X(1,J),V1(1,J))
F1(N1,J)=DONOR(X(N1-1,J),X(1,J),V1(N1,J))
else
F1( 1,J)=0.
F1(N1,J)=0.
endif
337 continue
DO 338 I=1,N1-1
DO 332 J=2,N2-1
332 F2(I,J)=DONOR(X(I,J-1),X(I,J),V2(I,J))
if(k.eq.1.and.ifl.eq.4) then
F2(I, 1)=DONOR(0.,X(I,1),V2(I,1)) ! fallout of rain
F2(I,N2)=0. ! no fall-in of rain
else
F2(I, 1)=0.
F2(I,N2)=0.
endif
338 continue
C
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)
C
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),V1(I,J),.5*(H(I-1,J)+H(I,J)))
* +VCORR(V1(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),V2(I,J),.5*(H(I,J-1)+H(I,J)))
* +VCORR(V2(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)))
IF(IDIV.EQ.1) THEN
DO 521 J=2,N2-1
DO 521 I=2,N1-2
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 62 J=2,N2-2
DO 62 I=3,N1-2
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=2,N1-2
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)))
ENDIF
C
C
IF(NONOS.EQ.0) GO TO 3
C NON-OSSCILATORY OPTION
DO 401 J=2,N2-2
DO 401 I=2,N1-2
MX(I,J)=AMAX1(X(I-1,J),X(I,J),X(I+1,J),X(I,J-1),X(I,J+1),MX(I,J))
401 MN(I,J)=AMIN1(X(I-1,J),X(I,J),X(I+1,J),X(I,J-1),X(I,J+1),MN(I,J))
C
DO 402 J=2,N2-2
DO 402 I=2,N1-1
402 F1(I,J)=DONOR(X(I-1,J),X(I,J),V1(I,J))
DO 403 J=2,N2-1
DO 403 I=2,N1-2
403 F2(I,J)=DONOR(X(I,J-1),X(I,J),V2(I,J))
DO 404 J=2,N2-2
DO 404 I=2,N1-2
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=3,N2-2
DO 405 I=3,N1-2
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 ))) )
405 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 )))