-
Notifications
You must be signed in to change notification settings - Fork 13
/
ice_therm_vertical.F90
2542 lines (2090 loc) · 94.9 KB
/
ice_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
! SVN:$Id: ice_therm_vertical.F90 925 2015-03-04 00:34:27Z eclare $
!=========================================================================
!
! 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 ice_therm_vertical computes vertical growth rates and coupler
! fluxes. Then ice_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 ice_therm_vertical
use ice_kinds_mod
use ice_domain_size, only: ncat, nilyr, nslyr, max_ntrcr, max_blocks
use ice_calendar, only: istep1
use ice_constants
use ice_fileunits, only: nu_diag
use ice_state, only: tr_iage, tr_pond_topo, nt_apnd, nt_hpnd, tr_pond, &
nt_Tsfc, nt_iage, nt_sice, nt_qice, nt_qsno, &
nt_apnd, nt_hpnd
use ice_therm_shared, only: ktherm, ferrmax, heat_capacity, l_brine, &
calc_Tsfc, calculate_tin_from_qin, Tmin
use ice_therm_bl99, only: temperature_changes
use ice_therm_0layer, only: zerolayer_temperature
use ice_flux, only: Tf
use ice_zbgc_shared, only: min_salin
implicit none
save
private
public :: init_thermo_vertical, frzmlt_bottom_lateral, thermo_vertical
real (kind=dbl_kind), parameter, public :: &
saltmax = 3.2_dbl_kind, & ! max salinity at ice base for BL99 (ppt)
! phi_init and dSin0_frazil are used for mushy thermo, ktherm=2
phi_init = 0.75_dbl_kind, & ! initial liquid fraction of frazil
dSin0_frazil = c3 ! bulk salinity reduction of newly formed frazil
real (kind=dbl_kind), public :: &
!#if defined(AusCOM) || defined(ACCICE)
#ifdef AusCOM
ustar_min , & ! minimum friction velocity for ice-ocean heat flux
chio ! default 0.006 = unitless param for basal heat flx ala McPhee and Maykut
#else
ustar_min ! minimum friction velocity for ice-ocean heat flux
#endif
character (len=char_len), public :: &
fbot_xfer_type ! transfer coefficient type for ice-ocean heat flux
!=======================================================================
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 (nx_block, ny_block, &
dt, icells, &
indxi, indxj, &
aicen, trcrn, &
vicen, vsnon, &
flw, potT, &
Qa, rhoa, &
fsnow, fpond, &
fbot, Tbot, &
sss, &
lhcoef, shcoef, &
fswsfc, fswint, &
Sswabs, Iswabs, &
fsurfn, fcondtopn, &
fsensn, flatn, &
flwoutn, evapn, &
freshn, fsaltn, &
fhocnn, meltt, &
melts, meltb, &
congel, snoice, &
mlt_onset, frz_onset, &
yday, l_stop, &
istop, jstop, &
dsnow)
use ice_communicate, only: my_task
use ice_therm_mushy, only: temperature_changes_salinity
#ifdef CCSMCOUPLED
use ice_prescribed_mod, only: prescribed_ice
#endif
integer (kind=int_kind), intent(in) :: &
nx_block, ny_block, & ! block dimensions
icells ! number of cells with ice present
integer (kind=int_kind), dimension (nx_block*ny_block), &
intent(in) :: &
indxi, indxj ! compressed indices for cells with ice
real (kind=dbl_kind), intent(in) :: &
dt ! time step
! ice state variables
real (kind=dbl_kind), dimension (nx_block,ny_block), &
intent(inout) :: &
aicen , & ! concentration of ice
vicen , & ! volume per unit area of ice (m)
vsnon ! volume per unit area of snow (m)
real (kind=dbl_kind), dimension (nx_block,ny_block,max_ntrcr), &
intent(inout) :: &
trcrn
! input from atmosphere
real (kind=dbl_kind), dimension (nx_block,ny_block), &
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), dimension (nx_block,ny_block), &
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 (nx_block,ny_block,nslyr), &
intent(inout) :: &
Sswabs ! SW radiation absorbed in snow layers (W m-2)
real (kind=dbl_kind), dimension (nx_block,ny_block,nilyr), &
intent(inout) :: &
Iswabs ! SW radiation absorbed in ice layers (W m-2)
! input from ocean
real (kind=dbl_kind), dimension (nx_block,ny_block), intent(in) :: &
fbot , & ! ice-ocean heat flux at bottom surface (W/m^2)
Tbot , & ! ice bottom surface temperature (deg C)
sss ! ocean salinity
! coupler fluxes to atmosphere
real (kind=dbl_kind), dimension (nx_block,ny_block), intent(out):: &
flwoutn , & ! outgoing longwave radiation (W/m^2)
evapn ! evaporative water flux (kg/m^2/s)
! Note: these are intent out if calc_Tsfc = T, otherwise intent in
real (kind=dbl_kind), dimension (nx_block,ny_block), 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)
! coupler fluxes to ocean
real (kind=dbl_kind), dimension (nx_block,ny_block), 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), dimension(nx_block,ny_block), &
intent(inout):: &
meltt , & ! top ice melt (m/step-->cm/day)
melts , & ! snow melt (m/step-->cm/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
logical (kind=log_kind), intent(out) :: &
l_stop ! if true, print diagnostics and abort on return
integer (kind=int_kind), intent(out) :: &
istop, jstop ! indices of grid cell where code aborts
! local variables
integer (kind=int_kind) :: &
i, j , & ! horizontal indices
ij , & ! horizontal index, combines i and j loops
k ! ice layer index
real (kind=dbl_kind) :: &
dhi , & ! change in ice thickness
dhs ! change in snow thickness
! 2D state variables (thickness, temperature, enthalpy)
real (kind=dbl_kind), dimension (icells) :: &
hilyr , & ! ice layer thickness
hslyr , & ! snow layer thickness
Tsf , & ! ice/snow top surface temp, same as Tsfcn (deg C)
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 (icells,nilyr) :: &
zqin , & ! ice layer enthalpy, zqin < 0 (J m-3)
zTin , & ! internal ice layer temperatures
zSin ! internal ice layer salinities
real (kind=dbl_kind), dimension (icells,nslyr) :: &
zqsn , & ! snow layer enthalpy, zqsn < 0 (J m-3)
zTsn ! internal snow layer temperatures
! other 2D flux and energy variables
real (kind=dbl_kind), dimension (icells) :: &
fcondbot , & ! downward cond flux at bottom surface (W m-2)
einit , & ! initial energy of melting (J m-2)
efinal , & ! final energy of melting (J m-2)
einter ! intermediate energy
! echmod: reduce size to icells?
real (kind=dbl_kind), dimension (nx_block,ny_block) :: &
iage ! ice age (s)
real (kind=dbl_kind), dimension (nx_block,ny_block) :: &
fadvocn ! advective heat flux to ocean
!-----------------------------------------------------------------
! Initialize
!-----------------------------------------------------------------
l_stop = .false.
istop = 0
jstop = 0
do j=1, ny_block
do i=1, nx_block
flwoutn(i,j) = c0
evapn (i,j) = c0
freshn (i,j) = c0
fsaltn (i,j) = c0
fhocnn (i,j) = c0
fadvocn(i,j) = c0
meltt (i,j) = c0
meltb (i,j) = c0
melts (i,j) = c0
congel (i,j) = c0
snoice (i,j) = c0
dsnow (i,j) = c0
if (tr_iage) iage(i,j) = trcrn(i,j,nt_iage)
enddo
enddo
if (calc_Tsfc) then
do j=1, ny_block
do i=1, nx_block
fsensn (i,j) = c0
flatn (i,j) = c0
fsurfn (i,j) = c0
fcondtopn(i,j) = c0
enddo
enddo
endif
!-----------------------------------------------------------------
! Compute variables needed for vertical thermo calculation
!-----------------------------------------------------------------
call init_vertical_profile (nx_block, ny_block, &
my_task, istep1, &
icells, &
indxi, indxj, &
aicen(:,:), &
vicen(:,:), vsnon(:,:), &
trcrn(:,:,:), &
hin, hilyr, &
hsn, hslyr, &
zqin, zTin, &
zqsn, zTsn, &
zSin, &
Tsf, einit, &
Tbot, l_stop, &
istop, jstop)
if (l_stop) return
do ij = 1, icells
! Save initial ice and snow thickness (for fresh and fsalt)
worki(ij) = hin(ij)
works(ij) = hsn(ij)
enddo
!-----------------------------------------------------------------
! Compute new surface temperature and internal ice and snow
! temperatures.
!-----------------------------------------------------------------
if (heat_capacity) then ! usual case
if (ktherm == 2) then
call temperature_changes_salinity(nx_block, ny_block, &
my_task, istep1, &
dt, icells, &
indxi, indxj, &
rhoa, flw, &
potT, Qa, &
shcoef, lhcoef, &
fswsfc, fswint, &
Sswabs, Iswabs, &
hilyr, hslyr, &
zqin, zTin, &
zqsn, zTsn, &
zSin, &
trcrn, &
Tsf, Tbot, &
sss, &
fsensn, flatn, &
flwoutn, fsurfn, &
fcondtopn, fcondbot, &
fadvocn, snoice, &
einit, l_stop, &
istop, jstop)
else ! ktherm
call temperature_changes(nx_block, ny_block, &
my_task, istep1, &
dt, icells, &
indxi, indxj, &
rhoa, flw, &
potT, Qa, &
shcoef, lhcoef, &
fswsfc, fswint, &
Sswabs, Iswabs, &
hilyr, hslyr, &
zqin, zTin, &
zqsn, zTsn, &
zSin, &
Tsf, Tbot, &
fsensn, flatn, &
flwoutn, fsurfn, &
fcondtopn, fcondbot, &
einit, l_stop, &
istop, jstop)
endif ! ktherm
else
if (calc_Tsfc) then
call zerolayer_temperature(nx_block, ny_block, &
my_task, istep1, &
dt, icells, &
indxi, indxj, &
rhoa, flw, &
potT, Qa, &
shcoef, lhcoef, &
fswsfc, &
hilyr, hslyr, &
Tsf, Tbot, &
fsensn, flatn, &
flwoutn, fsurfn, &
fcondtopn, fcondbot, &
l_stop, &
istop, jstop)
else
!------------------------------------------------------------
! Set fcondbot = fcondtop for zero layer thermodynamics
! fcondtop is set in call to set_sfcflux in step_therm1
!------------------------------------------------------------
do ij = 1, icells
i = indxi(ij)
j = indxj(ij)
fcondbot(ij) = fcondtopn(i,j) ! zero layer
enddo
endif ! calc_Tsfc
endif ! heat_capacity
! intermediate energy for error check
do ij = 1, icells
einter(ij) = c0
do k = 1, nslyr
einter(ij) = einter(ij) + hslyr(ij) * zqsn(ij,k)
enddo ! k
do k = 1, nilyr
einter(ij) = einter(ij) + hilyr(ij) * zqin(ij,k)
enddo ! k
enddo ! ij
if (l_stop) 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(nx_block, ny_block, &
dt, &
yday, icells, &
indxi, indxj, &
efinal, &
hin, hilyr, &
hsn, hslyr, &
zqin, zqsn, &
fbot, Tbot, &
flatn, fsurfn, &
fcondtopn, fcondbot, &
fsnow, hsn_new, &
fhocnn, evapn, &
meltt, melts, &
meltb, iage, &
congel, snoice, &
mlt_onset, frz_onset,&
zSin, sss, &
dsnow)
!-----------------------------------------------------------------
! Check for energy conservation by comparing the change in energy
! to the net energy input
!-----------------------------------------------------------------
call conservation_check_vthermo(nx_block, ny_block, &
my_task, istep1, &
dt, icells, &
indxi, indxj, &
fsurfn, flatn, &
fhocnn, fswint, &
fsnow, einit, &
einter, efinal, &
fcondtopn,fcondbot, &
fadvocn, &
fbot, l_stop, &
istop, jstop)
if (l_stop) return
!-----------------------------------------------------------------
! If prescribed ice, set hi back to old values
!-----------------------------------------------------------------
#ifdef CCSMCOUPLED
if (prescribed_ice) then
do ij = 1, icells
i = indxi(ij)
j = indxj(ij)
hin(ij) = worki(ij)
fhocnn(i,j) = c0 ! for diagnostics
enddo ! ij
endif
#endif
!-----------------------------------------------------------------
! Compute fluxes of water and salt from ice to ocean.
! evapn < 0 => sublimation, evapn > 0 => condensation
! aerosol flux is accounted for in ice_aerosol.F90
!-----------------------------------------------------------------
do ij = 1, icells
i = indxi(ij)
j = indxj(ij)
dhi = hin(ij) - worki(ij)
dhs = hsn(ij) - works(ij) - hsn_new(ij)
freshn(i,j) = freshn(i,j) + &
evapn(i,j) - &
(rhoi*dhi + rhos*dhs) / dt
fsaltn(i,j) = fsaltn(i,j) - &
rhoi*dhi*ice_ref_salinity*p001/dt
fhocnn(i,j) = fhocnn(i,j) + fadvocn(i,j) ! for ktherm=2
if (hin(ij) == c0) then
if (tr_pond_topo) &
fpond(i,j) = fpond(i,j) - aicen(i,j) &
* trcrn(i,j,nt_apnd) * trcrn(i,j,nt_hpnd)
endif
enddo ! ij
!-----------------------------------------------------------------
! Given the vertical thermo state variables, compute the new ice
! state variables.
!-----------------------------------------------------------------
call update_state_vthermo(nx_block, ny_block, &
icells, &
indxi, indxj, &
Tbot, Tsf, &
hin, hsn, &
zqin, zSin, &
zqsn, &
aicen(:,:), &
vicen(:,:), vsnon(:,:), &
trcrn(:,:,:))
!-----------------------------------------------------------------
! Reload passive tracer array
!-----------------------------------------------------------------
do j = 1, ny_block
do i = 1, nx_block
if (tr_iage) trcrn(i,j,nt_iage) = iage(i,j)
enddo
enddo
end subroutine thermo_vertical
!=======================================================================
!
! Initialize the vertical profile of ice salinity and melting temperature.
!
! authors: C. M. Bitz, UW
! William H. Lipscomb, LANL
subroutine init_thermo_vertical
use ice_blocks, only: nx_block, ny_block
use ice_flux, only: salinz, Tmltz, sss
integer (kind=int_kind) :: &
i, j, iblk ! horizontal indices
real (kind=dbl_kind), parameter :: &
nsal = 0.407_dbl_kind, &
msal = 0.573_dbl_kind
integer (kind=int_kind) :: k ! ice layer index
real (kind=dbl_kind) :: zn ! normalized ice thickness
!-----------------------------------------------------------------
! Determine l_brine based on saltmax.
! Thermodynamic solver will not converge if l_brine is true and
! saltmax is close to zero.
! Set l_brine to false for zero layer thermodynamics
!-----------------------------------------------------------------
heat_capacity = .true.
if (ktherm == 0) heat_capacity = .false. ! 0-layer thermodynamics
l_brine = .false.
if (saltmax > min_salin .and. heat_capacity) l_brine = .true.
!-----------------------------------------------------------------
! Prescibe vertical profile of salinity and melting temperature.
! Note this profile is only used for BL99 thermodynamics.
!-----------------------------------------------------------------
!$OMP PARALLEL DO PRIVATE(iblk,i,j,k,zn)
do iblk = 1,max_blocks
do j = 1, ny_block
do i = 1, nx_block
if (l_brine) then
do k = 1, nilyr
zn = (real(k,kind=dbl_kind)-p5) / &
real(nilyr,kind=dbl_kind)
salinz(i,j,k,iblk)=(saltmax/c2)*(c1-cos(pi*zn**(nsal/(msal+zn))))
salinz(i,j,k,iblk) = max(salinz(i,j,k,iblk), min_salin)
Tmltz (i,j,k,iblk) = -salinz(i,j,k,iblk)*depressT
enddo ! k
salinz(i,j,nilyr+1,iblk) = saltmax
Tmltz(i,j,nilyr+1,iblk) = -salinz(i,j,nilyr+1,iblk)*depressT
else ! .not. l_brine
do k = 1, nilyr+1
salinz(i,j,k,iblk) = c0
Tmltz(i,j,k,iblk) = c0
enddo
endif ! l_brine
enddo !i
enddo !j
enddo !iblk
!$OMP END PARALLEL DO
end subroutine init_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 (nx_block, ny_block, &
ilo, ihi, jlo, jhi, &
ntrcr, dt, &
aice, frzmlt, &
vicen, vsnon, &
trcrn, &
sst, Tf, &
strocnxT, strocnyT, &
Tbot, fbot, &
rside, Cdn_ocn)
integer (kind=int_kind), intent(in) :: &
nx_block, ny_block, & ! block dimensions
ilo,ihi,jlo,jhi , & ! beginning and end of physical domain
ntrcr ! number of tracers
real (kind=dbl_kind), intent(in) :: &
dt ! time step
real (kind=dbl_kind), dimension(nx_block,ny_block), intent(in) :: &
aice , & ! ice concentration
frzmlt , & ! freezing/melting potential (W/m^2)
sst , & ! sea surface temperature (C)
Tf , & ! freezing temperature (C)
Cdn_ocn , & ! ocean-ice neutral drag coefficient
strocnxT, & ! ice-ocean stress, x-direction
strocnyT ! ice-ocean stress, y-direction
real (kind=dbl_kind), dimension(nx_block,ny_block,ncat), &
intent(in) :: &
vicen , & ! ice volume (m)
vsnon ! snow volume (m)
real (kind=dbl_kind), dimension(nx_block,ny_block,ntrcr,ncat), &
intent(in) :: &
trcrn ! tracer array
real (kind=dbl_kind), dimension(nx_block,ny_block), &
intent(out) :: &
Tbot , & ! ice bottom surface temperature (deg C)
fbot , & ! heat flux to ice bottom (W/m^2)
rside ! fraction of ice that melts laterally
! local variables
integer (kind=int_kind) :: &
i, j , & ! horizontal indices
n , & ! thickness category index
k , & ! layer index
ij , & ! horizontal index, combines i and j loops
imelt ! number of cells with ice melting
integer (kind=int_kind), dimension (nx_block*ny_block) :: &
indxi, indxj ! compressed indices for cells with ice melting
real (kind=dbl_kind), dimension (:), allocatable :: &
etot , & ! total energy in column
fside ! lateral heat flux (W/m^2)
real (kind=dbl_kind) :: &
deltaT , & ! SST - Tbot >= 0
ustar , & ! skin friction velocity for fbot (m/s)
wlat , & ! lateral melt rate (m/s)
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 :: &
floediam = 300.0_dbl_kind, & ! effective floe diameter (m)
floeshape = 0.66_dbl_kind , & ! constant from Steele (unitless)
m1 = 1.6e-6_dbl_kind , & ! constant from Maykut & Perovich
! (m/s/deg^(-m2))
m2 = 1.36_dbl_kind ! constant from Maykut & Perovich
! (unitless)
!#if defined(AusCOM) || defined(ACCICE)
#ifdef AusCOM
cpchr = -cp_ocn*rhow*chio
#endif
do j = 1, ny_block
do i = 1, nx_block
rside(i,j) = c0
Tbot (i,j) = Tf(i,j)
fbot (i,j) = c0
enddo
enddo
!-----------------------------------------------------------------
! Identify grid cells where ice can melt.
!-----------------------------------------------------------------
imelt = 0
do j = jlo, jhi
do i = ilo, ihi
if (aice(i,j) > puny .and. frzmlt(i,j) < c0) then ! ice can melt
imelt = imelt + 1
indxi(imelt) = i
indxj(imelt) = j
endif
enddo ! i
enddo ! j
allocate(etot (imelt))
allocate(fside(imelt))
do ij = 1, imelt ! cells where ice can melt
i = indxi(ij)
j = indxj(ij)
fside(ij) = c0
!-----------------------------------------------------------------
! Use boundary layer theory for fbot.
! See Maykut and McPhee (1995): JGR, 100, 24,691-24,703.
!-----------------------------------------------------------------
deltaT = max((sst(i,j)-Tbot(i,j)),c0)
! strocnx has units N/m^2 so strocnx/rho has units m^2/s^2
ustar = sqrt (sqrt(strocnxT(i,j)**2+strocnyT(i,j)**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(i,j)
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(i,j) = cpchr * deltaT * ustar ! < 0
fbot(i,j) = max (fbot(i,j), frzmlt(i,j)) ! frzmlt < fbot < 0
!!! uncomment to use all frzmlt for standalone runs
! fbot(i,j) = min (c0, frzmlt(i,j))
!-----------------------------------------------------------------
! Compute rside. See these references:
! Maykut and Perovich (1987): JGR, 92, 7032-7044
! Steele (1992): JGR, 97, 17,729-17,738
!-----------------------------------------------------------------
wlat = m1 * deltaT**m2 ! Maykut & Perovich
rside(i,j) = wlat*dt*pi/(floeshape*floediam) ! Steele
rside(i,j) = max(c0,min(rside(i,j),c1))
enddo ! ij
!-----------------------------------------------------------------
! Compute heat flux associated with this value of rside.
!-----------------------------------------------------------------
do n = 1, ncat
do ij = 1, imelt
etot(ij) = c0
enddo
! melting energy/unit area in each column, etot < 0
do k = 1, nslyr
!DIR$ CONCURRENT !Cray
!cdir nodep !NEC
!ocl novrec !Fujitsu
do ij = 1, imelt
i = indxi(ij)
j = indxj(ij)
etot(ij) = etot(ij) + trcrn(i,j,nt_qsno+k-1,n) &
* vsnon(i,j,n)/real(nslyr,kind=dbl_kind)
enddo ! ij
enddo
do k = 1, nilyr
!DIR$ CONCURRENT !Cray
!cdir nodep !NEC
!ocl novrec !Fujitsu
do ij = 1, imelt
i = indxi(ij)
j = indxj(ij)
etot(ij) = etot(ij) + trcrn(i,j,nt_qice+k-1,n) &
* vicen(i,j,n)/real(nilyr,kind=dbl_kind)
enddo ! ij
enddo ! nilyr
!DIR$ CONCURRENT !Cray
!cdir nodep !NEC
!ocl novrec !Fujitsu
do ij = 1, imelt
i = indxi(ij)
j = indxj(ij)
! lateral heat flux
fside(ij) = fside(ij) + rside(i,j)*etot(ij)/dt ! fside < 0
enddo ! ij
enddo ! n
!-----------------------------------------------------------------
! Limit bottom and lateral heat fluxes if necessary.
!-----------------------------------------------------------------
!DIR$ CONCURRENT !Cray
!cdir nodep !NEC
!ocl novrec !Fujitsu
do ij = 1, imelt
i = indxi(ij)
j = indxj(ij)
xtmp = frzmlt(i,j)/(fbot(i,j) + fside(ij) + puny)
xtmp = min(xtmp, c1)
fbot (i,j) = fbot (i,j) * xtmp
rside(i,j) = rside(i,j) * xtmp
enddo ! ij
deallocate(etot)
deallocate(fside)
end subroutine frzmlt_bottom_lateral
!=======================================================================
!
! Given the state variables (vicen, vsnon, trcrn)
! compute variables needed for the vertical thermodynamics
! (hin, hsn, zqin, zqsn, zTin, zTsn, Tsf).
!
! authors William H. Lipscomb, LANL
! C. M. Bitz, UW
subroutine init_vertical_profile(nx_block, ny_block, &
my_task, istep1, &
icells, &
indxi, indxj, &
aicen, vicen, &
vsnon, trcrn, &
hin, hilyr, &
hsn, hslyr, &
zqin, zTin, &
zqsn, zTsn, &
zSin, &
Tsf, einit, &
Tbot, l_stop, &
istop, jstop)
use ice_therm_mushy, only: temperature_mush, &
liquidus_temperature_mush, &
enthalpy_of_melting
integer (kind=int_kind), intent(in) :: &
nx_block, ny_block, & ! block dimensions
my_task , & ! task number (diagnostic only)
istep1 , & ! time step index (diagnostic only)
icells ! number of cells with aicen > puny
integer (kind=int_kind), dimension(nx_block*ny_block), &
intent(in) :: &
indxi, indxj ! compressed indices for cells with aicen > puny
real (kind=dbl_kind), dimension (nx_block,ny_block), 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), dimension (nx_block,ny_block,max_ntrcr), &
intent(in) :: &
trcrn ! tracer array
real (kind=dbl_kind), dimension(icells), intent(out):: &
hilyr , & ! ice layer thickness
hslyr , & ! snow layer thickness
Tsf , & ! ice/snow surface temperature, Tsfcn
einit ! initial energy of melting (J m-2)
real (kind=dbl_kind), dimension(nx_block,ny_block), intent(in):: &
Tbot ! bottom ice temp (C)
real (kind=dbl_kind), dimension(icells), intent(out):: &
hin , & ! ice thickness (m)
hsn ! snow thickness (m)
real (kind=dbl_kind), dimension (icells,nilyr), &
intent(out) :: &
zqin , & ! ice layer enthalpy (J m-3)
zTin , & ! internal ice layer temperatures
zSin ! internal ice layer salinities
real (kind=dbl_kind), dimension (icells,nslyr), &
intent(out) :: &
zqsn , & ! snow enthalpy
zTsn ! snow temperature
logical (kind=log_kind), intent(inout) :: &
l_stop ! if true, print diagnostics and abort model
integer (kind=int_kind), intent(inout) :: &
istop, jstop ! i and j indices of cell where model fails
! local variables
real (kind=dbl_kind), dimension(icells,nilyr) :: &
Tmlts ! melting temperature
integer (kind=int_kind) :: &
i, j , & ! horizontal indices
ij , & ! horizontal index, combines i and j loops
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
!-----------------------------------------------------------------
! Initialize
!-----------------------------------------------------------------
rnslyr = real(nslyr,kind=dbl_kind)
do ij = 1, icells
einit(ij) = c0
enddo
tsno_high = .false.
tice_high = .false.
tsno_low = .false.
tice_low = .false.
!-----------------------------------------------------------------
! Load arrays for vertical thermo calculation.
!-----------------------------------------------------------------
!DIR$ CONCURRENT !Cray
!cdir nodep !NEC
!ocl novrec !Fujitsu
do ij = 1, icells
i = indxi(ij)
j = indxj(ij)
!-----------------------------------------------------------------
! Surface temperature, ice and snow thickness
! Initialize internal energy
!-----------------------------------------------------------------
Tsf(ij) = trcrn(i,j,nt_Tsfc)
hin(ij) = vicen(i,j) / aicen(i,j)
hsn(ij) = vsnon(i,j) / aicen(i,j)
hilyr(ij) = hin(ij) / real(nilyr,kind=dbl_kind)
hslyr(ij) = hsn(ij) / rnslyr
enddo ! ij
!-----------------------------------------------------------------
! Snow enthalpy and maximum allowed snow temperature
! If heat_capacity = F, zqsn and zTsn are used only for checking
! conservation.
!-----------------------------------------------------------------
do k = 1, nslyr
!DIR$ CONCURRENT !Cray
!cdir nodep !NEC
!ocl novrec !Fujitsu
do ij = 1, icells
i = indxi(ij)
j = indxj(ij)
!-----------------------------------------------------------------
! 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(ij) > hs_min/rnslyr .and. heat_capacity) then
! zqsn < 0
zqsn(ij,k) = trcrn(i,j,nt_qsno+k-1)
Tmax = -zqsn(ij,k)*puny*rnslyr / &
(rhos*cp_ice*vsnon(i,j))
else
zqsn (ij,k) = -rhos * Lfresh
Tmax = puny
endif