forked from NOAA-GFDL/SIS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SIS_dyn_trans.F90
1462 lines (1291 loc) · 72.2 KB
/
SIS_dyn_trans.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
!***********************************************************************
!* GNU General Public License *
!* This file is a part of SIS2. *
!* *
!* SIS2 is free software; you can redistribute it and/or modify it and *
!* are expected to follow the terms of the GNU General Public License *
!* as published by the Free Software Foundation; either version 2 of *
!* the License, or (at your option) any later version. *
!* *
!* SIS2 is distributed in the hope that it will be useful, but WITHOUT *
!* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
!* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public *
!* License for more details. *
!* *
!* For the full text of the GNU General Public License, *
!* write to: Free Software Foundation, Inc., *
!* 675 Mass Ave, Cambridge, MA 02139, USA. *
!* or see: http://www.gnu.org/licenses/gpl.html *
!***********************************************************************
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! SIS2 is a SEA ICE MODEL for coupling through the GFDL exchange grid. SIS2 !
! is a revision of the original SIS with have extended capabilities, including !
! the option of using a B-grid or C-grid spatial discretization. The SIS2 !
! software has been extensively reformulated from SIS for greater consistency !
! with the Modular Ocean Model, version 6 (MOM6), and to permit might tighter !
! dynamical coupling between the ocean and sea-ice. !
! This module handles the main updates of the ice states at the slower time- !
! scales of the couplng or the interactions with the ocean due to ice dynamics !
! and lateral transport. !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
module SIS_dyn_trans
use SIS_diag_mediator, only : enable_SIS_averaging, disable_SIS_averaging
use SIS_diag_mediator, only : post_SIS_data, post_data=>post_SIS_data
use SIS_diag_mediator, only : query_SIS_averaging_enabled, SIS_diag_ctrl
use SIS_diag_mediator, only : register_diag_field=>register_SIS_diag_field
use MOM_checksums, only : chksum, Bchksum, hchksum, uchksum, vchksum
use SIS_error_checking, only : check_redundant_B, check_redundant_C
use SIS_sum_output, only : write_ice_statistics, SIS_sum_output_init, SIS_sum_out_CS
use mpp_domains_mod, only : domain2D
use MOM_domains, only : pass_var, pass_vector, AGRID, BGRID_NE, CGRID_NE
use MOM_domains, only : fill_symmetric_edges !, MOM_domains_init, clone_MOM_domain
! use MOM_dyn_horgrid, only : dyn_horgrid_type, create_dyn_horgrid, destroy_dyn_horgrid
use MOM_error_handler, only : SIS_error=>MOM_error, FATAL, WARNING, SIS_mesg=>MOM_mesg
use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint
use MOM_file_parser, only : get_param, read_param, log_param, log_version, param_file_type
use MOM_hor_index, only : hor_index_type ! , hor_index_init
! use MOM_string_functions, only : uppercase
use MOM_EOS, only : EOS_type, calculate_density_derivs
use fms_mod, only : clock_flag_default
! use fms_io_mod, only : restore_state, query_initialized
use fms_io_mod, only : register_restart_field, restart_file_type
use mpp_mod, only : mpp_clock_id, mpp_clock_begin, mpp_clock_end
use mpp_mod, only : CLOCK_COMPONENT, CLOCK_LOOP, CLOCK_ROUTINE
use time_manager_mod, only : time_type, time_type_to_real, get_date, get_time
use time_manager_mod, only : set_date, set_time, operator(+), operator(-)
use MOM_time_manager, only : operator(>), operator(*), operator(/), operator(/=)
use SIS_types, only : ice_state_type, ice_ocean_flux_type, fast_ice_avg_type
use SIS_types, only : ocean_sfc_state_type
use SIS_types, only : IST_chksum, IST_bounds_check
use ice_utils_mod, only : get_avg, post_avg, ice_line !, ice_grid_chksum
use SIS_hor_grid, only : SIS_hor_grid_type
use ice_grid, only : ice_grid_type
use SIS2_ice_thm, only: get_SIS2_thermo_coefs, enthalpy_liquid_freeze
use SIS2_ice_thm, only: enth_from_TS, Temp_from_En_S, T_freeze
use SIS_dyn_bgrid, only: SIS_B_dyn_CS, SIS_B_dynamics, SIS_B_dyn_init
use SIS_dyn_bgrid, only: SIS_B_dyn_register_restarts, SIS_B_dyn_end
use SIS_dyn_cgrid, only: SIS_C_dyn_CS, SIS_C_dynamics, SIS_C_dyn_init
use SIS_dyn_cgrid, only: SIS_C_dyn_register_restarts, SIS_C_dyn_end
use ice_transport_mod, only : ice_transport, ice_transport_init, ice_transport_end
use ice_transport_mod, only : ice_transport_CS
use ice_bergs, only: icebergs, icebergs_run, icebergs_init, icebergs_end
implicit none ; private
#include <SIS2_memory.h>
public :: SIS_dynamics_trans, update_icebergs, dyn_trans_CS
public :: SIS_dyn_trans_register_restarts, SIS_dyn_trans_init, SIS_dyn_trans_end
public :: SIS_dyn_trans_transport_CS, SIS_dyn_trans_sum_output_CS
public :: post_ocean_sfc_diagnostics, post_ice_state_diagnostics
type dyn_trans_CS ; private
logical :: Cgrid_dyn ! If true use a C-grid discretization of the
! sea-ice dynamics.
logical :: specified_ice ! If true, the sea ice is specified and there is
! no need for ice dynamics.
real :: dt_ice_dyn ! The time step used for the slow ice dynamics, including
! stepping the continuity equation and interactions
! between the ice mass field and velocities, in s. If
! 0 or negative, the coupling time step will be used.
logical :: do_ridging ! If true, apply a ridging scheme to the convergent
! ice. The original SIS2 implementation is based on
! work by Torge Martin. Otherwise, ice is compressed
! proportionately if the concentration exceeds 1.
logical :: berg_windstress_bug ! If true, use older code that applied an old
! ice-ocean stress to the icebergs in place of the
! current air-ice stress. This option is here for
! backward compatibility, but should be avoided.
logical :: debug ! If true, write verbose checksums for debugging purposes.
logical :: column_check ! If true, enable the heat check column by column.
real :: imb_tol ! The tolerance for imbalances to be flagged by
! column_check, nondim.
logical :: bounds_check ! If true, check for sensible values of thicknesses
! temperatures, fluxes, etc.
logical :: verbose ! A flag to control the printing of an ice-diagnostic
! message. When true, this will slow the model down.
integer :: ntrunc = 0 ! The number of times the velocity has been truncated
! since the last call to write_ice_statistics.
integer :: n_calls = 0 ! The number of times SIS_dynamics_trans has been called.
type(time_type) :: ice_stats_interval ! The interval between writes of the
! globally summed ice statistics and conservation checks.
type(time_type) :: write_ice_stats_time ! The next time to write out the ice statistics.
type(time_type), pointer :: Time ! A pointer to the ocean model's clock.
type(SIS_diag_ctrl), pointer :: diag ! A structure that is used to regulate the
! timing of diagnostic output.
integer :: id_fax=-1, id_fay=-1, id_xprt=-1, id_mib=-1, id_mi=-1
! These are the diagnostic ids for describing the ice state.
integer, dimension(:), allocatable :: id_t, id_sal
integer :: id_cn=-1, id_hi=-1, id_hp=-1, id_hs=-1, id_tsn=-1, id_tsfc=-1, id_ext=-1 ! id_hp mw/new
integer :: id_t_iceav=-1, id_s_iceav=-1, id_e2m=-1
integer :: id_rdgr=-1 ! These do not exist yet: id_rdgf=-1, id_rdgo=-1, id_rdgv=-1
integer :: id_simass=-1, id_sisnmass=-1, id_sivol=-1
integer :: id_siconc=-1, id_sithick=-1, id_sisnconc=-1, id_sisnthick=-1
integer :: id_sitemptop=-1, id_siu=-1, id_siv=-1, id_sispeed=-1, id_sitimefrac=-1
type(SIS_B_dyn_CS), pointer :: SIS_B_dyn_CSp => NULL()
type(SIS_C_dyn_CS), pointer :: SIS_C_dyn_CSp => NULL()
type(ice_transport_CS), pointer :: ice_transport_CSp => NULL()
type(SIS_sum_out_CS), pointer :: sum_output_CSp => NULL()
logical :: module_is_initialized = .false.
end type dyn_trans_CS
integer :: iceClock4, iceClock8, iceClock9, iceClocka, iceClockb, iceClockc
contains
subroutine update_icebergs(IST, OSS, IOF, FIA, icebergs_CS, dt_slow, G, IG, CS)
type(ice_state_type), intent(inout) :: IST
type(ocean_sfc_state_type), intent(in) :: OSS
type(fast_ice_avg_type), intent(inout) :: FIA
type(ice_ocean_flux_type), intent(inout) :: IOF
real, intent(in) :: dt_slow
type(icebergs), pointer :: icebergs_CS
type(SIS_hor_grid_type), intent(inout) :: G
type(ice_grid_type), intent(inout) :: IG
type(dyn_trans_CS), pointer :: CS
real, dimension(SZI_(G),SZJ_(G)) :: &
hi_avg ! The area-weighted average ice thickness, in m.
real, dimension(G%isc:G%iec, G%jsc:G%jec) :: &
windstr_x, & ! The area-weighted average ice thickness, in Pa.
windstr_y ! The area-weighted average ice thickness, in Pa.
real :: rho_ice ! The nominal density of sea ice in kg m-3.
real :: H_to_m_ice ! The specific volume of ice times the conversion factor
! from thickness units, in m H-1.
integer :: stress_stagger
integer :: i, j, isc, iec, jsc, jec
isc = G%isc ; iec = G%iec ; jsc = G%jsc ; jec = G%jec
call get_SIS2_thermo_coefs(IST%ITV, rho_ice=rho_ice)
H_to_m_ice = IG%H_to_kg_m2 / rho_ice
call get_avg(IST%mH_ice, IST%part_size(:,:,1:), hi_avg, wtd=.true.)
hi_avg(:,:) = hi_avg(:,:) * H_to_m_Ice
if (CS%berg_windstress_bug) then
! This code reproduces a long-standing bug, in that the old ice-ocean
! stresses are being passed in place of the wind stresses on the icebergs.
do j=jsc,jec ; do i=isc,iec
windstr_x(i,j) = IOF%flux_u_ocn(i,j)
windstr_y(i,j) = IOF%flux_v_ocn(i,j)
enddo ; enddo
stress_stagger = IOF%flux_uv_stagger
else
do j=jsc,jec ; do i=isc,iec
windstr_x(i,j) = FIA%WindStr_ocn_x(i,j)
windstr_y(i,j) = FIA%WindStr_ocn_y(i,j)
enddo ; enddo
stress_stagger = AGRID
endif
if (IST%Cgrid_dyn) then
call icebergs_run( icebergs_CS, CS%Time, &
FIA%calving(isc:iec,jsc:jec), OSS%u_ocn_C(isc-2:iec+1,jsc-1:jec+1), &
OSS%v_ocn_C(isc-1:iec+1,jsc-2:jec+1), IST%u_ice_C(isc-2:iec+1,jsc-1:jec+1), &
IST%v_ice_C(isc-1:iec+1,jsc-2:jec+1), windstr_x, windstr_y, &
OSS%sea_lev(isc-1:iec+1,jsc-1:jec+1), IST%t_surf(isc:iec,jsc:jec,0), &
FIA%calving_hflx(isc:iec,jsc:jec), FIA%ice_cover(isc-1:iec+1,jsc-1:jec+1), &
hi_avg(isc-1:iec+1,jsc-1:jec+1), stagger=CGRID_NE, &
stress_stagger=stress_stagger,sss=OSS%s_surf(isc:iec,jsc:jec), &
mass_berg=IOF%mass_berg, ustar_berg=IOF%ustar_berg, &
area_berg=IOF%area_berg )
else
call icebergs_run( icebergs_CS, CS%Time, &
FIA%calving(isc:iec,jsc:jec), OSS%u_ocn_B(isc-1:iec+1,jsc-1:jec+1), &
OSS%v_ocn_B(isc-1:iec+1,jsc-1:jec+1), IST%u_ice_B(isc-1:iec+1,jsc-1:jec+1), &
IST%v_ice_B(isc-1:iec+1,jsc-1:jec+1), windstr_x, windstr_y, &
OSS%sea_lev(isc-1:iec+1,jsc-1:jec+1), IST%t_surf(isc:iec,jsc:jec,0), &
FIA%calving_hflx(isc:iec,jsc:jec), FIA%ice_cover(isc-1:iec+1,jsc-1:jec+1), &
hi_avg(isc-1:iec+1,jsc-1:jec+1), stagger=BGRID_NE, &
stress_stagger=stress_stagger, sss=OSS%s_surf(isc:iec,jsc:jec), &
mass_berg=IOF%mass_berg, ustar_berg=IOF%ustar_berg, &
area_berg=IOF%area_berg )
endif
call enable_SIS_averaging(dt_slow, CS%Time, CS%diag)
if (IOF%id_ustar_berg>0 .and. associated(IOF%ustar_berg)) then
call post_data(IOF%id_ustar_berg, IOF%ustar_berg, CS%diag)
endif
if (IOF%id_area_berg>0 .and. associated(IOF%area_berg)) then
call post_data(IOF%id_area_berg, IOF%area_berg, CS%diag)
endif
if (IOF%id_mass_berg>0 .and. associated(IOF%mass_berg)) then
call post_data(IOF%id_mass_berg, IOF%mass_berg, CS%diag)
endif
call disable_SIS_averaging(CS%diag)
end subroutine update_icebergs
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! SIS_dynamics_trans - do ice dynamics and mass and tracer transport !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
subroutine SIS_dynamics_trans(IST, OSS, FIA, IOF, dt_slow, CS, icebergs_CS, G, IG)
type(ice_state_type), intent(inout) :: IST
type(ocean_sfc_state_type), intent(in) :: OSS
type(fast_ice_avg_type), intent(inout) :: FIA
type(ice_ocean_flux_type), intent(inout) :: IOF
real, intent(in) :: dt_slow
type(SIS_hor_grid_type), intent(inout) :: G
type(ice_grid_type), intent(inout) :: IG
type(dyn_trans_CS), pointer :: CS
type(icebergs), pointer :: icebergs_CS
real, dimension(G%isc:G%iec,G%jsc:G%jec) :: h2o_chg_xprt, mass, mass_ice, mass_snow, tmp2d
real, dimension(SZI_(G),SZJ_(G),IG%CatIce,IG%NkIce) :: &
temp_ice ! A diagnostic array with the ice temperature in degC.
real, dimension(SZI_(G),SZJ_(G),IG%CatIce) :: &
temp_snow ! A diagnostic array with the snow temperature in degC.
real, dimension(SZI_(G),SZJ_(G)) :: &
ms_sum, mi_sum, & ! Masses of snow and ice per unit total area, in kg m-2.
ice_free, & ! The fractional open water; nondimensional, between 0 & 1.
ice_cover, & ! The fractional ice coverage, summed across all
! thickness categories; nondimensional, between 0 & 1.
WindStr_x_A, & ! Zonal (_x_) and meridional (_y_) wind stresses
WindStr_y_A, & ! averaged over the ice categories on an A-grid, in Pa.
WindStr_x_ocn_A, & ! Zonal (_x_) and meridional (_y_) wind stresses on the
WindStr_y_ocn_A ! ice-free ocean on an A-grid, in Pa.
real, dimension(SZIB_(G),SZJB_(G)) :: &
WindStr_x_B, & ! Zonal (_x_) and meridional (_y_) wind stresses
WindStr_y_B, & ! averaged over the ice categories on a B-grid, in Pa.
WindStr_x_ocn_B, WindStr_y_ocn_B, & ! Wind stresses on the ice-free ocean on a B-grid, in Pa.
str_x_ice_ocn_B, str_y_ice_ocn_B ! Ice-ocean stresses on a B-grid, in Pa.
real, dimension(SZIB_(G),SZJ_(G)) :: &
WindStr_x_Cu, & ! Zonal wind stress averaged over the ice categores on C-grid u-points, in Pa.
WindStr_x_ocn_Cu, & ! Zonal wind stress on the ice-free ocean on C-grid u-points, in Pa.
str_x_ice_ocn_Cu ! Zonal ice-ocean stress on C-grid u-points, in Pa.
real, dimension(SZI_(G),SZJB_(G)) :: &
WindStr_y_Cv, & ! Meridional wind stress averaged over the ice categores on C-grid v-points, in Pa.
WindStr_y_ocn_Cv, & ! Meridional wind stress on the ice-free ocean on C-grid v-points, in Pa.
str_y_ice_ocn_Cv ! Meridional ice-ocean stress on C-grid v-points, in Pa.
real, dimension(SZIB_(G),SZJ_(G)) :: uc ! Ice velocities interpolated onto
real, dimension(SZI_(G),SZJB_(G)) :: vc ! a C-grid, in m s-1.
real, dimension(SZIB_(G),SZJB_(G)) :: diagVarBx ! An temporary array for diagnostics.
real, dimension(SZIB_(G),SZJB_(G)) :: diagVarBy ! An temporary array for diagnostics.
real :: weights ! A sum of the weights around a point.
real :: I_wts ! 1.0 / wts or 0 if wts is 0, nondim.
real :: ps_vel ! The fractional thickness catetory coverage at a velocity point.
real :: dt_slow_dyn
integer :: ndyn_steps
real :: Idt_slow
integer :: i, j, k, l, m, isc, iec, jsc, jec, ncat, NkIce, nds
integer :: isd, ied, jsd, jed
integer :: iyr, imon, iday, ihr, imin, isec
real, parameter :: T_0degC = 273.15 ! 0 degrees C in Kelvin
real, dimension(SZI_(G),SZJ_(G),IG%CatIce) :: &
rdg_frac ! fraction of ridged ice per category
real, dimension(SZI_(G),SZJ_(G)) :: &
rdg_open, & ! formation rate of open water due to ridging
rdg_vosh, & ! rate of ice mass shifted from level to ridged ice
!! rdg_s2o, & ! snow mass [kg m-2] dumped into ocean during ridging
rdg_rate, & ! Niki: Where should this come from?
snow2ocn
real :: tmp3 ! This is a bad name - make it more descriptive!
isc = G%isc ; iec = G%iec ; jsc = G%jsc ; jec = G%jec ; ncat = IG%CatIce
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed ; NkIce = IG%NkIce
Idt_slow = 0.0 ; if (dt_slow > 0.0) Idt_slow = 1.0/dt_slow
if (CS%specified_ice) then
ndyn_steps = 0.0 ; dt_slow_dyn = 0.0
else
ndyn_steps = 1
if ((CS%dt_ice_dyn > 0.0) .and. (CS%dt_ice_dyn < dt_slow)) &
ndyn_steps = max(CEILING(dt_slow/CS%dt_ice_dyn - 0.000001), 1)
dt_slow_dyn = dt_slow / ndyn_steps
endif
IOF%stress_count = 0
CS%n_calls = CS%n_calls + 1
if (CS%id_xprt>0) then
! Store values to determine the ice and snow mass change due to transport.
h2o_chg_xprt(:,:) = 0.0
endif
!$OMP parallel do default(none) shared(isd,ied,jsd,jed,WindStr_x_A,WindStr_y_A, &
!$OMP ice_cover,ice_free,WindStr_x_ocn_A, &
!$OMP WindStr_y_ocn_A,FIA)
do j=jsd,jed
do i=isd,ied
WindStr_x_ocn_A(i,j) = FIA%WindStr_ocn_x(i,j)
WindStr_y_ocn_A(i,j) = FIA%WindStr_ocn_y(i,j)
ice_cover(i,j) = FIA%ice_cover(i,j) ; ice_free(i,j) = FIA%ice_free(i,j)
WindStr_x_A(i,j) = FIA%WindStr_x(i,j) ; WindStr_y_A(i,j) = FIA%WindStr_y(i,j)
enddo
enddo
do nds=1,ndyn_steps
call enable_SIS_averaging(dt_slow_dyn, CS%Time - set_time(int((ndyn_steps-nds)*dt_slow_dyn)), CS%diag)
! Correct the wind stresses for changes in the fractional ice-coverage.
ice_cover(:,:) = 0.0
!$OMP parallel do default(none) shared(isd,ied,jsd,jed,ncat,ice_cover,IST,FIA,ice_free, &
!$OMP WindStr_x_A,WindStr_y_A,WindStr_x_ocn_A,WindStr_y_ocn_A)
do j=jsd,jed
do k=1,ncat ; do i=isd,ied
ice_cover(i,j) = ice_cover(i,j) + IST%part_size(i,j,k)
enddo ; enddo
do i=isd,ied
ice_free(i,j) = IST%part_size(i,j,0)
if (ice_cover(i,j) > FIA%ice_cover(i,j)) then
WindStr_x_A(i,j) = ((ice_cover(i,j)-FIA%ice_cover(i,j))*FIA%WindStr_ocn_x(i,j) + &
FIA%ice_cover(i,j)*FIA%WindStr_x(i,j)) / ice_cover(i,j)
WindStr_y_A(i,j) = ((ice_cover(i,j)-FIA%ice_cover(i,j))*FIA%WindStr_ocn_y(i,j) + &
FIA%ice_cover(i,j)*FIA%WindStr_y(i,j)) / ice_cover(i,j)
else
WindStr_x_A(i,j) = FIA%WindStr_x(i,j)
WindStr_y_A(i,j) = FIA%WindStr_y(i,j)
endif
if (ice_free(i,j) <= FIA%ice_free(i,j)) then
WindStr_x_ocn_A(i,j) = FIA%WindStr_ocn_x(i,j)
WindStr_y_ocn_A(i,j) = FIA%WindStr_ocn_y(i,j)
else
WindStr_x_ocn_A(i,j) = ((ice_free(i,j)-FIA%ice_free(i,j))*FIA%WindStr_x(i,j) + &
FIA%ice_free(i,j)*FIA%WindStr_ocn_x(i,j)) / ice_free(i,j)
WindStr_y_ocn_A(i,j) = ((ice_free(i,j)-FIA%ice_free(i,j))*FIA%WindStr_y(i,j) + &
FIA%ice_free(i,j)*FIA%WindStr_ocn_y(i,j)) / ice_free(i,j)
endif
enddo
enddo
!
! Dynamics - update ice velocities.
!
call mpp_clock_begin(iceClock4)
ms_sum(:,:) = 0.0 ; mi_sum(:,:) = 0.0
!$OMP parallel do default(none) shared(isd,ied,jsd,jed,ncat,ms_sum,mi_sum,G,IST,IG)
do j=jsd,jed ; do k=1,ncat ; do i=isd,ied
ms_sum(i,j) = ms_sum(i,j) + (IG%H_to_kg_m2 * IST%mH_snow(i,j,k)) * IST%part_size(i,j,k)
mi_sum(i,j) = mi_sum(i,j) + (IG%H_to_kg_m2 * IST%mH_ice(i,j,k)) * IST%part_size(i,j,k)
enddo ; enddo ; enddo
! In the dynamics code, only the ice velocities are changed, and the ice-ocean
! stresses are calculated. The gravity wave dynamics (i.e. the continuity
! equation) are not included in the dynamics. All of the thickness categories
! are merged together.
if (CS%Cgrid_dyn) then
! The j-loop extents here are larger than they would normally be in case
! the stresses are being passed to the ocean on a B-grid.
!$OMP parallel default(none) shared(isc,iec,jsc,jec,G,ice_cover,WindStr_x_Cu,ice_free, &
!$OMP WindStr_x_A,WindStr_x_ocn_Cu,WindStr_x_ocn_A, &
!$OMP WindStr_y_Cv,WindStr_y_A,WindStr_y_ocn_Cv, &
!$OMP WindStr_y_ocn_A) &
!$OMP private(weights,I_wts)
!$OMP do
do j=jsc-1,jec+1 ; do I=isc-1,iec
weights = (G%areaT(i,j)*ice_cover(i,j) + G%areaT(i+1,j)*ice_cover(i+1,j))
if (G%mask2dCu(I,j) * weights > 0.0) then ; I_wts = 1.0 / weights
WindStr_x_Cu(I,j) = G%mask2dCu(I,j) * &
(G%areaT(i,j) * ice_cover(i,j) * WindStr_x_A(i,j) + &
G%areaT(i+1,j)*ice_cover(i+1,j)*WindStr_x_A(i+1,j)) * I_wts
else
WindStr_x_Cu(I,j) = 0.0
endif
weights = (G%areaT(i,j)*ice_free(i,j) + G%areaT(i+1,j)*ice_free(i+1,j))
if (G%mask2dCu(I,j) * weights > 0.0) then ; I_wts = 1.0 / weights
WindStr_x_ocn_Cu(I,j) = G%mask2dCu(I,j) * &
(G%areaT(i,j) * ice_free(i,j) * WindStr_x_ocn_A(i,j) + &
G%areaT(i+1,j)*ice_free(i+1,j)*WindStr_x_ocn_A(i+1,j)) * I_wts
else
WindStr_x_ocn_Cu(I,j) = 0.0
endif
enddo ; enddo
!$OMP end do nowait
!$OMP do
do J=jsc-1,jec ; do i=isc-1,iec+1
weights = (G%areaT(i,j)*ice_cover(i,j) + G%areaT(i,j+1)*ice_cover(i,j+1))
if (G%mask2dCv(i,J) * weights > 0.0) then ; I_wts = 1.0 / weights
WindStr_y_Cv(i,J) = G%mask2dCv(i,J) * &
(G%areaT(i,j) * ice_cover(i,j) * WindStr_y_A(i,j) + &
G%areaT(i,j+1)*ice_cover(i,j+1)*WindStr_y_A(i,j+1)) * I_wts
else
WindStr_y_Cv(i,J) = 0.0
endif
weights = (G%areaT(i,j)*ice_free(i,j) + G%areaT(i,j+1)*ice_free(i,j+1))
if (weights > 0.0) then ; I_wts = 1.0 / weights
WindStr_y_ocn_Cv(i,J) = G%mask2dCv(i,J) * &
(G%areaT(i,j) * ice_free(i,j) * WindStr_y_ocn_A(i,j) + &
G%areaT(i,j+1)*ice_free(i,j+1)*WindStr_y_ocn_A(i,j+1)) * I_wts
else
WindStr_y_ocn_Cv(i,J) = 0.0
endif
enddo ; enddo
!$OMP end parallel
if (CS%debug) then
call IST_chksum("Before SIS_C_dynamics", IST, G, IG)
call hchksum(IST%part_size(:,:,0), "ps(0) before SIS_C_dynamics", G%HI)
call hchksum(ms_sum, "ms_sum before SIS_C_dynamics", G%HI)
call hchksum(mi_sum, "mi_sum before SIS_C_dynamics", G%HI)
call hchksum(OSS%sea_lev, "sea_lev before SIS_C_dynamics", G%HI, haloshift=1)
call uchksum(OSS%u_ocn_C, "u_ocn_C before SIS_C_dynamics", G%HI)
call vchksum(OSS%v_ocn_C, "v_ocn_C before SIS_C_dynamics", G%HI)
call uchksum(WindStr_x_Cu, "WindStr_x_Cu before SIS_C_dynamics", G%HI)
call vchksum(WindStr_y_Cv, "WindStr_y_Cv before SIS_C_dynamics", G%HI)
call check_redundant_C("WindStr before SIS_C_dynamics", WindStr_x_Cu, WindStr_y_Cv, G)
endif
call mpp_clock_begin(iceClocka)
!### Ridging needs to be added with C-grid dynamics.
call SIS_C_dynamics(1.0-IST%part_size(:,:,0), ms_sum, mi_sum, IST%u_ice_C, IST%v_ice_C, &
OSS%u_ocn_C, OSS%v_ocn_C, &
WindStr_x_Cu, WindStr_y_Cv, OSS%sea_lev, str_x_ice_ocn_Cu, str_y_ice_ocn_Cv, &
dt_slow_dyn, G, CS%SIS_C_dyn_CSp)
call mpp_clock_end(iceClocka)
if (CS%debug) then
call IST_chksum("After ice_dynamics", IST, G, IG)
endif
call mpp_clock_begin(iceClockb)
call pass_vector(IST%u_ice_C, IST%v_ice_C, G%Domain, stagger=CGRID_NE)
call pass_vector(str_x_ice_ocn_Cu, str_y_ice_ocn_Cv, G%Domain, stagger=CGRID_NE)
call mpp_clock_end(iceClockb)
!
! Dynamics diagnostics
!
call mpp_clock_begin(iceClockc)
if (CS%id_fax>0) call post_data(CS%id_fax, WindStr_x_Cu, CS%diag)
if (CS%id_fay>0) call post_data(CS%id_fay, WindStr_y_Cv, CS%diag)
if (CS%debug) call IST_chksum("Before set_ocean_top_stress_Cgrid", IST, G, IG)
call set_ocean_top_stress_Cgrid(IOF, WindStr_x_ocn_Cu, WindStr_y_ocn_Cv, &
str_x_ice_ocn_Cu, str_y_ice_ocn_Cv, IST%part_size, G, IG)
if (CS%debug) call IST_chksum("After set_ocean_top_stress_Cgrid", IST, G, IG)
call mpp_clock_end(iceClockc)
else ! B-grid dynamics.
!$OMP parallel do default(none) shared(isc,iec,jsc,jec,G,ice_cover,WindStr_x_B,ice_free, &
!$OMP WindStr_x_A,WindStr_x_ocn_B,WindStr_x_ocn_A, &
!$OMP WindStr_y_ocn_B,WindStr_y_ocn_A,WindStr_y_B, &
!$OMP WindStr_y_A) &
!$OMP private(weights,I_wts)
do J=jsc-1,jec ; do I=isc-1,iec ; if (G%mask2dBu(I,J) > 0.0) then
weights = ((G%areaT(i+1,j+1)*ice_cover(i+1,j+1) + G%areaT(i,j)*ice_cover(i,j)) + &
(G%areaT(i+1,j)*ice_cover(i+1,j) + G%areaT(i,j+1)*ice_cover(i,j+1)) )
I_wts = 0.0 ; if (weights > 0.0) I_wts = 1.0 / weights
WindStr_x_B(I,J) = G%mask2dBu(I,J) * &
((G%areaT(i+1,j+1)*ice_cover(i+1,j+1)*WindStr_x_A(i+1,j+1) + &
G%areaT(i,j) * ice_cover(i,j) * WindStr_x_A(i,j)) + &
(G%areaT(i+1,j) * ice_cover(i+1,j) * WindStr_x_A(i+1,j) + &
G%areaT(i,j+1) * ice_cover(i,j+1) * WindStr_x_A(i,j+1)) ) * I_wts
WindStr_y_B(I,J) = G%mask2dBu(I,J) * &
((G%areaT(i+1,j+1)*ice_cover(i+1,j+1)*WindStr_y_A(i+1,j+1) + &
G%areaT(i,j) * ice_cover(i,j) * WindStr_y_A(i,j)) + &
(G%areaT(i+1,j) * ice_cover(i+1,j) * WindStr_y_A(i+1,j) + &
G%areaT(i,j+1) * ice_cover(i,j+1) * WindStr_y_A(i,j+1)) ) * I_wts
weights = ((G%areaT(i+1,j+1)*ice_free(i+1,j+1) + G%areaT(i,j)*ice_free(i,j)) + &
(G%areaT(i+1,j)*ice_free(i+1,j) + G%areaT(i,j+1)*ice_free(i,j+1)) )
I_wts = 0.0 ; if (weights > 0.0) I_wts = 1.0 / weights
WindStr_x_ocn_B(I,J) = G%mask2dBu(I,J) * &
((G%areaT(i+1,j+1)*ice_free(i+1,j+1)*WindStr_x_ocn_A(i+1,j+1) + &
G%areaT(i,j) * ice_free(i,j) * WindStr_x_ocn_A(i,j)) + &
(G%areaT(i+1,j) * ice_free(i+1,j) * WindStr_x_ocn_A(i+1,j) + &
G%areaT(i,j+1) * ice_free(i,j+1) * WindStr_x_ocn_A(i,j+1)) ) * I_wts
WindStr_y_ocn_B(I,J) = G%mask2dBu(I,J) * &
((G%areaT(i+1,j+1)*ice_free(i+1,j+1)*WindStr_y_ocn_A(i+1,j+1) + &
G%areaT(i,j) * ice_free(i,j) * WindStr_y_ocn_A(i,j)) + &
(G%areaT(i+1,j) * ice_free(i+1,j) * WindStr_y_ocn_A(i+1,j) + &
G%areaT(i,j+1) * ice_free(i,j+1) * WindStr_y_ocn_A(i,j+1)) ) * I_wts
else
WindStr_x_B(I,J) = 0.0 ; WindStr_y_B(I,J) = 0.0
WindStr_x_ocn_B(I,J) = 0.0 ; WindStr_y_ocn_B(I,J) = 0.0
endif ; enddo ; enddo
if (CS%debug) then
call IST_chksum("Before ice_dynamics", IST, G, IG)
call hchksum(IST%part_size(:,:,0), "ps(0) before ice_dynamics", G%HI)
call hchksum(ms_sum, "ms_sum before ice_dynamics", G%HI)
call hchksum(mi_sum, "mi_sum before ice_dynamics", G%HI)
call hchksum(OSS%sea_lev, "sea_lev before ice_dynamics", G%HI, haloshift=1)
call Bchksum(OSS%u_ocn_B, "u_ocn before ice_dynamics", G%HI, symmetric=.true.)
call Bchksum(OSS%v_ocn_B, "v_ocn before ice_dynamics", G%HI, symmetric=.true.)
call Bchksum(WindStr_x_B, "WindStr_x_B before ice_dynamics", G%HI, symmetric=.true.)
call Bchksum(WindStr_y_B, "WindStr_y_B before ice_dynamics", G%HI, symmetric=.true.)
call check_redundant_B("WindStr before ice_dynamics",WindStr_x_B, WindStr_y_B, G)
endif
rdg_rate(:,:) = 0.0
call mpp_clock_begin(iceClocka)
call SIS_B_dynamics(1.0-IST%part_size(:,:,0), ms_sum, mi_sum, IST%u_ice_B, IST%v_ice_B, &
OSS%u_ocn_B, OSS%v_ocn_B, WindStr_x_B, WindStr_y_B, OSS%sea_lev, &
str_x_ice_ocn_B, str_y_ice_ocn_B, CS%do_ridging, &
rdg_rate(isc:iec,jsc:jec), dt_slow_dyn, G, CS%SIS_B_dyn_CSp)
call mpp_clock_end(iceClocka)
if (CS%debug) then
call IST_chksum("After ice_dynamics", IST, G, IG)
endif
call mpp_clock_begin(iceClockb)
call pass_vector(IST%u_ice_B, IST%v_ice_B, G%Domain, stagger=BGRID_NE)
call mpp_clock_end(iceClockb)
call mpp_clock_begin(iceClockc)
!
! Dynamics diagnostics
!
if ((CS%id_fax>0) .or. (CS%id_fay>0)) then
!$OMP parallel do default(none) shared(isc,iec,jsc,jec,G,IST,diagVarBx,diagVarBy, &
!$OMP WindStr_x_ocn_B,WindStr_y_ocn_B, &
!$OMP WindStr_x_B,WindStr_y_B) &
!$OMP private(ps_vel)
do J=jsc-1,jec ; do I=isc-1,iec
ps_vel = (1.0 - G%mask2dBu(I,J)) + 0.25*G%mask2dBu(I,J) * &
((IST%part_size(i+1,j+1,0) + IST%part_size(i,j,0)) + &
(IST%part_size(i+1,j,0) + IST%part_size(i,j+1,0)) )
diagVarBx(I,J) = ps_vel * WindStr_x_ocn_B(I,J) + &
(1.0-ps_vel) * WindStr_x_B(I,J)
diagVarBy(I,J) = ps_vel * WindStr_y_ocn_B(I,J) + &
(1.0-ps_vel) * WindStr_y_B(I,J)
enddo ; enddo
if (CS%id_fax>0) call post_data(CS%id_fax, diagVarBx, CS%diag)
if (CS%id_fay>0) call post_data(CS%id_fay, diagVarBy, CS%diag)
endif
if (CS%debug) call IST_chksum("Before set_ocean_top_stress_Bgrid", IST, G, IG)
call set_ocean_top_stress_Bgrid(IOF, WindStr_x_ocn_B, WindStr_y_ocn_B, &
str_x_ice_ocn_B, str_y_ice_ocn_B, IST%part_size, G, IG)
if (CS%debug) call IST_chksum("After set_ocean_top_stress_Bgrid", IST, G, IG)
call mpp_clock_end(iceClockc)
endif ! End of B-grid dynamics
call mpp_clock_end(iceClock4)
call enable_SIS_averaging(dt_slow_dyn, CS%Time - set_time(int((ndyn_steps-nds)*dt_slow_dyn)), CS%diag)
!
! Do ice transport ... all ocean fluxes have been calculated by now.
!
call mpp_clock_begin(iceClock8)
if (CS%id_xprt>0) then
!$OMP parallel do default(none) shared(isc,iec,jsc,jec,ncat,h2o_chg_xprt,IST,G,IG)
do j=jsc,jec ; do k=1,ncat ; do i=isc,iec
h2o_chg_xprt(i,j) = h2o_chg_xprt(i,j) - IST%part_size(i,j,k) * &
IG%H_to_kg_m2 * (IST%mH_snow(i,j,k) + IST%mH_ice(i,j,k))
enddo ; enddo ; enddo
endif
if (CS%debug) then
call IST_chksum("Before ice_transport", IST, G, IG)
endif
if (CS%Cgrid_dyn) then
call ice_transport(IST%part_size, IST%mH_ice, IST%mH_snow, IST%mH_pond, &
IST%u_ice_C, IST%v_ice_C, IST%t_surf, IST%TrReg, &
OSS%sea_lev, dt_slow_dyn, G, IG, CS%ice_transport_CSp,&
IST%rdg_mice, snow2ocn, rdg_rate, &
rdg_open, rdg_vosh)
else
! B-grid transport
! Convert the velocities to C-grid points for transport.
uc(:,:) = 0.0; vc(:,:) = 0.0
do j=jsc,jec ; do I=isc-1,iec
uc(I,j) = 0.5 * ( IST%u_ice_B(I,J-1) + IST%u_ice_B(I,J) )
enddo ; enddo
do J=jsc-1,jec ; do i = isc,iec
vc(i,J) = 0.5 * ( IST%v_ice_B(I-1,J) + IST%v_ice_B(I,J) )
enddo ; enddo
call ice_transport(IST%part_size, IST%mH_ice, IST%mH_snow, IST%mH_pond, &
uc, vc, IST%t_surf, IST%TrReg, OSS%sea_lev, &
dt_slow_dyn, G, IG, CS%ice_transport_CSp, &
IST%rdg_mice, snow2ocn, rdg_rate, rdg_open, rdg_vosh)
endif
if (CS%column_check) &
call write_ice_statistics(IST, CS%Time, CS%n_calls, G, IG, CS%sum_output_CSp, &
message=" Post_transport")! , check_column=.true.)
if (CS%id_xprt>0) then
!$OMP parallel do default(none) shared(isc,iec,jsc,jec,ncat,h2o_chg_xprt,IST,G,IG)
do j=jsc,jec ; do k=1,ncat ; do i=isc,iec
h2o_chg_xprt(i,j) = h2o_chg_xprt(i,j) + IST%part_size(i,j,k) * &
IG%H_to_kg_m2 * (IST%mH_snow(i,j,k) + IST%mH_ice(i,j,k))
enddo ; enddo ; enddo ; endif
call mpp_clock_end(iceClock8)
enddo ! nds=1,ndyn_steps
call finish_ocean_top_stresses(IOF, G%HI)
! Add snow mass dumped into ocean to flux of frozen precipitation:
!### WARNING - rdg_s2o is never calculated!!!
! if (CS%do_ridging) then ; do k=1,ncat ; do j=jsc,jec ; do i=isc,iec
! FIA%fprec_top(i,j,k) = FIA%fprec_top(i,j,k) + rdg_s2o(i,j)/dt_slow
! enddo ; enddo ; enddo ; endif
call mpp_clock_begin(iceClock9)
! Set appropriate surface quantities in categories with no ice.
!$OMP parallel do default(none) shared(isc,iec,jsc,jec,ncat,IST,OSS)
do j=jsc,jec ; do k=1,ncat ; do i=isc,iec ; if (IST%part_size(i,j,k)<=0.0) &
IST%t_surf(i,j,k) = T_0degC + T_Freeze(OSS%s_surf(i,j),IST%ITV)
enddo ; enddo ; enddo
if (CS%bounds_check) call IST_bounds_check(IST, G, IG, "After ice_transport", OSS=OSS)
if (CS%debug) call IST_chksum("After ice_transport", IST, G, IG)
call enable_SIS_averaging(dt_slow, CS%Time, CS%diag)
call post_ice_state_diagnostics(CS, IST, OSS, IOF, dt_slow, G, IG, CS%diag, &
h2o_chg_xprt=h2o_chg_xprt, rdg_rate=rdg_rate)
call disable_SIS_averaging(CS%diag)
if (CS%verbose) then
call get_date(CS%Time, iyr, imon, iday, ihr, imin, isec)
call get_time(CS%Time-set_date(iyr,1,1,0,0,0),isec,iday)
call ice_line(iyr, iday+1, isec, IST%part_size(isc:iec,jsc:jec,0), &
IST%t_surf(:,:,0)-T_0degC, G)
endif
call mpp_clock_end(iceClock9)
if (CS%debug) then
call IST_chksum("End SIS_dynamics_trans", IST, G, IG)
endif
if (CS%bounds_check) then
call IST_bounds_check(IST, G, IG, "End of SIS_dynamics_trans", OSS=OSS)
endif
if (CS%Time + set_time(int(floor(0.5*dt_slow+0.5))) > CS%write_ice_stats_time) then
call write_ice_statistics(IST, CS%Time, CS%n_calls, G, IG, CS%sum_output_CSp)
CS%write_ice_stats_time = CS%write_ice_stats_time + CS%ice_stats_interval
elseif (CS%column_check) then
call write_ice_statistics(IST, CS%Time, CS%n_calls, G, IG, CS%sum_output_CSp)
endif
end subroutine SIS_dynamics_trans
subroutine post_ice_state_diagnostics(CS, IST, OSS, IOF, dt_slow, G, IG, diag, &
h2o_chg_xprt, rdg_rate)
type(ice_state_type), intent(inout) :: IST
type(ocean_sfc_state_type), intent(in) :: OSS
! type(fast_ice_avg_type), intent(inout) :: FIA
type(ice_ocean_flux_type), intent(in) :: IOF
real, intent(in) :: dt_slow
type(SIS_hor_grid_type), intent(inout) :: G
type(ice_grid_type), intent(inout) :: IG
type(dyn_trans_CS), pointer :: CS
type(SIS_diag_ctrl), pointer :: diag
real, dimension(G%isc:G%iec,G%jsc:G%jec), optional, intent(in) :: h2o_chg_xprt
real, dimension(SZI_(G),SZJ_(G)), optional, intent(in) :: rdg_rate
real, dimension(G%isc:G%iec,G%jsc:G%jec) :: mass, mass_ice, mass_snow, tmp2d
real, dimension(SZI_(G),SZJ_(G),IG%CatIce,IG%NkIce) :: &
temp_ice ! A diagnostic array with the ice temperature in degC.
real, dimension(SZI_(G),SZJ_(G),IG%CatIce) :: &
temp_snow ! A diagnostic array with the snow temperature in degC.
real, dimension(SZI_(G),SZJ_(G)) :: diagVar ! An temporary array for diagnostics.
real, dimension(IG%NkIce) :: S_col ! Specified thermodynamic salinity of each
! ice layer if spec_thermo_sal is true.
real :: rho_ice ! The nominal density of sea ice in kg m-3.
real :: rho_snow ! The nominal density of snow in kg m-3.
real :: enth_units, I_enth_units
real :: I_Nk ! The inverse of the number of layers in the ice.
real :: Idt_slow ! The inverse of the thermodynamic step, in s-1.
real, parameter :: T_0degC = 273.15 ! 0 degrees C in Kelvin
logical :: spec_thermo_sal
logical :: do_temp_diags
integer :: i, j, k, l, m, isc, iec, jsc, jec, ncat, NkIce ! , nds
isc = G%isc ; iec = G%iec ; jsc = G%jsc ; jec = G%jec ; ncat = IG%CatIce
! isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed ;
NkIce = IG%NkIce
I_Nk = 1.0 / NkIce
Idt_slow = 0.0 ; if (dt_slow > 0.0) Idt_slow = 1.0/dt_slow
! Sum the concentration weighted mass for diagnostics.
if (CS%id_mi>0 .or. CS%id_mib>0) then
mass_ice(:,:) = 0.0
mass_snow(:,:) = 0.0
mass(:,:) = 0.0
!$OMP parallel do default(none) shared(isc,iec,jsc,jec,ncat,mass,mass_ice,mass_snow,G,IST,IG)
do j=jsc,jec ; do k=1,ncat ; do i=isc,iec
mass_ice(i,j) = mass_ice(i,j) + IG%H_to_kg_m2*IST%mH_ice(i,j,k)*IST%part_size(i,j,k)
mass_snow(i,j) = mass_snow(i,j) + IG%H_to_kg_m2*IST%mH_snow(i,j,k)*IST%part_size(i,j,k)
mass(i,j) = mass_ice(i,j) + mass_snow(i,j)
enddo ; enddo ; enddo
if (CS%id_simass>0) call post_data(CS%id_simass, mass_ice(isc:iec,jsc:jec), diag)
if (CS%id_sisnmass>0) call post_data(CS%id_sisnmass, mass_snow(isc:iec,jsc:jec), diag)
if (CS%id_mi>0) call post_data(CS%id_mi, mass(isc:iec,jsc:jec), diag)
if (CS%id_mib>0) then
if (associated(IOF%mass_berg)) then
do j=jsc,jec ; do i=isc,iec
mass(i,j) = (mass(i,j) + IOF%mass_berg(i,j)) ! Add icebergs mass in kg/m^2
enddo ; enddo
endif
call post_data(CS%id_mib, mass(isc:iec,jsc:jec), diag)
endif
endif
!
! Thermodynamic state diagnostics
!
if (CS%id_cn>0) call post_data(CS%id_cn, IST%part_size(:,:,1:ncat), diag)
if (CS%id_siconc>0) call post_data(CS%id_siconc, sum(IST%part_size(:,:,1:ncat),3), diag)
! TK Mod: 10/18/02
! if (CS%id_obs_cn>0) call post_data(CS%id_obs_cn, Obs_cn_ice(:,:,2), diag)
! TK Mod: 10/18/02: (commented out...does not compile yet... add later)
! if (CS%id_obs_hi>0) &
! call post_avg(CS%id_obs_hi, Obs_h_ice(isc:iec,jsc:jec), IST%part_size(isc:iec,jsc:jec,1:), &
! diag, G=G, wtd=.true.)
! Convert from ice and snow enthalpy back to temperature for diagnostic purposes.
do_temp_diags = (CS%id_tsn > 0)
do m=1,NkIce ; if (CS%id_t(m)>0) do_temp_diags = .true. ; enddo
call get_SIS2_thermo_coefs(IST%ITV, ice_salinity=S_col, enthalpy_units=enth_units, &
rho_ice=rho_ice, rho_snow=rho_snow, &
specified_thermo_salinity=spec_thermo_sal)
I_enth_units = 1.0 / enth_units
if (do_temp_diags) then
!$OMP parallel do default(none) shared(isc,iec,jsc,jec,G,IST,spec_thermo_sal,temp_ice, &
!$OMP S_col,temp_snow,ncat,NkIce)
do j=jsc,jec ; do k=1,ncat ; do i=isc,iec
if (IST%part_size(i,j,k)*IST%mH_ice(i,j,k) > 0.0) then
if (spec_thermo_sal) then ; do m=1,NkIce
temp_ice(i,j,k,m) = temp_from_En_S(IST%enth_ice(i,j,k,m), S_col(m), IST%ITV)
enddo ; else ; do m=1,NkIce
temp_ice(i,j,k,m) = temp_from_En_S(IST%enth_ice(i,j,k,m), &
IST%sal_ice(i,j,k,m), IST%ITV)
enddo ; endif
else
do m=1,NkIce ; temp_ice(i,j,k,m) = 0.0 ; enddo
endif
if (IST%part_size(i,j,k)*IST%mH_snow(i,j,k) > 0.0) then
temp_snow(i,j,k) = temp_from_En_S(IST%enth_snow(i,j,k,1), 0.0, IST%ITV)
else
temp_snow(i,j,k) = 0.0 ! ### Should this be = temp_ice(i,j,k,1)?
endif
enddo ; enddo ; enddo
endif
if (CS%id_ext>0) then
diagVar(:,:) = 0.0
do j=jsc,jec ; do i=isc,iec
if (IST%part_size(i,j,0) < 0.85) diagVar(i,j) = 1.0
enddo ; enddo
call post_data(CS%id_ext, diagVar, diag)
endif
if (CS%id_hp>0) call post_avg(CS%id_hp, IST%mH_pond, IST%part_size(:,:,1:), & ! mw/new
diag, G=G, &
scale=IG%H_to_kg_m2/1e3, wtd=.true.) ! rho_water=1e3
if (CS%id_hs>0) call post_avg(CS%id_hs, IST%mH_snow, IST%part_size(:,:,1:), &
diag, G=G, scale=IG%H_to_kg_m2/Rho_snow, wtd=.true.)
if (CS%id_sisnthick>0) call post_avg(CS%id_sisnthick, IST%mH_snow, IST%part_size(:,:,1:), &
diag, G=G, scale=IG%H_to_kg_m2/Rho_snow, wtd=.true.)
if (CS%id_hi>0) call post_avg(CS%id_hi, IST%mH_ice, IST%part_size(:,:,1:), &
diag, G=G, scale=IG%H_to_kg_m2/Rho_ice, wtd=.true.)
if (CS%id_sithick>0) call post_avg(CS%id_sithick, IST%mH_ice, IST%part_size(:,:,1:), &
diag, G=G, scale=IG%H_to_kg_m2/Rho_ice, wtd=.true.)
if (CS%id_sivol>0) call post_avg(CS%id_sivol, IST%mH_ice, IST%part_size(:,:,1:), &
diag, G=G, scale=IG%H_to_kg_m2/Rho_ice, wtd=.true.)
if (CS%id_tsfc>0) call post_avg(CS%id_tsfc, IST%t_surf(:,:,1:), IST%part_size(:,:,1:), &
diag, G=G, offset=-T_0degC, wtd=.true.)
if (CS%id_sitemptop>0) call post_avg(CS%id_sitemptop, IST%t_surf(:,:,1:), IST%part_size(:,:,1:), &
diag, G=G, offset=-T_0degC, wtd=.true.)
if (CS%id_tsn>0) call post_avg(CS%id_tsn, temp_snow, IST%part_size(:,:,1:), &
diag, G=G, wtd=.true.)
if (CS%id_sitimefrac>0) then
diagVar(:,:) = 0.0
do j=jsc,jec ; do i=isc,iec
if (IST%part_size(i,j,0) < 1.0) diagVar(i,j) = 1.0
enddo ; enddo
call post_data(CS%id_sitimefrac, diagVar, diag)
endif
if (CS%id_sisnconc>0) then
diagVar(:,:) = 0.0
do j=jsc,jec ; do i=isc,iec; do k=1,ncat
if (IST%part_size(i,j,k) > 0.0 .and. IST%mH_snow(i,j,k) > 0.0) then
diagVar(i,j) = diagVar(i,j) + IST%part_size(i,j,k)
endif
enddo ; enddo ; enddo
call post_data(CS%id_sisnconc, diagVar, diag)
endif
do m=1,NkIce
if (CS%id_t(m)>0) call post_avg(CS%id_t(m), temp_ice(:,:,:,m), IST%part_size(:,:,1:), &
diag, G=G, wtd=.true.)
if (CS%id_sal(m)>0) call post_avg(CS%id_sal(m), IST%sal_ice(:,:,:,m), IST%part_size(:,:,1:), &
diag, G=G, wtd=.true.)
enddo
if (CS%id_t_iceav>0) call post_avg(CS%id_t_iceav, temp_ice, IST%part_size(:,:,1:), &
diag, G=G, wtd=.true.)
if (CS%id_S_iceav>0) call post_avg(CS%id_S_iceav, IST%sal_ice, IST%part_size(:,:,1:), &
diag, G=G, wtd=.true.)
! Write out diagnostics of the ocean surface state, as seen by the slow sea ice.
! These fields do not change over the course of the sea-ice time stepping.
call post_ocean_sfc_diagnostics(OSS, dt_slow, G, diag)
if (CS%id_xprt>0 .and. present(h2o_chg_xprt)) then
call post_data(CS%id_xprt, h2o_chg_xprt(isc:iec,jsc:jec)*864e2*365/dt_slow, &
diag)
endif
if (CS%id_e2m>0) then
tmp2d(:,:) = 0.0
!$OMP parallel do default(none) shared(isc,iec,jsc,jec,ncat,IST,G,tmp2d,I_enth_units, &
!$OMP spec_thermo_sal,NkIce,I_Nk,S_col,IG)
do j=jsc,jec ; do k=1,ncat ; do i=isc,iec ; if (IST%part_size(i,j,k)*IST%mH_ice(i,j,k)>0.0) then
tmp2d(i,j) = tmp2d(i,j) + IST%part_size(i,j,k)*IST%mH_snow(i,j,k)*IG%H_to_kg_m2 * &
((enthalpy_liquid_freeze(0.0, IST%ITV) - &
IST%enth_snow(i,j,k,1)) * I_enth_units)
if (spec_thermo_sal) then ; do m=1,NkIce
tmp2d(i,j) = tmp2d(i,j) + (IST%part_size(i,j,k)*IST%mH_ice(i,j,k)*IG%H_to_kg_m2*I_Nk) * &
((enthalpy_liquid_freeze(S_col(m), IST%ITV) - &
IST%enth_ice(i,j,k,m)) * I_enth_units)
enddo ; else ; do m=1,NkIce
tmp2d(i,j) = tmp2d(i,j) + (IST%part_size(i,j,k)*IST%mH_ice(i,j,k)*IG%H_to_kg_m2*I_Nk) * &
((enthalpy_liquid_freeze(IST%sal_ice(i,j,k,m), IST%ITV) - &
IST%enth_ice(i,j,k,m)) * I_enth_units)
enddo ; endif
endif ; enddo ; enddo ; enddo
call post_data(CS%id_e2m, tmp2d(:,:), diag)
endif
if (CS%do_ridging) then
!TOM> preparing output field fraction of ridged ice rdg_frac = (ridged ice volume) / (total ice volume)
! in each category; IST%rdg_mice is ridged ice mass per unit total area throughout the code.
! if (CS%id_rdgf>0) then
! !$OMP parallel do default(none) shared(isc,iec,jsc,jec,ncat,IST,G,rdg_frac,IG) &
! !$OMP private(tmp3)
! do j=jsc,jec ; do k=1,ncat ; do i=isc,iec
! tmp3 = IST%mH_ice(i,j,k)*IST%part_size(i,j,k)
! if (tmp3*IG%H_to_kg_m2 > Rho_Ice*1.e-5) then ! 1 mm ice thickness x 1% ice concentration
! rdg_frac(i,j,k) = IST%rdg_mice(i,j,k) / tmp3
! else
! rdg_frac(i,j,k) = 0.0
! endif
! enddo ; enddo ; enddo
! call post_data(CS%id_rdgf, rdg_frac(isc:iec,jsc:jec), diag)
! endif
if (CS%id_rdgr>0 .and. present(rdg_rate)) &
call post_data(CS%id_rdgr, rdg_rate(isc:iec,jsc:jec), diag)
! if (CS%id_rdgo>0) call post_data(CS%id_rdgo, rdg_open(isc:iec,jsc:jec), diag)
! if (CS%id_rdgv>0) then
! do j=jsc,jec ; do i=isc,iec
! tmp2d(i,j) = rdg_vosh(i,j) * G%areaT(i,j) * G%mask2dT(i,j)
! enddo ; enddo
! call post_data(CS%id_rdgv, tmp2d, diag)
! endif
endif
end subroutine post_ice_state_diagnostics
subroutine post_ocean_sfc_diagnostics(OSS, dt_slow, G, diag)
type(ocean_sfc_state_type), intent(in) :: OSS
real, intent(in) :: dt_slow
type(SIS_hor_grid_type), intent(inout) :: G
type(SIS_diag_ctrl), pointer :: diag
real :: Idt_slow ! The inverse of the thermodynamic step, in s-1.
Idt_slow = 0.0 ; if (dt_slow > 0.0) Idt_slow = 1.0/dt_slow
! Write out diagnostics of the ocean surface state, as seen by the slow sea ice.
! These fields do not change over the course of the sea-ice time stepping.
if (OSS%id_sst>0) call post_data(OSS%id_sst, OSS%t_ocn, diag)
if (OSS%id_sss>0) call post_data(OSS%id_sss, OSS%s_surf, diag)
if (OSS%id_ssh>0) call post_data(OSS%id_ssh, OSS%sea_lev, diag)
if (allocated(OSS%u_ocn_C)) then
if (OSS%id_uo>0) call post_data(OSS%id_uo, OSS%u_ocn_C, diag)
if (OSS%id_vo>0) call post_data(OSS%id_vo, OSS%v_ocn_C, diag)
else
if (OSS%id_uo>0) call post_data(OSS%id_uo, OSS%u_ocn_B, diag)
if (OSS%id_vo>0) call post_data(OSS%id_vo, OSS%v_ocn_B, diag)
endif
if (OSS%id_frazil>0) &
call post_data(OSS%id_frazil, OSS%frazil*Idt_slow, diag)
end subroutine post_ocean_sfc_diagnostics
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! finish_ocean_top_stresses - Finish setting the ice-ocean stresses by dividing!
! them through the stresses by the number of times they have been augmented. !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
subroutine finish_ocean_top_stresses(IOF, HI)
type(hor_index_type), intent(in) :: HI
type(ice_ocean_flux_type), intent(inout) :: IOF
real :: I_count
integer :: i, j, isc, iec, jsc, jec
isc = HI%isc ; iec = HI%iec ; jsc = HI%jsc ; jec = HI%jec
if (IOF%stress_count > 1) then
I_count = 1.0 / IOF%stress_count
do j=jsc,jec ; do i=isc,iec
IOF%flux_u_ocn(i,j) = IOF%flux_u_ocn(i,j) * I_count
IOF%flux_v_ocn(i,j) = IOF%flux_v_ocn(i,j) * I_count
enddo ; enddo
endif
end subroutine finish_ocean_top_stresses
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! set_ocean_top_stress_Bgrid - Calculate the stresses on the ocean integrated !
! across all the thickness categories with the appropriate staggering, and !
! store them in the public ice data type for use by the ocean model. This !
! version of the routine uses wind and ice-ocean stresses on a B-grid. !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
subroutine set_ocean_top_stress_Bgrid(IOF, windstr_x_water, windstr_y_water, &
str_ice_oce_x, str_ice_oce_y, part_size, G, IG)
type(ice_ocean_flux_type), intent(inout) :: IOF
type(SIS_hor_grid_type), intent(inout) :: G
type(ice_grid_type), intent(inout) :: IG
real, dimension(SZIB_(G),SZJB_(G)), intent(in) :: windstr_x_water, str_ice_oce_x
real, dimension(SZIB_(G),SZJB_(G)), intent(in) :: windstr_y_water, str_ice_oce_y
real, dimension (SZI_(G),SZJ_(G),0:IG%CatIce), intent(in) :: part_size
real :: ps_vel ! part_size interpolated to a velocity point, nondim.
integer :: i, j, k, isc, iec, jsc, jec, ncat
isc = G%isc ; iec = G%iec ; jsc = G%jsc ; jec = G%jec ; ncat = IG%CatIce
if (IOF%stress_count == 0) then
IOF%flux_u_ocn(:,:) = 0.0 ; IOF%flux_v_ocn(:,:) = 0.0
endif
! Copy and interpolate the ice-ocean stress_Bgrid. This code is slightly
! complicated because there are 3 different staggering options supported.
!$OMP parallel default(none) shared(isc,iec,jsc,jec,ncat,G,IOF, &
!$OMP part_size,windstr_x_water,windstr_y_water, &
!$OMP str_ice_oce_x,str_ice_oce_y) &
!$OMP private(ps_vel)
if (IOF%flux_uv_stagger == AGRID) then
!$OMP do
do j=jsc,jec
do i=isc,iec
ps_vel = G%mask2dT(i,j) * part_size(i,j,0)
IOF%flux_u_ocn(i,j) = IOF%flux_u_ocn(i,j) + ps_vel * 0.25 * &
((windstr_x_water(I,J) + windstr_x_water(I-1,J-1)) + &