-
Notifications
You must be signed in to change notification settings - Fork 4
/
snowtran_code.f
3629 lines (3033 loc) · 115 KB
/
snowtran_code.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
c snowtran_code.f
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccc Snow-Transport Modeling System - 3D (SnowTran-3D) cccccc
ccccc Copyright (C) 1998 cccccc
ccccc by Glen E. Liston, InterWorks Consulting cccccc
ccccc All Rights Reserved cccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c This FORTRAN code receives inputs of wind speed, wind direction,
c air temperature, relative humidity, vegetation type, topography,
c and precipitation, and it outputs snow depth, saltation flux,
c suspended flux, sublimation of blowing snow, and the snow depth
c changes resulting from these processes.
c
c All units are in m, kg, s, K.
c
c This model is described in the paper:
c A Snow-Transport Model for Complex Terrain, by Glen E. Liston
c and Matthew Sturm, Journal of Glaciology, 1998, Vol. 44,
c No. 148, pages 498-516.
c
c The author of this code is:
c Dr. Glen E. Liston
c InterWorks Consulting
c 15621 SnowMan Road
c Loveland, Colorado 80538
c
c To run in 2-D mode, set nx = 3 and look at the data at i = 2.
c This is required because of the boundary conditions imposed
c along i = 1 and 3.
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine SNOWTRAN_CODE(bc_flag,bs_flag,C_z,
& conc_salt,deltax,deltay,dh_salt,dh_salt_u,dh_salt_v,
& dh_susp,dh_susp_u,dh_susp_v,dt,dz_susp,fall_vel,fetch,
& gravity,h_const,h_star,ht_rhobs,ht_windobs,index_ue,
& index_uw,index_vn,index_vs,iter,nx,ny,pi,Qsalt,Qsalt_max,
& Qsalt_maxu,Qsalt_maxv,Qsalt_u,Qsalt_v,Qsubl,Qsusp,
& Qsusp_u,Qsusp_v,rh_grid,ro_air,ro_snow,ro_water,snow_d,
& snow_d_init,snow_z0,soft_snow_d,sprec,sum_glacmelt,
& subgrid_flag,wbal_salt,wbal_susp,wbal_qsubl,sum_sprec,
& tabler_ee,tabler_ne,tabler_nn,tabler_nw,tabler_se,
& tabler_ss,tabler_sw,tabler_ww,tair_grid,topo,topo_land,
& topoflag,tp_scale,twolayer_flag,Up_const,Ur_const,Utau,
& Utau_t,uwind_grid,veg_z0,vegsnowd_xy,vegtype,vonKarman,
& vwind_grid,wind_min,winddir_flag,winddir_grid,
& windspd_flag,windspd_grid,xmu,z_0,ztop_susp,erosion_dist,
& run_enbal,run_snowpack,wbal_subgrid,sum_qsubl,sum_trans,
& swe_depth,snow_depth,ro_snow_grid,sum_prec,sum_runoff,
& sum_Qcs,canopy_int,w_balance,sum_sfcsublim,tabler_dir,
& slope_adjust,Utau_t_const,Utau_t_flag,ro_soft_snow_old,
& ro_soft_snow,ro_nsnow,prec,Qcs,runoff,d_canopy_int,
& glacier_melt,swe_depth_old,swesublim,canopy_unload,
& canopy_int_old,iter_start,multilayer_snowpack,swe_lyr,
& JJ,dy_snow,ro_layer,curve_lg_scale_flag,curve_wt_lg,
& seaice_run,seaice_conc,tslsnowfall,T_old,tsls_threshold)
implicit none
include 'snowmodel.inc'
integer iter,nx,ny,i,j,iter_start
real ro_snow,ro_water,ro_air,gravity,vonKarman,snow_z0
real deltax,deltay,dt
real fetch,xmu,C_z,h_const,wind_min,windspd_flag
real Up_const,dz_susp,ztop_susp,fall_vel,Ur_const
real Utau_t_const,pi,bc_flag,topoflag,Utau_t_flag
real ht_windobs,ht_rhobs,bs_flag,twolayer_flag
real subgrid_flag,tp_scale,winddir_flag,erosion_dist
real run_enbal,run_snowpack,tabler_dir,slope_adjust
real topo_land(nx_max,ny_max)
real tabler_nn(nx_max,ny_max)
real tabler_ss(nx_max,ny_max)
real tabler_ee(nx_max,ny_max)
real tabler_ww(nx_max,ny_max)
real tabler_ne(nx_max,ny_max)
real tabler_se(nx_max,ny_max)
real tabler_sw(nx_max,ny_max)
real tabler_nw(nx_max,ny_max)
real topo(nx_max,ny_max)
real vegtype(nx_max,ny_max)
real tabler_nn_orig(nx_max,ny_max)
real tabler_ss_orig(nx_max,ny_max)
real tabler_ee_orig(nx_max,ny_max)
real tabler_ww_orig(nx_max,ny_max)
real tabler_ne_orig(nx_max,ny_max)
real tabler_se_orig(nx_max,ny_max)
real tabler_sw_orig(nx_max,ny_max)
real tabler_nw_orig(nx_max,ny_max)
real snow_d_tabler(nx_max,ny_max)
real topo_tmp(nx_max,ny_max)
real uwind_grid(nx_max,ny_max),vwind_grid(nx_max,ny_max)
real windspd_grid(nx_max,ny_max),winddir_grid(nx_max,ny_max)
real tair_grid(nx_max,ny_max),sprec(nx_max,ny_max)
real rh_grid(nx_max,ny_max)
integer index_ue(ny_max,2*nx_max+1),index_uw(ny_max,2*nx_max+1)
integer index_vn(nx_max,2*ny_max+1),index_vs(nx_max,2*ny_max+1)
real snow_d(nx_max,ny_max)
real snow_depth(nx_max,ny_max)
real swe_depth(nx_max,ny_max)
real ro_snow_grid(nx_max,ny_max)
real ro_soft_snow(nx_max,ny_max)
real ro_soft_snow_old(nx_max,ny_max)
real ro_nsnow(nx_max,ny_max)
real snow_d_init(nx_max,ny_max)
real Utau(nx_max,ny_max)
real Utau_t(nx_max,ny_max)
real z_0(nx_max,ny_max)
real h_star(nx_max,ny_max)
real conc_salt(nx_max,ny_max)
real Qsalt_max(nx_max,ny_max)
real Qsalt_maxu(nx_max,ny_max),Qsalt_maxv(nx_max,ny_max)
real Qsalt(nx_max,ny_max)
real Qsalt_u(nx_max,ny_max),Qsalt_v(nx_max,ny_max)
real dh_salt(nx_max,ny_max)
real dh_salt_u(nx_max,ny_max),dh_salt_v(nx_max,ny_max)
real Qsusp(nx_max,ny_max)
real Qsusp_u(nx_max,ny_max),Qsusp_v(nx_max,ny_max)
real dh_susp(nx_max,ny_max)
real dh_susp_u(nx_max,ny_max),dh_susp_v(nx_max,ny_max)
real dh_subgrid(nx_max,ny_max)
real Qsubl(nx_max,ny_max)
real sum_sprec(nx_max,ny_max)
real wbal_qsubl(nx_max,ny_max)
real wbal_salt(nx_max,ny_max)
real wbal_susp(nx_max,ny_max)
real wbal_subgrid(nx_max,ny_max)
real sum_qsubl(nx_max,ny_max)
real sum_trans(nx_max,ny_max)
real soft_snow_d(nx_max,ny_max)
real prec(nx_max,ny_max)
real Qcs(nx_max,ny_max)
real runoff(nx_max,ny_max)
real d_canopy_int(nx_max,ny_max)
real glacier_melt(nx_max,ny_max)
real swe_depth_old(nx_max,ny_max)
real swesublim(nx_max,ny_max)
real canopy_unload(nx_max,ny_max)
real canopy_int_old(nx_max,ny_max)
real vegsnowd_xy(nx_max,ny_max)
real veg_z0(nx_max,ny_max)
real sum_glacmelt(nx_max,ny_max),w_balance(nx_max,ny_max),
& sum_prec(nx_max,ny_max),sum_runoff(nx_max,ny_max),
& sum_Qcs(nx_max,ny_max),canopy_int(nx_max,ny_max),
& sum_sfcsublim(nx_max,ny_max)
integer multilayer_snowpack,k
integer JJ(nx_max,ny_max)
real swe_change_tmp,swe_change,tsls_threshold
real swe_lyr_z(nz_max)
real swe_lyr(nx_max,ny_max,nz_max)
real dy_snow(nx_max,ny_max,nz_max)
real ro_layer(nx_max,ny_max,nz_max)
real T_old(nx_max,ny_max,nz_max)
real tslsnowfall(nx_max,ny_max)
real curve_lg_scale_flag
real curve_wt_lg(nx_max,ny_max)
real seaice_run
real seaice_conc(nx_max,ny_max)
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
c Perform some intialization steps that are unique to SnowTran-3D.
if (iter.eq.iter_start) then
print *,
& 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'
print *,
& 'c Snow-Transport Modeling System - 3D (SnowTran-3D) c'
print *,
& 'c Copyright (C) 1998 c'
print *,
& 'c by Glen E. Liston, InterWorks Consulting c'
print *,
& 'c All Rights Reserved c'
print *,
& 'cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'
if (subgrid_flag.eq.1.0) then
c Check to make sure topoflag = 0.0.
if (topoflag.eq.1.0) then
print *,'If subgrid_flag=1.0, then topoflag must = 0.0'
print *,' Correct this in snowmodel.par to continue.'
stop
endif
c The Tabler surfaces were originally developed assuming the grid
c increment would never be less than 1.0 m. You probably should
c not run it with deltax and deltay less than 1.0 without some
c further testing.
if (deltax.lt.1.0 .or. deltay.lt.1.0) then
print *,'The Tabler subgrid algorithm has not been'
print *,'tested for deltax and/or deltay less than'
print *,'1.0 m. You should probably do some testing'
print *,'before running the model at less than 1.0-m'
print *,'resolution. Acually I am pretty sure it will'
print *,'run, but it will not generate the correct'
print *,'snow-depth profiles.'
stop
endif
c If this is the first time through, generate the Tabler snow
c accumulation surfaces for the land topography.
call tabler_3d(nx,ny,topo_land,deltax,deltay,
& tabler_ww_orig,tabler_ee_orig,tabler_ss_orig,
& tabler_nn_orig,erosion_dist,tabler_ne_orig,
& tabler_se_orig,tabler_sw_orig,tabler_nw_orig,
& slope_adjust)
c As part of generating the Tabler surfaces, a -8888.0 has been
c used to identify the areas immediately upwind of any Tabler
c drift trap that is an erosion area where no snow is allowed
c to accumulate (see 'erosion_dist' in snowmodel.par). Now
c take those areas and set them equal to the snow-holding depth
c to keep the snow relatively thin in those areas.
do i=1,nx
do j=1,ny
tabler_nn_orig(i,j) =
& max(tabler_nn_orig(i,j),vegsnowd_xy(i,j))
tabler_ne_orig(i,j) =
& max(tabler_ne_orig(i,j),vegsnowd_xy(i,j))
tabler_ee_orig(i,j) =
& max(tabler_ee_orig(i,j),vegsnowd_xy(i,j))
tabler_se_orig(i,j) =
& max(tabler_se_orig(i,j),vegsnowd_xy(i,j))
tabler_ss_orig(i,j) =
& max(tabler_ss_orig(i,j),vegsnowd_xy(i,j))
tabler_sw_orig(i,j) =
& max(tabler_sw_orig(i,j),vegsnowd_xy(i,j))
tabler_ww_orig(i,j) =
& max(tabler_ww_orig(i,j),vegsnowd_xy(i,j))
tabler_nw_orig(i,j) =
& max(tabler_nw_orig(i,j),vegsnowd_xy(i,j))
enddo
enddo
c If you don't want to write out these distributions, comment out
c the following lines.
open(51,file='outputs/tabler_sfcs.gdat',
& form='unformatted',access='direct',recl=4*nx*ny)
write(51,rec=1) ((tabler_ww_orig(i,j),i=1,nx),j=1,ny)
write(51,rec=2) ((tabler_ee_orig(i,j),i=1,nx),j=1,ny)
write(51,rec=3) ((tabler_ss_orig(i,j),i=1,nx),j=1,ny)
write(51,rec=4) ((tabler_nn_orig(i,j),i=1,nx),j=1,ny)
write(51,rec=5) ((tabler_ne_orig(i,j),i=1,nx),j=1,ny)
write(51,rec=6) ((tabler_se_orig(i,j),i=1,nx),j=1,ny)
write(51,rec=7) ((tabler_sw_orig(i,j),i=1,nx),j=1,ny)
write(51,rec=8) ((tabler_nw_orig(i,j),i=1,nx),j=1,ny)
write(51,rec=9) ((topo_land(i,j),i=1,nx),j=1,ny)
close (51)
c This available if you want to save a specific Tabler surface at
c each time step.
c open(52,file='outputs/tabler_sfcs_iter.gdat',
c & form='unformatted',access='direct',recl=4*nx*ny)
endif
endif
c Print out some basic run information to the screen.
print 102, windspd_flag,winddir_flag
102 format(25x,' wind spd = ',f5.2,' wind dir = ',f4.0)
if (subgrid_flag.eq.1.0) then
c Generate the tabler surfaces at this time step, assuming the
c snow surface is the topographic surface.
c Take the snow depth coming out of SnowPack, and before any wind
c redistribution has been applied at this time step, and add it
c to topo_land. Then use this to create the Tabler surface that
c will be used for this time step. Also define this depth to be
c dependent on the SnowPack spatially distributed snow density,
c not the constant density used in SnowTran.
do i=1,nx
do j=1,ny
snow_d_tabler(i,j) = swe_depth(i,j) *
& ro_water / ro_snow_grid(i,j)
topo_tmp(i,j) = tp_scale * snow_d_tabler(i,j) +
& topo_land(i,j)
enddo
enddo
call tabler_3d(nx,ny,topo_tmp,deltax,deltay,
& tabler_ww_orig,tabler_ee_orig,tabler_ss_orig,
& tabler_nn_orig,erosion_dist,tabler_ne_orig,
& tabler_se_orig,tabler_sw_orig,tabler_nw_orig,
& slope_adjust)
c The Tabler surfaces that were just generated have had topo_tmp
c subtracted off of them, giving just the drift profiles with
c things like zero drift depth on ridges and windwards slopes.
c So, add the snow depth, prior to any wind redistribution, to
c these Tabler surfaces. This will be the maximum snow depth
c allowed as part of the wind redistribution.
do i=1,nx
do j=1,ny
tabler_ww(i,j) = tp_scale * snow_d_tabler(i,j) +
& tabler_ww_orig(i,j)
tabler_ee(i,j) = tp_scale * snow_d_tabler(i,j) +
& tabler_ee_orig(i,j)
tabler_ss(i,j) = tp_scale * snow_d_tabler(i,j) +
& tabler_ss_orig(i,j)
tabler_nn(i,j) = tp_scale * snow_d_tabler(i,j) +
& tabler_nn_orig(i,j)
tabler_ne(i,j) = tp_scale * snow_d_tabler(i,j) +
& tabler_ne_orig(i,j)
tabler_se(i,j) = tp_scale * snow_d_tabler(i,j) +
& tabler_se_orig(i,j)
tabler_sw(i,j) = tp_scale * snow_d_tabler(i,j) +
& tabler_sw_orig(i,j)
tabler_nw(i,j) = tp_scale * snow_d_tabler(i,j) +
& tabler_nw_orig(i,j)
enddo
enddo
c As part of generating the Tabler surfaces, a -8888.0 has been
c used to identify the areas immediately upwind of any Tabler
c drift trap that is an erosion area where no snow is allowed
c to accumulate (see 'erosion_dist' in snowmodel.par). Now
c take those areas and set them equal to the snow-holding depth
c to keep the snow relatively thin in those areas.
do i=1,nx
do j=1,ny
tabler_nn(i,j) = max(tabler_nn(i,j),vegsnowd_xy(i,j))
tabler_ne(i,j) = max(tabler_ne(i,j),vegsnowd_xy(i,j))
tabler_ee(i,j) = max(tabler_ee(i,j),vegsnowd_xy(i,j))
tabler_se(i,j) = max(tabler_se(i,j),vegsnowd_xy(i,j))
tabler_ss(i,j) = max(tabler_ss(i,j),vegsnowd_xy(i,j))
tabler_sw(i,j) = max(tabler_sw(i,j),vegsnowd_xy(i,j))
tabler_ww(i,j) = max(tabler_ww(i,j),vegsnowd_xy(i,j))
tabler_nw(i,j) = max(tabler_nw(i,j),vegsnowd_xy(i,j))
enddo
enddo
c The following saves the calculated Tabler surface at each time
c step. You can comment this out if you don't want to write
c them out.
c if (tabler_dir.eq.0.0) then
c write(52,rec=iter) ((tabler_nn(i,j),i=1,nx),j=1,ny)
c elseif (tabler_dir.eq.45.0) then
c write(52,rec=iter) ((tabler_ne(i,j),i=1,nx),j=1,ny)
c elseif (tabler_dir.eq.90.0) then
c write(52,rec=iter) ((tabler_ee(i,j),i=1,nx),j=1,ny)
c elseif (tabler_dir.eq.135.0) then
c write(52,rec=iter) ((tabler_se(i,j),i=1,nx),j=1,ny)
c elseif (tabler_dir.eq.180.0) then
c write(52,rec=iter) ((tabler_ss(i,j),i=1,nx),j=1,ny)
c elseif (tabler_dir.eq.225.0) then
c write(52,rec=iter) ((tabler_sw(i,j),i=1,nx),j=1,ny)
c elseif (tabler_dir.eq.270.0) then
c write(52,rec=iter) ((tabler_ww(i,j),i=1,nx),j=1,ny)
c elseif (tabler_dir.eq.315.0) then
c write(52,rec=iter) ((tabler_nw(i,j),i=1,nx),j=1,ny)
c endif
endif
c In SnowTran-3D, the summed snow precipitation must be in units
c of snow-depth. The rest of the routines assume that it is in
c swe units.
do j=1,ny
do i=1,nx
sum_sprec(i,j) = sum_sprec(i,j) * ro_water / ro_snow
enddo
enddo
c If running EnBal and SnowPack, then don't need to run these
c two routines.
if (run_enbal.ne.1.0 .and. run_snowpack.ne.1.0) then
print *,'I am not sure you can configure the model like'
print *,'this anymore. You may need to always run'
print *,'SnowTran-3D with SnowPack now.'
stop
c Add the new precipitation to the snowpack.
call precip(snow_d,sprec,nx,ny,ro_snow,
& ro_water,sum_sprec,soft_snow_d,sum_prec)
c If the two-layer scheme is turned on, update the thicknesses
c of the hard and soft layers.
if (twolayer_flag.eq.1.0) then
call twolayer1(nx,ny,soft_snow_d,tair_grid)
endif
endif
c Update the threshold friction velocity.
if (Utau_t_flag.eq.0.0) then
if (curve_lg_scale_flag.eq.1.0) then
do j=1,ny
do i=1,nx
Utau_t(i,j) = curve_wt_lg(i,j) * Utau_t_const
enddo
enddo
else
do j=1,ny
do i=1,nx
Utau_t(i,j) = Utau_t_const
enddo
enddo
endif
elseif (Utau_t_flag.eq.1.0) then
do j=1,ny
do i=1,nx
call surface_snow_1(tair_grid(i,j),windspd_grid(i,j),
& sprec(i,j),ro_soft_snow(i,j),Utau_t(i,j),
& ro_soft_snow_old(i,j),dt,snow_z0,ht_windobs,
& ro_nsnow(i,j))
enddo
enddo
if (curve_lg_scale_flag.eq.1.0) then
do j=1,ny
do i=1,nx
Utau_t(i,j) = curve_wt_lg(i,j) * Utau_t(i,j)
enddo
enddo
endif
endif
c Set the blowing snow flag to zero until it is clear that we will
c have blowing snow.
bs_flag = 0.0
c If the wind speed is lower that some threshold, then don't
c need to to any of the snow transport computations.
if (windspd_flag.ge.wind_min) then
c Get the wind direction indexing arrays for this particular
c wind event (time step).
call getdirection(nx,ny,uwind_grid,vwind_grid,index_ue,
& index_uw,index_vn,index_vs)
c Solve for Utau and z_0 if snow is saltating, else solve assuming
c z_0 is known from snow depth and/or veg type, and solve for
c Utau.
call solveUtau(Utau,ht_windobs,windspd_grid,C_z,vonKarman,
& gravity,z_0,h_star,h_const,vegsnowd_xy,snow_d,
& snow_z0,veg_z0,bs_flag,nx,ny,Utau_t,soft_snow_d)
c If the blowing snow flag indicates wind transported snow
c somewhere within the domain (bs_flag = 1.0), run the saltation
c and suspension models.
if (bs_flag.eq.1.0) then
c Solve for the saltation flux.
print *,' Saltation'
call saltation(Qsalt,deltax,fetch,Utau,Utau_t,nx,ny,
& ro_air,gravity,vegsnowd_xy,snow_d,
& Qsalt_max,Qsalt_maxu,Qsalt_maxv,deltay,Qsalt_u,Qsalt_v,
& index_ue,index_uw,index_vn,index_vs,uwind_grid,
& vwind_grid,xmu,soft_snow_d,bc_flag)
c Solve for the suspension flux.
print *,' Suspension'
call suspension(Utau,vonKarman,nx,ny,conc_salt,
& Qsalt,Qsusp,z_0,h_star,dz_susp,ztop_susp,pi,
& fall_vel,Ur_const,Up_const,Utau_t,Qsubl,ht_rhobs,
& tair_grid,rh_grid,Qsusp_u,Qsusp_v,uwind_grid,
& vwind_grid)
elseif (bs_flag.eq.0.0) then
call noblowsnow(nx,ny,Qsalt_max,Qsalt_maxu,
& Qsalt_maxv,Qsalt,Qsalt_u,Qsalt_v,dh_salt,dh_salt_u,
& dh_salt_v,conc_salt,Qsusp,Qsusp_u,Qsusp_v,dh_susp,
& dh_susp_u,dh_susp_v,Qsubl,dh_subgrid)
endif
else
c This 'noblowsnow' call zeros out data from a previous time step
c that had blowing snow.
call noblowsnow(nx,ny,Qsalt_max,Qsalt_maxu,
& Qsalt_maxv,Qsalt,Qsalt_u,Qsalt_v,dh_salt,dh_salt_u,
& dh_salt_v,conc_salt,Qsusp,Qsusp_u,Qsusp_v,dh_susp,
& dh_susp_u,dh_susp_v,Qsubl,dh_subgrid)
endif
c Compute the new snow depth due to accumulation from precipitation,
c saltation, and suspension, and the mass loss due to
c sublimation.
call accum(snow_d,nx,ny,ro_snow,dt,ro_water,
& deltax,deltay,vegtype,vegsnowd_xy,
& index_ue,index_uw,index_vn,index_vs,
& Qsalt_u,Qsalt_v,Qsusp_u,Qsusp_v,Qsubl,dh_salt,
& dh_salt_u,dh_salt_v,dh_susp,dh_susp_u,dh_susp_v,
& wbal_qsubl,wbal_salt,wbal_susp,bs_flag,
& soft_snow_d,topo,topo_land,topoflag,subgrid_flag,
& winddir_grid,tabler_nn,tabler_ss,tabler_ee,tabler_ww,
& tabler_ne,tabler_se,tabler_sw,tabler_nw,
& uwind_grid,vwind_grid,wbal_subgrid,sum_qsubl,
& sum_trans,swe_depth,snow_depth,ro_snow_grid,
& dh_subgrid,tabler_dir)
c Use the changes in swe due to saltation, suspension, and
c blowing snow sublimation to adjust the multilayer snowpack
c layers.
if (multilayer_snowpack.eq.1) then
do j=1,ny
do i=1,nx
swe_change = wbal_qsubl(i,j) + wbal_salt(i,j) +
& wbal_susp(i,j) + wbal_subgrid(i,j)
c Net mass loss for this grid cell at this time step.
if (swe_change.lt.0.0) then
swe_change_tmp = -swe_change
c Extract the vertical column for this i,j point, and send it
c to the subroutine. *** Note that I should use f95, then I would
c not have to do this (I could pass in subsections of the arrays).
do k=1,nz_max
swe_lyr_z(k) = swe_lyr(i,j,k)
enddo
c Check to see whether a layer reduction is required.
CALL REDUCE_LAYERS(swe_change_tmp,swe_lyr_z,JJ(i,j))
c Re-build the 3-D array. See note above about using f95 to avoid this.
do k=1,nz_max
swe_lyr(i,j,k) = swe_lyr_z(k)
enddo
c Update the snow layer thicknesses, and recalculate the total
c snow and swe depths. Assume this swe change does not change
c the snow density and does not change the soft snow depth. It
c only reduces the snow depth and the associated swe depth.
snow_depth(i,j) = 0.0
swe_depth(i,j) = 0.0
do k=1,JJ(i,j)
dy_snow(i,j,k) = swe_lyr(i,j,k) * ro_water /
& ro_layer(i,j,k)
c ro_layer(i,j,k) = ro_layer(i,j,k)
snow_depth(i,j) = snow_depth(i,j) + dy_snow(i,j,k)
swe_depth(i,j) = swe_depth(i,j) + swe_lyr(i,j,k)
enddo
c Net mass gain for this grid cell at this time step.
elseif (swe_change.gt.0.0) then
c Add to the existing top layer.
swe_lyr(i,j,JJ(i,j)) = swe_lyr(i,j,JJ(i,j)) +
& swe_change
c ro_layer(i,j,k) = ro_layer(i,j,k)
dy_snow(i,j,JJ(i,j)) = swe_lyr(i,j,JJ(i,j)) *
& ro_water / ro_layer(i,j,JJ(i,j))
c Update the snow layer thicknesses, and recalculate the total
c snow and swe depths. Assume this swe change does not change
c the snow density and does not change the soft snow depth. It
c only reduces the snow depth and the associated swe depth.
snow_depth(i,j) = 0.0
swe_depth(i,j) = 0.0
do k=1,JJ(i,j)
snow_depth(i,j) = snow_depth(i,j) + dy_snow(i,j,k)
swe_depth(i,j) = swe_depth(i,j) + swe_lyr(i,j,k)
enddo
else
snow_depth(i,j) = 0.0
swe_depth(i,j) = 0.0
do k=1,JJ(i,j)
snow_depth(i,j) = snow_depth(i,j) + dy_snow(i,j,k)
swe_depth(i,j) = swe_depth(i,j) + swe_lyr(i,j,k)
enddo
endif
enddo
enddo
endif
c Perform a water balance check (see notes in this subroutine).
if (seaice_run.eq.0.0) then
call waterbal_snowtran(w_balance,prec,Qcs,
& runoff,d_canopy_int,swe_depth,glacier_melt,iter,
& wbal_qsubl,wbal_salt,wbal_susp,wbal_subgrid,nx,ny,
& swe_depth_old,swesublim,canopy_unload,canopy_int,
& canopy_int_old)
c call waterbal_snowtran_sums(w_balance,sum_prec,sum_Qcs,
c & sum_runoff,canopy_int,swe_depth,sum_glacmelt,iter,
c & sum_qsubl,sum_trans,nx,ny,snow_d_init,ro_snow,ro_water,
c & sum_sfcsublim)
endif
c If this is a sea ice run, zero out the ocean grid cells that
c have no sea ice in them.
if (seaice_run.ne.0.0) then
CALL ZERO_SEAICE_SNOW(nx,ny,snow_depth,ro_snow_grid,
& ro_snow,swe_depth,swe_depth_old,canopy_int_old,JJ,
& tslsnowfall,dy_snow,swe_lyr,ro_layer,T_old,
& multilayer_snowpack,tsls_threshold,seaice_conc)
endif
c Save the mass balance variables from this time step.
do j=1,ny
do i=1,nx
swe_depth_old(i,j) = swe_depth(i,j)
canopy_int_old(i,j) = canopy_int(i,j)
enddo
enddo
c In SnowTran-3D, the summed snow precipitation were in units
c of snow-depth. The rest of the routines assume that it is in
c swe units.
do j=1,ny
do i=1,nx
sum_sprec(i,j) = sum_sprec(i,j) * ro_snow / ro_water
enddo
enddo
return
end
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine waterbal_snowtran(w_balance,prec,Qcs,
& runoff,d_canopy_int,swe_depth,glacier_melt,iter,
& wbal_qsubl,wbal_salt,wbal_susp,wbal_subgrid,nx,ny,
& swe_depth_old,swesublim,canopy_unload,canopy_int,
& canopy_int_old)
implicit none
include 'snowmodel.inc'
integer iter,nx,ny,i,j
real w_balance(nx_max,ny_max),prec(nx_max,ny_max),
& Qcs(nx_max,ny_max),runoff(nx_max,ny_max),
& d_canopy_int(nx_max,ny_max),swe_depth(nx_max,ny_max),
& glacier_melt(nx_max,ny_max),wbal_qsubl(nx_max,ny_max),
& wbal_salt(nx_max,ny_max),swe_depth_old(nx_max,ny_max),
& swesublim(nx_max,ny_max),wbal_susp(nx_max,ny_max),
& wbal_subgrid(nx_max,ny_max),canopy_unload(nx_max,ny_max),
& canopy_int_old(nx_max,ny_max),canopy_int(nx_max,ny_max)
c Note that the following balances should hold. These aren't quite
c right, but it is a place to start.
c Canopy Balance (forest):
c canopy = sprec - unload + Qcs ==> unload = sprec - canopy + Qcs
c
c Snowpack Balance (forest):
c swe_d = unload + rain - runoff ==>
c canopy + swe_d = sprec + rain + Qcs - runoff
c prec = sprec + rain
c sum_rain = sum_sprec - sum_prec
c
c Snowpack Balance (non-forest):
c swe_d = sprec + rain - runoff + subl + salt + susp + subgrid +
c glaciermelt
c
c Everywhere:
c w_balance = sum_prec + sum_Qcs - sum_runoff + sum_subl +
c sum_trans - canopy_int - swe_depth + sum_glacmelt
c
c The related variables that would need to be brought in are:
c d_canopy_int,sum_d_canopy_int,sum_unload
c The subroutine WATERBAL_SNOWTRAN is used if the model simulation
c includes SnowTran-3D.
do j=1,ny
do i=1,nx
w_balance(i,j) = swe_depth_old(i,j) - swe_depth(i,j) +
& prec(i,j) - runoff(i,j) + glacier_melt(i,j) +
& wbal_qsubl(i,j) + wbal_salt(i,j) + wbal_susp(i,j) +
& wbal_subgrid(i,j) - swesublim(i,j) + canopy_int_old(i,j) -
& canopy_int(i,j) + Qcs(i,j)
if (abs(w_balance(i,j)).gt.1.0e-5)
& print*,'water imbalance at iter =',iter,' ',w_balance(i,j)
enddo
enddo
return
end
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine waterbal_snowtran_sums(w_balance,sum_prec,sum_Qcs,
& sum_runoff,canopy_int,swe_depth,sum_glacmelt,iter,
& sum_qsubl,sum_trans,nx,ny,snow_d_init,ro_snow,ro_water,
& sum_sfcsublim)
implicit none
include 'snowmodel.inc'
integer iter,nx,ny,i,j
real w_balance(nx_max,ny_max),sum_prec(nx_max,ny_max),
& sum_Qcs(nx_max,ny_max),sum_runoff(nx_max,ny_max),
& canopy_int(nx_max,ny_max),swe_depth(nx_max,ny_max),
& sum_glacmelt(nx_max,ny_max),sum_qsubl(nx_max,ny_max),
& sum_trans(nx_max,ny_max),snow_d_init(nx_max,ny_max),
& sum_sfcsublim(nx_max,ny_max)
real ro_snow,ro_water
c Note that the following balances should hold. These aren't quite
c right, but it is a place to start.
c Canopy Balance (forest):
c canopy = sprec - unload + Qcs ==> unload = sprec - canopy + Qcs
c
c Snowpack Balance (forest):
c swe_d = unload + rain - runoff ==>
c canopy + swe_d = sprec + rain + Qcs - runoff
c prec = sprec + rain
c sum_rain = sum_sprec - sum_prec
c
c Snowpack Balance (non-forest):
c swe_d = sprec + rain - runoff + subl + salt + susp + subgrid +
c glaciermelt
c
c Everywhere:
c w_balance = sum_prec + sum_Qcs - sum_runoff + sum_subl +
c sum_trans - canopy_int - swe_depth + sum_glacmelt
c
c The related variables that would need to be brought in are:
c d_canopy_int,sum_d_canopy_int,sum_unload
c The subroutine WATERBAL_SNOWTRAN is used if the model simulation
c includes SnowTran-3D.
do j=1,ny
do i=1,nx
w_balance(i,j) = sum_prec(i,j) + sum_Qcs(i,j) -
& sum_runoff(i,j) - canopy_int(i,j) - swe_depth(i,j) +
& sum_glacmelt(i,j) + sum_qsubl(i,j) + sum_trans(i,j) +
& snow_d_init(i,j) * ro_snow/ro_water -
& sum_sfcsublim(i,j)
if (abs(w_balance(i,j)).gt.1.0e-4)
& print*,'water imbalance at iter =',iter,' ',w_balance(i,j)
enddo
enddo
return
end
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine noblowsnow(nx,ny,Qsalt_max,Qsalt_maxu,
& Qsalt_maxv,Qsalt,Qsalt_u,Qsalt_v,dh_salt,dh_salt_u,
& dh_salt_v,conc_salt,Qsusp,Qsusp_u,Qsusp_v,dh_susp,
& dh_susp_u,dh_susp_v,Qsubl,dh_subgrid)
implicit none
include 'snowmodel.inc'
integer nx,ny,i,j
real Qsalt_max(nx_max,ny_max)
real Qsalt_maxu(nx_max,ny_max),Qsalt_maxv(nx_max,ny_max)
real Qsalt(nx_max,ny_max)
real Qsalt_u(nx_max,ny_max),Qsalt_v(nx_max,ny_max)
real dh_salt(nx_max,ny_max)
real dh_salt_u(nx_max,ny_max),dh_salt_v(nx_max,ny_max)
real conc_salt(nx_max,ny_max)
real Qsusp(nx_max,ny_max)
real Qsusp_u(nx_max,ny_max),Qsusp_v(nx_max,ny_max)
real dh_susp(nx_max,ny_max)
real dh_susp_u(nx_max,ny_max),dh_susp_v(nx_max,ny_max)
real dh_subgrid(nx_max,ny_max)
real Qsubl(nx_max,ny_max)
do i=1,nx
do j=1,ny
Qsalt_max(i,j) = 0.0
Qsalt_maxu(i,j) = 0.0
Qsalt_maxv(i,j) = 0.0
Qsalt(i,j) = 0.0
Qsalt_u(i,j) = 0.0
Qsalt_v(i,j) = 0.0
dh_salt(i,j) = 0.0
dh_salt_u(i,j) = 0.0
dh_salt_v(i,j) = 0.0
conc_salt(i,j) = 0.0
Qsusp(i,j) = 0.0
Qsusp_u(i,j) = 0.0
Qsusp_v(i,j) = 0.0
dh_susp(i,j) = 0.0
dh_susp_u(i,j) = 0.0
dh_susp_v(i,j) = 0.0
Qsubl(i,j) = 0.0
dh_subgrid(i,j) = 0.0
enddo
enddo
return
end
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine precip(snow_d,sprec,nx,ny,ro_snow,
& ro_water,sum_sprec,soft_snow_d,sum_prec)
implicit none
include 'snowmodel.inc'
integer i,j,nx,ny
real ro_snow,ro_water
real sprec(nx_max,ny_max)
real snow_d(nx_max,ny_max)
real sum_sprec(nx_max,ny_max)
real soft_snow_d(nx_max,ny_max)
real sum_prec(nx_max,ny_max)
do i=1,nx
do j=1,ny
c Place the new snow in the soft snow layer.
soft_snow_d(i,j) = soft_snow_d(i,j) +
& sprec(i,j) * ro_water / ro_snow
c Update the snow depth resulting from swe precipitation.
snow_d(i,j) = snow_d(i,j) + sprec(i,j) * ro_water / ro_snow
c Sum the precipitation in terms of snow depth.
sum_sprec(i,j) = sum_sprec(i,j) + sprec(i,j) *
& ro_water / ro_snow
c Sum the precipitation in terms of swe.
sum_prec(i,j) = sum_prec(i,j) + sprec(i,j)
enddo
enddo
return
end
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine twolayer1(nx,ny,soft_snow_d,tair_grid)
implicit none
include 'snowmodel.inc'
integer i,j,nx,ny
real tmax,tfreeze
real tair_grid(nx_max,ny_max)
real soft_snow_d(nx_max,ny_max)
c Place the soft snow layer in the hard snow layer if the air
c temperature gets too high.
tmax = 3.0
tfreeze = 273.16
do i=1,nx
do j=1,ny
if (tair_grid(i,j).ge.tfreeze+tmax) soft_snow_d(i,j) = 0.0
enddo
enddo
return
end
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
subroutine accum(snow_d,nx,ny,ro_snow,dt,ro_water,
& deltax,deltay,vegtype,vegsnowd_xy,
& index_ue,index_uw,index_vn,index_vs,
& Qsalt_u,Qsalt_v,Qsusp_u,Qsusp_v,Qsubl,dh_salt,
& dh_salt_u,dh_salt_v,dh_susp,dh_susp_u,dh_susp_v,
& wbal_qsubl,wbal_salt,wbal_susp,bs_flag,
& soft_snow_d,topo,topo_land,topoflag,subgrid_flag,
& winddir_grid,tabler_nn,tabler_ss,tabler_ee,tabler_ww,
& tabler_ne,tabler_se,tabler_sw,tabler_nw,
& uwind_grid,vwind_grid,wbal_subgrid,sum_qsubl,
& sum_trans,swe_depth,snow_depth,ro_snow_grid,
& dh_subgrid,tabler_dir)
implicit none
include 'snowmodel.inc'
integer i,j,nx,ny
real ro_snow,dt,deltax,deltay,bs_flag,topoflag,ro_water
real snowdmin,hard_snow_d,subgrid_flag,tabler_dir
real snow_d(nx_max,ny_max)
real snow_d_tmp(nx_max,ny_max)
real snow_depth(nx_max,ny_max)
real swe_depth(nx_max,ny_max)
real ro_snow_grid(nx_max,ny_max)
real snow_d_tabler(nx_max,ny_max)
real tabler_nn(nx_max,ny_max)
real tabler_ss(nx_max,ny_max)
real tabler_ee(nx_max,ny_max)
real tabler_ww(nx_max,ny_max)
real tabler_ne(nx_max,ny_max)
real tabler_se(nx_max,ny_max)
real tabler_sw(nx_max,ny_max)
real tabler_nw(nx_max,ny_max)
real winddir_grid(nx_max,ny_max)
real uwind_grid(nx_max,ny_max)
real vwind_grid(nx_max,ny_max)
real soft_snow_d(nx_max,ny_max)
real Qsubl(nx_max,ny_max)
real topo(nx_max,ny_max)
real topo_land(nx_max,ny_max)
real dh_salt(nx_max,ny_max)
real dh_salt_u(nx_max,ny_max)
real dh_salt_v(nx_max,ny_max)
real dh_susp(nx_max,ny_max)
real dh_susp_u(nx_max,ny_max)
real dh_susp_v(nx_max,ny_max)
real dh_subgrid(nx_max,ny_max)
real Qsalt_u(nx_max,ny_max)
real Qsalt_v(nx_max,ny_max)
real Qsusp_u(nx_max,ny_max)
real Qsusp_v(nx_max,ny_max)
real wbal_qsubl(nx_max,ny_max)
real wbal_salt(nx_max,ny_max)
real wbal_susp(nx_max,ny_max)
real wbal_subgrid(nx_max,ny_max)
real sum_qsubl(nx_max,ny_max)
real sum_trans(nx_max,ny_max)
real vegtype(nx_max,ny_max)
real vegsnowd_xy(nx_max,ny_max)
integer index_ue(ny_max,2*nx_max+1)
integer index_uw(ny_max,2*nx_max+1)
integer index_vn(nx_max,2*ny_max+1)
integer index_vs(nx_max,2*ny_max+1)
c COMPUTE THE NEW SNOW DEPTH.
c PRECIPITATION
c Account for the addition due to snow precipitation.
c This is now updated at the beginning of the program (day).
c Sum the precipitation in terms of snow depth.
if (bs_flag.eq.1.0) then
c SALTATION
call getnewdepth(nx,ny,deltax,deltay,Qsalt_u,
& Qsalt_v,dh_salt_u,dh_salt_v,index_ue,index_uw,
& index_vn,index_vs,ro_snow,dt,vegsnowd_xy,snow_d,
& soft_snow_d)
do i=1,nx
do j=1,ny
dh_salt(i,j) = dh_salt_u(i,j) + dh_salt_v(i,j)
enddo
enddo
c SUSPENSION
call getnewdepth(nx,ny,deltax,deltay,Qsusp_u,