@@ -24,6 +24,8 @@ module MOM_ice_shelf
24
24
use MOM_domains, only : TO_ALL, CGRID_NE, BGRID_NE, CORNER
25
25
use MOM_dyn_horgrid, only : dyn_horgrid_type, create_dyn_horgrid, destroy_dyn_horgrid
26
26
use MOM_error_handler, only : MOM_error, MOM_mesg, FATAL, WARNING, is_root_pe
27
+ use MOM_error_handler, only : callTree_showQuery
28
+ use MOM_error_handler, only : callTree_enter, callTree_leave, callTree_waypoint
27
29
use MOM_file_parser, only : read_param, get_param, log_param, log_version, param_file_type
28
30
use MOM_grid, only : MOM_grid_init, ocean_grid_type
29
31
use MOM_grid_initialize, only : set_grid_metrics
@@ -39,12 +41,12 @@ module MOM_ice_shelf
39
41
use MOM_restart, only : restart_init, restore_state, MOM_restart_CS, register_restart_pair
40
42
use MOM_time_manager, only : time_type, time_type_to_real, real_to_time, operator (>), operator (- )
41
43
use MOM_transcribe_grid, only : copy_dyngrid_to_MOM_grid, copy_MOM_grid_to_dyngrid
42
- use MOM_transcribe_grid, only : rotate_dyngrid
44
+ use MOM_transcribe_grid, only : rotate_dyngrid
43
45
use MOM_unit_scaling, only : unit_scale_type, unit_scaling_init, fix_restart_unit_scaling
44
46
use MOM_variables, only : surface, allocate_surface_state, deallocate_surface_state
45
47
use MOM_variables, only : rotate_surface_state
46
48
use MOM_forcing_type, only : forcing, allocate_forcing_type, deallocate_forcing_type, MOM_forcing_chksum
47
- use MOM_forcing_type, only : mech_forcing, allocate_mech_forcing, MOM_mech_forcing_chksum
49
+ use MOM_forcing_type, only : mech_forcing, allocate_mech_forcing, deallocate_mech_forcing, MOM_mech_forcing_chksum
48
50
use MOM_forcing_type, only : copy_common_forcing_fields, rotate_forcing, rotate_mech_forcing
49
51
use MOM_get_input, only : directories, Get_MOM_input
50
52
use MOM_EOS, only : calculate_density, calculate_density_derivs, calculate_TFreeze, EOS_domain
@@ -59,7 +61,6 @@ module MOM_ice_shelf
59
61
use MOM_ice_shelf_state, only : ice_shelf_state, ice_shelf_state_end, ice_shelf_state_init
60
62
use user_shelf_init, only : USER_initialize_shelf_mass, USER_update_shelf_mass
61
63
use user_shelf_init, only : user_ice_shelf_CS
62
- use MOM_coms, only : reproducing_sum
63
64
use MOM_spatial_means, only : global_area_integral
64
65
use MOM_checksums, only : hchksum, qchksum, chksum, uchksum, vchksum, uvchksum
65
66
use MOM_interpolate, only : init_external_field, time_interp_external, time_interp_external_init
@@ -90,10 +91,6 @@ module MOM_ice_shelf
90
91
type (MOM_restart_CS), pointer :: restart_CSp = > NULL () ! < A pointer to the restart control
91
92
! ! structure for the ice shelves
92
93
type (ocean_grid_type), pointer :: Grid_in = > NULL () ! < un-rotated input grid metric
93
- type (hor_index_type), pointer :: HI_in = > NULL () ! < Pointer to a horizontal indexing structure for
94
- ! ! incoming data which has not been rotated.
95
- type (hor_index_type), pointer :: HI = > NULL () ! < Pointer to a horizontal indexing structure for
96
- ! ! incoming data which has not been rotated.
97
94
logical :: rotate_index = .false. ! < True if index map is rotated
98
95
integer :: turns ! < The number of quarter turns for rotation testing.
99
96
type (ocean_grid_type), pointer :: Grid = > NULL () ! < Grid for the ice-shelf model
@@ -1020,18 +1017,18 @@ end subroutine change_thickness_using_melt
1020
1017
1021
1018
! > This subroutine adds the mechanical forcing fields and perhaps shelf areas, based on
1022
1019
! ! the ice state in ice_shelf_CS.
1023
- subroutine add_shelf_forces (Ocn_grid , US , CS , forces , do_shelf_area , external_call )
1020
+ subroutine add_shelf_forces (Ocn_grid , US , CS , forces_in , do_shelf_area , external_call )
1024
1021
type (ocean_grid_type), intent (in ) :: Ocn_grid ! < The ocean's grid structure.
1025
1022
type (unit_scale_type), intent (in ) :: US ! < A dimensional unit scaling type
1026
1023
type (ice_shelf_CS), pointer :: CS ! < This module's control structure.
1027
- type (mech_forcing), intent (inout ) :: forces ! < A structure with the
1024
+ type (mech_forcing), target , intent (inout ) :: forces_in ! < A structure with the
1028
1025
! ! driving mechanical forces
1029
1026
logical , optional , intent (in ) :: do_shelf_area ! < If true find the shelf-covered areas.
1030
1027
logical , optional , intent (in ) :: external_call ! < If true the incoming forcing type
1031
- ! ! is using the input grid metric and needs
1028
+ ! ! is using the unrotated input grid and may need
1032
1029
! ! to be rotated.
1033
1030
type (ocean_grid_type), pointer :: G = > NULL () ! < A pointer to the ocean grid metric.
1034
- ! type(mech_forcing), target :: forces !< A structure with the driving mechanical forces
1031
+ type (mech_forcing), pointer :: forces ! < A structure with the driving mechanical forces
1035
1032
real :: kv_rho_ice ! The viscosity of ice divided by its density [L4 T-1 R-1 Z-2 ~> m5 kg-1 s-1].
1036
1033
real :: press_ice ! The pressure of the ice shelf per unit area of ocean (not ice) [R L2 T-2 ~> Pa].
1037
1034
logical :: find_area ! If true find the shelf areas at u & v points.
@@ -1041,29 +1038,25 @@ subroutine add_shelf_forces(Ocn_grid, US, CS, forces, do_shelf_area, external_ca
1041
1038
1042
1039
integer :: i, j, is, ie, js, je, isd, ied, jsd, jed
1043
1040
1044
- if (present (external_call)) rotate= external_call
1045
-
1046
- if ((Ocn_grid% isc /= CS% Grid_in% isc) .or. (Ocn_grid% iec /= CS% Grid_in% iec) .or. &
1047
- (Ocn_grid% jsc /= CS% Grid_in% jsc) .or. (Ocn_grid% jec /= CS% Grid_in% jec)) &
1048
- call MOM_error(FATAL," add_shelf_forces: Incompatible Ocean and Ice shelf grids." )
1041
+ rotate = .false. ; if (present (external_call)) rotate = external_call
1049
1042
1050
1043
if (CS% rotate_index .and. rotate) then
1051
- call MOM_error(FATAL," add_shelf_forces: Rotation not implemented for ice shelves." )
1052
- ! allocate(forces)
1053
- ! call allocate_mech_forcing(forces_in, CS%Grid, forces)
1054
- ! call rotate_mech_forcing(forces_in, CS%turns, forces)
1055
- ! else
1056
- ! if ((Ocn_grid%isc /= CS%Grid%isc) .or. (Ocn_grid%iec /= CS%Grid%iec) .or. &
1057
- ! (Ocn_grid%jsc /= CS%Grid%jsc) .or. (Ocn_grid%jec /= CS%Grid%jec)) &
1058
- ! call MOM_error(FATAL,"add_shelf_forces: Incompatible Ocean and Ice shelf grids.")
1059
-
1060
- ! forces=>forces_in
1044
+ if ((Ocn_grid% isc /= CS% Grid_in% isc) .or. (Ocn_grid% iec /= CS% Grid_in% iec) .or. &
1045
+ (Ocn_grid% jsc /= CS% Grid_in% jsc) .or. (Ocn_grid% jec /= CS% Grid_in% jec)) &
1046
+ call MOM_error(FATAL," add_shelf_forces: Incompatible Ocean and external Ice shelf grids." )
1047
+ allocate (forces)
1048
+ call allocate_mech_forcing(forces_in, CS% Grid, forces)
1049
+ call rotate_mech_forcing(forces_in, CS% turns, forces)
1050
+ else
1051
+ if ((Ocn_grid% isc /= CS% Grid% isc) .or. (Ocn_grid% iec /= CS% Grid% iec) .or. &
1052
+ (Ocn_grid% jsc /= CS% Grid% jsc) .or. (Ocn_grid% jec /= CS% Grid% jec)) &
1053
+ call MOM_error(FATAL," add_shelf_forces: Incompatible Ocean and internal Ice shelf grids." )
1054
+
1055
+ forces= >forces_in
1061
1056
endif
1062
1057
1063
1058
G= >CS% Grid
1064
1059
1065
-
1066
-
1067
1060
is = G% isc ; ie = G% iec ; js = G% jsc ; je = G% jec
1068
1061
isd = G% isd ; jsd = G% jsd ; ied = G% ied ; jed = G% jed
1069
1062
@@ -1125,10 +1118,10 @@ subroutine add_shelf_forces(Ocn_grid, US, CS, forces, do_shelf_area, external_ca
1125
1118
scalar_pair= .true. )
1126
1119
endif
1127
1120
1128
- ! if (CS%rotate_index .and. rotate) then
1129
- ! call rotate_mech_forcing(forces, -CS%turns, forces_in)
1130
- ! ! TODO: deallocate mech forcing?
1131
- ! endif
1121
+ if (CS% rotate_index .and. rotate) then
1122
+ call rotate_mech_forcing(forces, - CS% turns, forces_in)
1123
+ call deallocate_mech_forcing(forces)
1124
+ endif
1132
1125
1133
1126
end subroutine add_shelf_forces
1134
1127
@@ -1411,6 +1404,7 @@ subroutine initialize_ice_shelf(param_file, ocn_grid, Time, CS, diag, Time_init,
1411
1404
! ! the ice-shelf state
1412
1405
type (directories) :: dirs
1413
1406
type (dyn_horgrid_type), pointer :: dG = > NULL ()
1407
+ type (dyn_horgrid_type), pointer :: dG_in = > NULL ()
1414
1408
real :: meltrate_conversion ! The conversion factor to use for in the melt rate diagnostic.
1415
1409
real :: dz_ocean_min_float ! The minimum ocean thickness above which the ice shelf is considered
1416
1410
! to be floating when CONST_SEA_LEVEL = True [Z ~> m].
@@ -1422,6 +1416,7 @@ subroutine initialize_ice_shelf(param_file, ocn_grid, Time, CS, diag, Time_init,
1422
1416
character (len= 40 ) :: mdl = " MOM_ice_shelf" ! This module's name.
1423
1417
integer :: i, j, is, ie, js, je, isd, ied, jsd, jed, Isdq, Iedq, Jsdq, Jedq
1424
1418
integer :: wd_halos(2 )
1419
+ logical :: showCallTree
1425
1420
logical :: read_TideAmp, debug
1426
1421
logical :: global_indexing
1427
1422
character (len= 240 ) :: Tideamp_file ! Input file names
@@ -1463,55 +1458,57 @@ subroutine initialize_ice_shelf(param_file, ocn_grid, Time, CS, diag, Time_init,
1463
1458
1464
1459
! Set up the ice-shelf domain and grid
1465
1460
wd_halos(:)= 0
1466
- allocate (CS% Grid )
1467
- call MOM_domains_init(CS% Grid % domain, param_file, min_halo= wd_halos, symmetric= GRID_SYM_,&
1461
+ allocate (CS% Grid_in )
1462
+ call MOM_domains_init(CS% Grid_in % domain, param_file, min_halo= wd_halos, symmetric= GRID_SYM_,&
1468
1463
domain_name= ' MOM_Ice_Shelf_in' , US= CS% US)
1469
1464
! allocate(CS%Grid_in%HI)
1470
1465
! call hor_index_init(CS%Grid%Domain, CS%Grid%HI, param_file, &
1471
1466
! local_indexing=.not.global_indexing)
1472
- call MOM_grid_init(CS% Grid , param_file, CS% US)
1467
+ call MOM_grid_init(CS% Grid_in , param_file, CS% US)
1473
1468
1474
- ! if (CS%rotate_index) then
1469
+ if (CS% rotate_index) then
1475
1470
! ! TODO: Index rotation currently only works when index rotation does not
1476
1471
! ! change the MPI rank of each domain. Resolving this will require a
1477
1472
! ! modification to FMS PE assignment.
1478
1473
! ! For now, we only permit single-core runs.
1479
1474
1480
- ! if (num_PEs() /= 1) &
1481
- ! call MOM_error(FATAL, "Index rotation is only supported on one PE.")
1482
-
1483
- ! call get_param(param_file, mdl, "INDEX_TURNS", CS%turns, &
1484
- ! "Number of counterclockwise quarter-turn index rotations.", &
1485
- ! default=1, debuggingParam=.true.)
1486
- ! ! NOTE: If indices are rotated, then CS%Grid and CS%Grid_in must both be initialized.
1487
- ! ! If not rotated, then CS%Grid_in and CS%Ggrid are the same grid.
1488
- ! allocate(CS%Grid)
1489
- ! !allocate(CS%HI)
1490
- ! call clone_MOM_domain(CS%Grid_in%Domain, CS%Grid%Domain,turns=CS%turns)
1491
- ! call rotate_hor_index(CS%Grid_in%HI, CS%turns, CS%Grid%HI)
1492
- ! call MOM_grid_init(CS%Grid, param_file, CS%US, CS%HI)
1493
- ! call create_dyn_horgrid(dG, CS%Grid%HI)
1494
- ! call create_dyn_horgrid(dG_in, CS%Grid_in%HI)
1495
- ! call clone_MOM_domain(CS%Grid_in%Domain, dG_in%Domain)
1496
- ! ! Set up the bottom depth, G%D either analytically or from file
1497
- ! call set_grid_metrics(dG_in,param_file,CS%US)
1498
- ! call MOM_initialize_topography(dG_in%bathyT, CS%Grid_in%max_depth, dG_in, param_file)
1499
- ! call rescale_dyn_horgrid_bathymetry(dG_in, CS%US%Z_to_m)
1500
- ! call rotate_dyngrid(dG_in, dG, CS%US, CS%turns)
1501
- ! call copy_dyngrid_to_MOM_grid(dG,CS%Grid,CS%US)
1502
- ! else
1503
- ! CS%Grid=>CS%Grid_in
1504
- dG = > NULL ()
1505
- ! CS%Grid%HI=>CS%Grid_in%HI
1506
- call create_dyn_horgrid(dG, CS% Grid% HI)
1507
- call clone_MOM_domain(CS% Grid% Domain,dG% Domain)
1508
- call set_grid_metrics(dG,param_file,CS% US)
1509
- ! Set up the bottom depth, dG%bathyT, either analytically or from file
1510
- call MOM_initialize_topography(dG% bathyT, CS% Grid% max_depth, dG, param_file, CS% US)
1511
- call copy_dyngrid_to_MOM_grid(dG, CS% Grid, CS% US)
1512
- call destroy_dyn_horgrid(dG)
1513
- ! endif
1514
- G = > CS% Grid ; CS% Grid_in = > CS% Grid
1475
+ if (num_PEs() /= 1 ) call MOM_error(FATAL, " Index rotation is only supported on one PE." )
1476
+
1477
+ call get_param(param_file, mdl, " INDEX_TURNS" , CS% turns, &
1478
+ " Number of counterclockwise quarter-turn index rotations." , &
1479
+ default= 1 , debuggingParam= .true. )
1480
+ ! NOTE: If indices are rotated, then CS%Grid and CS%Grid_in must both be initialized.
1481
+ ! If not rotated, then CS%Grid_in and CS%Ggrid are the same grid.
1482
+ call create_dyn_horgrid(dG_in, CS% Grid_in% HI)
1483
+ call clone_MOM_domain(CS% Grid_in% Domain, dG_in% Domain)
1484
+ call set_grid_metrics(dG_in, param_file, CS% US)
1485
+ ! Set up the bottom depth, dG_in%bathyT, either analytically or from file
1486
+ call MOM_initialize_topography(dG_in% bathyT, CS% Grid_in% max_depth, dG_in, param_file, CS% US)
1487
+ call copy_dyngrid_to_MOM_grid(dG_in, CS% Grid_in, CS% US)
1488
+
1489
+ ! Now set up the rotated ice-shelf grid.
1490
+ allocate (CS% Grid)
1491
+ call clone_MOM_domain(CS% Grid_in% Domain, CS% Grid% Domain, turns= CS% turns)
1492
+ call rotate_hor_index(CS% Grid_in% HI, CS% turns, CS% Grid% HI)
1493
+ call MOM_grid_init(CS% Grid, param_file, CS% US, CS% Grid% HI)
1494
+ call create_dyn_horgrid(dG, CS% Grid% HI)
1495
+ call rotate_dyngrid(dG_in, dG, CS% US, CS% turns)
1496
+ call copy_dyngrid_to_MOM_grid(dG, CS% Grid, CS% US)
1497
+
1498
+ call destroy_dyn_horgrid(dG_in)
1499
+ call destroy_dyn_horgrid(dG)
1500
+ else
1501
+ CS% Grid = > CS% Grid_in
1502
+ dG = > NULL ()
1503
+ call create_dyn_horgrid(dG, CS% Grid% HI)
1504
+ call clone_MOM_domain(CS% Grid% Domain, dG% Domain)
1505
+ call set_grid_metrics(dG, param_file, CS% US)
1506
+ ! Set up the bottom depth, dG%bathyT, either analytically or from file
1507
+ call MOM_initialize_topography(dG% bathyT, CS% Grid% max_depth, dG, param_file, CS% US)
1508
+ call copy_dyngrid_to_MOM_grid(dG, CS% Grid, CS% US)
1509
+ call destroy_dyn_horgrid(dG)
1510
+ endif
1511
+ G = > CS% Grid
1515
1512
1516
1513
allocate (CS% diag)
1517
1514
call MOM_IS_diag_mediator_init(G, CS% US, param_file, CS% diag, component= ' MOM_IceShelf' )
@@ -1979,8 +1976,11 @@ subroutine initialize_ice_shelf(param_file, ocn_grid, Time, CS, diag, Time_init,
1979
1976
1980
1977
if (save_IC .and. .not. ((dirs% input_filename(1 :1 ) == ' r' ) .and. &
1981
1978
(LEN_TRIM (dirs% input_filename) == 1 ))) then
1979
+ showCallTree = callTree_showQuery()
1980
+ if (showCallTree) call callTree_waypoint(" About to call save_restart (MOM_ice_shelf)" )
1982
1981
call save_restart(dirs% output_directory, CS% Time, CS% Grid_in, CS% restart_CSp, &
1983
1982
filename= IC_file, write_ic= .true. )
1983
+ if (showCallTree) call callTree_waypoint(" Done with call to save_restart (MOM_ice_shelf)" )
1984
1984
endif
1985
1985
1986
1986
CS% id_area_shelf_h = register_diag_field(' ice_shelf_model' , ' area_shelf_h' , CS% diag% axesT1, CS% Time, &
@@ -2130,16 +2130,23 @@ subroutine initialize_ice_shelf_fluxes(CS, ocn_grid, US, fluxes_in)
2130
2130
2131
2131
end subroutine initialize_ice_shelf_fluxes
2132
2132
2133
+ ! > Allocate and initialize the ice-shelf forcing elements of a mechanical forcing type.
2134
+ ! ! This forcing type is on the unrotated grid that is used outside of the MOM6 ice shelf code.
2133
2135
subroutine initialize_ice_shelf_forces (CS , ocn_grid , US , forces_in )
2134
2136
type (ice_shelf_CS), pointer :: CS ! < A pointer to the ice shelf control structure
2135
2137
type (ocean_grid_type), pointer :: ocn_grid ! < The calling ocean model's horizontal grid structure
2136
- type (unit_scale_type), intent (in ) :: US ! < A dimensional unit scaling type
2138
+ type (unit_scale_type), intent (in ) :: US ! < A dimensional unit scaling type
2137
2139
type (mech_forcing), target , intent (inout ) :: forces_in ! < A structure with the driving mechanical forces
2138
2140
2139
2141
! Local variables
2140
2142
type (mech_forcing), pointer :: forces = > NULL ()
2141
2143
2142
2144
call MOM_mesg(" MOM_ice_shelf.F90, initialize_ice_shelf: allocating forces." )
2145
+
2146
+ if ((Ocn_grid% isc /= CS% Grid_in% isc) .or. (Ocn_grid% iec /= CS% Grid_in% iec) .or. &
2147
+ (Ocn_grid% jsc /= CS% Grid_in% jsc) .or. (Ocn_grid% jec /= CS% Grid_in% jec)) &
2148
+ call MOM_error(FATAL," initialize_ice_shelf_forces: Incompatible ocean and external ice shelf grids." )
2149
+
2143
2150
call allocate_mech_forcing(CS% Grid_in, forces_in, ustar= .true. , shelf= .true. , press= .true. , tau_mag= .true. )
2144
2151
if (CS% rotate_index) then
2145
2152
allocate (forces)
@@ -2149,10 +2156,13 @@ subroutine initialize_ice_shelf_forces(CS, ocn_grid, US, forces_in)
2149
2156
forces= >forces_in
2150
2157
endif
2151
2158
2152
- call add_shelf_forces(ocn_grid, US, CS, forces, do_shelf_area= .not. CS% solo_ice_sheet)
2159
+ call add_shelf_forces(CS% grid, US, CS, forces, do_shelf_area= .not. CS% solo_ice_sheet, &
2160
+ external_call= .false. )
2153
2161
2154
- if (CS% rotate_index) &
2162
+ if (CS% rotate_index) then
2155
2163
call rotate_mech_forcing(forces, - CS% turns, forces_in)
2164
+ call deallocate_mech_forcing(forces)
2165
+ endif
2156
2166
2157
2167
end subroutine initialize_ice_shelf_forces
2158
2168
0 commit comments