-
Notifications
You must be signed in to change notification settings - Fork 4
/
snowpack_code.f
2408 lines (1932 loc) · 75.1 KB
/
snowpack_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 snowpack_code.f
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE SNOWPACK_CODE(nx,ny,Tair_grid,rh_grid,ro_nsnow,
& dt,swe_depth,Tsfc,snow_d,prec_grid,runoff,Qm,rain,
& sprec,iter,w_balance,sum_prec,sum_runoff,xro_snow,
& undef,ro_snow,ro_snow_grid,soft_snow_d,sum_sprec,
& snow_depth,windspd_grid,Qsi_grid,sum_Qcs,canopy_int,
& Qcs,vegtype,forest_LAI,albedo,glacier_melt,
& canopy_unload,sum_unload,sum_glacmelt,run_snowtran,
& swemelt,d_canopy_int,sum_d_canopy_int,snow_d_init,
& sfc_pressure,Qe,sfc_sublim_flag,sum_sfcsublim,
& sum_swemelt,corr_factor,icorr_factor_index,swesublim,
& swe_depth_old,canopy_int_old,JJ,max_layers,melt_flag,
& ro_snowmax,tsls_threshold,dz_snow_min,tslsnowfall,
& change_layer,dy_snow,swe_lyr,ro_layer,T_old,gamma,
& multilayer_snowpack,seaice_run,seaice_conc,
& fc_param,t_avg)
implicit none
include 'snowmodel.inc'
integer nx,ny,iter,i,j,max_iter
integer max_layers,multilayer_snowpack,k,n_tsteps_in_day,irec
integer JJ(nx_max,ny_max)
integer melt_flag(nx_max,ny_max,nz_max)
real ro_snowmax,tsls_threshold,dz_snow_min,Cp_snow,
& fc_param,t_avg
real tslsnowfall(nx_max,ny_max)
real change_layer(nx_max,ny_max)
real dy_snow(nx_max,ny_max,nz_max)
real swe_lyr(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 gamma(nx_max,ny_max,nz_max)
real layerFlux(nx_max,ny_max,nz_max)
real ml_ret(nx_max,ny_max,nz_max)
real liqfracml(nx_max,ny_max,nz_max)
real icefracml(nx_max,ny_max,nz_max)
integer melt_flag_z(nz_max)
real dy_snow_z(nz_max)
real swe_lyr_z(nz_max)
real ro_layer_z(nz_max)
real T_old_z(nz_max)
real gamma_z(nz_max)
c real layerFlux_z(nz_max)
real ml_ret_z(nz_max)
c real liqfrac_z(nz_max)
c real icefrac_z(nz_max)
real Tair_grid(nx_max,ny_max)
real rh_grid(nx_max,ny_max)
real prec_grid(nx_max,ny_max)
real windspd_grid(nx_max,ny_max)
real Qsi_grid(nx_max,ny_max)
real vegtype(nx_max,ny_max)
real albedo(nx_max,ny_max)
real glacier_melt(nx_max,ny_max)
real canopy_unload(nx_max,ny_max)
real sum_unload(nx_max,ny_max)
real sum_glacmelt(nx_max,ny_max)
real sum_swemelt(nx_max,ny_max)
real swemelt(nx_max,ny_max)
real swesublim(nx_max,ny_max)
real snow_d_init(nx_max,ny_max)
real swe_depth_old(nx_max,ny_max)
real canopy_int_old(nx_max,ny_max)
real seaice_conc(nx_max,ny_max)
real ro_nsnow(nx_max,ny_max),snow_d(nx_max,ny_max),
& runoff(nx_max,ny_max),rain(nx_max,ny_max),
& sprec(nx_max,ny_max),w_balance(nx_max,ny_max),
& sum_prec(nx_max,ny_max),sum_runoff(nx_max,ny_max),
& xro_snow(nx_max,ny_max),sfc_pressure(nx_max,ny_max),
& ro_snow_grid(nx_max,ny_max),swe_depth(nx_max,ny_max),
& Tsfc(nx_max,ny_max),Qm(nx_max,ny_max),
& soft_snow_d(nx_max,ny_max),sum_sprec(nx_max,ny_max),
& ro_snow,snow_depth(nx_max,ny_max),sum_Qcs(nx_max,ny_max),
& canopy_int(nx_max,ny_max),Qcs(nx_max,ny_max),
& d_canopy_int(nx_max,ny_max),sum_d_canopy_int(nx_max,ny_max),
& Qe(nx_max,ny_max),sum_sfcsublim(nx_max,ny_max)
real dt,undef,Cp,xLf,Tf,A1,A2,ro_water,xLs,ro_ice,Twb,
& run_snowtran,sfc_sublim_flag,seaice_run,Cp_water
real corr_factor(nx_max,ny_max,max_obs_dates+1)
integer icorr_factor_index(max_time_steps)
integer nftypes
parameter (nftypes=5)
real forest_LAI(nftypes)
print *,' solving the snow-cover evolution'
c Define the constants used in the computations.
CALL CONSTS_SNOWPACK(Cp,xLs,ro_ice,xLf,Tf,A1,A2,ro_water,
& Cp_snow,ro_snowmax,Cp_water)
c Run the snowpack evolution sub-model.
do j=1,ny
do i=1,nx
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).
if (multilayer_snowpack.eq.1) then
do k=1,nz_max
melt_flag_z(k) = melt_flag(i,j,k)
dy_snow_z(k) = dy_snow(i,j,k)
swe_lyr_z(k) = swe_lyr(i,j,k)
ro_layer_z(k) = ro_layer(i,j,k)
T_old_z(k) = T_old(i,j,k)
gamma_z(k) = gamma(i,j,k)
c J.PFLUG
c variables for multilayer percolation investigation
c layerFlux_z(k) = layerFlux(i,j,k)
ml_ret_z(k) = ml_ret(i,j,k)
c liqfrac_z(k) = liqfracml(i,j,k)
c icefrac_z(k) = icefracml(i,j,k)
c END J.PFLUG
enddo
endif
CALL SNOWPACK_CORE(Twb,Tf,Tair_grid(i,j),rh_grid(i,j),xLs,
& Cp,sfc_pressure(i,j),ro_nsnow(i,j),dt,ro_snow,
& swe_depth(i,j),Tsfc(i,j),A1,A2,snow_d(i,j),ro_water,
& ro_ice,prec_grid(i,j),runoff(i,j),Qm(i,j),xLf,rain(i,j),
& sprec(i,j),iter,w_balance(i,j),sum_prec(i,j),
& sum_runoff(i,j),xro_snow(i,j),undef,
& soft_snow_d(i,j),sum_sprec(i,j),ro_snow_grid(i,j),
& snow_depth(i,j),windspd_grid(i,j),Qsi_grid(i,j),
& sum_Qcs(i,j),canopy_int(i,j),Qcs(i,j),vegtype(i,j),
& forest_LAI,albedo(i,j),canopy_unload(i,j),
& sum_unload(i,j),sum_glacmelt(i,j),run_snowtran,
& swemelt(i,j),d_canopy_int(i,j),sum_d_canopy_int(i,j),
& snow_d_init(i,j),Qe(i,j),glacier_melt(i,j),
& sfc_sublim_flag,sum_sfcsublim(i,j),sum_swemelt(i,j),
& corr_factor(i,j,-icorr_factor_index(iter)),
& icorr_factor_index(iter),swesublim(i,j),
& swe_depth_old(i,j),canopy_int_old(i,j),JJ(i,j),
& max_layers,melt_flag_z,ro_snowmax,tsls_threshold,
& dz_snow_min,tslsnowfall(i,j),change_layer(i,j),dy_snow_z,
& swe_lyr_z,ro_layer_z,T_old_z,gamma_z,multilayer_snowpack,
& Cp_snow,seaice_run,fc_param,t_avg,Cp_water,ml_ret_z)
c Re-build the 3-D arrays. See note above about using f95 to avoid this.
if (multilayer_snowpack.eq.1) then
do k=1,nz_max
melt_flag(i,j,k) = melt_flag_z(k)
dy_snow(i,j,k) = dy_snow_z(k)
swe_lyr(i,j,k) = swe_lyr_z(k)
ro_layer(i,j,k) = ro_layer_z(k)
T_old(i,j,k) = T_old_z(k)
gamma(i,j,k) = gamma_z(k)
c layerFlux(i,j,k) = layerFlux_z(k)
ml_ret(i,j,k) = ml_ret_z(k)
c liqfracml(i,j,k) = liqfrac_z(k)
c icefracml(i,j,k) = icefrac_z(k)
enddo
endif
enddo
enddo
if (run_snowtran.eq.0.0) then
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
endif
c Read in the sea ice concentration. These are daily data, so
c first calculate which record in the data file this time step
c corresponds to.
if (seaice_run.ne.0.0) then
n_tsteps_in_day = nint(86400.0 / dt)
if (mod(iter-1,n_tsteps_in_day).eq.0) then
irec = int((real(iter) - 0.5) * dt / 86400.0) + 1
print *,'sea ice irec =',irec
read (445,rec=irec) ((seaice_conc(i,j),i=1,nx),j=1,ny)
endif
endif
c If this simulation is not running SnowTran-3D, then zero out
c the ocean grid cells that have no sea ice here. If it is
c running with SnowTran-3D, then do this in the SnowTran-3D
c subroutine.
if (run_snowtran.eq.0.0) then
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
endif
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE SNOWPACK_CORE(Twb,Tf,Tair,rh,xLs,
& Cp,sfc_pressure,ro_nsnow,dt,ro_snow,
& swe_depth,Tsfc,A1,A2,snow_d,ro_water,
& ro_ice,prec,runoff,Qm,xLf,rain,
& sprec,iter,w_balance,sum_prec,
& sum_runoff,xro_snow,undef,
& soft_snow_d,sum_sprec,ro_snow_grid,
& snow_depth,windspd,Qsi,
& sum_Qcs,canopy_int,Qcs,vegtype,
& forest_LAI,albedo,canopy_unload,
& sum_unload,sum_glacmelt,run_snowtran,
& swemelt,d_canopy_int,sum_d_canopy_int,
& snow_d_init,Qe,glacier_melt,
& sfc_sublim_flag,sum_sfcsublim,sum_swemelt,
& corr_factor,
& icorr_factor_index,swesublim,
& swe_depth_old,canopy_int_old,JJ,
& max_layers,melt_flag,ro_snowmax,tsls_threshold,
& dz_snow_min,tslsnowfall,change_layer,dy_snow,
& swe_lyr,ro_layer,T_old,gamma,multilayer_snowpack,
& Cp_snow,seaice_run,fc_param,t_avg,
& Cp_water,ml_ret)
implicit none
include 'snowmodel.inc'
integer iter,icorr_factor_index
integer JJ,max_layers,multilayer_snowpack
real ro_snowmax,tsls_threshold,dz_snow_min,tslsnowfall,Cp_snow,
& Cp_water
integer melt_flag(nz_max)
real change_layer
real dy_snow(nz_max)
real swe_lyr(nz_max)
real ro_layer(nz_max)
real T_old(nz_max)
real gamma(nz_max)
real ml_ret(nz_max)
real Twb,Tf,Tair,rh,xLs,Cp,ro_nsnow,dt,ro_snow,swe_depth,
& Tsfc,A1,A2,snow_d,ro_water,ro_ice,prec,runoff,Qm,xLf,rain,
& sprec,w_balance,sum_prec,sum_runoff,xro_snow,undef,
& soft_snow_d,sum_sprec,ro_snow_grid,snow_depth,sprec_grnd,
& windspd,Qsi,sum_Qcs,canopy_int,Qcs,canopy_unload,
& vegtype,albedo,glacier_melt,sum_unload,sum_glacmelt,
& run_snowtran,swemelt,d_canopy_int,sfc_pressure,
& sum_d_canopy_int,snow_d_init,Qe,sfc_sublim_flag,
& sum_sfcsublim,sum_swemelt,corr_factor,swesublim,
& swe_depth_old,canopy_int_old,sprec_grnd_ml,seaice_run,
& mLayerVolFracLiqTrial,fc_param,t_avg
integer nftypes
parameter (nftypes=5)
real forest_LAI(nftypes)
c Calculate the canopy sublimation, loading and unloading. Note
c that here I have assumed that evergreen trees are type 1.
if (vegtype.le.5.0) then
CALL CANOPY_SNOW(rh,Tair,windspd,Qsi,sum_Qcs,albedo,
& canopy_int,sprec,Qcs,dt,canopy_unload,
& forest_LAI(nint(vegtype)),sum_unload,d_canopy_int,
& sum_d_canopy_int)
sprec_grnd = sprec + canopy_unload - d_canopy_int
sprec_grnd_ml = sprec - d_canopy_int
else
Qcs = 0.0
sprec_grnd = sprec
sprec_grnd_ml = sprec
endif
c Solve for the wet bulb temperature.
CALL SOLVEWB(Twb,Tf,Tair,rh,xLs,Cp,sfc_pressure)
c Compute the new snow density.
CALL NSNOWDEN(ro_nsnow,Twb,Tf,dt)
c Call the multi-layer snowpack model.
if (multilayer_snowpack.eq.1) then
CALL MULTI_LAYER_SNOW(JJ,ro_layer,Tf,dt,ro_water,
& ro_ice,T_old,dy_snow,swe_lyr,Qm,ro_snowmax,rain,
& xLf,Cp_snow,melt_flag,runoff,tslsnowfall,ro_nsnow,
& sprec,Tsfc,tsls_threshold,gamma,max_layers,change_layer,
& dz_snow_min,snow_depth,swe_depth,undef,canopy_unload,
& vegtype,glacier_melt,sum_glacmelt,sum_swemelt,snow_d,
& Qe,sfc_sublim_flag,sum_sfcsublim,soft_snow_d,ro_snow,
& sum_sprec,sprec_grnd_ml,sum_prec,prec,sum_runoff,
& ro_snow_grid,xro_snow,swesublim,A1,A2,
& fc_param,Cp_water,ml_ret,icorr_factor_index,corr_factor)
c Call the original single-layer snowpack model.
else
c Compute the snow density change due to settling.
CALL DDENSITY(ro_snow_grid,swe_depth,Tf,Tsfc,dt,A1,A2,
& snow_depth,ro_water,ro_ice)
c Compute the melt, rain, and snow contributions to modifying
c the snowpack depth, density, and snow water equivalent.
CALL SNOWPACK(swe_depth,snow_d,ro_snow_grid,
& prec,ro_water,ro_nsnow,runoff,Qm,xLf,dt,rain,sprec,
& sum_prec,sum_runoff,soft_snow_d,sum_sprec,ro_snow,
& snow_depth,sprec_grnd,vegtype,glacier_melt,sum_glacmelt,
& swemelt,canopy_unload,Qe,sfc_sublim_flag,sum_sfcsublim,
& sum_swemelt,corr_factor,icorr_factor_index,swesublim,
& ro_snowmax)
c Post process the data for output.
CALL POSTPROC(ro_snow_grid,xro_snow,snow_depth,undef)
endif
c Perform a water balance check (see notes in this subroutine).
if (seaice_run.eq.0.0) then
if (run_snowtran.eq.0.0) then
CALL WATERBAL_SNOWPACK(w_balance,prec,Qcs,runoff,
& d_canopy_int,swe_depth,glacier_melt,swe_depth_old,iter,
& swesublim,canopy_unload,canopy_int_old,canopy_int)
c CALL WATERBAL_SNOWPACK_sums(w_balance,sum_prec,sum_Qcs,
c & sum_runoff,canopy_int,swe_depth,sum_glacmelt,iter,
c & snow_d_init,ro_snow,ro_water,sum_sfcsublim)
endif
endif
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE CANOPY_SNOW(rh,Tair,windspd,Qsi,sum_Qcs,albedo,
& canopy_int,sprec,Qcs,dt,canopy_unload,
& forest_LAI,sum_unload,d_canopy_int,
& sum_d_canopy_int)
implicit none
real rh,Tair,windspd,V_s,Qsi,forest_LAI,dt,xImax,canopy_int,
& d_canopy_int,Qcs,Ce,sprec,C_0,unload_melt,canopy_unload,
& sum_Qcs,albedo,sum_unload,sum_d_canopy_int
c Note that all of this must deal with the (kg/m2)=(mm), => (m)
c issues. Precip is in (m), all of these equations are in
c (kg/m2), and I want the outputs to be in (m).
c Compute the sublimation loss rate coefficient for canopy snow.
CALL SUBLIM_COEF(rh,Tair,windspd,V_s,Qsi,albedo)
c Maximum interception storage.
xImax = 4.4 * forest_LAI
c Change in canopy load due to snow precipitation during this time
c step. Convert the canopy interception to mm.
canopy_int = 1000.0 * canopy_int
d_canopy_int = 0.7 * (xImax - canopy_int) *
& ( 1.0 - exp((- sprec)*1000.0/xImax))
c Update the interception load.
canopy_int = canopy_int + d_canopy_int
c Canopy exposure coefficient.
if (canopy_int.eq.0.0) then
Ce = 0.0
else
c Pomeroy's k_c value
c Ce = 0.0114 * (canopy_int/xImax)**(-0.4)
c My k_c value.
Ce = 0.00995 * (canopy_int/xImax)**(-0.4)
endif
c Canopy sublimation (kg/m2), (a negative mumber). Make sure that
c you don't sublimate more than is available.
Qcs = Ce * canopy_int * V_s * dt
Qcs = -min(canopy_int,-Qcs)
c Remove the sublimated moisture from the canopy store.
canopy_int = canopy_int + Qcs
c Save the sublimation in (m).
Qcs = Qcs / 1000.0
sum_Qcs = sum_Qcs + Qcs
c Perform a second unloading due to melt. Assume an unloading rate
c of 5.0 mm/day/C.
C_0 = 5.0 / 86400.0
unload_melt = C_0 * max(0.0,Tair-273.16) * dt
unload_melt = min(canopy_int,unload_melt)
canopy_int = canopy_int - unload_melt
c Keep track of the unloaded snow that reached the ground during
c this time step (m) (this will add to the snow depth).
canopy_unload = unload_melt / 1000.0
d_canopy_int = d_canopy_int / 1000.0
c Save a summing array of this unloaded snow.
sum_unload = sum_unload + canopy_unload
c Save a summing array of the change in canopy load.
sum_d_canopy_int = sum_d_canopy_int + d_canopy_int
c Save the interception load for the next time step. Convert to m.
canopy_int = canopy_int / 1000.0
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE SUBLIM_COEF(rh,Tair,windspd,V_s,Qsi,albedo)
c Compute the sublimation loss rate coefficient for canopy snow.
implicit none
real pi,ro_ice,xM,R,R_dryair,vonKarman,visc_air,h_s,xlamdaT,
& D,ro_sat,sigma,V_s,radius,xmass,windspd,rh,Tair,Qsi,Sp,
& xN_r,xNu,xSh,top,bottom,omega,albedo
c Constants.
pi = 2.0 * acos(0.0)
ro_ice = 917.0
xM = 18.01
R = 8313.
R_dryair = 287.
vonKarman = 0.4
visc_air = 13.e-6
h_s = 2.838e6
xlamdaT = 0.024
c Particle radius.
radius = 5.0e-4
c Particle mass.
xmass = 4.0/3.0 * pi * ro_ice * radius**3
c Diffusivity of water vapor in the atmosphere.
D = 2.06e-5 * (Tair/273.)**(1.75)
c Saturation density of water vapor.
ro_sat = 0.622 / (R_dryair * Tair) *
& 611.15 * exp(22.452 * (Tair - 273.16) / (Tair - 0.61))
c Humidity deficit.
sigma = 0.01 * rh - 1.0
sigma = min(0.0,sigma)
sigma = max(-1.0,sigma)
c Reynolds, Nusselt, and Sherwood numbers.
xN_r = 2.0 * radius * windspd / visc_air
xNu = 1.79 + 0.606 * xN_r**(0.5)
xSh = xNu
c Solar radiation absorbed by the snow particle. Here assume that
c the general snow albedo is the same as the snow particle albedo.
Sp = pi * radius**2 * (1.0 - albedo) * Qsi
c Sublimation-loss rate coefficient for an ice sphere.
omega = ((h_s * xM)/(R * Tair) - 1.0) / (xlamdaT * Tair * xNu)
top = 2.0 * pi * radius * sigma - Sp * omega
bottom = h_s * omega + 1.0/(D * ro_sat * xSh)
V_s = (top/bottom)/xmass
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE WATERBAL_SNOWPACK(w_balance,prec,Qcs,runoff,
& d_canopy_int,swe_depth,glacier_melt,swe_depth_old,iter,
& swesublim,canopy_unload,canopy_int_old,canopy_int)
implicit none
integer iter
real w_balance,prec,Qcs,runoff,d_canopy_int,swe_depth_old,
& swe_depth,glacier_melt,swesublim,canopy_unload,canopy_int_old,
& canopy_int
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 This subroutine is called for the case where SnowTran-3D is not
c run. The subroutine WATERBAL_SNOWTRAN is used if the model
c simulation includes SnowTran-3D.
c w_balance = swe_depth_old - swe_depth + prec - runoff +
c & glacier_melt - swesublim + canopy_int_old - canopy_int -
c & d_canopy_int + Qcs + canopy_unload
c Do the snowpack.
c w_balance = swe_depth_old - swe_depth + prec - runoff -
c & glacier_melt - swesublim
c Do the canopy.
c w_balance = canopy_int_old - canopy_int + d_canopy_int +
c & Qcs - canopy_unload
c Do the snowpack and canopy store.
w_balance = swe_depth_old - swe_depth + prec - runoff +
& glacier_melt - swesublim + canopy_int_old - canopy_int +
& Qcs
if (abs(w_balance).gt.1.0e-5) then
print*,'water imbalance found, iter =',iter,' ',w_balance
print*,swe_depth_old,swe_depth,prec,runoff,glacier_melt,
& swesublim,canopy_int_old,canopy_int,Qcs
endif
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE WATERBAL_SNOWPACK_sums(w_balance,sum_prec,sum_Qcs,
& sum_runoff,canopy_int,swe_depth,sum_glacmelt,iter,
& snow_d_init,ro_snow,ro_water,sum_sfcsublim)
implicit none
integer iter
real w_balance,sum_prec,sum_Qcs,sum_runoff,canopy_int,
& swe_depth,sum_glacmelt,snow_d_init,ro_snow,ro_water,
& sum_sfcsublim
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 This subroutine is called for the case where SnowTran-3D is not
c run. The subroutine WATERBAL_SNOWTRAN is used if the model
c simulation includes SnowTran-3D.
w_balance = sum_prec + sum_Qcs - sum_runoff - canopy_int -
& swe_depth + sum_glacmelt + snow_d_init * ro_snow/ro_water -
& sum_sfcsublim
if (abs(w_balance).gt.1.0e-4)
& print*,'water imbalance found, iter =',iter,' ',w_balance
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc;cccccc
SUBROUTINE SNOWPACK(swe_depth,snow_d,ro_snow_grid,
& prec,ro_water,ro_nsnow,runoff,Qm,xLf,dt,rain,sprec,
& sum_prec,sum_runoff,soft_snow_d,sum_sprec,ro_snow,
& snow_depth,sprec_grnd,vegtype,glacier_melt,sum_glacmelt,
& swemelt,canopy_unload,Qe,sfc_sublim_flag,sum_sfcsublim,
& sum_swemelt,corr_factor,icorr_factor_index,swesublim,
& ro_snowmax)
implicit none
real ro_snowmax,runoff,Qm,swe_depth,potmelt,swemelt,dt,
& ro_water,xLf,snow_depth,ro_snow_grid,snow_d_melt,dz_water,
& soft_snow_d,prec,rain,snow_d,sum_sprec,sum_prec,
& sum_runoff,ro_nsnow,sprec,ro_snow,snow_d_new,sprec_grnd,
& vegtype,glacier_melt,sum_glacmelt,canopy_unload,Qe,
& xLsublim,potsublim,swesublim,snow_d_sublim,sfc_sublim_flag,
& sum_sfcsublim,sum_swemelt,corr_factor,potmelt_tmp
integer icorr_factor_index
runoff = 0.0
c SURFACE SUBLIMATION.
c Whether static-surface (non-blowing snow) sublimation is included
c in the model calculations is controlled by the sfc_sublim_flag.
c I am waiting for the flux-tower data Matthew and I are collecting
c in Alaska, to compare with the model simulations, before
c including this part of the model in all simulations.
c If the sfc_sublim_flag is turned on, the latent heat flux (Qe)
c calculated in ENBAL is used to add/remove snow from the snowpack.
c xLsublim = xLf + xLv = 2.5104x10^6 J/kg + 3.334x10^5 J/kg, and
c potsublim is in m swe.
if (swe_depth.gt.0.0 .and. sfc_sublim_flag.eq.1.0) then
if (Qe.lt.0.0) then
c Compute the snow-surface sublimation (m, swe).
xLsublim = 2.844e6
potsublim = (- dt) * Qe / (ro_water * xLsublim)
swesublim = min(potsublim,swe_depth)
c Save a summing array of the static surface snow sublimation.
sum_sfcsublim = sum_sfcsublim + swesublim
c Compute the change in snow depth. Assume that this sublimated
c snow does not change the snow density and does not change the
c soft snow depth. It only reduces the snow depth and the
c associated swe depth.
swe_depth = swe_depth - swesublim
if (swe_depth.eq.0.0) then
snow_depth = 0.0
else
snow_d_sublim = swesublim * ro_water / ro_snow_grid
snow_depth = snow_depth - snow_d_sublim
endif
else
swesublim = 0.0
endif
else
swesublim = 0.0
endif
c MELTING.
c If melting occurs, decrease the snow depth, and place the melt
c water in the 'runoff' variable. Keep track of the liquid water
c produced.
if (Qm.gt.0.0) then
c Compute the snow melt (m).
potmelt = dt * Qm / (ro_water * xLf)
c Account for any snowmelt data assimilation.
if (icorr_factor_index.lt.0.0) then
potmelt_tmp = potmelt * corr_factor
swemelt = min(potmelt_tmp,swe_depth)
c Handle the case of no snowmelt data assimilation.
else
swemelt = min(potmelt,swe_depth)
endif
c Compute any glacier or permanent snow-field melt (m water equiv.).
if (vegtype.eq.20.0) then
glacier_melt = potmelt - swemelt
else
glacier_melt = 0.0
endif
c Save a summing array of the glacier melt.
sum_glacmelt = sum_glacmelt + glacier_melt
c Save the runoff contribution.
runoff = runoff + glacier_melt
c Save a summing array of the snow melt.
sum_swemelt = sum_swemelt + swemelt
c Compute the change in snow depth.
snow_d_melt = swemelt * ro_water / ro_snow_grid
snow_depth = snow_depth - snow_d_melt
snow_depth = max(0.0,snow_depth)
c Compute the changes in snow density resulting from the melt.
c Assume that the melted snow is redistributed through the new
c snow depth up to a maximum density. Any additional melt water
c is added to the runoff.
if (snow_depth.eq.0.0) then
ro_snow_grid = ro_snowmax
runoff = runoff + swemelt
else
ro_snow_grid = swe_depth * ro_water / snow_depth
endif
if (ro_snow_grid.gt.ro_snowmax) then
dz_water = snow_depth *
& (ro_snow_grid - ro_snowmax) / ro_water
ro_snow_grid = ro_snowmax
swe_depth = snow_depth * ro_snow_grid / ro_water
runoff = runoff + dz_water
else
swe_depth = snow_depth * ro_snow_grid / ro_water
endif
soft_snow_d = 0.0
else
c These prevent values from the previous time step from being
c carried through to the next time step.
swemelt = 0.0
glacier_melt = 0.0
endif
c PRECIPITATION.
c Precipitation falling as rain on snow contributes to a snow
c density increase, precipitation falling as snow adds to the
c snow depth, and rain falling on bare ground contributes to the
c runoff.
c We have precipitation.
if (prec.gt.0.0) then
rain = prec - sprec
c We have rain.
if (rain.gt.0.0) then
c Rain on snow. Note that we can also have snow unloading here.
c Assume this unloading is wet as rain.
if (snow_depth.gt.0.0) then
swe_depth = swe_depth + rain + canopy_unload
ro_snow_grid = swe_depth * ro_water / snow_depth
if (ro_snow_grid.gt.ro_snowmax) then
dz_water = snow_depth * (ro_snow_grid - ro_snowmax) /
& ro_water
ro_snow_grid = ro_snowmax
swe_depth = snow_depth * ro_snow_grid / ro_water
runoff = runoff + dz_water
endif
c Rain on bare ground. Assume any unloading is as wet as rain.
else
runoff = runoff + rain + canopy_unload
endif
c We have snow precipitation (on either snow or bare ground).
else
swe_depth = swe_depth + sprec_grnd
snow_d_new = ro_water / ro_nsnow * sprec_grnd
snow_depth = snow_depth + snow_d_new
ro_snow_grid = ro_water * swe_depth / snow_depth
endif
c Here we handle the case where there is no precipitation, but
c there is snow falling from the canopy to the snowpack.
else
rain = 0.0
if (sprec_grnd.gt.0.0) then
swe_depth = swe_depth + sprec_grnd
snow_d_new = ro_water / ro_snow * sprec_grnd
snow_depth = snow_depth + snow_d_new
ro_snow_grid = ro_water * swe_depth / snow_depth
endif
endif
c The following are set up to be compatible with SnowTran-3D, and
c are in snow-depth units. The sum_sprec corrections are done
c in the SnowTran-3D code.
soft_snow_d = soft_snow_d + sprec_grnd * ro_water / ro_snow
snow_d = swe_depth * ro_water / ro_snow
c sum_sprec = sum_sprec + sprec_grnd * ro_water / ro_snow
sum_sprec = sum_sprec + sprec_grnd
c The following are in swe-depth units.
sum_prec = sum_prec + prec
sum_runoff = sum_runoff + runoff
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE DDENSITY(ro_snow_grid,swe_depth,Tf,Tsfc,dt,A1,A2,
& snow_depth,ro_water,ro_ice)
implicit none
real snow_depth,Tsg,Tf,Tsnow,Tsfc,ro_snow_grid,dt,A1,A2,
& swe_depth_star,ro_ice,ro_water,swe_depth
if (snow_depth.gt.0.0) then
c Assume that the snow-ground interface temperature is -1.0 C.
Tsg = Tf - 1.0
Tsnow = 0.5 * (Tsg + Tsfc)
swe_depth_star= 0.5 * swe_depth
ro_snow_grid = ro_snow_grid + dt *
& (A1 * swe_depth_star * ro_snow_grid *
& exp((- 0.08)*(Tf-Tsnow)) * exp((- A2)*ro_snow_grid))
ro_snow_grid = min(ro_ice,ro_snow_grid)
snow_depth = ro_water * swe_depth / ro_snow_grid
endif
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE SOLVEWB(xnew,Tf,Tair,rh,xLs,Cp,sfc_pressure)
implicit none
real A,B,C,ea,rh,Tair,Tf,tol,old,fprime,xLs,Cp,funct,xnew,
& sfc_pressure
integer maxiter,i
c Coeffs for saturation vapor pressure over water (Buck 1981).
c Note: temperatures for Buck`s equations are in deg C, and
c vapor pressures are in mb. Do the adjustments so that the
c calculations are done with temperatures in K, and vapor
c pressures in Pa.
c Over water.
A = 6.1121 * 100.0
B = 17.502
C = 240.97
c Over ice.
c A = 6.1115 * 100.0
c B = 22.452
c C = 272.55
c Atmospheric vapor pressure from relative humidity data.
ea = rh / 100.0 * A * exp((B * (Tair - Tf))/(C + (Tair - Tf)))
c Solve for the wet bulb temperature.
tol = 1.0e-2
maxiter = 20
old = Tair
do i=1,maxiter
fprime = 1.0 + xLs/Cp * 0.622/sfc_pressure * log(10.0) *
& 2353. * (10.0**(11.40 - 2353./old)) / old**2
funct = old - Tair + xLs/Cp * 0.622/sfc_pressure *
& (10.0**(11.40-2353./old) - ea)
xnew = old - funct/fprime
if (abs(xnew - old).lt.tol) return
old = xnew
end do
c If the maximum iterations are exceeded, send a message and set
c the wet bulb temperature to the air temperature.
write (*,102)
102 format('max iteration exceeded when solving for Twb')
xnew = Tair
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE NSNOWDEN(ro_nsnow,Twb,Tf,dt)
implicit none
real Twgmax,Tf,Twb,ro_nsnow,scalefact,dt,wt
Twgmax = Tf + 1.0
if (Twb.ge.258.16 .and. Twb.le.Twgmax) then
ro_nsnow = 50. + 1.7 * (Twb - 258.16)**1.5
elseif (Twb.lt.258.16) then
ro_nsnow = 50.0
else
ro_nsnow = 158.8
endif
c For one day time steps, this equation gives a new snow density at
c the end of the 24 hour period which is too low, by an approximate
c factor of X. Thus, for a daily time step, I scale the density by
c X before returning it to the main program.
scalefact = 1.0
if (dt.eq.86400.0) then
if (ro_nsnow.le.158.8) then
wt = 1.0 + (50.0 - ro_nsnow) / 108.8
ro_nsnow = wt * scalefact * ro_nsnow + ro_nsnow
ro_nsnow = min(158.8,ro_nsnow)
endif
endif
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE POSTPROC(ro_snow_grid,xro_snow,snow_depth,undef)
implicit none
real snow_depth,xro_snow,undef,ro_snow_grid
if (snow_depth.eq.0.0) then
xro_snow = undef
else
xro_snow = ro_snow_grid
endif
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE CONSTS_SNOWPACK(Cp,xLs,ro_ice,xLf,Tf,A1,A2,ro_water,
& Cp_snow,ro_snowmax,Cp_water)
implicit none
real Cp,xLs,ro_ice,xLf,Tf,A1,A2,ro_water,Cp_snow,ro_snowmax,
& Cp_water
Cp = 1004.
xLs = 2.500e6
ro_ice = 917.0
xLf = 3.34e5
Tf = 273.16
A1 = 0.0013
A2 = 0.021
ro_water = 1000.0
Cp_snow = 2106.
ro_snowmax = 550.0
Cp_water = 4180.0
return
end
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
SUBROUTINE MULTI_LAYER_SNOW(JJ,ro_layer,Tf,dt,ro_water,
& ro_ice,T_old,dy_snow,swe_lyr,Qm,ro_snowmax,rain,
& xLf,Cp_snow,melt_flag,runoff,tslsnowfall,ro_nsnow,
& sprec,Tsfc,tsls_threshold,gamma,max_layers,change_layer,
& dz_snow_min,snow_depth,swe_depth,undef,canopy_unload,
& vegtype,glacier_melt,sum_glacmelt,sum_swemelt,snow_d,
& Qe,sfc_sublim_flag,sum_sfcsublim,soft_snow_d,ro_snow,
& sum_sprec,sprec_grnd_ml,sum_prec,prec,sum_runoff,
& ro_snow_grid,xro_snow,swesublim,A1,A2,fc_param,
& Cp_water,ml_ret,icorr_factor_index,corr_factor)
implicit none
include 'snowmodel.inc'
integer JJ,max_layers
integer melt_flag(nz_max)
integer i,j
integer icorr_factor_index
real dy_snow(nz_max)
real swe_lyr(nz_max)
real ro_layer(nz_max)
real T_old(nz_max)
real gamma(nz_max)
real ml_ret(nz_max)
real Tf,dt,ro_water,ro_ice,Qm,ro_snowmax,rain,xLf,Cp_snow,
& runoff,tslsnowfall,ro_nsnow,sprec,Tsfc,tsls_threshold,
& dz_snow_min,snow_depth,swe_depth,undef,change_layer,
& canopy_unload,vegtype,glacier_melt,sum_glacmelt,sum_swemelt,
& soft_snow_d,Qe,sfc_sublim_flag,sum_sfcsublim,snow_d,
& ro_snow,sum_sprec,sprec_grnd_ml,sum_prec,prec,sum_runoff,
& ro_snow_grid,xro_snow,swesublim,A1,A2,Tk,fc_param,Cp_water,