LCOV - code coverage report
Current view: top level - configuration/driver - icedrv_flux.F90 (source / functions) Coverage Total Hit
Test: 250115-224328:3d8b76b919:4:base,io,travis,quick Lines: 98.46 % 259 255
Test Date: 2025-01-15 16:24:29 Functions: 100.00 % 5 5

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

Generated by: LCOV version 2.0-1