forked from NOAA-GFDL/SIS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSIS_types.F90
1412 lines (1209 loc) · 70 KB
/
SIS_types.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
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! SIS_types contains a number of common SIS types, along with subroutines to !
! perform various tasks on these types, including allocation, deallocation, !
! registration for restarts, and checksums. !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
module SIS_types
! use mpp_mod, only: mpp_sum, stdout, input_nml_file, PE_here => mpp_pe
! use mpp_domains_mod, only: domain2D, mpp_get_compute_domain, CORNER, EAST, NORTH
use mpp_domains_mod, only: domain2D, CORNER, EAST, NORTH, mpp_redistribute
! use mpp_parameter_mod, only: CGRID_NE, BGRID_NE, AGRID
! use fms_mod, only: open_namelist_file, check_nml_error, close_file
! use fms_io_mod, only: save_restart, restore_state, query_initialized
use fms_io_mod, only: register_restart_field, restart_file_type
use time_manager_mod, only: time_type, time_type_to_real
use coupler_types_mod,only: coupler_2d_bc_type, coupler_3d_bc_type
use SIS_hor_grid, only : SIS_hor_grid_type
use ice_grid, only : ice_grid_type
use SIS2_ice_thm, only : ice_thermo_type, SIS2_ice_thm_CS, enth_from_TS, energy_melt_EnthS
use SIS2_ice_thm, only : get_SIS2_thermo_coefs, temp_from_En_S
use MOM_coms, only : PE_here, max_across_PEs
use MOM_error_handler, only : SIS_error=>MOM_error, FATAL, WARNING, SIS_mesg=>MOM_mesg, is_root_pe
use MOM_file_parser, only : param_file_type
use MOM_hor_index, only : hor_index_type
use SIS_diag_mediator, only : SIS_diag_ctrl, post_data=>post_SIS_data
use SIS_diag_mediator, only : register_SIS_diag_field, register_static_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_type, only : SIS_sum_out_CS
use SIS_tracer_registry, only : SIS_tracer_registry_type
implicit none ; private
#include <SIS2_memory.h>
public :: ice_state_type, alloc_IST_arrays, ice_state_register_restarts, dealloc_IST_arrays
public :: IST_chksum, IST_bounds_check, copy_IST_to_IST
public :: ice_ocean_flux_type, alloc_ice_ocean_flux, dealloc_ice_ocean_flux
public :: ocean_sfc_state_type, alloc_ocean_sfc_state, dealloc_ocean_sfc_state
public :: fast_ice_avg_type, alloc_fast_ice_avg, dealloc_fast_ice_avg, copy_FIA_to_FIA
public :: IOF_chksum, FIA_chksum
public :: ice_rad_type, ice_rad_register_restarts, dealloc_ice_rad
public :: simple_OSS_type, alloc_simple_OSS, dealloc_simple_OSS, copy_sOSS_to_sOSS
public :: redistribute_IST_to_IST, redistribute_FIA_to_FIA, redistribute_sOSS_to_sOSS
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! This structure contains the ice model state, and is intended to be private !
! to SIS2. It is not to be shared with other components and modules, and may !
! use different indexing conventions than other components. !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
type ice_state_type
! The 8 of the following 10 variables constitute the sea-ice state.
real, allocatable, dimension(:,:,:) :: &
part_size ! The fractional coverage of a grid cell by each ice
! thickness category, nondim, 0 to 1. Category 0 is
! open ocean. The sum of part_size is 1.
! These velocities are only used on the slow ice processors
real, allocatable, dimension(:,:) :: &
u_ice_B, & ! The pseudo-zonal and pseudo-meridional ice velocities
v_ice_B, & ! along the model's grid directions on a B-grid, in m s-1.
! All thickness categories are assumed to have the same
! velocity.
u_ice_C, & ! The pseudo-zonal and pseudo-meridional ice velocities
v_ice_C ! along the model's grid directions on a C-grid, in m s-1.
! All thickness categories are assumed to have the same
! velocity.
real, allocatable, dimension(:,:,:) :: &
mH_pond, & ! The mass per unit area of the pond in each category,
! in units of H (usually kg m-2). mw/new
mH_snow, & ! The mass per unit area of the snow in each category,
! in units of H (usually kg m-2).
mH_ice, & ! The mass per unit area of the ice in each category,
! in units of H (usually kg m-2).
t_surf ! The surface temperature, in Kelvin.
real, allocatable, dimension(:,:,:,:) :: &
sal_ice, & ! The salinity of the sea ice in each category and
! fractional thickness layer, in g/kg.
enth_ice, & ! The enthalpy of the sea ice in each category and
! fractional thickness layer, in enth_unit (J/kg or rescaled).
enth_snow ! The enthalpy of the snow in each category, in enth_unit.
real, allocatable, dimension(:,:,:) :: &
rdg_mice ! A diagnostic of the ice load that was formed by
! ridging, in H (usually kg m-2).
logical :: Cgrid_dyn ! If true use a C-grid discretization of the
! sea-ice dynamics.
type(SIS_tracer_registry_type), pointer :: TrReg => NULL()
type(ice_thermo_type), pointer :: ITV => NULL()
end type ice_state_type
!> ocean_sfc_state_type contains variables that describe the ocean's surface
!! state as seen by the slowly evolving sea-ice, on the ice grid.
type ocean_sfc_state_type
! 6 of the following 8 variables describe the ocean state as seen by the sea ice.
real, allocatable, dimension(:,:) :: &
s_surf , & ! The ocean's surface salinity in g/kg.
t_ocn , & ! The ocean's bulk surface temperature in degC.
u_ocn_B, & ! The ocean's zonal velocity on B-grid points in m s-1.
v_ocn_B, & ! The ocean's meridional velocity on B-grid points in m s-1.
u_ocn_C, & ! The ocean's zonal and meridional velocity on C-grid
v_ocn_C, & ! points, both in m s-1.
frazil , & ! A downward heat flux from the ice into the ocean
! associated with the formation of frazil ice in
! the ocean integrated over a timestep, in J m-2.
! This is the input value and is not changed by the ice.
sea_lev ! The equivalent sea-level, after any non-levitating
! ice has been converted to sea-water, as determined
! by the ocean, in m. Sea-ice only contributes by
! applying pressure to the ocean that is then
! (partially) converted back to its equivalent by the
! ocean.
real, allocatable, dimension(:,:,:) :: &
tr_array ! An array of fields related to properties for additional tracers.
integer :: num_tr = -1 ! The number of additional tracer-related arrays.
! type(coupler_3d_bc_type) :: ocean_fields ! array of fields used for additional tracers
real :: kmelt ! A constant that is used in the calculation of the ocean/ice
! basal heat flux, in W m-2 K-1. This could be replaced with
! an array reflecting the turbulence in the under-ice ocean
! boundary layer and the effective depth of the reported value
! of t_ocn.
logical :: Cgrid_dyn ! If true use a C-grid discretization of the
! sea-ice dynamics.
! diagnostic IDs for ocean surface properties.
integer :: id_sst=-1, id_sss=-1, id_ssh=-1, id_uo=-1, id_vo=-1, id_frazil=-1
end type ocean_sfc_state_type
!> simple_OSS_type contains variables that describe the ocean's surface
!! state as seen by the fast sea-ice or atmosphere, on the ice grid.
type simple_OSS_type
! The following 5 variables describe the ocean state as seen by the
! atmosphere and use for the rapid thermodynamic sea ice changes.
real, allocatable, dimension(:,:) :: &
s_surf , & ! The ocean's surface salinity in g/kg.
t_ocn , & ! The ocean's bulk surface temperature in degC.
u_ocn_A, & ! The ocean's zonal surface velocity on A-grid points in m s-1.
v_ocn_A, & ! The ocean's meridional surface velocity on A-grid points in m s-1.
u_ice_A, & ! The sea ice's zonal velocity on A-grid points in m s-1.
v_ice_A, & ! The sea ice's meridional velocity on A-grid points in m s-1.
bheat ! The upward diffusive heat flux from the ocean
! to the ice at the base of the ice, in W m-2.
real, allocatable, dimension(:,:,:) :: &
tr_array ! An array of fields related to properties for additional tracers.
integer :: num_tr = -1 ! The number of additional tracer-related arrays.
logical :: first_copy = .true.
end type simple_OSS_type
!> fast_ice_avg_type contains variables that describe the fluxes between the
!! atmosphere and the ice or that have been accumlated over fast thermodynamic
!! steps but will be applied to the slow (mass-changing) thermodynamics. Some
!! of these are diagnostics, while others are averages of fluxes taken during
!! the fast ice thermodynamics and used during the slow ice thermodynamics or dynamics.
type fast_ice_avg_type
!FAST ONLY
integer :: avg_count ! The number of times that surface fluxes to the ice
! have been incremented.
logical :: atmos_winds ! The wind stresses come directly from the atmosphere
! model and have the wrong sign.
! These are the arrays that are averaged over the fast thermodynamics. They
! are either used to communicate to the slow thermodynamics or diagnostics or
! both.
real, allocatable, dimension(:,:,:) :: &
! The 3rd dimension in each of the following is ice thickness category.
flux_u_top , & ! The downward flux of zonal and meridional
flux_v_top , & ! momentum on an A-grid in Pa.
flux_t_top , & ! The upward sensible heat flux at the ice top
! in W m-2.
flux_q_top , & ! The upward evaporative moisture flux at
! top of the ice, in kg m-2 s-1.
flux_lw_top , & ! The downward flux of longwave radiation at
! the top of the ice, in W m-2.
flux_sw_vis_dir_top, & ! The downward diffuse flux of direct (dir)
flux_sw_vis_dif_top, & ! and diffuse (dif) shortwave radiation in
flux_sw_nir_dir_top, & ! the visible (vis) and near-infrared (nir)
flux_sw_nir_dif_top, & ! bands at the top of the ice, in W m-2.
flux_lh_top , & ! The upward flux of latent heat at the top
! of the ice, in W m-2.
lprec_top , & ! The downward flux of liquid precipitation
! at the top of the ice, in kg m-2 s-1.
fprec_top , & ! The downward flux of frozen precipitation
! at the top of the ice, in kg m-2 s-1.
tmelt , & ! Ice-top melt energy into the ice/snow in J m-2.
bmelt , & ! Ice-bottom melting energy into the ice in J m-2.
sw_abs_ocn ! The fraction of the absorbed shortwave radiation that is
! absorbed in the ocean, nondim and <=1.
! Equivalent sw_abs_ocn fields are in both the fast_ice_avg_type
! and the ice_rad_type because it is used as a part of the slow
! thermodynamic updates.
real, allocatable, dimension(:,:) :: &
bheat , & ! The upward diffusive heat flux from the ocean
! to the ice at the base of the ice, in W m-2.
WindStr_x , & ! The zonal wind stress averaged over the ice
! categories on an A-grid, in Pa.
WindStr_y , & ! The meridional wind stress averaged over the
! ice categories on an A-grid, in Pa.
WindStr_ocn_x, & ! The zonal wind stress on open water on an A-grid, in Pa.
WindStr_ocn_y, & ! The meridional wind stress on open water on an A-grid, in Pa.
p_atm_surf , & ! The atmospheric pressure at the top of the ice, in Pa.
flux_sw_dn, & ! The total downward shortwave flux, summed across all
! wavelengths and averaged across all thickness categories
! in W m-2.
runoff, & ! Liquid runoff into the ocean, in kg m-2.
calving, & ! Calving of ice or runoff of frozen fresh
! water into the ocean, in kg m-2.
runoff_hflx, & ! The heat flux associated with runoff, based
! on the temperature difference relative to a
! reference temperature, in ???.
calving_hflx, & ! The heat flux associated with calving, based
! on the temperature difference relative to a
! reference temperature, in ???.
calving_preberg, & ! Calving of ice or runoff of frozen fresh
! water into the ocean, exclusive of any
! iceberg contributions, in kg m-2.
calving_hflx_preberg, & ! The heat flux associated with calving,
! exclusive of any iceberg contributions, based on
! the temperature difference relative to a
! reference temperature, in ???.
ice_free , & ! The fractional open water used in calculating
! WindStr_[xy]_A; nondimensional, between 0 & 1.
ice_cover ! The fractional ice coverage, summed across all
! thickness categories, used in calculating
! WindStr_[xy]_A; nondimensional, between 0 & 1.
logical :: first_copy = .true.
integer :: num_tr_fluxes = -1 ! The number of tracer flux fields
real, allocatable, dimension(:,:,:,:) :: &
tr_flux_top ! An array of tracer fluxes at the top of the
! sea ice.
!SLOW ONLY
real, allocatable, dimension(:,:) :: &
frazil_left ! The frazil heat flux that has not yet been
! consumed in making ice, in J m-2. This array
! is decremented by the ice model as the heat
! flux is used up.
!SLOW ONLY
integer :: id_sh=-1, id_lh=-1, id_sw=-1, id_slp=-1
integer :: id_lw=-1, id_snofl=-1, id_rain=-1, id_evap=-1
integer :: id_sw_vis_dir=-1, id_sw_vis_dif=-1, id_sw_nir_dir=-1, id_sw_nir_dif=-1
integer :: id_sw_vis=-1, id_sw_dir=-1, id_sw_dif=-1, id_sw_dn=-1, id_albedo=-1
integer :: id_runoff=-1, id_calving=-1, id_runoff_hflx=-1, id_calving_hflx=-1
integer :: id_tmelt=-1, id_bmelt=-1, id_bheat=-1
end type fast_ice_avg_type
!> ice_rad_type contains variables that describe the absorption and reflection
!! of shortwave radiation in and around the sea ice.
type ice_rad_type
! The ice skin temperature that can next be used for radiation
real, allocatable, dimension(:,:,:) :: &
t_skin ! The surface skin temperature as calculated by the most
! recent fast atmospheric timestep, or a value filled in
! from other ice categories or the local freezing point of
! seawater when there is no ice at all, in Kelvin.
! Shortwave absorption parameters that are set in ice_optics.
real, allocatable, dimension(:,:,:) :: &
sw_abs_sfc , & !< The fraction of the absorbed shortwave radiation that is
!! absorbed in a surface skin layer, nondim and <=1.
sw_abs_snow, & !< The fraction of the absorbed shortwave radiation that is
!! absorbed in the snow, nondim and <=1.
sw_abs_ocn , & !< The fraction of the absorbed shortwave radiation that is
!! absorbed in the ocean, nondim and <=1.
! Only sw_abs_ocn is used in the slow step.
sw_abs_int !< The fraction of the absorbed shortwave radiation that is
!! absorbed by all ice layers in aggregate, nondim and <=1.
! sw_abs_int is only used for diagnostics.
real, allocatable, dimension(:,:,:,:) :: &
sw_abs_ice !< The fraction of the absorbed shortwave that is
!! absorbed in each of the ice layers, nondim, <=1.
real, allocatable, dimension(:,:) :: &
coszen_nextrad !< Cosine of the solar zenith angle averaged
!! over the next radiation timestep, nondim.
logical :: add_diurnal_sw !< If true, apply a synthetic diurnal cycle to
!! the shortwave radiation.
logical :: do_sun_angle_for_alb !< If true, find the sun angle for calculating
!! the ocean albedo in the frame of the ice model.
logical :: frequent_albedo_update !< If true, update the ice and ocean albedos
!! within the fast ice model update. Otherwise,
!! the albedos are only updated within
!! set_ice_surface_state.
integer, allocatable, dimension(:) :: id_sw_abs_ice
integer :: id_sw_abs_sfc=-1, id_sw_abs_snow=-1, id_sw_pen=-1, id_sw_abs_ocn=-1
integer :: id_alb=-1, id_coszen=-1, id_swdn=-1, id_lwdn=-1
integer :: id_alb_vis_dir=-1, id_alb_vis_dif=-1, id_alb_nir_dir=-1, id_alb_nir_dif=-1
integer :: id_tskin=-1, id_cn=-1, id_mi=-1
end type ice_rad_type
!> ice_ocean_flux_type contains variables that describe the fluxes between the
!! ice and the ocean, on the ice grid.
type ice_ocean_flux_type
! These variables describe the fluxes between ice or atmosphere and the ocean.
real, allocatable, dimension(:,:) :: &
flux_t_ocn_top , & ! The upward sensible heat flux from the ocean
! to the ice or atmosphere, in W m-2.
flux_q_ocn_top , & ! The upward evaporative moisture flux at
! the ocean surface, in kg m-2 s-1.
flux_lw_ocn_top, & ! The downward flux of longwave radiation at
! the ocean surface, in W m-2.
flux_sw_vis_dir_ocn, & ! The downward diffuse flux of direct (dir)
flux_sw_vis_dif_ocn, & ! and diffuse (dif) shortwave radiation in
flux_sw_nir_dir_ocn, & ! the visible (vis) and near-infrared (nir)
flux_sw_nir_dif_ocn, & ! bands at the ocean surface, in W m-2.
flux_lh_ocn_top, & ! The upward flux of latent heat at the
! ocean surface, in W m-2.
lprec_ocn_top, & ! The downward flux of liquid precipitation at
! the ocean surface, in kg m-2 s-1.
fprec_ocn_top, & ! The downward flux of frozen precipitation at
! the ocean surface, in kg m-2 s-1.
flux_u_ocn, & ! The flux of x-momentum into the ocean, in Pa,
! at locations determined by flux_uv_stagger,
! but allocated as though on an A-grid.
flux_v_ocn, & ! The flux of y-momentum into the ocean, in Pa,
! at locations determined by flux_uv_stagger,
! but allocated as though on an A-grid.
melt_nudge, & ! A downward fresh water flux into the ocean that
! acts to nudge the ocean surface salinity to
! facilitate the retention of sea ice, in kg m-2 s-1.
flux_salt ! The flux of salt out of the ocean in kg m-2.
!Iceberg fields
real, pointer, dimension(:,:) :: &
ustar_berg =>NULL(), & ! ustar contribution below icebergs in m/s
area_berg =>NULL(), & ! fraction of grid cell covered by icebergs in m2/m2
mass_berg =>NULL() ! mass of icebergs in km/m^2
! These arrays are used for enthalpy change diagnostics in the slow thermodynamics.
real, allocatable, dimension(:,:) :: &
! These terms diagnose the enthalpy change associated with the addition or
! removal of water mass (liquid or frozen) from the ice model are required
! to close the enthalpy budget. Ice enthalpy is generally negative, so terms
! that add mass to the ice are generally negative.
Enth_Mass_in_atm , & ! The enthalpy introduced to the ice by water
! fluxes from the atmosphere, in J m-2.
Enth_Mass_out_atm, & ! Negative of the enthalpy extracted from the
! ice by water fluxes to the atmosphere, in J m-2.
Enth_Mass_in_ocn , & ! The enthalpy introduced to the ice by water
! fluxes from the ocean, in J m-2.
Enth_Mass_out_ocn ! Negative of the enthalpy extracted from the
! ice by water fluxes to the ocean, in J m-2.
integer :: stress_count ! The number of times that the stresses from the ice
! to the ocean have been incremented.
integer :: flux_uv_stagger = -999 ! The staggering relative to the tracer points
! points of the two wind stress components. Valid entries
! include AGRID, BGRID_NE, CGRID_NE, BGRID_SW, and CGRID_SW,
! corresponding to the community-standard Arakawa notation.
! (These are named integers taken from mpp_parameter_mod.)
! Following SIS, this is BGRID_NE by default when the sea
! ice is initialized, but here it is set to -999 so that a
! global max across ice and non-ice processors can be used
! to determine its value.
logical :: slp2ocean ! If true, apply sea level pressure to ocean surface.
! type(coupler_2d_bc_type) :: ocean_fluxes ! array of fluxes used for additional tracers
integer :: num_tr_fluxes = -1 ! The number of tracer flux fields
real, allocatable, dimension(:,:,:) :: &
tr_flux_ocn_top ! An array of tracer fluxes at the ocean's surface.
! diagnostic IDs for ice-to-ocean fluxes.
integer :: id_saltf=-1
! The following are diagnostic IDs for iceberg-related fields. These are only
! used if the iceberg code is activated.
integer :: id_ustar_berg=-1, id_area_berg=-1, id_mass_berg=-1
end type ice_ocean_flux_type
contains
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> alloc_IST_arrays allocates the arrays in an ice_state_type.
subroutine alloc_IST_arrays(HI, IG, IST, omit_velocities)
type(hor_index_type), intent(in) :: HI
type(ice_grid_type), intent(in) :: IG
type(ice_state_type), intent(inout) :: IST
logical, optional, intent(in) :: omit_velocities
integer :: isd, ied, jsd, jed, CatIce, NkIce, idr
logical :: do_vel
do_vel = .true. ; if (present(omit_velocities)) do_vel = .not.omit_velocities
CatIce = IG%CatIce ; NkIce = IG%NkIce
isd = HI%isd ; ied = HI%ied ; jsd = HI%jsd ; jed = HI%jed
allocate(IST%part_size(isd:ied, jsd:jed, 0:CatIce)) ; IST%part_size(:,:,:) = 0.0
allocate(IST%mH_pond( isd:ied, jsd:jed, CatIce)) ; IST%mH_pond(:,:,:) = 0.0
allocate(IST%mH_snow( isd:ied, jsd:jed, CatIce)) ; IST%mH_snow(:,:,:) = 0.0
allocate(IST%enth_snow(isd:ied, jsd:jed, CatIce, 1)) ; IST%enth_snow(:,:,:,:) = 0.0
allocate(IST%mH_ice( isd:ied, jsd:jed, CatIce)) ; IST%mH_ice(:,:,:) = 0.0
allocate(IST%enth_ice( isd:ied, jsd:jed, CatIce, NkIce)) ; IST%enth_ice(:,:,:,:) = 0.0
allocate(IST%sal_ice( isd:ied, jsd:jed, CatIce, NkIce)) ; IST%sal_ice(:,:,:,:) = 0.0
if (do_vel) then
! These velocities are only required for the slow ice processes, and hence
! can use the memory macros.
if (IST%Cgrid_dyn) then
allocate(IST%u_ice_C(SZIB_(HI), SZJ_(HI))) ; IST%u_ice_C(:,:) = 0.0
allocate(IST%v_ice_C(SZI_(HI), SZJB_(HI))) ; IST%v_ice_C(:,:) = 0.0
else
allocate(IST%u_ice_B(SZIB_(HI), SZJB_(HI))) ; IST%u_ice_B(:,:) = 0.0
allocate(IST%v_ice_B(SZIB_(HI), SZJB_(HI))) ; IST%v_ice_B(:,:) = 0.0
endif
! ### THESE ARE DIAGNOSTICS. PERHAPS THEY SHOULD ONLY BE ALLOCATED IF USED.
allocate(IST%rdg_mice(isd:ied, jsd:jed, CatIce)) ; IST%rdg_mice(:,:,:) = 0.0
endif
allocate(IST%t_surf(isd:ied, jsd:jed, 0:CatIce)) ; IST%t_surf(:,:,:) = 0.0
end subroutine alloc_IST_arrays
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> ice_state_register_restarts registers any variables in the ice state type
!! that need to be includedin the restart files.
subroutine ice_state_register_restarts(mpp_domain, IST, IG, Ice_restart, restart_file)
type(domain2d), intent(in) :: mpp_domain
type(ice_state_type), intent(inout) :: IST
type(ice_grid_type), intent(in) :: IG
type(restart_file_type), pointer :: Ice_restart
character(len=*), intent(in) :: restart_file
integer :: idr
! Now register some of these arrays to be read from the restart files.
if (associated(Ice_restart)) then
idr = register_restart_field(Ice_restart, restart_file, 'part_size', IST%part_size, domain=mpp_domain)
idr = register_restart_field(Ice_restart, restart_file, 't_surf', IST%t_surf, &
domain=mpp_domain)
idr = register_restart_field(Ice_restart, restart_file, 'h_pond', IST%mH_pond, & ! mw/new
domain=mpp_domain, mandatory=.false., units="H_to_kg_m2 kg m-2")
idr = register_restart_field(Ice_restart, restart_file, 'h_snow', IST%mH_snow, &
domain=mpp_domain, mandatory=.true., units="H_to_kg_m2 kg m-2")
idr = register_restart_field(Ice_restart, restart_file, 'enth_snow', IST%enth_snow, &
domain=mpp_domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'h_ice', IST%mH_ice, &
domain=mpp_domain, mandatory=.true., units="H_to_kg_m2 kg m-2")
idr = register_restart_field(Ice_restart, restart_file, 'H_to_kg_m2', IG%H_to_kg_m2, &
longname="The conversion factor from SIS2 mass-thickness units to kg m-2.", &
no_domain=.true., mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'enth_ice', IST%enth_ice, &
domain=mpp_domain, mandatory=.false., units="J kg-1")
idr = register_restart_field(Ice_restart, restart_file, 'sal_ice', IST%sal_ice, &
domain=mpp_domain, mandatory=.false., units="kg/kg")
if (IST%Cgrid_dyn) then
idr = register_restart_field(Ice_restart, restart_file, 'u_ice_C', IST%u_ice_C, &
domain=mpp_domain, position=EAST, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'v_ice_C', IST%v_ice_C, &
domain=mpp_domain, position=NORTH, mandatory=.false.)
else
idr = register_restart_field(Ice_restart, restart_file, 'u_ice', IST%u_ice_B, &
domain=mpp_domain, position=CORNER, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'v_ice', IST%v_ice_B, &
domain=mpp_domain, position=CORNER, mandatory=.false.)
endif
endif
end subroutine ice_state_register_restarts
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> alloc_fast_ice_avg allocates and zeros out the arrays in a fast_ice_avg_type.
subroutine alloc_fast_ice_avg(FIA, HI, IG)
type(fast_ice_avg_type), pointer :: FIA
type(hor_index_type), intent(in) :: HI
type(ice_grid_type), intent(in) :: IG
integer :: isd, ied, jsd, jed, CatIce, NkIce
if (.not.associated(FIA)) allocate(FIA)
CatIce = IG%CatIce ; NkIce = IG%NkIce
isd = HI%isd ; ied = HI%ied ; jsd = HI%jsd ; jed = HI%jed
FIA%avg_count = 0
allocate(FIA%flux_u_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_u_top(:,:,:) = 0.0
allocate(FIA%flux_v_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_v_top(:,:,:) = 0.0
allocate(FIA%flux_t_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_t_top(:,:,:) = 0.0
allocate(FIA%flux_q_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_q_top(:,:,:) = 0.0
allocate(FIA%flux_sw_vis_dir_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_sw_vis_dir_top(:,:,:) = 0.0
allocate(FIA%flux_sw_vis_dif_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_sw_vis_dif_top(:,:,:) = 0.0
allocate(FIA%flux_sw_nir_dir_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_sw_nir_dir_top(:,:,:) = 0.0
allocate(FIA%flux_sw_nir_dif_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_sw_nir_dif_top(:,:,:) = 0.0
allocate(FIA%flux_lw_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_lw_top(:,:,:) = 0.0
allocate(FIA%flux_lh_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%flux_lh_top(:,:,:) = 0.0
allocate(FIA%lprec_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%lprec_top(:,:,:) = 0.0
allocate(FIA%fprec_top(isd:ied, jsd:jed, 0:CatIce)) ; FIA%fprec_top(:,:,:) = 0.0
allocate(FIA%runoff(isd:ied, jsd:jed)) ; FIA%runoff(:,:) = 0.0 !NI
allocate(FIA%calving(isd:ied, jsd:jed)) ; FIA%calving(:,:) = 0.0 !NI
allocate(FIA%calving_preberg(isd:ied, jsd:jed)) ; FIA%calving_preberg(:,:) = 0.0 !NI, diag
allocate(FIA%runoff_hflx(isd:ied, jsd:jed)) ; FIA%runoff_hflx(:,:) = 0.0 !NI
allocate(FIA%calving_hflx(isd:ied, jsd:jed)) ; FIA%calving_hflx(:,:) = 0.0 !NI
allocate(FIA%calving_hflx_preberg(isd:ied, jsd:jed)) ; FIA%calving_hflx_preberg(:,:) = 0.0 !NI, diag
allocate(FIA%frazil_left(isd:ied, jsd:jed)) ; FIA%frazil_left(:,:) = 0.0
allocate(FIA%bheat(isd:ied, jsd:jed)) ; FIA%bheat(:,:) = 0.0
allocate(FIA%tmelt(isd:ied, jsd:jed, CatIce)) ; FIA%tmelt(:,:,:) = 0.0
allocate(FIA%bmelt(isd:ied, jsd:jed, CatIce)) ; FIA%bmelt(:,:,:) = 0.0
allocate(FIA%WindStr_x(isd:ied, jsd:jed)) ; FIA%WindStr_x(:,:) = 0.0
allocate(FIA%WindStr_y(isd:ied, jsd:jed)) ; FIA%WindStr_y(:,:) = 0.0
allocate(FIA%WindStr_ocn_x(isd:ied, jsd:jed)) ; FIA%WindStr_ocn_x(:,:) = 0.0
allocate(FIA%WindStr_ocn_y(isd:ied, jsd:jed)) ; FIA%WindStr_ocn_y(:,:) = 0.0
allocate(FIA%p_atm_surf(isd:ied, jsd:jed)) ; FIA%p_atm_surf(:,:) = 0.0
allocate(FIA%ice_free(isd:ied, jsd:jed)) ; FIA%ice_free(:,:) = 0.0
allocate(FIA%ice_cover(isd:ied, jsd:jed)) ; FIA%ice_cover(:,:) = 0.0
allocate(FIA%flux_sw_dn(isd:ied, jsd:jed)) ; FIA%flux_sw_dn(:,:) = 0.0
allocate(FIA%sw_abs_ocn(isd:ied, jsd:jed, CatIce)) ; FIA%sw_abs_ocn(:,:,:) = 0.0
end subroutine alloc_fast_ice_avg
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> ice_rad_register_restarts allocates the arrays in the ice_rad_type
!! and registers any variables in the ice rad type that need to be included
!! in the restart files.
subroutine ice_rad_register_restarts(mpp_domain, HI, IG, param_file, Rad, &
Ice_restart, restart_file)
type(domain2d), intent(in) :: mpp_domain
type(hor_index_type), intent(in) :: HI
type(ice_grid_type), intent(in) :: IG
type(param_file_type), intent(in) :: param_file
type(ice_rad_type), pointer :: Rad
type(restart_file_type), intent(inout) :: Ice_restart
character(len=*), intent(in) :: restart_file
integer :: isd, ied, jsd, jed, CatIce, NkIce, idr
if (.not.associated(Rad)) allocate(Rad)
CatIce = IG%CatIce ; NkIce = IG%NkIce
isd = HI%isd ; ied = HI%ied ; jsd = HI%jsd ; jed = HI%jed
allocate(Rad%t_skin(isd:ied, jsd:jed, CatIce)) ; Rad%t_skin(:,:,:) = 0.0
allocate(Rad%sw_abs_sfc(isd:ied, jsd:jed, CatIce)) ; Rad%sw_abs_sfc(:,:,:) = 0.0
allocate(Rad%sw_abs_snow(isd:ied, jsd:jed, CatIce)) ; Rad%sw_abs_snow(:,:,:) = 0.0
allocate(Rad%sw_abs_ice(isd:ied, jsd:jed, CatIce, NkIce)) ; Rad%sw_abs_ice(:,:,:,:) = 0.0
allocate(Rad%sw_abs_ocn(isd:ied, jsd:jed, CatIce)) ; Rad%sw_abs_ocn(:,:,:) = 0.0
allocate(Rad%sw_abs_int(isd:ied, jsd:jed, CatIce)) ; Rad%sw_abs_int(:,:,:) = 0.0
allocate(Rad%coszen_nextrad(isd:ied, jsd:jed)) ; Rad%coszen_nextrad(:,:) = 0.0
idr = register_restart_field(Ice_restart, restart_file, 'coszen', Rad%coszen_nextrad, &
domain=mpp_domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'T_skin', Rad%t_skin, &
domain=mpp_domain, mandatory=.false.)
end subroutine ice_rad_register_restarts
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> alloc_ice_ocean_flux allocates and zeros out the arrays in an ice_ocean_flux_type.
subroutine alloc_ice_ocean_flux(IOF, HI, do_iceberg_fields)
type(ice_ocean_flux_type), pointer :: IOF
type(hor_index_type), intent(in) :: HI
logical, optional, intent(in) :: do_iceberg_fields
integer :: CatIce
logical :: alloc_bergs
alloc_bergs = .false. ; if (present(do_iceberg_fields)) alloc_bergs = do_iceberg_fields
if (.not.associated(IOF)) allocate(IOF)
allocate(IOF%flux_salt(SZI_(HI), SZJ_(HI))) ; IOF%flux_salt(:,:) = 0.0
allocate(IOF%flux_t_ocn_top(SZI_(HI), SZJ_(HI))) ; IOF%flux_t_ocn_top(:,:) = 0.0
allocate(IOF%flux_q_ocn_top(SZI_(HI), SZJ_(HI))) ; IOF%flux_q_ocn_top(:,:) = 0.0
allocate(IOF%flux_lw_ocn_top(SZI_(HI), SZJ_(HI))) ; IOF%flux_lw_ocn_top(:,:) = 0.0
allocate(IOF%flux_lh_ocn_top(SZI_(HI), SZJ_(HI))) ; IOF%flux_lh_ocn_top(:,:) = 0.0
allocate(IOF%flux_sw_vis_dir_ocn(SZI_(HI), SZJ_(HI))) ; IOF%flux_sw_vis_dir_ocn(:,:) = 0.0
allocate(IOF%flux_sw_vis_dif_ocn(SZI_(HI), SZJ_(HI))) ; IOF%flux_sw_vis_dif_ocn(:,:) = 0.0
allocate(IOF%flux_sw_nir_dir_ocn(SZI_(HI), SZJ_(HI))) ; IOF%flux_sw_nir_dir_ocn(:,:) = 0.0
allocate(IOF%flux_sw_nir_dif_ocn(SZI_(HI), SZJ_(HI))) ; IOF%flux_sw_nir_dif_ocn(:,:) = 0.0
allocate(IOF%lprec_ocn_top(SZI_(HI), SZJ_(HI))) ; IOF%lprec_ocn_top(:,:) = 0.0
allocate(IOF%fprec_ocn_top(SZI_(HI), SZJ_(HI))) ; IOF%fprec_ocn_top(:,:) = 0.0
allocate(IOF%flux_u_ocn(SZI_(HI), SZJ_(HI))) ; IOF%flux_u_ocn(:,:) = 0.0
allocate(IOF%flux_v_ocn(SZI_(HI), SZJ_(HI))) ; IOF%flux_v_ocn(:,:) = 0.0
allocate(IOF%Enth_Mass_in_atm(SZI_(HI), SZJ_(HI))) ; IOF%Enth_Mass_in_atm(:,:) = 0.0
allocate(IOF%Enth_Mass_out_atm(SZI_(HI), SZJ_(HI))) ; IOF%Enth_Mass_out_atm(:,:) = 0.0
allocate(IOF%Enth_Mass_in_ocn(SZI_(HI), SZJ_(HI))) ; IOF%Enth_Mass_in_ocn(:,:) = 0.0
allocate(IOF%Enth_Mass_out_ocn(SZI_(HI), SZJ_(HI))) ; IOF%Enth_Mass_out_ocn(:,:) = 0.0
!Allocating iceberg fields (only used if pass_iceberg_area_to_ocean=.True.)
! Please note that these are only allocated on the computational domain so that they
! can be passed conveniently to the iceberg code.
if (alloc_bergs) then
allocate(IOF%mass_berg(HI%isc:HI%iec, HI%jsc:HI%jec)) ; IOF%mass_berg(:,:) = 0.0
allocate(IOF%ustar_berg(HI%isc:HI%iec, HI%jsc:HI%jec)) ; IOF%ustar_berg(:,:) = 0.0
allocate(IOF%area_berg(HI%isc:HI%iec, HI%jsc:HI%jec)) ; IOF%area_berg(:,:) = 0.0
endif
end subroutine alloc_ice_ocean_flux
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> alloc_ocean_sfc_state allocates and zeros out the arrays in an ocean_sfc_state_type.
subroutine alloc_ocean_sfc_state(OSS, HI, Cgrid_dyn)
type(ocean_sfc_state_type), pointer :: OSS
type(hor_index_type), intent(in) :: HI
logical, intent(in) :: Cgrid_dyn
if (.not.associated(OSS)) allocate(OSS)
! The ocean_sfc_state_type only occurs on slow ice PEs, so it can use the memory macros.
allocate(OSS%s_surf(SZI_(HI), SZJ_(HI))) ; OSS%s_surf(:,:) = 0.0
allocate(OSS%t_ocn(SZI_(HI), SZJ_(HI))) ; OSS%t_ocn(:,:) = 0.0
allocate(OSS%sea_lev(SZI_(HI), SZJ_(HI))) ; OSS%sea_lev(:,:) = 0.0
allocate(OSS%frazil(SZI_(HI), SZJ_(HI))) ; OSS%frazil(:,:) = 0.0
if (Cgrid_dyn) then
allocate(OSS%u_ocn_C(SZIB_(HI), SZJ_(HI))) ; OSS%u_ocn_C(:,:) = 0.0
allocate(OSS%v_ocn_C(SZI_(HI), SZJB_(HI))) ; OSS%v_ocn_C(:,:) = 0.0
else
allocate(OSS%u_ocn_B(SZIB_(HI), SZJB_(HI))) ; OSS%u_ocn_B(:,:) = 0.0
allocate(OSS%v_ocn_B(SZIB_(HI), SZJB_(HI))) ; OSS%v_ocn_B(:,:) = 0.0
endif
OSS%Cgrid_dyn = Cgrid_dyn
end subroutine alloc_ocean_sfc_state
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> alloc_simple_ocean_sfc_state allocates and zeros out the arrays in a
!! simple_OSS_type.
subroutine alloc_simple_OSS(OSS, HI)
type(simple_OSS_type), pointer :: OSS
type(hor_index_type), intent(in) :: HI
integer :: isd, ied, jsd, jed
if (.not.associated(OSS)) allocate(OSS)
isd = HI%isd ; ied = HI%ied ; jsd = HI%jsd ; jed = HI%jed
allocate(OSS%s_surf(isd:ied, jsd:jed)) ; OSS%s_surf(:,:) = 0.0
allocate(OSS%t_ocn(isd:ied, jsd:jed)) ; OSS%t_ocn(:,:) = 0.0
allocate(OSS%bheat(isd:ied, jsd:jed)) ; OSS%bheat(:,:) = 0.0
allocate(OSS%u_ocn_A(isd:ied, jsd:jed)) ; OSS%u_ocn_A(:,:) = 0.0
allocate(OSS%v_ocn_A(isd:ied, jsd:jed)) ; OSS%v_ocn_A(:,:) = 0.0
allocate(OSS%u_ice_A(isd:ied, jsd:jed)) ; OSS%u_ice_A(:,:) = 0.0
allocate(OSS%v_ice_A(isd:ied, jsd:jed)) ; OSS%v_ice_A(:,:) = 0.0
end subroutine alloc_simple_OSS
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> copy_IST_to_IST copies the computational domain of one ice state type into
!! the computational domain of another ice_state_type. Both must use the same
!! domain decomposition and indexing convention (for now), but they may have
!! different halo sizes.
subroutine copy_IST_to_IST(IST_in, IST_out, HI_in, HI_out, IG)
type(ice_state_type), intent(in) :: IST_in
type(ice_state_type), intent(inout) :: IST_out
type(hor_index_type), intent(in) :: HI_in, HI_out
type(ice_grid_type), intent(in) :: IG
integer :: i, j, k, m, isc, iec, jsc, jec, ncat, NkIce
integer :: i2, j2, i_off, j_off
isc = HI_in%isc ; iec = HI_in%iec ; jsc = HI_in%jsc ; jec = HI_in%jec
ncat = IG%CatIce ; NkIce = IG%NkIce
if ((HI_in%iec-HI_in%isc /= HI_out%iec-HI_out%isc) .or. &
(HI_in%jec-HI_in%jsc /= HI_out%jec-HI_out%jsc)) then
call SIS_error(FATAL, "copy_IST_to_IST called with inconsistent domain "//&
"decompositions of the two ice types.")
endif
i_off = HI_out%iec-HI_in%iec ; j_off = HI_out%jec-HI_in%jec
do k=0,ncat ; do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off
IST_out%part_size(i2,j2,k) = IST_in%part_size(i,j,k)
IST_out%t_surf(i2,j2,k) = IST_in%t_surf(i,j,k)
enddo ; enddo ; enddo
do k=1,ncat ; do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off
IST_out%mH_pond(i2,j2,k) = IST_in%mH_pond(i,j,k)
IST_out%mH_snow(i2,j2,k) = IST_in%mH_snow(i,j,k)
IST_out%mH_ice(i2,j2,k) = IST_in%mH_ice(i,j,k)
IST_out%enth_snow(i2,j2,k,1) = IST_in%enth_snow(i,j,k,1)
enddo ; enddo ; enddo
do m=1,NkIce ; do k=1,ncat ; do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off
IST_out%enth_ice(i2,j2,k,m) = IST_in%enth_ice(i,j,k,m)
IST_out%sal_ice(i2,j2,k,m) = IST_in%sal_ice(i,j,k,m)
enddo ; enddo ; enddo ; enddo
! The velocity components, rdg_mice, TrReg, and ITV are deliberately not being
! copied.
end subroutine copy_IST_to_IST
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> redistribute_IST_to_IST redistributes the computational domain of one ice state type into
!! the computational domain of another ice_state_type.
subroutine redistribute_IST_to_IST(IST_in, IST_out, domain_in, domain_out)
type(ice_state_type), intent(in) :: IST_in
type(ice_state_type), intent(inout) :: IST_out
type(domain2d), intent(in) :: domain_in, domain_out
call mpp_redistribute(domain_in, IST_in%part_size, domain_out, &
IST_out%part_size, complete=.false.)
call mpp_redistribute(domain_in, IST_in%t_surf, domain_out, &
IST_out%t_surf, complete=.true.)
call mpp_redistribute(domain_in, IST_in%mH_pond, domain_out, &
IST_out%mH_pond, complete=.false.)
call mpp_redistribute(domain_in, IST_in%mH_snow, domain_out, &
IST_out%mH_snow, complete=.false.)
call mpp_redistribute(domain_in, IST_in%mH_ice, domain_out, &
IST_out%mH_ice, complete=.false.)
call mpp_redistribute(domain_in, IST_in%enth_snow, domain_out, &
IST_out%enth_snow, complete=.true.)
call mpp_redistribute(domain_in, IST_in%enth_ice, domain_out, &
IST_out%enth_ice, complete=.false.)
call mpp_redistribute(domain_in, IST_in%sal_ice, domain_out, &
IST_out%sal_ice, complete=.true.)
! The velocity components, rdg_mice, TrReg, and ITV are deliberately not being
! copied.
end subroutine redistribute_IST_to_IST
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> copy_sOSS_to_sOSS copies the computational domain of one simple_OSS_type into
!! the computational domain of another simple_OSS_type. Both must use the same
!! domain decomposition and indexing convention (for now), but they may have
!! different halo sizes.
subroutine copy_sOSS_to_sOSS(OSS_in, OSS_out, HI_in, HI_out)
type(simple_OSS_type), intent(inout) :: OSS_in
type(simple_OSS_type), intent(inout) :: OSS_out
type(hor_index_type), intent(in) :: HI_in, HI_out
integer :: i, j, m, isc, iec, jsc, jec
integer :: i2, j2, i_off, j_off
isc = HI_in%isc ; iec = HI_in%iec ; jsc = HI_in%jsc ; jec = HI_in%jec
if ((HI_in%iec-HI_in%isc /= HI_out%iec-HI_out%isc) .or. &
(HI_in%jec-HI_in%jsc /= HI_out%jec-HI_out%jsc)) then
call SIS_error(FATAL, "copy_sOSS_to_sOSS called with inconsistent domain "//&
"decompositions of the two ice types.")
endif
i_off = HI_out%iec-HI_in%iec ; j_off = HI_out%jec-HI_in%jec
do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off
OSS_out%t_ocn(i2,j2) = OSS_in%t_ocn(i,j)
OSS_out%s_surf(i2,j2) = OSS_in%s_surf(i,j)
OSS_out%bheat(i2,j2) = OSS_in%bheat(i,j)
OSS_out%u_ocn_A(i2,j2) = OSS_in%u_ocn_A(i,j)
OSS_out%v_ocn_A(i2,j2) = OSS_in%v_ocn_A(i,j)
OSS_out%u_ice_A(i2,j2) = OSS_in%u_ice_A(i,j)
OSS_out%v_ice_A(i2,j2) = OSS_in%v_ice_A(i,j)
enddo ; enddo
if (OSS_out%first_copy) then
OSS_in%first_copy = .false. ; OSS_out%first_copy = .false.
OSS_out%num_tr = OSS_in%num_tr
if (OSS_out%num_tr > 0) then
allocate(OSS_out%tr_array(HI_out%isd:HI_out%ied,HI_out%jsd:HI_out%jed,OSS_out%num_tr))
OSS_out%tr_array(:,:,:) = 0.0
endif
endif
do m=1,OSS_in%num_tr ; do j=jsc,jec ; do i=isc,iec
OSS_out%tr_array(i,j,m) = OSS_in%tr_array(i,j,m)
enddo ; enddo ; enddo
end subroutine copy_sOSS_to_sOSS
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> redistribute_sOSS_to_sOSS copies the computational domain of one simple_OSS_type into
!! the computational domain of another simple_OSS_type.
subroutine redistribute_sOSS_to_sOSS(OSS_in, OSS_out, domain_in, domain_out, HI_out)
type(simple_OSS_type), intent(inout) :: OSS_in
type(simple_OSS_type), intent(inout) :: OSS_out
type(domain2d), intent(in) :: domain_in, domain_out
type(hor_index_type), intent(in) :: HI_out
integer :: m, num_tr
if (OSS_in%first_copy .or. OSS_out%first_copy) then
! Determine the number of fluxes.
num_tr = OSS_in%num_tr
call max_across_PEs(num_tr)
OSS_out%num_tr = num_tr
if ((OSS_out%num_tr > 0) .and. .not.allocated(OSS_out%tr_array)) then
allocate(OSS_out%tr_array(HI_out%isd:HI_out%ied,HI_out%jsd:HI_out%jed,OSS_out%num_tr))
OSS_out%tr_array(:,:,:) = 0.0
endif
OSS_in%first_copy = .false. ; OSS_out%first_copy = .false.
endif
! The extra tracer arrays are copied first so that they can all have
! complete=.false.
do m=1,max(OSS_in%num_tr,OSS_out%num_tr)
call mpp_redistribute(domain_in, OSS_in%tr_array(:,:,m), domain_out, &
OSS_out%tr_array(:,:,m), complete=.false.)
enddo
call mpp_redistribute(domain_in, OSS_in%t_ocn, domain_out, &
OSS_out%t_ocn, complete=.false.)
call mpp_redistribute(domain_in, OSS_in%s_surf, domain_out, &
OSS_out%s_surf, complete=.false.)
call mpp_redistribute(domain_in, OSS_in%bheat, domain_out, &
OSS_out%bheat, complete=.false.)
call mpp_redistribute(domain_in, OSS_in%u_ocn_A, domain_out, &
OSS_out%u_ocn_A, complete=.false.)
call mpp_redistribute(domain_in, OSS_in%v_ocn_A, domain_out, &
OSS_out%v_ocn_A, complete=.false.)
call mpp_redistribute(domain_in, OSS_in%u_ice_A, domain_out, &
OSS_out%u_ice_A, complete=.false.)
call mpp_redistribute(domain_in, OSS_in%v_ice_A, domain_out, &
OSS_out%v_ice_A, complete=.true.)
end subroutine redistribute_sOSS_to_sOSS
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> copy_FIA_to_FIA copies the computational domain of one fast_ice_avg_type into
!! the computational domain of another fast_ice_avg_type. Both must use the same
!! domain decomposition and indexing convention (for now), but they may have
!! different halo sizes.
subroutine copy_FIA_to_FIA(FIA_in, FIA_out, HI_in, HI_out, IG)
type(fast_ice_avg_type), intent(inout) :: FIA_in
type(fast_ice_avg_type), intent(inout) :: FIA_out
type(hor_index_type), intent(in) :: HI_in, HI_out
type(ice_grid_type), intent(in) :: IG
integer :: i, j, k, m, n, isc, iec, jsc, jec, ncat, NkIce ! , i_off, j_off
integer :: i2, j2, i_off, j_off
integer :: isd, ied, jsd, jed
isc = HI_in%isc ; iec = HI_in%iec ; jsc = HI_in%jsc ; jec = HI_in%jec
ncat = IG%CatIce ; NkIce = IG%NkIce
if ((HI_in%iec-HI_in%isc /= HI_out%iec-HI_out%isc) .or. &
(HI_in%jec-HI_in%jsc /= HI_out%jec-HI_out%jsc)) then
call SIS_error(FATAL, "copy_FIA_to_FIA called with inconsistent domain "//&
"decompositions of the two ice types.")
endif
i_off = HI_out%iec-HI_in%iec ; j_off = HI_out%jec-HI_in%jec
do k=0,ncat ; do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off
FIA_out%flux_t_top(i2,j2,k) = FIA_in%flux_t_top(i,j,k)
FIA_out%flux_q_top(i2,j2,k) = FIA_in%flux_q_top(i,j,k)
FIA_out%flux_sw_vis_dir_top(i2,j2,k) = FIA_in%flux_sw_vis_dir_top(i,j,k)
FIA_out%flux_sw_vis_dif_top(i2,j2,k) = FIA_in%flux_sw_vis_dif_top(i,j,k)
FIA_out%flux_sw_nir_dir_top(i2,j2,k) = FIA_in%flux_sw_nir_dir_top(i,j,k)
FIA_out%flux_sw_nir_dif_top(i2,j2,k) = FIA_in%flux_sw_nir_dif_top(i,j,k)
FIA_out%flux_lw_top(i2,j2,k) = FIA_in%flux_lw_top(i,j,k)
FIA_out%flux_lh_top(i2,j2,k) = FIA_in%flux_lh_top(i,j,k)
FIA_out%lprec_top(i2,j2,k) = FIA_in%lprec_top(i,j,k)
FIA_out%fprec_top(i2,j2,k) = FIA_in%fprec_top(i,j,k)
enddo ; enddo ; enddo
do k=1,ncat ; do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off
FIA_out%tmelt(i2,j2,k) = FIA_in%tmelt(i,j,k)
FIA_out%bmelt(i2,j2,k) = FIA_in%bmelt(i,j,k)
FIA_out%sw_abs_ocn(i2,j2,k) = FIA_in%sw_abs_ocn(i,j,k)
enddo ; enddo ; enddo
do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off
FIA_out%bheat(i2,j2) = FIA_in%bheat(i,j)
FIA_out%WindStr_x(i2,j2) = FIA_in%WindStr_x(i,j)
FIA_out%WindStr_y(i2,j2) = FIA_in%WindStr_y(i,j)
FIA_out%WindStr_ocn_x(i2,j2) = FIA_in%WindStr_ocn_x(i,j)
FIA_out%WindStr_ocn_y(i2,j2) = FIA_in%WindStr_ocn_y(i,j)
FIA_out%p_atm_surf(i2,j2) = FIA_in%p_atm_surf(i,j)
FIA_out%runoff(i2,j2) = FIA_in%runoff(i,j)
FIA_out%calving(i2,j2) = FIA_in%calving(i,j)
FIA_out%runoff_hflx(i2,j2) = FIA_in%runoff_hflx(i,j)
FIA_out%calving_hflx(i2,j2) = FIA_in%calving_hflx(i,j)
FIA_out%ice_free(i2,j2) = FIA_in%ice_free(i,j)
FIA_out%ice_cover(i2,j2) = FIA_in%ice_cover(i,j)
FIA_out%flux_sw_dn(i2,j2) = FIA_in%flux_sw_dn(i,j)
enddo ; enddo
! FIA%flux_u_top and flux_v_top are deliberately not being copied, as they
! are only needed on the fast_ice_PEs
! FIA%frazil_left is deliberately not being copied, as it is only valid on
! the slow_ice_PEs.
! FIA%calving_preberg and FIA%calving_hflx_preberg are deliberately not
! being copied over.
if (FIA_in%first_copy .or. FIA_out%first_copy) then ; if (FIA_in%num_tr_fluxes >= 0) then
if (FIA_out%num_tr_fluxes < 0) then
! Allocate the tr_flux_top arrays to accommodate the size of the input
! fluxes. This only occurs the first time FIA_out is copied from a fully
! initialized FIA_in.
FIA_out%num_tr_fluxes = FIA_in%num_tr_fluxes
if (FIA_out%num_tr_fluxes > 0) then
isd = HI_out%isd ; ied = HI_out%ied ; jsd = HI_out%jsd ; jed = HI_out%jed
allocate(FIA_out%tr_flux_top(isd:ied, jsd:jed, 0:ncat, FIA_out%num_tr_fluxes))
FIA_out%tr_flux_top(:,:,:,:) = 0.0
endif
endif
FIA_in%first_copy = .false. ; FIA_out%first_copy = .false.
endif ; endif
if (FIA_in%num_tr_fluxes >= 0) then
if (FIA_in%num_tr_fluxes /= FIA_out%num_tr_fluxes) &
call SIS_error(FATAL, "copy_FIA_to_FIA called with different num_tr_fluxes.")
do n=1,FIA_in%num_tr_fluxes ; do k=0,ncat ; do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off
FIA_out%tr_flux_top(i2,j2,k,n) = FIA_in%tr_flux_top(i,j,k,n)
enddo ; enddo ; enddo ; enddo
endif
! avg_count, atmos_winds, and the IDs are deliberately not being copied.
end subroutine copy_FIA_to_FIA
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
!> redistribute_FIA_to_FIA copies the computational domain of one fast_ice_avg_type into
!! the computational domain of another fast_ice_avg_type.
subroutine redistribute_FIA_to_FIA(FIA_in, FIA_out, domain_in, domain_out, G_out, IG)
type(fast_ice_avg_type), intent(inout) :: FIA_in
type(fast_ice_avg_type), intent(inout) :: FIA_out
type(domain2d), intent(in) :: domain_in, domain_out
type(SIS_hor_grid_type), intent(in) :: G_out
type(ice_grid_type), intent(in) :: IG
integer :: i, j, isd, ied, jsd, jed, ncat
integer :: num_tr_flux
call mpp_redistribute(domain_in, FIA_in%flux_t_top, domain_out, &
FIA_out%flux_t_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%flux_q_top, domain_out, &
FIA_out%flux_q_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%flux_sw_vis_dir_top, domain_out, &
FIA_out%flux_sw_vis_dir_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%flux_sw_vis_dif_top, domain_out, &
FIA_out%flux_sw_vis_dif_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%flux_sw_nir_dir_top, domain_out, &
FIA_out%flux_sw_nir_dir_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%flux_sw_nir_dif_top, domain_out, &
FIA_out%flux_sw_nir_dif_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%flux_lw_top, domain_out, &
FIA_out%flux_lw_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%flux_lh_top, domain_out, &
FIA_out%flux_lh_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%lprec_top, domain_out, &
FIA_out%lprec_top, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%fprec_top, domain_out, &
FIA_out%fprec_top, complete=.true.)
call mpp_redistribute(domain_in, FIA_in%tmelt, domain_out, &
FIA_out%tmelt, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%bmelt, domain_out, &
FIA_out%bmelt, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%sw_abs_ocn, domain_out, &
FIA_out%sw_abs_ocn, complete=.true.)
call mpp_redistribute(domain_in, FIA_in%bheat, domain_out, &
FIA_out%bheat, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%WindStr_x, domain_out, &
FIA_out%WindStr_x, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%WindStr_y, domain_out, &
FIA_out%WindStr_y, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%WindStr_ocn_x, domain_out, &
FIA_out%WindStr_ocn_x, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%WindStr_ocn_y, domain_out, &
FIA_out%WindStr_ocn_y, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%p_atm_surf, domain_out, &
FIA_out%p_atm_surf, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%runoff, domain_out, &
FIA_out%runoff, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%calving, domain_out, &
FIA_out%calving, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%runoff_hflx, domain_out, &
FIA_out%runoff_hflx, complete=.false.)
call mpp_redistribute(domain_in, FIA_in%calving_hflx, domain_out, &
FIA_out%calving_hflx, complete=.false.)