-
Notifications
You must be signed in to change notification settings - Fork 1
/
S3M_Module_Phys_Snow.f90
1221 lines (986 loc) · 74.4 KB
/
S3M_Module_Phys_Snow.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!------------------------------------------------------------------------------------
! File: S3M_Module_Phys_Snow.f90
! Author: Francesco Avanzi, Fabio Delogu, Simone Gabellani.
!
! Created on Jul 15, 2015 11:00 AM
! Last update on February 09, 2023 10:30 AM
!
! Snow- and glacier-physics subroutine for S3M
!------------------------------------------------------------------------------------
!------------------------------------------------------------------------------------
! Module Header
module S3M_Module_Phys_Snow
!------------------------------------------------------------------------------------
! External module(s)
use S3M_Module_Namelist, only: oS3M_Namelist
use S3M_Module_Vars_Loader, only: oS3M_Vars
use S3M_Module_Tools_Debug
use S3M_Module_Phys_Snow_Apps_Assimilation, only: S3M_Phys_Snow_Apps_AssimSH, &
S3M_Phys_Snow_Apps_AssimSWE
use S3M_Module_Phys_Snow_Apps_Density, only: S3M_Phys_Snow_Apps_Rho
use S3M_Module_Phys_Snow_Apps_Hydraulics, only: S3M_Phys_Snow_Apps_Outflow
use S3M_Module_Phys_Snow_Apps_Melting, only: S3M_Phys_Snow_Apps_TMean, &
S3M_Phys_Snow_Apps_Age, &
S3M_Phys_Snow_Apps_Albedo, &
S3M_Phys_Snow_Apps_MeltingRefr
use S3M_Module_Phys_Snow_Apps_PhasePart, only: S3M_Phys_Snow_Apps_PhasePart_Froidurot
use S3M_Module_Phys_Snow_Apps_Glaciers, only: S3M_Phys_Snow_Apps_GlacierDeltaH
use gnufor2
! Implicit none for all subroutines in this module
implicit none
!------------------------------------------------------------------------------------------
contains
!------------------------------------------------------------------------------------------
! Subroutine to calculate snow- and glacier-physics
subroutine S3M_Phys_Snow_Cpl(iID, iRows, iCols)
!-------------------------------------------------------------------------------------
! Variable(s) declaration
integer(kind = 4) :: iID, iRows, iCols
integer(kind = 4) :: iRows_Pivot, iCols_Pivot
integer(kind = 4) :: iDaySteps, iDaySteps1Days, iTime, iDtDataForcing, iDt, iHour
integer(kind = 4) :: iGlacierValue
integer(kind = 4) :: iFlagSnowAssim, iFlagSnowAssim_SWE, iFlagIceMassBalance, iFlagGlacierDebris, iFlagAssOnlyPos
integer(kind = 4) :: iDaysAvgTSuppressMelt
real(kind = 4) :: dVarRhoW
real(kind = 4) :: dVarMeltingTRef, dVarIceMeltingCoeff, dVarRefreezingSc, dVarModFactorRadS
character(len = 19) :: sTime
character(len = 2) :: sWYstart
integer(kind = 4), dimension(iRows, iCols) :: a2iVarMask, a2iVarGlacierMask
integer(kind = 4), dimension(iRows, iCols) :: a2iVarAgeS
!topography
real(kind = 4), dimension(iRows, iCols) :: a2dVarDEM
!weather inputs
real(kind = 4), dimension(iRows, iCols) :: a2dVarTa, a2dVarRelHum, a2dVarIncRad, a2dVarPrecip
!assimilation variables: snow-depth and SCA information
real(kind = 4), dimension(iRows, iCols) :: a2dVarSnowHeight, a2dVarSnowKernel, a2dVarSnowCA, a2dVarSnowQA
!assimilation variables: SWE information & data-assimilation-related variables
real(kind = 4), dimension(iRows, iCols) :: a2dVarSWEass, a2dVarSWE_preass, a2dVarUass
!parameters
real(kind = 4), dimension(iRows, iCols) :: a2dVarArctUp
!variables: snowfall and rainfall
real(kind = 4), dimension(iRows, iCols) :: a2dVarSnowFall, a2dVarSnowFallDayCum, a2dVarRainfall
real(kind = 4), dimension(iRows, iCols) :: a2dVarSepCoeff
!variables: dry and wet snow
real(kind = 4), dimension(iRows, iCols) :: a2dVarSWE_D, a2dVarRho_D, a2dVarH_D, a2dVarSWE_W, a2dVarTheta_W
!variables: bulk snow
real(kind = 4), dimension(iRows, iCols) :: a2dVarSWE, a2dVarRhoS, a2dVarRhoS0, a2dVarH_S, a2dVarSnowMask
!variables: snow melt and refreezing
real(kind = 4), dimension(iRows, iCols) :: a2dVarMeltingS, a2dVarMeltingSDayCum, a2dVarMeltingSc, a2dVarMeltingSRadc
real(kind = 4), dimension(iRows, iCols) :: a2dVarMeltSIncRad, a2dVarMeltSTemp, a2dVarMeltGIncRad, a2dVarMeltGTemp
real(kind = 4), dimension(iRows, iCols) :: a2dVarRefreezingS, a2dVarAlbedoS
real(kind = 4), dimension(iRows, iCols) :: a2dVarTaC_MeanDays1, &
a2dVarTaC_MeanDaysSuppressMelt
!variables: snow hydraulics
real(kind = 4), dimension(iRows, iCols) :: a2dVarOutflow, a2dVarSSA, a2dVarPerm, a2dVarReff, &
a2dVarOutflow_ExcessRain, a2dVarOutflow_ExcessMelt, a2dVarOutflow_K
!variables: glaciers
real(kind = 4), dimension(iRows, iCols) :: a2dVarIceThick, a2dVarIceThick_WE, a2dVarIceFlag, a2dVarMeltingG
real(kind = 4), dimension(iRows, iCols) :: a2dVarMeltingGCumWY , a2dVarChangeThickness
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Local variable(s) initialization
! Topography
a2iVarGlacierMask = -9999; a2dVarDEM = -9999.0;
! Parameters
a2dVarArctUp = -9999.0;
! Weather inputs
a2dVarPrecip = -9999.0; a2dVarTa = -9999.0; a2dVarRelHum = -9999.0; a2dVarIncRad = -9999.0;
! Assimilation variables: snow-depth and SCA information
a2dVarSnowHeight = -9999.0; a2dVarSnowKernel = -9999.0; a2dVarSnowCA = -9999.0; a2dVarSnowQA = -9999.0;
! Assimilation variables: SWE information & data-assimilation-related variables
a2dVarSWEass = -9999.0; a2dVarSWE_preass = -9999.0; a2dVarUass = -9999.0;
! Variables: snowfall and rainfall
a2dVarSnowFall = 0.0; a2dVarSnowFallDayCum = -9999; a2dVarRainfall = 0.0;
a2dVarSepCoeff = -9999.0;
! Variables: dry and wet snow
a2dVarSWE_D = -9999.0; a2dVarRho_D = -9999.0; a2dVarH_D = -9999.0; a2dVarSWE_W = -9999.0; a2dVarTheta_W = -9999.0;
! Variables: bulk snow
a2dVarSWE = -9999.0; a2dVarRhoS = -9999.0; a2dVarRhoS0 = -9999; a2dVarH_S = -9999.0;
a2dVarSnowMask = -9999.0;
! Variables: snow melt and refreezing
a2dVarMeltingS = 0; a2dVarMeltingSDayCum = -9999.0; a2dVarMeltingSc = -9999.0; a2dVarMeltingSRadc = -9999.0;
a2dVarAlbedoS = -9999.0; a2iVarAgeS = 0;
dVarRefreezingSc = -9999.0; dVarModFactorRadS = -9999.0;
a2dVarRefreezingS = 0;
a2dVarMeltingG = 0;
a2dVarTaC_MeanDays1 = -9999.0; a2dVarTaC_MeanDaysSuppressMelt = -9999.0;
a2dVarMeltSIncRad = 0.0; a2dVarMeltSTemp = 0.0; a2dVarMeltGIncRad = 0.0; a2dVarMeltGTemp = 0.0;
! Variables: snow hydraulics
a2dVarOutflow = 0; a2dVarSSA = -9999.0; a2dVarPerm = -9999.0; a2dVarReff = 0.0;
a2dVarOutflow_ExcessRain = 0.0; a2dVarOutflow_ExcessMelt = 0.0; a2dVarOutflow_K = 0.0;
! Variables: glaciers
a2dVarIceThick = -9999.0; a2dVarIceThick_WE = -9999.0; a2dVarIceFlag = 1.0; a2dVarMeltingGCumWY = 0.0;
a2dVarChangeThickness = 0.0;
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Read values from oS3M_Namelist
! Flags
iFlagSnowAssim = oS3M_Namelist(iID)%iFlagSnowAssim
iFlagSnowAssim_SWE = oS3M_Namelist(iID)%iFlagSnowAssim_SWE
iFlagIceMassBalance = oS3M_Namelist(iID)%iFlagIceMassBalance
iFlagGlacierDebris = oS3M_Namelist(iID)%iFlagGlacierDebris
iFlagAssOnlyPos = oS3M_Namelist(iID)%iFlagAssOnlyPos
! Constants
dVarRhoW = oS3M_Namelist(iID)%dRhoW
iGlacierValue = oS3M_Namelist(iID)%iGlacierValue
sWYstart = oS3M_Namelist(iID)%sWYstart
iRows_Pivot = oS3M_Namelist(iID)%iRowsPivot
iCols_Pivot = oS3M_Namelist(iID)%iColsPivot
! Snow Parameters
dVarMeltingTRef = oS3M_Namelist(iID)%dMeltingTRef
dVarIceMeltingCoeff = oS3M_Namelist(iID)%dIceMeltingCoeff
dVarRefreezingSc = oS3M_Namelist(iID)%dRefreezingSc
dVarModFactorRadS = oS3M_Namelist(iID)%dModFactorRadS
iDaysAvgTSuppressMelt = oS3M_Namelist(iID)%iDaysAvgTSuppressMelt
! Time
iDaySteps1Days = oS3M_Namelist(iID)%iDaySteps ! Define days steps [-]
iDtDataForcing = oS3M_Namelist(iID)%iDtData_Forcing ! Dt data forcing
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Static variable(s)
a2dVarDEM = oS3M_Vars(iID)%a2dDem
a2iVarMask = oS3M_Vars(iID)%a2iMask
a2iVarGlacierMask = oS3M_Vars(iID)%a2iGlacierMask
a2dVarArctUp = oS3M_Vars(iID)%a2dArctUp
sTime = oS3M_Vars(iID)%sTimeStep ! Time information
iTime = oS3M_Vars(iID)%iTime ! Time information
read (sTime(12:13),*) iHour ! Time information
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Extracting dynamic forcing variable(s)
a2dVarPrecip = oS3M_Vars(iID)%a2dPrecip
a2dVarTa = oS3M_Vars(iID)%a2dTa
a2dVarRelHum = oS3M_Vars(iID)%a2dRHum
if (iHour .ge. int(7) .and. iHour.le.int(19)) then
a2dVarIncRad = oS3M_Vars(iID)%a2dK
else
a2dVarIncRad = 0.0
endif
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Extracting snow-depth and SWE assimilation variable(s)
a2dVarSnowHeight = oS3M_Vars(iID)%a2dSHeight
a2dVarSnowKernel = oS3M_Vars(iID)%a2dSKernel
a2dVarSnowCA = oS3M_Vars(iID)%a2dSCA
a2dVarSnowQA = oS3M_Vars(iID)%a2dSQA
a2dVarSWEass = oS3M_Vars(iID)%a2dSWEass
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
!Re-initialize snowfall and melting cumulated variable(s)
if ( (sTime(12:13).eq.'00') ) then
! Update cumulative daily variables
oS3M_Vars(iID)%a2dMeltingDayCum = 0.0
oS3M_Vars(iID)%a2dSnowFallDayCum = 0.0
endif
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Extracting state variable(s)
! Here we only extract those variables that depend on previous time-step values. Other fluxes are only defined and
! initialized above. a2dVarSWE is an exception: it could be computed just as a2dVarSWE_D + a2dVarSWE_W, but we need it
! right away to perform a first set of sanity checks. So we simply take it from previous time step.
a2dVarSWE_D = oS3M_Vars(iID)%a2dSWE_D
a2dVarRho_D = oS3M_Vars(iID)%a2dRho_D
a2dVarSWE_W = oS3M_Vars(iID)%a2dSWE_W
a2dVarSWE = oS3M_Vars(iID)%a2dSWE
a2iVarAgeS = oS3M_Vars(iID)%a2iAge
a2dVarMeltingSDayCum = oS3M_Vars(iID)%a2dMeltingDayCum
a2dVarSnowFallDayCum = oS3M_Vars(iID)%a2dSnowFallDayCum
a2dVarAlbedoS = oS3M_Vars(iID)%a2dAlbedo_Snow
a2dVarTaC_MeanDaysSuppressMelt = oS3M_Vars(iID)%a2dTaC_MeanDaysSuppressMelt
a2dVarMeltingGCumWY = oS3M_Vars(iID)%a2dMeltingGCumWY
! Check ice melting flag and variable(s)
if ( (iFlagIceMassBalance.eq.1.0) .or. (iFlagIceMassBalance.eq.2.0) ) then
a2dVarIceThick = oS3M_Vars(iID)%a2dIceThick
! Conversion in mm of water equivalent for calculation
where(a2dVarDEM.gt.0.0)
a2dVarIceThick_WE = a2dVarIceThick*917
endwhere
endif
!-------------------------------------------------------------------------------------
!----------------------------------------------------------------------------------------
! Info start
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow model ... ' )
!----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Debug
if (iDEBUG.gt.0) then
call mprintf(.true., iINFO_Extra, ' ========= SNOW START =========== ')
! METEO
call mprintf(.true., iINFO_Extra, checkvar(a2dVarPrecip, a2iVarMask, 'PRECIP START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarTa, a2iVarMask, 'TA START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarRelHum, a2iVarMask, 'RELHUM START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarIncRad, a2iVarMask, 'INCRAD START ') )
!ASSIMILATION
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSnowHeight, a2iVarMask, 'SNOWH START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSnowKernel, a2iVarMask, 'SNOWK START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSnowCA, a2iVarMask, 'SNOWCA START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSnowQA, a2iVarMask, 'SNOWQA START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSWEass, a2iVarMask, 'SWEASS START ') )
!SNOWFALL AND RAINFALL
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSepCoeff, a2iVarMask, 'SEPCOEFF START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSnowFall, a2iVarMask, 'SNOWFALL START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSnowFallDayCum, a2iVarMask, 'SNOWFALL DAYCUM START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarRainFall, a2iVarMask, 'RAINFALL START ') )
!DRY WET SNOW
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSWE_D, a2iVarMask, 'SWE_D START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarRho_D, a2iVarMask, 'RHO_D START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSWE_W, a2iVarMask, 'SWE_W START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarTheta_W, a2iVarMask, 'THETA_W START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarH_D, a2iVarMask, 'HD START ') )
!BULK SNOW
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSWE, a2iVarMask, 'SWE START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarRhoS, a2iVarMask, 'RHOS START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarH_S, a2iVarMask, 'HS START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSnowMask, a2iVarMask, 'SNOWMASK START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarRhoS0, a2iVarMask, 'RHOS0 START ') )
!SNOWMELT AND REFREEZING
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltingS, a2iVarMask, 'MELTINGS START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltingSDayCum, a2iVarMask, 'MELTINGS DAYCUM START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltingSc, a2iVarMask, 'MELTINGS COEFF START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarAlbedoS, a2iVarMask, 'ALBEDOS START ') )
call mprintf(.true., iINFO_Extra, checkvar(real(a2iVarAgeS), a2iVarMask, 'AGES START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarRefreezingS, a2iVarMask, 'REFREEZING START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltingG, a2iVarMask, 'MELTINGG START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltSIncRad, a2iVarMask, 'MELTSINCRAD START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltSTemp, a2iVarMask, 'MELTSTEMP START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltGIncRad, a2iVarMask, 'MELTGINCRAD START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltGTemp, a2iVarMask, 'MELTGTEMP START ') )
!SNOW HYDRAULICS
call mprintf(.true., iINFO_Extra, checkvar(a2dVarOutflow, a2iVarMask, 'OUTFLOW START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarSSA, a2iVarMask, 'SSA START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarPerm, a2iVarMask, 'PERMEABILITY START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarReff, a2iVarMask, 'REFF START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarOutflow_ExcessRain, a2iVarMask, 'OUTFLOW EXCESS RAIN START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarOutflow_ExcessMelt, a2iVarMask, 'OUTFLOW EXCESS MELT START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarOutflow_K, a2iVarMask, 'OUTFLOW PERMEABILITY START ') )
!GLACIERS
if ( (iFlagIceMassBalance.eq.1.0) .or. (iFlagIceMassBalance.eq.2.0) ) then
call mprintf(.true., iINFO_Extra, checkvar(a2dVarIceThick_WE, a2iVarMask, 'ICE W.E. START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarIceThick, a2iVarMask, 'ICE START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarMeltingGCumWY, a2iVarMask, 'ICE MELT CUM START ') )
call mprintf(.true., iINFO_Extra, checkvar(a2dVarChangeThickness, a2iVarMask, 'ICE CHANGE THICKNESS ') )
endif
call mprintf(.true., iINFO_Extra, ' ')
endif
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Check variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRho_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarTheta_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRhoS = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_S = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2iVarAgeS = 0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSSA = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarPerm = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarIceThick_WE.lt.0.01) ) a2dVarIceThick_WE = 0.0 ! just in case
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Call subroutine to compute precipitation phase partitioning
call S3M_Phys_Snow_Apps_PhasePart_Froidurot(iID, iRows, iCols, &
a2dVarDEM, &
a2dVarTa, a2dVarRelHum, a2dVarPrecip, a2dVarSepCoeff, a2dVarSnowFall, &
a2dVarRainfall)
! Compute cumulative daily snowfall
a2dVarSnowFallDayCum = a2dVarSnowFallDayCum + a2dVarSnowFall
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Update SWE (1): inputs
where( (a2dVarDEM.ge.0.0) .and. (a2dVarSnowFall .gt. 0.0))
a2dVarSWE_D = a2dVarSWE_D + a2dVarSnowFall
endwhere
where( (a2dVarDEM.ge.0.0) .and. (a2dVarRainfall .gt. 0.0) .and. (a2dVarSWE_D.ge.10.0))
a2dVarSWE_W = a2dVarSWE_W + a2dVarRainfall
endwhere
where( (a2dVarDEM.ge.0.0) .and. (a2dVarRainfall .gt. 0.0) .and. (a2dVarSWE_D.lt.10.0))
a2dVarOutflow_ExcessRain = a2dVarRainfall + a2dVarSWE_W
a2dVarSWE_W = 0.0
endwhere
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
! Check variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRho_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarTheta_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRhoS = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_S = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2iVarAgeS = 0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSSA = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarPerm = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarIceThick_WE.lt.0.01) ) a2dVarIceThick_WE = 0.0 ! just in case
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Call subroutine to compute snow density
call S3M_Phys_Snow_Apps_Rho(iID, iRows, iCols, &
sTime, iTime, iDtDataForcing, &
a2dVarDem, &
a2dVarTa, a2dVarSnowFall, a2dVarSWE_D, &
a2dVarH_D, a2dVarRho_D, a2dVarRhoS0)
! Check variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRho_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarTheta_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRhoS = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_S = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2iVarAgeS = 0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSSA = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarPerm = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarIceThick_WE.lt.0.01) ) a2dVarIceThick_WE = 0.0 ! just in case
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Call subroutine to compute average temperature over 1 days
call S3M_Phys_Snow_Apps_TMean(iID, iRows, iCols, &
iDaySteps1Days, &
a2iVarMask, &
oS3M_Vars(iID)%a3dTaC_Days1, &
a2dVarTa, a2dVarTaC_MeanDays1)
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Call subroutine to compute surface-snow age
call S3M_Phys_Snow_Apps_Age(iID, iRows, iCols, &
sTime, iTime, &
a2dVarDem, &
a2dVarSnowFallDayCum, a2dVarSWE, &
a2iVarAgeS)
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! We now compute average temperature over the last iDaysAvgTSuppressMelt days...
where( (a2dVarDem.ge.0.0) )
a2dVarTaC_MeanDaysSuppressMelt = &
(a2dVarTaC_MeanDaysSuppressMelt*(iDaySteps1Days*iDaysAvgTSuppressMelt - 1) &
+ a2dVarTa)/(iDaySteps1Days*iDaysAvgTSuppressMelt)
!We subtract - 1 from iDaySteps1Days*iDaysAvgTSuppressMelt here to exclude the current timestep, which has T = a2dVarTa
endwhere
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Call subroutine to compute snow albedo
call S3M_Phys_Snow_Apps_Albedo(iID, iRows, iCols, &
sTime, iTime, iGlacierValue, &
a2dVarDem, a2iVarGlacierMask, &
a2dVarTaC_MeanDays1, a2iVarAgeS, &
a2dVarAlbedoS, iFlagIceMassBalance, a2dVarSWE_D, a2dVarIceThick_WE)
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Call subroutine to compute open-loop melting
call S3M_Phys_Snow_Apps_MeltingRefr(iID, iRows, iCols, iDtDataForcing, iDaySteps1Days, &
sTime, iTime, &
iGlacierValue, dVarRhoW, dVarMeltingTRef, dVarIceMeltingCoeff, &
a2dVarDem, a2iVarGlacierMask, a2dVarArctUp, &
a2dVarTa, a2dVarIncRad, &
a2dVarAlbedoS, a2dVarSWE_D, a2dVarMeltingS, a2dVarMeltingSc, &
a2dVarSWE_W, a2dVarRefreezingS, dVarRefreezingSc, &
iFlagIceMassBalance, a2dVarIceThick_WE, a2dVarMeltingG, a2dVarMeltSIncRad, &
a2dVarMeltSTemp, a2dVarMeltGIncRad, a2dVarMeltGTemp, &
a2dVarTaC_MeanDaysSuppressMelt, dVarModFactorRadS, a2dVarMeltingSRadc, &
iFlagGlacierDebris)
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Update SWE (2): melt. Here we must consider glaciers too (if any)
if (iFlagIceMassBalance.eq.1) then
! This first case regards a simulation with mass balance but no movement, where we simply subtract glacier melt from
! a2dVarIceThick_WE as simulation time passes (of course, if no snow is on the ground).
!-------------------------------------------------------------------------------------
! PIXELS W/O GLACIERS AND WITH SNOW
! where Melt > SWE_D: deplete all snowpack and send to Outflow for mass conservation
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. &
(a2dVarSWE_D.le.a2dVarMeltingS) .and. (a2dVarIceThick_WE.le.0.0) )
a2dVarMeltingS = a2dVarSWE_D
a2dVarOutflow_ExcessMelt = a2dVarSWE_D + a2dVarSWE_W
a2dVarSWE_D = 0.0
a2dVarSWE_W = 0.0
a2dVarSWE = 0.0
! elsewhere Melt < SWE_D: reduce SWE_D and increase SWE_W, update SWE, Outflow not involved here
elsewhere( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. (a2dVarIceThick_WE.le.0.0))
a2dVarSWE_D = a2dVarSWE_D - a2dVarMeltingS
a2dVarSWE_W = a2dVarSWE_W + a2dVarMeltingS
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
endwhere
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! PIXELS W GLACIERS AND WITH SNOW
! where Melt > SWE_D: deplete all snowpack, send to Outflow for mass conservation, erode glacier
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. &
(a2dVarSWE_D.le.a2dVarMeltingS) .and. (a2dVarIceThick_WE.gt.0.0) )
a2dVarOutflow_ExcessMelt = a2dVarSWE_D + a2dVarSWE_W
a2dVarIceThick_WE = a2dVarIceThick_WE - (a2dVarMeltingS - a2dVarSWE_D)
a2dVarMeltingG = a2dVarMeltingG + (a2dVarMeltingS - a2dVarSWE_D) !original a2dVarMeltingG should be 0.0
a2dVarSWE_D = 0.0
a2dVarSWE_W = 0.0
a2dVarSWE = 0.0
a2dVarIceFlag = 0.0 !this a2dVarIceFlag is used to ''turn off'' ice melting and so avoid that a2dVarMeltingG
!is subtracted twice below in the ''PIXELS W GLACIERS BUT NO SNOW'' case
! elsewhere Melt < SWE_D: reduce SWE_D and increase SWE_W, update SWE, Outflow not involved here
elsewhere( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. (a2dVarIceThick_WE.gt.0.0))
a2dVarSWE_D = a2dVarSWE_D - a2dVarMeltingS
a2dVarSWE_W = a2dVarSWE_W + a2dVarMeltingS
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
endwhere
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! PIXELS W GLACIERS BUT NO SNOW
where ( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.eq.0.0) .and. (a2dVarIceThick_WE.gt.0.0) &
.and. (a2dVarMeltingG.gt.0.0) .and. (a2dVarIceFlag.gt.0.0))
a2dVarIceThick_WE = a2dVarIceThick_WE - a2dVarMeltingG
endwhere
!-------------------------------------------------------------------------------------
elseif (iFlagIceMassBalance.eq.2) then
! This second case regards a simulation with mass balance AND movement according to the deltaH parametrization,
! so here WE DO NOT subtract glacier melt from a2dVarIceThick_WE as simulation time passes. We store melt into
! a2dVarMeltingGCumWY
!-------------------------------------------------------------------------------------
! PIXELS W/O GLACIERS AND WITH SNOW
! where Melt > SWE_D: deplete all snowpack and send to Outflow for mass conservation
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. &
(a2dVarSWE_D.le.a2dVarMeltingS) .and. (a2dVarIceThick_WE.le.0.0) )
a2dVarMeltingS = a2dVarSWE_D
a2dVarOutflow_ExcessMelt = a2dVarSWE_D + a2dVarSWE_W
a2dVarSWE_D = 0.0
a2dVarSWE_W = 0.0
a2dVarSWE = 0.0
! elsewhere Melt < SWE_D: reduce SWE_D and increase SWE_W, update SWE, Outflow not involved here
elsewhere( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. (a2dVarIceThick_WE.le.0.0))
a2dVarSWE_D = a2dVarSWE_D - a2dVarMeltingS
a2dVarSWE_W = a2dVarSWE_W + a2dVarMeltingS
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
endwhere
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! PIXELS W GLACIERS AND WITH SNOW
! where Melt > SWE_D: deplete all snowpack, send to Outflow for mass conservation, erode glacier
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. &
(a2dVarSWE_D.le.a2dVarMeltingS) .and. (a2dVarIceThick_WE.gt.0.0) )
a2dVarOutflow_ExcessMelt = a2dVarSWE_D + a2dVarSWE_W
a2dVarMeltingG = a2dVarMeltingG + (a2dVarMeltingS - a2dVarSWE_D) !original a2dVarMeltingG should be 0.0
a2dVarMeltingGCumWY = a2dVarMeltingG + a2dVarMeltingGCumWY
a2dVarSWE_D = 0.0
a2dVarSWE_W = 0.0
a2dVarSWE = 0.0
a2dVarIceFlag = 0.0 !this a2dVarIceFlag is used to ''turn off'' ice melting and so avoid that a2dVarMeltingG
!is subtracted twice below in the ''PIXELS W GLACIERS BUT NO SNOW'' case
! elsewhere Melt < SWE_D: reduce SWE_D and increase SWE_W, update SWE, Outflow not involved here
elsewhere( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. (a2dVarIceThick_WE.gt.0.0))
a2dVarSWE_D = a2dVarSWE_D - a2dVarMeltingS
a2dVarSWE_W = a2dVarSWE_W + a2dVarMeltingS
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
endwhere
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! PIXELS W GLACIERS BUT NO SNOW
where ( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.eq.0.0) .and. (a2dVarIceThick_WE.gt.0.0) &
.and. (a2dVarMeltingG.gt.0.0) .and. (a2dVarIceFlag.gt.0.0))
a2dVarMeltingGCumWY = a2dVarMeltingG + a2dVarMeltingGCumWY
endwhere
!-------------------------------------------------------------------------------------
else
!-------------------------------------------------------------------------------------
! PIXELS where Melt > SWE_D: deplete all snowpack and send to Outflow for mass conservation
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) .and. &
(a2dVarSWE_D.le.a2dVarMeltingS) )
a2dVarMeltingS = a2dVarSWE_D
a2dVarOutflow_ExcessMelt = a2dVarSWE_D + a2dVarSWE_W
a2dVarSWE_D = 0.0
a2dVarSWE_W = 0.0
a2dVarSWE = 0.0
! elsewhere Melt < SWE_D: reduce SWE_D and increase SWE_W, update SWE, Outflow not involved here
elsewhere( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.gt.0.0) )
a2dVarSWE_D = a2dVarSWE_D - a2dVarMeltingS
a2dVarSWE_W = a2dVarSWE_W + a2dVarMeltingS
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
endwhere
!-------------------------------------------------------------------------------------
endif
!-------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Update SWE
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_D.lt.0.0) ) a2dVarSWE_D = 0.0 !just in case....
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W !an update just in case...
! Compute daily cumulated melting
where( (a2dVarDem.ge.0.0) .and. (a2dVarMeltingS.gt.0.0) )
a2dVarMeltingSDayCum = a2dVarMeltingSDayCum + a2dVarMeltingS
endwhere
!-------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Check variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRho_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarTheta_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRhoS = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_S = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2iVarAgeS = 0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSSA = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarPerm = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarIceThick_WE.lt.0.01) ) a2dVarIceThick_WE = 0.0 ! just in case
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Update SWE (3): Refreezing (better to decouple this from melt for readability).
! Here we also update dry-snow density
! PIXELS with a2dVarSWE_W and where Refreezing > SWE_W: set SWE_W to 0 and send it to SWE_D, correct Refreezing
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_W.gt.0.0) .and. (a2dVarRefreezingS.gt.0.0) .and. &
(a2dVarSWE_W.le.a2dVarRefreezingS) )
a2dVarRefreezingS = a2dVarSWE_W
a2dVarRho_D = (a2dVarSWE_D + a2dVarRefreezingS)/((a2dVarRefreezingS/917) + (a2dVarSWE_D/a2dVarRho_D))
a2dVarSWE_D = a2dVarSWE_D + a2dVarRefreezingS
a2dVarSWE_W = 0.0
a2dVarSWE = a2dVarSWE_D
! elsewhere with a2dVarSWE_W where Refreezing < SWE_W: reduce SWE_W and increase SWE_D, update SWE
elsewhere( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_W.gt.0.0) .and. (a2dVarRefreezingS.gt.0.0))
a2dVarRho_D = (a2dVarSWE_D + a2dVarRefreezingS)/((a2dVarRefreezingS/917) + (a2dVarSWE_D/a2dVarRho_D))
a2dVarSWE_D = a2dVarSWE_D + a2dVarRefreezingS
a2dVarSWE_W = a2dVarSWE_W - a2dVarRefreezingS
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
endwhere
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Update SWE
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_W.lt.0.0) ) a2dVarSWE_W = 0.0
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Check variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRho_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarTheta_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRhoS = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_S = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2iVarAgeS = 0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSSA = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarPerm = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarIceThick_WE.lt.0.01) ) a2dVarIceThick_WE = 0.0 ! just in case
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Call subroutine to compute outflow
call S3M_Phys_Snow_Apps_Outflow(iID, iRows, iCols, iDtDataForcing, &
dVarRhoW, &
a2dVarDem, &
a2dVarSWE_D, a2dVarRho_D, a2dVarSWE_W, &
a2dVarRainfall, a2dVarMeltingS, a2dVarRefreezingS, &
a2dVarOutflow_K, a2dVarH_D, a2dVarH_S, a2dVarSSA, a2dVarPerm, a2dVarTheta_W)
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Update SWE (4): outflow
! Here we must bear in mind that a2dVarOutflow is the result of two computations:
! (1) complete snow depletion due to melt or rain on shallow snowpack; in that case, SWE_W has already been updated
! (2) Outflow due to drainage of liquid water from the snowpack. In this case, SWE_W has not been updated yet.
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_W.gt.0.0) )
a2dVarSWE_W = a2dVarSWE_W - a2dVarOutflow_K !the only flux we have not taken into account yet
a2dVarSWE = a2dVarSWE_D + a2dVarSWE_W
!Note that the S3M_Phys_Snow_Apps_Outflow routine already includes a number of sanity checks to make sure that
!a2dVarOutflow_K should be .le. a2dVarSWE_W
endwhere
!we now compute total outflow from all sources...
a2dVarOutflow = a2dVarOutflow_K + a2dVarOutflow_ExcessRain + a2dVarOutflow_ExcessMelt
!sanity check
where( (a2dVarSWE_W.lt.0.0) )
a2dVarOutflow = a2dVarOutflow + a2dVarSWE_W
a2dVarSWE_W = 0.0
a2dVarSWE = a2dVarSWE_D
!this should never happen, but if this was the case then remove the negative a2dVarSWE_W from a2dVarOutflow
!and correct a2dVarSWE_W.
endwhere
!--------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Check variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRho_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarTheta_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRhoS = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_S = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2iVarAgeS = 0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSSA = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarPerm = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarIceThick_WE.lt.0.01) ) a2dVarIceThick_WE = 0.0 ! just in case
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Compute Reff
! Reff is the sum of any snowpack runoff and glacier melt resulting at this point.
where( (a2dVarDem.ge.0.0) )
a2dVarReff = a2dVarOutflow + a2dVarMeltingG
! note that here we add a2dVarMeltingG to outflow regardless of iFlagIceMassBalance. If iFlagIceMassBalance = 0 or
! 1, this choice has no implication; if iFlagIceMassBalance = 2, this choice implies that we disconnect the update of
! glacier thickness (which happens once per yr) from the sub-annual patterns of a2dVarMeltingG.
endwhere
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! In preparation of the assimilation part, we update control volumes, bulk-snow density,
! and some ancillary state variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarRho_D .gt. 0.0) )
a2dVarH_D = ((a2dVarSWE_D/1000)*dVarRhoW)/a2dVarRho_D
where( (a2dVarSWE_W/1000 .ge. ((1 - a2dVarRho_D/917)*a2dVarH_D)) )
! We divide by 1000 to convert mm to m and so compare a2dVarSWE_W with a2dVarH_D
! (1 - - a2dVarRho_D/917) is porosity
a2dVarH_S = a2dVarH_D + ((a2dVarSWE_W/1000) - (1 - a2dVarRho_D/917)*a2dVarH_D)
elsewhere
a2dVarH_S = a2dVarH_D
endwhere
where( (a2dVarH_S .gt. 0.0) )
a2dVarTheta_W = a2dVarSWE_W/1000/a2dVarH_S
a2dVarRhoS = (a2dVarRho_D*a2dVarH_S + dVarRhoW*(a2dVarSWE_W/1000))/(a2dVarH_S)
elsewhere
a2dVarTheta_W = 0.0
a2dVarRhoS = 0.0
endwhere
endwhere
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Call subroutine to compute SWE assimilation from snow height interpolated observations
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow :: Assimilation of SH and MODIS... ' )
if (iFlagSnowAssim.eq.1) then
!-----------------------------------------------------------------------------------------
! Check forcing(s) to use assimilation method
if ( any(a2dVarSnowHeight.ne.-9999.0) .and. any(a2dVarSnowKernel.ne.-9999.0) .and. &
any(a2dVarSnowCA.ne.-9999.0) .and. any(a2dVarSnowQA.ne.-9999.0) ) then
!-----------------------------------------------------------------------------------------
! We store the modeled map of a2dVarSWE into a matrix, that we will then use to update SWE_D and SWE_W
a2dVarSWE_preass = a2dVarSWE
! Call subroutine to compute SWE assimilation from snow height interpolated observations
call S3M_Phys_Snow_Apps_AssimSH(iID, iRows, iCols, &
dVarRhoW, &
a2iVarMask, &
a2dVarSnowHeight, a2dVarSnowKernel, &
a2dVarSnowCA, a2dVarSnowQA, &
a2dVarSWE, a2iVarAgeS, a2dVarAlbedoS, a2dVarRhoS, iFlagAssOnlyPos)
! Now we update SWE_D and SWE_W as well
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_preass.gt.10) .and. (a2dVarTheta_W .lt. 0.1) )
a2dVarUass = a2dVarSWE/a2dVarSWE_preass
a2dVarSWE_D = a2dVarUass*a2dVarSWE_D
a2dVarSWE_W = a2dVarUass*a2dVarSWE_W
elsewhere( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_preass.gt.10) )
a2dVarUass = a2dVarSWE - a2dVarSWE_preass
a2dVarSWE_D = a2dVarSWE + a2dVarUass
a2dVarSWE_W = a2dVarSWE_W
elsewhere( (a2dVarDem.ge.0.0) )
a2dVarSWE_D = a2dVarSWE
a2dVarSWE_W = 0.0
endwhere
! Info end assimilation
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow :: Assimilation of SH and MODIS... OK' )
!-----------------------------------------------------------------------------------------
else
!-----------------------------------------------------------------------------------------
! Info assimilation no data available
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow :: Assimilation of SH and MODIS... DATA NO AVAILABLE ' )
!-----------------------------------------------------------------------------------------
endif
!-----------------------------------------------------------------------------------------
else
!-----------------------------------------------------------------------------------------
! Info assimilation no data available
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow :: Assimilation of SH and MODIS... NOT ACTIVATED ' )
!-----------------------------------------------------------------------------------------
endif
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Check variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRho_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarTheta_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRhoS = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_S = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2iVarAgeS = 0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSSA = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarPerm = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarIceThick_WE.lt.0.01) ) a2dVarIceThick_WE = 0.0 ! just in case
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! In preparation of the assimilation part, we update control volumes, bulk-snow density, and some ancillary state variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarRho_D .gt. 0.0) )
a2dVarH_D = ((a2dVarSWE_D/1000)*dVarRhoW)/a2dVarRho_D
where( (a2dVarSWE_W/1000 .ge. ((1 - a2dVarRho_D/917)*a2dVarH_D)) )
!we divide by 1000 to convert mm to m and so compare a2dVarSWE_W with a2dVarH_D
!(1 - - a2dVarRho_D/917) is porosity
a2dVarH_S = a2dVarH_D + ((a2dVarSWE_W/1000) - (1 - a2dVarRho_D/917)*a2dVarH_D)
elsewhere
a2dVarH_S = a2dVarH_D
endwhere
where( (a2dVarH_S .gt. 0.0) )
a2dVarTheta_W = a2dVarSWE_W/1000/a2dVarH_S
a2dVarRhoS = (a2dVarRho_D*a2dVarH_S + dVarRhoW*(a2dVarSWE_W/1000))/(a2dVarH_S)
elsewhere
a2dVarTheta_W = 0.0
a2dVarRhoS = 0.0
endwhere
endwhere
!-----------------------------------------------------------------------------------------
!-------------------------------------------------------------------------------------
! Call subroutine to compute SWE assimilation map, ex. from ARPA VdA
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow :: Assimilation of SWE map... ' )
if (iFlagSnowAssim_SWE.eq.1) then
! Check forcing(s) to use assimilation method
if ( any(a2dVarSWEass.ne.-9999.0) ) then
! We store the modeled map of a2dVarSWE into a matrix, that we will then use to update SWE_D and SWE_W
a2dVarSWE_preass = a2dVarSWE
! Call subroutine to compute SWE assimilation from external map
call S3M_Phys_Snow_Apps_AssimSWE(iID, iRows, iCols, &
a2iVarMask, &
a2dVarSWE, a2dVarSWEass, iFlagAssOnlyPos)
! Now we update SWE_D and SWE_W as well
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_preass.gt.10) .and. (a2dVarTheta_W .lt. 0.1) )
a2dVarUass = a2dVarSWE/a2dVarSWE_preass
a2dVarSWE_D = a2dVarUass*a2dVarSWE_D
a2dVarSWE_W = a2dVarUass*a2dVarSWE_W
elsewhere( (a2dVarDem.ge.0.0) .and. (a2dVarSWE_preass.gt.10) )
a2dVarUass = a2dVarSWE - a2dVarSWE_preass
a2dVarSWE_D = a2dVarSWE + a2dVarUass
a2dVarSWE_W = a2dVarSWE_W
elsewhere( (a2dVarDem.ge.0.0) )
a2dVarSWE_D = a2dVarSWE
a2dVarSWE_W = 0.0
endwhere
! Info start assimilation
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow :: Assimilation of SWE map ... OK' )
!-------------------------------------------------------------------------------------
else
!-------------------------------------------------------------------------------------
! Info assimilation no data available
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow :: Assimilation of SWE map ... DATA NO AVAILABLE ' )
!-------------------------------------------------------------------------------------
endif
!-------------------------------------------------------------------------------------
else
!-------------------------------------------------------------------------------------
! Info assimilation no data available
call mprintf(.true., iINFO_Verbose, ' Phys :: Snow :: Assimilation of SWE map... NOT ACTIVATED ' )
!-------------------------------------------------------------------------------------
endif
!-------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! Check variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRho_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_D = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSWE_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarTheta_W = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarRhoS = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarH_S = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2iVarAgeS = 0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarSSA = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarSWE.lt.0.01) ) a2dVarPerm = 0.0 ! just in case
where( (a2dVarDem.ge.0.0) .and. (a2dVarIceThick_WE.lt.0.01) ) a2dVarIceThick_WE = 0.0 ! just in case
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! We update again control volumes, bulk-snow density, and some ancillary state variables
where( (a2dVarDem.ge.0.0) .and. (a2dVarRho_D .gt. 0.0) )
a2dVarH_D = ((a2dVarSWE_D/1000)*dVarRhoW)/a2dVarRho_D
where( (a2dVarSWE_W/1000 .ge. ((1 - a2dVarRho_D/917)*a2dVarH_D)) )
!we divide by 1000 to convert mm to m and so compare a2dVarSWE_W with a2dVarH_D
!(1 - - a2dVarRho_D/917) is porosity
a2dVarH_S = a2dVarH_D + ((a2dVarSWE_W/1000) - (1 - a2dVarRho_D/917)*a2dVarH_D)
elsewhere
a2dVarH_S = a2dVarH_D
endwhere
where( (a2dVarH_S .gt. 0.0) )
a2dVarTheta_W = a2dVarSWE_W/1000/a2dVarH_S
a2dVarRhoS = (a2dVarRho_D*a2dVarH_S + dVarRhoW*(a2dVarSWE_W/1000))/(a2dVarH_S)
elsewhere
a2dVarTheta_W = 0.0
a2dVarRhoS = 0.0
endwhere
endwhere
!-----------------------------------------------------------------------------------------
!-----------------------------------------------------------------------------------------
! We apply the deltaH parametrization for glacier-thickness update, as well as snow-to-ice conversion
!-----------------------------------------------------------------------------------------
if ( (iFlagIceMassBalance.eq.2) .and. (sTime(9:10).eq.'01') .and. (sTime(6:7).eq.sWYstart) &
.and. (sTime(12:13).eq.'00')) then