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

          Line data    Source code
       1             : !=======================================================================
       2             : 
       3             : ! parameter and variable initializations
       4             : !
       5             : ! authors Elizabeth C. Hunke and William H. Lipscomb, LANL
       6             : !         C. M. Bitz, UW
       7             : !
       8             : ! 2004 WHL: Block structure added
       9             : ! 2006 ECH: Added namelist variables, warnings.
      10             : !           Replaced old default initial ice conditions with 3.14 version.
      11             : !           Converted to free source form (F90).
      12             : 
      13             :       module ice_init
      14             : 
      15             :       use ice_kinds_mod
      16             :       use ice_communicate, only: my_task, master_task, ice_barrier
      17             :       use ice_constants, only: c0, c1, c2, c3, c5, c12, p01, p2, p3, p5, p75, p166, &
      18             :           cm_to_m
      19             :       use ice_exit, only: abort_ice
      20             :       use ice_fileunits, only: nu_nml, nu_diag, nml_filename, diag_type, &
      21             :           ice_stdout, get_fileunit, release_fileunit, bfbflag, flush_fileunit, &   ! LCOV_EXCL_LINE
      22             :           ice_IOUnitsMinUnit, ice_IOUnitsMaxUnit
      23             : #ifdef CESMCOUPLED
      24             :       use ice_fileunits, only: inst_suffix, nu_diag_set
      25             : #endif
      26             :       use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
      27             :       use icepack_intfc, only: icepack_aggregate
      28             :       use icepack_intfc, only: icepack_init_trcr
      29             :       use icepack_intfc, only: icepack_init_parameters
      30             :       use icepack_intfc, only: icepack_init_tracer_flags
      31             :       use icepack_intfc, only: icepack_init_tracer_sizes
      32             :       use icepack_intfc, only: icepack_query_tracer_flags
      33             :       use icepack_intfc, only: icepack_query_tracer_sizes
      34             :       use icepack_intfc, only: icepack_query_tracer_indices
      35             :       use icepack_intfc, only: icepack_query_parameters
      36             : 
      37             :       implicit none
      38             :       private
      39             : 
      40             :       character(len=char_len_long), public :: &
      41             :          ice_ic      ! method of ice cover initialization
      42             :                      ! 'internal' => set from ice_data_ namelist
      43             :                      ! 'none'     => no ice
      44             :                      ! filename   => read file
      45             : 
      46             :       public :: input_data, init_state, set_state_var
      47             : 
      48             : !=======================================================================
      49             : 
      50             :       contains
      51             : 
      52             : !=======================================================================
      53             : 
      54             : ! Namelist variables, set to default values; may be altered
      55             : ! at run time
      56             : !
      57             : ! author Elizabeth C. Hunke, LANL
      58             : 
      59          37 :       subroutine input_data
      60             : 
      61             :       use ice_broadcast, only: broadcast_scalar, broadcast_array
      62             :       use ice_diagnostics, only: diag_file, print_global, print_points, latpnt, lonpnt, &
      63             :                                  debug_model, debug_model_step, debug_model_task, &   ! LCOV_EXCL_LINE
      64             :                                  debug_model_i, debug_model_j, debug_model_iblk
      65             :       use ice_domain, only: close_boundaries, orca_halogrid
      66             :       use ice_domain_size, only: ncat, nilyr, nslyr, nblyr, nfsd, nfreq, &
      67             :                                  n_iso, n_aero, n_zaero, n_algae, &   ! LCOV_EXCL_LINE
      68             :                                  n_doc, n_dic, n_don, n_fed, n_fep, &   ! LCOV_EXCL_LINE
      69             :                                  max_nstrm
      70             :       use ice_calendar, only: year_init, month_init, day_init, sec_init, &
      71             :                               istep0, histfreq, histfreq_n, histfreq_base, &   ! LCOV_EXCL_LINE
      72             :                               dumpfreq, dumpfreq_n, diagfreq, dumpfreq_base, &   ! LCOV_EXCL_LINE
      73             :                               npt, dt, ndtd, days_per_year, use_leap_years, &   ! LCOV_EXCL_LINE
      74             :                               write_ic, dump_last, npt_unit
      75             :       use ice_arrays_column, only: oceanmixed_ice
      76             :       use ice_restart_column, only: restart_age, restart_FY, restart_lvl, &
      77             :           restart_pond_lvl, restart_pond_topo, restart_aero, &   ! LCOV_EXCL_LINE
      78             :           restart_fsd, restart_iso, restart_snow
      79             :       use ice_restart_shared, only: &
      80             :           restart, restart_ext, restart_coszen, restart_dir, restart_file, pointer_file, &   ! LCOV_EXCL_LINE
      81             :           runid, runtype, use_restart_time, restart_format, lcdf64
      82             :       use ice_history_shared, only: hist_avg, history_dir, history_file, &
      83             :                              incond_dir, incond_file, version_name, &   ! LCOV_EXCL_LINE
      84             :                              history_precision, history_format, hist_time_axis
      85             :       use ice_flux, only: update_ocn_f, cpl_frazil, l_mpond_fresh
      86             :       use ice_flux, only: default_season
      87             :       use ice_flux_bgc, only: cpl_bgc
      88             :       use ice_forcing, only: &
      89             :           ycycle,          fyear_init,    debug_forcing, &   ! LCOV_EXCL_LINE
      90             :           atm_data_type,   atm_data_dir,  precip_units, rotate_wind, &   ! LCOV_EXCL_LINE
      91             :           atm_data_format, ocn_data_format, &   ! LCOV_EXCL_LINE
      92             :           bgc_data_type, &   ! LCOV_EXCL_LINE
      93             :           ocn_data_type, ocn_data_dir, wave_spec_file,  &   ! LCOV_EXCL_LINE
      94             :           oceanmixed_file, restore_ocn, trestore, &   ! LCOV_EXCL_LINE
      95             :           ice_data_type, ice_data_conc, ice_data_dist, &   ! LCOV_EXCL_LINE
      96             :           snw_filename, &   ! LCOV_EXCL_LINE
      97             :           snw_tau_fname, snw_kappa_fname, snw_drdt0_fname, &   ! LCOV_EXCL_LINE
      98             :           snw_rhos_fname, snw_Tgrd_fname, snw_T_fname
      99             :       use ice_arrays_column, only: bgc_data_dir, fe_data_type
     100             :       use ice_grid, only: grid_file, gridcpl_file, kmt_file, &
     101             :                           bathymetry_file, use_bathymetry, &   ! LCOV_EXCL_LINE
     102             :                           bathymetry_format, kmt_type, &   ! LCOV_EXCL_LINE
     103             :                           grid_type, grid_format, &   ! LCOV_EXCL_LINE
     104             :                           grid_ice, grid_ice_thrm, grid_ice_dynu, grid_ice_dynv, &   ! LCOV_EXCL_LINE
     105             :                           grid_ocn, grid_ocn_thrm, grid_ocn_dynu, grid_ocn_dynv, &   ! LCOV_EXCL_LINE
     106             :                           grid_atm, grid_atm_thrm, grid_atm_dynu, grid_atm_dynv, &   ! LCOV_EXCL_LINE
     107             :                           dxrect, dyrect, dxscale, dyscale, scale_dxdy, &   ! LCOV_EXCL_LINE
     108             :                           lonrefrect, latrefrect, pgl_global_ext
     109             :       use ice_dyn_shared, only: ndte, kdyn, revised_evp, yield_curve, &
     110             :                                 evp_algorithm, visc_method,     &   ! LCOV_EXCL_LINE
     111             :                                 seabed_stress, seabed_stress_method,  &   ! LCOV_EXCL_LINE
     112             :                                 k1, k2, alphab, threshold_hw, Ktens,  &   ! LCOV_EXCL_LINE
     113             :                                 e_yieldcurve, e_plasticpot, coriolis, &   ! LCOV_EXCL_LINE
     114             :                                 ssh_stress, kridge, brlx, arlx,       &   ! LCOV_EXCL_LINE
     115             :                                 deltaminEVP, deltaminVP, capping,     &   ! LCOV_EXCL_LINE
     116             :                                 elasticDamp
     117             : 
     118             :       use ice_dyn_vp, only: maxits_nonlin, precond, dim_fgmres, dim_pgmres, maxits_fgmres, &
     119             :                             maxits_pgmres, monitor_nonlin, monitor_fgmres, &   ! LCOV_EXCL_LINE
     120             :                             monitor_pgmres, reltol_nonlin, reltol_fgmres, reltol_pgmres, &   ! LCOV_EXCL_LINE
     121             :                             algo_nonlin, fpfunc_andacc, dim_andacc, reltol_andacc, &   ! LCOV_EXCL_LINE
     122             :                             damping_andacc, start_andacc, use_mean_vrel, ortho_type
     123             :       use ice_transport_driver, only: advection, conserv_check
     124             :       use ice_restoring, only: restore_ice
     125             :       use ice_timers, only: timer_stats
     126             :       use ice_memusage, only: memory_stats
     127             :       use ice_fileunits, only: goto_nml
     128             : 
     129             : #ifdef CESMCOUPLED
     130             :       use shr_file_mod, only: shr_file_setIO
     131             : #endif
     132             : 
     133             :       ! local variables
     134             : 
     135             :       integer (kind=int_kind) :: &
     136             :          nml_error, & ! namelist i/o error flag   ! LCOV_EXCL_LINE
     137             :          n            ! loop index
     138             : 
     139             : #ifdef CESMCOUPLED
     140             :       logical :: exists
     141             : #endif
     142             : 
     143           8 :       real (kind=dbl_kind) :: ustar_min, albicev, albicei, albsnowv, albsnowi, &
     144             :         ahmax, R_ice, R_pnd, R_snw, dT_mlt, rsnw_mlt, emissivity, hi_min, &   ! LCOV_EXCL_LINE
     145             :         mu_rdg, hs0, dpscale, rfracmin, rfracmax, pndaspect, hs1, hp1, &   ! LCOV_EXCL_LINE
     146             :         a_rapid_mode, Rac_rapid_mode, aspect_rapid_mode, dSdt_slow_mode, &   ! LCOV_EXCL_LINE
     147             :         phi_c_slow_mode, phi_i_mushy, kalg, atmiter_conv, Pstar, Cstar, &   ! LCOV_EXCL_LINE
     148             :         sw_frac, sw_dtemp, floediam, hfrazilmin, iceruf, iceruf_ocn, &   ! LCOV_EXCL_LINE
     149             :         rsnw_fall, rsnw_tmax, rhosnew, rhosmin, rhosmax, Tliquidus_max, &   ! LCOV_EXCL_LINE
     150           8 :         windmin, drhosdwind, snwlvlfac
     151             : 
     152             :       integer (kind=int_kind) :: ktherm, kstrength, krdg_partic, krdg_redist, natmiter, &
     153             :         kitd, kcatbound, ktransport
     154             : 
     155             :       character (len=char_len) :: shortwave, albedo_type, conduct, fbot_xfer_type, &
     156             :         tfrz_option, saltflux_option, frzpnd, atmbndy, wave_spec_type, snwredist, snw_aging_table, &   ! LCOV_EXCL_LINE
     157             :         capping_method, snw_ssp_table
     158             : 
     159             :       logical (kind=log_kind) :: calc_Tsfc, formdrag, highfreq, calc_strair, wave_spec, &
     160             :         sw_redist, calc_dragio, use_smliq_pnd, snwgrain
     161             : 
     162             :       logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_pond
     163             :       logical (kind=log_kind) :: tr_iso, tr_aero, tr_fsd, tr_snow
     164             :       logical (kind=log_kind) :: tr_pond_lvl, tr_pond_topo
     165             :       integer (kind=int_kind) :: numin, numax  ! unit number limits
     166             : 
     167             :       integer (kind=int_kind) :: rplvl, rptopo
     168           8 :       real (kind=dbl_kind)    :: Cf, ksno, puny, ice_ref_salinity, Tocnfrz
     169             : 
     170             :       character (len=char_len) :: abort_list
     171             :       character (len=char_len)      :: nml_name ! namelist name
     172             :       character (len=char_len_long) :: tmpstr2
     173             : 
     174             :       character(len=*), parameter :: subname='(input_data)'
     175             : 
     176             :       !-----------------------------------------------------------------
     177             :       ! Namelist variables
     178             :       !-----------------------------------------------------------------
     179             : 
     180             :       namelist /setup_nml/ &
     181             :         days_per_year,  use_leap_years, istep0,          npt_unit,      &   ! LCOV_EXCL_LINE
     182             :         dt,             npt,            ndtd,            numin,         &   ! LCOV_EXCL_LINE
     183             :         runtype,        runid,          bfbflag,         numax,         &   ! LCOV_EXCL_LINE
     184             :         ice_ic,         restart,        restart_dir,     restart_file,  &   ! LCOV_EXCL_LINE
     185             :         restart_ext,    use_restart_time, restart_format, lcdf64,       &   ! LCOV_EXCL_LINE
     186             :         pointer_file,   dumpfreq,       dumpfreq_n,      dump_last,     &   ! LCOV_EXCL_LINE
     187             :         diagfreq,       diag_type,      diag_file,       history_format,&   ! LCOV_EXCL_LINE
     188             :         hist_time_axis,                                                 &   ! LCOV_EXCL_LINE
     189             :         print_global,   print_points,   latpnt,          lonpnt,        &   ! LCOV_EXCL_LINE
     190             :         debug_forcing,  histfreq,       histfreq_n,      hist_avg,      &   ! LCOV_EXCL_LINE
     191             :         history_dir,    history_file,   history_precision, cpl_bgc,     &   ! LCOV_EXCL_LINE
     192             :         histfreq_base,  dumpfreq_base,  timer_stats,     memory_stats,  &   ! LCOV_EXCL_LINE
     193             :         conserv_check,  debug_model,    debug_model_step,               &   ! LCOV_EXCL_LINE
     194             :         debug_model_i,  debug_model_j,  debug_model_iblk, debug_model_task, &   ! LCOV_EXCL_LINE
     195             :         year_init,      month_init,     day_init,        sec_init,      &   ! LCOV_EXCL_LINE
     196             :         write_ic,       incond_dir,     incond_file,     version_name
     197             : 
     198             :       namelist /grid_nml/ &
     199             :         grid_format,    grid_type,       grid_file,     kmt_file,       &   ! LCOV_EXCL_LINE
     200             :         bathymetry_file, use_bathymetry, nfsd,          bathymetry_format, &   ! LCOV_EXCL_LINE
     201             :         ncat,           nilyr,           nslyr,         nblyr,          &   ! LCOV_EXCL_LINE
     202             :         kcatbound,      gridcpl_file,    dxrect,        dyrect,         &   ! LCOV_EXCL_LINE
     203             :         dxscale,        dyscale,         lonrefrect,    latrefrect,     &   ! LCOV_EXCL_LINE
     204             :         scale_dxdy,                                                     &   ! LCOV_EXCL_LINE
     205             :         close_boundaries, orca_halogrid, grid_ice,      kmt_type,       &   ! LCOV_EXCL_LINE
     206             :         grid_atm,       grid_ocn
     207             : 
     208             :       namelist /tracer_nml/                                             &
     209             :         tr_iage, restart_age,                                           &   ! LCOV_EXCL_LINE
     210             :         tr_FY, restart_FY,                                              &   ! LCOV_EXCL_LINE
     211             :         tr_lvl, restart_lvl,                                            &   ! LCOV_EXCL_LINE
     212             :         tr_pond_lvl, restart_pond_lvl,                                  &   ! LCOV_EXCL_LINE
     213             :         tr_pond_topo, restart_pond_topo,                                &   ! LCOV_EXCL_LINE
     214             :         tr_snow, restart_snow,                                          &   ! LCOV_EXCL_LINE
     215             :         tr_iso, restart_iso,                                            &   ! LCOV_EXCL_LINE
     216             :         tr_aero, restart_aero,                                          &   ! LCOV_EXCL_LINE
     217             :         tr_fsd, restart_fsd,                                            &   ! LCOV_EXCL_LINE
     218             :         n_iso, n_aero, n_zaero, n_algae,                                &   ! LCOV_EXCL_LINE
     219             :         n_doc, n_dic, n_don, n_fed, n_fep
     220             : 
     221             :       namelist /thermo_nml/ &
     222             :         kitd,           ktherm,          conduct,     ksno,             &   ! LCOV_EXCL_LINE
     223             :         a_rapid_mode,   Rac_rapid_mode,  aspect_rapid_mode,             &   ! LCOV_EXCL_LINE
     224             :         dSdt_slow_mode, phi_c_slow_mode, phi_i_mushy,                   &   ! LCOV_EXCL_LINE
     225             :         floediam,       hfrazilmin,      Tliquidus_max,   hi_min
     226             : 
     227             :       namelist /dynamics_nml/ &
     228             :         kdyn,           ndte,           revised_evp,    yield_curve,    &   ! LCOV_EXCL_LINE
     229             :         evp_algorithm,  elasticDamp,                                    &   ! LCOV_EXCL_LINE
     230             :         brlx,           arlx,           ssh_stress,                     &   ! LCOV_EXCL_LINE
     231             :         advection,      coriolis,       kridge,         ktransport,     &   ! LCOV_EXCL_LINE
     232             :         kstrength,      krdg_partic,    krdg_redist,    mu_rdg,         &   ! LCOV_EXCL_LINE
     233             :         e_yieldcurve,   e_plasticpot,   visc_method,              &   ! LCOV_EXCL_LINE
     234             :         maxits_nonlin,  precond,        dim_fgmres,                     &   ! LCOV_EXCL_LINE
     235             :         dim_pgmres,     maxits_fgmres,  maxits_pgmres,  monitor_nonlin, &   ! LCOV_EXCL_LINE
     236             :         monitor_fgmres, monitor_pgmres, reltol_nonlin,  reltol_fgmres,  &   ! LCOV_EXCL_LINE
     237             :         reltol_pgmres,  algo_nonlin,    dim_andacc,     reltol_andacc,  &   ! LCOV_EXCL_LINE
     238             :         damping_andacc, start_andacc,   fpfunc_andacc,  use_mean_vrel,  &   ! LCOV_EXCL_LINE
     239             :         ortho_type,     seabed_stress,  seabed_stress_method,           &   ! LCOV_EXCL_LINE
     240             :         k1, k2,         alphab,         threshold_hw,                   &   ! LCOV_EXCL_LINE
     241             :         deltaminEVP,    deltaminVP,     capping_method,                 &   ! LCOV_EXCL_LINE
     242             :         Cf,             Pstar,          Cstar,          Ktens
     243             : 
     244             :       namelist /shortwave_nml/ &
     245             :         shortwave,      albedo_type,     snw_ssp_table,                 &   ! LCOV_EXCL_LINE
     246             :         albicev,        albicei,         albsnowv,      albsnowi,       &   ! LCOV_EXCL_LINE
     247             :         ahmax,          R_ice,           R_pnd,         R_snw,          &   ! LCOV_EXCL_LINE
     248             :         sw_redist,      sw_frac,         sw_dtemp,                      &   ! LCOV_EXCL_LINE
     249             :         dT_mlt,         rsnw_mlt,        kalg
     250             : 
     251             :       namelist /ponds_nml/ &
     252             :         hs0,            dpscale,         frzpnd,                        &   ! LCOV_EXCL_LINE
     253             :         rfracmin,       rfracmax,        pndaspect,     hs1,            &   ! LCOV_EXCL_LINE
     254             :         hp1
     255             : 
     256             :       namelist /snow_nml/ &
     257             :         snwredist,      snwgrain,        rsnw_fall,     rsnw_tmax,      &   ! LCOV_EXCL_LINE
     258             :         rhosnew,        rhosmin,         rhosmax,       snwlvlfac,      &   ! LCOV_EXCL_LINE
     259             :         windmin,        drhosdwind,      use_smliq_pnd, snw_aging_table,&   ! LCOV_EXCL_LINE
     260             :         snw_filename,   snw_rhos_fname,  snw_Tgrd_fname,snw_T_fname,    &   ! LCOV_EXCL_LINE
     261             :         snw_tau_fname,  snw_kappa_fname, snw_drdt0_fname
     262             : 
     263             :       namelist /forcing_nml/ &
     264             :         formdrag,       atmbndy,         calc_strair,   calc_Tsfc,      &   ! LCOV_EXCL_LINE
     265             :         highfreq,       natmiter,        atmiter_conv,  calc_dragio,    &   ! LCOV_EXCL_LINE
     266             :         ustar_min,      emissivity,      iceruf,        iceruf_ocn,     &   ! LCOV_EXCL_LINE
     267             :         fbot_xfer_type, update_ocn_f,    l_mpond_fresh, tfrz_option,    &   ! LCOV_EXCL_LINE
     268             :         saltflux_option,ice_ref_salinity,cpl_frazil,                    &   ! LCOV_EXCL_LINE
     269             :         oceanmixed_ice, restore_ice,     restore_ocn,   trestore,       &   ! LCOV_EXCL_LINE
     270             :         precip_units,   default_season,  wave_spec_type,nfreq,          &   ! LCOV_EXCL_LINE
     271             :         atm_data_type,  ocn_data_type,   bgc_data_type, fe_data_type,   &   ! LCOV_EXCL_LINE
     272             :         ice_data_type,  ice_data_conc,   ice_data_dist,                 &   ! LCOV_EXCL_LINE
     273             :         fyear_init,     ycycle,          wave_spec_file,restart_coszen, &   ! LCOV_EXCL_LINE
     274             :         atm_data_dir,   ocn_data_dir,    bgc_data_dir,                  &   ! LCOV_EXCL_LINE
     275             :         atm_data_format, ocn_data_format, rotate_wind,                  &   ! LCOV_EXCL_LINE
     276             :         oceanmixed_file
     277             : 
     278             :       !-----------------------------------------------------------------
     279             :       ! default values
     280             :       !-----------------------------------------------------------------
     281             : 
     282          37 :       abort_list = ""
     283             : 
     284          37 :       call icepack_query_parameters(puny_out=puny,Tocnfrz_out=Tocnfrz)
     285             : ! nu_diag not yet defined
     286             : !      call icepack_warnings_flush(nu_diag)
     287             : !      if (icepack_warnings_aborted()) call abort_ice(error_message=subname//'Icepack Abort0', &
     288             : !         file=__FILE__, line=__LINE__)
     289             : 
     290          37 :       days_per_year = 365    ! number of days in a year
     291          37 :       use_leap_years= .false.! if true, use leap years (Feb 29)
     292          37 :       year_init = 0          ! initial year
     293          37 :       month_init = 1         ! initial month
     294          37 :       day_init = 1           ! initial day
     295          37 :       sec_init = 0           ! initial second
     296          37 :       istep0 = 0             ! no. of steps taken in previous integrations,
     297             :                              ! real (dumped) or imagined (to set calendar)
     298             : #ifndef CESMCOUPLED
     299          37 :       dt = 3600.0_dbl_kind   ! time step, s
     300             : #endif
     301          37 :       numin = 11             ! min allowed unit number
     302          37 :       numax = 99             ! max allowed unit number
     303          37 :       npt = 99999            ! total number of time steps (dt)
     304          37 :       npt_unit = '1'         ! units of npt 'y', 'm', 'd', 's', '1'
     305          37 :       diagfreq = 24          ! how often diag output is written
     306          37 :       debug_model  = .false. ! debug output
     307          37 :       debug_model_step = 0   ! debug model after this step number
     308          37 :       debug_model_i = -1     ! debug model local i index
     309          37 :       debug_model_j = -1     ! debug model local j index
     310          37 :       debug_model_iblk = -1  ! debug model local iblk number
     311          37 :       debug_model_task = -1  ! debug model local task number
     312          37 :       print_points = .false. ! if true, print point data
     313          37 :       print_global = .true.  ! if true, print global diagnostic data
     314          37 :       timer_stats = .false.  ! if true, print out detailed timer statistics
     315          37 :       memory_stats = .false. ! if true, print out memory information
     316          37 :       bfbflag = 'off'        ! off = optimized
     317          37 :       diag_type = 'stdout'
     318          37 :       diag_file = 'ice_diag.d'
     319          37 :       histfreq(1) = '1'      ! output frequency option for different streams
     320          37 :       histfreq(2) = 'h'      ! output frequency option for different streams
     321          37 :       histfreq(3) = 'd'      ! output frequency option for different streams
     322          37 :       histfreq(4) = 'm'      ! output frequency option for different streams
     323          37 :       histfreq(5) = 'y'      ! output frequency option for different streams
     324         222 :       histfreq_n(:) = 1      ! output frequency
     325         222 :       histfreq_base(:) = 'zero' ! output frequency reference date
     326         222 :       hist_avg(:) = .true.   ! if true, write time-averages (not snapshots)
     327          37 :       history_format = 'default' ! history file format
     328          37 :       hist_time_axis = 'end' ! History file time axis averaging interval position
     329             : 
     330          37 :       history_dir  = './'    ! write to executable dir for default
     331          37 :       history_file = 'iceh'  ! history file name prefix
     332          37 :       history_precision = 4  ! precision of history files
     333          37 :       write_ic = .false.     ! write out initial condition
     334          37 :       cpl_bgc = .false.      ! couple bgc thru driver
     335          37 :       incond_dir = history_dir ! write to history dir for default
     336          37 :       incond_file = 'iceh_ic'! file prefix
     337         222 :       dumpfreq(:)='x'           ! restart frequency option
     338         222 :       dumpfreq_n(:) = 1         ! restart frequency
     339         222 :       dumpfreq_base(:) = 'init' ! restart frequency reference date
     340          37 :       dumpfreq(1)='y'           ! restart frequency option
     341          37 :       dumpfreq_n(1) = 1         ! restart frequency
     342          37 :       dump_last = .false.    ! write restart on last time step
     343          37 :       restart_dir  = './'    ! write to executable dir for default
     344          37 :       restart_file = 'iced'  ! restart file name prefix
     345          37 :       restart_ext  = .false. ! if true, read/write ghost cells
     346          37 :       restart_coszen  = .false.   ! if true, read/write coszen
     347          37 :       pointer_file = 'ice.restart_file'
     348          37 :       restart_format = 'default'  ! restart file format
     349          37 :       lcdf64       = .false.      ! 64 bit offset for netCDF
     350          37 :       ice_ic       = 'default'    ! latitude and sst-dependent
     351          37 :       grid_format  = 'bin'        ! file format ('bin'=binary or 'nc'=netcdf)
     352          37 :       grid_type    = 'rectangular'! define rectangular grid internally
     353          37 :       grid_file    = 'unknown_grid_file'
     354          37 :       grid_ice     = 'B'          ! underlying grid system
     355          37 :       grid_atm     = 'A'          ! underlying atm forcing/coupling grid
     356          37 :       grid_ocn     = 'A'          ! underlying atm forcing/coupling grid
     357          37 :       gridcpl_file = 'unknown_gridcpl_file'
     358          37 :       orca_halogrid = .false.     ! orca haloed grid
     359          37 :       bathymetry_file   = 'unknown_bathymetry_file'
     360          37 :       bathymetry_format = 'default'
     361          37 :       use_bathymetry    = .false.
     362          37 :       kmt_type     = 'file'
     363          37 :       kmt_file     = 'unknown_kmt_file'
     364          37 :       version_name = 'unknown_version_name'
     365          37 :       ncat  = 0          ! number of ice thickness categories
     366          37 :       nfsd  = 1          ! number of floe size categories (1 = default)
     367          37 :       nilyr = 0          ! number of vertical ice layers
     368          37 :       nslyr = 0          ! number of vertical snow layers
     369          37 :       nblyr = 0          ! number of bio layers
     370             : 
     371          37 :       kitd = 1           ! type of itd conversions (0 = delta, 1 = linear)
     372          37 :       kcatbound = 1      ! category boundary formula (0 = old, 1 = new, etc)
     373          37 :       kdyn = 1           ! type of dynamics (-1, 0 = off, 1 = evp, 2 = eap, 3 = vp)
     374          37 :       ndtd = 1           ! dynamic time steps per thermodynamic time step
     375          37 :       ndte = 120         ! subcycles per dynamics timestep:  ndte=dt_dyn/dte
     376          37 :       evp_algorithm = 'standard_2d'  ! EVP kernel (standard_2d=standard cice evp; shared_mem_1d=1d shared memory and no mpi
     377          37 :       elasticDamp = 0.36_dbl_kind    ! coefficient for calculating the parameter E
     378          37 :       pgl_global_ext = .false.       ! if true, init primary grid lengths (global ext.)
     379          37 :       brlx   = 300.0_dbl_kind ! revised_evp values. Otherwise overwritten in ice_dyn_shared
     380          37 :       arlx   = 300.0_dbl_kind ! revised_evp values. Otherwise overwritten in ice_dyn_shared
     381          37 :       revised_evp = .false.   ! if true, use revised procedure for evp dynamics
     382          37 :       yield_curve = 'ellipse' ! yield curve
     383          37 :       kstrength = 1           ! 1 = Rothrock 75 strength, 0 = Hibler 79
     384          37 :       Pstar = 2.75e4_dbl_kind ! constant in Hibler strength formula (kstrength = 0)
     385          37 :       Cstar = 20._dbl_kind    ! constant in Hibler strength formula (kstrength = 0)
     386          37 :       krdg_partic = 1         ! 1 = new participation, 0 = Thorndike et al 75
     387          37 :       krdg_redist = 1         ! 1 = new redistribution, 0 = Hibler 80
     388          37 :       mu_rdg = 3              ! e-folding scale of ridged ice, krdg_partic=1 (m^0.5)
     389          37 :       Cf = 17.0_dbl_kind      ! ratio of ridging work to PE change in ridging
     390          37 :       ksno = 0.3_dbl_kind     ! snow thermal conductivity
     391          37 :       dxrect = 0.0_dbl_kind   ! user defined grid spacing in cm in x direction
     392          37 :       dyrect = 0.0_dbl_kind   ! user defined grid spacing in cm in y direction
     393          37 :       lonrefrect = -156.50_dbl_kind  ! lower left corner lon for rectgrid
     394          37 :       latrefrect =   71.35_dbl_kind  ! lower left corner lat for rectgrid
     395          37 :       scale_dxdy = .false.    ! apply dxscale, dyscale to rectgrid
     396          37 :       dxscale = 1.0_dbl_kind   ! user defined rectgrid x-grid scale factor (e.g., 1.02)
     397          37 :       dyscale = 1.0_dbl_kind   ! user defined rectgrid y-grid scale factor (e.g., 1.02)
     398          37 :       close_boundaries = .false.   ! true = set land on edges of grid
     399          37 :       seabed_stress= .false.  ! if true, seabed stress for landfast is on
     400          37 :       seabed_stress_method  = 'LKD'! LKD = Lemieux et al 2015, probabilistic = Dupont et al. 2022
     401          37 :       k1 = 7.5_dbl_kind       ! 1st free parameter for landfast parameterization
     402          37 :       k2 = 15.0_dbl_kind      ! 2nd free parameter (N/m^3) for landfast parametrization
     403          37 :       alphab = 20.0_dbl_kind  ! alphab=Cb factor in Lemieux et al 2015
     404          37 :       threshold_hw = 30.0_dbl_kind ! max water depth for grounding
     405          37 :       Ktens = 0.0_dbl_kind    ! T=Ktens*P (tensile strength: see Konig and Holland, 2010)
     406          37 :       e_yieldcurve = 2.0_dbl_kind  ! VP aspect ratio of elliptical yield curve
     407          37 :       e_plasticpot = 2.0_dbl_kind  ! VP aspect ratio of elliptical plastic potential
     408          37 :       visc_method = 'avg_zeta' ! calc viscosities at U point: avg_strength, avg_zeta
     409          37 :       deltaminEVP = 1e-11_dbl_kind ! minimum delta for viscosities (EVP, Hunke 2001)
     410          37 :       deltaminVP  = 2e-9_dbl_kind  ! minimum delta for viscosities (VP, Hibler 1979)
     411          37 :       capping_method  = 'max'  ! method for capping of viscosities (max=Hibler 1979,sum=Kreyscher2000)
     412          37 :       maxits_nonlin = 10       ! max nb of iteration for nonlinear solver
     413          37 :       precond = 'pgmres'       ! preconditioner for fgmres: 'ident' (identity), 'diag' (diagonal),
     414             :                                ! 'pgmres' (Jacobi-preconditioned GMRES)
     415          37 :       dim_fgmres = 50          ! size of fgmres Krylov subspace
     416          37 :       dim_pgmres = 5           ! size of pgmres Krylov subspace
     417          37 :       maxits_fgmres = 50       ! max nb of iteration for fgmres
     418          37 :       maxits_pgmres = 5        ! max nb of iteration for pgmres
     419          37 :       monitor_nonlin = .false. ! print nonlinear residual norm
     420          37 :       monitor_fgmres = .false. ! print fgmres residual norm
     421          37 :       monitor_pgmres = .false. ! print pgmres residual norm
     422          37 :       ortho_type = 'mgs'       ! orthogonalization procedure 'cgs' or 'mgs'
     423          37 :       reltol_nonlin = 1e-8_dbl_kind ! nonlinear stopping criterion: reltol_nonlin*res(k=0)
     424          37 :       reltol_fgmres = 1e-1_dbl_kind ! fgmres stopping criterion: reltol_fgmres*res(k)
     425          37 :       reltol_pgmres = 1e-6_dbl_kind ! pgmres stopping criterion: reltol_pgmres*res(k)
     426          37 :       algo_nonlin = 'picard'        ! nonlinear algorithm: 'picard' (Picard iteration), 'anderson' (Anderson acceleration)
     427          37 :       fpfunc_andacc = 1        ! fixed point function for Anderson acceleration:
     428             :                                ! 1: g(x) = FMGRES(A(x),b(x)), 2: g(x) = x - A(x)x + b(x)
     429          37 :       dim_andacc = 5           ! size of Anderson minimization matrix (number of saved previous residuals)
     430          37 :       reltol_andacc = 1e-6_dbl_kind  ! relative tolerance for Anderson acceleration
     431          37 :       damping_andacc = 0       ! damping factor for Anderson acceleration
     432          37 :       start_andacc = 0         ! acceleration delay factor (acceleration starts at this iteration)
     433          37 :       use_mean_vrel = .true.   ! use mean of previous 2 iterates to compute vrel
     434          37 :       advection  = 'remap'     ! incremental remapping transport scheme
     435          37 :       conserv_check = .false.  ! tracer conservation check
     436          37 :       shortwave = 'ccsm3'      ! 'ccsm3' or 'dEdd' (delta-Eddington)
     437          37 :       snw_ssp_table = 'test'   ! 'test' or 'snicar' dEdd_snicar_ad table data
     438          37 :       albedo_type = 'ccsm3'    ! 'ccsm3' or 'constant'
     439          37 :       ktherm = 1               ! -1 = OFF, 1 = BL99, 2 = mushy thermo
     440          37 :       conduct = 'bubbly'       ! 'MU71' or 'bubbly' (Pringle et al 2007)
     441          37 :       coriolis = 'latitude'    ! latitude dependent, or 'constant'
     442          37 :       ssh_stress = 'geostrophic'  ! 'geostrophic' or 'coupled'
     443          37 :       kridge   = 1             ! -1 = off, 1 = on
     444          37 :       ktransport = 1           ! -1 = off, 1 = on
     445          37 :       calc_Tsfc = .true.       ! calculate surface temperature
     446          37 :       update_ocn_f = .false.   ! include fresh water and salt fluxes for frazil
     447          37 :       cpl_frazil = 'fresh_ice_correction' ! type of coupling for frazil ice
     448          37 :       ustar_min = 0.005        ! minimum friction velocity for ocean heat flux (m/s)
     449          37 :       hi_min = p01             ! minimum ice thickness allowed (m)
     450          37 :       iceruf = 0.0005_dbl_kind ! ice surface roughness at atmosphere interface (m)
     451          37 :       iceruf_ocn = 0.03_dbl_kind ! under-ice roughness (m)
     452          37 :       calc_dragio = .false.    ! compute dragio from iceruf_ocn and thickness of first ocean level
     453          37 :       emissivity = 0.985       ! emissivity of snow and ice
     454          37 :       l_mpond_fresh = .false.  ! logical switch for including meltpond freshwater
     455             :                                ! flux feedback to ocean model
     456          37 :       fbot_xfer_type = 'constant' ! transfer coefficient type for ocn heat flux
     457          37 :       R_ice     = 0.00_dbl_kind   ! tuning parameter for sea ice
     458          37 :       R_pnd     = 0.00_dbl_kind   ! tuning parameter for ponded sea ice
     459          37 :       R_snw     = 1.50_dbl_kind   ! tuning parameter for snow over sea ice
     460          37 :       dT_mlt    = 1.5_dbl_kind    ! change in temp to give non-melt to melt change
     461             :                                   ! in snow grain radius
     462          37 :       rsnw_mlt  = 1500._dbl_kind  ! maximum melting snow grain radius
     463          37 :       kalg      = 0.60_dbl_kind   ! algae absorption coefficient for 0.5 m thick layer
     464             :                                   ! 0.5 m path of 75 mg Chl a / m2
     465          37 :       hp1       = 0.01_dbl_kind   ! critical pond lid thickness for topo ponds
     466          37 :       hs0       = 0.03_dbl_kind   ! snow depth for transition to bare sea ice (m)
     467          37 :       hs1       = 0.03_dbl_kind   ! snow depth for transition to bare pond ice (m)
     468          37 :       dpscale   = c1              ! alter e-folding time scale for flushing
     469          37 :       frzpnd    = 'cesm'          ! melt pond refreezing parameterization
     470          37 :       rfracmin  = 0.15_dbl_kind   ! minimum retained fraction of meltwater
     471          37 :       rfracmax  = 0.85_dbl_kind   ! maximum retained fraction of meltwater
     472          37 :       pndaspect = 0.8_dbl_kind    ! ratio of pond depth to area fraction
     473          37 :       snwredist = 'none'          ! type of snow redistribution
     474          37 :       snw_aging_table = 'test'    ! snow aging lookup table
     475          37 :       snw_filename    = 'unknown' ! snowtable filename
     476          37 :       snw_tau_fname   = 'unknown' ! snowtable file tau fieldname
     477          37 :       snw_kappa_fname = 'unknown' ! snowtable file kappa fieldname
     478          37 :       snw_drdt0_fname = 'unknown' ! snowtable file drdt0 fieldname
     479          37 :       snw_rhos_fname  = 'unknown' ! snowtable file rhos fieldname
     480          37 :       snw_Tgrd_fname  = 'unknown' ! snowtable file Tgrd fieldname
     481          37 :       snw_T_fname     = 'unknown' ! snowtable file T fieldname
     482          37 :       snwgrain  = .false.         ! snow metamorphosis
     483          37 :       use_smliq_pnd = .false.     ! use liquid in snow for ponds
     484          37 :       rsnw_fall =  100.0_dbl_kind ! radius of new snow (10^-6 m) ! advanced snow physics: 54.526 x 10^-6 m
     485          37 :       rsnw_tmax = 1500.0_dbl_kind ! maximum snow radius (10^-6 m)
     486          37 :       rhosnew   =  100.0_dbl_kind ! new snow density (kg/m^3)
     487          37 :       rhosmin   =  100.0_dbl_kind ! minimum snow density (kg/m^3)
     488          37 :       rhosmax   =  450.0_dbl_kind ! maximum snow density (kg/m^3)
     489          37 :       windmin   =   10.0_dbl_kind ! minimum wind speed to compact snow (m/s)
     490          37 :       drhosdwind=   27.3_dbl_kind ! wind compaction factor for snow (kg s/m^4)
     491          37 :       snwlvlfac =    0.3_dbl_kind ! fractional increase in snow depth for bulk redistribution
     492          37 :       albicev   = 0.78_dbl_kind   ! visible ice albedo for h > ahmax
     493          37 :       albicei   = 0.36_dbl_kind   ! near-ir ice albedo for h > ahmax
     494          37 :       albsnowv  = 0.98_dbl_kind   ! cold snow albedo, visible
     495          37 :       albsnowi  = 0.70_dbl_kind   ! cold snow albedo, near IR
     496          37 :       ahmax     = 0.3_dbl_kind    ! thickness above which ice albedo is constant (m)
     497          37 :       atmbndy   = 'similarity'    ! Atm boundary layer: 'similarity', 'constant' or 'mixed'
     498          37 :       default_season  = 'winter'  ! default forcing data, if data is not read in
     499          37 :       fyear_init = 1900           ! first year of forcing cycle
     500          37 :       ycycle = 1                  ! number of years in forcing cycle
     501          37 :       atm_data_format = 'bin'     ! file format ('bin'=binary or 'nc'=netcdf)
     502          37 :       atm_data_type   = 'default'
     503          37 :       atm_data_dir    = ' '
     504          37 :       rotate_wind     = .true.    ! rotate wind/stress composants to computational grid orientation
     505          37 :       calc_strair     = .true.    ! calculate wind stress
     506          37 :       formdrag        = .false.   ! calculate form drag
     507          37 :       highfreq        = .false.   ! calculate high frequency RASM coupling
     508          37 :       natmiter        = 5         ! number of iterations for atm boundary layer calcs
     509          37 :       atmiter_conv    = c0        ! ustar convergence criteria
     510          37 :       precip_units    = 'mks'     ! 'mm_per_month' or
     511             :                                   ! 'mm_per_sec' = 'mks' = kg/m^2 s
     512          37 :       tfrz_option     = 'mushy'   ! freezing temp formulation
     513          37 :       saltflux_option = 'constant'    ! saltflux calculation
     514          37 :       ice_ref_salinity = 4.0_dbl_kind ! Ice reference salinity for coupling
     515          37 :       oceanmixed_ice  = .false.   ! if true, use internal ocean mixed layer
     516          37 :       wave_spec_type  = 'none'    ! type of wave spectrum forcing
     517          37 :       nfreq           = 25        ! number of wave frequencies
     518          37 :       wave_spec_file  = ' '       ! wave forcing file name
     519          37 :       ocn_data_format = 'bin'     ! file format ('bin'=binary or 'nc'=netcdf)
     520          37 :       bgc_data_type   = 'default'
     521          37 :       fe_data_type    = 'default'
     522          37 :       ice_data_type   = 'default' ! used by some tests to initialize ice state (overall type and mask)
     523          37 :       ice_data_conc   = 'default' ! used by some tests to initialize ice state (concentration)
     524          37 :       ice_data_dist   = 'default' ! used by some tests to initialize ice state (distribution)
     525          37 :       bgc_data_dir    = 'unknown_bgc_data_dir'
     526          37 :       ocn_data_type   = 'default'
     527          37 :       ocn_data_dir    = 'unknown_ocn_data_dir'
     528          37 :       oceanmixed_file = 'unknown_oceanmixed_file' ! ocean forcing data
     529          37 :       restore_ocn     = .false.   ! restore sst if true
     530          37 :       trestore        = 90        ! restoring timescale, days (0 instantaneous)
     531          37 :       restore_ice     = .false.   ! restore ice state on grid edges if true
     532          37 :       debug_forcing   = .false.   ! true writes diagnostics for input forcing
     533             : 
     534          37 :       latpnt(1) =  90._dbl_kind   ! latitude of diagnostic point 1 (deg)
     535          37 :       lonpnt(1) =   0._dbl_kind   ! longitude of point 1 (deg)
     536          37 :       latpnt(2) = -65._dbl_kind   ! latitude of diagnostic point 2 (deg)
     537          37 :       lonpnt(2) = -45._dbl_kind   ! longitude of point 2 (deg)
     538             : 
     539             : #ifndef CESMCOUPLED
     540          37 :       runid   = 'unknown'   ! run ID used in CESM and for machine 'bering'
     541          37 :       runtype = 'initial'   ! run type: 'initial', 'continue'
     542          37 :       restart = .false.     ! if true, read ice state from restart file
     543          37 :       use_restart_time = .false.   ! if true, use time info written in file
     544             : #endif
     545             : 
     546             :       ! extra tracers
     547          37 :       tr_iage      = .false. ! ice age
     548          37 :       restart_age  = .false. ! ice age restart
     549          37 :       tr_FY        = .false. ! ice age
     550          37 :       restart_FY   = .false. ! ice age restart
     551          37 :       tr_lvl       = .false. ! level ice
     552          37 :       restart_lvl  = .false. ! level ice restart
     553          37 :       tr_pond_lvl  = .false. ! level-ice melt ponds
     554          37 :       restart_pond_lvl  = .false. ! melt ponds restart
     555          37 :       tr_pond_topo = .false. ! explicit melt ponds (topographic)
     556          37 :       restart_pond_topo = .false. ! melt ponds restart
     557          37 :       tr_snow      = .false. ! advanced snow physics
     558          37 :       restart_snow = .false. ! advanced snow physics restart
     559          37 :       tr_iso       = .false. ! isotopes
     560          37 :       restart_iso  = .false. ! isotopes restart
     561          37 :       tr_aero      = .false. ! aerosols
     562          37 :       restart_aero = .false. ! aerosols restart
     563          37 :       tr_fsd       = .false. ! floe size distribution
     564          37 :       restart_fsd  = .false. ! floe size distribution restart
     565             : 
     566          37 :       n_iso = 0
     567          37 :       n_aero = 0
     568          37 :       n_zaero = 0
     569          37 :       n_algae = 0
     570          37 :       n_doc = 0
     571          37 :       n_dic = 0
     572          37 :       n_don = 0
     573          37 :       n_fed = 0
     574          37 :       n_fep = 0
     575             : 
     576             :       ! mushy layer gravity drainage physics
     577          37 :       a_rapid_mode      =  0.5e-3_dbl_kind ! channel radius for rapid drainage mode (m)
     578          37 :       Rac_rapid_mode    =    10.0_dbl_kind ! critical Rayleigh number
     579          37 :       aspect_rapid_mode =     1.0_dbl_kind ! aspect ratio (larger is wider)
     580          37 :       dSdt_slow_mode    = -1.5e-7_dbl_kind ! slow mode drainage strength (m s-1 K-1)
     581          37 :       phi_c_slow_mode   =    0.05_dbl_kind ! critical liquid fraction porosity cutoff
     582          37 :       phi_i_mushy       =    0.85_dbl_kind ! liquid fraction of congelation ice
     583          37 :       Tliquidus_max     =    0.00_dbl_kind ! maximum liquidus temperature of mush (C)
     584             : 
     585          37 :       floediam          =   300.0_dbl_kind ! min thickness of new frazil ice (m)
     586          37 :       hfrazilmin        =    0.05_dbl_kind ! effective floe diameter (m)
     587             : 
     588             :       ! shortwave redistribution in the thermodynamics
     589          37 :       sw_redist = .false.
     590          37 :       sw_frac   = 0.9_dbl_kind
     591          37 :       sw_dtemp  = 0.02_dbl_kind
     592             : 
     593             :       !-----------------------------------------------------------------
     594             :       ! read from input file
     595             :       !-----------------------------------------------------------------
     596             : 
     597             : #ifdef CESMCOUPLED
     598             :       nml_filename  = 'ice_in'//trim(inst_suffix)
     599             : #endif
     600             : 
     601          37 :       if (my_task == master_task) then
     602             : 
     603             :          ! open namelist file
     604           7 :          call get_fileunit(nu_nml)
     605           7 :          open (nu_nml, file=trim(nml_filename), status='old',iostat=nml_error)
     606           7 :          if (nml_error /= 0) then
     607             :             call abort_ice(subname//'ERROR: open file '// &
     608             :                trim(nml_filename), &   ! LCOV_EXCL_LINE
     609           0 :                file=__FILE__, line=__LINE__)
     610             :          endif
     611             : 
     612             :          ! read setup_nml
     613           7 :          nml_name = 'setup_nml'
     614           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     615             :          ! goto namelist in file
     616           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     617           7 :          if (nml_error /= 0) then
     618             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     619           0 :                file=__FILE__, line=__LINE__)
     620             :          endif
     621             : 
     622             :          ! read namelist
     623           7 :          nml_error =  1
     624          14 :          do while (nml_error > 0)
     625           7 :             read(nu_nml, nml=setup_nml,iostat=nml_error)
     626             :             ! check if error
     627           7 :             if (nml_error /= 0) then
     628             :                ! backspace and re-read erroneous line
     629           0 :                backspace(nu_nml)
     630           0 :                read(nu_nml,fmt='(A)') tmpstr2
     631             :                call abort_ice(subname//'ERROR: '//trim(nml_name)//' reading '// &
     632           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     633             :             endif
     634             :          end do
     635             : 
     636             :          ! read grid_nml
     637           7 :          nml_name = 'grid_nml'
     638           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     639             :          ! goto namelist in file
     640           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     641           7 :          if (nml_error /= 0) then
     642             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     643           0 :                file=__FILE__, line=__LINE__)
     644             :          endif
     645             : 
     646             :          ! read namelist
     647           7 :          nml_error =  1
     648          14 :          do while (nml_error > 0)
     649           7 :             read(nu_nml, nml=grid_nml,iostat=nml_error)
     650             :             ! check if error
     651           7 :             if (nml_error /= 0) then
     652             :                ! backspace and re-read erroneous line
     653           0 :                backspace(nu_nml)
     654           0 :                read(nu_nml,fmt='(A)') tmpstr2
     655             :                call abort_ice(subname//'ERROR: ' //trim(nml_name)//' reading '// &
     656           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     657             :             endif
     658             :          end do
     659             : 
     660             :          ! read tracer_nml
     661           7 :          nml_name = 'tracer_nml'
     662           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     663             :          ! goto namelist in file
     664           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     665           7 :          if (nml_error /= 0) then
     666             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     667           0 :                file=__FILE__, line=__LINE__)
     668             :          endif
     669             : 
     670             :          ! read namelist
     671           7 :          nml_error =  1
     672          14 :          do while (nml_error > 0)
     673           7 :             read(nu_nml, nml=tracer_nml,iostat=nml_error)
     674             :             ! check if error
     675           7 :             if (nml_error /= 0) then
     676             :                ! backspace and re-read erroneous line
     677           0 :                backspace(nu_nml)
     678           0 :                read(nu_nml,fmt='(A)') tmpstr2
     679             :                call abort_ice(subname//'ERROR: ' //trim(nml_name)//' reading '// &
     680           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     681             :             endif
     682             :          end do
     683             : 
     684             :          ! read thermo_nml
     685           7 :          nml_name = 'thermo_nml'
     686           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     687             :          ! goto namelist in file
     688           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     689           7 :          if (nml_error /= 0) then
     690             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     691           0 :                file=__FILE__, line=__LINE__)
     692             :          endif
     693             : 
     694             :          ! read namelist
     695           7 :          nml_error =  1
     696          14 :          do while (nml_error > 0)
     697           7 :             read(nu_nml, nml=thermo_nml,iostat=nml_error)
     698             :             ! check if error
     699           7 :             if (nml_error /= 0) then
     700             :                ! backspace and re-read erroneous line
     701           0 :                backspace(nu_nml)
     702           0 :                read(nu_nml,fmt='(A)') tmpstr2
     703             :                call abort_ice(subname//'ERROR: '//trim(nml_name)//' reading '// &
     704           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     705             :             endif
     706             :          end do
     707             : 
     708             :          ! read dynamics_nml
     709           7 :          nml_name = 'dynamics_nml'
     710           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     711             : 
     712             :          ! goto namelist in file
     713           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     714           7 :          if (nml_error /= 0) then
     715             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     716           0 :                file=__FILE__, line=__LINE__)
     717             :          endif
     718             : 
     719             :          ! read namelist
     720           7 :          nml_error =  1
     721          14 :          do while (nml_error > 0)
     722           7 :             read(nu_nml, nml=dynamics_nml,iostat=nml_error)
     723             :             ! check if error
     724           7 :             if (nml_error /= 0) then
     725             :                ! backspace and re-read erroneous line
     726           0 :                backspace(nu_nml)
     727           0 :                read(nu_nml,fmt='(A)') tmpstr2
     728             :                call abort_ice(subname//'ERROR: '//trim(nml_name)//' reading '// &
     729           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     730             :             endif
     731             :          end do
     732             : 
     733             :          ! read shortwave_nml
     734           7 :          nml_name = 'shortwave_nml'
     735           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     736             : 
     737             :          ! goto namelist in file
     738           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     739           7 :          if (nml_error /= 0) then
     740             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     741           0 :                file=__FILE__, line=__LINE__)
     742             :          endif
     743             : 
     744             :          ! read namelist
     745           7 :          nml_error =  1
     746          14 :          do while (nml_error > 0)
     747           7 :             read(nu_nml, nml=shortwave_nml,iostat=nml_error)
     748             :             ! check if error
     749           7 :             if (nml_error /= 0) then
     750             :                ! backspace and re-read erroneous line
     751           0 :                backspace(nu_nml)
     752           0 :                read(nu_nml,fmt='(A)') tmpstr2
     753             :                call abort_ice(subname//'ERROR: '//trim(nml_name)//' reading '//&
     754           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     755             :             endif
     756             :          end do
     757             : 
     758             :          ! read ponds_nml
     759           7 :          nml_name = 'ponds_nml'
     760           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     761             : 
     762             :          ! goto namelist in file
     763           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     764           7 :          if (nml_error /= 0) then
     765             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     766           0 :                file=__FILE__, line=__LINE__)
     767             :          endif
     768             : 
     769             :          ! read namelist
     770           7 :          nml_error =  1
     771          14 :          do while (nml_error > 0)
     772           7 :             read(nu_nml, nml=ponds_nml,iostat=nml_error)
     773             :             ! check if error
     774           7 :             if (nml_error /= 0) then
     775             :                ! backspace and re-read erroneous line
     776           0 :                backspace(nu_nml)
     777           0 :                read(nu_nml,fmt='(A)') tmpstr2
     778             :                call abort_ice(subname//'ERROR: '//trim(nml_name)//' reading '// &
     779           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     780             :             endif
     781             :          end do
     782             : 
     783             :          ! read snow_nml
     784           7 :          nml_name = 'snow_nml'
     785           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     786             : 
     787             :          ! goto namelist in file
     788           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     789           7 :          if (nml_error /= 0) then
     790             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     791           0 :                file=__FILE__, line=__LINE__)
     792             :          endif
     793             : 
     794             :          ! read  namelist
     795           7 :          nml_error =  1
     796          14 :          do while (nml_error > 0)
     797           7 :             read(nu_nml, nml=snow_nml,iostat=nml_error)
     798             :             ! check if error
     799           7 :             if (nml_error /= 0) then
     800             :                ! backspace and re-read erroneous line
     801           0 :                backspace(nu_nml)
     802           0 :                read(nu_nml,fmt='(A)') tmpstr2
     803             :                call abort_ice(subname//'ERROR: '//trim(nml_name)//' reading '// &
     804           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     805             :             endif
     806             :          end do
     807             : 
     808             :          ! read forcing_nml
     809           7 :          nml_name = 'forcing_nml'
     810           7 :          write(nu_diag,*) subname,' Reading ', trim(nml_name)
     811             : 
     812             :          ! goto namelist in file
     813           7 :          call goto_nml(nu_nml,trim(nml_name),nml_error)
     814           7 :          if (nml_error /= 0) then
     815             :             call abort_ice(subname//'ERROR: searching for '// trim(nml_name), &
     816           0 :                file=__FILE__, line=__LINE__)
     817             :          endif
     818             : 
     819             :          ! read namelist
     820           7 :          nml_error =  1
     821          14 :          do while (nml_error > 0)
     822           7 :             read(nu_nml, nml=forcing_nml,iostat=nml_error)
     823             :             ! check if error
     824           7 :             if (nml_error /= 0) then
     825             :                ! backspace and re-read erroneous line
     826           0 :                backspace(nu_nml)
     827           0 :                read(nu_nml,fmt='(A)') tmpstr2
     828             :                call abort_ice(subname//'ERROR: '// trim(nml_name)//' reading '// &
     829           0 :                     trim(tmpstr2), file=__FILE__, line=__LINE__)
     830             :             endif
     831             :          end do
     832             : 
     833             :          ! done reading namelist.
     834           7 :          close(nu_nml)
     835           7 :          call release_fileunit(nu_nml)
     836             :       endif
     837             : 
     838             :       !-----------------------------------------------------------------
     839             :       ! set up diagnostics output and resolve conflicts
     840             :       !-----------------------------------------------------------------
     841             : 
     842             : #ifdef CESMCOUPLED
     843             :       ! Note in CESMCOUPLED mode diag_file is not utilized and
     844             :       ! runid and runtype are obtained from the driver, not from the namelist
     845             : 
     846             :       if (my_task == master_task) then
     847             :          history_file  = trim(runid) // ".cice" // trim(inst_suffix) //".h"
     848             :          restart_file  = trim(runid) // ".cice" // trim(inst_suffix) //".r"
     849             :          incond_file   = trim(runid) // ".cice" // trim(inst_suffix) //".i"
     850             :          ! Note by tcraig - this if test is needed because the nuopc cap sets
     851             :          ! nu_diag before this routine is called.  This creates a conflict.
     852             :          ! In addition, in the nuopc cap, shr_file_setIO will fail if the
     853             :          ! needed namelist is missing (which it is in the CIME nuopc implementation)
     854             :          if (.not. nu_diag_set) then
     855             :             inquire(file='ice_modelio.nml'//trim(inst_suffix),exist=exists)
     856             :             if (exists) then
     857             :                call get_fileUnit(nu_diag)
     858             :                call shr_file_setIO('ice_modelio.nml'//trim(inst_suffix),nu_diag)
     859             :             end if
     860             :          endif
     861             :       else
     862             :          ! each task gets unique ice log filename when if test is true, for debugging
     863             :          if (1 == 0) then
     864             :             call get_fileUnit(nu_diag)
     865             :             write(tmpstr2,'(a,i4.4)') "ice.log.task_",my_task
     866             :             open(nu_diag,file=tmpstr2)
     867             :          endif
     868             :       end if
     869             :       if (trim(ice_ic) /= 'default' .and. &
     870             :           trim(ice_ic) /= 'none'    .and. &   ! LCOV_EXCL_LINE
     871             :           trim(ice_ic) /= 'internal') then
     872             :          restart = .true.
     873             :       end if
     874             : #else
     875          37 :       if (trim(diag_type) == 'file') call get_fileunit(nu_diag)
     876             : #endif
     877             : 
     878             :       !-----------------------------------------------------------------
     879             :       ! broadcast namelist settings
     880             :       !-----------------------------------------------------------------
     881             : 
     882          37 :       call broadcast_scalar(numin,                master_task)
     883          37 :       call broadcast_scalar(numax,                master_task)
     884          37 :       call broadcast_scalar(days_per_year,        master_task)
     885          37 :       call broadcast_scalar(use_leap_years,       master_task)
     886          37 :       call broadcast_scalar(year_init,            master_task)
     887          37 :       call broadcast_scalar(month_init,           master_task)
     888          37 :       call broadcast_scalar(day_init,             master_task)
     889          37 :       call broadcast_scalar(sec_init,             master_task)
     890          37 :       call broadcast_scalar(istep0,               master_task)
     891          37 :       call broadcast_scalar(dt,                   master_task)
     892          37 :       call broadcast_scalar(npt,                  master_task)
     893          37 :       call broadcast_scalar(npt_unit,             master_task)
     894          37 :       call broadcast_scalar(diagfreq,             master_task)
     895          37 :       call broadcast_scalar(debug_model,          master_task)
     896          37 :       call broadcast_scalar(debug_model_step,     master_task)
     897          37 :       call broadcast_scalar(debug_model_i,        master_task)
     898          37 :       call broadcast_scalar(debug_model_j,        master_task)
     899          37 :       call broadcast_scalar(debug_model_iblk,     master_task)
     900          37 :       call broadcast_scalar(debug_model_task,     master_task)
     901          37 :       call broadcast_scalar(print_points,         master_task)
     902          37 :       call broadcast_scalar(print_global,         master_task)
     903          37 :       call broadcast_scalar(timer_stats,          master_task)
     904          37 :       call broadcast_scalar(memory_stats,         master_task)
     905          37 :       call broadcast_scalar(bfbflag,              master_task)
     906          37 :       call broadcast_scalar(diag_type,            master_task)
     907          37 :       call broadcast_scalar(diag_file,            master_task)
     908         222 :       do n = 1, max_nstrm
     909         185 :          call broadcast_scalar(histfreq(n),       master_task)
     910         185 :          call broadcast_scalar(histfreq_base(n),  master_task)
     911         185 :          call broadcast_scalar(dumpfreq(n),       master_task)
     912         302 :          call broadcast_scalar(dumpfreq_base(n),  master_task)
     913             :       enddo
     914          37 :       call broadcast_array(hist_avg,              master_task)
     915          37 :       call broadcast_array(histfreq_n,            master_task)
     916          37 :       call broadcast_array(dumpfreq_n,            master_task)
     917          37 :       call broadcast_scalar(history_dir,          master_task)
     918          37 :       call broadcast_scalar(history_file,         master_task)
     919          37 :       call broadcast_scalar(history_precision,    master_task)
     920          37 :       call broadcast_scalar(history_format,       master_task)
     921          37 :       call broadcast_scalar(hist_time_axis,       master_task)
     922          37 :       call broadcast_scalar(write_ic,             master_task)
     923          37 :       call broadcast_scalar(cpl_bgc,              master_task)
     924          37 :       call broadcast_scalar(incond_dir,           master_task)
     925          37 :       call broadcast_scalar(incond_file,          master_task)
     926          37 :       call broadcast_scalar(dump_last,            master_task)
     927          37 :       call broadcast_scalar(restart_file,         master_task)
     928          37 :       call broadcast_scalar(restart,              master_task)
     929          37 :       call broadcast_scalar(restart_dir,          master_task)
     930          37 :       call broadcast_scalar(restart_ext,          master_task)
     931          37 :       call broadcast_scalar(restart_coszen,       master_task)
     932          37 :       call broadcast_scalar(use_restart_time,     master_task)
     933          37 :       call broadcast_scalar(restart_format,       master_task)
     934          37 :       call broadcast_scalar(lcdf64,               master_task)
     935          37 :       call broadcast_scalar(pointer_file,         master_task)
     936          37 :       call broadcast_scalar(ice_ic,               master_task)
     937          37 :       call broadcast_scalar(grid_format,          master_task)
     938          37 :       call broadcast_scalar(dxrect,               master_task)
     939          37 :       call broadcast_scalar(dyrect,               master_task)
     940          37 :       call broadcast_scalar(scale_dxdy,           master_task)
     941          37 :       call broadcast_scalar(dxscale,              master_task)
     942          37 :       call broadcast_scalar(dyscale,              master_task)
     943          37 :       call broadcast_scalar(lonrefrect,           master_task)
     944          37 :       call broadcast_scalar(latrefrect,           master_task)
     945          37 :       call broadcast_scalar(close_boundaries,     master_task)
     946          37 :       call broadcast_scalar(grid_type,            master_task)
     947          37 :       call broadcast_scalar(grid_ice,             master_task)
     948          37 :       call broadcast_scalar(grid_ocn,             master_task)
     949          37 :       call broadcast_scalar(grid_atm,             master_task)
     950          37 :       call broadcast_scalar(grid_file,            master_task)
     951          37 :       call broadcast_scalar(gridcpl_file,         master_task)
     952          37 :       call broadcast_scalar(orca_halogrid,        master_task)
     953          37 :       call broadcast_scalar(bathymetry_file,      master_task)
     954          37 :       call broadcast_scalar(bathymetry_format,    master_task)
     955          37 :       call broadcast_scalar(use_bathymetry,       master_task)
     956          37 :       call broadcast_scalar(kmt_type,             master_task)
     957          37 :       call broadcast_scalar(kmt_file,             master_task)
     958          37 :       call broadcast_scalar(kitd,                 master_task)
     959          37 :       call broadcast_scalar(kcatbound,            master_task)
     960          37 :       call broadcast_scalar(kdyn,                 master_task)
     961          37 :       call broadcast_scalar(ndtd,                 master_task)
     962          37 :       call broadcast_scalar(ndte,                 master_task)
     963          37 :       call broadcast_scalar(evp_algorithm,        master_task)
     964          37 :       call broadcast_scalar(elasticDamp,          master_task)
     965          37 :       call broadcast_scalar(pgl_global_ext,       master_task)
     966          37 :       call broadcast_scalar(brlx,                 master_task)
     967          37 :       call broadcast_scalar(arlx,                 master_task)
     968          37 :       call broadcast_scalar(revised_evp,          master_task)
     969          37 :       call broadcast_scalar(yield_curve,          master_task)
     970          37 :       call broadcast_scalar(kstrength,            master_task)
     971          37 :       call broadcast_scalar(Pstar,                master_task)
     972          37 :       call broadcast_scalar(Cstar,                master_task)
     973          37 :       call broadcast_scalar(krdg_partic,          master_task)
     974          37 :       call broadcast_scalar(krdg_redist,          master_task)
     975          37 :       call broadcast_scalar(mu_rdg,               master_task)
     976          37 :       call broadcast_scalar(Cf,                   master_task)
     977          37 :       call broadcast_scalar(ksno,                 master_task)
     978          37 :       call broadcast_scalar(seabed_stress,        master_task)
     979          37 :       call broadcast_scalar(seabed_stress_method, master_task)
     980          37 :       call broadcast_scalar(k1,                   master_task)
     981          37 :       call broadcast_scalar(k2,                   master_task)
     982          37 :       call broadcast_scalar(alphab,               master_task)
     983          37 :       call broadcast_scalar(threshold_hw,         master_task)
     984          37 :       call broadcast_scalar(Ktens,                master_task)
     985          37 :       call broadcast_scalar(e_yieldcurve,         master_task)
     986          37 :       call broadcast_scalar(e_plasticpot,         master_task)
     987          37 :       call broadcast_scalar(visc_method,          master_task)
     988          37 :       call broadcast_scalar(deltaminEVP,          master_task)
     989          37 :       call broadcast_scalar(deltaminVP,           master_task)
     990          37 :       call broadcast_scalar(capping_method,       master_task)
     991          37 :       call broadcast_scalar(advection,            master_task)
     992          37 :       call broadcast_scalar(conserv_check,        master_task)
     993          37 :       call broadcast_scalar(shortwave,            master_task)
     994          37 :       call broadcast_scalar(snw_ssp_table,        master_task)
     995          37 :       call broadcast_scalar(albedo_type,          master_task)
     996          37 :       call broadcast_scalar(ktherm,               master_task)
     997          37 :       call broadcast_scalar(coriolis,             master_task)
     998          37 :       call broadcast_scalar(ssh_stress,           master_task)
     999          37 :       call broadcast_scalar(kridge,               master_task)
    1000          37 :       call broadcast_scalar(ktransport,           master_task)
    1001          37 :       call broadcast_scalar(maxits_nonlin,        master_task)
    1002          37 :       call broadcast_scalar(precond,              master_task)
    1003          37 :       call broadcast_scalar(dim_fgmres,           master_task)
    1004          37 :       call broadcast_scalar(dim_pgmres,           master_task)
    1005          37 :       call broadcast_scalar(maxits_fgmres,        master_task)
    1006          37 :       call broadcast_scalar(maxits_pgmres,        master_task)
    1007          37 :       call broadcast_scalar(monitor_nonlin,       master_task)
    1008          37 :       call broadcast_scalar(monitor_fgmres,       master_task)
    1009          37 :       call broadcast_scalar(monitor_pgmres,       master_task)
    1010          37 :       call broadcast_scalar(ortho_type,           master_task)
    1011          37 :       call broadcast_scalar(reltol_nonlin,        master_task)
    1012          37 :       call broadcast_scalar(reltol_fgmres,        master_task)
    1013          37 :       call broadcast_scalar(reltol_pgmres,        master_task)
    1014          37 :       call broadcast_scalar(algo_nonlin,          master_task)
    1015          37 :       call broadcast_scalar(fpfunc_andacc,        master_task)
    1016          37 :       call broadcast_scalar(dim_andacc,           master_task)
    1017          37 :       call broadcast_scalar(reltol_andacc,        master_task)
    1018          37 :       call broadcast_scalar(damping_andacc,       master_task)
    1019          37 :       call broadcast_scalar(start_andacc,         master_task)
    1020          37 :       call broadcast_scalar(use_mean_vrel,        master_task)
    1021          37 :       call broadcast_scalar(conduct,              master_task)
    1022          37 :       call broadcast_scalar(R_ice,                master_task)
    1023          37 :       call broadcast_scalar(R_pnd,                master_task)
    1024          37 :       call broadcast_scalar(R_snw,                master_task)
    1025          37 :       call broadcast_scalar(dT_mlt,               master_task)
    1026          37 :       call broadcast_scalar(rsnw_mlt,             master_task)
    1027          37 :       call broadcast_scalar(kalg,                 master_task)
    1028          37 :       call broadcast_scalar(hp1,                  master_task)
    1029          37 :       call broadcast_scalar(hs0,                  master_task)
    1030          37 :       call broadcast_scalar(hs1,                  master_task)
    1031          37 :       call broadcast_scalar(dpscale,              master_task)
    1032          37 :       call broadcast_scalar(frzpnd,               master_task)
    1033          37 :       call broadcast_scalar(rfracmin,             master_task)
    1034          37 :       call broadcast_scalar(rfracmax,             master_task)
    1035          37 :       call broadcast_scalar(pndaspect,            master_task)
    1036          37 :       call broadcast_scalar(snwredist,            master_task)
    1037          37 :       call broadcast_scalar(snw_aging_table,      master_task)
    1038          37 :       call broadcast_scalar(snw_filename,         master_task)
    1039          37 :       call broadcast_scalar(snw_tau_fname,        master_task)
    1040          37 :       call broadcast_scalar(snw_kappa_fname,      master_task)
    1041          37 :       call broadcast_scalar(snw_drdt0_fname,      master_task)
    1042          37 :       call broadcast_scalar(snw_rhos_fname,       master_task)
    1043          37 :       call broadcast_scalar(snw_Tgrd_fname,       master_task)
    1044          37 :       call broadcast_scalar(snw_T_fname,          master_task)
    1045          37 :       call broadcast_scalar(snwgrain,             master_task)
    1046          37 :       call broadcast_scalar(use_smliq_pnd,        master_task)
    1047          37 :       call broadcast_scalar(rsnw_fall,            master_task)
    1048          37 :       call broadcast_scalar(rsnw_tmax,            master_task)
    1049          37 :       call broadcast_scalar(rhosnew,              master_task)
    1050          37 :       call broadcast_scalar(rhosmin,              master_task)
    1051          37 :       call broadcast_scalar(rhosmax,              master_task)
    1052          37 :       call broadcast_scalar(windmin,              master_task)
    1053          37 :       call broadcast_scalar(drhosdwind,           master_task)
    1054          37 :       call broadcast_scalar(snwlvlfac,            master_task)
    1055          37 :       call broadcast_scalar(albicev,              master_task)
    1056          37 :       call broadcast_scalar(albicei,              master_task)
    1057          37 :       call broadcast_scalar(albsnowv,             master_task)
    1058          37 :       call broadcast_scalar(albsnowi,             master_task)
    1059          37 :       call broadcast_scalar(ahmax,                master_task)
    1060          37 :       call broadcast_scalar(atmbndy,              master_task)
    1061          37 :       call broadcast_scalar(default_season,       master_task)
    1062          37 :       call broadcast_scalar(fyear_init,           master_task)
    1063          37 :       call broadcast_scalar(ycycle,               master_task)
    1064          37 :       call broadcast_scalar(atm_data_format,      master_task)
    1065          37 :       call broadcast_scalar(atm_data_type,        master_task)
    1066          37 :       call broadcast_scalar(atm_data_dir,         master_task)
    1067          37 :       call broadcast_scalar(rotate_wind,          master_task)
    1068          37 :       call broadcast_scalar(calc_strair,          master_task)
    1069          37 :       call broadcast_scalar(calc_Tsfc,            master_task)
    1070          37 :       call broadcast_scalar(formdrag,             master_task)
    1071          37 :       call broadcast_scalar(highfreq,             master_task)
    1072          37 :       call broadcast_scalar(natmiter,             master_task)
    1073          37 :       call broadcast_scalar(atmiter_conv,         master_task)
    1074          37 :       call broadcast_scalar(update_ocn_f,         master_task)
    1075          37 :       call broadcast_scalar(cpl_frazil,           master_task)
    1076          37 :       call broadcast_scalar(l_mpond_fresh,        master_task)
    1077          37 :       call broadcast_scalar(ustar_min,            master_task)
    1078          37 :       call broadcast_scalar(hi_min,               master_task)
    1079          37 :       call broadcast_scalar(iceruf,               master_task)
    1080          37 :       call broadcast_scalar(iceruf_ocn,           master_task)
    1081          37 :       call broadcast_scalar(calc_dragio,          master_task)
    1082          37 :       call broadcast_scalar(emissivity,           master_task)
    1083          37 :       call broadcast_scalar(fbot_xfer_type,       master_task)
    1084          37 :       call broadcast_scalar(precip_units,         master_task)
    1085          37 :       call broadcast_scalar(oceanmixed_ice,       master_task)
    1086          37 :       call broadcast_scalar(wave_spec_type,       master_task)
    1087          37 :       call broadcast_scalar(wave_spec_file,       master_task)
    1088          37 :       call broadcast_scalar(nfreq,                master_task)
    1089          37 :       call broadcast_scalar(tfrz_option,          master_task)
    1090          37 :       call broadcast_scalar(saltflux_option,      master_task)
    1091          37 :       call broadcast_scalar(ice_ref_salinity,     master_task)
    1092          37 :       call broadcast_scalar(ocn_data_format,      master_task)
    1093          37 :       call broadcast_scalar(bgc_data_type,        master_task)
    1094          37 :       call broadcast_scalar(fe_data_type,         master_task)
    1095          37 :       call broadcast_scalar(ice_data_type,        master_task)
    1096          37 :       call broadcast_scalar(ice_data_conc,        master_task)
    1097          37 :       call broadcast_scalar(ice_data_dist,        master_task)
    1098          37 :       call broadcast_scalar(bgc_data_dir,         master_task)
    1099          37 :       call broadcast_scalar(ocn_data_type,        master_task)
    1100          37 :       call broadcast_scalar(ocn_data_dir,         master_task)
    1101          37 :       call broadcast_scalar(oceanmixed_file,      master_task)
    1102          37 :       call broadcast_scalar(restore_ocn,          master_task)
    1103          37 :       call broadcast_scalar(trestore,             master_task)
    1104          37 :       call broadcast_scalar(restore_ice,          master_task)
    1105          37 :       call broadcast_scalar(debug_forcing,        master_task)
    1106          37 :       call broadcast_array (latpnt(1:2),          master_task)
    1107          37 :       call broadcast_array (lonpnt(1:2),          master_task)
    1108          37 :       call broadcast_scalar(runid,                master_task)
    1109          37 :       call broadcast_scalar(runtype,              master_task)
    1110             :       !call broadcast_scalar(nu_diag,              master_task)
    1111             : 
    1112             :       ! tracers
    1113          37 :       call broadcast_scalar(tr_iage,              master_task)
    1114          37 :       call broadcast_scalar(restart_age,          master_task)
    1115          37 :       call broadcast_scalar(tr_FY,                master_task)
    1116          37 :       call broadcast_scalar(restart_FY,           master_task)
    1117          37 :       call broadcast_scalar(tr_lvl,               master_task)
    1118          37 :       call broadcast_scalar(restart_lvl,          master_task)
    1119          37 :       call broadcast_scalar(tr_pond_lvl,          master_task)
    1120          37 :       call broadcast_scalar(restart_pond_lvl,     master_task)
    1121          37 :       call broadcast_scalar(tr_pond_topo,         master_task)
    1122          37 :       call broadcast_scalar(restart_pond_topo,    master_task)
    1123          37 :       call broadcast_scalar(tr_snow,              master_task)
    1124          37 :       call broadcast_scalar(restart_snow,         master_task)
    1125          37 :       call broadcast_scalar(tr_iso,               master_task)
    1126          37 :       call broadcast_scalar(restart_iso,          master_task)
    1127          37 :       call broadcast_scalar(tr_aero,              master_task)
    1128          37 :       call broadcast_scalar(restart_aero,         master_task)
    1129          37 :       call broadcast_scalar(tr_fsd,               master_task)
    1130          37 :       call broadcast_scalar(restart_fsd,          master_task)
    1131          37 :       call broadcast_scalar(ncat,                 master_task)
    1132          37 :       call broadcast_scalar(nfsd,                 master_task)
    1133          37 :       call broadcast_scalar(nilyr,                master_task)
    1134          37 :       call broadcast_scalar(nslyr,                master_task)
    1135          37 :       call broadcast_scalar(nblyr,                master_task)
    1136          37 :       call broadcast_scalar(n_iso,                master_task)
    1137          37 :       call broadcast_scalar(n_aero,               master_task)
    1138          37 :       call broadcast_scalar(n_zaero,              master_task)
    1139          37 :       call broadcast_scalar(n_algae,              master_task)
    1140          37 :       call broadcast_scalar(n_doc,                master_task)
    1141          37 :       call broadcast_scalar(n_dic,                master_task)
    1142          37 :       call broadcast_scalar(n_don,                master_task)
    1143          37 :       call broadcast_scalar(n_fed,                master_task)
    1144          37 :       call broadcast_scalar(n_fep,                master_task)
    1145          37 :       call broadcast_scalar(a_rapid_mode,         master_task)
    1146          37 :       call broadcast_scalar(floediam,             master_task)
    1147          37 :       call broadcast_scalar(hfrazilmin,           master_task)
    1148          37 :       call broadcast_scalar(Rac_rapid_mode,       master_task)
    1149          37 :       call broadcast_scalar(aspect_rapid_mode,    master_task)
    1150          37 :       call broadcast_scalar(dSdt_slow_mode,       master_task)
    1151          37 :       call broadcast_scalar(phi_c_slow_mode,      master_task)
    1152          37 :       call broadcast_scalar(phi_i_mushy,          master_task)
    1153          37 :       call broadcast_scalar(Tliquidus_max,        master_task)
    1154          37 :       call broadcast_scalar(sw_redist,            master_task)
    1155          37 :       call broadcast_scalar(sw_frac,              master_task)
    1156          37 :       call broadcast_scalar(sw_dtemp,             master_task)
    1157             : 
    1158             : #ifdef CESMCOUPLED
    1159             :       pointer_file = trim(pointer_file) // trim(inst_suffix)
    1160             : #endif
    1161             : 
    1162             :       !-----------------------------------------------------------------
    1163             :       ! update defaults
    1164             :       !-----------------------------------------------------------------
    1165             : 
    1166          37 :       if (trim(ice_ic)        == 'default') ice_ic        = 'internal'
    1167          37 :       if (trim(ice_data_conc) == 'default') ice_data_conc = 'parabolic'
    1168          37 :       if (trim(ice_data_dist) == 'default') ice_data_dist = 'uniform'
    1169          37 :       if (trim(ice_data_type) == 'default') ice_data_type = 'latsst'
    1170             : 
    1171             :       !-----------------------------------------------------------------
    1172             :       ! verify inputs
    1173             :       !-----------------------------------------------------------------
    1174             : 
    1175          37 :       if (my_task == master_task) then
    1176           7 :          if (trim(diag_type) == 'file') then
    1177           0 :             write(ice_stdout,*) 'Diagnostic output will be in file ',diag_file
    1178           0 :             open (nu_diag, file=diag_file, status='unknown')
    1179             :          endif
    1180           7 :          write(nu_diag,*) '--------------------------------'
    1181           7 :          write(nu_diag,*) '   ',subname
    1182           7 :          write(nu_diag,*) '  CICE model diagnostic output  '
    1183           7 :          write(nu_diag,*) '--------------------------------'
    1184           7 :          write(nu_diag,*) ' '
    1185             :       endif
    1186             : 
    1187          37 :       if (trim(runtype) == 'continue') then
    1188          12 :          if (my_task == master_task) then
    1189           2 :             write(nu_diag,*) subname//'NOTE: runtype=continue, setting restart=.true.'
    1190           2 :             if (.not. use_restart_time) &
    1191           2 :                write(nu_diag,*) subname//'NOTE: runtype=continue, setting use_restart_time=.true.'
    1192           2 :             write(nu_diag,*) ' '
    1193             :          endif
    1194          12 :          restart = .true.
    1195          12 :          use_restart_time = .true.
    1196          25 :       elseif (trim(runtype) == 'initial') then
    1197          25 :          if (ice_ic == 'none' .or. ice_ic == 'internal') then
    1198           8 :             if (my_task == master_task) then
    1199           1 :                write(nu_diag,*) subname//'NOTE: ice_ic = none or internal, setting restart flags to .false.'
    1200           1 :                if (.not. use_restart_time) &
    1201           1 :                   write(nu_diag,*) subname//'NOTE: ice_ic = none or internal, setting use_restart_time=.false.'
    1202           1 :                write(nu_diag,*) ' '
    1203             :             endif
    1204           8 :             use_restart_time = .false.
    1205           8 :             restart = .false.
    1206           8 :             restart_iso =  .false.
    1207           8 :             restart_aero =  .false.
    1208           8 :             restart_fsd =  .false.
    1209           8 :             restart_age =  .false.
    1210           8 :             restart_fy =  .false.
    1211           8 :             restart_lvl =  .false.
    1212           8 :             restart_pond_lvl =  .false.
    1213           8 :             restart_pond_topo =  .false.
    1214           8 :             restart_snow = .false.
    1215             : ! tcraig, OK to leave as true, needed for boxrestore case
    1216             : !            restart_ext =  .false.
    1217             :          else
    1218          17 :             if (my_task == master_task) then
    1219           4 :                write(nu_diag,*) subname//'NOTE: ice_ic /= none or internal, setting restart=.true.'
    1220           4 :                write(nu_diag,*) ' '
    1221             :             endif
    1222          17 :             restart = .true.
    1223             :          endif
    1224             :       else
    1225           0 :          if (my_task == master_task) then
    1226           0 :             write(nu_diag,*) subname//' ERROR: runtype unknown = ',trim(runtype)
    1227             :          endif
    1228           0 :          abort_list = trim(abort_list)//":1"
    1229             :       endif
    1230             : 
    1231          37 :       if (ktransport <= 0) then
    1232           0 :          advection = 'none'
    1233             :       endif
    1234             : 
    1235          37 :       if (ktransport > 0 .and. advection /= 'remap' .and. advection /= 'upwind') then
    1236           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: invalid advection=',trim(advection)
    1237           0 :          abort_list = trim(abort_list)//":3"
    1238             :       endif
    1239             : 
    1240          37 :       if (ncat == 1 .and. kitd == 1) then
    1241           0 :          if (my_task == master_task) then
    1242           0 :             write(nu_diag,*) subname//' ERROR: kitd incompatability: ncat=1 and kitd=1'
    1243           0 :             write(nu_diag,*) subname//' ERROR:   Remapping the ITD is not allowed for ncat=1.'
    1244           0 :             write(nu_diag,*) subname//' ERROR:   Use kitd = 0 (delta function ITD) with kcatbound = 0'
    1245           0 :             write(nu_diag,*) subname//' ERROR:   or for column configurations use kcatbound = -1'
    1246             :          endif
    1247           0 :          abort_list = trim(abort_list)//":4"
    1248             :       endif
    1249             : 
    1250          37 :       if (ncat /= 1 .and. kcatbound == -1) then
    1251           0 :          if (my_task == master_task) then
    1252           0 :             write(nu_diag,*) subname//' ERROR: ITD required for ncat > 1'
    1253           0 :             write(nu_diag,*) subname//' ERROR:   ncat=',ncat,' kcatbound=',kcatbound
    1254           0 :             write(nu_diag,*) subname//' ERROR:   Please review user guide'
    1255             :          endif
    1256           0 :          abort_list = trim(abort_list)//":5"
    1257             :       endif
    1258             : 
    1259          37 :       if (kdyn == 2 .and. revised_evp) then
    1260           0 :          if (my_task == master_task) then
    1261           0 :             write(nu_diag,*) subname//' WARNING: revised_evp = T with EAP dynamics'
    1262           0 :             write(nu_diag,*) subname//' WARNING:   revised_evp is ignored'
    1263             :          endif
    1264           0 :          revised_evp = .false.
    1265             :       endif
    1266             : 
    1267          37 :       if (kdyn > 3) then
    1268           0 :          if (my_task == master_task) then
    1269           0 :             write(nu_diag,*) subname//' WARNING: kdyn out of range'
    1270             :          endif
    1271           0 :          abort_list = trim(abort_list)//":33"
    1272             :       endif
    1273             : 
    1274          37 :       if (seabed_stress) then
    1275           0 :          if (seabed_stress_method /= 'LKD' .and. seabed_stress_method /= 'probabilistic') then
    1276           0 :             if (my_task == master_task) then
    1277           0 :                write(nu_diag,*) subname//' ERROR: invalid seabed stress method'
    1278           0 :                write(nu_diag,*) subname//' ERROR: seabed_stress_method should be LKD or probabilistic'
    1279             :             endif
    1280           0 :             abort_list = trim(abort_list)//":48"
    1281             :          endif
    1282             :       endif
    1283             : 
    1284          37 :       if (grid_ice == 'CD') then
    1285           0 :          if (my_task == master_task) then
    1286           0 :             write(nu_diag,*) subname//' ERROR: grid_ice = CD not supported yet'
    1287             :          endif
    1288           0 :          abort_list = trim(abort_list)//":47"
    1289          37 :       elseif (grid_ice == 'C_override_D') then
    1290           0 :          if (my_task == master_task) then
    1291           0 :             write(nu_diag,*) subname//' WARNING: using grid_ice = CD, not supported'
    1292             :          endif
    1293           0 :          grid_ice = 'CD'
    1294             :       endif
    1295             : 
    1296          37 :       if (grid_ice == 'C' .or. grid_ice == 'CD') then
    1297           0 :          if (kdyn > 1) then
    1298           0 :             if (my_task == master_task) then
    1299           0 :                write(nu_diag,*) subname//' ERROR: grid_ice = C | CD only supported with kdyn<=1 (evp or off)'
    1300           0 :                write(nu_diag,*) subname//' ERROR: kdyn and grid_ice inconsistency'
    1301             :             endif
    1302           0 :             abort_list = trim(abort_list)//":46"
    1303             :          endif
    1304           0 :          if (visc_method /= 'avg_zeta' .and. visc_method /= 'avg_strength') then
    1305           0 :             if (my_task == master_task) then
    1306           0 :                write(nu_diag,*) subname//' ERROR: invalid method for viscosities'
    1307           0 :                write(nu_diag,*) subname//' ERROR: visc_method should be avg_zeta or avg_strength'
    1308             :             endif
    1309           0 :             abort_list = trim(abort_list)//":44"
    1310             :          endif
    1311             :       endif
    1312             : 
    1313          37 :       capping = -9.99e30
    1314          37 :       if (kdyn == 1 .or. kdyn == 3) then
    1315          37 :          if (capping_method == 'max') then
    1316          37 :             capping = c1
    1317           0 :          elseif (capping_method == 'sum') then
    1318           0 :             capping = c0
    1319             :          else
    1320           0 :             if (my_task == master_task) then
    1321           0 :                write(nu_diag,*) subname//' ERROR: invalid method for capping viscosities'
    1322           0 :                write(nu_diag,*) subname//' ERROR: capping_method should be equal to max or sum'
    1323             :             endif
    1324           0 :             abort_list = trim(abort_list)//":45"
    1325             :          endif
    1326             :       endif
    1327             : 
    1328          37 :       rplvl  = 0
    1329          37 :       rptopo = 0
    1330          37 :       if (tr_pond_lvl ) rplvl  = 1
    1331          37 :       if (tr_pond_topo) rptopo = 1
    1332             : 
    1333          37 :       tr_pond = .false. ! explicit melt ponds
    1334          37 :       if (rplvl + rptopo > 0) tr_pond = .true.
    1335             : 
    1336          37 :       if (rplvl + rptopo > 1) then
    1337           0 :          if (my_task == master_task) then
    1338           0 :             write(nu_diag,*) subname//' ERROR: Must use only one melt pond scheme'
    1339             :          endif
    1340           0 :          abort_list = trim(abort_list)//":6"
    1341             :       endif
    1342             : 
    1343          37 :       if (tr_pond_lvl .and. .not. tr_lvl) then
    1344           0 :          if (my_task == master_task) then
    1345           0 :             write(nu_diag,*) subname//' ERROR: tr_pond_lvl=T but tr_lvl=F'
    1346             :          endif
    1347           0 :          abort_list = trim(abort_list)//":30"
    1348             :       endif
    1349             : 
    1350             : ! tcraig - this was originally implemented by resetting hs0=0. EH says it might be OK
    1351             : ! to not reset it but extra calculations are done and it might not be bfb.  In our
    1352             : ! testing, we should explicitly set hs0 to 0. when setting tr_pond_lvl=T, and otherwise
    1353             : ! this will abort (safest option until additional testing is done)
    1354          37 :       if (tr_pond_lvl .and. abs(hs0) > puny) then
    1355           0 :          if (my_task == master_task) then
    1356           0 :             write(nu_diag,*) subname//' ERROR: tr_pond_lvl=T and hs0 /= 0'
    1357             :          endif
    1358           0 :          abort_list = trim(abort_list)//":7"
    1359             :       endif
    1360             : 
    1361          37 :       if (shortwave(1:4) /= 'dEdd' .and. tr_pond .and. calc_tsfc) then
    1362           0 :          if (my_task == master_task) then
    1363           0 :             write(nu_diag,*) subname//' ERROR: tr_pond=T, calc_tsfc=T, invalid shortwave'
    1364           0 :             write(nu_diag,*) subname//' ERROR:   Must use shortwave=dEdd or dEdd_snicar_ad'
    1365             :          endif
    1366           0 :          abort_list = trim(abort_list)//":8"
    1367             :       endif
    1368             : 
    1369          37 :       if (snwredist(1:3) == 'ITD' .and. .not. tr_snow) then
    1370           0 :          if (my_task == master_task) then
    1371           0 :             write (nu_diag,*) 'ERROR: snwredist on but tr_snow=F'
    1372           0 :             write (nu_diag,*) 'ERROR: Use tr_snow=T for snow redistribution'
    1373             :          endif
    1374           0 :          abort_list = trim(abort_list)//":37"
    1375             :       endif
    1376          37 :       if (snwredist(1:4) == 'bulk' .and. .not. tr_lvl) then
    1377           0 :          if (my_task == master_task) then
    1378           0 :             write (nu_diag,*) 'ERROR: snwredist=bulk but tr_lvl=F'
    1379           0 :             write (nu_diag,*) 'ERROR: Use tr_lvl=T for snow redistribution'
    1380             :          endif
    1381           0 :          abort_list = trim(abort_list)//":38"
    1382             :       endif
    1383          37 :       if (snwredist(1:6) == 'ITDrdg' .and. .not. tr_lvl) then
    1384           0 :          if (my_task == master_task) then
    1385           0 :             write (nu_diag,*) 'ERROR: snwredist=ITDrdg but tr_lvl=F'
    1386           0 :             write (nu_diag,*) 'ERROR: Use tr_lvl=T for snow redistribution'
    1387             :          endif
    1388           0 :          abort_list = trim(abort_list)//":39"
    1389             :       endif
    1390          37 :       if (use_smliq_pnd .and. .not. snwgrain) then
    1391           0 :          if (my_task == master_task) then
    1392           0 :             write (nu_diag,*) 'ERROR: use_smliq_pnd = T but'
    1393           0 :             write (nu_diag,*) 'ERROR: snow metamorphosis not used'
    1394           0 :             write (nu_diag,*) 'ERROR: Use snwgrain=T with smliq for ponds'
    1395             :          endif
    1396           0 :          abort_list = trim(abort_list)//":40"
    1397             :       endif
    1398          37 :       if (use_smliq_pnd .and. .not. tr_snow) then
    1399           0 :          if (my_task == master_task) then
    1400           0 :             write (nu_diag,*) 'ERROR: use_smliq_pnd = T but'
    1401           0 :             write (nu_diag,*) 'ERROR: snow tracers are not active'
    1402           0 :             write (nu_diag,*) 'ERROR: Use tr_snow=T with smliq for ponds'
    1403             :          endif
    1404           0 :          abort_list = trim(abort_list)//":41"
    1405             :       endif
    1406          37 :       if (snwgrain .and. .not. tr_snow) then
    1407           0 :          if (my_task == master_task) then
    1408           0 :             write (nu_diag,*) 'ERROR: snwgrain=T but tr_snow=F'
    1409           0 :             write (nu_diag,*) 'ERROR: Use tr_snow=T for snow metamorphosis'
    1410             :          endif
    1411           0 :          abort_list = trim(abort_list)//":42"
    1412             :       endif
    1413             :       if (trim(snw_aging_table) /= 'test' .and. &
    1414             :           trim(snw_aging_table) /= 'snicar' .and. &   ! LCOV_EXCL_LINE
    1415             :           trim(snw_aging_table) /= 'file') then
    1416           0 :          if (my_task == master_task) then
    1417           0 :             write (nu_diag,*) 'ERROR: unknown snw_aging_table = '//trim(snw_aging_table)
    1418             :          endif
    1419           0 :          abort_list = trim(abort_list)//":43"
    1420             :       endif
    1421             : 
    1422          37 :       if (tr_iso .and. n_iso==0) then
    1423           0 :          if (my_task == master_task) then
    1424           0 :             write(nu_diag,*) subname//' ERROR: isotopes activated but'
    1425           0 :             write(nu_diag,*) subname//' ERROR:   not allocated in tracer array.'
    1426           0 :             write(nu_diag,*) subname//' ERROR:   if tr_iso, n_iso must be > 0.'
    1427             :          endif
    1428           0 :          abort_list = trim(abort_list)//":31"
    1429             :       endif
    1430             : 
    1431          37 :       if (tr_aero .and. n_aero==0) then
    1432           0 :          if (my_task == master_task) then
    1433           0 :             write(nu_diag,*) subname//' ERROR: aerosols activated but'
    1434           0 :             write(nu_diag,*) subname//' ERROR:   not allocated in tracer array.'
    1435           0 :             write(nu_diag,*) subname//' ERROR:   if tr_aero, n_aero must be > 0.'
    1436             :          endif
    1437           0 :          abort_list = trim(abort_list)//":9"
    1438             :       endif
    1439             : 
    1440          37 :       if (ncat < 1) then
    1441           0 :          if (my_task == master_task) then
    1442           0 :             write(nu_diag,*) subname//' ERROR: ncat < 1'
    1443             :          endif
    1444           0 :          abort_list = trim(abort_list)//":32"
    1445             :       endif
    1446             : 
    1447          37 :       if (nilyr < 1) then
    1448           0 :          if (my_task == master_task) then
    1449           0 :             write(nu_diag,*) subname//' ERROR: nilyr < 1'
    1450             :          endif
    1451           0 :          abort_list = trim(abort_list)//":2"
    1452             :       endif
    1453             : 
    1454          37 :       if (nslyr < 1) then
    1455           0 :          if (my_task == master_task) then
    1456           0 :             write(nu_diag,*) subname//' ERROR: nslyr < 1'
    1457             :          endif
    1458           0 :          abort_list = trim(abort_list)//":34"
    1459             :       endif
    1460             : 
    1461          37 :       if (nblyr < 1) then
    1462           0 :          if (my_task == master_task) then
    1463           0 :             write(nu_diag,*) subname//' ERROR: nblyr < 1'
    1464           0 :             write(nu_diag,*) subname//' ERROR:   not allowed due to history implementation.'
    1465             :          endif
    1466           0 :          abort_list = trim(abort_list)//":35"
    1467             :       endif
    1468             : 
    1469          37 :       if (nfsd < 1) then
    1470           0 :          if (my_task == master_task) then
    1471           0 :             write(nu_diag,*) subname//' ERROR: nfsd < 1'
    1472           0 :             write(nu_diag,*) subname//' ERROR:   not allowed due to history implementation.'
    1473             :          endif
    1474           0 :          abort_list = trim(abort_list)//":36"
    1475             :       endif
    1476             : 
    1477          37 :       if (shortwave(1:4) /= 'dEdd' .and. tr_aero) then
    1478           0 :          if (my_task == master_task) then
    1479           0 :             write(nu_diag,*) subname//' ERROR: tr_aero=T, invalid shortwave'
    1480           0 :             write(nu_diag,*) subname//' ERROR:   Must use shortwave=dEdd or dEdd_snicar_ad'
    1481             :          endif
    1482           0 :          abort_list = trim(abort_list)//":10"
    1483             :       endif
    1484             : 
    1485          37 :       if (shortwave(1:4) /= 'dEdd' .and. snwgrain) then
    1486           0 :          if (my_task == master_task) then
    1487           0 :             write (nu_diag,*) subname//' ERROR: snow grain radius is activated'
    1488           0 :             write (nu_diag,*) subname//' ERROR:   Must use shortwave=dEdd or dEdd_snicar_ad'
    1489             :          endif
    1490           0 :          abort_list = trim(abort_list)//":29"
    1491             :       endif
    1492             : 
    1493             :       if ((rfracmin < -puny .or. rfracmin > c1+puny) .or. &
    1494             :           (rfracmax < -puny .or. rfracmax > c1+puny) .or. &   ! LCOV_EXCL_LINE
    1495             :           (rfracmin > rfracmax)) then
    1496           0 :          if (my_task == master_task) then
    1497           0 :             write(nu_diag,*) subname//' ERROR: rfracmin, rfracmax must be between 0 and 1'
    1498           0 :             write(nu_diag,*) subname//' ERROR:   and rfracmax >= rfracmin'
    1499             :          endif
    1500           0 :          abort_list = trim(abort_list)//":11"
    1501             :       endif
    1502          37 :       rfracmin = min(max(rfracmin,c0),c1)
    1503          37 :       rfracmax = min(max(rfracmax,c0),c1)
    1504             : 
    1505          37 :       if (trim(atm_data_type) == 'monthly' .and. calc_strair) then
    1506           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: atm_data_type=monthly and calc_strair=T'
    1507           0 :          abort_list = trim(abort_list)//":12"
    1508             :       endif
    1509             : 
    1510          37 :       if (ktherm == 2 .and. .not. calc_Tsfc) then
    1511           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: ktherm = 2 and calc_Tsfc=F'
    1512           0 :          abort_list = trim(abort_list)//":13"
    1513             :       endif
    1514             : 
    1515             : ! ech: allow inconsistency for testing sensitivities.  It's not recommended for science runs
    1516          37 :       if (ktherm == 1 .and. trim(tfrz_option) /= 'linear_salt') then
    1517           0 :          if (my_task == master_task) then
    1518           0 :             write(nu_diag,*) subname//' WARNING: ktherm = 1 and tfrz_option = ',trim(tfrz_option)
    1519           0 :             write(nu_diag,*) subname//' WARNING:   For consistency, set tfrz_option = linear_salt'
    1520             :          endif
    1521             :       endif
    1522          37 :       if (ktherm == 2 .and. trim(tfrz_option) /= 'mushy') then
    1523           0 :          if (my_task == master_task) then
    1524           0 :             write(nu_diag,*) subname//' WARNING: ktherm = 2 and tfrz_option = ',trim(tfrz_option)
    1525           0 :             write(nu_diag,*) subname//' WARNING:   For consistency, set tfrz_option = mushy'
    1526             :          endif
    1527             :       endif
    1528          37 :       if (ktherm == 1 .and. trim(saltflux_option) /= 'constant') then
    1529           0 :          if (my_task == master_task) then
    1530           0 :             write(nu_diag,*) subname//' WARNING: ktherm = 1 and saltflux_option = ',trim(saltflux_option)
    1531           0 :             write(nu_diag,*) subname//' WARNING:   For consistency, set saltflux_option = constant'
    1532             :          endif
    1533             :       endif
    1534          37 :       if (ktherm == 1 .and. .not.sw_redist) then
    1535           0 :          if (my_task == master_task) then
    1536           0 :             write(nu_diag,*) subname//' WARNING: ktherm = 1 and sw_redist = ',sw_redist
    1537           0 :             write(nu_diag,*) subname//' WARNING:   For consistency, set sw_redist = .true.'
    1538             :          endif
    1539             :       endif
    1540             : 
    1541          37 :       if (trim(atmbndy) == 'default') then
    1542           0 :          if (my_task == master_task) then
    1543           0 :             write(nu_diag,*) subname//' WARNING: atmbndy = default is deprecated'
    1544           0 :             write(nu_diag,*) subname//' WARNING:   setting atmbndy = similarity'
    1545             :          endif
    1546           0 :          atmbndy = 'similarity'
    1547             :       endif
    1548             : 
    1549          37 :       if (formdrag) then
    1550           0 :          if (trim(atmbndy) == 'constant') then
    1551           0 :             if (my_task == master_task) write(nu_diag,*) subname//' ERROR: formdrag=T and atmbndy=constant'
    1552           0 :             abort_list = trim(abort_list)//":14"
    1553             :          endif
    1554             : 
    1555           0 :          if (.not. calc_strair) then
    1556           0 :             if (my_task == master_task) write(nu_diag,*) subname//' ERROR: formdrag=T and calc_strair=F'
    1557           0 :             abort_list = trim(abort_list)//":15"
    1558             :          endif
    1559             : 
    1560           0 :          if (.not. tr_pond) then
    1561           0 :             if (my_task == master_task) write(nu_diag,*) subname//' ERROR: formdrag=T and tr_pond=F'
    1562           0 :             abort_list = trim(abort_list)//":16"
    1563             :          endif
    1564             : 
    1565           0 :          if (.not. tr_lvl) then
    1566           0 :             if (my_task == master_task) write(nu_diag,*) subname//' ERROR: formdrag=T and tr_lvl=F'
    1567           0 :             abort_list = trim(abort_list)//":18"
    1568             :          endif
    1569             :       endif
    1570             : 
    1571          37 :       if (trim(fbot_xfer_type) == 'Cdn_ocn' .and. .not. formdrag)  then
    1572           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: formdrag=F and fbot_xfer_type=Cdn_ocn'
    1573           0 :          abort_list = trim(abort_list)//":19"
    1574             :       endif
    1575             : 
    1576          37 :       if(history_precision .ne. 4 .and. history_precision .ne. 8) then
    1577           0 :          write (nu_diag,*) subname//' ERROR: bad value for history_precision, allowed values: 4, 8'
    1578           0 :          abort_list = trim(abort_list)//":22"
    1579             :       endif
    1580             : 
    1581         222 :       do n = 1,max_nstrm
    1582         185 :          if(histfreq_base(n) /= 'init' .and. histfreq_base(n) /= 'zero') then
    1583           0 :             write (nu_diag,*) subname//' ERROR: bad value for histfreq_base, allowed values: init, zero: '//trim(histfreq_base(n))
    1584           0 :             abort_list = trim(abort_list)//":24"
    1585             :          endif
    1586             : 
    1587         185 :          if(dumpfreq_base(n) /= 'init' .and. dumpfreq_base(n) /= 'zero') then
    1588           0 :             write (nu_diag,*) subname//' ERROR: bad value for dumpfreq_base, allowed values: init, zero: '//trim(dumpfreq_base(n))
    1589           0 :             abort_list = trim(abort_list)//":25"
    1590             :          endif
    1591             : 
    1592         222 :          if (.not.(scan(dumpfreq(n)(1:1),'ymdhx1YMDHX') == 1 .and. (dumpfreq(n)(2:2) == '1' .or. dumpfreq(n)(2:2) == ' '))) then
    1593           0 :             if (my_task == master_task) then
    1594           0 :                write(nu_diag,*) subname//' WARNING: unrecognized dumpfreq=', trim(dumpfreq(n))
    1595           0 :                write(nu_diag,*) subname//' WARNING:   No restarts files will be written for this stream'
    1596           0 :                write(nu_diag,*) subname//' WARNING:   Allowed values : y,m,d,h,x,1 followed by an optional 1'
    1597             :             endif
    1598           0 :             dumpfreq(n) = 'x'
    1599             :          endif
    1600             :       enddo
    1601             : 
    1602          37 :       if(trim(hist_time_axis) /= 'begin' .and. trim(hist_time_axis) /= 'middle' .and. trim(hist_time_axis) /= 'end') then
    1603           0 :          write (nu_diag,*) subname//' ERROR: hist_time_axis value not valid = '//trim(hist_time_axis)
    1604           0 :          abort_list = trim(abort_list)//":29"
    1605             :       endif
    1606             : 
    1607             :       ! Implicit solver input validation
    1608          37 :       if (kdyn == 3) then
    1609           0 :          if (.not. (trim(algo_nonlin) == 'picard' .or. trim(algo_nonlin) == 'anderson')) then
    1610           0 :             if (my_task == master_task) then
    1611           0 :                write(nu_diag,*) subname//' ERROR: unknown algo_nonlin: '//algo_nonlin
    1612           0 :                write(nu_diag,*) subname//' ERROR:   allowed values: ''picard'', ''anderson'''
    1613             :             endif
    1614           0 :             abort_list = trim(abort_list)//":60"
    1615             :          endif
    1616             : 
    1617           0 :          if (trim(algo_nonlin) == 'picard') then
    1618             :             ! Picard solver is implemented in the Anderson solver; reset number of saved residuals to zero
    1619           0 :             dim_andacc = 0
    1620             :          endif
    1621             : 
    1622           0 :          if (.not. (trim(precond) == 'ident' .or. trim(precond) == 'diag' .or. trim(precond) == 'pgmres')) then
    1623           0 :             if (my_task == master_task) then
    1624           0 :                write(nu_diag,*) subname//' ERROR: unknown precond: '//precond
    1625           0 :                write(nu_diag,*) subname//' ERROR:   allowed values: ''ident'', ''diag'', ''pgmres'''
    1626             :             endif
    1627           0 :             abort_list = trim(abort_list)//":61"
    1628             :          endif
    1629             : 
    1630           0 :          if (.not. (trim(ortho_type) == 'cgs' .or. trim(ortho_type) == 'mgs')) then
    1631           0 :             if (my_task == master_task) then
    1632           0 :                write(nu_diag,*) subname//' ERROR: unknown ortho_type: '//ortho_type
    1633           0 :                write(nu_diag,*) subname//' ERROR:   allowed values: ''cgs'', ''mgs'''
    1634             :             endif
    1635           0 :             abort_list = trim(abort_list)//":62"
    1636             :          endif
    1637             :       endif
    1638             : 
    1639          37 :       ice_IOUnitsMinUnit = numin
    1640          37 :       ice_IOUnitsMaxUnit = numax
    1641             : 
    1642          37 :       call icepack_init_parameters(Cf_in=Cf)
    1643          37 :       call icepack_init_parameters(ksno_in=ksno)
    1644          37 :       call icepack_warnings_flush(nu_diag)
    1645          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname//'Icepack Abort1', &
    1646           0 :          file=__FILE__, line=__LINE__)
    1647             : 
    1648          37 :       wave_spec = .false.
    1649          37 :       if (tr_fsd .and. (trim(wave_spec_type) /= 'none')) wave_spec = .true.
    1650          37 :       if (tr_fsd .and. (trim(wave_spec_type) == 'none')) then
    1651           0 :             if (my_task == master_task) then
    1652           0 :                write(nu_diag,*) subname//' WARNING: tr_fsd=T but wave_spec=F - not recommended'
    1653             :             endif
    1654             :       end if
    1655             : 
    1656             :       ! compute grid locations for thermo, u and v fields
    1657             : 
    1658          37 :       grid_ice_thrm = 'T'
    1659          37 :       if (grid_ice == 'A') then
    1660           0 :          grid_ice_dynu = 'T'
    1661           0 :          grid_ice_dynv = 'T'
    1662          37 :       elseif (grid_ice == 'B') then
    1663          37 :          grid_ice_dynu = 'U'
    1664          37 :          grid_ice_dynv = 'U'
    1665           0 :       elseif (grid_ice == 'C') then
    1666           0 :          grid_ice_dynu = 'E'
    1667           0 :          grid_ice_dynv = 'N'
    1668           0 :       elseif (grid_ice == 'CD') then
    1669           0 :          grid_ice_dynu = 'NE'
    1670           0 :          grid_ice_dynv = 'NE'
    1671             :       else
    1672           0 :          if (my_task == master_task) then
    1673           0 :             write(nu_diag,*) subname//' ERROR: unknown grid_ice: '//trim(grid_ice)
    1674             :          endif
    1675           0 :          abort_list = trim(abort_list)//":64"
    1676             :       endif
    1677             : 
    1678          37 :       grid_atm_thrm = 'T'
    1679          37 :       if (grid_atm == 'A') then
    1680          37 :          grid_atm_dynu = 'T'
    1681          37 :          grid_atm_dynv = 'T'
    1682           0 :       elseif (grid_atm == 'B') then
    1683           0 :          grid_atm_dynu = 'U'
    1684           0 :          grid_atm_dynv = 'U'
    1685           0 :       elseif (grid_atm == 'C') then
    1686           0 :          grid_atm_dynu = 'E'
    1687           0 :          grid_atm_dynv = 'N'
    1688           0 :       elseif (grid_atm == 'CD') then
    1689           0 :          grid_atm_dynu = 'NE'
    1690           0 :          grid_atm_dynv = 'NE'
    1691             :       else
    1692           0 :          if (my_task == master_task) then
    1693           0 :             write(nu_diag,*) subname//' ERROR: unknown grid_atm: '//trim(grid_atm)
    1694             :          endif
    1695           0 :          abort_list = trim(abort_list)//":65"
    1696             :       endif
    1697             : 
    1698          37 :       grid_ocn_thrm = 'T'
    1699          37 :       if (grid_ocn == 'A') then
    1700          21 :          grid_ocn_dynu = 'T'
    1701          21 :          grid_ocn_dynv = 'T'
    1702          16 :       elseif (grid_ocn == 'B') then
    1703          16 :          grid_ocn_dynu = 'U'
    1704          16 :          grid_ocn_dynv = 'U'
    1705           0 :       elseif (grid_ocn == 'C') then
    1706           0 :          grid_ocn_dynu = 'E'
    1707           0 :          grid_ocn_dynv = 'N'
    1708           0 :       elseif (grid_ocn == 'CD') then
    1709           0 :          grid_ocn_dynu = 'NE'
    1710           0 :          grid_ocn_dynv = 'NE'
    1711             :       else
    1712           0 :          if (my_task == master_task) then
    1713           0 :             write(nu_diag,*) subname//' ERROR: unknown grid_ocn: '//trim(grid_ocn)
    1714             :          endif
    1715           0 :          abort_list = trim(abort_list)//":66"
    1716             :       endif
    1717             : 
    1718             :       !-----------------------------------------------------------------
    1719             :       ! spew
    1720             :       !-----------------------------------------------------------------
    1721             : 
    1722          37 :       if (my_task == master_task) then
    1723             : 
    1724           7 :          write(nu_diag,*) ' Overview of model configuration with relevant parameters'
    1725           7 :          write(nu_diag,*) '========================================================='
    1726           7 :          write(nu_diag,*) 'For details, compare namelist output below with the'
    1727           7 :          write(nu_diag,*) 'Case Settings section in the model documentation.'
    1728           7 :          write(nu_diag,*) ' '
    1729           7 :          write(nu_diag,*) ' Calendar'
    1730           7 :          write(nu_diag,*) '--------------------------------'
    1731           7 :          write(nu_diag,1020) ' days_per_year    = ',days_per_year,' : number of days in a model year'
    1732           7 :          if (use_leap_years) then
    1733           7 :             tmpstr2 = ' : leap days are included'
    1734             :          else
    1735           0 :             tmpstr2 = ' : leap days are not included'
    1736             :          endif
    1737           7 :          write(nu_diag,1010) ' use_leap_years   = ',use_leap_years,trim(tmpstr2)
    1738           7 :          write(nu_diag,1002) ' dt               = ', dt, ' : model time step'
    1739             : 
    1740           7 :          write(nu_diag,*) ' '
    1741           7 :          write(nu_diag,*) ' Grid, Discretization'
    1742           7 :          write(nu_diag,*) '--------------------------------'
    1743           7 :          tmpstr2 = ' '
    1744           7 :          if (trim(grid_type) == 'rectangular')    tmpstr2 = ' : internally defined, rectangular grid'
    1745           7 :          if (trim(grid_type) == 'regional')       tmpstr2 = ' : user-defined, regional grid'
    1746           7 :          if (trim(grid_type) == 'displaced_pole') tmpstr2 = ' : user-defined grid with rotated north pole'
    1747           7 :          if (trim(grid_type) == 'tripole')        tmpstr2 = ' : user-defined grid with northern hemisphere zipper'
    1748           7 :          write(nu_diag,1030) ' grid_type        = ',trim(grid_type),trim(tmpstr2)
    1749           7 :          write(nu_diag,1030) ' grid_ice         = ',trim(grid_ice)
    1750           7 :          write(nu_diag,1030) '   grid_ice_thrm  = ',trim(grid_ice_thrm)
    1751           7 :          write(nu_diag,1030) '   grid_ice_dynu  = ',trim(grid_ice_dynu)
    1752           7 :          write(nu_diag,1030) '   grid_ice_dynv  = ',trim(grid_ice_dynv)
    1753           7 :          write(nu_diag,1030) ' grid_atm         = ',trim(grid_atm)
    1754           7 :          write(nu_diag,1030) '   grid_atm_thrm  = ',trim(grid_atm_thrm)
    1755           7 :          write(nu_diag,1030) '   grid_atm_dynu  = ',trim(grid_atm_dynu)
    1756           7 :          write(nu_diag,1030) '   grid_atm_dynv  = ',trim(grid_atm_dynv)
    1757           7 :          write(nu_diag,1030) ' grid_ocn         = ',trim(grid_ocn)
    1758           7 :          write(nu_diag,1030) '   grid_ocn_thrm  = ',trim(grid_ocn_thrm)
    1759           7 :          write(nu_diag,1030) '   grid_ocn_dynu  = ',trim(grid_ocn_dynu)
    1760           7 :          write(nu_diag,1030) '   grid_ocn_dynv  = ',trim(grid_ocn_dynv)
    1761           7 :          write(nu_diag,1030) ' kmt_type         = ',trim(kmt_type)
    1762           7 :          if (trim(grid_type) /= 'rectangular') then
    1763           5 :             if (use_bathymetry) then
    1764           0 :                tmpstr2 = ' : bathymetric input data is used'
    1765             :             else
    1766           5 :                tmpstr2 = ' : bathymetric input data is not used'
    1767             :             endif
    1768           5 :             write(nu_diag,1010) ' use_bathymetry   = ', use_bathymetry,trim(tmpstr2)
    1769           5 :             write(nu_diag,1030) ' bathymetry_format= ', trim(bathymetry_format)
    1770             :          endif
    1771           7 :          write(nu_diag,1020) ' nilyr            = ', nilyr, ' : number of ice layers (equal thickness)'
    1772           7 :          write(nu_diag,1020) ' nslyr            = ', nslyr, ' : number of snow layers (equal thickness)'
    1773           7 :          write(nu_diag,1020) ' nblyr            = ', nblyr, ' : number of bio layers (equal thickness)'
    1774           7 :          if (shortwave(1:4) == 'dEdd') &
    1775           7 :          write(nu_diag,*) 'dEdd interior and sfc scattering layers are used in both ice, snow (unequal)'
    1776           7 :          write(nu_diag,1020) ' ncat             = ', ncat,  ' : number of ice categories'
    1777           7 :          if (kcatbound == 0) then
    1778           7 :             tmpstr2 = ' : original ITD category bounds'
    1779           0 :          elseif (kcatbound == 1) then
    1780           0 :             tmpstr2 = ' : round-number category bounds'
    1781           0 :          elseif (kcatbound == 2) then
    1782           0 :             tmpstr2 = ' : WMO standard ITD categories'
    1783           0 :          elseif (kcatbound == -1) then
    1784           0 :             tmpstr2 = ' : one thickness category'
    1785             :          else
    1786           0 :             tmpstr2 = ' : unknown value'
    1787             :          endif
    1788           7 :          write(nu_diag,1020) ' kcatbound        = ', kcatbound,trim(tmpstr2)
    1789           7 :          if (kitd==0) then
    1790           0 :             tmpstr2 = ' : delta function ITD approx'
    1791             :          else
    1792           7 :             tmpstr2 = ' : linear remapping ITD approx'
    1793             :          endif
    1794           7 :          write(nu_diag,1020) ' kitd             = ', kitd,trim(tmpstr2)
    1795             : 
    1796           7 :          if (tr_fsd) then
    1797           0 :             tmpstr2 = ' : floe size distribution is enabled'
    1798             :          else
    1799           7 :             tmpstr2 = ' : floe size distribution is disabled'
    1800             :          endif
    1801           7 :          write(nu_diag,1010) ' tr_fsd           = ', tr_fsd,trim(tmpstr2)
    1802           7 :          write(nu_diag,1020) ' nfsd             = ', nfsd, ' : number of floe size categories'
    1803             : 
    1804           7 :          write(nu_diag,*) ' '
    1805           7 :          write(nu_diag,*) ' Horizontal Dynamics'
    1806           7 :          write(nu_diag,*) '--------------------------------'
    1807           7 :          if (kdyn == 1) then
    1808           7 :             tmpstr2 = ' : elastic-viscous-plastic dynamics'
    1809           0 :          elseif (kdyn == 2) then
    1810           0 :             tmpstr2 = ' : elastic-anisotropic-plastic dynamics'
    1811           0 :          elseif (kdyn == 3) then
    1812           0 :             tmpstr2 = ' : viscous-plastic dynamics'
    1813           0 :          elseif (kdyn < 1) then
    1814           0 :             tmpstr2 = ' : dynamics disabled'
    1815             :          else
    1816           0 :             tmpstr2 = ' : unknown value'
    1817             :          endif
    1818           7 :          write(nu_diag,1020) ' kdyn             = ', kdyn,trim(tmpstr2)
    1819           7 :          if (kdyn >= 1) then
    1820           7 :             if (kdyn == 1 .or. kdyn == 2) then
    1821           7 :                if (revised_evp) then
    1822           0 :                   tmpstr2 = ' : revised EVP formulation used'
    1823           0 :                   write(nu_diag,1002) ' arlx             = ', arlx, ' : stress equation factor alpha'
    1824           0 :                   write(nu_diag,1002) ' brlx             = ', brlx, ' : stress equation factor beta'
    1825             :                else
    1826           7 :                   tmpstr2 = ' : revised EVP formulation not used'
    1827             :                endif
    1828           7 :                write(nu_diag,1010) ' revised_evp      = ', revised_evp,trim(tmpstr2)
    1829             : 
    1830           7 :                if (evp_algorithm == 'standard_2d') then
    1831           7 :                   tmpstr2 = ' : standard 2d EVP solver'
    1832           0 :                elseif (evp_algorithm == 'shared_mem_1d') then
    1833           0 :                   tmpstr2 = ' : vectorized 1d EVP solver'
    1834           0 :                   pgl_global_ext = .true.
    1835             :                else
    1836           0 :                   tmpstr2 = ' : unknown value'
    1837             :                endif
    1838           7 :                write(nu_diag,1031) ' evp_algorithm    = ', trim(evp_algorithm),trim(tmpstr2)
    1839           7 :                write(nu_diag,1020) ' ndtd             = ', ndtd, ' : number of dynamics/advection/ridging/steps per thermo timestep'
    1840           7 :                write(nu_diag,1020) ' ndte             = ', ndte, ' : number of EVP or EAP subcycles'
    1841             :             endif
    1842             : 
    1843           7 :             if (kdyn == 1 .or. kdyn == 3) then
    1844           7 :                write(nu_diag,1030) ' yield_curve      = ', trim(yield_curve), ' : yield curve'
    1845           7 :                if (trim(yield_curve) == 'ellipse') &
    1846           7 :                   write(nu_diag,1002) ' e_yieldcurve     = ', e_yieldcurve, ' : aspect ratio of yield curve'
    1847           7 :                   write(nu_diag,1002) ' e_plasticpot     = ', e_plasticpot, ' : aspect ratio of plastic potential'
    1848             :             endif
    1849             : 
    1850           7 :             if (kdyn == 1) then
    1851           7 :                write(nu_diag,1003) ' deltamin     = ', deltaminEVP, ' : minimum delta for viscosities'
    1852           7 :                write(nu_diag,1030) ' capping_meth = ', trim(capping_method), ' : capping method for viscosities'
    1853           0 :             elseif (kdyn == 3) then
    1854           0 :                write(nu_diag,1003) ' deltamin     = ', deltaminVP, ' : minimum delta for viscosities'
    1855           0 :                write(nu_diag,1030) ' capping_meth = ', trim(capping_method), ' : capping method for viscosities'
    1856             :             endif
    1857             :             !write(nu_diag,1002) ' capping      = ', capping, ' : capping value for viscosities'
    1858             : 
    1859           7 :             write(nu_diag,1002) ' elasticDamp  = ', elasticDamp, ' : coefficient for calculating the parameter E'
    1860             : 
    1861           7 :             if (trim(coriolis) == 'latitude') then
    1862           7 :                tmpstr2 = ' : latitude-dependent Coriolis parameter'
    1863           0 :             elseif (trim(coriolis) == 'contant') then
    1864           0 :                tmpstr2 = ' : = 1.46e-4/s'
    1865           0 :             elseif (trim(coriolis) == 'zero') then
    1866           0 :                tmpstr2 = ' : = 0.0'
    1867             :             else
    1868           0 :                tmpstr2 = ': unknown value'
    1869             :             endif
    1870           7 :             write(nu_diag,1030) ' coriolis         = ',trim(coriolis),trim(tmpstr2)
    1871             : 
    1872           7 :             if (trim(ssh_stress) == 'geostrophic') then
    1873           7 :                tmpstr2 = ' : from ocean velocity'
    1874           0 :             elseif (trim(ssh_stress) == 'coupled') then
    1875           0 :                tmpstr2 = ' : from coupled sea surface height gradients'
    1876             :             else
    1877           0 :                tmpstr2 = ' : unknown value'
    1878             :             endif
    1879           7 :             write(nu_diag,1030) ' ssh_stress       = ',trim(ssh_stress),trim(tmpstr2)
    1880             : 
    1881           7 :             if (trim(advection) == 'remap') then
    1882           7 :                tmpstr2 = ' : linear remapping advection'
    1883           0 :             elseif (trim(advection) == 'upwind') then
    1884           0 :                tmpstr2 = ' : donor cell (upwind) advection'
    1885           0 :             elseif (trim(advection) == 'none') then
    1886           0 :                tmpstr2 = ' : advection disabled by ktransport namelist'
    1887             :             else
    1888           0 :                tmpstr2 = ' : unknown value'
    1889             :             endif
    1890           7 :             write(nu_diag,1030) ' advection        = ', trim(advection),trim(tmpstr2)
    1891             : 
    1892           7 :             if (seabed_stress) then
    1893           0 :                tmpstr2 = ' : use seabed stress parameterization for landfast ice'
    1894             :             else
    1895           7 :                tmpstr2 = ' : no seabed stress parameterization'
    1896             :             endif
    1897           7 :             write(nu_diag,1010) ' seabed_stress    = ', seabed_stress,trim(tmpstr2)
    1898           7 :             if (seabed_stress) then
    1899           0 :                write(nu_diag,1030) ' seabed method    = ',trim(seabed_stress_method)
    1900           0 :                if (seabed_stress_method == 'LKD') then
    1901           0 :                   write(nu_diag,1002) ' k1               = ', k1, ' : free parameter for landfast ice'
    1902           0 :                   write(nu_diag,1002) ' k2               = ', k2, ' : free parameter for landfast ice'
    1903           0 :                   write(nu_diag,1002) ' alphab           = ', alphab, ' : factor for landfast ice'
    1904           0 :                   write(nu_diag,1002) ' threshold_hw     = ', threshold_hw, ' : max water depth for grounding ice'
    1905           0 :                elseif (seabed_stress_method == 'probabilistic') then
    1906           0 :                   write(nu_diag,1002) ' alphab           = ', alphab, ' : factor for landfast ice'
    1907             :                endif
    1908             :             endif
    1909           7 :             if (grid_ice == 'C' .or. grid_ice == 'CD') then
    1910           0 :                write(nu_diag,1030) ' visc_method= ', trim(visc_method),' : viscosities method (U point)'
    1911             :             endif
    1912             : 
    1913           7 :             write(nu_diag,1002) ' Ktens            = ', Ktens, ' : tensile strength factor'
    1914             : 
    1915           7 :             if (kdyn == 3) then
    1916           0 :                write(nu_diag,1020) ' maxits_nonlin    = ', maxits_nonlin,' : max nb of iteration for nonlinear solver'
    1917           0 :                write(nu_diag,1030) ' precond          = ', trim(precond),' : preconditioner for FGMRES'
    1918           0 :                write(nu_diag,1020) ' dim_fgmres       = ', dim_fgmres,' : size of FGMRES Krylov subspace'
    1919           0 :                write(nu_diag,1020) ' dim_pgmres       = ', dim_pgmres,' : size of PGMRES Krylov subspace'
    1920           0 :                write(nu_diag,1020) ' maxits_fgmres    = ', maxits_fgmres,' : max nb of iteration for FGMRES'
    1921           0 :                write(nu_diag,1020) ' maxits_pgmres    = ', maxits_pgmres,' : max nb of iteration for PGMRES'
    1922           0 :                write(nu_diag,1010) ' monitor_nonlin   = ', monitor_nonlin,' : print nonlinear residual norm'
    1923           0 :                write(nu_diag,1010) ' monitor_fgmres   = ', monitor_fgmres,' : print FGMRES residual norm'
    1924           0 :                write(nu_diag,1010) ' monitor_pgmres   = ', monitor_pgmres,' : print PGMRES residual norm'
    1925           0 :                write(nu_diag,1030) ' ortho_type       = ', trim(ortho_type),' : type of orthogonalization for FGMRES'
    1926           0 :                write(nu_diag,1009) ' reltol_nonlin    = ', reltol_nonlin,' : nonlinear stopping criterion'
    1927           0 :                write(nu_diag,1009) ' reltol_fgmres    = ', reltol_fgmres,' : FGMRES stopping criterion'
    1928           0 :                write(nu_diag,1009) ' reltol_pgmres    = ', reltol_pgmres,' : PGMRES stopping criterion'
    1929           0 :                write(nu_diag,1030) ' algo_nonlin      = ', trim(algo_nonlin),' : nonlinear algorithm'
    1930           0 :                write(nu_diag,1010) ' use_mean_vrel    = ', use_mean_vrel,' : use mean of previous 2 iterates to compute vrel'
    1931           0 :                if (algo_nonlin == 'anderson') then
    1932           0 :                   write(nu_diag,1020) ' fpfunc_andacc    = ', fpfunc_andacc,' : fixed point function for Anderson acceleration'
    1933           0 :                   write(nu_diag,1020) ' dim_andacc       = ', dim_andacc,' : size of Anderson minimization matrix'
    1934           0 :                   write(nu_diag,1009) ' reltol_andacc    = ', reltol_andacc,' : relative tolerance for Anderson acceleration'
    1935           0 :                   write(nu_diag,1000) ' damping_andacc   = ', damping_andacc,' : damping factor for Anderson acceleration'
    1936           0 :                   write(nu_diag,1020) ' start_andacc     = ', start_andacc,' : nonlinear iteration at which acceleration starts'
    1937             :                endif
    1938             :             endif
    1939             : 
    1940             :          endif ! kdyn enabled
    1941             : 
    1942           7 :          write(nu_diag,*) ' '
    1943           7 :          write(nu_diag,*) ' Mechanical Deformation (Ridging) and Ice Strength'
    1944           7 :          write(nu_diag,*) '--------------------------------------------------'
    1945           7 :          if (kridge == 1) then
    1946           7 :             tmpstr2 = ' : ridging enabled'
    1947             :          else
    1948           0 :             tmpstr2 = ' : ridging disabled'
    1949             :          endif
    1950           7 :          write(nu_diag,1010) ' tr_lvl           = ', tr_lvl,' : ridging related tracers'
    1951           7 :          write(nu_diag,1020) ' kridge           = ', kridge,trim(tmpstr2)
    1952           7 :          if (kridge == 1) then
    1953           7 :             if (krdg_partic == 1) then
    1954           7 :                tmpstr2 = ' : new participation function'
    1955             :             else
    1956           0 :                tmpstr2 = ' : old participation function'
    1957             :             endif
    1958           7 :             write(nu_diag,1020) ' krdg_partic      = ', krdg_partic,trim(tmpstr2)
    1959           7 :             if (krdg_partic == 1) &
    1960           7 :             write(nu_diag,1002) ' mu_rdg           = ', mu_rdg,' : e-folding scale of ridged ice'
    1961           7 :             if (krdg_redist == 1) then
    1962           7 :                tmpstr2 = ' : new redistribution function'
    1963             :             else
    1964           0 :                tmpstr2 = ' : old redistribution function'
    1965             :             endif
    1966           7 :             write(nu_diag,1020) ' krdg_redist      = ', krdg_redist,trim(tmpstr2)
    1967             :          endif
    1968             : 
    1969           7 :          if (kstrength == 0) then
    1970           0 :             tmpstr2 = ' : Hibler (1979)'
    1971           7 :          elseif (kstrength == 1) then
    1972           7 :             tmpstr2 = ' : Rothrock (1975)'
    1973             :          else
    1974           0 :             tmpstr2 = ' : unknown value'
    1975             :          endif
    1976           7 :          write(nu_diag,1020) ' kstrength        = ', kstrength,trim(tmpstr2)
    1977           7 :          if (kstrength == 0) then
    1978           0 :             write(nu_diag,1009) ' Pstar            = ', Pstar, ' : P* strength factor'
    1979           0 :             write(nu_diag,1002) ' Cstar            = ', Cstar, ' : C* strength exponent factor'
    1980           7 :          elseif (kstrength == 1) then
    1981           7 :             write(nu_diag,1002) ' Cf               = ', Cf, ' : ratio of ridging work to PE change'
    1982             :          endif
    1983             : 
    1984           7 :          write(nu_diag,*) ' '
    1985           7 :          write(nu_diag,*) ' Thermodynamics'
    1986           7 :          write(nu_diag,*) '--------------------------------'
    1987             : 
    1988           7 :          if (ktherm == 1) then
    1989           0 :             tmpstr2 = ' : Bitz and Lipscomb 1999 thermo'
    1990           7 :          elseif (ktherm == 2) then
    1991           7 :             tmpstr2 = ' : mushy-layer thermo'
    1992           0 :          elseif (ktherm < 0) then
    1993           0 :             tmpstr2 = ' : Thermodynamics disabled'
    1994             :          else
    1995           0 :             tmpstr2 = ' : unknown value'
    1996             :          endif
    1997           7 :          write(nu_diag,1020) ' ktherm           = ', ktherm,trim(tmpstr2)
    1998           7 :          if (ktherm >= 0) then
    1999           7 :             write(nu_diag,1002) ' dt               = ', dt, ' : thermodynamic time step'
    2000           7 :             write(nu_diag,1002) ' ksno             = ', ksno,' : snow thermal conductivity'
    2001           7 :             if (ktherm == 1) &
    2002           0 :             write(nu_diag,1030) ' conduct          = ', trim(conduct),' : ice thermal conductivity'
    2003           7 :             if (ktherm == 2) then
    2004           7 :                write(nu_diag,1002) ' a_rapid_mode     = ', a_rapid_mode,' : brine channel diameter'
    2005           7 :                write(nu_diag,1002) ' Rac_rapid_mode   = ', Rac_rapid_mode,' : critical Rayleigh number'
    2006           7 :                write(nu_diag,1002) ' aspect_rapid_mode= ', aspect_rapid_mode,' : brine convection aspect ratio'
    2007           7 :                write(nu_diag,1009) ' dSdt_slow_mode   = ', dSdt_slow_mode,' : drainage strength parameter'
    2008           7 :                write(nu_diag,1002) ' phi_c_slow_mode  = ', phi_c_slow_mode,' : critical liquid fraction'
    2009           7 :                write(nu_diag,1002) ' phi_i_mushy      = ', phi_i_mushy,' : solid fraction at lower boundary'
    2010           7 :                write(nu_diag,1002) ' Tliquidus_max    = ', Tliquidus_max,' : max mush liquidus temperature'
    2011             :             endif
    2012           7 :             write(nu_diag,1002) ' hfrazilmin       = ', hfrazilmin,' : minimum new frazil ice thickness'
    2013             : 
    2014           7 :             write(nu_diag,*) ' '
    2015           7 :             write(nu_diag,*) ' Radiation'
    2016           7 :             write(nu_diag,*) '--------------------------------'
    2017           7 :             if (trim(shortwave) == 'dEdd') then
    2018           7 :                tmpstr2 = ' : delta-Eddington multiple-scattering method'
    2019           0 :             elseif (trim(shortwave) == 'dEdd_snicar_ad') then
    2020           0 :                tmpstr2 = ' : delta-Eddington multiple-scattering method with SNICAR AD'
    2021           0 :             elseif (trim(shortwave) == 'ccsm3') then
    2022           0 :                tmpstr2 = ' : NCAR CCSM3 distribution method'
    2023             :             else
    2024           0 :                tmpstr2 = ' : unknown value'
    2025             :             endif
    2026           7 :             write(nu_diag,1030) ' shortwave        = ', trim(shortwave),trim(tmpstr2)
    2027           7 :             if (shortwave(1:4) == 'dEdd') then
    2028           7 :                write(nu_diag,1002) ' R_ice            = ', R_ice,' : tuning parameter for sea ice albedo'
    2029           7 :                write(nu_diag,1002) ' R_pnd            = ', R_pnd,' : tuning parameter for ponded sea ice albedo'
    2030           7 :                write(nu_diag,1002) ' R_snw            = ', R_snw,' : tuning parameter for snow broadband albedo'
    2031           7 :                write(nu_diag,1002) ' dT_mlt           = ', dT_mlt,' : change in temperature per change in snow grain radius'
    2032           7 :                write(nu_diag,1002) ' rsnw_mlt         = ', rsnw_mlt,' : maximum melting snow grain radius'
    2033           7 :                write(nu_diag,1002) ' kalg             = ', kalg,' : absorption coefficient for algae'
    2034           7 :              if (trim(shortwave) == 'dEdd_snicar_ad') then
    2035           0 :                write(nu_diag,1030) ' snw_ssp_table    = ', trim(snw_ssp_table)
    2036             :              endif
    2037             :             else
    2038           0 :                if (trim(albedo_type) == 'ccsm3') then
    2039           0 :                   tmpstr2 = ' : NCAR CCSM3 albedos'
    2040           0 :                elseif (trim(albedo_type) == 'constant') then
    2041           0 :                   tmpstr2 = ' : four constant albedos'
    2042             :                else
    2043           0 :                   tmpstr2 = ' : unknown value'
    2044           0 :                   abort_list = trim(abort_list)//":23"
    2045             :                endif
    2046           0 :                write(nu_diag,1030) ' albedo_type     = ', trim(albedo_type),trim(tmpstr2)
    2047           0 :                if (trim(albedo_type) == 'ccsm3') then
    2048           0 :                   write(nu_diag,1002) ' albicev          = ', albicev,' : visible  ice albedo for thicker ice'
    2049           0 :                   write(nu_diag,1002) ' albicei          = ', albicei,' : near infrared ice albedo for thicker ice'
    2050           0 :                   write(nu_diag,1002) ' albsnowv         = ', albsnowv,' : visible, cold snow albedo'
    2051           0 :                   write(nu_diag,1002) ' albsnowi         = ', albsnowi,' : near infrared, cold snow albedo'
    2052           0 :                   write(nu_diag,1002) ' ahmax            = ', ahmax,' : albedo is constant above this thickness'
    2053           0 :                   write(nu_diag,1002) ' ahmax            = ', ahmax,' : albedo is constant above this thickness'
    2054             :                endif
    2055             :             endif
    2056           7 :             write(nu_diag,1000) ' emissivity       = ', emissivity,' : emissivity of snow and ice'
    2057           7 :             write(nu_diag,1010) ' sw_redist        = ', sw_redist,' : redistribute internal shortwave to surface'
    2058           7 :             if (sw_redist) then
    2059           0 :                write(nu_diag,1002) ' sw_frac          = ', sw_frac,' : fraction redistributed'
    2060           0 :                write(nu_diag,1002) ' sw_dtemp         = ', sw_dtemp,' : temperature difference from freezing to redistribute'
    2061             :             endif
    2062             :          endif
    2063             : 
    2064           7 :          write(nu_diag,*) ' '
    2065           7 :          write(nu_diag,*) ' Atmospheric Forcing / Coupling'
    2066           7 :          write(nu_diag,*) '--------------------------------'
    2067           7 :          write(nu_diag,1010) ' calc_Tsfc        = ', calc_Tsfc,' : calculate surface temperature as part of thermo'
    2068           7 :          write(nu_diag,1010) ' calc_strair      = ', calc_strair,' : calculate wind stress and speed'
    2069           7 :          write(nu_diag,1010) ' rotate_wind      = ', rotate_wind,' : rotate wind/stress to computational grid'
    2070           7 :          write(nu_diag,1010) ' formdrag         = ', formdrag,' : use form drag parameterization'
    2071           7 :          write(nu_diag,1000) ' iceruf           = ', iceruf, ' : ice surface roughness at atmosphere interface (m)'
    2072           7 :          if (trim(atmbndy) == 'constant') then
    2073           0 :             tmpstr2 = ' : constant-based boundary layer'
    2074           7 :          elseif (trim(atmbndy) == 'similarity' .or. &
    2075             :                  trim(atmbndy) == 'mixed') then
    2076           7 :             write(nu_diag,1010) ' highfreq         = ', highfreq,' : high-frequency atmospheric coupling'
    2077           7 :             write(nu_diag,1020) ' natmiter         = ', natmiter,' : number of atmo boundary layer iterations'
    2078           7 :             write(nu_diag,1002) ' atmiter_conv     = ', atmiter_conv,' : convergence criterion for ustar'
    2079           7 :             if (trim(atmbndy) == 'similarity') then
    2080           7 :                tmpstr2 = ' : stability-based boundary layer'
    2081             :             else
    2082           0 :                tmpstr2 = ' : stability-based boundary layer for wind stress, constant-based for sensible+latent heat fluxes'
    2083             :             endif
    2084             :          else
    2085           0 :             tmpstr2 = ' : unknown value'
    2086             :          endif
    2087           7 :          write(nu_diag,1030) ' atmbndy          = ', trim(atmbndy),trim(tmpstr2)
    2088             : 
    2089           7 :          write(nu_diag,*) ' '
    2090           7 :          write(nu_diag,*) ' Oceanic Forcing / Coupling'
    2091           7 :          write(nu_diag,*) '--------------------------------'
    2092           7 :          if (oceanmixed_ice) then
    2093           7 :             tmpstr2 = ' : ocean mixed layer calculation (SST) enabled'
    2094             :          else
    2095           0 :             tmpstr2 = ' : ocean mixed layer calculation (SST) disabled'
    2096             :          endif
    2097           7 :          write(nu_diag,1010) ' oceanmixed_ice   = ', oceanmixed_ice,trim(tmpstr2)
    2098           7 :          if (oceanmixed_ice) then
    2099           7 :             write(nu_diag,*) '     WARNING: ocean mixed layer ON'
    2100           7 :             write(nu_diag,*) '     WARNING: will impact ocean forcing interaction'
    2101           7 :             write(nu_diag,*) '     WARNING: coupled forcing will be modified by mixed layer routine'
    2102             :          endif
    2103           7 :          write(nu_diag,1030) ' saltflux_option  = ', trim(saltflux_option)
    2104           7 :          if (trim(saltflux_option) == 'constant') then
    2105           7 :             write(nu_diag,1002) ' ice_ref_salinity = ',ice_ref_salinity
    2106             :          endif
    2107           7 :          if (trim(tfrz_option) == 'constant') then
    2108           0 :             tmpstr2 = ' : constant ocean freezing temperature (Tocnfrz)'
    2109           7 :          elseif (trim(tfrz_option) == 'minus1p8') then
    2110           0 :             tmpstr2 = ' : constant ocean freezing temperature (-1.8C) (to be deprecated)'
    2111           7 :          elseif (trim(tfrz_option) == 'linear_salt') then
    2112           0 :             tmpstr2 = ' : linear function of salinity (use with ktherm=1)'
    2113           7 :          elseif (trim(tfrz_option) == 'mushy') then
    2114           7 :             tmpstr2 = ' : Assur (1958) as in mushy-layer thermo (ktherm=2)'
    2115             :          else
    2116           0 :             tmpstr2 = ' : unknown value'
    2117             :          endif
    2118           7 :          write(nu_diag,1030) ' tfrz_option      = ', trim(tfrz_option),trim(tmpstr2)
    2119           7 :          if (trim(tfrz_option) == 'constant') then
    2120           0 :             write(nu_diag,1002) ' Tocnfrz          = ', Tocnfrz
    2121             :          endif
    2122           7 :          if (update_ocn_f) then
    2123           0 :             tmpstr2 = ' : frazil water/salt fluxes included in ocean fluxes'
    2124             :          else
    2125           7 :             tmpstr2 = ' : frazil water/salt fluxes not included in ocean fluxes'
    2126             :          endif
    2127           7 :          write(nu_diag,1010) ' update_ocn_f     = ', update_ocn_f,trim(tmpstr2)
    2128           7 :          write(nu_diag,1030) ' cpl_frazil       = ', trim(cpl_frazil)
    2129           7 :          if (l_mpond_fresh .and. tr_pond_topo) then
    2130           0 :             tmpstr2 = ' : retain (topo) pond water until ponds drain'
    2131             :          else
    2132           7 :             tmpstr2 = ' : pond water not retained on ice (virtual only)'
    2133             :          endif
    2134           7 :          write(nu_diag,1010) ' l_mpond_fresh    = ', l_mpond_fresh,trim(tmpstr2)
    2135           7 :          if (trim(fbot_xfer_type) == 'constant') then
    2136           7 :             tmpstr2 = ' : ocean heat transfer coefficient is constant'
    2137           0 :          elseif (trim(fbot_xfer_type) == 'Cdn_ocn') then
    2138           0 :             tmpstr2 = ' : variable ocean heat transfer coefficient'  ! only used with form_drag=T?
    2139             :          else
    2140           0 :             tmpstr2 = ' : unknown value'
    2141             :          endif
    2142           7 :          write(nu_diag,1030) ' fbot_xfer_type   = ', trim(fbot_xfer_type),trim(tmpstr2)
    2143           7 :          write(nu_diag,1000) ' ustar_min        = ', ustar_min,' : minimum value of ocean friction velocity'
    2144           7 :          write(nu_diag,1000) ' hi_min           = ', hi_min,' : minimum ice thickness allowed (m)'
    2145           7 :          if (calc_dragio) then
    2146           0 :             tmpstr2 = ' : dragio computed from iceruf_ocn'
    2147             :          else
    2148           7 :             tmpstr2 = ' : dragio hard-coded'
    2149             :          endif
    2150           7 :          write(nu_diag,1010) ' calc_dragio   = ', calc_dragio,trim(tmpstr2)
    2151           7 :          if(calc_dragio) then
    2152           0 :             write(nu_diag,1002) ' iceruf_ocn       = ', iceruf_ocn,' : under-ice roughness length'
    2153             :          endif
    2154             : 
    2155           7 :          if (tr_fsd) then
    2156           0 :             write(nu_diag,1002) ' floediam         = ', floediam, ' constant floe diameter'
    2157           0 :             if (wave_spec) then
    2158           0 :                tmpstr2 = ' : use wave spectrum for floe size distribution'
    2159             :             else
    2160           0 :                tmpstr2 = 'WARNING : floe size distribution does not use wave spectrum'
    2161             :             endif
    2162           0 :             write(nu_diag,1010) ' wave_spec          = ', wave_spec,trim(tmpstr2)
    2163           0 :             if (wave_spec) then
    2164           0 :                if (trim(wave_spec_type) == 'none') then
    2165           0 :                   tmpstr2 = ' : no wave data provided, no wave-ice interactions'
    2166           0 :                elseif (trim(wave_spec_type) == 'profile') then
    2167             :                   tmpstr2 = ' : use fixed dummy wave spectrum for testing, sea surface height generated '// &
    2168           0 :                             'using constant phase (1 iteration of wave fracture)'
    2169           0 :                elseif (trim(wave_spec_type) == 'constant') then
    2170             :                   tmpstr2 = ' : wave spectrum data file provided, sea surface height generated '// &
    2171           0 :                             'using constant phase (1 iteration of wave fracture)'
    2172           0 :                elseif (trim(wave_spec_type) == 'random') then
    2173             :                   tmpstr2 = ' : wave spectrum data file provided, sea surface height generated using '// &
    2174           0 :                             'random number (multiple iterations of wave fracture to convergence)'
    2175             :                else
    2176           0 :                   tmpstr2 = ' : unknown value'
    2177             :                endif
    2178           0 :                write(nu_diag,1030) ' wave_spec_type   = ', trim(wave_spec_type),trim(tmpstr2)
    2179             :             endif
    2180           0 :             write(nu_diag,1020) ' nfreq            = ', nfreq,' : number of wave spectral forcing frequencies'
    2181             :          endif
    2182             : 
    2183           7 :          write(nu_diag,*) ' '
    2184           7 :          write(nu_diag,*) ' Age related tracers'
    2185           7 :          write(nu_diag,*) '--------------------------------'
    2186           7 :          write(nu_diag,1010) ' tr_iage          = ', tr_iage,' : chronological ice age'
    2187           7 :          write(nu_diag,1010) ' tr_FY            = ', tr_FY,' : first-year ice area'
    2188             : 
    2189           7 :          write(nu_diag,*) ' '
    2190           7 :          write(nu_diag,*) ' Melt ponds'
    2191           7 :          write(nu_diag,*) '--------------------------------'
    2192           7 :          if (tr_pond_lvl) then
    2193           7 :             write(nu_diag,1010) ' tr_pond_lvl      = ', tr_pond_lvl,' : level-ice pond formulation'
    2194           7 :             write(nu_diag,1002) ' pndaspect        = ', pndaspect,' : ratio of pond depth to area fraction'
    2195           7 :             write(nu_diag,1000) ' dpscale          = ', dpscale,' : time scale for flushing in permeable ice'
    2196           7 :             if (trim(frzpnd) == 'hlid') then
    2197           7 :                tmpstr2 = ' : Stefan refreezing with pond ice thickness'
    2198           0 :             elseif (trim(frzpnd) == 'cesm') then
    2199           0 :                tmpstr2 = ' : CESM refreezing empirical formula'
    2200             :             else
    2201           0 :                tmpstr2 = ' : unknown value'
    2202             :             endif
    2203           7 :             write(nu_diag,1030) ' frzpnd           = ', trim(frzpnd),trim(tmpstr2)
    2204           7 :             write(nu_diag,1002) ' hs1              = ', hs1,' : snow depth of transition to pond ice'
    2205           0 :          elseif (tr_pond_topo) then
    2206           0 :             write(nu_diag,1010) ' tr_pond_topo     = ', tr_pond_topo,' : topo pond formulation'
    2207           0 :             write(nu_diag,1002) ' hp1              = ', hp1,' : critical ice lid thickness for topo ponds'
    2208           0 :          elseif (trim(shortwave) == 'ccsm3') then
    2209           0 :             write(nu_diag,*) 'Pond effects on radiation are treated implicitly in the ccsm3 shortwave scheme'
    2210             :          else
    2211           0 :             write(nu_diag,*) 'Using default dEdd melt pond scheme for testing only'
    2212             :          endif
    2213             : 
    2214           7 :          if (shortwave(1:4) == 'dEdd') then
    2215           7 :             write(nu_diag,1002) ' hs0              = ', hs0,' : snow depth of transition to bare sea ice'
    2216             :          endif
    2217             : 
    2218           7 :          write(nu_diag,1002) ' rfracmin         = ', rfracmin,' : minimum fraction of melt water added to ponds'
    2219           7 :          write(nu_diag,1002) ' rfracmax         = ', rfracmax,' : maximum fraction of melt water added to ponds'
    2220             : 
    2221           7 :          write(nu_diag,*) ' '
    2222           7 :          write(nu_diag,*) ' Snow redistribution/metamorphism tracers'
    2223           7 :          write(nu_diag,*) '-----------------------------------------'
    2224           7 :          if (tr_snow) then
    2225           0 :             write(nu_diag,1010) ' tr_snow          = ', tr_snow, &
    2226           0 :                                 ' : advanced snow physics'
    2227           0 :             if (snwredist(1:4) == 'none') then
    2228           0 :                write(nu_diag,1030) ' snwredist        = ', trim(snwredist), &
    2229           0 :                                    ' : Snow redistribution scheme turned off'
    2230             :             else
    2231           0 :                if (snwredist(1:4) == 'bulk') then
    2232           0 :                   write(nu_diag,1030) ' snwredist        = ', trim(snwredist), &
    2233           0 :                                       ' : Using bulk snow redistribution scheme'
    2234           0 :                elseif (snwredist(1:6) == 'ITDrdg') then
    2235           0 :                   write(nu_diag,1030) ' snwredist        = ', trim(snwredist), &
    2236           0 :                                       ' : Using ridging based snow redistribution scheme'
    2237           0 :                   write(nu_diag,1002) ' rhosnew          = ', rhosnew, &
    2238           0 :                                       ' : new snow density (kg/m^3)'
    2239           0 :                   write(nu_diag,1002) ' rhosmin          = ', rhosmin, &
    2240           0 :                                       ' : minimum snow density (kg/m^3)'
    2241           0 :                   write(nu_diag,1002) ' rhosmax          = ', rhosmax, &
    2242           0 :                                       ' : maximum snow density (kg/m^3)'
    2243           0 :                   write(nu_diag,1002) ' windmin          = ', windmin, &
    2244           0 :                                       ' : minimum wind speed to compact snow (m/s)'
    2245           0 :                   write(nu_diag,1002) ' drhosdwind       = ', drhosdwind, &
    2246           0 :                                       ' : wind compaction factor (kg s/m^4)'
    2247             :                endif
    2248           0 :                write(nu_diag,1002) ' snwlvlfac        = ', snwlvlfac, &
    2249           0 :                                    ' : fractional increase in snow depth for redistribution on ridges'
    2250             :             endif
    2251           0 :             if (.not. snwgrain) then
    2252           0 :                write(nu_diag,1010) ' snwgrain         = ', snwgrain, &
    2253           0 :                                    ' : Snow metamorphosis turned off'
    2254             :             else
    2255           0 :                write(nu_diag,1010) ' snwgrain         = ', snwgrain, &
    2256           0 :                                    ' : Using snow metamorphosis scheme'
    2257           0 :                write(nu_diag,1002) ' rsnw_tmax        = ', rsnw_tmax, &
    2258           0 :                                    ' : maximum snow radius (10^-6 m)'
    2259             :             endif
    2260           0 :             write(nu_diag,1002) ' rsnw_fall        = ', rsnw_fall, &
    2261           0 :                                 ' : radius of new snow (10^-6 m)'
    2262           0 :             if (snwgrain) then
    2263           0 :                if (use_smliq_pnd) then
    2264           0 :                   tmpstr2 = ' : Using liquid water in snow for melt ponds'
    2265             :                else
    2266           0 :                   tmpstr2 = ' : NOT using liquid water in snow for melt ponds'
    2267             :                endif
    2268           0 :                   write(nu_diag,1010) ' use_smliq_pnd    = ', use_smliq_pnd, trim(tmpstr2)
    2269           0 :                if (snw_aging_table == 'test') then
    2270           0 :                   tmpstr2 = ' : Using 5x5x1 test matrix of internallly defined snow aging parameters'
    2271           0 :                   write(nu_diag,1030) ' snw_aging_table  = ', trim(snw_aging_table),trim(tmpstr2)
    2272           0 :                elseif (snw_aging_table == 'snicar') then
    2273           0 :                   tmpstr2 = ' : Reading 3D snow aging parameters from SNICAR file'
    2274           0 :                   write(nu_diag,1030) ' snw_aging_table  = ', trim(snw_aging_table),trim(tmpstr2)
    2275           0 :                   write(nu_diag,1031) ' snw_filename     = ',trim(snw_filename)
    2276           0 :                   write(nu_diag,1031) ' snw_tau_fname    = ',trim(snw_tau_fname)
    2277           0 :                   write(nu_diag,1031) ' snw_kappa_fname  = ',trim(snw_kappa_fname)
    2278           0 :                   write(nu_diag,1031) ' snw_drdt0_fname  = ',trim(snw_drdt0_fname)
    2279           0 :                elseif (snw_aging_table == 'file') then
    2280           0 :                   tmpstr2 = ' : Reading 1D and 3D snow aging dimensions and parameters from external file'
    2281           0 :                   write(nu_diag,1030) ' snw_aging_table  = ', trim(snw_aging_table),trim(tmpstr2)
    2282           0 :                   write(nu_diag,1031) ' snw_filename     = ',trim(snw_filename)
    2283           0 :                   write(nu_diag,1031) ' snw_rhos_fname   = ',trim(snw_rhos_fname)
    2284           0 :                   write(nu_diag,1031) ' snw_Tgrd_fname   = ',trim(snw_Tgrd_fname)
    2285           0 :                   write(nu_diag,1031) ' snw_T_fname      = ',trim(snw_T_fname)
    2286           0 :                   write(nu_diag,1031) ' snw_tau_fname    = ',trim(snw_tau_fname)
    2287           0 :                   write(nu_diag,1031) ' snw_kappa_fname  = ',trim(snw_kappa_fname)
    2288           0 :                   write(nu_diag,1031) ' snw_drdt0_fname  = ',trim(snw_drdt0_fname)
    2289             :                endif
    2290             :             endif
    2291             :          endif
    2292             : 
    2293           7 :          write(nu_diag,*) ' '
    2294           7 :          write(nu_diag,*) ' Primary state variables, tracers'
    2295           7 :          write(nu_diag,*) '   (excluding biogeochemistry)'
    2296           7 :          write(nu_diag,*) '---------------------------------'
    2297           7 :          write(nu_diag,*) 'Conserved properties (all tracers are conserved):'
    2298           7 :          write(nu_diag,*) 'ice concentration, volume and enthalpy'
    2299           7 :          write(nu_diag,*) 'snow volume and enthalpy'
    2300           7 :          if (ktherm == 2)  write(nu_diag,1030) ' ice salinity'
    2301           7 :          if (tr_fsd)       write(nu_diag,1010) ' tr_fsd           = ', tr_fsd,' : floe size distribution'
    2302           7 :          if (tr_lvl)       write(nu_diag,1010) ' tr_lvl           = ', tr_lvl,' : ridging related tracers'
    2303           7 :          if (tr_pond_lvl)  write(nu_diag,1010) ' tr_pond_lvl      = ', tr_pond_lvl,' : level-ice pond formulation'
    2304           7 :          if (tr_pond_topo) write(nu_diag,1010) ' tr_pond_topo     = ', tr_pond_topo,' : topo pond formulation'
    2305           7 :          if (tr_snow)      write(nu_diag,1010) ' tr_snow          = ', tr_snow,' : advanced snow physics'
    2306           7 :          if (tr_iage)      write(nu_diag,1010) ' tr_iage          = ', tr_iage,' : chronological ice age'
    2307           7 :          if (tr_FY)        write(nu_diag,1010) ' tr_FY            = ', tr_FY,' : first-year ice area'
    2308           7 :          if (tr_iso)       write(nu_diag,1010) ' tr_iso           = ', tr_iso,' : diagnostic isotope tracers'
    2309           7 :          if (tr_aero)      write(nu_diag,1010) ' tr_aero          = ', tr_aero,' : CESM aerosol tracers'
    2310           7 :          write(nu_diag,*) 'Non-conserved properties:'
    2311           7 :          write(nu_diag,*) 'ice surface temperature'
    2312           7 :          write(nu_diag,*) 'ice velocity components and internal stress'
    2313             : 
    2314           7 :          write(nu_diag,*) ' '
    2315           7 :          write(nu_diag,*) ' Other ice_in namelist parameters:'
    2316           7 :          write(nu_diag,*) '===================================== '
    2317           7 :          if (trim(runid) /= 'unknown') &
    2318           0 :          write(nu_diag,1031) ' runid            = ', trim(runid)
    2319           7 :          write(nu_diag,1031) ' runtype          = ', trim(runtype)
    2320           7 :          write(nu_diag,1021) ' year_init        = ', year_init
    2321           7 :          write(nu_diag,1021) ' month_init       = ', month_init
    2322           7 :          write(nu_diag,1021) ' day_init         = ', day_init
    2323           7 :          write(nu_diag,1021) ' sec_init         = ', sec_init
    2324           7 :          write(nu_diag,1021) ' istep0           = ', istep0
    2325           7 :          write(nu_diag,1031) ' npt_unit         = ', trim(npt_unit)
    2326           7 :          write(nu_diag,1021) ' npt              = ', npt
    2327           7 :          write(nu_diag,1021) ' diagfreq         = ', diagfreq
    2328           7 :          write(nu_diag,1011) ' print_global     = ', print_global
    2329           7 :          write(nu_diag,1011) ' print_points     = ', print_points
    2330           7 :          write(nu_diag,1011) ' debug_model      = ', debug_model
    2331           7 :          write(nu_diag,1022) ' debug_model_step = ', debug_model_step
    2332           7 :          write(nu_diag,1021) ' debug_model_i    = ', debug_model_i
    2333           7 :          write(nu_diag,1021) ' debug_model_i    = ', debug_model_j
    2334           7 :          write(nu_diag,1021) ' debug_model_iblk = ', debug_model_iblk
    2335           7 :          write(nu_diag,1021) ' debug_model_task = ', debug_model_task
    2336           7 :          write(nu_diag,1011) ' timer_stats      = ', timer_stats
    2337           7 :          write(nu_diag,1011) ' memory_stats     = ', memory_stats
    2338           7 :          write(nu_diag,1031) ' bfbflag          = ', trim(bfbflag)
    2339           7 :          write(nu_diag,1021) ' numin            = ', numin
    2340           7 :          write(nu_diag,1021) ' numax            = ', numax
    2341           7 :          write(nu_diag,1033) ' histfreq         = ', histfreq(:)
    2342           7 :          write(nu_diag,1023) ' histfreq_n       = ', histfreq_n(:)
    2343           7 :          write(nu_diag,1033) ' histfreq_base    = ', histfreq_base(:)
    2344           7 :          write(nu_diag,*)    ' hist_avg         = ', hist_avg(:)
    2345           7 :          write(nu_diag,1031) ' history_dir      = ', trim(history_dir)
    2346           7 :          write(nu_diag,1031) ' history_file     = ', trim(history_file)
    2347           7 :          write(nu_diag,1021) ' history_precision= ', history_precision
    2348           7 :          write(nu_diag,1031) ' history_format   = ', trim(history_format)
    2349           7 :          write(nu_diag,1031) ' hist_time_axis   = ', trim(hist_time_axis)
    2350           7 :          if (write_ic) then
    2351           7 :             write(nu_diag,1039) ' Initial condition will be written in ', &
    2352          14 :                                trim(incond_dir)
    2353             :          endif
    2354           7 :          write(nu_diag,1033) ' dumpfreq         = ', dumpfreq(:)
    2355           7 :          write(nu_diag,1023) ' dumpfreq_n       = ', dumpfreq_n(:)
    2356           7 :          write(nu_diag,1033) ' dumpfreq_base    = ', dumpfreq_base(:)
    2357           7 :          write(nu_diag,1011) ' dump_last        = ', dump_last
    2358           7 :          write(nu_diag,1011) ' restart          = ', restart
    2359           7 :          write(nu_diag,1031) ' restart_dir      = ', trim(restart_dir)
    2360           7 :          write(nu_diag,1011) ' restart_ext      = ', restart_ext
    2361           7 :          write(nu_diag,1011) ' restart_coszen   = ', restart_coszen
    2362           7 :          write(nu_diag,1031) ' restart_format   = ', trim(restart_format)
    2363           7 :          write(nu_diag,1011) ' lcdf64           = ', lcdf64
    2364           7 :          write(nu_diag,1031) ' restart_file     = ', trim(restart_file)
    2365           7 :          write(nu_diag,1031) ' pointer_file     = ', trim(pointer_file)
    2366           7 :          write(nu_diag,1011) ' use_restart_time = ', use_restart_time
    2367           7 :          write(nu_diag,1031) ' ice_ic           = ', trim(ice_ic)
    2368           7 :          if (trim(grid_type) /= 'rectangular' .or. &
    2369             :              trim(grid_type) /= 'column') then
    2370           7 :             write(nu_diag,1031) ' grid_file        = ', trim(grid_file)
    2371           7 :             write(nu_diag,1031) ' gridcpl_file     = ', trim(gridcpl_file)
    2372           7 :             write(nu_diag,1031) ' bathymetry_file  = ', trim(bathymetry_file)
    2373           7 :             if (trim(kmt_type) == 'file') &
    2374           5 :                write(nu_diag,1031) ' kmt_file         = ', trim(kmt_file)
    2375             :          endif
    2376           7 :          write(nu_diag,1011) ' orca_halogrid    = ', orca_halogrid
    2377             : 
    2378           7 :          write(nu_diag,1011) ' conserv_check    = ', conserv_check
    2379             : 
    2380           7 :          write(nu_diag,1021) ' fyear_init       = ', fyear_init
    2381           7 :          write(nu_diag,1021) ' ycycle           = ', ycycle
    2382           7 :          write(nu_diag,1031) ' atm_data_type    = ', trim(atm_data_type)
    2383           7 :          if (trim(atm_data_type) /= 'default') then
    2384           7 :             write(nu_diag,1031) ' atm_data_dir     = ', trim(atm_data_dir)
    2385           7 :             write(nu_diag,1031) ' precip_units     = ', trim(precip_units)
    2386           0 :          elseif (trim(atm_data_type)=='default') then
    2387           0 :             write(nu_diag,1031) ' default_season   = ', trim(default_season)
    2388             :          endif
    2389             : 
    2390           7 :          if (wave_spec) then
    2391           0 :             write(nu_diag,1031) ' wave_spec_file   = ', trim(wave_spec_file)
    2392             :          endif
    2393           7 :          if (trim(bgc_data_type) == 'ncar' .or. &
    2394             :              trim(ocn_data_type) == 'ncar') then
    2395           0 :             write(nu_diag,1031) ' oceanmixed_file  = ', trim(oceanmixed_file)
    2396             :          endif
    2397           7 :          if (cpl_bgc) then
    2398           0 :              write(nu_diag,*) 'BGC coupling is switched ON'
    2399             :          else
    2400           7 :              write(nu_diag,*) 'BGC coupling is switched OFF'
    2401             :          endif
    2402           7 :          write(nu_diag,1031) ' bgc_data_type    = ', trim(bgc_data_type)
    2403           7 :          write(nu_diag,1031) ' fe_data_type     = ', trim(fe_data_type)
    2404           7 :          write(nu_diag,1031) ' ice_data_type    = ', trim(ice_data_type)
    2405           7 :          write(nu_diag,1031) ' ice_data_conc    = ', trim(ice_data_conc)
    2406           7 :          write(nu_diag,1031) ' ice_data_dist    = ', trim(ice_data_dist)
    2407           7 :          write(nu_diag,1031) ' bgc_data_dir     = ', trim(bgc_data_dir)
    2408           7 :          write(nu_diag,1031) ' ocn_data_type    = ', trim(ocn_data_type)
    2409           7 :          if (trim(bgc_data_type) /= 'default' .or. &
    2410             :              trim(ocn_data_type) /= 'default') then
    2411           2 :             write(nu_diag,1031) ' ocn_data_dir     = ', trim(ocn_data_dir)
    2412           2 :             write(nu_diag,1011) ' restore_ocn      = ', restore_ocn
    2413             :          endif
    2414           7 :          write(nu_diag,1011) ' restore_ice      = ', restore_ice
    2415           7 :          if (restore_ice .or. restore_ocn) &
    2416           0 :          write(nu_diag,1021) ' trestore         = ', trestore
    2417             : 
    2418           7 :          write(nu_diag,*) ' '
    2419           7 :          write(nu_diag,'(a31,2f8.2)') 'Diagnostic point 1: lat, lon =', &
    2420          14 :                             latpnt(1), lonpnt(1)
    2421           7 :          write(nu_diag,'(a31,2f8.2)') 'Diagnostic point 2: lat, lon =', &
    2422          14 :                             latpnt(2), lonpnt(2)
    2423           7 :          write(nu_diag,*) ' '
    2424             : 
    2425             :          ! tracer restarts
    2426           7 :          write(nu_diag,1011) ' restart_age      = ', restart_age
    2427           7 :          write(nu_diag,1011) ' restart_FY       = ', restart_FY
    2428           7 :          write(nu_diag,1011) ' restart_lvl      = ', restart_lvl
    2429           7 :          write(nu_diag,1011) ' restart_pond_lvl = ', restart_pond_lvl
    2430           7 :          write(nu_diag,1011) ' restart_pond_topo= ', restart_pond_topo
    2431           7 :          write(nu_diag,1011) ' restart_snow     = ', restart_snow
    2432           7 :          write(nu_diag,1011) ' restart_iso      = ', restart_iso
    2433           7 :          write(nu_diag,1011) ' restart_aero     = ', restart_aero
    2434           7 :          write(nu_diag,1011) ' restart_fsd      = ', restart_fsd
    2435             : 
    2436           7 :          write(nu_diag,1021) ' n_iso            = ', n_iso
    2437           7 :          write(nu_diag,1021) ' n_aero           = ', n_aero
    2438           7 :          write(nu_diag,1021) ' n_zaero          = ', n_zaero
    2439           7 :          write(nu_diag,1021) ' n_algae          = ', n_algae
    2440           7 :          write(nu_diag,1021) ' n_doc            = ', n_doc
    2441           7 :          write(nu_diag,1021) ' n_dic            = ', n_dic
    2442           7 :          write(nu_diag,1021) ' n_don            = ', n_don
    2443           7 :          write(nu_diag,1021) ' n_fed            = ', n_fed
    2444           7 :          write(nu_diag,1021) ' n_fep            = ', n_fep
    2445           7 :          write(nu_diag,*)    ' '
    2446             : 
    2447             :       endif                     ! my_task = master_task
    2448             : 
    2449             :       if (grid_type  /=  'displaced_pole' .and. &
    2450             :           grid_type  /=  'tripole'        .and. &   ! LCOV_EXCL_LINE
    2451             :           grid_type  /=  'column'         .and. &   ! LCOV_EXCL_LINE
    2452             :           grid_type  /=  'rectangular'    .and. &   ! LCOV_EXCL_LINE
    2453             :           grid_type  /=  'cpom_grid'      .and. &   ! LCOV_EXCL_LINE
    2454             :           grid_type  /=  'regional'       .and. &   ! LCOV_EXCL_LINE
    2455             :           grid_type  /=  'latlon') then
    2456           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: unknown grid_type=',trim(grid_type)
    2457           0 :          abort_list = trim(abort_list)//":20"
    2458             :       endif
    2459             : 
    2460             :       if (grid_ice /=  'B' .and. &
    2461             :           grid_ice /=  'C' .and. &   ! LCOV_EXCL_LINE
    2462             :           grid_ice /=  'CD' ) then
    2463           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: unknown grid_ice=',trim(grid_ice)
    2464           0 :          abort_list = trim(abort_list)//":26"
    2465             :       endif
    2466             : 
    2467             :       if (kmt_type  /=  'file'    .and. &
    2468             :           kmt_type  /=  'channel' .and. &   ! LCOV_EXCL_LINE
    2469             :           kmt_type  /=  'channel_oneeast' .and. &   ! LCOV_EXCL_LINE
    2470             :           kmt_type  /=  'channel_onenorth' .and. &   ! LCOV_EXCL_LINE
    2471             :           kmt_type  /=  'wall'    .and. &   ! LCOV_EXCL_LINE
    2472             :           kmt_type  /=  'default' .and. &   ! LCOV_EXCL_LINE
    2473             :           kmt_type  /=  'boxislands') then
    2474           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: unknown kmt_type=',trim(kmt_type)
    2475           0 :          abort_list = trim(abort_list)//":27"
    2476             :       endif
    2477             : 
    2478             :       if (grid_type  /=  'column'      .and. &
    2479             :           grid_type  /=  'rectangular' .and. &   ! LCOV_EXCL_LINE
    2480             :           kmt_type   /=  'file') then
    2481           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: need kmt file, kmt_type=',trim(kmt_type)
    2482           0 :          abort_list = trim(abort_list)//":28"
    2483             :       endif
    2484             : 
    2485             :       if (kdyn         == 1                .and. &
    2486             :           evp_algorithm /= 'standard_2d'   .and. &   ! LCOV_EXCL_LINE
    2487             :           evp_algorithm /= 'shared_mem_1d') then
    2488           0 :          if (my_task == master_task) write(nu_diag,*) subname//' ERROR: unknown evp_algorithm=',trim(evp_algorithm)
    2489           0 :              abort_list = trim(abort_list)//":21"
    2490             :       endif
    2491             : 
    2492          37 :       if (abort_list /= "") then
    2493           0 :          call flush_fileunit(nu_diag)
    2494             :       endif
    2495          37 :       call ice_barrier()
    2496          37 :       if (abort_list /=  "") then
    2497           0 :          write(nu_diag,*) subname,' ERROR: abort_list = ',trim(abort_list)
    2498             :          call abort_ice (subname//' ABORTING on input ERRORS', &
    2499           0 :             file=__FILE__, line=__LINE__)
    2500             :       endif
    2501             : 
    2502             :       call icepack_init_parameters(ustar_min_in=ustar_min, albicev_in=albicev, albicei_in=albicei, &
    2503             :          albsnowv_in=albsnowv, albsnowi_in=albsnowi, natmiter_in=natmiter, atmiter_conv_in=atmiter_conv, &   ! LCOV_EXCL_LINE
    2504             :          emissivity_in=emissivity, snw_ssp_table_in=snw_ssp_table, hi_min_in=hi_min, &   ! LCOV_EXCL_LINE
    2505             :          ahmax_in=ahmax, shortwave_in=shortwave, albedo_type_in=albedo_type, R_ice_in=R_ice, R_pnd_in=R_pnd, &   ! LCOV_EXCL_LINE
    2506             :          R_snw_in=R_snw, dT_mlt_in=dT_mlt, rsnw_mlt_in=rsnw_mlt, &   ! LCOV_EXCL_LINE
    2507             :          kstrength_in=kstrength, krdg_partic_in=krdg_partic, krdg_redist_in=krdg_redist, mu_rdg_in=mu_rdg, &   ! LCOV_EXCL_LINE
    2508             :          atmbndy_in=atmbndy, calc_strair_in=calc_strair, formdrag_in=formdrag, highfreq_in=highfreq, &   ! LCOV_EXCL_LINE
    2509             :          kitd_in=kitd, kcatbound_in=kcatbound, hs0_in=hs0, dpscale_in=dpscale, frzpnd_in=frzpnd, &   ! LCOV_EXCL_LINE
    2510             :          rfracmin_in=rfracmin, rfracmax_in=rfracmax, pndaspect_in=pndaspect, hs1_in=hs1, hp1_in=hp1, &   ! LCOV_EXCL_LINE
    2511             :          ktherm_in=ktherm, calc_Tsfc_in=calc_Tsfc, conduct_in=conduct, &   ! LCOV_EXCL_LINE
    2512             :          a_rapid_mode_in=a_rapid_mode, Rac_rapid_mode_in=Rac_rapid_mode, &   ! LCOV_EXCL_LINE
    2513             :          floediam_in=floediam, hfrazilmin_in=hfrazilmin, Tliquidus_max_in=Tliquidus_max, &   ! LCOV_EXCL_LINE
    2514             :          aspect_rapid_mode_in=aspect_rapid_mode, dSdt_slow_mode_in=dSdt_slow_mode, &   ! LCOV_EXCL_LINE
    2515             :          phi_c_slow_mode_in=phi_c_slow_mode, phi_i_mushy_in=phi_i_mushy, conserv_check_in=conserv_check, &   ! LCOV_EXCL_LINE
    2516             :          wave_spec_type_in = wave_spec_type, wave_spec_in=wave_spec, nfreq_in=nfreq, &   ! LCOV_EXCL_LINE
    2517             :          update_ocn_f_in=update_ocn_f, cpl_frazil_in=cpl_frazil, &   ! LCOV_EXCL_LINE
    2518             :          tfrz_option_in=tfrz_option, kalg_in=kalg, fbot_xfer_type_in=fbot_xfer_type, &   ! LCOV_EXCL_LINE
    2519             :          saltflux_option_in=saltflux_option, ice_ref_salinity_in=ice_ref_salinity, &   ! LCOV_EXCL_LINE
    2520             :          Pstar_in=Pstar, Cstar_in=Cstar, iceruf_in=iceruf, iceruf_ocn_in=iceruf_ocn, calc_dragio_in=calc_dragio, &   ! LCOV_EXCL_LINE
    2521             :          windmin_in=windmin, drhosdwind_in=drhosdwind, &   ! LCOV_EXCL_LINE
    2522             :          rsnw_fall_in=rsnw_fall, rsnw_tmax_in=rsnw_tmax, rhosnew_in=rhosnew, &   ! LCOV_EXCL_LINE
    2523             :          snwlvlfac_in=snwlvlfac, rhosmin_in=rhosmin, rhosmax_in=rhosmax, &   ! LCOV_EXCL_LINE
    2524             :          snwredist_in=snwredist, snwgrain_in=snwgrain, snw_aging_table_in=trim(snw_aging_table), &   ! LCOV_EXCL_LINE
    2525          37 :          sw_redist_in=sw_redist, sw_frac_in=sw_frac, sw_dtemp_in=sw_dtemp)
    2526             :       call icepack_init_tracer_flags(tr_iage_in=tr_iage, tr_FY_in=tr_FY, &
    2527             :          tr_lvl_in=tr_lvl, tr_iso_in=tr_iso, tr_aero_in=tr_aero, &   ! LCOV_EXCL_LINE
    2528             :          tr_fsd_in=tr_fsd, tr_snow_in=tr_snow, tr_pond_in=tr_pond, &   ! LCOV_EXCL_LINE
    2529          37 :          tr_pond_lvl_in=tr_pond_lvl, tr_pond_topo_in=tr_pond_topo)
    2530             :       call icepack_init_tracer_sizes(ncat_in=ncat, nilyr_in=nilyr, nslyr_in=nslyr, nblyr_in=nblyr, &
    2531             :          nfsd_in=nfsd, n_algae_in=n_algae, n_iso_in=n_iso, n_aero_in=n_aero, &   ! LCOV_EXCL_LINE
    2532             :          n_DOC_in=n_DOC, n_DON_in=n_DON, &   ! LCOV_EXCL_LINE
    2533          37 :          n_DIC_in=n_DIC, n_fed_in=n_fed, n_fep_in=n_fep, n_zaero_in=n_zaero)
    2534          37 :       call icepack_warnings_flush(nu_diag)
    2535          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2536           0 :          file=__FILE__, line=__LINE__)
    2537             : 
    2538             :  1000    format (a20,1x,f13.6,1x,a) ! float
    2539             :  1002    format (a20,5x,f9.2,1x,a)
    2540             :  1003    format (a20,1x,G13.4,1x,a)
    2541             :  1009    format (a20,1x,d13.6,1x,a)
    2542             :  1010    format (a20,8x,l6,1x,a)  ! logical
    2543             :  1011    format (a20,1x,l6)
    2544             :  1020    format (a20,8x,i6,1x,a)  ! integer
    2545             :  1021    format (a20,1x,i6)
    2546             :  1022    format (a20,1x,i12)
    2547             :  1023    format (a20,1x,6i6)
    2548             :  1030    format (a20,a14,1x,a)    ! character
    2549             :  1031    format (a20,1x,a,a)
    2550             :  1033    format (a20,1x,6a6)
    2551             :  1039    format (a,1x,a,1x,a,1x,a)
    2552             : 
    2553          37 :       end subroutine input_data
    2554             : 
    2555             : !=======================================================================
    2556             : 
    2557             : ! Initialize state for the itd model
    2558             : !
    2559             : ! authors: C. M. Bitz, UW
    2560             : !          William H. Lipscomb, LANL
    2561             : 
    2562          37 :       subroutine init_state
    2563             : 
    2564             :       use ice_blocks, only: block, get_block, nx_block, ny_block
    2565             :       use ice_domain, only: nblocks, blocks_ice, halo_info
    2566             :       use ice_domain_size, only: ncat, nilyr, nslyr, n_iso, n_aero, nfsd
    2567             :       use ice_flux, only: sst, Tf, Tair, salinz, Tmltz
    2568             :       use ice_grid, only: tmask, umask, ULON, TLAT, grid_ice, grid_average_X2Y
    2569             :       use ice_boundary, only: ice_HaloUpdate
    2570             :       use ice_constants, only: field_loc_Nface, field_loc_Eface, field_type_scalar
    2571             :       use ice_state, only: trcr_depend, aicen, trcrn, vicen, vsnon, &
    2572             :           aice0, aice, vice, vsno, trcr, aice_init, bound_state, &   ! LCOV_EXCL_LINE
    2573             :           n_trcr_strata, nt_strata, trcr_base, uvel, vvel, &   ! LCOV_EXCL_LINE
    2574             :           uvelN, vvelN, uvelE, vvelE
    2575             : 
    2576             :       integer (kind=int_kind) :: &
    2577             :          ilo, ihi    , & ! physical domain indices   ! LCOV_EXCL_LINE
    2578             :          jlo, jhi    , & ! physical domain indices   ! LCOV_EXCL_LINE
    2579             :          iglob(nx_block), & ! global indices   ! LCOV_EXCL_LINE
    2580             :          jglob(ny_block), & ! global indices   ! LCOV_EXCL_LINE
    2581             :          i, j        , & ! horizontal indices   ! LCOV_EXCL_LINE
    2582             :          k           , & ! vertical index   ! LCOV_EXCL_LINE
    2583             :          it          , & ! tracer index   ! LCOV_EXCL_LINE
    2584             :          iblk            ! block index
    2585             : 
    2586             : 
    2587             :       integer (kind=int_kind) :: ntrcr
    2588             :       logical (kind=log_kind) :: tr_iage, tr_FY, tr_lvl, tr_iso, tr_aero
    2589             :       logical (kind=log_kind) :: tr_pond_lvl, tr_pond_topo
    2590             :       logical (kind=log_kind) :: tr_snow, tr_fsd
    2591             :       integer (kind=int_kind) :: nt_Tsfc, nt_sice, nt_qice, nt_qsno, nt_iage, nt_FY
    2592             :       integer (kind=int_kind) :: nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd
    2593             :       integer (kind=int_kind) :: nt_smice, nt_smliq, nt_rhos, nt_rsnw
    2594             :       integer (kind=int_kind) :: nt_isosno, nt_isoice, nt_aero, nt_fsd
    2595             : 
    2596             :       type (block) :: &
    2597             :          this_block           ! block information for current block
    2598             : 
    2599             :       character(len=*), parameter :: subname='(init_state)'
    2600             : 
    2601             :       !-----------------------------------------------------------------
    2602             : 
    2603          37 :       call icepack_query_tracer_sizes(ntrcr_out=ntrcr)
    2604             :       call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, &
    2605             :         tr_lvl_out=tr_lvl, tr_iso_out=tr_iso, tr_aero_out=tr_aero, &   ! LCOV_EXCL_LINE
    2606             :         tr_pond_lvl_out=tr_pond_lvl, tr_pond_topo_out=tr_pond_topo, &   ! LCOV_EXCL_LINE
    2607          37 :         tr_snow_out=tr_snow, tr_fsd_out=tr_fsd)
    2608             :       call icepack_query_tracer_indices(nt_Tsfc_out=nt_Tsfc, nt_sice_out=nt_sice, &
    2609             :         nt_qice_out=nt_qice, nt_qsno_out=nt_qsno, nt_iage_out=nt_iage, nt_fy_out=nt_fy, &   ! LCOV_EXCL_LINE
    2610             :         nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, &   ! LCOV_EXCL_LINE
    2611             :         nt_ipnd_out=nt_ipnd, nt_aero_out=nt_aero, nt_fsd_out=nt_fsd, &   ! LCOV_EXCL_LINE
    2612             :         nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, &   ! LCOV_EXCL_LINE
    2613             :         nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw, &   ! LCOV_EXCL_LINE
    2614          37 :         nt_isosno_out=nt_isosno, nt_isoice_out=nt_isoice)
    2615             : 
    2616          37 :       call icepack_warnings_flush(nu_diag)
    2617          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2618           0 :          file=__FILE__, line=__LINE__)
    2619             : 
    2620             :       !-----------------------------------------------------------------
    2621             :       ! Check number of layers in ice and snow.
    2622             :       !-----------------------------------------------------------------
    2623             : 
    2624          37 :       if (my_task == master_task) then
    2625             : 
    2626           7 :          if (nilyr < 1) then
    2627           0 :             write(nu_diag,*) subname//' ERROR: Must have at least one ice layer'
    2628           0 :             write(nu_diag,*) subname//' ERROR:   nilyr =', nilyr
    2629             :             call abort_ice (error_message=subname//' Not enough ice layers', &
    2630           0 :                file=__FILE__, line=__LINE__)
    2631             :          endif
    2632             : 
    2633           7 :          if (nslyr < 1) then
    2634           0 :             write(nu_diag,*) subname//' ERROR: Must have at least one snow layer'
    2635           0 :             write(nu_diag,*) subname//' ERROR:   nslyr =', nslyr
    2636             :             call abort_ice(error_message=subname//' Not enough snow layers', &
    2637           0 :                file=__FILE__, line=__LINE__)
    2638             :          endif
    2639             : 
    2640             :       endif      ! my_task
    2641             : 
    2642             :       !-----------------------------------------------------------------
    2643             :       ! Set tracer types
    2644             :       !-----------------------------------------------------------------
    2645             : 
    2646          37 :       trcr_depend(nt_Tsfc) = 0 ! ice/snow surface temperature
    2647         296 :       do k = 1, nilyr
    2648         259 :          trcr_depend(nt_sice + k - 1) = 1 ! volume-weighted ice salinity
    2649         296 :          trcr_depend(nt_qice + k - 1) = 1 ! volume-weighted ice enthalpy
    2650             :       enddo
    2651          74 :       do k = 1, nslyr
    2652          74 :          trcr_depend(nt_qsno + k - 1) = 2 ! volume-weighted snow enthalpy
    2653             :       enddo
    2654          37 :       if (tr_iage) trcr_depend(nt_iage)  = 1   ! volume-weighted ice age
    2655          37 :       if (tr_FY)   trcr_depend(nt_FY)    = 0   ! area-weighted first-year ice area
    2656          37 :       if (tr_lvl)  trcr_depend(nt_alvl)  = 0   ! level ice area
    2657          37 :       if (tr_lvl)  trcr_depend(nt_vlvl)  = 1   ! level ice volume
    2658          37 :       if (tr_pond_lvl) then
    2659          37 :                    trcr_depend(nt_apnd)  = 2+nt_alvl   ! melt pond area
    2660          37 :                    trcr_depend(nt_hpnd)  = 2+nt_apnd   ! melt pond depth
    2661          37 :                    trcr_depend(nt_ipnd)  = 2+nt_apnd   ! refrozen pond lid
    2662             :       endif
    2663          37 :       if (tr_pond_topo) then
    2664           0 :                    trcr_depend(nt_apnd)  = 0           ! melt pond area
    2665           0 :                    trcr_depend(nt_hpnd)  = 2+nt_apnd   ! melt pond depth
    2666           0 :                    trcr_depend(nt_ipnd)  = 2+nt_apnd   ! refrozen pond lid
    2667             :       endif
    2668          37 :       if (tr_snow) then                                ! snow-volume-weighted snow tracers
    2669           0 :          do k = 1, nslyr
    2670           0 :             trcr_depend(nt_smice + k - 1) = 2          ! ice mass in snow
    2671           0 :             trcr_depend(nt_smliq + k - 1) = 2          ! liquid mass in snow
    2672           0 :             trcr_depend(nt_rhos  + k - 1) = 2          ! effective snow density
    2673           0 :             trcr_depend(nt_rsnw  + k - 1) = 2          ! snow radius
    2674             :          enddo
    2675             :       endif
    2676          37 :       if (tr_fsd) then
    2677           0 :          do it = 1, nfsd
    2678           0 :             trcr_depend(nt_fsd + it - 1) = 0    ! area-weighted floe size distribution
    2679             :          enddo
    2680             :       endif
    2681          37 :       if (tr_iso) then  ! isotopes
    2682           0 :          do it = 1, n_iso
    2683           0 :             trcr_depend(nt_isosno+it-1) = 2     ! snow
    2684           0 :             trcr_depend(nt_isoice+it-1) = 1     ! ice
    2685             :          enddo
    2686             :       endif
    2687          37 :       if (tr_aero) then ! volume-weighted aerosols
    2688           0 :          do it = 1, n_aero
    2689           0 :             trcr_depend(nt_aero+(it-1)*4  ) = 2 ! snow
    2690           0 :             trcr_depend(nt_aero+(it-1)*4+1) = 2 ! snow
    2691           0 :             trcr_depend(nt_aero+(it-1)*4+2) = 1 ! ice
    2692           0 :             trcr_depend(nt_aero+(it-1)*4+3) = 1 ! ice
    2693             :          enddo
    2694             :       endif
    2695             : 
    2696        2812 :       trcr_base = c0
    2697             : 
    2698         925 :       do it = 1, ntrcr
    2699             :          ! mask for base quantity on which tracers are carried
    2700         888 :          if (trcr_depend(it) == 0) then      ! area
    2701         148 :             trcr_base(it,1) = c1
    2702         740 :          elseif (trcr_depend(it) == 1) then  ! ice volume
    2703         592 :             trcr_base(it,2) = c1
    2704         148 :          elseif (trcr_depend(it) == 2) then  ! snow volume
    2705          37 :             trcr_base(it,3) = c1
    2706             :          else
    2707         111 :             trcr_base(it,1) = c1    ! default: ice area
    2708         111 :             trcr_base(it,2) = c0
    2709         111 :             trcr_base(it,3) = c0
    2710             :          endif
    2711             : 
    2712             :          ! initialize number of underlying tracer layers
    2713         888 :          n_trcr_strata(it) = 0
    2714             :          ! default indices of underlying tracer layers
    2715         888 :          nt_strata   (it,1) = 0
    2716         925 :          nt_strata   (it,2) = 0
    2717             :       enddo
    2718             : 
    2719          37 :       if (tr_pond_lvl) then
    2720          37 :          n_trcr_strata(nt_apnd)   = 1       ! melt pond area
    2721          37 :          nt_strata    (nt_apnd,1) = nt_alvl ! on level ice area
    2722          37 :          n_trcr_strata(nt_hpnd)   = 2       ! melt pond depth
    2723          37 :          nt_strata    (nt_hpnd,2) = nt_apnd ! on melt pond area
    2724          37 :          nt_strata    (nt_hpnd,1) = nt_alvl ! on level ice area
    2725          37 :          n_trcr_strata(nt_ipnd)   = 2       ! refrozen pond lid
    2726          37 :          nt_strata    (nt_ipnd,2) = nt_apnd ! on melt pond area
    2727          37 :          nt_strata    (nt_ipnd,1) = nt_alvl ! on level ice area
    2728             :       endif
    2729          37 :       if (tr_pond_topo) then
    2730           0 :          n_trcr_strata(nt_hpnd)   = 1       ! melt pond depth
    2731           0 :          nt_strata    (nt_hpnd,1) = nt_apnd ! on melt pond area
    2732           0 :          n_trcr_strata(nt_ipnd)   = 1       ! refrozen pond lid
    2733           0 :          nt_strata    (nt_ipnd,1) = nt_apnd ! on melt pond area
    2734             :       endif
    2735             : 
    2736             :       !-----------------------------------------------------------------
    2737             :       ! Set state variables
    2738             :       !-----------------------------------------------------------------
    2739             : 
    2740             :       !$OMP PARALLEL DO PRIVATE(iblk,ilo,ihi,jlo,jhi,this_block, &
    2741          20 :       !$OMP                     iglob,jglob)
    2742          50 :       do iblk = 1, nblocks
    2743             : 
    2744          33 :          this_block = get_block(blocks_ice(iblk),iblk)
    2745          33 :          ilo = this_block%ilo
    2746          33 :          ihi = this_block%ihi
    2747          33 :          jlo = this_block%jlo
    2748          33 :          jhi = this_block%jhi
    2749        1223 :          iglob = this_block%i_glob
    2750        1239 :          jglob = this_block%j_glob
    2751             : 
    2752             :          call set_state_var (nx_block,            ny_block,            &
    2753             :                              ilo, ihi,            jlo, jhi,            &   ! LCOV_EXCL_LINE
    2754             :                              iglob,               jglob,               &   ! LCOV_EXCL_LINE
    2755             :                              ice_ic,              tmask(:,:,    iblk), &   ! LCOV_EXCL_LINE
    2756             :                              umask(:,:,    iblk), &   ! LCOV_EXCL_LINE
    2757             :                              ULON (:,:,    iblk), &   ! LCOV_EXCL_LINE
    2758             :                              TLAT (:,:,    iblk), &   ! LCOV_EXCL_LINE
    2759             :                              Tair (:,:,    iblk), sst  (:,:,    iblk), &   ! LCOV_EXCL_LINE
    2760             :                              Tf   (:,:,    iblk),                      &   ! LCOV_EXCL_LINE
    2761             :                              salinz(:,:,:, iblk), Tmltz(:,:,:,  iblk), &   ! LCOV_EXCL_LINE
    2762             :                              aicen(:,:,  :,iblk), trcrn(:,:,:,:,iblk), &   ! LCOV_EXCL_LINE
    2763             :                              vicen(:,:,  :,iblk), vsnon(:,:,  :,iblk), &   ! LCOV_EXCL_LINE
    2764          70 :                              uvel (:,:,    iblk), vvel (:,:,    iblk))
    2765             : 
    2766             :       enddo                     ! iblk
    2767             :       !$OMP END PARALLEL DO
    2768             : 
    2769             :       !-----------------------------------------------------------------
    2770             :       ! ghost cell updates
    2771             :       !-----------------------------------------------------------------
    2772             : 
    2773             :       call bound_state (aicen,        &
    2774             :                         vicen, vsnon, &   ! LCOV_EXCL_LINE
    2775          37 :                         ntrcr, trcrn)
    2776             : 
    2777          37 :       if (grid_ice == 'CD' .or. grid_ice == 'C') then
    2778             : 
    2779           0 :          call grid_average_X2Y('A',uvel,'U',uvelN,'N')
    2780           0 :          call grid_average_X2Y('A',vvel,'U',vvelN,'N')
    2781           0 :          call grid_average_X2Y('A',uvel,'U',uvelE,'E')
    2782           0 :          call grid_average_X2Y('A',vvel,'U',vvelE,'E')
    2783             : 
    2784             :          ! Halo update on North, East faces
    2785             :          call ice_HaloUpdate(uvelN, halo_info, &
    2786           0 :                              field_loc_Nface, field_type_scalar)
    2787             :          call ice_HaloUpdate(vvelN, halo_info, &
    2788           0 :                              field_loc_Nface, field_type_scalar)
    2789             : 
    2790             :          call ice_HaloUpdate(uvelE, halo_info, &
    2791           0 :                              field_loc_Eface, field_type_scalar)
    2792             :          call ice_HaloUpdate(vvelE, halo_info, &
    2793           0 :                              field_loc_Eface, field_type_scalar)
    2794             : 
    2795             :       endif
    2796             : 
    2797             :       !-----------------------------------------------------------------
    2798             :       ! compute aggregate ice state and open water area
    2799             :       !-----------------------------------------------------------------
    2800             : 
    2801          20 :       !$OMP PARALLEL DO PRIVATE(iblk,it,i,j)
    2802          50 :       do iblk = 1, nblocks
    2803             : 
    2804        1276 :       do j = 1, ny_block
    2805       50267 :       do i = 1, nx_block
    2806       49028 :          aice(i,j,iblk) = c0
    2807       49028 :          vice(i,j,iblk) = c0
    2808       49028 :          vsno(i,j,iblk) = c0
    2809     1225700 :          do it = 1, ntrcr
    2810     1225700 :             trcr(i,j,it,iblk) = c0
    2811             :          enddo
    2812             : 
    2813       49028 :          if (tmask(i,j,iblk)) &
    2814             :             call icepack_aggregate(ncat  = ncat,                  &   ! LCOV_EXCL_LINE
    2815             :                                    aicen = aicen(i,j,:,iblk),     &   ! LCOV_EXCL_LINE
    2816             :                                    trcrn = trcrn(i,j,:,:,iblk),   &   ! LCOV_EXCL_LINE
    2817             :                                    vicen = vicen(i,j,:,iblk),     &   ! LCOV_EXCL_LINE
    2818             :                                    vsnon = vsnon(i,j,:,iblk),     &   ! LCOV_EXCL_LINE
    2819             :                                    aice  = aice (i,j,  iblk),     &   ! LCOV_EXCL_LINE
    2820             :                                    trcr  = trcr (i,j,:,iblk),     &   ! LCOV_EXCL_LINE
    2821             :                                    vice  = vice (i,j,  iblk),     &   ! LCOV_EXCL_LINE
    2822             :                                    vsno  = vsno (i,j,  iblk),     &   ! LCOV_EXCL_LINE
    2823             :                                    aice0 = aice0(i,j,  iblk),     &   ! LCOV_EXCL_LINE
    2824             :                                    ntrcr = ntrcr,                 &   ! LCOV_EXCL_LINE
    2825             :                                    trcr_depend   = trcr_depend(:),   &   ! LCOV_EXCL_LINE
    2826             :                                    trcr_base     = trcr_base(:,:),   &   ! LCOV_EXCL_LINE
    2827             :                                    n_trcr_strata = n_trcr_strata(:), &   ! LCOV_EXCL_LINE
    2828             :                                    nt_strata     = nt_strata(:,:),   &   ! LCOV_EXCL_LINE
    2829       43389 :                                    Tf            = Tf(i,j,iblk))
    2830             : 
    2831       50234 :          aice_init(i,j,iblk) = aice(i,j,iblk)
    2832             : 
    2833             :       enddo
    2834             :       enddo
    2835             : 
    2836             :       enddo                     ! iblk
    2837             :       !$OMP END PARALLEL DO
    2838             : 
    2839          37 :       call icepack_warnings_flush(nu_diag)
    2840          37 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2841           0 :          file=__FILE__, line=__LINE__)
    2842             : 
    2843          37 :       end subroutine init_state
    2844             : 
    2845             : !=======================================================================
    2846             : 
    2847             : ! Initialize state in each ice thickness category
    2848             : !
    2849             : ! authors: C. M. Bitz
    2850             : !          William H. Lipscomb, LANL
    2851             : 
    2852         160 :       subroutine set_state_var (nx_block, ny_block, &
    2853             :                                 ilo, ihi, jlo, jhi, &   ! LCOV_EXCL_LINE
    2854             :                                 iglob,    jglob,    &   ! LCOV_EXCL_LINE
    2855             :                                 ice_ic,   tmask,    &   ! LCOV_EXCL_LINE
    2856             :                                 umask, &   ! LCOV_EXCL_LINE
    2857             :                                 ULON,  &   ! LCOV_EXCL_LINE
    2858             :                                 TLAT,  &   ! LCOV_EXCL_LINE
    2859             :                                 Tair,     sst,  &   ! LCOV_EXCL_LINE
    2860             :                                 Tf,       &   ! LCOV_EXCL_LINE
    2861             :                                 salinz,   Tmltz, &   ! LCOV_EXCL_LINE
    2862             :                                 aicen,    trcrn, &   ! LCOV_EXCL_LINE
    2863             :                                 vicen,    vsnon, &   ! LCOV_EXCL_LINE
    2864         160 :                                 uvel,     vvel)
    2865             : 
    2866             : 
    2867             :       use ice_arrays_column, only: hin_max
    2868             :       use ice_domain_size, only: nilyr, nslyr, nx_global, ny_global, ncat
    2869             :       use ice_grid, only: dxrect, dyrect
    2870             :       use ice_forcing, only: ice_data_type, ice_data_conc, ice_data_dist
    2871             : 
    2872             :       integer (kind=int_kind), intent(in) :: &
    2873             :          nx_block, ny_block, & ! block dimensions   ! LCOV_EXCL_LINE
    2874             :          ilo, ihi          , & ! physical domain indices   ! LCOV_EXCL_LINE
    2875             :          jlo, jhi          , & !   ! LCOV_EXCL_LINE
    2876             :          iglob(nx_block)   , & ! global indices   ! LCOV_EXCL_LINE
    2877             :          jglob(ny_block)       !
    2878             : 
    2879             :       character(len=char_len_long), intent(in) :: &
    2880             :          ice_ic      ! method of ice cover initialization
    2881             : 
    2882             :       logical (kind=log_kind), dimension (nx_block,ny_block), intent(in) :: &
    2883             :          tmask  , & ! true for ice/ocean cells   ! LCOV_EXCL_LINE
    2884             :          umask      ! for U points
    2885             : 
    2886             :       real (kind=dbl_kind), dimension (nx_block,ny_block), intent(in) :: &
    2887             :          ULON   , & ! longitude of velocity pts (radians)   ! LCOV_EXCL_LINE
    2888             :          TLAT       ! latitude of temperature pts (radians)
    2889             : 
    2890             :       real (kind=dbl_kind), dimension (nx_block,ny_block), intent(in) :: &
    2891             :          Tair    , & ! air temperature  (K)   ! LCOV_EXCL_LINE
    2892             :          Tf      , & ! freezing temperature (C)   ! LCOV_EXCL_LINE
    2893             :          sst         ! sea surface temperature (C)
    2894             : 
    2895             :       real (kind=dbl_kind), dimension (nx_block,ny_block,nilyr), intent(in) :: &
    2896             :          salinz  , & ! initial salinity profile   ! LCOV_EXCL_LINE
    2897             :          Tmltz       ! initial melting temperature profile
    2898             : 
    2899             :       real (kind=dbl_kind), dimension (nx_block,ny_block,ncat), intent(out) :: &
    2900             :          aicen , & ! concentration of ice   ! LCOV_EXCL_LINE
    2901             :          vicen , & ! volume per unit area of ice          (m)   ! LCOV_EXCL_LINE
    2902             :          vsnon     ! volume per unit area of snow         (m)
    2903             : 
    2904             :       real (kind=dbl_kind), intent(out), dimension (:,:,:,:) :: & ! (nx_block,ny_block,ntrcr,ncat)
    2905             :          trcrn     ! ice tracers
    2906             :                    ! 1: surface temperature of ice/snow (C)
    2907             : 
    2908             :       real (kind=dbl_kind), dimension (nx_block,ny_block), intent(out) :: &
    2909             :          uvel    , & ! ice velocity B grid   ! LCOV_EXCL_LINE
    2910             :          vvel        !
    2911             : 
    2912             :       ! local variables
    2913             :       integer (kind=int_kind) :: &
    2914             :          i, j        , & ! horizontal indices   ! LCOV_EXCL_LINE
    2915             :          ij          , & ! horizontal index, combines i and j loops   ! LCOV_EXCL_LINE
    2916             :          k           , & ! ice layer index   ! LCOV_EXCL_LINE
    2917             :          n           , & ! thickness category index   ! LCOV_EXCL_LINE
    2918             :          it          , & ! tracer index   ! LCOV_EXCL_LINE
    2919             :          iedge       , & ! edge around big block   ! LCOV_EXCL_LINE
    2920             :          jedge       , & ! edge around big block   ! LCOV_EXCL_LINE
    2921             :          icells          ! number of cells initialized with ice
    2922             : 
    2923             :       logical (kind=log_kind) :: &
    2924             :          in_slot, in_cyl ! boxslotcyl flags
    2925             : 
    2926             :       real (kind=dbl_kind) :: &  ! boxslotcyl parameters
    2927             :          diam    , & ! cylinder diameter   ! LCOV_EXCL_LINE
    2928             :          radius  , & ! cylinder radius   ! LCOV_EXCL_LINE
    2929             :          center_x, & ! cylinder center   ! LCOV_EXCL_LINE
    2930             :          center_y, &   ! LCOV_EXCL_LINE
    2931             :          width   , & ! slot width   ! LCOV_EXCL_LINE
    2932          32 :          length      ! slot height
    2933             : 
    2934             :       integer (kind=int_kind), dimension(nx_block*ny_block) :: &
    2935         320 :          indxi, indxj    ! compressed indices for cells with aicen > puny
    2936             : 
    2937             :       real (kind=dbl_kind) :: &
    2938         128 :          Tsfc, sum, hbar, abar, puny, rhos, Lfresh, rad_to_deg, rsnw_fall, dist_ratio, Tffresh
    2939             : 
    2940             :       real (kind=dbl_kind), dimension(ncat) :: &
    2941         640 :          ainit, hinit    ! initial area, thickness
    2942             : 
    2943             :       real (kind=dbl_kind), dimension(nilyr) :: &
    2944         512 :          qin             ! ice enthalpy (J/m3)
    2945             : 
    2946             :       real (kind=dbl_kind), dimension(nslyr) :: &
    2947         352 :          qsn             ! snow enthalpy (J/m3)
    2948             : 
    2949             :       real (kind=dbl_kind), parameter :: &
    2950             :          hsno_init = 0.20_dbl_kind   , & ! initial snow thickness (m)   ! LCOV_EXCL_LINE
    2951             :          edge_init_nh =  70._dbl_kind, & ! initial ice edge, N.Hem. (deg)   ! LCOV_EXCL_LINE
    2952             :          edge_init_sh = -60._dbl_kind    ! initial ice edge, S.Hem. (deg)
    2953             : 
    2954             :       real (kind=dbl_kind) :: &  ! boxslotcyl
    2955             :          pi             , & ! pi   ! LCOV_EXCL_LINE
    2956             :          secday         , & ! seconds per day   ! LCOV_EXCL_LINE
    2957             :          max_vel        , & ! max velocity   ! LCOV_EXCL_LINE
    2958             :          domain_length  , & ! physical domain length   ! LCOV_EXCL_LINE
    2959          32 :          period             ! rotational period
    2960             : 
    2961             :       logical (kind=log_kind) :: tr_brine, tr_lvl, tr_snow
    2962             :       integer (kind=int_kind) :: ntrcr
    2963             :       integer (kind=int_kind) :: nt_Tsfc, nt_qice, nt_qsno, nt_sice
    2964             :       integer (kind=int_kind) :: nt_fbri, nt_alvl, nt_vlvl
    2965             :       integer (kind=int_kind) :: nt_smice, nt_smliq, nt_rhos, nt_rsnw
    2966             : 
    2967             :       character(len=*), parameter :: subname='(set_state_var)'
    2968             : 
    2969             :       !-----------------------------------------------------------------
    2970             : 
    2971         160 :       call icepack_query_tracer_sizes(ntrcr_out=ntrcr)
    2972             :       call icepack_query_tracer_flags(tr_brine_out=tr_brine, tr_lvl_out=tr_lvl, &
    2973         160 :         tr_snow_out=tr_snow)
    2974             :       call icepack_query_tracer_indices( nt_Tsfc_out=nt_Tsfc, nt_qice_out=nt_qice, &
    2975             :         nt_qsno_out=nt_qsno, nt_sice_out=nt_sice, &   ! LCOV_EXCL_LINE
    2976             :         nt_fbri_out=nt_fbri, nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, &   ! LCOV_EXCL_LINE
    2977             :         nt_smice_out=nt_smice, nt_smliq_out=nt_smliq, &   ! LCOV_EXCL_LINE
    2978         160 :         nt_rhos_out=nt_rhos, nt_rsnw_out=nt_rsnw)
    2979             :       call icepack_query_parameters(rhos_out=rhos, Lfresh_out=Lfresh, puny_out=puny, &
    2980         160 :         rad_to_deg_out=rad_to_deg, rsnw_fall_out=rsnw_fall, Tffresh_out=Tffresh)
    2981         160 :       call icepack_query_parameters(secday_out=secday, pi_out=pi)
    2982         160 :       call icepack_warnings_flush(nu_diag)
    2983         160 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    2984           0 :          file=__FILE__, line=__LINE__)
    2985             : 
    2986      106507 :       indxi(:) = 0
    2987      106507 :       indxj(:) = 0
    2988             : 
    2989             :       ! Initialize state variables.
    2990             :       ! If restarting, these values are overwritten.
    2991             : 
    2992         960 :       do n = 1, ncat
    2993       26675 :          do j = 1, ny_block
    2994      558250 :          do i = 1, nx_block
    2995      531735 :             aicen(i,j,n) = c0
    2996      531735 :             vicen(i,j,n) = c0
    2997      531735 :             vsnon(i,j,n) = c0
    2998      531735 :             if (tmask(i,j)) then
    2999      412695 :                trcrn(i,j,nt_Tsfc,n) = Tf(i,j)  ! surface temperature
    3000             :             else
    3001      119040 :                trcrn(i,j,nt_Tsfc,n) = c0       ! at land grid cells (for clean history/restart files)
    3002             :             endif
    3003      531735 :             if (ntrcr >= 2) then
    3004    12761640 :                do it = 2, ntrcr
    3005    12761640 :                   trcrn(i,j,it,n) = c0
    3006             :                enddo
    3007             :             endif
    3008      531735 :             if (tr_lvl)   trcrn(i,j,nt_alvl,n) = c1
    3009      531735 :             if (tr_lvl)   trcrn(i,j,nt_vlvl,n) = c1
    3010      531735 :             if (tr_brine) trcrn(i,j,nt_fbri,n) = c1
    3011     4253880 :             do k = 1, nilyr
    3012     4253880 :                trcrn(i,j,nt_sice+k-1,n) = salinz(i,j,k)
    3013             :             enddo
    3014     1063470 :             do k = 1, nslyr
    3015     1063470 :                trcrn(i,j,nt_qsno+k-1,n) = -rhos * Lfresh
    3016             :             enddo
    3017      557450 :             if (tr_snow) then
    3018           0 :                do k = 1, nslyr
    3019           0 :                   trcrn(i,j,nt_rsnw +k-1,n) = rsnw_fall
    3020           0 :                   trcrn(i,j,nt_rhos +k-1,n) = rhos
    3021           0 :                   trcrn(i,j,nt_smice+k-1,n) = rhos
    3022           0 :                   trcrn(i,j,nt_smliq+k-1,n) = c0
    3023             :                enddo               ! nslyr
    3024             :             endif
    3025             :          enddo
    3026             :          enddo
    3027             :       enddo
    3028             : 
    3029         160 :       if (trim(ice_ic) == 'internal') then
    3030             : 
    3031             :          !---------------------------------------------------------
    3032             :          ! ice concentration/thickness
    3033             :          !---------------------------------------------------------
    3034             : 
    3035             :          if (trim(ice_data_conc) == 'p5' .or. &
    3036             :              trim(ice_data_conc) == 'p8' .or. &   ! LCOV_EXCL_LINE
    3037             :              trim(ice_data_conc) == 'p9' .or. &   ! LCOV_EXCL_LINE
    3038             :              trim(ice_data_conc) == 'c1' .or. &   ! LCOV_EXCL_LINE
    3039             :              trim(ice_data_conc) == 'box2001') then
    3040             : 
    3041          32 :             if (trim(ice_data_conc) == 'p5') then
    3042           0 :                hbar = c2  ! initial ice thickness
    3043           0 :                abar = p5  ! initial ice concentration
    3044          32 :             elseif (trim(ice_data_conc) == 'p8') then
    3045           0 :                hbar = c1  ! initial ice thickness
    3046           0 :                abar = 0.8_dbl_kind  ! initial ice concentration
    3047          32 :             elseif (trim(ice_data_conc) == 'p9') then
    3048           0 :                hbar = c1  ! initial ice thickness
    3049           0 :                abar = 0.9_dbl_kind  ! initial ice concentration
    3050          32 :             elseif (trim(ice_data_conc) == 'c1') then
    3051           0 :                hbar = c1  ! initial ice thickness
    3052           0 :                abar = c1  ! initial ice concentration
    3053          32 :             elseif (trim(ice_data_conc) == 'box2001') then
    3054          32 :                hbar = c2  ! initial ice thickness
    3055          32 :                abar = p5  ! initial ice concentration
    3056             :             endif
    3057             : 
    3058         192 :             do n = 1, ncat
    3059         160 :                hinit(n) = c0
    3060         160 :                ainit(n) = c0
    3061         192 :                if (hbar > hin_max(n-1) .and. hbar <= hin_max(n)) then
    3062          32 :                   hinit(n) = hbar
    3063          32 :                   ainit(n) = abar
    3064             :                endif
    3065             :             enddo
    3066             : 
    3067           0 :          elseif (trim(ice_data_conc) == 'parabolic') then
    3068             : 
    3069             :             ! initial category areas in cells with ice
    3070           0 :             hbar = c3  ! initial ice thickness with greatest area
    3071             :                        ! Note: the resulting average ice thickness
    3072             :                        ! tends to be less than hbar due to the
    3073             :                        ! nonlinear distribution of ice thicknesses
    3074           0 :             sum = c0
    3075           0 :             do n = 1, ncat
    3076           0 :                if (n < ncat) then
    3077           0 :                   hinit(n) = p5*(hin_max(n-1) + hin_max(n)) ! m
    3078             :                else                ! n=ncat
    3079           0 :                   hinit(n) = (hin_max(n-1) + c1) ! m
    3080             :                endif
    3081             :                ! parabola, max at h=hbar, zero at h=0, 2*hbar
    3082           0 :                ainit(n) = max(c0, (c2*hbar*hinit(n) - hinit(n)**2))
    3083           0 :                sum = sum + ainit(n)
    3084             :             enddo
    3085           0 :             do n = 1, ncat
    3086           0 :                ainit(n) = ainit(n) / (sum + puny/ncat) ! normalize
    3087             :             enddo
    3088             : 
    3089             :          else
    3090             : 
    3091             :             call abort_ice(subname//'ERROR: ice_data_conc setting = '//trim(ice_data_conc), &
    3092           0 :                file=__FILE__, line=__LINE__)
    3093             : 
    3094             :          endif ! ice_data_conc
    3095             : 
    3096             :          !---------------------------------------------------------
    3097             :          ! location of ice
    3098             :          !---------------------------------------------------------
    3099             : 
    3100          32 :          if (trim(ice_data_type) == 'box2001') then
    3101             : 
    3102             :             ! place ice on left side of domain
    3103          32 :             icells = 0
    3104        1056 :             do j = jlo, jhi
    3105       33824 :             do i = ilo, ihi
    3106       33792 :                if (tmask(i,j)) then
    3107       31800 :                   if (ULON(i,j) < -50./rad_to_deg) then
    3108       31800 :                      icells = icells + 1
    3109       31800 :                      indxi(icells) = i
    3110       31800 :                      indxj(icells) = j
    3111             :                   endif            ! ULON
    3112             :                endif               ! tmask
    3113             :             enddo                  ! i
    3114             :             enddo                  ! j
    3115             : 
    3116           0 :          elseif (trim(ice_data_type) == 'boxslotcyl') then
    3117             : 
    3118             :             ! Geometric configuration of the slotted cylinder
    3119           0 :             diam     = p3 *dxrect*(nx_global-1)
    3120           0 :             center_x = p5 *dxrect*(nx_global-1)
    3121           0 :             center_y = p75*dyrect*(ny_global-1)
    3122           0 :             radius   = p5*diam
    3123           0 :             width    = p166*diam
    3124           0 :             length   = c5*p166*diam
    3125             : 
    3126           0 :             icells = 0
    3127           0 :             do j = jlo, jhi
    3128           0 :             do i = ilo, ihi
    3129           0 :                if (tmask(i,j)) then
    3130             :                   ! check if grid point is inside slotted cylinder
    3131           0 :                   in_slot = (dxrect*real(iglob(i)-1, kind=dbl_kind) >= center_x - width/c2) .and. &
    3132             :                             (dxrect*real(iglob(i)-1, kind=dbl_kind) <= center_x + width/c2) .and. &   ! LCOV_EXCL_LINE
    3133             :                             (dyrect*real(jglob(j)-1, kind=dbl_kind) >= center_y - radius) .and. &   ! LCOV_EXCL_LINE
    3134           0 :                             (dyrect*real(jglob(j)-1, kind=dbl_kind) <= center_y + (length - radius))
    3135             : 
    3136           0 :                   in_cyl  = sqrt((dxrect*real(iglob(i)-1, kind=dbl_kind) - center_x)**c2 + &
    3137           0 :                                  (dyrect*real(jglob(j)-1, kind=dbl_kind) - center_y)**c2) <= radius
    3138             : 
    3139           0 :                   if (in_cyl .and. .not. in_slot) then
    3140           0 :                      icells = icells + 1
    3141           0 :                      indxi(icells) = i
    3142           0 :                      indxj(icells) = j
    3143             :                   endif
    3144             :                endif
    3145             :             enddo
    3146             :             enddo
    3147             : 
    3148           0 :          elseif (trim(ice_data_type) == 'uniform') then
    3149             :             ! all cells not land mask are ice
    3150           0 :             icells = 0
    3151           0 :             do j = jlo, jhi
    3152           0 :             do i = ilo, ihi
    3153           0 :                if (tmask(i,j)) then
    3154           0 :                   icells = icells + 1
    3155           0 :                   indxi(icells) = i
    3156           0 :                   indxj(icells) = j
    3157             :                endif
    3158             :             enddo
    3159             :             enddo
    3160             : 
    3161           0 :          elseif (ice_data_type(1:7) == 'channel') then
    3162             :             ! channel ice in center of domain in i direction
    3163           0 :             icells = 0
    3164           0 :             do j = jlo, jhi
    3165           0 :             do i = ilo, ihi
    3166           0 :                if (jglob(j) > ny_global/4 .and. jglob(j) < 3*nx_global/4) then
    3167           0 :                   icells = icells + 1
    3168           0 :                   indxi(icells) = i
    3169           0 :                   indxj(icells) = j
    3170             :                endif
    3171             :             enddo
    3172             :             enddo
    3173             : 
    3174           0 :          elseif (trim(ice_data_type) == 'block') then
    3175             :             ! ice in 50% of domain, not at edges
    3176           0 :             icells = 0
    3177           0 :             iedge = int(real(nx_global,kind=dbl_kind) * 0.25) + 1
    3178           0 :             jedge = int(real(ny_global,kind=dbl_kind) * 0.25) + 1
    3179           0 :             do j = jlo, jhi
    3180           0 :             do i = ilo, ihi
    3181           0 :                if ((iglob(i) > iedge .and. iglob(i) < nx_global-iedge+1) .and. &
    3182           0 :                    (jglob(j) > jedge .and. jglob(j) < ny_global-jedge+1)) then
    3183           0 :                   icells = icells + 1
    3184           0 :                   indxi(icells) = i
    3185           0 :                   indxj(icells) = j
    3186             :                endif
    3187             :             enddo
    3188             :             enddo
    3189             : 
    3190           0 :          elseif (trim(ice_data_type) == 'eastblock') then
    3191             :             ! block on east half of domain in center of domain
    3192           0 :             icells = 0
    3193           0 :             do j = jlo, jhi
    3194           0 :             do i = ilo, ihi
    3195           0 :                if (jglob(j) > ny_global/4 .and. jglob(j) < 3*nx_global/4 .and. &
    3196           0 :                    iglob(i) >= nx_global/2) then
    3197           0 :                   icells = icells + 1
    3198           0 :                   indxi(icells) = i
    3199           0 :                   indxj(icells) = j
    3200             :                endif
    3201             :             enddo
    3202             :             enddo
    3203             : 
    3204           0 :          elseif (trim(ice_data_type) == 'latsst') then
    3205             : 
    3206             :             !-----------------------------------------------------------------
    3207             :             ! Place ice where ocean surface is cold.
    3208             :             ! Note: If SST is not read from a file, then the ocean is assumed
    3209             :             !       to be at its freezing point everywhere, and ice will
    3210             :             !       extend to the prescribed edges.
    3211             :             !-----------------------------------------------------------------
    3212             : 
    3213           0 :             icells = 0
    3214           0 :             do j = jlo, jhi
    3215           0 :             do i = ilo, ihi
    3216           0 :                if (tmask(i,j)) then
    3217             :                   ! place ice in high latitudes where ocean sfc is cold
    3218             : #ifdef CESMCOUPLED
    3219             :                   ! Option to use Tair instead.
    3220             :                   if ( (Tair (i,j) <= Tffresh) .and. &
    3221             : #else
    3222           0 :                   if ( (sst (i,j) <= Tf(i,j)+p2) .and. &
    3223             : #endif
    3224           0 :                        (TLAT(i,j) < edge_init_sh/rad_to_deg .or. &
    3225             :                         TLAT(i,j) > edge_init_nh/rad_to_deg) ) then
    3226           0 :                      icells = icells + 1
    3227           0 :                      indxi(icells) = i
    3228           0 :                      indxj(icells) = j
    3229             :                   endif            ! cold surface
    3230             :                endif               ! tmask
    3231             :             enddo                  ! i
    3232             :             enddo                  ! j
    3233             : 
    3234             :          else
    3235             : 
    3236             :             call abort_ice(subname//'ERROR: ice_data_type setting = '//trim(ice_data_type), &
    3237           0 :                file=__FILE__, line=__LINE__)
    3238             : 
    3239             :          endif                     ! ice_data_type
    3240             : 
    3241             :          !---------------------------------------------------------
    3242             :          ! ice distribution
    3243             :          !---------------------------------------------------------
    3244             : 
    3245         192 :          do n = 1, ncat
    3246             : 
    3247             :             ! ice volume, snow volume
    3248      159192 :             do ij = 1, icells
    3249      159000 :                i = indxi(ij)
    3250      159000 :                j = indxj(ij)
    3251             : 
    3252      159000 :                aicen(i,j,n) = ainit(n)
    3253             : 
    3254      159000 :                if (trim(ice_data_dist) == 'box2001') then
    3255      159000 :                   if (hinit(n) > c0) then
    3256             : !                  ! varies linearly from 0 to 1 in x direction
    3257           0 :                      aicen(i,j,n) = (real(iglob(i), kind=dbl_kind)-p5) &
    3258       31800 :                                   / (real(nx_global,kind=dbl_kind))
    3259             : !                  ! constant slope from 0 to 0.5 in x direction
    3260             : !                     aicen(i,j,n) = (real(iglob(i), kind=dbl_kind)-p5) &
    3261             : !                                  / (real(nx_global,kind=dbl_kind)) * p5
    3262             : !                  ! quadratic
    3263             : !                     aicen(i,j,n) = max(c0,(real(iglob(i), kind=dbl_kind)-p5) &
    3264             : !                                         / (real(nx_global,kind=dbl_kind)) &   ! LCOV_EXCL_LINE
    3265             : !                                         * (real(jglob(j), kind=dbl_kind)-p5) &   ! LCOV_EXCL_LINE
    3266             : !                                         / (real(ny_global,kind=dbl_kind)) * p5)
    3267             : !                     aicen(i,j,n) = max(c0,(real(nx_global, kind=dbl_kind) &
    3268             : !                                         -  real(iglob(i), kind=dbl_kind)-p5) &   ! LCOV_EXCL_LINE
    3269             : !                                         / (real(nx_global,kind=dbl_kind)) &   ! LCOV_EXCL_LINE
    3270             : !                                         * (real(ny_global, kind=dbl_kind) &   ! LCOV_EXCL_LINE
    3271             : !                                         -  real(jglob(j), kind=dbl_kind)-p5) &   ! LCOV_EXCL_LINE
    3272             : !                                         / (real(ny_global,kind=dbl_kind)) * p5)
    3273             :                   endif
    3274             : 
    3275           0 :                elseif (trim(ice_data_dist) == 'gauss') then
    3276           0 :                   if (hinit(n) > c0) then
    3277             :                      dist_ratio = 8._dbl_kind * &
    3278             :                                   sqrt((real(iglob(i),kind=dbl_kind)-real(nx_global+1,kind=dbl_kind)/c2)**2 + &   ! LCOV_EXCL_LINE
    3279             :                                        (real(jglob(j),kind=dbl_kind)-real(ny_global+1,kind=dbl_kind)/c2)**2) / &   ! LCOV_EXCL_LINE
    3280             :                                   sqrt((real(nx_global,kind=dbl_kind))**2 + &   ! LCOV_EXCL_LINE
    3281           0 :                                        (real(ny_global,kind=dbl_kind))**2)
    3282           0 :                      aicen(i,j,n) = ainit(n) * exp(-dist_ratio)
    3283             :                   endif
    3284             : 
    3285           0 :                elseif (trim(ice_data_dist) == 'uniform') then
    3286             : 
    3287             :                   ! nothing extra to do
    3288             : 
    3289             :                else
    3290             : 
    3291             :                   call abort_ice(subname//'ERROR: ice_data_dist setting = '//trim(ice_data_dist), &
    3292           0 :                   file=__FILE__, line=__LINE__)
    3293             : 
    3294             :                endif  ! ice_data_dist
    3295             : 
    3296      159000 :                vicen(i,j,n) = hinit(n) * aicen(i,j,n) ! m
    3297      159000 :                vsnon(i,j,n) = min(aicen(i,j,n)*hsno_init,p2*vicen(i,j,n))
    3298             : 
    3299           0 :                call icepack_init_trcr(Tair  = Tair(i,j), Tf = Tf(i,j),  &
    3300             :                                       Sprofile = salinz(i,j,:),         &   ! LCOV_EXCL_LINE
    3301             :                                       Tprofile = Tmltz(i,j,:),          &   ! LCOV_EXCL_LINE
    3302             :                                       Tsfc  = Tsfc,                     &   ! LCOV_EXCL_LINE
    3303             :                                       nilyr = nilyr,     nslyr = nslyr, &   ! LCOV_EXCL_LINE
    3304      159000 :                                       qin   = qin(:),    qsn = qsn(:))
    3305             : 
    3306             :                ! surface temperature
    3307      159000 :                trcrn(i,j,nt_Tsfc,n) = Tsfc ! deg C
    3308             :                ! ice enthalpy, salinity
    3309     1272000 :                do k = 1, nilyr
    3310     1113000 :                   trcrn(i,j,nt_qice+k-1,n) = qin(k)
    3311     1272000 :                   trcrn(i,j,nt_sice+k-1,n) = salinz(i,j,k)
    3312             :                enddo
    3313             :                ! snow enthalpy
    3314      318000 :                do k = 1, nslyr
    3315      318000 :                   trcrn(i,j,nt_qsno+k-1,n) = qsn(k)
    3316             :                enddo               ! nslyr
    3317             :                ! brine fraction
    3318      159160 :                if (tr_brine) trcrn(i,j,nt_fbri,n) = c1
    3319             : 
    3320             :             enddo               ! ij
    3321             :          enddo                  ! ncat
    3322             : 
    3323             :          !---------------------------------------------------------
    3324             :          ! ice velocity
    3325             :          ! these velocites are defined on B-grid
    3326             :          !---------------------------------------------------------
    3327             : 
    3328          32 :          if (trim(ice_data_type) == 'boxslotcyl') then
    3329           0 :             domain_length = dxrect*cm_to_m*nx_global
    3330           0 :             period        = c12*secday               ! 12 days rotational period
    3331           0 :             max_vel       = pi*domain_length/period
    3332             : 
    3333           0 :             do j = 1, ny_block
    3334           0 :             do i = 1, nx_block
    3335             : 
    3336           0 :                if (umask(i,j)) then
    3337           0 :                   uvel(i,j) =  c2*max_vel*(real(jglob(j), kind=dbl_kind) - p5) &
    3338           0 :                             / real(ny_global - 1, kind=dbl_kind) - max_vel
    3339           0 :                   vvel(i,j) = -c2*max_vel*(real(iglob(i), kind=dbl_kind) - p5) &
    3340           0 :                             / real(nx_global - 1, kind=dbl_kind) + max_vel
    3341             :                else
    3342           0 :                   uvel(i,j) = c0
    3343           0 :                   vvel(i,j) = c0
    3344             :                endif
    3345             :             enddo               ! j
    3346             :             enddo               ! i
    3347             :          else
    3348       38112 :             uvel = c0
    3349       38112 :             vvel = c0
    3350             :          endif
    3351             : 
    3352             :       endif                     ! ice_ic
    3353             : 
    3354         160 :       call icepack_warnings_flush(nu_diag)
    3355         160 :       if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
    3356           0 :          file=__FILE__, line=__LINE__)
    3357             : 
    3358         160 :       end subroutine set_state_var
    3359             : 
    3360             : !=======================================================================
    3361             : 
    3362             :       end module ice_init
    3363             : 
    3364             : !=======================================================================

Generated by: LCOV version 1.14-6-g40580cd