LCOV - code coverage report
Current view: top level - configuration/driver - icedrv_flux.F90 (source / functions) Hit Total Coverage
Test: 200704-015006:b1e41d9f12:3:base,travis,quick Lines: 261 265 98.49 %
Date: 2020-07-03 20:11:40 Functions: 5 5 100.00 %

          Line data    Source code
       1             : !=======================================================================
       2             : 
       3             : ! Flux variable declarations; these include fields sent from the coupler
       4             : ! ("in"), sent to the coupler ("out"), written to diagnostic history files
       5             : ! ("diagnostic"), and used internally ("internal").
       6             : !
       7             : ! author Elizabeth C. Hunke, LANL
       8             : !
       9             :       module icedrv_flux
      10             : 
      11             :       use icedrv_kinds
      12             :       use icedrv_domain_size, only: ncat, nilyr, nx
      13             :       use icedrv_constants, only: c0, c1, c5, c10, c20, c180
      14             :       use icedrv_constants, only: nu_diag
      15             :       use icepack_intfc, only: icepack_max_iso, icepack_max_aero
      16             :       use icepack_intfc, only: icepack_max_nbtrcr, icepack_max_fe
      17             :       use icepack_intfc, only: icepack_max_algae, icepack_max_doc, icepack_max_don
      18             :       use icepack_intfc, only: icepack_max_dic
      19             :       use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
      20             :       use icepack_intfc, only: icepack_query_parameters
      21             :       use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_indices
      22             :       use icepack_intfc, only: icepack_query_parameters
      23             :       use icedrv_system, only: icedrv_system_abort
      24             : 
      25             :       implicit none
      26             :       private
      27             :       public :: init_coupler_flux, init_history_therm, init_history_dyn, &
      28             :                 init_flux_atm_ocn, init_history_bgc
      29             : 
      30             :       character (char_len), public :: &
      31             :          default_season ! seasonal default values for forcing
      32             : 
      33             :       !-----------------------------------------------------------------
      34             :       ! Dynamics component
      35             :       !-----------------------------------------------------------------
      36             : 
      37             :       real (kind=dbl_kind), dimension (nx), public :: &
      38             : 
      39             :        ! in from atmos (if .not.calc_strair)  
      40             :          strax   , & ! wind stress components (N/m^2)
      41             :          stray   , & ! 
      42             : 
      43             :        ! in from ocean
      44             :          uocn    , & ! ocean current, x-direction (m/s)
      45             :          vocn    , & ! ocean current, y-direction (m/s)
      46             : 
      47             :        ! out to atmosphere
      48             :          strairxT, & ! stress on ice by air, x-direction
      49             :          strairyT, & ! stress on ice by air, y-direction
      50             : 
      51             :        ! out to ocean          T-cell (kg/m s^2)
      52             :          strocnxT, & ! ice-ocean stress, x-direction
      53             :          strocnyT    ! ice-ocean stress, y-direction
      54             : 
      55             :        ! diagnostic
      56             : 
      57             :       real (kind=dbl_kind), dimension (nx), public :: &
      58             :          strairx , & ! stress on ice by air, x-direction
      59             :          strairy , & ! stress on ice by air, y-direction
      60             :          daidtd  , & ! ice area tendency due to transport   (1/s)
      61             :          dvidtd  , & ! ice volume tendency due to transport (m/s)
      62             :          dagedtd , & ! ice age tendency due to transport (s/s)
      63             :          dardg1dt, & ! rate of area loss by ridging ice (1/s)
      64             :          dardg2dt, & ! rate of area gain by new ridges (1/s)
      65             :          dvirdgdt, & ! rate of ice volume ridged (m/s)
      66             :          closing,  & ! rate of closing due to divergence/shear (1/s)
      67             :          opening     ! rate of opening due to divergence/shear (1/s)
      68             : 
      69             :       real (kind=dbl_kind), & 
      70             :          dimension (nx,ncat), public :: &
      71             :        ! ridging diagnostics in categories
      72             :          dardg1ndt, & ! rate of area loss by ridging ice (1/s)
      73             :          dardg2ndt, & ! rate of area gain by new ridges (1/s)
      74             :          dvirdgndt, & ! rate of ice volume ridged (m/s)
      75             :          aparticn,  & ! participation function
      76             :          krdgn,     & ! mean ridge thickness/thickness of ridging ice
      77             :          ardgn,     & ! fractional area of ridged ice
      78             :          vrdgn,     & ! volume of ridged ice
      79             :          araftn,    & ! rafting ice area
      80             :          vraftn,    & ! rafting ice volume 
      81             :          aredistn,  & ! redistribution function: fraction of new ridge area
      82             :          vredistn     ! redistribution function: fraction of new ridge volume
      83             : 
      84             :       !-----------------------------------------------------------------
      85             :       ! Thermodynamic component
      86             :       !-----------------------------------------------------------------
      87             : 
      88             :        ! in from atmosphere (if calc_Tsfc)
      89             : 
      90             :       real (kind=dbl_kind), dimension (nx), public :: &
      91             :          zlvl    , & ! atm level height (m)
      92             :          uatm    , & ! wind velocity components (m/s)
      93             :          vatm    , &
      94             :          wind    , & ! wind speed (m/s)
      95             :          potT    , & ! air potential temperature  (K)
      96             :          Tair    , & ! air temperature  (K)
      97             :          Qa      , & ! specific humidity (kg/kg)
      98             :          rhoa    , & ! air density (kg/m^3)
      99             :          swvdr   , & ! sw down, visible, direct  (W/m^2)
     100             :          swvdf   , & ! sw down, visible, diffuse (W/m^2)
     101             :          swidr   , & ! sw down, near IR, direct  (W/m^2)
     102             :          swidf   , & ! sw down, near IR, diffuse (W/m^2)
     103             :          flw         ! incoming longwave radiation (W/m^2)
     104             : 
     105             :        ! in from atmosphere (if .not. calc_Tsfc)
     106             :        ! These are per ice area
     107             : 
     108             :       real (kind=dbl_kind), & 
     109             :          dimension (nx,ncat), public :: &
     110             :          fsurfn_f   , & ! net flux to top surface, excluding fcondtop
     111             :          fcondtopn_f, & ! downward cond flux at top surface (W m-2)
     112             :          fsensn_f   , & ! sensible heat flux (W m-2)
     113             :          flatn_f        ! latent heat flux (W m-2)
     114             : 
     115             :        ! in from atmosphere
     116             : 
     117             :       real (kind=dbl_kind), dimension (nx), public :: &
     118             :          frain   , & ! rainfall rate (kg/m^2 s)
     119             :          fsnow       ! snowfall rate (kg/m^2 s)
     120             : 
     121             :        ! in from ocean
     122             : 
     123             :       real (kind=dbl_kind), dimension (nx), public :: &
     124             :          sss     , & ! sea surface salinity (ppt)
     125             :          sst     , & ! sea surface temperature (C)
     126             :          sstdat  , & ! sea surface temperature (C) saved for restoring
     127             :          frzmlt  , & ! freezing/melting potential (W/m^2)
     128             :          frzmlt_init, & ! frzmlt used in current time step (W/m^2)
     129             :          Tf      , & ! freezing temperature (C)
     130             :          qdp     , & ! deep ocean heat flux (W/m^2), negative upward
     131             :          hmix        ! mixed layer depth (m)
     132             : 
     133             :       ! water isotopes
     134             :       real (kind=dbl_kind), dimension (nx), public :: &
     135             :          HDO_ocn    , & ! seawater concentration of HDO (kg/kg)
     136             :          H2_16O_ocn , & ! seawater concentration of H2_16O (kg/kg)
     137             :          H2_18O_ocn     ! seawater concentration of H2_18O (kg/kg)
     138             : 
     139             :       real (kind=dbl_kind), dimension (nx), public :: &
     140             :          fsens   , & ! sensible heat flux (W/m^2)
     141             :          flat    , & ! latent heat flux   (W/m^2)
     142             :          fswabs  , & ! shortwave flux absorbed in ice and ocean (W/m^2)
     143             :          fswint_ai,& ! SW absorbed in ice interior below surface (W/m^2)
     144             :          flwout  , & ! outgoing longwave radiation (W/m^2)
     145             :          Tref    , & ! 2m atm reference temperature (K)
     146             :          Qref    , & ! 2m atm reference spec humidity (kg/kg)
     147             :          Uref    , & ! 10m atm reference wind speed (m/s)
     148             :          evap    , & ! evaporative water flux (kg/m^2/s)
     149             :          evaps   , & ! evaporative water flux over snow (kg/m^2/s)
     150             :          evapi       ! evaporative water flux over ice (kg/m^2/s)
     151             : 
     152             :        ! albedos aggregated over categories (if calc_Tsfc)
     153             :       real (kind=dbl_kind), dimension(nx), public :: &
     154             :          alvdr   , & ! visible, direct   (fraction)
     155             :          alidr   , & ! near-ir, direct   (fraction)
     156             :          alvdf   , & ! visible, diffuse  (fraction)
     157             :          alidf   , & ! near-ir, diffuse  (fraction)
     158             :          ! grid-box-mean versions
     159             :          alvdr_ai, & ! visible, direct   (fraction)
     160             :          alidr_ai, & ! near-ir, direct   (fraction)
     161             :          alvdf_ai, & ! visible, diffuse  (fraction)
     162             :          alidf_ai, & ! near-ir, diffuse  (fraction)
     163             :          ! components for history
     164             :          albice    , & ! bare ice albedo
     165             :          albsno    , & ! snow albedo
     166             :          albpnd    , & ! melt pond albedo
     167             :          apeff_ai  , & ! effective pond area used for radiation calculation
     168             :          snowfrac  , & ! snow fraction used in radiation
     169             :          ! components for diagnostic
     170             :          alvdr_init, & ! visible, direct   (fraction)
     171             :          alidr_init, & ! near-ir, direct   (fraction)
     172             :          alvdf_init, & ! visible, diffuse  (fraction)
     173             :          alidf_init    ! near-ir, diffuse  (fraction)
     174             : 
     175             :        ! out to ocean
     176             :       real (kind=dbl_kind), dimension (nx), public :: &
     177             :          fpond   , & ! fresh water flux to ponds (kg/m^2/s)
     178             :          fresh   , & ! fresh water flux to ocean (kg/m^2/s)
     179             :          fsalt   , & ! salt flux to ocean (kg/m^2/s)
     180             :          fhocn   , & ! net heat flux to ocean (W/m^2)
     181             :          fswthru , & ! shortwave penetrating to ocean (W/m^2)
     182             :          fswthru_vdr , & ! vis dir shortwave penetrating to ocean (W/m^2)
     183             :          fswthru_vdf , & ! vis dif shortwave penetrating to ocean (W/m^2)
     184             :          fswthru_idr , & ! nir dir shortwave penetrating to ocean (W/m^2)
     185             :          fswthru_idf     ! nir dif shortwave penetrating to ocean (W/m^2)
     186             : 
     187             :        ! internal
     188             : 
     189             :       real (kind=dbl_kind), &
     190             :          dimension (nx), public :: &
     191             :          fswfac  , & ! for history
     192             :          scale_factor! scaling factor for shortwave components
     193             : 
     194             :       logical (kind=log_kind), public :: &
     195             :          update_ocn_f, & ! if true, update fresh water and salt fluxes
     196             :          l_mpond_fresh   ! if true, include freshwater feedback from meltponds
     197             :                          ! when running in ice-ocean or coupled configuration
     198             : 
     199             :       real (kind=dbl_kind), dimension (nx,ncat), public :: &
     200             :          meltsn      , & ! snow melt in category n (m)
     201             :          melttn      , & ! top melt in category n (m)
     202             :          meltbn      , & ! bottom melt in category n (m)
     203             :          congeln     , & ! congelation ice formation in category n (m)
     204             :          snoicen         ! snow-ice formation in category n (m)
     205             : 
     206             :       real (kind=dbl_kind), dimension (nx,ncat), public :: &
     207             :          keffn_top       ! effective thermal conductivity of the top ice layer 
     208             :                          ! on categories (W/m^2/K)
     209             : 
     210             :       ! quantities passed from ocean mixed layer to atmosphere
     211             : 
     212             :       real (kind=dbl_kind), dimension (nx), public :: &
     213             :          strairx_ocn , & ! stress on ocean by air, x-direction
     214             :          strairy_ocn , & ! stress on ocean by air, y-direction
     215             :          fsens_ocn   , & ! sensible heat flux (W/m^2)
     216             :          flat_ocn    , & ! latent heat flux   (W/m^2)
     217             :          flwout_ocn  , & ! outgoing longwave radiation (W/m^2)
     218             :          evap_ocn    , & ! evaporative water flux (kg/m^2/s)
     219             :          alvdr_ocn   , & ! visible, direct   (fraction)
     220             :          alidr_ocn   , & ! near-ir, direct   (fraction)
     221             :          alvdf_ocn   , & ! visible, diffuse  (fraction)
     222             :          alidf_ocn   , & ! near-ir, diffuse  (fraction)
     223             :          Tref_ocn    , & ! 2m atm reference temperature (K)
     224             :          Qref_ocn        ! 2m atm reference spec humidity (kg/kg)
     225             : 
     226             :       ! diagnostic
     227             : 
     228             :       real (kind=dbl_kind), dimension (nx), public :: &
     229             :          fsurf , & ! net surface heat flux (excluding fcondtop)(W/m^2)
     230             :          fcondtop,&! top surface conductive flux        (W/m^2)
     231             :          fcondbot,&! bottom surface conductive flux        (W/m^2)
     232             :          fbot,   & ! heat flux at bottom surface of ice (excluding excess) (W/m^2)
     233             :          Tbot,   & ! Temperature at bottom surface of ice (deg C)
     234             :          Tsnice,  & ! Temperature at snow ice interface (deg C)
     235             :          congel, & ! basal ice growth         (m/step-->cm/day)
     236             :          frazil, & ! frazil ice growth        (m/step-->cm/day)
     237             :          snoice, & ! snow-ice formation       (m/step-->cm/day)
     238             :          meltt , & ! top ice melt             (m/step-->cm/day)
     239             :          melts , & ! snow melt                (m/step-->cm/day)
     240             :          meltb , & ! basal ice melt           (m/step-->cm/day)
     241             :          meltl , & ! lateral ice melt         (m/step-->cm/day)
     242             :          dsnow,  & ! change in snow thickness (m/step-->cm/day)
     243             :          daidtt, & ! ice area tendency thermo.   (s^-1)
     244             :          dvidtt, & ! ice volume tendency thermo. (m/s)
     245             :          dagedtt,& ! ice age tendency thermo.    (s/s)
     246             :          mlt_onset, &! day of year that sfc melting begins
     247             :          frz_onset, &! day of year that freezing begins (congel or frazil)
     248             :          frazil_diag ! frazil ice growth diagnostic (m/step-->cm/day)
     249             :          
     250             :       real (kind=dbl_kind), & 
     251             :          dimension (nx,ncat), public :: &
     252             :          fsurfn,   & ! category fsurf
     253             :          fcondtopn,& ! category fcondtop
     254             :          fcondbotn,& ! category fcondbot
     255             :          fsensn,   & ! category sensible heat flux
     256             :          flatn       ! category latent heat flux
     257             : 
     258             :       ! As above but these remain grid box mean values i.e. they are not
     259             :       ! divided by aice at end of ice_dynamics.
     260             :       ! These are used for generating
     261             :       ! ice diagnostics as these are more accurate. 
     262             :       ! (The others suffer from problem of incorrect values at grid boxes
     263             :       !  that change from an ice free state to an icy state.)
     264             :     
     265             :       real (kind=dbl_kind), dimension (nx), public :: &
     266             :          fresh_ai, & ! fresh water flux to ocean (kg/m^2/s)
     267             :          fsalt_ai, & ! salt flux to ocean (kg/m^2/s)
     268             :          fhocn_ai, & ! net heat flux to ocean (W/m^2)
     269             :          fswthru_ai  ! shortwave penetrating to ocean (W/m^2)
     270             : 
     271             :       !-----------------------------------------------------------------
     272             :       ! internal
     273             :       !-----------------------------------------------------------------
     274             : 
     275             :       real (kind=dbl_kind), dimension (nx), public :: &
     276             :          rside   , & ! fraction of ice that melts laterally
     277             :          fside   , & ! lateral heat flux (W/m^2)
     278             :          fsw     , & ! incoming shortwave radiation (W/m^2)
     279             :          coszen  , & ! cosine solar zenith angle, < 0 for sun below horizon 
     280             :          rdg_conv, & ! convergence term for ridging (1/s)
     281             :          rdg_shear   ! shear term for ridging (1/s)
     282             :  
     283             :       real (kind=dbl_kind), dimension(nx,nilyr+1), public :: &
     284             :          salinz  , & ! initial salinity  profile (ppt)   
     285             :          Tmltz       ! initial melting temperature (C)
     286             : 
     287             :       !-----------------------------------------------------------------
     288             :       ! biogeochemistry
     289             :       !-----------------------------------------------------------------
     290             : 
     291             :       ! in from atmosphere
     292             : 
     293             :       real (kind=dbl_kind), &   ! coupling variable for both tr_aero and tr_zaero
     294             :          dimension (nx,icepack_max_aero), public :: &
     295             :          faero_atm   ! aerosol deposition rate (kg/m^2 s)   
     296             : 
     297             :       real (kind=dbl_kind), &   ! coupling variable for tr_iso
     298             :          dimension (nx,icepack_max_iso), public :: &
     299             :          fiso_atm  , & ! isotope deposition rate (kg/m^2 s)   
     300             :          fiso_evap     ! isotope evaporation rate (kg/m^2 s)   
     301             : 
     302             :       real (kind=dbl_kind), &
     303             :          dimension (nx,icepack_max_nbtrcr), public :: &
     304             :          flux_bio_atm  ! all bio fluxes to ice from atmosphere
     305             : 
     306             :       real (kind=dbl_kind), dimension (nx,icepack_max_iso), public :: &
     307             :          Qa_iso      , & ! isotope specific humidity (kg/kg)
     308             :          Qref_iso        ! 2m atm reference isotope spec humidity (kg/kg)
     309             : 
     310             :       ! out to ocean
     311             : 
     312             :       real (kind=dbl_kind), &
     313             :          dimension (nx,icepack_max_aero), public :: &
     314             :          faero_ocn   ! aerosol flux to ocean  (kg/m^2/s)
     315             : 
     316             :       real (kind=dbl_kind), &
     317             :          dimension (nx,icepack_max_iso), public :: &
     318             :          fiso_ocn    ! isotope flux to ocean  (kg/m^2/s)
     319             : 
     320             :       real (kind=dbl_kind), &
     321             :          dimension (nx,icepack_max_nbtrcr), public :: &
     322             :          flux_bio   , & ! all bio fluxes to ocean
     323             :          flux_bio_ai    ! all bio fluxes to ocean, averaged over grid cell
     324             : 
     325             :       real (kind=dbl_kind), dimension (nx), public :: &
     326             :          fzsal_ai, & ! salt flux to ocean from zsalinity (kg/m^2/s) 
     327             :          fzsal_g_ai  ! gravity drainage salt flux to ocean (kg/m^2/s) 
     328             : 
     329             :       ! internal
     330             : 
     331             :       logical (kind=log_kind), public :: &
     332             :          cpl_bgc         ! switch to couple BGC via drivers
     333             : 
     334             :       real (kind=dbl_kind), dimension (nx,ncat), public :: &
     335             :          hin_old     , & ! old ice thickness
     336             :          dsnown          ! change in snow thickness in category n (m)
     337             : 
     338             :       real (kind=dbl_kind), dimension (nx), public :: &
     339             :          nit        , & ! ocean nitrate (mmol/m^3)          
     340             :          amm        , & ! ammonia/um (mmol/m^3)
     341             :          sil        , & ! silicate (mmol/m^3)
     342             :          dmsp       , & ! dmsp (mmol/m^3)
     343             :          dms        , & ! dms (mmol/m^3)
     344             :          hum        , & ! humic material carbon (mmol/m^3)
     345             :          fnit       , & ! ice-ocean nitrate flux (mmol/m^2/s), positive to ocean
     346             :          famm       , & ! ice-ocean ammonia/um flux (mmol/m^2/s), positive to ocean
     347             :          fsil       , & ! ice-ocean silicate flux (mmol/m^2/s), positive to ocean
     348             :          fdmsp      , & ! ice-ocean dmsp (mmol/m^2/s), positive to ocean
     349             :          fdms       , & ! ice-ocean dms (mmol/m^2/s), positive to ocean
     350             :          fhum       , & ! ice-ocean humic material carbon (mmol/m^2/s), positive to ocean
     351             :          fdust          ! ice-ocean dust flux (kg/m^2/s), positive to ocean
     352             : 
     353             :       real (kind=dbl_kind), dimension (nx,icepack_max_algae), public :: &
     354             :          algalN     , & ! ocean algal nitrogen (mmol/m^3) (diatoms, pico, phaeo)
     355             :          falgalN        ! ice-ocean algal nitrogen flux (mmol/m^2/s) (diatoms, pico, phaeo)
     356             : 
     357             :       real (kind=dbl_kind), dimension (nx,icepack_max_doc), public :: &
     358             :          doc         , & ! ocean doc (mmol/m^3)  (saccharids, lipids, tbd )
     359             :          fdoc            ! ice-ocean doc flux (mmol/m^2/s)  (saccharids, lipids, tbd)
     360             : 
     361             :       real (kind=dbl_kind), dimension (nx,icepack_max_don), public :: &
     362             :          don         , & ! ocean don (mmol/m^3) (proteins and amino acids)
     363             :          fdon            ! ice-ocean don flux (mmol/m^2/s) (proteins and amino acids)
     364             : 
     365             :       real (kind=dbl_kind), dimension (nx,icepack_max_dic), public :: &
     366             :          dic         , & ! ocean dic (mmol/m^3) 
     367             :          fdic            ! ice-ocean dic flux (mmol/m^2/s) 
     368             : 
     369             :       real (kind=dbl_kind), dimension (nx,icepack_max_fe), public :: &
     370             :          fed, fep    , & ! ocean dissolved and particulate fe (nM) 
     371             :          ffed, ffep      ! ice-ocean dissolved and particulate fe flux (umol/m^2/s) 
     372             : 
     373             :       real (kind=dbl_kind), dimension (nx,icepack_max_aero), public :: &
     374             :          zaeros          ! ocean aerosols (mmol/m^3) 
     375             : 
     376             : !=======================================================================
     377             : 
     378             :       contains
     379             : 
     380             : !=======================================================================
     381             : 
     382             : ! Initialize all fluxes exchanged with flux coupler
     383             : ! and some data-derived fields
     384             : !
     385             : ! author Elizabeth C. Hunke, LANL
     386             : 
     387          45 :       subroutine init_coupler_flux
     388             : 
     389             :       use icedrv_arrays_column, only: Cdn_atm
     390             :       use icepack_intfc, only: icepack_liquidus_temperature
     391             : 
     392             :       integer (kind=int_kind) :: n
     393             : 
     394             :       real (kind=dbl_kind) :: fcondtopn_d(6), fsurfn_d(6)
     395          16 :       real (kind=dbl_kind) :: stefan_boltzmann, Tffresh
     396          32 :       real (kind=dbl_kind) :: vonkar, zref, iceruf
     397             : 
     398             :       integer :: i
     399             : 
     400             :       data fcondtopn_d / -50.0_dbl_kind,-17.0_dbl_kind,-12.0_dbl_kind, &
     401             :                           -9.0_dbl_kind, -7.0_dbl_kind, -3.0_dbl_kind /
     402             :       data fsurfn_d    /  0.20_dbl_kind, 0.15_dbl_kind, 0.10_dbl_kind, &
     403             :                           0.05_dbl_kind, 0.01_dbl_kind, 0.01_dbl_kind /
     404             : 
     405             :       character(len=*), parameter :: subname='(init_coupler_flux)'
     406             : 
     407             :       !-----------------------------------------------------------------
     408             :       ! query Icepack values
     409             :       !-----------------------------------------------------------------
     410             : 
     411             :       call icepack_query_parameters(stefan_boltzmann_out=stefan_boltzmann, &
     412          45 :         Tffresh_out=Tffresh, vonkar_out=vonkar, zref_out=zref, iceruf_out=iceruf)
     413          45 :       call icepack_warnings_flush(nu_diag)
     414          45 :       if (icepack_warnings_aborted()) call icedrv_system_abort(string=subname, &
     415           0 :           file=__FILE__,line= __LINE__)
     416             : 
     417             :       !-----------------------------------------------------------------
     418             :       ! fluxes received from atmosphere
     419             :       !-----------------------------------------------------------------
     420         225 :       zlvl  (:) = c10                ! atm level height (m)
     421         225 :       rhoa  (:) = 1.3_dbl_kind       ! air density (kg/m^3)
     422         225 :       uatm  (:) = c5                 ! wind velocity    (m/s)
     423         225 :       vatm  (:) = c5
     424         225 :       strax (:) = 0.05_dbl_kind
     425         225 :       stray (:) = 0.05_dbl_kind
     426          45 :       fsnow (:) = c0                 ! snowfall rate (kg/m2/s)
     427             :                                      ! fsnow must be 0 for exact restarts
     428          45 :       if (trim(default_season) == 'winter') then
     429             :          ! typical winter values
     430          15 :          potT  (:) = 253.0_dbl_kind  ! air potential temp (K)
     431          15 :          Tair  (:) = 253.0_dbl_kind  ! air temperature  (K)
     432          15 :          Qa    (:) = 0.0006_dbl_kind ! specific humidity (kg/kg)
     433           3 :          swvdr (:) = c0              ! shortwave radiation (W/m^2)
     434           3 :          swvdf (:) = c0              ! shortwave radiation (W/m^2)
     435           3 :          swidr (:) = c0              ! shortwave radiation (W/m^2)
     436           3 :          swidf (:) = c0              ! shortwave radiation (W/m^2)
     437          15 :          flw   (:) = c180            ! incoming longwave rad (W/m^2)
     438           3 :          frain (:) = c0              ! rainfall rate (kg/m2/s)
     439           6 :          do n = 1, ncat              ! conductive heat flux (W/m^2)
     440          18 :             fcondtopn_f(:,n) = fcondtopn_d(n)
     441             :          enddo
     442           3 :          fsurfn_f = fcondtopn_f      ! surface heat flux (W/m^2)
     443           3 :          flatn_f (:,:) = c0          ! latent heat flux (kg/m2/s)
     444           3 :          fsensn_f(:,:) = c0          ! sensible heat flux (W/m^2)
     445          42 :       elseif (trim(default_season) == 'summer') then
     446             :          ! typical summer values
     447          15 :          potT  (:) = 273.0_dbl_kind  ! air potential temp (K)
     448          15 :          Tair  (:) = 273.0_dbl_kind  ! air temperature  (K)
     449          15 :          Qa    (:) = 0.0035_dbl_kind ! specific humidity (kg/kg)
     450          15 :          swvdr (:) = 50._dbl_kind    ! shortwave radiation (W/m^2)
     451          15 :          swvdf (:) = 50._dbl_kind    ! shortwave radiation (W/m^2)
     452          15 :          swidr (:) = 50._dbl_kind    ! shortwave radiation (W/m^2)
     453          15 :          swidf (:) = 50._dbl_kind    ! shortwave radiation (W/m^2)
     454          15 :          flw   (:) = 280.0_dbl_kind  ! incoming longwave rad (W/m^2)
     455           3 :          frain (:) = c0              ! rainfall rate (kg/m2/s)
     456          18 :          do n = 1, ncat                   ! surface heat flux (W/m^2)
     457          78 :             fsurfn_f(:,n) = fsurfn_d(n)
     458             :          enddo
     459           3 :          fcondtopn_f(:,:) =  0.0_dbl_kind ! conductive heat flux (W/m^2)
     460          78 :          flatn_f    (:,:) = -2.0_dbl_kind ! latent heat flux (W/m^2)
     461           3 :          fsensn_f   (:,:) =  c0           ! sensible heat flux (W/m^2)
     462             :       else
     463             :          ! typical spring values
     464         195 :          potT  (:) = 263.15_dbl_kind ! air potential temp (K)
     465         195 :          Tair  (:) = 263.15_dbl_kind ! air temperature  (K)
     466         195 :          Qa    (:) = 0.001_dbl_kind  ! specific humidity (kg/kg)
     467         195 :          swvdr (:) = 25._dbl_kind    ! shortwave radiation (W/m^2)
     468         195 :          swvdf (:) = 25._dbl_kind    ! shortwave radiation (W/m^2)
     469         195 :          swidr (:) = 25._dbl_kind    ! shortwave radiation (W/m^2)
     470         195 :          swidf (:) = 25._dbl_kind    ! shortwave radiation (W/m^2)
     471         195 :          flw   (:) = 230.0_dbl_kind  ! incoming longwave rad (W/m^2)
     472          39 :          frain (:) = c0              ! rainfall rate (kg/m2/s)
     473         234 :          do n = 1, ncat                   ! surface heat flux (W/m^2)
     474        1014 :             fsurfn_f(:,n) = fsurfn_d(n)
     475             :          enddo
     476          39 :          fcondtopn_f(:,:) =  c0           ! conductive heat flux (W/m^2)
     477        1014 :          flatn_f    (:,:) = -1.0_dbl_kind ! latent heat flux (W/m^2)
     478          39 :          fsensn_f   (:,:) =  c0           ! sensible heat flux (W/m^2)
     479             :       endif !     l_winter
     480             : 
     481          45 :       fiso_atm     (:,:) = c0        ! isotope deposition rate (kg/m2/s)
     482          45 :       fiso_evap    (:,:) = c0        ! isotope evaporation rate (kg/m2/s)
     483          45 :       faero_atm    (:,:) = c0        ! aerosol deposition rate (kg/m2/s)
     484          45 :       flux_bio_atm (:,:) = c0        ! zaero and bio deposition rate (kg/m2/s)
     485             : 
     486             :       !-----------------------------------------------------------------
     487             :       ! fluxes received from ocean
     488             :       !-----------------------------------------------------------------
     489             : 
     490          45 :       uocn   (:) = c0              ! surface ocean currents (m/s)
     491          45 :       vocn   (:) = c0
     492          45 :       frzmlt (:) = c0              ! freezing/melting potential (W/m^2)
     493         225 :       sss    (:) = 34.0_dbl_kind   ! sea surface salinity (ppt)
     494         225 :       sst    (:) = -1.8_dbl_kind   ! sea surface temperature (C)
     495          45 :       sstdat (:) = sst(:)          ! sea surface temperature (C)
     496             : 
     497             :       ! water isotopes from ocean
     498          45 :       HDO_ocn   (:) = c0
     499          45 :       H2_16O_ocn(:) = c0
     500          45 :       H2_18O_ocn(:) = c0
     501             : 
     502         225 :       do i = 1, nx
     503         225 :          Tf (i) = icepack_liquidus_temperature(sss(i)) ! freezing temp (C)
     504             :       enddo
     505          45 :       call icepack_warnings_flush(nu_diag)
     506          45 :       if (icepack_warnings_aborted()) call icedrv_system_abort(string=subname, &
     507           0 :           file=__FILE__,line= __LINE__)
     508             : 
     509          45 :       qdp     (:) = c0             ! deep ocean heat flux (W/m^2)
     510         225 :       hmix    (:) = c20            ! ocean mixed layer depth
     511             : 
     512             :       !-----------------------------------------------------------------
     513             :       ! fluxes sent to atmosphere
     514             :       !-----------------------------------------------------------------
     515             : 
     516          45 :       strairxT(:) = c0            ! wind stress, T grid
     517          45 :       strairyT(:) = c0
     518             : 
     519          45 :       fsens   (:) = c0
     520          45 :       flat    (:) = c0
     521          45 :       fswabs  (:) = c0
     522         225 :       flwout  (:) = -stefan_boltzmann*Tffresh**4   
     523             :                      ! in case atm model diagnoses Tsfc from flwout
     524          45 :       evap    (:) = c0
     525          45 :       evaps   (:) = c0
     526          45 :       evapi   (:) = c0
     527          45 :       Tref    (:) = c0
     528          45 :       Qref    (:) = c0
     529          45 :       Uref    (:) = c0
     530          45 :       alvdr   (:) = c0
     531          45 :       alidr   (:) = c0
     532          45 :       alvdf   (:) = c0
     533          45 :       alidf   (:) = c0
     534             : 
     535             :       !-----------------------------------------------------------------
     536             :       ! fluxes sent to ocean
     537             :       !-----------------------------------------------------------------
     538             : 
     539          45 :       strocnxT(:) = c0    ! ice-ocean stress, x-direction (T-cell)
     540          45 :       strocnyT(:) = c0    ! ice-ocean stress, y-direction (T-cell)
     541          45 :       fresh   (:) = c0
     542          45 :       fsalt   (:) = c0
     543          45 :       fhocn   (:) = c0
     544          45 :       fswthru (:) = c0
     545          45 :       fswthru_vdr (:) = c0
     546          45 :       fswthru_vdf (:) = c0
     547          45 :       fswthru_idr (:) = c0
     548          45 :       fswthru_idf (:) = c0
     549          45 :       flux_bio(:,:) = c0 ! bgc
     550          45 :       fnit    (:) = c0
     551          45 :       fsil    (:) = c0
     552          45 :       famm    (:) = c0
     553          45 :       fdmsp   (:) = c0
     554          45 :       fdms    (:) = c0
     555          45 :       fhum    (:) = c0
     556          45 :       fdust   (:) = c0
     557          45 :       falgalN(:,:)= c0
     558          45 :       fdoc   (:,:)= c0
     559          45 :       fdic   (:,:)= c0
     560          45 :       fdon   (:,:)= c0
     561          45 :       ffep   (:,:)= c0
     562          45 :       ffed   (:,:)= c0
     563             :       
     564             :       !-----------------------------------------------------------------
     565             :       ! derived or computed fields
     566             :       !-----------------------------------------------------------------
     567             : 
     568          45 :       coszen  (:) = c0            ! Cosine of the zenith angle
     569             : !      fsw     (:) = c0            ! shortwave radiation (W/m^2)
     570         225 :       fsw     (:) = swvdr(:) + swvdf(:) + swidr(:) + swidf(:)
     571         225 :       scale_factor(:) = c1        ! shortwave scaling factor 
     572         225 :       wind    (:) = sqrt(uatm(:)**2 + vatm(:)**2)  ! wind speed, (m/s)
     573             :       Cdn_atm(:) = (vonkar/log(zref/iceruf)) &
     574         225 :                  * (vonkar/log(zref/iceruf)) ! atmo drag for RASM
     575             : 
     576          45 :       end subroutine init_coupler_flux
     577             : 
     578             : !=======================================================================
     579             : 
     580             : ! Initialize some fluxes sent to coupler for use by the atm and ocean models
     581             : !
     582             : ! author: Elizabeth C. Hunke, LANL
     583             : 
     584      342540 :       subroutine init_flux_atm_ocn
     585             :       character(len=*), parameter :: subname='(init_flux_atm_ocn)'
     586             : 
     587             :       !-----------------------------------------------------------------
     588             :       ! initialize albedo and atmosphere fluxes
     589             :       !-----------------------------------------------------------------
     590             : 
     591      342540 :       strairxT(:) = c0      ! wind stress, T grid
     592      342540 :       strairyT(:) = c0
     593      342540 :       fsens   (:) = c0
     594      342540 :       flat    (:) = c0
     595      342540 :       fswabs  (:) = c0
     596      342540 :       flwout  (:) = c0
     597      342540 :       evap    (:) = c0
     598      342540 :       evaps   (:) = c0
     599      342540 :       evapi   (:) = c0
     600      342540 :       Tref    (:) = c0
     601      342540 :       Qref    (:) = c0
     602      342540 :       Uref    (:) = c0
     603      342540 :       fiso_evap(:,:) = c0   ! isotope evaporation rate (kg/m2/s)
     604             : 
     605             :       !-----------------------------------------------------------------
     606             :       ! fluxes sent to ocean
     607             :       !-----------------------------------------------------------------
     608             : 
     609      342540 :       fresh    (:)   = c0
     610      342540 :       fsalt    (:)   = c0
     611      342540 :       fhocn    (:)   = c0
     612      342540 :       fswthru  (:)   = c0
     613      342540 :       fswthru_vdr  (:)   = c0
     614      342540 :       fswthru_vdf  (:)   = c0
     615      342540 :       fswthru_idr  (:)   = c0
     616      342540 :       fswthru_idf  (:)   = c0
     617      342540 :       fiso_ocn (:,:) = c0
     618      342540 :       faero_ocn(:,:) = c0
     619             : 
     620      342540 :       end subroutine init_flux_atm_ocn
     621             : 
     622             : !=======================================================================
     623             : 
     624             : ! Initialize thermodynamic fields written to history files.
     625             : !
     626             : ! authors: William H. Lipscomb, LANL
     627             : !          Elizabeth C. Hunke, LANL
     628             : 
     629      342585 :       subroutine init_history_therm
     630             : 
     631             :       use icedrv_state, only: aice, vice, trcr
     632             :       use icedrv_arrays_column, only: hfreebd, hdraft, hridge, distrdg
     633             :       use icedrv_arrays_column, only: hkeel, dkeel, lfloe, dfloe
     634             :       use icedrv_arrays_column, only: Cdn_atm_skin, Cdn_atm_floe
     635             :       use icedrv_arrays_column, only: Cdn_atm_pond, Cdn_atm_rdg
     636             :       use icedrv_arrays_column, only: Cdn_ocn_skin, Cdn_ocn_floe
     637             :       use icedrv_arrays_column, only: Cdn_ocn_keel, Cdn_atm_ratio
     638             :       use icedrv_arrays_column, only: Cdn_atm, Cdn_ocn
     639             : 
     640             :       logical (kind=log_kind) :: formdrag, tr_iage
     641             :       integer (kind=int_kind) :: nt_iage
     642      118588 :       real (kind=dbl_kind) :: vonkar, zref, iceruf
     643      118588 :       real (kind=dbl_kind) :: dragio
     644             :       character(len=*), parameter :: subname='(init_history_therm)'
     645             : 
     646             :       !-----------------------------------------------------------------
     647             :       ! query Icepack values
     648             :       !-----------------------------------------------------------------
     649             : 
     650      342585 :       call icepack_query_parameters(formdrag_out=formdrag)
     651      342585 :       call icepack_query_tracer_flags(tr_iage_out=tr_iage)
     652      342585 :       call icepack_query_tracer_indices(nt_iage_out=nt_iage)
     653             :       call icepack_query_parameters(dragio_out=dragio, &
     654      342585 :            vonkar_out=vonkar, zref_out=zref, iceruf_out=iceruf)
     655             : 
     656      342585 :       call icepack_warnings_flush(nu_diag)
     657      342585 :       if (icepack_warnings_aborted()) call icedrv_system_abort(string=subname, &
     658           0 :           file=__FILE__,line= __LINE__)
     659             : 
     660             :       !-----------------------------------------------------------------
     661             : 
     662      342585 :       fsurf  (:) = c0
     663      342585 :       fcondtop(:)= c0
     664      342585 :       fcondbot(:)= c0
     665      342585 :       congel (:) = c0
     666      342585 :       frazil (:) = c0
     667      342585 :       snoice (:) = c0
     668      342585 :       dsnow  (:) = c0
     669      342585 :       meltt  (:) = c0
     670      342585 :       melts  (:) = c0
     671      342585 :       meltb  (:) = c0
     672      342585 :       meltl  (:) = c0
     673      342585 :       daidtt (:) = aice(:) ! temporary initial area
     674      342585 :       dvidtt (:) = vice(:) ! temporary initial volume
     675      342585 :       if (tr_iage) then
     676       76870 :          dagedtt(:) = trcr(:,nt_iage) ! temporary initial age
     677             :       else
     678      327211 :          dagedtt(:) = c0
     679             :       endif
     680      342585 :       fsurfn    (:,:) = c0
     681      342585 :       fcondtopn (:,:) = c0
     682      342585 :       fcondbotn (:,:) = c0
     683      342585 :       flatn     (:,:) = c0
     684      342585 :       fsensn    (:,:) = c0
     685      342585 :       fpond     (:) = c0
     686      342585 :       fresh_ai  (:) = c0
     687      342585 :       fsalt_ai  (:) = c0
     688      342585 :       fhocn_ai  (:) = c0
     689      342585 :       fswthru_ai(:) = c0
     690      342585 :       albice (:) = c0
     691      342585 :       albsno (:) = c0
     692      342585 :       albpnd (:) = c0
     693      342585 :       apeff_ai (:) = c0
     694      342585 :       snowfrac (:) = c0
     695      342585 :       frazil_diag (:) = c0
     696             : 
     697             :       ! drag coefficients are computed prior to the atmo_boundary call, 
     698             :       ! during the thermodynamics section 
     699     1712925 :       Cdn_ocn(:) = dragio
     700             :       Cdn_atm(:) = (vonkar/log(zref/iceruf)) &
     701     1712925 :                  * (vonkar/log(zref/iceruf)) ! atmo drag for RASM
     702             : 
     703      342585 :       if (formdrag) then
     704       24135 :         Cdn_atm_rdg (:) = c0
     705       24135 :         Cdn_atm_ratio(:)= c0
     706       24135 :         Cdn_atm_floe(:) = c0
     707       24135 :         Cdn_atm_pond(:) = c0
     708       24135 :         Cdn_atm_skin(:) = c0
     709       24135 :         Cdn_ocn_skin(:) = c0
     710       24135 :         Cdn_ocn_keel(:) = c0
     711       24135 :         Cdn_ocn_floe(:) = c0
     712       24135 :         hfreebd     (:) = c0
     713       24135 :         hdraft      (:) = c0
     714       24135 :         hridge      (:) = c0
     715       24135 :         distrdg     (:) = c0
     716       24135 :         hkeel       (:) = c0
     717       24135 :         dkeel       (:) = c0
     718       24135 :         lfloe       (:) = c0
     719       24135 :         dfloe       (:) = c0
     720             :       endif
     721             : 
     722      342585 :       end subroutine init_history_therm
     723             : 
     724             : !=======================================================================
     725             : 
     726             : ! Initialize dynamic fields written to history files.
     727             : !
     728             : ! authors: William H. Lipscomb, LANL
     729             : !          Elizabeth C. Hunke, LANL
     730             : 
     731      342540 :       subroutine init_history_dyn
     732             : 
     733             :       use icedrv_state, only: aice, vice, trcr
     734             :       logical (kind=log_kind) :: tr_iage
     735             :       integer (kind=int_kind) :: nt_iage
     736             :       character(len=*), parameter :: subname='(init_history_dyn)'
     737             : 
     738             :       !-----------------------------------------------------------------
     739             :       ! query Icepack values
     740             :       !-----------------------------------------------------------------
     741             : 
     742      342540 :       call icepack_query_tracer_flags(tr_iage_out=tr_iage)
     743      342540 :       call icepack_query_tracer_indices(nt_iage_out=nt_iage)
     744      342540 :       call icepack_warnings_flush(nu_diag)
     745      342540 :       if (icepack_warnings_aborted()) call icedrv_system_abort(string=subname, &
     746           0 :           file=__FILE__,line= __LINE__)
     747             : 
     748             :       !-----------------------------------------------------------------
     749             : 
     750      342540 :       dardg1dt(:) = c0
     751      342540 :       dardg2dt(:) = c0
     752      342540 :       dvirdgdt(:) = c0
     753      342540 :       daidtd  (:) = aice(:) ! temporary initial area
     754      342540 :       dvidtd  (:) = vice(:) ! temporary initial volume
     755      342540 :       if (tr_iage) &
     756       76860 :          dagedtd (:) = trcr(:,nt_iage) ! temporary initial age
     757      342540 :       ardgn   (:,:) = c0
     758      342540 :       vrdgn   (:,:) = c0
     759     8423400 :       krdgn   (:,:) = c1
     760      342540 :       aparticn(:,:) = c0
     761      342540 :       aredistn(:,:) = c0
     762      342540 :       vredistn(:,:) = c0
     763      342540 :       dardg1ndt(:,:) = c0
     764      342540 :       dardg2ndt(:,:) = c0
     765      342540 :       dvirdgndt(:,:) = c0
     766      342540 :       araftn   (:,:) = c0
     767      342540 :       vraftn   (:,:) = c0
     768      342540 :       aredistn (:,:) = c0
     769      342540 :       vredistn (:,:) = c0
     770             : 
     771      342540 :       end subroutine init_history_dyn
     772             : 
     773             : !=======================================================================
     774             : 
     775             : ! Initialize bgc fields written to history files
     776             : !
     777             : ! authors: Nicole Jeffery, LANL
     778             : 
     779      342540 :       subroutine init_history_bgc
     780             : 
     781             :       use icedrv_arrays_column, only: PP_net, grow_net, hbri
     782             :       use icedrv_arrays_column, only: ice_bio_net, snow_bio_net, fbio_snoice, fbio_atmice
     783             :       use icedrv_arrays_column, only: fzsal, fzsal_g, zfswin 
     784             :       character(len=*), parameter :: subname='(init_history_bgc)'
     785             : 
     786      342540 :       PP_net        (:) = c0
     787      342540 :       grow_net      (:) = c0
     788      342540 :       hbri          (:) = c0
     789      342540 :       flux_bio    (:,:) = c0
     790      342540 :       flux_bio_ai (:,:) = c0
     791      342540 :       ice_bio_net (:,:) = c0
     792      342540 :       snow_bio_net(:,:) = c0
     793      342540 :       fbio_snoice (:,:) = c0
     794      342540 :       fbio_atmice (:,:) = c0
     795      342540 :       fzsal         (:) = c0
     796      342540 :       fzsal_g       (:) = c0
     797      342540 :       zfswin    (:,:,:) = c0
     798      342540 :       fnit          (:) = c0
     799      342540 :       fsil          (:) = c0
     800      342540 :       famm          (:) = c0
     801      342540 :       fdmsp         (:) = c0
     802      342540 :       fdms          (:) = c0
     803      342540 :       fhum          (:) = c0
     804      342540 :       fdust         (:) = c0
     805      342540 :       falgalN     (:,:) = c0
     806      342540 :       fdoc        (:,:) = c0
     807      342540 :       fdic        (:,:) = c0
     808      342540 :       fdon        (:,:) = c0
     809      342540 :       ffep        (:,:) = c0
     810      342540 :       ffed        (:,:) = c0
     811             : 
     812      342540 :       end subroutine init_history_bgc
     813             : 
     814             : !=======================================================================
     815             : 
     816             :       end module icedrv_flux
     817             : 
     818             : !=======================================================================

Generated by: LCOV version 1.14-6-g40580cd