|
| 1 | +!======================================================================= |
| 2 | +! |
| 3 | +! Primary state variables in various configurations |
| 4 | +! Note: other state variables are at the end of this... |
| 5 | +! The primary state variable names are: |
| 6 | +!------------------------------------------------------------------- |
| 7 | +! for each category aggregated over units |
| 8 | +! categories |
| 9 | +!------------------------------------------------------------------- |
| 10 | +! aicen(i,j,n) aice(i,j) --- |
| 11 | +! vicen(i,j,n) vice(i,j) m |
| 12 | +! vsnon(i,j,n) vsno(i,j) m |
| 13 | +! trcrn(i,j,it,n) trcr(i,j,it) |
| 14 | +! |
| 15 | +! Area is dimensionless because aice is the fractional area |
| 16 | +! (normalized so that the sum over all categories, including open |
| 17 | +! water, is 1.0). That is why vice/vsno have units of m instead of m^3. |
| 18 | +! |
| 19 | +! Variable names follow these rules: |
| 20 | +! |
| 21 | +! (1) For 3D variables (indices i,j,n), write 'ice' or 'sno' or |
| 22 | +! 'sfc' and put an 'n' at the end. |
| 23 | +! (2) For 2D variables (indices i,j) aggregated over all categories, |
| 24 | +! write 'ice' or 'sno' or 'sfc' without the 'n'. |
| 25 | +! (3) For 2D variables (indices i,j) associated with an individual |
| 26 | +! category, write 'i' or 's' instead of 'ice' or 'sno' and put an 'n' |
| 27 | +! at the end: e.g. hin, hsn. These are not declared here |
| 28 | +! but in individual modules (e.g., icepack_therm_vertical). |
| 29 | +! |
| 30 | +! authors C. M. Bitz, UW |
| 31 | +! Elizabeth C. Hunke and William H. Lipscomb, LANL |
| 32 | +! |
| 33 | +! 2004: Block structure added by William Lipscomb |
| 34 | +! 2006: Converted to free form source (F90) by Elizabeth Hunke |
| 35 | + |
| 36 | + module ice_bound_state |
| 37 | + |
| 38 | + use ice_kinds_mod |
| 39 | + use ice_constants, only: field_loc_center, field_type_scalar, c0 |
| 40 | + use ice_exit, only: abort_ice |
| 41 | + use ice_fileunits, only: nu_diag |
| 42 | +! use icepack_intfc, only: icepack_query_tracer_sizes |
| 43 | +! use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted |
| 44 | + |
| 45 | + implicit none |
| 46 | + private |
| 47 | + public :: bound_state |
| 48 | + |
| 49 | +!======================================================================= |
| 50 | + |
| 51 | + contains |
| 52 | + |
| 53 | +!======================================================================= |
| 54 | +! |
| 55 | +! Get ghost cell values for ice state variables in each thickness category. |
| 56 | +! NOTE: This subroutine cannot be called from inside a block loop! |
| 57 | +! |
| 58 | +! author: William H. Lipscomb, LANL |
| 59 | + |
| 60 | + subroutine bound_state (aicen, & |
| 61 | + vicen, vsnon, & |
| 62 | + ntrcr, trcrn, & |
| 63 | + restore) |
| 64 | + |
| 65 | + use ice_boundary, only: ice_halo, ice_HaloMask, ice_HaloUpdate, & |
| 66 | + ice_HaloDestroy |
| 67 | + use ice_domain_size, only: max_blocks, ncat |
| 68 | + use ice_blocks, only: nx_block, ny_block |
| 69 | + use ice_domain, only: halo_info, maskhalo_bound, nblocks |
| 70 | + use ice_restoring, only: ice_restoring_halo |
| 71 | + |
| 72 | + integer (kind=int_kind), intent(in) :: & |
| 73 | + ntrcr ! number of tracers in use |
| 74 | + |
| 75 | + real (kind=dbl_kind), dimension(nx_block,ny_block,ncat,max_blocks), intent(inout) :: & |
| 76 | + aicen , & ! fractional ice area |
| 77 | + vicen , & ! volume per unit area of ice (m) |
| 78 | + vsnon ! volume per unit area of snow (m) |
| 79 | + |
| 80 | + real (kind=dbl_kind), intent(inout), dimension(:,:,:,:,:) :: & ! (nx_block,ny_block,ntrcr,ncat,max_blocks) |
| 81 | + trcrn ! ice tracers |
| 82 | + |
| 83 | + logical (kind=log_kind), intent(in), optional :: & |
| 84 | + restore |
| 85 | + |
| 86 | + ! local variables |
| 87 | + |
| 88 | + integer (kind=int_kind) :: i, j, n, iblk |
| 89 | + |
| 90 | + integer (kind=int_kind), & |
| 91 | + dimension(nx_block,ny_block,max_blocks) :: halomask |
| 92 | + |
| 93 | + type (ice_halo) :: halo_info_aicemask ! halo mask |
| 94 | + |
| 95 | + logical (kind=log_kind) :: lrestore ! local restart flag |
| 96 | + |
| 97 | + character(len=*), parameter :: subname = '(bound_state)' |
| 98 | + |
| 99 | + if (present(restore)) then |
| 100 | + lrestore = restore |
| 101 | + else |
| 102 | + lrestore = .true. |
| 103 | + endif |
| 104 | + |
| 105 | + call ice_HaloUpdate (aicen, halo_info, & |
| 106 | + field_loc_center, field_type_scalar) |
| 107 | + |
| 108 | + if (maskhalo_bound) then |
| 109 | + halomask(:,:,:) = 0 |
| 110 | + |
| 111 | + !$OMP PARALLEL DO PRIVATE(iblk,n,i,j) |
| 112 | + do iblk = 1, nblocks |
| 113 | + do n = 1, ncat |
| 114 | + do j = 1, ny_block |
| 115 | + do i = 1, nx_block |
| 116 | + if (aicen(i,j,n,iblk) > c0) halomask(i,j,iblk) = 1 |
| 117 | + enddo |
| 118 | + enddo |
| 119 | + enddo |
| 120 | + enddo |
| 121 | + !$OMP END PARALLEL DO |
| 122 | + |
| 123 | + call ice_HaloMask(halo_info_aicemask, halo_info, halomask) |
| 124 | + |
| 125 | + call ice_HaloUpdate (trcrn(:,:,:,:,:), halo_info_aicemask, & |
| 126 | + field_loc_center, field_type_scalar) |
| 127 | + call ice_HaloUpdate (vicen, halo_info_aicemask, & |
| 128 | + field_loc_center, field_type_scalar) |
| 129 | + call ice_HaloUpdate (vsnon, halo_info_aicemask, & |
| 130 | + field_loc_center, field_type_scalar) |
| 131 | + call ice_HaloDestroy(halo_info_aicemask) |
| 132 | + |
| 133 | + else |
| 134 | + call ice_HaloUpdate (trcrn(:,:,:,:,:), halo_info, & |
| 135 | + field_loc_center, field_type_scalar) |
| 136 | + call ice_HaloUpdate (vicen, halo_info, & |
| 137 | + field_loc_center, field_type_scalar) |
| 138 | + call ice_HaloUpdate (vsnon, halo_info, & |
| 139 | + field_loc_center, field_type_scalar) |
| 140 | + endif |
| 141 | + |
| 142 | + if (lrestore) then |
| 143 | + call ice_restoring_halo(setfld='state') |
| 144 | + endif |
| 145 | + |
| 146 | + end subroutine bound_state |
| 147 | + |
| 148 | +!======================================================================= |
| 149 | + |
| 150 | + end module ice_bound_state |
| 151 | + |
| 152 | +!======================================================================= |
0 commit comments