LCOV - code coverage report
Current view: top level - cicecore/cicedyn/general - ice_state.F90 (source / functions) Hit Total Coverage
Test: 231018-211459:8916b9ff2c:1:quick Lines: 28 48 58.33 %
Date: 2023-10-18 15:30:36 Functions: 2 2 100.00 %

          Line data    Source code
       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_state
      37             : 
      38             :       use ice_kinds_mod
      39             :       use ice_constants, only: field_loc_center, field_type_scalar, c0
      40             :       use ice_domain_size, only: max_blocks, ncat
      41             :       use ice_blocks, only: nx_block, ny_block
      42             :       use ice_exit, only: abort_ice
      43             :       use ice_fileunits, only: nu_diag
      44             :       use icepack_intfc, only: icepack_query_tracer_sizes
      45             :       use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
      46             : 
      47             :       implicit none
      48             :       private
      49             :       public :: bound_state, alloc_state
      50             : 
      51             :       !-----------------------------------------------------------------
      52             :       ! state of the ice aggregated over all categories
      53             :       !-----------------------------------------------------------------
      54             : 
      55             :       real (kind=dbl_kind), dimension(:,:,:), allocatable, &
      56             :          public :: &   ! LCOV_EXCL_LINE
      57             :          aice  , & ! concentration of ice on T grid   ! LCOV_EXCL_LINE
      58             :          aiU   , & ! concentration of ice on U grid   ! LCOV_EXCL_LINE
      59             :          vice  , & ! volume per unit area of ice          (m)   ! LCOV_EXCL_LINE
      60             :          vsno      ! volume per unit area of snow         (m)
      61             : 
      62             :       real (kind=dbl_kind), &
      63             :          dimension(:,:,:,:), allocatable, public :: &   ! LCOV_EXCL_LINE
      64             :          trcr      ! ice tracers
      65             :                    ! 1: surface temperature of ice/snow (C)
      66             : 
      67             :       !-----------------------------------------------------------------
      68             :       ! state of the ice for each category
      69             :       !-----------------------------------------------------------------
      70             : 
      71             :       real (kind=dbl_kind), dimension (:,:,:), allocatable, &
      72             :          public:: &   ! LCOV_EXCL_LINE
      73             :          aice0     ! concentration of open water
      74             : 
      75             :       real (kind=dbl_kind), &
      76             :          dimension (:,:,:,:), allocatable, public :: &   ! LCOV_EXCL_LINE
      77             :          aicen , & ! concentration of ice   ! LCOV_EXCL_LINE
      78             :          vicen , & ! volume per unit area of ice          (m)   ! LCOV_EXCL_LINE
      79             :          vsnon     ! volume per unit area of snow         (m)
      80             : 
      81             :       real (kind=dbl_kind), public, &
      82             :          dimension (:,:,:,:,:), allocatable :: &   ! LCOV_EXCL_LINE
      83             :          trcrn     ! tracers
      84             :                    ! 1: surface temperature of ice/snow (C)
      85             : 
      86             :       !-----------------------------------------------------------------
      87             :       ! tracers infrastructure arrays
      88             :       !-----------------------------------------------------------------
      89             : 
      90             :       integer (kind=int_kind), dimension (:), allocatable, public :: &
      91             :          trcr_depend   ! = 0 for ice area tracers
      92             :                        ! = 1 for ice volume tracers
      93             :                        ! = 2 for snow volume tracers
      94             : 
      95             :       integer (kind=int_kind), dimension (:), allocatable, public :: &
      96             :          n_trcr_strata ! number of underlying tracer layers
      97             : 
      98             :       integer (kind=int_kind), dimension (:,:), allocatable, public :: &
      99             :          nt_strata     ! indices of underlying tracer layers
     100             : 
     101             :       real (kind=dbl_kind), dimension (:,:), allocatable, public :: &
     102             :          trcr_base     ! = 0 or 1 depending on tracer dependency
     103             :                        ! argument 2:  (1) aice, (2) vice, (3) vsno
     104             : 
     105             :       !-----------------------------------------------------------------
     106             :       ! dynamic variables closely related to the state of the ice
     107             :       !-----------------------------------------------------------------
     108             : 
     109             :       real (kind=dbl_kind), dimension(:,:,:), allocatable, &
     110             :          public :: &   ! LCOV_EXCL_LINE
     111             :          uvel     , & ! x-component of velocity on U grid (m/s)   ! LCOV_EXCL_LINE
     112             :          vvel     , & ! y-component of velocity on U grid (m/s)   ! LCOV_EXCL_LINE
     113             :          uvelE    , & ! x-component of velocity on E grid (m/s)   ! LCOV_EXCL_LINE
     114             :          vvelE    , & ! y-component of velocity on E grid (m/s)   ! LCOV_EXCL_LINE
     115             :          uvelN    , & ! x-component of velocity on N grid (m/s)   ! LCOV_EXCL_LINE
     116             :          vvelN    , & ! y-component of velocity on N grid (m/s)   ! LCOV_EXCL_LINE
     117             :          divu     , & ! strain rate I component, velocity divergence (1/s)   ! LCOV_EXCL_LINE
     118             :          shear    , & ! strain rate II component (1/s)   ! LCOV_EXCL_LINE
     119             :          strength     ! ice strength (N/m)
     120             : 
     121             :       !-----------------------------------------------------------------
     122             :       ! ice state at start of time step, saved for later in the step
     123             :       !-----------------------------------------------------------------
     124             : 
     125             :       real (kind=dbl_kind), dimension(:,:,:), allocatable, &
     126             :          public :: &   ! LCOV_EXCL_LINE
     127             :          aice_init       ! initial concentration of ice, for diagnostics
     128             : 
     129             :       real (kind=dbl_kind), &
     130             :          dimension(:,:,:,:), allocatable, public :: &   ! LCOV_EXCL_LINE
     131             :          aicen_init  , & ! initial ice concentration, for linear ITD   ! LCOV_EXCL_LINE
     132             :          vicen_init  , & ! initial ice volume (m), for linear ITD   ! LCOV_EXCL_LINE
     133             :          vsnon_init      ! initial snow volume (m), for aerosol
     134             : 
     135             : !=======================================================================
     136             : 
     137             :       contains
     138             : 
     139             : !=======================================================================
     140             : !
     141             : ! Allocate space for all state variables
     142             : !
     143          37 :       subroutine alloc_state
     144             :       integer (int_kind) :: ntrcr, ierr
     145             :       character(len=*),parameter :: subname='(alloc_state)'
     146             : 
     147          37 :       call icepack_query_tracer_sizes(ntrcr_out=ntrcr)
     148          37 :       call icepack_warnings_flush(nu_diag)
     149          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
     150           0 :           file=__FILE__, line=__LINE__)
     151             : 
     152             :       allocate ( &
     153             :          aice      (nx_block,ny_block,max_blocks) , & ! concentration of ice T grid   ! LCOV_EXCL_LINE
     154             :          aiU       (nx_block,ny_block,max_blocks) , & ! concentration of ice U grid   ! LCOV_EXCL_LINE
     155             :          vice      (nx_block,ny_block,max_blocks) , & ! volume per unit area of ice (m)   ! LCOV_EXCL_LINE
     156             :          vsno      (nx_block,ny_block,max_blocks) , & ! volume per unit area of snow (m)   ! LCOV_EXCL_LINE
     157             :          aice0     (nx_block,ny_block,max_blocks) , & ! concentration of open water   ! LCOV_EXCL_LINE
     158             :          uvel      (nx_block,ny_block,max_blocks) , & ! x-component of velocity on U grid (m/s)   ! LCOV_EXCL_LINE
     159             :          vvel      (nx_block,ny_block,max_blocks) , & ! y-component of velocity on U grid (m/s)   ! LCOV_EXCL_LINE
     160             :          uvelE     (nx_block,ny_block,max_blocks) , & ! x-component of velocity on E grid (m/s)   ! LCOV_EXCL_LINE
     161             :          vvelE     (nx_block,ny_block,max_blocks) , & ! y-component of velocity on E grid (m/s)   ! LCOV_EXCL_LINE
     162             :          uvelN     (nx_block,ny_block,max_blocks) , & ! x-component of velocity on N grid (m/s)   ! LCOV_EXCL_LINE
     163             :          vvelN     (nx_block,ny_block,max_blocks) , & ! y-component of velocity on N grid (m/s)   ! LCOV_EXCL_LINE
     164             :          divu      (nx_block,ny_block,max_blocks) , & ! strain rate I component, velocity divergence (1/s)   ! LCOV_EXCL_LINE
     165             :          shear     (nx_block,ny_block,max_blocks) , & ! strain rate II component (1/s)   ! LCOV_EXCL_LINE
     166             :          strength  (nx_block,ny_block,max_blocks) , & ! ice strength (N/m)   ! LCOV_EXCL_LINE
     167             :          aice_init (nx_block,ny_block,max_blocks) , & ! initial concentration of ice, for diagnostics   ! LCOV_EXCL_LINE
     168             :          aicen     (nx_block,ny_block,ncat,max_blocks) , & ! concentration of ice   ! LCOV_EXCL_LINE
     169             :          vicen     (nx_block,ny_block,ncat,max_blocks) , & ! volume per unit area of ice (m)   ! LCOV_EXCL_LINE
     170             :          vsnon     (nx_block,ny_block,ncat,max_blocks) , & ! volume per unit area of snow (m)   ! LCOV_EXCL_LINE
     171             :          aicen_init(nx_block,ny_block,ncat,max_blocks) , & ! initial ice concentration, for linear ITD   ! LCOV_EXCL_LINE
     172             :          vicen_init(nx_block,ny_block,ncat,max_blocks) , & ! initial ice volume (m), for linear ITD   ! LCOV_EXCL_LINE
     173             :          vsnon_init(nx_block,ny_block,ncat,max_blocks) , & ! initial snow volume (m), for aerosol   ! LCOV_EXCL_LINE
     174             :          trcr      (nx_block,ny_block,ntrcr,max_blocks) , & ! ice tracers: 1: surface temperature of ice/snow (C)   ! LCOV_EXCL_LINE
     175             :          trcrn     (nx_block,ny_block,ntrcr,ncat,max_blocks) , & ! tracers: 1: surface temperature of ice/snow (C)   ! LCOV_EXCL_LINE
     176          37 :          stat=ierr)
     177          37 :       if (ierr/=0) call abort_ice('(alloc_state): Out of memory1')
     178             : 
     179             :       allocate ( &
     180             :          trcr_depend(ntrcr)   , & !   ! LCOV_EXCL_LINE
     181             :          n_trcr_strata(ntrcr) , & ! number of underlying tracer layers   ! LCOV_EXCL_LINE
     182             :          nt_strata(ntrcr,2)   , & ! indices of underlying tracer layers   ! LCOV_EXCL_LINE
     183             :          trcr_base(ntrcr,3)   , & ! = 0 or 1 depending on tracer dependency, (1) aice, (2) vice, (3) vsno   ! LCOV_EXCL_LINE
     184          37 :          stat=ierr)
     185          37 :       if (ierr/=0) call abort_ice('(alloc_state): Out of memory2')
     186             : 
     187         925 :       trcr_depend = 0
     188         925 :       n_trcr_strata = 0
     189        1887 :       nt_strata = 0
     190        2812 :       trcr_base = c0
     191      559693 :       aicen = c0
     192      559693 :       aicen_init = c0
     193      559693 :       vicen = c0
     194      559693 :       vicen_init = c0
     195      559693 :       vsnon = c0
     196      559693 :       vsnon_init = c0
     197             : 
     198          37 :       end subroutine alloc_state
     199             : 
     200             : !=======================================================================
     201             : !
     202             : ! Get ghost cell values for ice state variables in each thickness category.
     203             : ! NOTE: This subroutine cannot be called from inside a block loop!
     204             : !
     205             : ! author: William H. Lipscomb, LANL
     206             : 
     207       17389 :       subroutine bound_state (aicen,        &
     208             :                               vicen, vsnon, &   ! LCOV_EXCL_LINE
     209       17389 :                               ntrcr, trcrn)
     210             : 
     211             :       use ice_boundary, only: ice_halo, ice_HaloMask, ice_HaloUpdate, &
     212             :           ice_HaloDestroy
     213             :       use ice_domain, only: halo_info, maskhalo_bound, nblocks
     214             : 
     215             :       integer (kind=int_kind), intent(in) :: &
     216             :          ntrcr     ! number of tracers in use
     217             : 
     218             :       real (kind=dbl_kind), dimension(nx_block,ny_block,ncat,max_blocks), intent(inout) :: &
     219             :          aicen , & ! fractional ice area   ! LCOV_EXCL_LINE
     220             :          vicen , & ! volume per unit area of ice          (m)   ! LCOV_EXCL_LINE
     221             :          vsnon     ! volume per unit area of snow         (m)
     222             : 
     223             :       real (kind=dbl_kind), intent(inout), dimension(:,:,:,:,:) :: &  ! (nx_block,ny_block,ntrcr,ncat,max_blocks)
     224             :          trcrn     ! ice tracers
     225             : 
     226             :       ! local variables
     227             : 
     228             :       integer (kind=int_kind) :: i, j, n, iblk
     229             : 
     230             :       integer (kind=int_kind), &
     231       34778 :          dimension(nx_block,ny_block,max_blocks) :: halomask
     232             : 
     233             :       type (ice_halo) :: halo_info_aicemask
     234             : 
     235             :       character(len=*), parameter :: subname = '(bound_state)'
     236             : 
     237           0 :       call ice_HaloUpdate (aicen,            halo_info, &
     238       17389 :                            field_loc_center, field_type_scalar)
     239             : 
     240       17389 :       if (maskhalo_bound) then
     241           0 :          halomask(:,:,:) = 0
     242             : 
     243           0 :          !$OMP PARALLEL DO PRIVATE(iblk,n,i,j)
     244           0 :          do iblk = 1, nblocks
     245           0 :          do n = 1, ncat
     246           0 :          do j = 1, ny_block
     247           0 :          do i = 1, nx_block
     248           0 :             if (aicen(i,j,n,iblk) > c0) halomask(i,j,iblk) = 1
     249             :          enddo
     250             :          enddo
     251             :          enddo
     252             :          enddo
     253             :          !$OMP END PARALLEL DO
     254             : 
     255           0 :          call ice_HaloMask(halo_info_aicemask, halo_info, halomask)
     256             : 
     257           0 :          call ice_HaloUpdate (trcrn(:,:,:,:,:), halo_info_aicemask, &
     258           0 :                               field_loc_center, field_type_scalar)
     259           0 :          call ice_HaloUpdate (vicen,            halo_info_aicemask, &
     260           0 :                               field_loc_center, field_type_scalar)
     261           0 :          call ice_HaloUpdate (vsnon,            halo_info_aicemask, &
     262           0 :                               field_loc_center, field_type_scalar)
     263           0 :          call ice_HaloDestroy(halo_info_aicemask)
     264             : 
     265             :       else
     266           0 :          call ice_HaloUpdate (trcrn(:,:,:,:,:), halo_info, &
     267       17389 :                               field_loc_center, field_type_scalar)
     268           0 :          call ice_HaloUpdate (vicen,            halo_info, &
     269       17389 :                               field_loc_center, field_type_scalar)
     270           0 :          call ice_HaloUpdate (vsnon,            halo_info, &
     271       17389 :                               field_loc_center, field_type_scalar)
     272             :       endif
     273             : 
     274       17389 :       end subroutine bound_state
     275             : 
     276             : !=======================================================================
     277             : 
     278             :       end module ice_state
     279             : 
     280             : !=======================================================================

Generated by: LCOV version 1.14-6-g40580cd