forked from NOAA-GFDL/SIS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathice_type.F90
1626 lines (1458 loc) · 94.8 KB
/
ice_type.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
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! ice_type_mod - maintains the sea ice data, reads/writes restarts, reads the !
! namelist and initializes diagnostics. - Mike Winton !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
module ice_type_mod
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_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 constants_mod, only: T_0degC=>Tfreeze
use SIS_hor_grid_mod, only : SIS_hor_grid_type
use ice_grid_mod, only : ice_grid_type
use ice_dyn_bgrid, only: ice_B_dyn_CS
use ice_dyn_cgrid, only: ice_C_dyn_CS
use ice_transport_mod, only: ice_transport_CS
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 constants_mod, only: radius, pi, LI => hlf ! latent heat of fusion - 334e3 J/(kg-ice)
use ice_bergs, only: icebergs, icebergs_stock_pe, icebergs_save_restart
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 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 SIS_error_checking, only : chksum, Bchksum, hchksum, uchksum, vchksum
use SIS_error_checking, only : check_redundant_B, check_redundant_C
use SIS_get_input, only : archaic_nml_check
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_data_type, ice_state_type
public :: ice_model_restart, dealloc_ice_arrays, dealloc_IST_arrays
public :: ice_data_type_register_restarts, ice_state_register_restarts
public :: ice_diagnostics_init, ice_stock_pe, check_ice_model_nml
public :: ocean_ice_boundary_type, atmos_ice_boundary_type, land_ice_boundary_type
public :: ocn_ice_bnd_type_chksum, atm_ice_bnd_type_chksum
public :: lnd_ice_bnd_type_chksum, ice_data_type_chksum
public :: IST_chksum, Ice_public_type_chksum, Ice_public_type_bounds_check, IST_bounds_check
public :: earth_area
real, parameter :: earth_area = 4*PI*RADIUS*RADIUS !5.10064471909788E+14 m^2
real, parameter :: missing = -1e34
integer, parameter :: miss_int = -9999
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! 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
type(time_type) :: Time_Init, Time
type(time_type) :: Time_step_fast, Time_step_slow
integer :: avg_count ! The number of times that surface fluxes to the ice
! have been incremented.
integer :: stress_count ! The number of times that the stresses from the ice
! to the ocean have been incremented.
real, pointer, dimension(:,:,:) :: &
part_size =>NULL() ! 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.
! The following are the 6 variables that constitute the sea-ice state.
real, pointer, dimension(:,:) :: &
u_ice_B =>NULL(), & ! The pseudo-zonal and pseudo-meridional ice velocities
v_ice_B =>NULL(), & ! 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 =>NULL(), & ! The pseudo-zonal and pseudo-meridional ice velocities
v_ice_C =>NULL() ! 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, pointer, dimension(:,:,:) :: &
mH_snow =>NULL(), & ! The mass per unit area of the snow in each category,
! in units of H (usually kg m-2).
mH_ice =>NULL(), & ! The mass per unit area of the ice in each category,
! in units of H (usually kg m-2).
unused_var =>NULL() ! An unused pointer that has been left here due to an
! apparent bug with the gnu compiler's optimization.
real, pointer, dimension(:,:,:,:) :: &
sal_ice =>NULL(), & ! The salinity of the sea ice in each category and
! fractional thickness layer, in g/kg.
enth_ice =>NULL(), & ! The enthalpy of the sea ice in each category and
! fractional thickness layer, in enth_unit (J/kg or rescaled).
enth_snow =>NULL() ! The enthalpy of the snow in each category, in enth_unit.
real, pointer, dimension(:,:,:) :: &
rdg_mice =>NULL() ! A diagnostic of the ice load that was formed by
! ridging, in H (usually kg m-2).
real, pointer, dimension(:,:,:,:) :: &
age_ice =>NULL() ! The average age of ice in a category, in days.
real, pointer, dimension(:,:) :: &
s_surf =>NULL(), & ! The ocean's surface salinity in g/kg.
t_ocn =>NULL(), & ! The ocean's bulk surface temperature in degC.
u_ocn =>NULL(), & ! The ocean's zonal velocity on B-grid points in m s-1.
v_ocn =>NULL(), & ! The ocean's meridional velocity on B-grid points in m s-1.
u_ocn_C =>NULL(), & ! The ocean's zonal and meridional velocity on C-grid
v_ocn_C =>NULL(), & ! points, both in m s-1.
sea_lev =>NULL() ! 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, pointer, dimension(:,:,:) :: &
enth_prev, heat_in
real, pointer, dimension(:,:,:) :: &
! The 3rd dimension in each of the following is ice thickness category.
t_surf =>NULL(), & ! The surface temperature, in Kelvin.
flux_u_top =>NULL(), & ! The downward? flux of zonal and meridional
flux_v_top =>NULL(), & ! momentum on an A-grid in ???.
flux_t_top =>NULL(), & ! The upward sensible heat flux at the ice top
! in W m-2.
flux_q_top =>NULL(), & ! The upward evaporative moisture flux at
! top of the ice, in kg m-2 s-1.
flux_lw_top =>NULL(), & ! The downward flux of longwave radiation at
! the top of the ice, in W m-2.
flux_sw_vis_dir_top =>NULL(), & ! The downward diffuse flux of direct (dir)
flux_sw_vis_dif_top =>NULL(), & ! and diffuse (dif) shortwave radiation in
flux_sw_nir_dir_top =>NULL(), & ! the visible (vis) and near-infrared (nir)
flux_sw_nir_dif_top =>NULL(), & ! bands at the top of the ice, in W m-2.
flux_lh_top =>NULL(), & ! The upward flux of latent heat at the top
! of the ice, in W m-2.
lprec_top =>NULL(), & ! The downward flux of liquid precipitation
! at the top of the ice, in kg m-2 s-1.
fprec_top =>NULL() ! The downward flux of frozen precipitation
! at the top of the ice, in kg m-2 s-1.
real, pointer, 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 =>NULL(), & ! The enthalpy introduced to the ice by water
! fluxes from the atmosphere, in J m-2.
Enth_Mass_out_atm =>NULL(), & ! Negative of the enthalpy extracted from the
! ice by water fluxes to the atmosphere, in J m-2.
Enth_Mass_in_ocn =>NULL(), & ! The enthalpy introduced to the ice by water
! fluxes from the ocean, in J m-2.
Enth_Mass_out_ocn =>NULL(), & ! Negative of the enthalpy extracted from the
! ice by water fluxes to the ocean, in J m-2.
flux_t_ocn_top => NULL(), & ! The upward sensible heat flux from the ocean
! to the ice or atmosphere, in W m-2.
flux_q_ocn_top => NULL(), & ! The upward evaporative moisture flux at
! the ocean surface, in kg m-2 s-1.
flux_lw_ocn_top =>NULL(), & ! The downward flux of longwave radiation at
! the ocean surface, in W m-2.
flux_sw_vis_dir_ocn =>NULL(), & ! The downward diffuse flux of direct (dir)
flux_sw_vis_dif_ocn =>NULL(), & ! and diffuse (dif) shortwave radiation in
flux_sw_nir_dir_ocn =>NULL(), & ! the visible (vis) and near-infrared (nir)
flux_sw_nir_dif_ocn =>NULL(), & ! bands at the ocean surface, in W m-2.
flux_lh_ocn_top =>NULL(), & ! The upward flux of latent heat at the
! ocean surface, in W m-2.
lprec_ocn_top => NULL(), & ! The downward flux of liquid precipitation at
! the ocean surface, in kg m-2 s-1.
fprec_ocn_top => NULL(), & ! The downward flux of frozen precipitation at
! the ocean surface, in kg m-2 s-1.
coszen => NULL(), & ! Cosine of the solar zenith angle, nondim.
lwdn => NULL(), & ! Accumulated diagnostics of downward long-
swdn => NULL() ! and short-wave radiation at the top of the
! snow, averaged across categories, in W m-2.
real, pointer, dimension(:,:,:) :: &
sw_abs_sfc => NULL(), & ! The fractions of the absorbed shortwave radiation
sw_abs_snow => NULL(), & ! that are absorbed in a surface skin layer (_sfc),
sw_abs_ocn => NULL(), & ! the snow (_snow), by the ocean (_ocn), or integrated
sw_abs_int => NULL() ! across all of the ice layers (_int), all nondim
! and <=1. sw_abs_int is only used for diagnostics.
real, pointer, dimension(:,:,:,:) :: &
sw_abs_ice =>NULL() ! The fraction of the absorbed shortwave that is
! absorbed in each of the ice layers, nondim, <=1.
real, pointer, dimension(:,:,:) :: &
tmelt =>NULL(), & ! Ice-top melt energy into the ice/snow in J m-2.
bmelt =>NULL() ! Ice-bottom melting energy into the ice in J m-2.
real, pointer, dimension(:,:) :: &
frazil => NULL(), & ! 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.
frazil_input => NULL(), & ! The input value of frazil at the start of a
! timestep, in J m-2. This is used only for
! diagnostic purposes.
cool_nudge => NULL(), & ! A heat flux out of the sea ice that
! acts to create sea-ice, in W m-2.
melt_nudge => NULL(), & ! 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.
bheat => NULL(), & ! The upward diffusive heat flux from the ocean
! to the ice at the base of the ice, in W m-2.
mi => NULL() ! The total ice+snow mass, in kg m-2.
logical :: slab_ice ! If true, do the old style GFDL slab ice.
logical :: Cgrid_dyn ! If true use a C-grid discretization of the
! sea-ice dynamics.
logical :: SIS1_5L_thermo ! If true, the thermodynamic calculations inhereted
! from the 5-layer version of SIS1. Otherwise, use the
! newer SIS2 version.
logical :: interspersed_thermo ! If true, the sea ice thermodynamic updates
! are applied after the new velocities are determined,
! but before the transport occurs. Otherwise, the ice
! thermodynamic updates occur at the start of the slow
! ice update and dynamics and continuity can occur
! together.
logical :: area_wtd_stress ! If true, use wind stresses that are weighted
! by the ice areas in the neighboring cells. The default
! (true) is probably the right behavior, and this option
! will be obsoleted as soon as it is verified to work
! properly.
real :: Rho_ocean ! The nominal density of sea water, in kg m-3.
real :: Rho_ice ! The nominal density of sea ice, in kg m-3.
real :: Rho_snow ! The nominal density of snow on sea ice, in kg m-3.
logical :: do_icebergs ! If true, use the Lagrangian iceberg code, which
! modifies the calving field among other things.
logical :: do_ridging ! If true, use the ridging code
logical :: specified_ice ! If true, the sea ice is specified and there is
! no need for ice dynamics.
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 :: debug ! If true, write verbose checksums for debugging purposes.
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.
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 :: atmos_winds ! The wind stresses come directly from the atmosphere
! model and have the wrong sign.
real :: kmelt ! A constant that is used in the calculation of the
! ocean/ice basal heat flux, in W m-2 K-1.
real :: ice_bulk_salin ! The globally constant sea ice bulk salinity, in g/kg
! that is used to calculate the ocean salt flux.
real :: ice_rel_salin ! The initial bulk salinity of sea-ice relative to the
! salinity of the water from which it formed, nondim.
logical :: do_ice_restore ! If true, restore the sea-ice toward climatology
! by applying a restorative heat flux.
real :: ice_restore_timescale ! The time scale for restoring ice when
! do_ice_restore is true, in days.
logical :: do_ice_limit ! Limit the sea ice thickness to max_ice_limit.
real :: max_ice_limit ! The maximum sea ice thickness, in m, when
! do_ice_limit is true.
logical :: slp2ocean ! If true, apply sea level pressure to ocean surface.
logical :: verbose ! A flag to control the printing of an ice-diagnostic
! message. When true, this will slow the model down.
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 :: filling_frazil ! If true, apply frazil to fill as many categories
! as possible to fill in a uniform (minimum) amount
! of frazil in all the thinnest categories.
! Otherwise the frazil is always assigned to a
! single category with part size > 0.01.
real :: fraz_fill_time ! A timescale with which the filling frazil causes
! the thinest cells to attain similar thicknesses,
! or a negative number to apply the frazil flux
! uniformly, in s.
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 update_ice_model_slow_down
! has been called.
integer :: n_fast = 0 ! The number of times update_ice_model_fast
! has been called.
logical :: do_init = .false. ! If true, there is still some initialization
! that needs to be done.
logical :: first_time = .true. ! If true, this is the first call to
! update_ice_model_slow_up
logical :: nudge_sea_ice = .false. ! If true, nudge sea ice concentrations towards observations.
real :: nudge_sea_ice_rate = 0.0 ! The rate of cooling of ice-free water that
! should be ice covered in order to constrained the
! ice concentration to track observations. A suggested
! value is of order 10000 W m-2.
real :: nudge_stab_fac ! A factor that determines whether the buoyancy
! flux associated with the sea ice nudging of
! warm water includes a freshwater flux so as to
! be destabilizing on net (<1), stabilizing (>1),
! or neutral (=1). The default is 1.
real :: nudge_conc_tol ! The tolerance for mismatch in the sea ice concentations
! before nudging begins to be applied.
integer :: num_tr_fluxes = -1 ! The number of tracer flux fields
integer, allocatable, dimension(:,:) :: tr_flux_index
real, allocatable, dimension(:,:,:,:) :: tr_flux_top
real, allocatable, dimension(:,:,:) :: tr_flux_ocn_top
! type(coupler_3d_bc_type) :: ocean_fields ! array of fields used for additional tracers
! type(coupler_2d_bc_type) :: ocean_fluxes ! array of fluxes used for additional tracers
integer, dimension(:), allocatable :: id_t, id_sw_abs_ice, id_sal
integer :: id_cn=-1, id_hi=-1, id_hs=-1, id_tsn=-1
integer :: id_ts=-1, id_t_iceav=-1, id_s_iceav=-1, id_mi=-1, id_sh=-1
integer :: id_lh=-1, id_sw=-1, id_lw=-1, id_snofl=-1, id_rain=-1, id_runoff=-1
integer :: id_calving=-1, id_runoff_hflx=-1, id_calving_hflx=-1, id_evap=-1
integer :: id_saltf=-1, id_tmelt=-1, id_bmelt=-1, id_bheat=-1, id_e2m=-1
integer :: id_rdgr=-1, id_rdgf=-1, id_rdgo=-1, id_rdgv=-1, id_age=-1, id_fwnudge=-1
integer :: id_frazil=-1, id_alb=-1, id_xprt=-1, id_lsrc=-1, id_lsnk=-1, id_bsnk=-1
integer :: id_strna=-1, id_fax=-1, id_fay=-1, id_swdn=-1, id_lwdn=-1, id_sn2ic=-1
integer :: id_slp=-1, id_ext=-1, id_sst=-1, id_sss=-1, id_ssh=-1, id_uo=-1, id_vo=-1
integer :: id_ta=-1, id_obi=-1, id_qfres=-1, id_qflim=-1, id_ix_trans=-1
integer :: id_iy_trans=-1, id_sw_vis=-1, id_sw_dir=-1, id_sw_dif=-1
integer :: id_sw_vis_dir=-1, id_sw_vis_dif=-1, id_sw_nir_dir=-1, id_sw_nir_dif=-1
integer :: id_mib=-1, id_coszen=-1
integer :: id_alb_vis_dir=-1, id_alb_vis_dif=-1, id_alb_nir_dir=-1, id_alb_nir_dif=-1
integer :: id_abs_int=-1, id_sw_abs_sfc=-1, id_sw_abs_snow=-1
integer :: id_sw_pen=-1, id_sw_abs_ocn=-1
type(SIS_tracer_registry_type), pointer :: TrReg => NULL()
type(ice_B_dyn_CS), pointer :: ice_B_dyn_CSp => NULL()
type(ice_C_dyn_CS), pointer :: ice_C_dyn_CSp => NULL()
type(ice_transport_CS), pointer :: ice_transport_CSp => NULL()
type(ice_thermo_type), pointer :: ITV => NULL()
type(SIS2_ice_thm_CS), pointer :: ice_thm_CSp => NULL()
type(SIS_sum_out_CS), pointer :: sum_output_CSp => NULL()
type(SIS_diag_ctrl) :: diag ! A structure that regulates diagnostis.
! type(icebergs), pointer :: icebergs => NULL()
end type ice_state_type
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! This structure contains the ice model data (some used by calling routines); !
! the third index is partition (1 is open water; 2 is ice cover) !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
type ice_data_type ! ice_public_type
type(domain2D) :: Domain
type(time_type) :: Time
logical :: pe
integer, pointer, dimension(:) :: pelist =>NULL() ! Used for flux-exchange.
logical, pointer, dimension(:,:) :: ocean_pt =>NULL() ! An array that indicates all ocean points as true.
! ### ice_mask should be eliminated as soon as flux_exchange.F90 is corrected.
logical, pointer, dimension(:,:,:) :: ice_mask =>NULL() ! where ice actually is (Used for k-size only?)
! These fields are used to provide information about the ice surface to the
! atmosphere, and contain separate values for each ice thickness category.
real, pointer, dimension(:,:,:) :: &
part_size => NULL(), & ! The fractional coverage of a grid cell by each ice
! thickness category, nondim, 0 to 1. Category 1 is
! open ocean. The sum of part_size is 1.
albedo => NULL(), & ! The surface albedo averaged across all wavelength
! and orientation bands within each ice-thickness
! category. Nondimensional, between 0 and 1.
albedo_vis_dir => NULL(), & ! The surface albedos for visible (_vis) or
albedo_nir_dir => NULL(), & ! near-infrared (_nir) wavelengths of direct (_dir)
albedo_vis_dif => NULL(), & ! diffuse (_dif) shortwave radiation in each
albedo_nir_dif => NULL(), & ! ice-thickness category. Nondim, between 0 and 1.
rough_mom => NULL(), & ! The roughnesses for momentum, heat, and moisture
rough_heat => NULL(), & ! at the ocean surface, as provided by ocean_rough_mod,
rough_moist => NULL(), & ! apparently in m.
t_surf => NULL(), & ! The surface temperature for the ocean or for
! each ice-thickness category, in Kelvin.
u_surf => NULL(), & ! The eastward (u_) and northward (v_) surface
v_surf => NULL() ! velocities of the ocean (:,:,1) or sea-ice, in m s-1.
real, pointer, dimension(:,:) :: &
s_surf =>NULL() ! The ocean's surface salinity, in g/kg.
! These arrays will be used to set the forcing for the ocean.
real, pointer, dimension(:,:) :: &
flux_u => NULL(), & ! The flux of x-momentum into the ocean, in Pa.
flux_v => NULL(), & ! The flux of y-momentum into the ocean, in Pa.
flux_t => NULL(), & ! The flux of sensible heat out of the ocean, in W m-2.
flux_q => NULL(), & ! The evaporative moisture flux out of the ocean, in kg m-2 s-1.
flux_lw => NULL(), & ! The sensible heat flux out of the ocean, in W m-2.
flux_sw_vis_dir => NULL(), & ! The direct (dir) or diffuse (dif) shortwave
flux_sw_vis_dif => NULL(), & ! heat fluxes into the ocean in the visible
flux_sw_nir_dir => NULL(), & ! (vis) or near-infrared (nir) band, all
flux_sw_nir_dif => NULL(), & ! in W m-2.
flux_lh => NULL(), & ! The latent heat flux out of the ocean, in W m-2.
lprec => NULL(), & ! The liquid precipitation flux into the ocean, in kg m-2.
fprec => NULL(), & ! The frozen precipitation flux into the ocean, in kg m-2.
p_surf => NULL(), & ! The pressure at the ocean surface, in Pa. This may
! or may not include atmospheric pressure.
runoff => NULL(), & ! Liquid runoff into the ocean, in kg m-2.
calving => NULL(), & ! Calving of ice or runoff of frozen fresh water into
! the ocean, in kg m-2.
runoff_hflx => NULL(), & ! The heat flux associated with runoff, based on
! the temperature difference relative to a
! reference temperature, in ???.
calving_hflx => NULL(), & ! The heat flux associated with calving, based on
! the temperature difference relative to a
! reference temperature, in ???.
flux_salt => NULL() ! The flux of salt out of the ocean in kg m-2.
real, pointer, dimension(:,:) :: &
area => NULL() , & ! The area of ocean cells, in m2. Land cells have
! a value of 0, so this could also be used as a mask.
mi => NULL() ! The total ice+snow mass, in kg m-2.
! mi is needed for the wave model. It is introduced here,
! because flux_ice_to_ocean cannot handle 3D fields. This may be
! removed, if the information on ice thickness can be derived from
! eventually from h_ice outside the ice module.
integer, dimension(3) :: axes
type(coupler_3d_bc_type) :: ocean_fields ! array of fields used for additional tracers
type(coupler_2d_bc_type) :: ocean_fluxes ! array of fluxes used for additional tracers
type(coupler_3d_bc_type) :: ocean_fluxes_top ! ###THIS IS ARCHAIC AND COULD BE DELETED!
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.
type(icebergs), pointer :: icebergs => NULL()
type(SIS_hor_grid_type), pointer :: G => NULL() ! A structure containing metrics and grid info.
type(ice_grid_type), pointer :: IG => NULL() ! A structure containing sea-ice specific grid info.
type(ice_state_type), pointer :: Ice_state => NULL() ! A structure containing the internal
! representation of the ice state.
type(restart_file_type), pointer :: Ice_restart => NULL()
end type ice_data_type ! ice_public_type
! The following three types are for data exchange with the FMS coupler
! they are defined here but declared in coupler_main and allocated in flux_init.
type :: ocean_ice_boundary_type
real, dimension(:,:), pointer :: &
u => NULL(), & ! The x-direction ocean velocity at a position
! determined by stagger, in m s-1.
v => NULL(), & ! The y-direction ocean velocity at a position
! determined by stagger, in m s-1.
t => NULL(), & ! The ocean's surface temperature in Kelvin.
s => NULL(), & ! The ocean's surface temperature in g/kg.
frazil => NULL(), & ! The frazil heat rejected by the ocean, in J.
sea_level => NULL() ! The sea level after adjustment for any surface
! pressure that the ocean allows to be expressed, in m.
real, dimension(:,:,:), pointer :: data =>NULL() ! collective field for "named" fields above
integer :: stagger = BGRID_NE
integer :: xtype ! REGRID, REDIST or DIRECT used by coupler
type(coupler_2d_bc_type) :: fields ! array of fields used for additional tracers
end type
type :: atmos_ice_boundary_type
real, dimension(:,:,:), pointer :: &
u_flux => NULL(), & ! The true-eastward stresses (momentum fluxes) from the atmosphere
! to the ocean or ice in each category, discretized on an A-grid,
! and _not_ rotated to align with the model grid, in Pa.
v_flux => NULL(), & ! The true-northward stresses (momentum fluxes) from the atmosphere
! to the ocean or ice in each category, discretized on an A-grid,
! and _not_ rotated to align with the model grid, in Pa.
u_star => NULL(), & ! The atmospheric friction velocity on an A-grid, in Pa.
t_flux => NULL(), & ! The sensible heat flux flux from the ocean or ice into the
! atmosphere at the surface, in W m-2.
q_flux => NULL(), & ! The flux of moisture from the ice or ocean to the
! atmosphere due to evaporation or sublimation, in kg m-2 s-1.
lw_flux => NULL(), & ! The flux longwave radiation from the atmosphere into the
! ice or ocean, in W m-2.
sw_flux_vis_dir => NULL(), & ! The visible (_vis) or near-infrared (_nir),
sw_flux_vis_dif => NULL(), & ! direct (_dir) or diffuse (_dif) shortwave
sw_flux_nir_dir => NULL(), & ! radiation fluxes from the atmosphere into
sw_flux_nir_dif => NULL(), & ! the ice or ocean, in W m-2.
lprec => NULL(), & ! The liquid precipitation from the atmosphere onto the
! atmosphere or ice in each thickness category, in kg m-2 s-1.
! Rain falling on snow is currently assumed to pass or drain
! directly through the ice into the ocean; this should be
! revisitied!
fprec => NULL(), & ! The frozen precipitation (snowfall) from the atmosphere
! to the ice or ocean, in kg m-2 s-1. Currently in SIS2
! all frozen precipitation, including snow, sleet, hail
! or graupel, are all treated as snow.
dhdt => NULL(), & ! The derivative of the upward sensible heat flux with the
! surface temperature in W m-2 K-1.
dedt => NULL(), & ! The derivative of the sublimation and evaporation rate
! with the surface temperature, in kg m-2 s-1 K-1.
drdt => NULL(), & ! The derivative of the downward longwave radiative heat
! flux with surface temperature, in W m-2 K-1.
coszen => NULL(), & ! The cosine of the solar zenith angle, nondim and <=1.
p => NULL(), & ! The atmospheric surface pressure, in Pa, often ~1e5 Pa.
data => NULL()
integer :: xtype ! DIRECT or REDIST - used by coupler.
type(coupler_3d_bc_type) :: fluxes ! array of fluxes used for additional tracers
end type
type :: land_ice_boundary_type
real, dimension(:,:), pointer :: &
runoff =>NULL(), & ! The liquid runoff into the ocean, in kg m-2.
calving =>NULL(), & ! The frozen runoff into each cell, that is offered
! first to the icebergs (if any), where it might be
! used or modified before being passed to the ocean,
! in kg m-2.
runoff_hflx =>NULL(), & ! The heat flux associated with the temperature of
! of the liquid runoff, relative to liquid water
! at 0 deg C, in W m-2.
calving_hflx =>NULL() ! The heat flux associated with the temperature of
! of the frozen runoff, relative to liquid? (or frozen?) water
! at 0 deg C, in W m-2.
real, dimension(:,:,:), pointer :: data =>NULL() ! collective field for "named" fields above
integer :: xtype ! REGRID, REDIST or DIRECT - used by coupler.
end type
contains
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! ice_data_type_register_restarts - allocate the arrays in the ice_data_type !
! and register any variables in the ice data type that need to be included !
! in the restart files. !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
subroutine ice_data_type_register_restarts(domain, CatIce, param_file, Ice, &
Ice_restart, restart_file)
type(domain2d), intent(in) :: domain
integer, intent(in) :: CatIce
type(param_file_type), intent(in) :: param_file
type(ice_data_type), intent(inout) :: Ice
type(restart_file_type), intent(inout) :: Ice_restart
character(len=*), intent(in) :: restart_file
! This subroutine allocates the externally visible ice_data_type's arrays and
! registers the appopriate ones for inclusion in the restart file.
integer :: isc, iec, jsc, jec, km, idr
call mpp_get_compute_domain(domain, isc, iec, jsc, jec )
km = CatIce + 1
allocate(Ice%ocean_pt(isc:iec, jsc:jec)) ; Ice%ocean_pt(:,:) = .false. !derived
! ### Delete ice_mask once flux_exchange.F90 is corrected.
allocate(Ice%ice_mask(isc:iec, jsc:jec, km)) ; Ice%ice_mask(:,:,:) = .false. !NI
allocate(Ice%t_surf(isc:iec, jsc:jec, km)) ; Ice%t_surf(:,:,:) = 0.0
allocate(Ice%s_surf(isc:iec, jsc:jec)) ; Ice%s_surf(:,:) = 0.0 !NI
allocate(Ice%u_surf(isc:iec, jsc:jec, km)) ; Ice%u_surf(:,:,:) = 0.0 !NI
allocate(Ice%v_surf(isc:iec, jsc:jec, km)) ; Ice%v_surf(:,:,:) = 0.0 !NI
allocate(Ice%part_size(isc:iec, jsc:jec, km)) ; Ice%part_size(:,:,:) = 0.0
allocate(Ice%rough_mom(isc:iec, jsc:jec, km)) ; Ice%rough_mom(:,:,:) = 0.0
allocate(Ice%rough_heat(isc:iec, jsc:jec, km)) ; Ice%rough_heat(:,:,:) = 0.0
allocate(Ice%rough_moist(isc:iec, jsc:jec, km)) ; Ice%rough_moist(:,:,:) = 0.0
allocate(Ice%albedo(isc:iec, jsc:jec, km)) ; Ice%albedo(:,:,:) = 0.0 ! Derived?
allocate(Ice%albedo_vis_dir(isc:iec, jsc:jec, km)) ; Ice%albedo_vis_dir(:,:,:) = 0.0
allocate(Ice%albedo_nir_dir(isc:iec, jsc:jec, km)) ; Ice%albedo_nir_dir(:,:,:) = 0.0
allocate(Ice%albedo_vis_dif(isc:iec, jsc:jec, km)) ; Ice%albedo_vis_dif(:,:,:) = 0.0
allocate(Ice%albedo_nir_dif(isc:iec, jsc:jec, km)) ; Ice%albedo_nir_dif(:,:,:) = 0.0
allocate(Ice%flux_u(isc:iec, jsc:jec)) ; Ice%flux_u(:,:) = 0.0
allocate(Ice%flux_v(isc:iec, jsc:jec)) ; Ice%flux_v(:,:) = 0.0
allocate(Ice%flux_t(isc:iec, jsc:jec)) ; Ice%flux_t(:,:) = 0.0
allocate(Ice%flux_q(isc:iec, jsc:jec)) ; Ice%flux_q(:,:) = 0.0
allocate(Ice%flux_sw_vis_dir(isc:iec, jsc:jec)) ; Ice%flux_sw_vis_dir(:,:) = 0.0
allocate(Ice%flux_sw_vis_dif(isc:iec, jsc:jec)) ; Ice%flux_sw_vis_dif(:,:) = 0.0
allocate(Ice%flux_sw_nir_dir(isc:iec, jsc:jec)) ; Ice%flux_sw_nir_dir(:,:) = 0.0
allocate(Ice%flux_sw_nir_dif(isc:iec, jsc:jec)) ; Ice%flux_sw_nir_dif(:,:) = 0.0
allocate(Ice%flux_lw(isc:iec, jsc:jec)) ; Ice%flux_lw(:,:) = 0.0
allocate(Ice%flux_lh(isc:iec, jsc:jec)) ; Ice%flux_lh(:,:) = 0.0 !NI
allocate(Ice%lprec(isc:iec, jsc:jec)) ; Ice%lprec(:,:) = 0.0
allocate(Ice%fprec(isc:iec, jsc:jec)) ; Ice%fprec(:,:) = 0.0
allocate(Ice%p_surf(isc:iec, jsc:jec)) ; Ice%p_surf(:,:) = 0.0
allocate(Ice%runoff(isc:iec, jsc:jec)) ; Ice%runoff(:,:) = 0.0
allocate(Ice%calving(isc:iec, jsc:jec)) ; Ice%calving(:,:) = 0.0
allocate(Ice%runoff_hflx(isc:iec, jsc:jec)) ; Ice%runoff_hflx(:,:) = 0.0
allocate(Ice%calving_hflx(isc:iec, jsc:jec)) ; Ice%calving_hflx(:,:) = 0.0
allocate(Ice%flux_salt(isc:iec, jsc:jec)) ; Ice%flux_salt(:,:) = 0.0
allocate(Ice%area(isc:iec, jsc:jec)) ; Ice%area(:,:) = 0.0 !derived
allocate(Ice%mi(isc:iec, jsc:jec)) ; Ice%mi(:,:) = 0.0 !NR
! Now register some of these arrays to be read from the restart files.
idr = register_restart_field(Ice_restart, restart_file, 'albedo', Ice%albedo, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'albedo_vis_dir', Ice%albedo_vis_dir, &
domain=domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'albedo_nir_dir', Ice%albedo_nir_dir, &
domain=domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'albedo_vis_dif', Ice%albedo_vis_dif, &
domain=domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'albedo_nir_dif', Ice%albedo_nir_dif, &
domain=domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'rough_mom', Ice%rough_mom, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'rough_heat', Ice%rough_heat, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'rough_moist', Ice%rough_moist, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_u', Ice%flux_u, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_v', Ice%flux_v, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_t', Ice%flux_t, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_q', Ice%flux_q, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_salt', Ice%flux_salt, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_lw', Ice%flux_lw, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'lprec', Ice%lprec, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'fprec', Ice%fprec, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'runoff', Ice%runoff, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'calving', Ice%calving, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'runoff_hflx', Ice%runoff_hflx, domain=domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'calving_hflx',Ice%calving_hflx, domain=domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'p_surf', Ice%p_surf, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_sw_vis_dir', Ice%flux_sw_vis_dir, &
domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_sw_vis_dif', Ice%flux_sw_vis_dif, &
domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_sw_nir_dir', Ice%flux_sw_nir_dir, &
domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'flux_sw_nir_dif', Ice%flux_sw_nir_dif, &
domain=domain)
end subroutine ice_data_type_register_restarts
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
! ice_state_register_restarts - allocate the arrays in the ice_state_type !
! and register any variables in the ice data type that need to be included !
! in the restart files. !
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~!
subroutine ice_state_register_restarts(G, IG, param_file, IST, Ice_restart, restart_file)
type(SIS_hor_grid_type), intent(in) :: G
type(ice_grid_type), intent(in) :: IG
type(param_file_type), intent(in) :: param_file
type(ice_state_type), intent(inout) :: IST
type(restart_file_type), intent(inout) :: Ice_restart
character(len=*), intent(in) :: restart_file
type(domain2d), pointer :: domain
integer :: CatIce, NkIce, idr, n
character(len=8) :: nstr
CatIce = IG%CatIce ; NkIce = IG%NkIce
allocate(IST%t_surf(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%t_surf(:,:,:) = 0.0 !X
allocate(IST%s_surf(SZI_(G), SZJ_(G))) ; IST%s_surf(:,:) = 0.0 !NI X
allocate(IST%t_ocn(SZI_(G), SZJ_(G))) ; IST%t_ocn(:,:) = 0.0 !NI X
allocate(IST%sea_lev(SZI_(G), SZJ_(G))) ; IST%sea_lev(:,:) = 0.0 !NR
allocate(IST%part_size(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%part_size(:,:,:) = 0.0
allocate(IST%coszen(SZI_(G), SZJ_(G))) ; IST%coszen(:,:) = 0.0 !NR X
allocate(IST%flux_u_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_u_top(:,:,:) = 0.0 !NR
allocate(IST%flux_v_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_v_top(:,:,:) = 0.0 !NR
allocate(IST%flux_t_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_t_top(:,:,:) = 0.0 !NI
allocate(IST%flux_q_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_q_top(:,:,:) = 0.0 !NI
allocate(IST%flux_sw_vis_dir_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_sw_vis_dir_top(:,:,:) = 0.0 !NI
allocate(IST%flux_sw_vis_dif_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_sw_vis_dif_top(:,:,:) = 0.0 !NI
allocate(IST%flux_sw_nir_dir_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_sw_nir_dir_top(:,:,:) = 0.0 !NI
allocate(IST%flux_sw_nir_dif_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_sw_nir_dif_top(:,:,:) = 0.0 !NI
allocate(IST%flux_lw_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_lw_top(:,:,:) = 0.0 !NI
allocate(IST%flux_lh_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%flux_lh_top(:,:,:) = 0.0 !NI
allocate(IST%lprec_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%lprec_top(:,:,:) = 0.0 !NI
allocate(IST%fprec_top(SZI_(G), SZJ_(G), 0:CatIce)) ; IST%fprec_top(:,:,:) = 0.0 !NI
allocate(IST%Enth_Mass_in_atm(SZI_(G), SZJ_(G))) ; IST%Enth_Mass_in_atm(:,:) = 0.0 !NR
allocate(IST%Enth_Mass_out_atm(SZI_(G), SZJ_(G))) ; IST%Enth_Mass_out_atm(:,:) = 0.0 !NR
allocate(IST%Enth_Mass_in_ocn(SZI_(G), SZJ_(G))) ; IST%Enth_Mass_in_ocn(:,:) = 0.0 !NR
allocate(IST%Enth_Mass_out_ocn(SZI_(G), SZJ_(G))) ; IST%Enth_Mass_out_ocn(:,:) = 0.0 !NR
allocate(IST%flux_t_ocn_top(SZI_(G), SZJ_(G))) ; IST%flux_t_ocn_top(:,:) = 0.0 !NI
allocate(IST%flux_q_ocn_top(SZI_(G), SZJ_(G))) ; IST%flux_q_ocn_top(:,:) = 0.0 !NI
allocate(IST%flux_lw_ocn_top(SZI_(G), SZJ_(G))) ; IST%flux_lw_ocn_top(:,:) = 0.0 !NI
allocate(IST%flux_lh_ocn_top(SZI_(G), SZJ_(G))) ; IST%flux_lh_ocn_top(:,:) = 0.0 !NI
allocate(IST%flux_sw_vis_dir_ocn(SZI_(G), SZJ_(G))) ; IST%flux_sw_vis_dir_ocn(:,:) = 0.0 !NI
allocate(IST%flux_sw_vis_dif_ocn(SZI_(G), SZJ_(G))) ; IST%flux_sw_vis_dif_ocn(:,:) = 0.0 !NI
allocate(IST%flux_sw_nir_dir_ocn(SZI_(G), SZJ_(G))) ; IST%flux_sw_nir_dir_ocn(:,:) = 0.0 !NI
allocate(IST%flux_sw_nir_dif_ocn(SZI_(G), SZJ_(G))) ; IST%flux_sw_nir_dif_ocn(:,:) = 0.0 !NI
allocate(IST%lprec_ocn_top(SZI_(G), SZJ_(G))) ; IST%lprec_ocn_top(:,:) = 0.0 !NI
allocate(IST%fprec_ocn_top(SZI_(G), SZJ_(G))) ; IST%fprec_ocn_top(:,:) = 0.0 !NI
allocate(IST%lwdn(SZI_(G), SZJ_(G))) ; IST%lwdn(:,:) = 0.0 !NR
allocate(IST%swdn(SZI_(G), SZJ_(G))) ; IST%swdn(:,:) = 0.0 !NR
allocate(IST%frazil(SZI_(G), SZJ_(G))) ; IST%frazil(:,:) = 0.0 !NR
allocate(IST%frazil_input(SZI_(G), SZJ_(G))) ; IST%frazil_input(:,:) = 0.0 !NR
allocate(IST%bheat(SZI_(G), SZJ_(G))) ; IST%bheat(:,:) = 0.0 !NI
allocate(IST%tmelt(SZI_(G), SZJ_(G), CatIce)) ; IST%tmelt(:,:,:) = 0.0 !NR
allocate(IST%bmelt(SZI_(G), SZJ_(G), CatIce)) ; IST%bmelt(:,:,:) = 0.0 !NR
allocate(IST%sw_abs_sfc(SZI_(G), SZJ_(G), CatIce)) ; IST%sw_abs_sfc(:,:,:) = 0.0 !NR
allocate(IST%sw_abs_snow(SZI_(G), SZJ_(G), CatIce)) ; IST%sw_abs_snow(:,:,:) = 0.0 !NR
allocate(IST%sw_abs_ice(SZI_(G), SZJ_(G), CatIce, NkIce)) ; IST%sw_abs_ice(:,:,:,:) = 0.0 !NR
allocate(IST%sw_abs_ocn(SZI_(G), SZJ_(G), CatIce)) ; IST%sw_abs_ocn(:,:,:) = 0.0 !NR
allocate(IST%sw_abs_int(SZI_(G), SZJ_(G), CatIce)) ; IST%sw_abs_int(:,:,:) = 0.0 !NR
allocate(IST%mH_snow(SZI_(G), SZJ_(G), CatIce)) ; IST%mH_snow(:,:,:) = 0.0
allocate(IST%enth_snow(SZI_(G), SZJ_(G), CatIce, 1)) ; IST%enth_snow(:,:,:,:) = 0.0
allocate(IST%mH_ice(SZI_(G), SZJ_(G), CatIce)) ; IST%mH_ice(:,:,:) = 0.0
allocate(IST%enth_ice(SZI_(G), SZJ_(G), CatIce, NkIce)) ; IST%enth_ice(:,:,:,:) = 0.0
allocate(IST%sal_ice(SZI_(G), SZJ_(G), CatIce, NkIce)) ; IST%sal_ice(:,:,:,:) = 0.0
allocate(IST%enth_prev(SZI_(G), SZJ_(G), CatIce)) ; IST%enth_prev(:,:,:) = 0.0
allocate(IST%heat_in(SZI_(G), SZJ_(G), CatIce)) ; IST%heat_in(:,:,:) = 0.0
! ### THESE ARE DIAGNOSTICS. PERHAPS THEY SHOULD ONLY BE ALLOCATED IF USED.
allocate(IST%rdg_mice(SZI_(G), SZJ_(G), CatIce)) ; IST%rdg_mice(:,:,:) = 0.0
allocate(IST%age_ice(SZI_(G), SZJ_(G), CatIce, 1)) ; IST%age_ice(:,:,:,:) = 0.0
if (IST%Cgrid_dyn) then
allocate(IST%u_ice_C(SZIB_(G), SZJ_(G))) ; IST%u_ice_C(:,:) = 0.0
allocate(IST%v_ice_C(SZI_(G), SZJB_(G))) ; IST%v_ice_C(:,:) = 0.0
allocate(IST%u_ocn_C(SZIB_(G), SZJ_(G))) ; IST%u_ocn_C(:,:) = 0.0 !NR
allocate(IST%v_ocn_C(SZI_(G), SZJB_(G))) ; IST%v_ocn_C(:,:) = 0.0 !NR
else
allocate(IST%u_ice_B(SZIB_(G), SZJB_(G))) ; IST%u_ice_B(:,:) = 0.0
allocate(IST%v_ice_B(SZIB_(G), SZJB_(G))) ; IST%v_ice_B(:,:) = 0.0
allocate(IST%u_ocn(SZIB_(G), SZJB_(G))) ; IST%u_ocn(:,:) = 0.0 !NR
allocate(IST%v_ocn(SZIB_(G), SZJB_(G))) ; IST%v_ocn(:,:) = 0.0 !NR
endif
! Now register some of these arrays to be read from the restart files.
domain => G%domain%mpp_domain
idr = register_restart_field(Ice_restart, restart_file, 'part_size', IST%part_size, domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 't_surf', IST%t_surf, &
domain=domain)
idr = register_restart_field(Ice_restart, restart_file, 'h_snow', IST%mH_snow, &
domain=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=domain, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'h_ice', IST%mH_ice, &
domain=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=domain, mandatory=.false., units="J kg-1")
idr = register_restart_field(Ice_restart, restart_file, 'sal_ice', IST%sal_ice, &
domain=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=domain, position=EAST, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'v_ice_C', IST%v_ice_C, &
domain=domain, position=NORTH, mandatory=.false.)
else
idr = register_restart_field(Ice_restart, restart_file, 'u_ice', IST%u_ice_B, &
domain=domain, position=CORNER, mandatory=.false.)
idr = register_restart_field(Ice_restart, restart_file, 'v_ice', IST%v_ice_B, &
domain=domain, position=CORNER, mandatory=.false.)
endif
idr = register_restart_field(Ice_restart, restart_file, 'coszen', IST%coszen, &
domain=domain, mandatory=.false.)
end subroutine ice_state_register_restarts
subroutine dealloc_Ice_arrays(Ice)
type(ice_data_type), intent(inout) :: Ice
deallocate(Ice%ocean_pt, Ice%t_surf, Ice%s_surf)
! ###Eliminate ice_mask once flux_exchange.F90 is fixed.
deallocate(Ice%ice_mask)
deallocate(Ice%u_surf, Ice%v_surf, Ice%part_size)
deallocate(Ice%rough_mom, Ice%rough_heat, Ice%rough_moist)
deallocate(Ice%albedo, Ice%albedo_vis_dir, Ice%albedo_nir_dir)
deallocate(Ice%albedo_vis_dif, Ice%albedo_nir_dif)
deallocate(Ice%flux_u, Ice%flux_v, Ice%flux_t, Ice%flux_q, Ice%flux_lw)
deallocate(Ice%flux_lh, Ice%lprec, Ice%fprec, Ice%p_surf, Ice%runoff)
deallocate(Ice%calving, Ice%runoff_hflx, Ice%calving_hflx)
deallocate(Ice%flux_salt)
deallocate(Ice%flux_sw_vis_dir, Ice%flux_sw_vis_dif)
deallocate(Ice%flux_sw_nir_dir, Ice%flux_sw_nir_dif)
deallocate(Ice%area, Ice%mi)
end subroutine dealloc_Ice_arrays
subroutine dealloc_IST_arrays(IST)
type(ice_state_type), intent(inout) :: IST
deallocate(IST%t_surf, IST%s_surf, IST%t_ocn, IST%sea_lev)
deallocate(IST%part_size)
if (IST%Cgrid_dyn) then
deallocate(IST%u_ice_C, IST%v_ice_C, IST%u_ocn_C, IST%v_ocn_C)
else
deallocate(IST%u_ocn, IST%v_ocn, IST%u_ice_B, IST%v_ice_B)
endif
deallocate(IST%flux_u_top, IST%flux_v_top )
deallocate(IST%flux_t_top, IST%flux_q_top, IST%flux_lw_top)
deallocate(IST%flux_lh_top, IST%lprec_top, IST%fprec_top)
deallocate(IST%flux_sw_vis_dir_top, IST%flux_sw_vis_dif_top)
deallocate(IST%flux_sw_nir_dir_top, IST%flux_sw_nir_dif_top)
deallocate(IST%Enth_Mass_in_atm, IST%Enth_Mass_out_atm)
deallocate(IST%Enth_Mass_in_ocn, IST%Enth_Mass_out_ocn)
deallocate(IST%flux_t_ocn_top, IST%flux_q_ocn_top)
deallocate(IST%flux_lw_ocn_top, IST%flux_lh_ocn_top)
deallocate(IST%flux_sw_vis_dir_ocn, IST%flux_sw_vis_dif_ocn)
deallocate(IST%flux_sw_nir_dir_ocn, IST%flux_sw_nir_dif_ocn)
deallocate(IST%lprec_ocn_top, IST%fprec_ocn_top)
deallocate(IST%lwdn, IST%swdn, IST%coszen, IST%frazil, IST%frazil_input)
deallocate(IST%bheat, IST%tmelt, IST%bmelt)
deallocate(IST%sw_abs_sfc, IST%sw_abs_snow, IST%sw_abs_ice)
deallocate(IST%sw_abs_ocn, IST%sw_abs_int)
deallocate(IST%mH_snow, IST%mH_ice)
deallocate(IST%enth_snow, IST%enth_ice, IST%sal_ice)
end subroutine dealloc_IST_arrays
subroutine IST_chksum(mesg, IST, G, IG, haloshift)
character(len=*), intent(in) :: mesg
type(ice_state_type), intent(inout) :: IST
type(SIS_hor_grid_type), intent(inout) :: G
type(ice_grid_type), intent(inout) :: IG
integer, optional, intent(in) :: haloshift
! This subroutine writes out chksums for the model's basic state variables.
! Arguments: mesg - A message that appears on the chksum lines.
! (in) IST - The ice state type variable to be checked.
! (in) G - The ocean's grid structure.
! (in,opt) haloshift - If present, check halo points out this far.
character(len=20) :: k_str1, k_str
integer :: hs, k
! Note that for the chksum calls to be useful for reproducing across PE
! counts, there must be no redundant points, so all variables use is..ie
! and js...je as their extent.
hs=0; if (present(haloshift)) hs=haloshift
call hchksum(IST%part_size, trim(mesg)//" IST%part_size",G,haloshift=hs)
call hchksum(IST%mH_ice*IG%H_to_kg_m2, trim(mesg)//" IST%mH_ice",G,haloshift=hs)
do k=1,IG%NkIce
write(k_str1,'(I8)') k
k_str = "("//trim(adjustl(k_str1))//")"
call hchksum(IST%enth_ice(:,:,:,k), trim(mesg)//" IST%enth_ice("//trim(k_str),G,haloshift=hs)
call hchksum(IST%sal_ice(:,:,:,k), trim(mesg)//" IST%sal_ice("//trim(k_str),G,haloshift=hs)
enddo
call hchksum(IST%mH_snow*IG%H_to_kg_m2, trim(mesg)//" IST%mH_snow",G,haloshift=hs)
call hchksum(IST%enth_snow(:,:,:,1), trim(mesg)//" IST%enth_snow",G,haloshift=hs)
if (associated(IST%u_ice_B)) call Bchksum(IST%u_ice_B, mesg//" IST%u_ice_B",G,haloshift=hs)
if (associated(IST%v_ice_B)) call Bchksum(IST%v_ice_B, mesg//" IST%v_ice_B",G,haloshift=hs)
call check_redundant_B(mesg//" IST%u/v_ice", IST%u_ice_B, IST%v_ice_B, G)
if (IST%Cgrid_dyn) then
call uchksum(IST%u_ice_C, mesg//" IST%u_ice_C",G,haloshift=hs)
call vchksum(IST%v_ice_C, mesg//" IST%v_ice_C",G,haloshift=hs)
call check_redundant_C(mesg//" IST%u/v_ice_C", IST%u_ice_C, IST%v_ice_C, G)
endif
end subroutine IST_chksum
subroutine Ice_public_type_chksum(mesg, Ice)
character(len=*), intent(in) :: mesg
type(ice_data_type), intent(inout) :: Ice
! This subroutine writes out chksums for the model's basic state variables.
! Arguments: mesg - A message that appears on the chksum lines.
! (in) Ice - An ice_data_type structure whose elements are to be
! checksummed.
! Note that the publicly visible ice_data_type has no halos, so it is not
! possible do check their values.
call chksum(Ice%part_size, trim(mesg)//" Ice%part_size")
call chksum(Ice%albedo, trim(mesg)//" Ice%albedo")
call chksum(Ice%albedo_vis_dir, trim(mesg)//" Ice%albedo_vis_dir")
call chksum(Ice%albedo_nir_dir, trim(mesg)//" Ice%albedo_nir_dir")
call chksum(Ice%albedo_vis_dif, trim(mesg)//" Ice%albedo_vis_dif")
call chksum(Ice%albedo_nir_dif, trim(mesg)//" Ice%albedo_nir_dif")
call chksum(Ice%rough_mom, trim(mesg)//" Ice%rough_mom")
call chksum(Ice%rough_mom, trim(mesg)//" Ice%rough_mom")
call chksum(Ice%rough_moist, trim(mesg)//" Ice%rough_moist")
call chksum(Ice%t_surf, trim(mesg)//" Ice%t_surf")
call chksum(Ice%u_surf, trim(mesg)//" Ice%u_surf")
call chksum(Ice%v_surf, trim(mesg)//" Ice%v_surf")
call chksum(Ice%s_surf, trim(mesg)//" Ice%s_surf")
call chksum(Ice%flux_u, trim(mesg)//" Ice%flux_u")
call chksum(Ice%flux_v, trim(mesg)//" Ice%flux_v")
call chksum(Ice%flux_t, trim(mesg)//" Ice%flux_t")
call chksum(Ice%flux_q, trim(mesg)//" Ice%flux_q")
call chksum(Ice%flux_lw, trim(mesg)//" Ice%flux_lw")
call chksum(Ice%flux_sw_vis_dir, trim(mesg)//" Ice%flux_sw_vis_dir")
call chksum(Ice%flux_sw_nir_dir, trim(mesg)//" Ice%flux_sw_nir_dir")
call chksum(Ice%flux_sw_vis_dif, trim(mesg)//" Ice%flux_sw_vis_dif")
call chksum(Ice%flux_sw_nir_dif, trim(mesg)//" Ice%flux_sw_nir_dif")
call chksum(Ice%flux_lh, trim(mesg)//" Ice%flux_lh")
call chksum(Ice%lprec, trim(mesg)//" Ice%lprec")
call chksum(Ice%fprec, trim(mesg)//" Ice%fprec")
call chksum(Ice%p_surf, trim(mesg)//" Ice%p_surf")
call chksum(Ice%calving, trim(mesg)//" Ice%calving")
call chksum(Ice%runoff, trim(mesg)//" Ice%runoff")
end subroutine Ice_public_type_chksum
subroutine Ice_public_type_bounds_check(Ice, G, msg)
type(ice_data_type), intent(in) :: Ice
type(SIS_hor_grid_type), intent(inout) :: G
character(len=*), intent(in) :: msg
character(len=512) :: mesg1, mesg2
integer :: i, j, k, l, i2, j2, k2, isc, iec, jsc, jec, ncat, i_off, j_off
integer :: n_bad, i_bad, j_bad, k_bad
real :: t_min, t_max
isc = G%isc ; iec = G%iec ; jsc = G%jsc ; jec = G%jec ; ncat = Ice%IG%CatIce
i_off = LBOUND(Ice%t_surf,1) - G%isc ; j_off = LBOUND(Ice%t_surf,2) - G%jsc
n_bad = 0 ; i_bad = 0 ; j_bad = 0 ; k_bad = 0
do j=jsc,jec ; do i=isc,iec ; i2 = i+i_off ; j2 = j+j_off
if ((Ice%s_surf(i2,j2) < 0.0) .or. (Ice%s_surf(i2,j2) > 100.0)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; endif
endif
if ((abs(Ice%flux_t(i2,j2)) > 1e4) .or. (abs(Ice%flux_lw(i2,j2)) > 1e4)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; endif
endif
enddo ; enddo
t_min = T_0degC-100. ; t_max = T_0degC+60.
do k=0,ncat ; do j=jsc,jec ; do i=isc,iec
i2 = i+i_off ; j2 = j+j_off ; k2 = k+1
if ((Ice%t_surf(i2,j2,k2) < t_min) .or. (Ice%t_surf(i2,j2,k2) > t_max)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; k_bad = k ; endif
endif
enddo ; enddo ; enddo
if (n_bad > 0) then
i2 = i_bad+i_off ; j2 = j_bad+j_off ; k2 = k_bad+1
write(mesg1,'(" at ", 2(F6.1)," or i,j,k = ",3i4,"; nbad = ",i6," on pe ",i4)') &
G%geolonT(i_bad,j_bad), G%geolatT(i_bad,j_bad), i_bad, j_bad, k_bad, n_bad, pe_here()
write(mesg2,'("T_sfc = ",1pe12.4,", ps = ",1pe12.4,", flux_t,lw,q = ",3(1pe12.4))') &
Ice%t_surf(i2,j2,k2), Ice%part_size(i2,j2,k2), Ice%flux_t(i2,j2), Ice%flux_lw(i2,j2), Ice%flux_q(i2,j2)
call SIS_error(WARNING, "Bad ice data "//trim(msg)//" ; "//trim(mesg1)//" ; "//trim(mesg2), all_print=.true.)
endif
end subroutine Ice_public_type_bounds_check
subroutine IST_bounds_check(IST, G, IG, msg)
type(ice_state_type), intent(in) :: IST
type(SIS_hor_grid_type), intent(inout) :: G
type(ice_grid_type), intent(in) :: IG
character(len=*), intent(in) :: msg
character(len=512) :: mesg1, mesg2
character(len=24) :: err
real, dimension(SZI_(G),SZJ_(G)) :: sum_part_sz
real, dimension(IG%NkIce) :: S_col
real :: tsurf_min, tsurf_max, tice_min, tice_max, tOcn_min, tOcn_max
real :: enth_min, enth_max, m_max
logical :: spec_thermo_sal
integer :: i, j, k, m, isc, iec, jsc, jec, ncat, NkIce, i_off, j_off
integer :: n_bad, i_bad, j_bad, k_bad
isc = G%isc ; iec = G%iec ; jsc = G%jsc ; jec = G%jec
ncat = IG%CatIce ; NkIce = IG%NkIce
n_bad = 0 ; i_bad = 0 ; j_bad = 0 ; k_bad = 0 ; err = ":"
m_max = 1.0e6*IG%kg_m2_to_H
sum_part_sz(:,:) = 0.0
do k=0,ncat ; do j=jsc,jec ; do i=isc,iec
sum_part_sz(i,j) = sum_part_sz(i,j) + IST%part_size(i,j,k)
enddo ; enddo ; enddo
tOcn_min = -100. ; tOcn_max = 60.
do j=jsc,jec ; do i=isc,iec
if ((abs(sum_part_sz(i,j) - 1.0) > 1.0e-5) .or. &
(IST%s_surf(i,j) < 0.0) .or. (IST%s_surf(i,j) > 100.0) .or. &
(IST%t_ocn(i,j) < tOcn_min) .or. (IST%t_ocn(i,j) > tOcn_max)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; err = "t_ocn" ; endif
endif
enddo ; enddo
tsurf_min = tOcn_min + T_0degC ; tsurf_max = tOcn_max + T_0degC
tice_min = -100. ; tice_max = 1.0
enth_min = enth_from_TS(tice_min, 0., IST%ITV)
enth_max = enth_from_TS(tice_max, 0., IST%ITV)
do k=0,ncat ; do j=jsc,jec ; do i=isc,iec
if ((IST%t_surf(i,j,k) < tsurf_min) .or. (IST%t_surf(i,j,k) > tsurf_max)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; k_bad = k ; err = "tsurf" ; endif
endif
enddo ; enddo ; enddo
do k=1,ncat ; do j=jsc,jec ; do i=isc,iec
if ((IST%mH_ice(i,j,k) > m_max) .or. (IST%mH_snow(i,j,k) > m_max)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; k_bad = k ; err = "large mass" ; endif
endif
if ((IST%enth_snow(i,j,k,1) < enth_min) .or. (IST%enth_snow(i,j,k,1) > enth_max)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; k_bad = k ; err = "enth_snow" ; endif
endif
enddo ; enddo ; enddo
do m=1,NkIce ; do k=1,ncat ; do j=jsc,jec ; do i=isc,iec
if ((IST%enth_ice(i,j,k,m) < enth_min) .or. (IST%enth_ice(i,j,k,m) > enth_max)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; k_bad = k ; err = "enth_ice" ; endif
endif
if ((IST%sal_ice(i,j,k,m) < 0.0) .or. (IST%sal_ice(i,j,k,m) > 1000.0)) then
n_bad = n_bad + 1
if (n_bad == 1) then ; i_bad = i ; j_bad = j ; k_bad = k ; err = "sal_ice" ; endif
endif
enddo ; enddo ; enddo ; enddo
if (n_bad > 0) then
i = i_bad ; j=j_bad ; k = k_bad
write(mesg1,'(" at ", 2(F6.1)," or i,j,k = ",3i4,"; nbad = ",i6," on pe ",i4)') &
G%geolonT(i,j), G%geolatT(i,j), i_bad, j_bad, k_bad, n_bad, pe_here()
if (k_bad > 0) then
write(mesg2,'("T_sfc = ",1pe12.4,", ps = ",1pe12.4)') IST%t_surf(i,j,k), IST%part_size(i,j,k)
else
write(mesg2,'("T_ocn = ",1pe12.4,", S_sfc = ",1pe12.4,", sum_ps = ",1pe12.4)') &
IST%t_ocn(i,j), IST%s_surf(i,j), sum_part_sz(i,j)
endif
call SIS_error(WARNING, "Bad ice state "//trim(err)//" "//trim(msg)//" ; "//trim(mesg1)//&
" ; "//trim(mesg2), all_print=.true.)