forked from CICE-Consortium/Icepack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathicepack_therm_vertical.F90
2990 lines (2512 loc) · 126 KB
/
icepack_therm_vertical.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
!=========================================================================
!
! Update ice and snow internal temperatures and compute
! thermodynamic growth rates and atmospheric fluxes.
!
! NOTE: The thermodynamic calculation is split in two for load balancing.
! First icepack_therm_vertical computes vertical growth rates and coupler
! fluxes. Then icepack_therm_itd does thermodynamic calculations not
! needed for coupling.
!
! authors: William H. Lipscomb, LANL
! C. M. Bitz, UW
! Elizabeth C. Hunke, LANL
!
! 2003: Vectorized by Clifford Chen (Fujitsu) and William Lipscomb
! 2004: Block structure added by William Lipscomb
! 2006: Streamlined for efficiency by Elizabeth Hunke
! Converted to free source form (F90)
module icepack_therm_vertical
use icepack_kinds
use icepack_fsd, only: floe_rad_c, floe_binwidth
use icepack_parameters, only: c0, c1, c2, p001, p5, puny
use icepack_parameters, only: pi, depressT, Lvap, hs_min, cp_ice, min_salin
use icepack_parameters, only: cp_ocn, rhow, rhoi, rhos, Lfresh, rhofresh, ice_ref_salinity
use icepack_parameters, only: ktherm, calc_Tsfc, rsnw_fall, rsnw_tmax
use icepack_parameters, only: ustar_min, fbot_xfer_type, formdrag, calc_strair
use icepack_parameters, only: rfracmin, rfracmax, dpscale, frzpnd, snwgrain, snwlvlfac
use icepack_parameters, only: phi_i_mushy, floeshape, floediam, use_smliq_pnd, snwredist
use icepack_parameters, only: saltflux_option, congel_freeze
use icepack_parameters, only: icepack_chkoptargflag
use icepack_tracers, only: ncat, nilyr, nslyr, nfsd
use icepack_tracers, only: tr_iage, tr_FY, tr_aero, tr_pond, tr_fsd, tr_iso
use icepack_tracers, only: tr_pond_lvl, tr_pond_topo
use icepack_tracers, only: n_aero, n_iso
use icepack_therm_shared, only: ferrmax, l_brine
use icepack_therm_shared, only: calculate_tin_from_qin, Tmin
use icepack_therm_shared, only: adjust_enthalpy
use icepack_therm_bl99, only: temperature_changes
use icepack_therm_mushy, only: temperature_changes_salinity
use icepack_warnings, only: warnstr, icepack_warnings_add
use icepack_warnings, only: icepack_warnings_setabort, icepack_warnings_aborted
use icepack_mushy_physics, only: icepack_mushy_temperature_mush
use icepack_mushy_physics, only: liquidus_temperature_mush
use icepack_mushy_physics, only: icepack_enthalpy_mush, enthalpy_of_melting
use icepack_mushy_physics, only: enthalpy_mush_liquid_fraction, enthalpy_brine
use icepack_aerosol, only: update_aerosol
use icepack_isotope, only: update_isotope
use icepack_atmo, only: neutral_drag_coeffs, icepack_atm_boundary
use icepack_age, only: increment_age
use icepack_firstyear, only: update_FYarea
use icepack_flux, only: set_sfcflux, merge_fluxes
use icepack_meltpond_lvl, only: compute_ponds_lvl
use icepack_meltpond_topo, only: compute_ponds_topo
use icepack_snow, only: drain_snow
implicit none
private
public :: icepack_step_therm1
!=======================================================================
contains
!=======================================================================
!
! Driver for updating ice and snow internal temperatures and
! computing thermodynamic growth rates and atmospheric fluxes.
!
! authors: William H. Lipscomb, LANL
! C. M. Bitz, UW
subroutine thermo_vertical (dt, aicen, &
vicen, vsnon, &
Tsf, zSin, &
zqin, zqsn, &
apond, hpond, &
flw, potT, &
Qa, rhoa, &
fsnow, fpond, &
fbot, Tbot, &
Tsnice, sss, &
sst, rsnw, &
lhcoef, shcoef, &
fswsfc, fswint, &
Sswabs, Iswabs, &
fsurfn, fcondtopn, &
fcondbotn, &
fsensn, flatn, &
flwoutn, evapn, &
evapsn, evapin, &
freshn, fsaltn, &
fhocnn, frain, &
meltt, melts, &
meltb, meltsliq, &
smice, massice, &
smliq, massliq, &
congel, snoice, &
mlt_onset, frz_onset, &
yday, dsnow, &
prescribed_ice)
real (kind=dbl_kind), intent(in) :: &
dt , & ! time step
frain ! rainfall rate (kg/m2/s)
! ice state variables
real (kind=dbl_kind), intent(inout) :: &
aicen , & ! concentration of ice
vicen , & ! volume per unit area of ice (m)
vsnon ! volume per unit area of snow (m)
! tracers
real (kind=dbl_kind), intent(inout) :: &
Tsf , & ! ice/snow top surface temp, same as Tsfcn (deg C)
apond , & ! melt pond area fraction
hpond ! melt pond depth (m)
! iage ! ice age (s)
logical (kind=log_kind), intent(in), optional :: &
prescribed_ice ! if .true., use prescribed ice instead of computed
real (kind=dbl_kind), dimension (:), intent(inout) :: &
zqsn , & ! snow layer enthalpy, zqsn < 0 (J m-3)
zqin , & ! ice layer enthalpy, zqin < 0 (J m-3)
zSin , & ! internal ice layer salinities
rsnw , & ! snow grain radius (10^-6 m)
smice , & ! ice mass tracer in snow (kg/m^3)
smliq ! liquid water mass tracer in snow (kg/m^3)
real (kind=dbl_kind), dimension (:), intent(out) :: &
massice , & ! ice mass in snow (kg/m^2)
massliq ! liquid water mass in snow (kg/m^2)
! input from atmosphere
real (kind=dbl_kind), intent(in) :: &
flw , & ! incoming longwave radiation (W/m^2)
potT , & ! air potential temperature (K)
Qa , & ! specific humidity (kg/kg)
rhoa , & ! air density (kg/m^3)
fsnow , & ! snowfall rate (kg m-2 s-1)
shcoef , & ! transfer coefficient for sensible heat
lhcoef ! transfer coefficient for latent heat
real (kind=dbl_kind), intent(inout) :: &
fswsfc , & ! SW absorbed at ice/snow surface (W m-2)
fswint , & ! SW absorbed in ice interior, below surface (W m-2)
fpond ! fresh water flux to ponds (kg/m^2/s)
real (kind=dbl_kind), dimension (:), intent(inout) :: &
Sswabs , & ! SW radiation absorbed in snow layers (W m-2)
Iswabs ! SW radiation absorbed in ice layers (W m-2)
! input from ocean
real (kind=dbl_kind), intent(in) :: &
fbot , & ! ice-ocean heat flux at bottom surface (W/m^2)
Tbot , & ! ice bottom surface temperature (deg C)
sst , & ! sea surface temperature (C)
sss ! ocean salinity
! coupler fluxes to atmosphere
real (kind=dbl_kind), intent(out):: &
flwoutn , & ! outgoing longwave radiation (W/m^2)
evapn , & ! evaporative water flux (kg/m^2/s)
evapsn , & ! evaporative water flux over snow (kg/m^2/s)
evapin ! evaporative water flux over ice (kg/m^2/s)
! Note: these are intent out if calc_Tsfc = T, otherwise intent in
real (kind=dbl_kind), intent(inout):: &
fsensn , & ! sensible heat flux (W/m^2)
flatn , & ! latent heat flux (W/m^2)
fsurfn , & ! net flux to top surface, excluding fcondtopn
fcondtopn, & ! downward cond flux at top surface (W m-2)
fcondbotn ! downward cond flux at bottom surface (W m-2)
! coupler fluxes to ocean
real (kind=dbl_kind), intent(out):: &
freshn , & ! fresh water flux to ocean (kg/m^2/s)
fsaltn , & ! salt flux to ocean (kg/m^2/s)
fhocnn ! net heat flux to ocean (W/m^2)
! diagnostic fields
real (kind=dbl_kind), intent(inout):: &
Tsnice , & ! snow ice interface temperature (deg C)
meltt , & ! top ice melt (m/step-->cm/day)
melts , & ! snow melt (m/step-->cm/day)
meltsliq , & ! snow melt mass (kg/m^2/step-->kg/m^2/day)
meltb , & ! basal ice melt (m/step-->cm/day)
congel , & ! basal ice growth (m/step-->cm/day)
snoice , & ! snow-ice formation (m/step-->cm/day)
dsnow , & ! change in snow thickness (m/step-->cm/day)
mlt_onset, & ! day of year that sfc melting begins
frz_onset ! day of year that freezing begins (congel or frazil)
real (kind=dbl_kind), intent(in) :: &
yday ! day of year
! local variables
integer (kind=int_kind) :: &
k ! ice layer index
real (kind=dbl_kind) :: &
dhi , & ! change in ice thickness
dhs ! change in snow thickness
! 2D state variables (thickness, temperature)
real (kind=dbl_kind) :: &
hilyr , & ! ice layer thickness
hslyr , & ! snow layer thickness
hin , & ! ice thickness (m)
hsn , & ! snow thickness (m)
hsn_new , & ! thickness of new snow (m)
worki , & ! local work array
works ! local work array
real (kind=dbl_kind), dimension (nilyr) :: &
zTin ! internal ice layer temperatures
real (kind=dbl_kind), dimension (nslyr) :: &
zTsn ! internal snow layer temperatures
! other 2D flux and energy variables
real (kind=dbl_kind) :: &
einit , & ! initial energy of melting (J m-2)
efinal , & ! final energy of melting (J m-2)
einter ! intermediate energy
real (kind=dbl_kind) :: &
fadvocn, saltvol, dfsalt ! advective heat flux to ocean
character(len=*),parameter :: subname='(thermo_vertical)'
!-----------------------------------------------------------------
! Initialize
!-----------------------------------------------------------------
flwoutn = c0
evapn = c0
evapsn = c0
evapin = c0
freshn = c0
fsaltn = c0
fhocnn = c0
fadvocn = c0
meltt = c0
meltb = c0
melts = c0
congel = c0
snoice = c0
dsnow = c0
zTsn(:) = c0
zTin(:) = c0
meltsliq= c0
massice(:) = c0
massliq(:) = c0
if (calc_Tsfc) then
fsensn = c0
flatn = c0
fsurfn = c0
fcondtopn = c0
endif
!-----------------------------------------------------------------
! Compute variables needed for vertical thermo calculation
!-----------------------------------------------------------------
call init_vertical_profile (aicen, &
vicen, vsnon, &
hin, hilyr, &
hsn, hslyr, &
zqin, zTin, &
zqsn, zTsn, &
zSin, &
einit )
if (icepack_warnings_aborted(subname)) return
! Save initial ice and snow thickness (for fresh and fsalt)
worki = hin
works = hsn
! Save initial salt volume for prognostic flux
if (saltflux_option == 'prognostic') then
saltvol = c0
do k=1,nilyr
saltvol = saltvol + rhoi*zSin(k)*hin*p001 / real(nilyr,kind=dbl_kind)
enddo
endif
!-----------------------------------------------------------------
! Compute new surface temperature and internal ice and snow
! temperatures.
!-----------------------------------------------------------------
if (ktherm == 2) then
call temperature_changes_salinity(dt, &
rhoa, flw, &
potT, Qa, &
shcoef, lhcoef, &
fswsfc, fswint, &
Sswabs, Iswabs, &
hilyr, hslyr, &
apond, hpond, &
zqin, zTin, &
zqsn, zTsn, &
zSin, &
Tsf, Tbot, &
sss, &
fsensn, flatn, &
flwoutn, fsurfn, &
fcondtopn, fcondbotn, &
fadvocn, snoice, &
smice, smliq)
if (icepack_warnings_aborted(subname)) return
else ! ktherm
call temperature_changes(dt, &
rhoa, flw, &
potT, Qa, &
shcoef, lhcoef, &
fswsfc, fswint, &
Sswabs, Iswabs, &
hilyr, hslyr, &
zqin, zTin, &
zqsn, zTsn, &
zSin, &
Tsf, Tbot, &
fsensn, flatn, &
flwoutn, fsurfn, &
fcondtopn, fcondbotn, &
einit )
if (icepack_warnings_aborted(subname)) return
endif ! ktherm
! mass of ice and liquid water in snow
if (snwgrain) then
massice(:) = smice(:) * hslyr
massliq(:) = smliq(:) * hslyr
endif
! intermediate energy for error check
einter = c0
do k = 1, nslyr
einter = einter + hslyr * zqsn(k)
enddo ! k
do k = 1, nilyr
einter = einter + hilyr * zqin(k)
enddo ! k
Tsnice = c0
if ((hslyr+hilyr) > puny) then
if (hslyr > puny) then
Tsnice = (hslyr*zTsn(nslyr) + hilyr*zTin(1)) / (hslyr+hilyr)
else
Tsnice = Tsf
endif
endif
if (icepack_warnings_aborted(subname)) return
!-----------------------------------------------------------------
! Compute growth and/or melting at the top and bottom surfaces.
! Add new snowfall.
! Repartition ice into equal-thickness layers, conserving energy.
!-----------------------------------------------------------------
call thickness_changes(dt, yday, &
efinal, &
hin, hilyr, &
hsn, hslyr, &
zqin, zqsn, &
smice, massice, &
smliq, massliq, &
fbot, Tbot, &
flatn, fsurfn, &
fcondtopn, fcondbotn, &
fsnow, hsn_new, &
fhocnn, evapn, &
evapsn, evapin, &
meltt, melts, &
meltsliq, frain, &
meltb, &
congel, snoice, &
mlt_onset, frz_onset, &
zSin, sss, &
sst, &
dsnow, rsnw)
if (icepack_warnings_aborted(subname)) return
!-----------------------------------------------------------------
! Check for energy conservation by comparing the change in energy
! to the net energy input
!-----------------------------------------------------------------
call conservation_check_vthermo(dt, &
fsurfn, flatn, &
fhocnn, fswint, &
fsnow, einit, &
einter, efinal, &
fcondtopn, fcondbotn, &
fadvocn, fbot )
if (icepack_warnings_aborted(subname)) return
!-----------------------------------------------------------------
! If prescribed ice, set hi back to old values
!-----------------------------------------------------------------
if (present(prescribed_ice)) then
if (prescribed_ice) then
hin = worki
fhocnn = c0 ! for diagnostics
endif
endif
!-----------------------------------------------------------------
! Compute fluxes of water and salt from ice to ocean.
! evapn < 0 => sublimation, evapn > 0 => condensation
! aerosol flux is accounted for in icepack_aerosol.F90
!-----------------------------------------------------------------
dhi = hin - worki
dhs = hsn - works - hsn_new
freshn = freshn + evapn - (rhoi*dhi + rhos*dhs) / dt
if (saltflux_option == 'prognostic') then
dfsalt = c0
do k=1,nilyr
dfsalt = dfsalt + rhoi*zSin(k)*hin*p001 / real(nilyr,kind=dbl_kind)
enddo
fsaltn = fsaltn - (dfsalt - saltvol) / dt
else
fsaltn = fsaltn - rhoi*dhi*ice_ref_salinity*p001/dt
endif
fhocnn = fhocnn + fadvocn ! for ktherm=2
if (hin == c0) then
if (tr_pond_topo) fpond = fpond - aicen * apond * hpond
endif
!-----------------------------------------------------------------
! Given the vertical thermo state variables, compute the new ice
! state variables.
!-----------------------------------------------------------------
call update_state_vthermo(Tbot, Tsf, &
hin, hsn, &
zqin, zSin, &
zqsn, &
aicen, &
vicen, vsnon)
if (icepack_warnings_aborted(subname)) return
end subroutine thermo_vertical
!=======================================================================
!
! Compute heat flux to bottom surface.
! Compute fraction of ice that melts laterally.
!
! authors C. M. Bitz, UW
! William H. Lipscomb, LANL
! Elizabeth C. Hunke, LANL
subroutine frzmlt_bottom_lateral (dt, &
aice, frzmlt, &
vicen, vsnon, &
qicen, qsnon, &
sst, Tf, &
ustar_min, &
fbot_xfer_type, &
strocnxT, strocnyT, &
Tbot, fbot, &
rsiden, Cdn_ocn, &
wlat, aicen, &
afsdn)
real (kind=dbl_kind), intent(in) :: &
dt ! time step
real (kind=dbl_kind), intent(in) :: &
aice , & ! ice concentration
frzmlt , & ! freezing/melting potential (W/m^2)
sst , & ! sea surface temperature (C)
Tf , & ! freezing temperature (C)
ustar_min,& ! minimum friction velocity for ice-ocean heat flux
Cdn_ocn , & ! ocean-ice neutral drag coefficient
strocnxT, & ! ice-ocean stress, x-direction
strocnyT ! ice-ocean stress, y-direction
character (char_len), intent(in) :: &
fbot_xfer_type ! transfer coefficient type for ice-ocean heat flux
real (kind=dbl_kind), dimension(:), intent(in) :: &
vicen , & ! ice volume (m)
vsnon ! snow volume (m)
real (kind=dbl_kind), dimension(:,:), intent(in) :: &
qicen , & ! ice layer enthalpy (J m-3)
qsnon ! snow layer enthalpy (J m-3)
real (kind=dbl_kind), intent(out) :: &
Tbot , & ! ice bottom surface temperature (deg C)
fbot ! heat flux to ice bottom (W/m^2)
real (kind=dbl_kind), dimension(:), intent(out) :: &
rsiden ! fraction of ice that melts laterally
real (kind=dbl_kind), intent(out), optional :: &
wlat ! lateral melt rate (m/s)
real (kind=dbl_kind), dimension(:), intent(in) :: &
aicen ! ice concentration
real (kind=dbl_kind), dimension (:,:), intent(in), optional :: &
afsdn ! area floe size distribution
! local variables
real (kind=dbl_kind), dimension (ncat) :: &
delta_an , & ! change in the ITD
G_radialn ! lateral melt rate in FSD (m/s)
real (kind=dbl_kind) :: &
rside , & !
fside ! lateral heat flux (W/m^2)
integer (kind=int_kind) :: &
n , & ! thickness category index
k ! layer index
real (kind=dbl_kind) :: &
etot , & ! total energy in column
wlat_loc, & ! lateral melt rate (m/s)
qavg ! average enthalpy in column (approximate)
real (kind=dbl_kind) :: &
deltaT , & ! SST - Tbot >= 0
ustar , & ! skin friction velocity for fbot (m/s)
bin1_arealoss, &
xtmp ! temporary variable
! Parameters for bottom melting
real (kind=dbl_kind) :: &
cpchr ! -cp_ocn*rhow*exchange coefficient
! Parameters for lateral melting
real (kind=dbl_kind), parameter :: &
m1 = 1.6e-6_dbl_kind , & ! constant from Maykut & Perovich
! (m/s/deg^(-m2))
m2 = 1.36_dbl_kind ! constant from Maykut & Perovich
! (unitless)
character(len=*),parameter :: subname='(frzmlt_bottom_lateral)'
!-----------------------------------------------------------------
! Identify grid cells where ice can melt.
!-----------------------------------------------------------------
rsiden(:) = c0
Tbot = Tf
fbot = c0
wlat_loc = c0
if (present(wlat)) wlat=c0
if (aice > puny .and. frzmlt < c0) then ! ice can melt
!-----------------------------------------------------------------
! Use boundary layer theory for fbot.
! See Maykut and McPhee (1995): JGR, 100, 24,691-24,703.
!-----------------------------------------------------------------
deltaT = max((sst-Tbot),c0)
! strocnx has units N/m^2 so strocnx/rho has units m^2/s^2
ustar = sqrt (sqrt(strocnxT**2+strocnyT**2)/rhow)
ustar = max (ustar,ustar_min)
if (trim(fbot_xfer_type) == 'Cdn_ocn') then
! Note: Cdn_ocn has already been used for calculating ustar
! (formdrag only) --- David Schroeder (CPOM)
cpchr = -cp_ocn*rhow*Cdn_ocn
else ! fbot_xfer_type == 'constant'
! 0.006 = unitless param for basal heat flx ala McPhee and Maykut
cpchr = -cp_ocn*rhow*0.006_dbl_kind
endif
fbot = cpchr * deltaT * ustar ! < 0
fbot = max (fbot, frzmlt) ! frzmlt < fbot < 0
!!! uncomment to use all frzmlt for standalone runs
! fbot = min (c0, frzmlt)
!-----------------------------------------------------------------
! Compute rside. See these references:
! Maykut and Perovich (1987): JGR, 92, 7032-7044
! Steele (1992): JGR, 97, 17,729-17,738
!-----------------------------------------------------------------
wlat_loc = m1 * deltaT**m2 ! Maykut & Perovich
rside = wlat_loc*dt*pi/(floeshape*floediam) ! Steele
rside = max(c0,min(rside,c1))
if (rside == c0) return ! nothing more to do so get out
rsiden(:) = rside
if (tr_fsd) then ! alter rsiden now since floes are not of size floediam
do n = 1, ncat
G_radialn(n) = -wlat_loc ! negative
! afsdn present check up the calling tree
if (any(afsdn(:,n) < c0)) then
write(warnstr,*) subname, 'lateral_melt B afsd < 0 ',n
call icepack_warnings_add(warnstr)
endif
bin1_arealoss = -afsdn(1,n) / floe_binwidth(1) ! when scaled by *G_radialn(n)*dt*aicen(n)
delta_an(n) = c0
do k = 1, nfsd
! this is delta_an(n) when scaled by *G_radialn(n)*dt*aicen(n)
delta_an(n) = delta_an(n) + ((c2/floe_rad_c(k)) * afsdn(k,n)) ! delta_an < 0
end do
! add negative area loss from fsd
delta_an(n) = (delta_an(n) - bin1_arealoss)*G_radialn(n)*dt
if (delta_an(n) > c0) then
write(warnstr,*) subname, 'ERROR delta_an > 0 ',delta_an(n)
call icepack_warnings_add(warnstr)
endif
! following original code, not necessary for fsd
if (aicen(n) > c0) rsiden(n) = MIN(-delta_an(n),c1)
if (rsiden(n) < c0) then
write(warnstr,*) subname, 'ERROR rsiden < 0 ',rsiden(n)
call icepack_warnings_add(warnstr)
endif
enddo ! ncat
endif ! if tr_fsd
!-----------------------------------------------------------------
! Compute heat flux associated with this value of rside.
!-----------------------------------------------------------------
fside = c0
do n = 1, ncat
etot = c0
! melting energy/unit area in each column, etot < 0
do k = 1, nslyr
etot = etot + qsnon(k,n) * vsnon(n)/real(nslyr,kind=dbl_kind)
enddo
do k = 1, nilyr
etot = etot + qicen(k,n) * vicen(n)/real(nilyr,kind=dbl_kind)
enddo ! nilyr
! lateral heat flux, fside < 0
fside = fside + rsiden(n)*etot/dt
enddo ! n
!-----------------------------------------------------------------
! Limit bottom and lateral heat fluxes if necessary.
! Limit rside so we don't melt laterally more ice than frzmlt permits
!-----------------------------------------------------------------
xtmp = frzmlt/(fbot + fside - puny)
xtmp = min(xtmp, c1)
xtmp = max(xtmp, c0)
fbot = fbot * xtmp
do n = 1, ncat
rsiden(n) = rsiden(n) * xtmp ! xtmp is almost always 1 so usually nothing happens here
enddo ! ncat
endif
if (present(wlat)) wlat=wlat_loc
end subroutine frzmlt_bottom_lateral
!=======================================================================
!
! Given the state variables (vicen, vsnon, zqin, etc.),
! compute variables needed for the vertical thermodynamics
! (hin, hsn, zTin, etc.)
!
! authors William H. Lipscomb, LANL
! C. M. Bitz, UW
subroutine init_vertical_profile(aicen, vicen, &
vsnon, &
hin, hilyr, &
hsn, hslyr, &
zqin, zTin, &
zqsn, zTsn, &
zSin, &
einit )
real (kind=dbl_kind), intent(in) :: &
aicen , & ! concentration of ice
vicen , & ! volume per unit area of ice (m)
vsnon ! volume per unit area of snow (m)
real (kind=dbl_kind), intent(out):: &
hilyr , & ! ice layer thickness
hslyr , & ! snow layer thickness
einit ! initial energy of melting (J m-2)
real (kind=dbl_kind), intent(out):: &
hin , & ! ice thickness (m)
hsn ! snow thickness (m)
real (kind=dbl_kind), dimension (:), intent(inout) :: &
zqin , & ! ice layer enthalpy (J m-3)
zTin ! internal ice layer temperatures
real (kind=dbl_kind), dimension (:), intent(in) :: &
zSin ! internal ice layer salinities
real (kind=dbl_kind), dimension (:), intent(inout) :: &
zqsn , & ! snow enthalpy
zTsn ! snow temperature
! local variables
real (kind=dbl_kind), dimension(nilyr) :: &
Tmlts ! melting temperature
integer (kind=int_kind) :: &
k ! ice layer index
real (kind=dbl_kind) :: &
rnslyr, & ! real(nslyr)
Tmax ! maximum allowed snow/ice temperature (deg C)
logical (kind=log_kind) :: & ! for vector-friendly error checks
tsno_high , & ! flag for zTsn > Tmax
tice_high , & ! flag for zTin > Tmlt
tsno_low , & ! flag for zTsn < Tmin
tice_low ! flag for zTin < Tmin
character(len=*),parameter :: subname='(init_vertical_profile)'
!-----------------------------------------------------------------
! Initialize
!-----------------------------------------------------------------
rnslyr = real(nslyr,kind=dbl_kind)
tsno_high = .false.
tice_high = .false.
tsno_low = .false.
tice_low = .false.
einit = c0
!-----------------------------------------------------------------
! Surface temperature, ice and snow thickness
! Initialize internal energy
!-----------------------------------------------------------------
hin = vicen / aicen
hsn = vsnon / aicen
hilyr = hin / real(nilyr,kind=dbl_kind)
hslyr = hsn / rnslyr
!-----------------------------------------------------------------
! Snow enthalpy and maximum allowed snow temperature
!-----------------------------------------------------------------
do k = 1, nslyr
!-----------------------------------------------------------------
! Tmax based on the idea that dT ~ dq / (rhos*cp_ice)
! dq ~ q dv / v
! dv ~ puny = eps11
! where 'd' denotes an error due to roundoff.
!-----------------------------------------------------------------
if (hslyr > hs_min/rnslyr) then
! zqsn < 0
Tmax = -zqsn(k)*puny*rnslyr / &
(rhos*cp_ice*vsnon)
else
zqsn (k) = -rhos * Lfresh
Tmax = puny
endif
!-----------------------------------------------------------------
! Compute snow temperatures from enthalpies.
! Note: zqsn <= -rhos*Lfresh, so zTsn <= 0.
!-----------------------------------------------------------------
zTsn(k) = (Lfresh + zqsn(k)/rhos)/cp_ice
!-----------------------------------------------------------------
! Check for zTsn > Tmax (allowing for roundoff error) and zTsn < Tmin.
!-----------------------------------------------------------------
if (zTsn(k) > Tmax) then
tsno_high = .true.
elseif (zTsn(k) < Tmin) then
tsno_low = .true.
endif
enddo ! nslyr
!-----------------------------------------------------------------
! If zTsn is out of bounds, print diagnostics and exit.
!-----------------------------------------------------------------
if (tsno_high) then
do k = 1, nslyr
if (hslyr > hs_min/rnslyr) then
Tmax = -zqsn(k)*puny*rnslyr / &
(rhos*cp_ice*vsnon)
else
Tmax = puny
endif
if (zTsn(k) > Tmax) then
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Starting thermo, zTsn > Tmax'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zTsn=',zTsn(k)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Tmax=',Tmax
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zqsn',zqsn(k),-Lfresh*rhos,zqsn(k)+Lfresh*rhos
call icepack_warnings_add(warnstr)
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//" init_vertical_profile: Starting thermo, zTsn > Tmax" )
return
endif
enddo ! nslyr
endif ! tsno_high
if (tsno_low) then
do k = 1, nslyr
if (zTsn(k) < Tmin) then ! allowing for roundoff error
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Starting thermo, zTsn < Tmin'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zTsn=', zTsn(k)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Tmin=', Tmin
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zqsn', zqsn(k)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, hin
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, hsn
call icepack_warnings_add(warnstr)
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//" init_vertical_profile: Starting thermo, zTsn < Tmin" )
return
endif
enddo ! nslyr
endif ! tsno_low
do k = 1, nslyr
if (zTsn(k) > c0) then ! correct roundoff error
zTsn(k) = c0
zqsn(k) = -rhos*Lfresh
endif
!-----------------------------------------------------------------
! initial energy per unit area of ice/snow, relative to 0 C
!-----------------------------------------------------------------
einit = einit + hslyr*zqsn(k)
enddo ! nslyr
do k = 1, nilyr
!---------------------------------------------------------------------
! Use initial salinity profile for thin ice
!---------------------------------------------------------------------
if (ktherm == 1 .and. zSin(k) < min_salin-puny) then
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Starting zSin < min_salin, layer', k
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zSin =', zSin(k)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'min_salin =', min_salin
call icepack_warnings_add(warnstr)
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//" init_vertical_profile: Starting zSin < min_salin, layer" )
return
endif
if (ktherm == 2) then
Tmlts(k) = liquidus_temperature_mush(zSin(k))
else
Tmlts(k) = -zSin(k) * depressT
endif
!-----------------------------------------------------------------
! Compute ice temperatures from enthalpies using quadratic formula
!-----------------------------------------------------------------
if (ktherm == 2) then
zTin(k) = icepack_mushy_temperature_mush(zqin(k),zSin(k))
else
zTin(k) = calculate_Tin_from_qin(zqin(k),Tmlts(k))
endif
if (l_brine) then
Tmax = Tmlts(k)
else ! fresh ice
Tmax = -zqin(k)*puny/(rhos*cp_ice*vicen)
endif
!-----------------------------------------------------------------
! Check for zTin > Tmax and zTin < Tmin
!-----------------------------------------------------------------
if (zTin(k) > Tmax) then
tice_high = .true.
elseif (zTin(k) < Tmin) then
tice_low = .true.
endif
!-----------------------------------------------------------------
! If zTin is out of bounds, print diagnostics and exit.
!-----------------------------------------------------------------
if (tice_high) then
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Starting thermo, zTin > Tmax, layer', k
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'k:', k
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zTin =',zTin(k),', Tmax=',Tmax
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zSin =',zSin(k)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'hin =',hin
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zqin =',zqin(k)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'qmlt=',enthalpy_of_melting(zSin(k))
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Tmlt=',Tmlts(k)
call icepack_warnings_add(warnstr)
if (ktherm == 2) then
zqin(k) = enthalpy_of_melting(zSin(k)) - c1
zTin(k) = icepack_mushy_temperature_mush(zqin(k),zSin(k))
write(warnstr,*) subname, 'Corrected quantities'
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zqin=',zqin(k)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zTin=',zTin(k)
call icepack_warnings_add(warnstr)
else
call icepack_warnings_setabort(.true.,__FILE__,__LINE__)
call icepack_warnings_add(subname//" init_vertical_profile: Starting thermo, zTin > Tmax, layer" )
return
endif
endif ! tice_high
if (tice_low) then
write(warnstr,*) ' '
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Starting thermo T < Tmin, layer', k
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'zTin =', zTin(k)
call icepack_warnings_add(warnstr)
write(warnstr,*) subname, 'Tmin =', Tmin