diff --git a/cicecore/cicedynB/general/ice_init.F90 b/cicecore/cicedynB/general/ice_init.F90 index 87a0f69cc..75ae1f669 100644 --- a/cicecore/cicedynB/general/ice_init.F90 +++ b/cicecore/cicedynB/general/ice_init.F90 @@ -132,6 +132,7 @@ subroutine input_data integer (kind=int_kind) :: rpcesm, rplvl, rptopo real (kind=dbl_kind) :: Cf, puny integer :: abort_flag + character (len=64) :: tmpstr character(len=*), parameter :: subname='(input_data)' @@ -472,8 +473,8 @@ subroutine input_data ! each task gets unique ice log filename when if test is true, for debugging if (1 == 0) then call get_fileUnit(nu_diag) - write(str,'(a,i4.4)') "ice.log.task_",my_task - open(nu_diag,file=str) + write(tmpstr,'(a,i4.4)') "ice.log.task_",my_task + open(nu_diag,file=tmpstr) endif end if if (trim(ice_ic) /= 'default' .and. trim(ice_ic) /= 'none') then diff --git a/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 b/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 index cee9d32d5..f00501bfc 100644 --- a/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 +++ b/cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90 @@ -666,6 +666,7 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & integer (kind=int_kind) :: & j, & ! dimension counter n, & ! number of dimensions for variable + ndims, & ! number of variable dimensions status ! status variable from netCDF routine real (kind=dbl_kind) :: amin,amax,asum @@ -681,12 +682,15 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & status = pio_inq_varid(File,trim(vname),vardesc) if (status /= 0) then - call abort_ice(subname//"ERROR: CICE4 restart? Missing variable: "//trim(vname)) + call abort_ice(subname//"ERROR: CICE restart? Missing variable: "//trim(vname)) endif + status = pio_inq_varndims(File, vardesc, ndims) + call pio_seterrorhandling(File, PIO_INTERNAL_ERROR) - if (ndim3 == ncat .and. ncat>1) then +! if (ndim3 == ncat .and. ncat>1) then + if (ndim3 == ncat .and. ndims == 3) then call pio_read_darray(File, vardesc, iodesc3d_ncat, work, status) if (present(field_loc)) then do n=1,ndim3 @@ -694,7 +698,8 @@ subroutine read_restart_field(nu,nrec,work,atype,vname,ndim3,diag, & field_loc, field_type) enddo endif - elseif (ndim3 == 1) then +! elseif (ndim3 == 1) then + elseif (ndim3 == 1 .and. ndims == 2) then call pio_read_darray(File, vardesc, iodesc2d, work, status) if (present(field_loc)) then call ice_HaloUpdate (work(:,:,1,:), halo_info, & diff --git a/cicecore/drivers/cesm/CICE_FinalMod.F90 b/cicecore/drivers/cesm/CICE_FinalMod.F90 index 05e3da174..c2331e4e5 100644 --- a/cicecore/drivers/cesm/CICE_FinalMod.F90 +++ b/cicecore/drivers/cesm/CICE_FinalMod.F90 @@ -11,7 +11,8 @@ module CICE_FinalMod use ice_kinds_mod - use ice_exit, only: abort_ice, end_run + use ice_communicate, only: my_task, master_task + use ice_exit, only: end_run, abort_ice use ice_fileunits, only: nu_diag, release_all_fileunits use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted @@ -70,7 +71,6 @@ end subroutine CICE_Finalize subroutine writeout_finished_file() use ice_restart_shared, only: restart_dir - use ice_communicate, only: my_task, master_task character(len=char_len_long) :: filename character(len=*), parameter :: subname = '(writeout_finished_file)' diff --git a/cicecore/drivers/cesm/CICE_InitMod.F90 b/cicecore/drivers/cesm/CICE_InitMod.F90 index 5a7e4ec84..56d30cb72 100644 --- a/cicecore/drivers/cesm/CICE_InitMod.F90 +++ b/cicecore/drivers/cesm/CICE_InitMod.F90 @@ -15,10 +15,12 @@ module CICE_InitMod use ice_kinds_mod use ice_exit, only: abort_ice use ice_fileunits, only: init_fileunits, nu_diag + use icepack_intfc, only: icepack_aggregate + use icepack_intfc, only: icepack_init_itd, icepack_init_itd_hist + use icepack_intfc, only: icepack_configure use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted - use icepack_intfc, only: icepack_query_parameters - use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_indices - use icepack_intfc, only: icepack_query_tracer_numbers + use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_flags, & + icepack_query_tracer_indices, icepack_query_tracer_numbers implicit none private @@ -41,7 +43,7 @@ module CICE_InitMod subroutine CICE_Initialize - character(len=*), parameter :: subname = '(CICE_Initialize)' + character(len=*), parameter :: subname='(CICE_Initialize)' !-------------------------------------------------------------------- ! model initialization @@ -57,10 +59,11 @@ end subroutine CICE_Initialize subroutine cice_init(mpicom_ice) - use ice_arrays_column, only: hin_max, c_hi_range, zfswin, trcrn_sw, & - ocean_bio_all, ice_bio_net, snow_bio_net, alloc_arrays_column - use ice_calendar, only: dt, dt_dyn, write_ic, & - init_calendar, calendar, time + use ice_arrays_column, only: hin_max, c_hi_range, alloc_arrays_column + use ice_state, only: alloc_state + use ice_flux_bgc, only: alloc_flux_bgc + use ice_calendar, only: dt, dt_dyn, time, istep, istep1, write_ic, & + init_calendar, calendar use ice_communicate, only: init_communicate, my_task, master_task use ice_diagnostics, only: init_diags use ice_domain, only: init_domain_blocks @@ -72,18 +75,16 @@ subroutine cice_init(mpicom_ice) use ice_forcing, only: init_forcing_ocn, init_forcing_atmo, & get_forcing_atmo, get_forcing_ocn, alloc_forcing use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & - faero_data, faero_default, faero_optics, alloc_forcing_bgc + faero_default, faero_optics, alloc_forcing_bgc use ice_grid, only: init_grid1, init_grid2, alloc_grid use ice_history, only: init_hist, accum_hist use ice_restart_shared, only: restart, runid, runtype use ice_init, only: input_data, init_state - use ice_init_column, only: init_thermo_vertical, init_shortwave, init_zbgc + use ice_init_column, only: init_thermo_vertical, init_shortwave, init_zbgc, input_zbgc, count_tracers use ice_kinds_mod use ice_restoring, only: ice_HaloRestore_init use ice_timers, only: timer_total, init_ice_timers, ice_timer_start use ice_transport_driver, only: init_transport - use icepack_intfc, only: icepack_configure - use icepack_intfc, only: icepack_init_itd, icepack_init_itd_hist #ifdef popcice use drv_forcing, only: sst_sss #endif @@ -91,34 +92,33 @@ subroutine cice_init(mpicom_ice) integer (kind=int_kind), optional, intent(in) :: & mpicom_ice ! communicator for sequential ccsm - logical (kind=log_kind) :: & - tr_aero, tr_zaero, skl_bgc, z_tracers - - character(len=*), parameter :: subname='(cice_init)' + logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers + character(len=*), parameter :: subname = '(cice_init)' call init_communicate(mpicom_ice) ! initial setup for message passing call init_fileunits ! unit numbers call icepack_configure() ! initialize icepack call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(subname, & + if (icepack_warnings_aborted()) call abort_ice(trim(subname), & file=__FILE__,line= __LINE__) call input_data ! namelist variables - if (trim(runid) == 'bering') call check_finished_file + call input_zbgc ! vertical biogeochemistry namelist + call count_tracers ! count tracers call init_domain_blocks ! set up block decomposition call init_grid1 ! domain distribution - call alloc_grid ! allocate grid + call alloc_grid ! allocate grid arrays call alloc_arrays_column ! allocate column arrays - call alloc_state ! allocate state - call alloc_dyn_shared ! allocate dyn shared (init_uvel,init_vvel) - call alloc_flux_bgc ! allocate flux_bgc - call alloc_flux ! allocate flux + call alloc_state ! allocate state arrays + call alloc_dyn_shared ! allocate dyn shared arrays + call alloc_flux_bgc ! allocate flux_bgc arrays + call alloc_flux ! allocate flux arrays call init_ice_timers ! initialize all timers call ice_timer_start(timer_total) ! start timing entire run call init_grid2 ! grid variables - call init_zbgc ! vertical biogeochemistry namelist + call init_zbgc ! vertical biogeochemistry initialization call init_calendar ! initialize some calendar stuff call init_hist (dt) ! initialize output history file @@ -135,14 +135,14 @@ subroutine cice_init(mpicom_ice) call sst_sss ! POP data for CICE initialization #endif call init_thermo_vertical ! initialize vertical thermodynamics - call icepack_init_itd(ncat, hin_max) ! ice thickness distribution + call icepack_init_itd(ncat, hin_max) ! ice thickness distribution if (my_task == master_task) then call icepack_init_itd_hist(ncat, hin_max, c_hi_range) ! output endif call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) + file=__FILE__, line=__LINE__) call calendar(time) ! determine the initial date @@ -150,19 +150,23 @@ subroutine cice_init(mpicom_ice) call init_state ! initialize the ice state call init_transport ! initialize horizontal transport call ice_HaloRestore_init ! restored boundary conditions + call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(trim(subname), & + file=__FILE__,line= __LINE__) + if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! allocate biogeochemistry arrays call init_restart ! initialize restart variables - call init_diags ! initialize diagnostic output points call init_history_therm ! initialize thermo history variables call init_history_dyn ! initialize dynamic history variables call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) + if (icepack_warnings_aborted()) call abort_ice(trim(subname), & + file=__FILE__,line= __LINE__) if (tr_aero .or. tr_zaero) call faero_optics !initialize aerosol optical !property tables @@ -210,12 +214,11 @@ subroutine init_restart use ice_arrays_column, only: dhsn use ice_blocks, only: nx_block, ny_block use ice_calendar, only: time, calendar - use icepack_intfc, only: icepack_aggregate + use ice_constants, only: c0 use ice_domain, only: nblocks use ice_domain_size, only: ncat, n_aero use ice_dyn_eap, only: read_restart_eap use ice_dyn_shared, only: kdyn - use ice_flux, only: sss use ice_grid, only: tmask use ice_init, only: ice_ic use ice_init_column, only: init_age, init_FY, init_lvl, & @@ -229,25 +232,21 @@ subroutine init_restart restart_aero, read_restart_aero, & restart_hbrine, read_restart_hbrine, & restart_zsal, restart_bgc - use ice_restart_driver, only: restartfile, restartfile_v4 + use ice_restart_driver, only: restartfile use ice_restart_shared, only: runtype, restart use ice_state ! almost everything - integer (kind=int_kind) :: & + integer(kind=int_kind) :: & i, j , & ! horizontal indices - iblk , & ! block index - ltmp - - logical (kind=log_kind) :: & - tr_iage, tr_FY, tr_lvl, & - tr_pond_cesm, tr_pond_lvl, & + iblk ! block index + logical(kind=log_kind) :: & + tr_iage, tr_FY, tr_lvl, tr_pond_cesm, tr_pond_lvl, & tr_pond_topo, tr_aero, tr_brine, & skl_bgc, z_tracers, solve_zsal - integer (kind=int_kind) :: & + integer(kind=int_kind) :: & ntrcr - integer (kind=int_kind) :: & - nt_alvl, nt_vlvl, & - nt_apnd, nt_hpnd, nt_ipnd, & + integer(kind=int_kind) :: & + nt_alvl, nt_vlvl, nt_apnd, nt_hpnd, nt_ipnd, & nt_iage, nt_FY, nt_aero character(len=*), parameter :: subname = '(init_restart)' @@ -257,16 +256,17 @@ subroutine init_restart if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & file=__FILE__, line=__LINE__) - call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers, solve_zsal_out=solve_zsal) - call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, & - tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & - tr_pond_topo_out=tr_pond_topo, tr_aero_out=tr_aero, tr_brine_out=tr_brine) + call icepack_query_parameters(skl_bgc_out=skl_bgc, & + z_tracers_out=z_tracers, solve_zsal_out=solve_zsal) + call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & + tr_pond_topo_out=tr_pond_topo, tr_aero_out=tr_aero, tr_brine_out=tr_brine) call icepack_query_tracer_indices(nt_alvl_out=nt_alvl, nt_vlvl_out=nt_vlvl, & - nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & - nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_aero_out=nt_aero) + nt_apnd_out=nt_apnd, nt_hpnd_out=nt_hpnd, nt_ipnd_out=nt_ipnd, & + nt_iage_out=nt_iage, nt_FY_out=nt_FY, nt_aero_out=nt_aero) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) + file=__FILE__, line=__LINE__) if (trim(runtype) == 'continue') then ! start from core restart file @@ -274,14 +274,11 @@ subroutine init_restart call calendar(time) ! update time parameters if (kdyn == 2) call read_restart_eap ! EAP else if (restart) then ! ice_ic = core restart file - ltmp = len_trim(ice_ic) - if (ice_ic(ltmp-2:ltmp) == '.nc') then - call restartfile (ice_ic) ! or 'default' or 'none' - else - call restartfile_v4 (ice_ic) ! CICE v4.1 binary restart file - !!! uncomment if EAP restart data exists - ! if (kdyn == 2) call read_restart_eap - endif + call restartfile (ice_ic) ! or 'default' or 'none' + !!! uncomment to create netcdf + ! call restartfile_v4 (ice_ic) ! CICE v4.1 binary restart file + !!! uncomment if EAP restart data exists + ! if (kdyn == 2) call read_restart_eap endif ! tracers @@ -315,7 +312,7 @@ subroutine init_restart call read_restart_lvl else do iblk = 1, nblocks - call init_lvl(trcrn(:,:,nt_alvl,:,iblk), & + call init_lvl(iblk,trcrn(:,:,nt_alvl,:,iblk), & trcrn(:,:,nt_vlvl,:,iblk)) enddo ! iblk endif @@ -360,7 +357,7 @@ subroutine init_restart trcrn(:,:,nt_hpnd,:,iblk), & trcrn(:,:,nt_ipnd,:,iblk)) enddo ! iblk - endif ! .not restart_pond + endif ! .not. restart_pond endif if (tr_aero) then ! ice aerosol if (trim(runtype) == 'continue') restart_aero = .true. @@ -372,7 +369,7 @@ subroutine init_restart enddo ! iblk endif ! .not. restart_aero endif - + if (trim(runtype) == 'continue') then if (tr_brine) & restart_hbrine = .true. @@ -397,57 +394,36 @@ subroutine init_restart do iblk = 1, nblocks do j = 1, ny_block do i = 1, nx_block - if (tmask(i,j,iblk)) & - call icepack_aggregate (ncat, & - aicen(i,j,:,iblk), & - trcrn(i,j,:,:,iblk),& - vicen(i,j,:,iblk), & - vsnon(i,j,:,iblk), & - aice (i,j, iblk), & - trcr (i,j,:,iblk), & - vice (i,j, iblk), & - vsno (i,j, iblk), & - aice0(i,j, iblk), & - ntrcr, & - trcr_depend, & - trcr_base, & - n_trcr_strata, & - nt_strata) + if (tmask(i,j,iblk)) then + call icepack_aggregate (ncat, & + aicen(i,j,:,iblk), & + trcrn(i,j,:,:,iblk),& + vicen(i,j,:,iblk), & + vsnon(i,j,:,iblk), & + aice (i,j, iblk), & + trcr (i,j,:,iblk), & + vice (i,j, iblk), & + vsno (i,j, iblk), & + aice0(i,j, iblk), & + ntrcr, & + trcr_depend, & + trcr_base, & + n_trcr_strata, & + nt_strata) + else + ! tcraig, reset all tracer values on land to zero + trcrn(i,j,:,:,iblk) = c0 + endif enddo enddo enddo !$OMP END PARALLEL DO - end subroutine init_restart - -!======================================================================= -! -! Check whether a file indicating that the previous run finished cleanly -! If so, then do not continue the current restart. This is needed only -! for runs on machine 'bering' (set using runid = 'bering'). -! -! author: Adrian Turner, LANL - - subroutine check_finished_file() - - use ice_communicate, only: my_task, master_task - use ice_restart_shared, only: restart_dir - - character(len=char_len_long) :: filename - logical :: lexist = .false. - character(len=*), parameter :: subname = '(check_finished_file)' - - if (my_task == master_task) then - - filename = trim(restart_dir)//"finished" - inquire(file=filename, exist=lexist) - if (lexist) then - call abort_ice(subname//"ERROR: Found already finished file - quitting") - end if - - endif + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) - end subroutine check_finished_file + end subroutine init_restart !======================================================================= diff --git a/cicecore/drivers/cesm/CICE_RunMod.F90 b/cicecore/drivers/cesm/CICE_RunMod.F90 index 704a96ab0..9ed65826b 100644 --- a/cicecore/drivers/cesm/CICE_RunMod.F90 +++ b/cicecore/drivers/cesm/CICE_RunMod.F90 @@ -17,8 +17,12 @@ module CICE_RunMod use ice_kinds_mod use perf_mod, only : t_startf, t_stopf, t_barrierf use ice_fileunits, only: nu_diag + use ice_arrays_column, only: oceanmixed_ice + use ice_constants, only: c0, c1 + use ice_constants, only: field_loc_center, field_type_scalar use ice_exit, only: abort_ice use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted + use icepack_intfc, only: icepack_max_aero use icepack_intfc, only: icepack_query_parameters use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_numbers @@ -41,27 +45,28 @@ module CICE_RunMod subroutine CICE_Run use ice_calendar, only: istep, istep1, time, dt, stop_now, calendar - use ice_forcing, only: get_forcing_atmo, get_forcing_ocn - use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, fzaero_data, & + use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, atm_data_type + use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & faero_default use ice_flux, only: init_flux_atm, init_flux_ocn use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_couple, timer_step - logical (kind=log_kind) :: tr_aero, tr_zaero - logical (kind=log_kind) :: skl_bgc, z_tracers + logical (kind=log_kind) :: & + tr_aero, tr_zaero, skl_bgc, z_tracers character(len=*), parameter :: subname = '(CICE_Run)' + !-------------------------------------------------------------------- ! initialize error code and step timer !-------------------------------------------------------------------- call ice_timer_start(timer_step) ! start timing entire run - call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers) + call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) + file=__FILE__, line=__LINE__) !-------------------------------------------------------------------- ! timestep loop @@ -90,11 +95,13 @@ subroutine CICE_Run #endif if (z_tracers) call get_atm_bgc ! biogeochemistry - call init_flux_atm ! initialize atmosphere fluxes sent to coupler - call init_flux_ocn ! initialize ocean fluxes sent to coupler + call init_flux_atm ! Initialize atmosphere fluxes sent to coupler + call init_flux_ocn ! initialize ocean fluxes sent to coupler call calendar(time) ! at the end of the timestep + call ice_timer_stop(timer_couple) ! atm/ocn coupling + call ice_step ! if (stop_now >= 1) exit timeLoop @@ -119,13 +126,11 @@ subroutine ice_step use ice_boundary, only: ice_HaloUpdate use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep, idate, sec - use ice_constants, only: field_loc_center, field_type_scalar, c0 - use ice_diagnostics, only: init_mass_diags, runtime_diags, print_points_state + use ice_diagnostics, only: init_mass_diags, runtime_diags use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags use ice_domain, only: halo_info, nblocks - use ice_domain_size, only: nslyr use ice_dyn_eap, only: write_restart_eap - use ice_dyn_shared, only: kdyn + use ice_dyn_shared, only: kdyn, kridge use ice_flux, only: scale_factor, init_history_therm, & daidtt, daidtd, dvidtt, dvidtd, dagedtt, dagedtd use ice_history, only: accum_hist @@ -137,10 +142,9 @@ subroutine ice_step write_restart_bgc, write_restart_hbrine use ice_restart_driver, only: dumpfile use ice_restoring, only: restore_ice, ice_HaloRestore - use ice_state, only: trcrn use ice_step_mod, only: prep_radiation, step_therm1, step_therm2, & update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - biogeochemistry + biogeochemistry, save_init use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_diags, timer_column, timer_thermo, timer_bound, & timer_hist, timer_readwrite @@ -149,27 +153,27 @@ subroutine ice_step integer (kind=int_kind) :: & iblk , & ! block index - k ! dynamics supercycling index + k , & ! dynamics supercycling index + ktherm ! thermodynamics is off when ktherm = -1 real (kind=dbl_kind) :: & offset ! d(age)/dt time offset logical (kind=log_kind) :: & - calc_Tsfc, skl_bgc, solve_zsal, z_tracers, & - tr_iage, tr_FY, tr_lvl, & - tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero + tr_iage, tr_FY, tr_lvl, & + tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & + calc_Tsfc, skl_bgc, solve_zsal, z_tracers character(len=*), parameter :: subname = '(ice_step)' call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & - solve_zsal_out=solve_zsal, z_tracers_out=z_tracers) - call icepack_query_tracer_flags( & - tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, & - tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & - tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero) + solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm) + call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & + tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero) call icepack_warnings_flush(nu_diag) if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) + file=__FILE__, line=__LINE__) !----------------------------------------------------------------- ! restoring on grid boundaries @@ -178,7 +182,7 @@ subroutine ice_step if (restore_ice) call ice_HaloRestore !----------------------------------------------------------------- - ! initialize diagnostics + ! initialize diagnostics and save initial state values !----------------------------------------------------------------- call ice_timer_start(timer_diags) ! diagnostics/history @@ -194,26 +198,32 @@ subroutine ice_step call t_stopf ('cice_run_presc') endif + call save_init + call ice_timer_start(timer_column) ! column physics call ice_timer_start(timer_thermo) ! thermodynamics !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks + if (ktherm >= 0) then + !----------------------------------------------------------------- - ! Scale radiation fields + ! scale radiation fields !----------------------------------------------------------------- - if (calc_Tsfc) call prep_radiation (dt, iblk) + if (calc_Tsfc) call prep_radiation (iblk) !----------------------------------------------------------------- ! thermodynamics and biogeochemistry !----------------------------------------------------------------- - call step_therm1 (dt, iblk) ! vertical thermodynamics - call biogeochemistry (dt, iblk) ! biogeochemistry - if (.not.prescribed_ice) & - call step_therm2 (dt, iblk) ! ice thickness distribution thermo + call step_therm1 (dt, iblk) ! vertical thermodynamics + call biogeochemistry (dt, iblk) ! biogeochemistry + if (.not.prescribed_ice) & + call step_therm2 (dt, iblk) ! ice thickness distribution thermo + + endif enddo ! iblk !$OMP END PARALLEL DO @@ -238,7 +248,7 @@ subroutine ice_step ! ridging !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - call step_dyn_ridge (dt_dyn, ndtd, iblk) + if (kridge > 0) call step_dyn_ridge (dt_dyn, ndtd, iblk) enddo !$OMP END PARALLEL DO @@ -259,7 +269,7 @@ subroutine ice_step !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - call step_radiation (dt, iblk) + if (ktherm >= 0) call step_radiation (dt, iblk) !----------------------------------------------------------------- ! get ready for coupling and the next time step @@ -285,9 +295,9 @@ subroutine ice_step call ice_timer_start(timer_diags) ! diagnostics if (mod(istep,diagfreq) == 0) then call runtime_diags(dt) ! log file - if (solve_zsal) call zsal_diags(dt) - if (skl_bgc .or. z_tracers) call bgc_diags (dt) - if (tr_brine) call hbrine_diags (dt) + if (solve_zsal) call zsal_diags + if (skl_bgc .or. z_tracers) call bgc_diags + if (tr_brine) call hbrine_diags endif call ice_timer_stop(timer_diags) ! diagnostics @@ -326,25 +336,22 @@ subroutine coupling_prep (iblk) use ice_arrays_column, only: alvdfn, alidfn, alvdrn, alidrn, & albicen, albsnon, albpndn, apeffn, fzsal_g, fzsal, snowfracn - use ice_arrays_column, only: oceanmixed_ice - use ice_blocks, only: block, nx_block, ny_block + use ice_blocks, only: nx_block, ny_block, get_block, block + use ice_domain, only: blocks_ice use ice_calendar, only: dt, nstreams - use ice_constants, only: c0, c1 use ice_domain_size, only: ncat use ice_flux, only: alvdf, alidf, alvdr, alidr, albice, albsno, & - albpnd, albcnt, apeff_ai, coszen, fpond, fresh, l_mpond_fresh, & + albpnd, albcnt, apeff_ai, fpond, fresh, l_mpond_fresh, & alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, & fresh_ai, fsalt_ai, fsalt, & fswthru_ai, fhocn, fswthru, scale_factor, snowfrac, & - swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyt, & - fsens, flat, fswabs, flwout, evap, Tref, Qref, Uref, & - fsurfn_f, flatn_f, scale_fluxes, frzmlt_init, frzmlt, wind - use ice_flux_bgc, only: bgcflux_ice_to_ocn, & - faero_ocn, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai, & - fnit, fsil, famm, fdmsp, fdms, fhum, fdust, falgalN, fdoc, & - fdic, fdon, ffep, ffed + swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyT, & + fsens, flat, fswabs, flwout, evap, Tref, Qref, & + scale_fluxes, frzmlt_init, frzmlt, Uref, wind, fsurfn_f, flatn_f + use ice_flux_bgc, only: faero_ocn, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai, & + fnit, fsil, famm, fdmsp, fdms, fhum, fdust, falgalN, & + fdoc, fdic, fdon, ffep, ffed, bgcflux_ice_to_ocn use ice_grid, only: tmask - use icepack_intfc, only: icepack_max_aero use ice_state, only: aicen, aice, aice_init use ice_step_mod, only: ocean_mixed_layer use ice_timers, only: timer_couple, ice_timer_start, ice_timer_stop @@ -355,30 +362,36 @@ subroutine coupling_prep (iblk) ! local variables integer (kind=int_kind) :: & + ilo,ihi,jlo,jhi, & ! beginning and end of physical domain n , & ! thickness category index i,j , & ! horizontal indices - k ! tracer index + k , & ! tracer index + nbtrcr ! + + type (block) :: & + this_block ! block information for current block + + logical (kind=log_kind) :: & + skl_bgc , & ! + calc_Tsfc ! real (kind=dbl_kind) :: & cszn , & ! counter for history averaging + puny , & ! + rhofresh , & ! netsw ! flag for shortwave radiation presence - logical (kind=log_kind) :: & - calc_Tsfc, skl_bgc - integer (kind=int_kind) :: & - nbtrcr - real (kind=dbl_kind) :: & - puny, rhofresh character(len=*), parameter :: subname = '(coupling_prep)' !----------------------------------------------------------------- - call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & - puny_out=puny, rhofresh_out=rhofresh) - call icepack_query_tracer_numbers(nbtrcr_out=nbtrcr) - call icepack_warnings_flush(nu_diag) - if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & - file=__FILE__, line=__LINE__) + call icepack_query_parameters(puny_out=puny, rhofresh_out=rhofresh) + call icepack_query_parameters(skl_bgc_out=skl_bgc) + call icepack_query_tracer_numbers(nbtrcr_out=nbtrcr) + call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) !----------------------------------------------------------------- ! Save current value of frzmlt for diagnostics. @@ -422,11 +435,18 @@ subroutine coupling_prep (iblk) enddo enddo enddo + + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + do n = 1, ncat - do j = 1, ny_block - do i = 1, nx_block + do j = jlo, jhi + do i = ilo, ihi if (aicen(i,j,n,iblk) > puny) then - + alvdf(i,j,iblk) = alvdf(i,j,iblk) & + alvdfn(i,j,n,iblk)*aicen(i,j,n,iblk) alidf(i,j,iblk) = alidf(i,j,iblk) & @@ -451,7 +471,7 @@ subroutine coupling_prep (iblk) + apeffn(i,j,n,iblk)*aicen(i,j,n,iblk) snowfrac(i,j,iblk) = snowfrac(i,j,iblk) & ! for history + snowfracn(i,j,n,iblk)*aicen(i,j,n,iblk) - + endif ! aicen > puny enddo enddo @@ -484,7 +504,7 @@ subroutine coupling_prep (iblk) fzsal_ai (i,j,iblk) = fzsal (i,j,iblk) fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk) - if (nbtrcr > 0 .or. skl_bgc) then + if (nbtrcr > 0) then do k = 1, nbtrcr flux_bio_ai (i,j,k,iblk) = flux_bio (i,j,k,iblk) enddo @@ -604,10 +624,15 @@ subroutine sfcflux_to_ocn(nx_block, ny_block, & i, j, n ! horizontal indices real (kind=dbl_kind) :: & + puny, & ! rLsub ! 1/Lsub character(len=*), parameter :: subname = '(sfcflux_to_ocn)' + call icepack_query_parameters(puny_out=puny) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) rLsub = c1 / Lsub do n = 1, ncat diff --git a/cicecore/drivers/cesm/CICE_RunMod.F90_debug b/cicecore/drivers/cesm/CICE_RunMod.F90_debug index c055a8cf5..ef505a353 100644 --- a/cicecore/drivers/cesm/CICE_RunMod.F90_debug +++ b/cicecore/drivers/cesm/CICE_RunMod.F90_debug @@ -15,13 +15,20 @@ module CICE_RunMod use ice_kinds_mod - use perf_mod, only : t_startf, t_stopf, t_barrierf + use perf_mod, only : t_startf, t_stopf, t_barrierf use ice_fileunits, only: nu_diag + use ice_arrays_column, only: oceanmixed_ice + use ice_constants, only: c0, c1 + use ice_constants, only: field_loc_center, field_type_scalar + use ice_exit, only: abort_ice + use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted + use icepack_intfc, only: icepack_max_aero + use icepack_intfc, only: icepack_query_parameters + use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_numbers implicit none private public :: CICE_Run, ice_step - save !======================================================================= @@ -38,14 +45,16 @@ subroutine CICE_Run use ice_calendar, only: istep, istep1, time, dt, stop_now, calendar - use ice_forcing, only: get_forcing_atmo, get_forcing_ocn - use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, fzaero_data, & + use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, atm_data_type + use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, & faero_default use ice_flux, only: init_flux_atm, init_flux_ocn - use ice_colpkg_tracers, only: tr_aero, tr_zaero use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_couple, timer_step - use ice_colpkg_shared, only: skl_bgc, z_tracers + + logical (kind=log_kind) :: & + tr_aero, tr_zaero, skl_bgc, z_tracers + character(len=*), parameter :: subname = '(CICE_Run)' !-------------------------------------------------------------------- ! initialize error code and step timer @@ -53,6 +62,12 @@ call ice_timer_start(timer_step) ! start timing entire run + call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers) + call icepack_query_tracer_flags(tr_aero_out=tr_aero, tr_zaero_out=tr_zaero) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) + !-------------------------------------------------------------------- ! timestep loop !-------------------------------------------------------------------- @@ -63,23 +78,30 @@ istep1 = istep1 + 1 time = time + dt ! determine the time and date -#ifndef coupled call ice_timer_start(timer_couple) ! atm/ocn coupling + +#ifndef coupled +#ifndef CESMCOUPLED call get_forcing_atmo ! atmospheric forcing from data call get_forcing_ocn(dt) ! ocean forcing from data - ! if (tr_aero) call faero_data ! aerosols - if (tr_aero .or. tr_zaero) call faero_default ! aerosols + + ! aerosols + ! if (tr_aero) call faero_data ! data file + ! if (tr_zaero) call fzaero_data ! data file (gx1) + if (tr_aero .or. tr_zaero) call faero_default ! default values + if (skl_bgc .or. z_tracers) call get_forcing_bgc ! biogeochemistry - if (z_tracers) call get_atm_bgc ! biogeochemistry - !if (tr_zaero) call fzaero_data ! zaerosols, gx1 - call ice_timer_stop(timer_couple) ! atm/ocn coupling #endif +#endif + if (z_tracers) call get_atm_bgc ! biogeochemistry - call init_flux_atm ! initialize atmosphere fluxes sent to coupler - call init_flux_ocn ! initialize ocean fluxes sent to coupler + call init_flux_atm ! Initialize atmosphere fluxes sent to coupler + call init_flux_ocn ! initialize ocean fluxes sent to coupler call calendar(time) ! at the end of the timestep + call ice_timer_stop(timer_couple) ! atm/ocn coupling + call ice_step ! if (stop_now >= 1) exit timeLoop @@ -104,13 +126,11 @@ use ice_boundary, only: ice_HaloUpdate use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep, idate, sec - use ice_constants, only: field_loc_center, field_type_scalar, c0 - use ice_diagnostics, only: init_mass_diags, runtime_diags, print_points_state + use ice_diagnostics, only: init_mass_diags, runtime_diags use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags use ice_domain, only: halo_info, nblocks - use ice_domain_size, only: nslyr use ice_dyn_eap, only: write_restart_eap - use ice_dyn_shared, only: kdyn + use ice_dyn_shared, only: kdyn, kridge use ice_flux, only: scale_factor, init_history_therm, & daidtt, daidtd, dvidtt, dvidtd, dagedtt, dagedtd use ice_history, only: accum_hist @@ -122,13 +142,9 @@ write_restart_bgc, write_restart_hbrine use ice_restart_driver, only: dumpfile use ice_restoring, only: restore_ice, ice_HaloRestore - use ice_state, only: trcrn - use ice_colpkg_tracers, only: tr_iage, tr_FY, tr_lvl, & - tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero use ice_step_mod, only: prep_radiation, step_therm1, step_therm2, & update_state, step_dyn_horiz, step_dyn_ridge, step_radiation, & - biogeochemistry - use ice_colpkg_shared, only: calc_Tsfc, skl_bgc, solve_zsal, z_tracers + biogeochemistry, save_init use ice_timers, only: ice_timer_start, ice_timer_stop, & timer_diags, timer_column, timer_thermo, timer_bound, & timer_hist, timer_readwrite @@ -137,11 +153,19 @@ integer (kind=int_kind) :: & iblk , & ! block index - k ! dynamics supercycling index + k , & ! dynamics supercycling index + ktherm ! thermodynamics is off when ktherm = -1 real (kind=dbl_kind) :: & offset ! d(age)/dt time offset + logical (kind=log_kind) :: & + tr_iage, tr_FY, tr_lvl, & + tr_pond_cesm, tr_pond_lvl, tr_pond_topo, tr_brine, tr_aero, & + calc_Tsfc, skl_bgc, solve_zsal, z_tracers + + character(len=*), parameter :: subname = '(ice_step)' + character (len=char_len) :: plabeld plabeld = 'beginning time step' @@ -149,6 +173,15 @@ call debug_ice (iblk, plabeld) enddo + call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc, skl_bgc_out=skl_bgc, & + solve_zsal_out=solve_zsal, z_tracers_out=z_tracers, ktherm_out=ktherm) + call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, & + tr_lvl_out=tr_lvl, tr_pond_cesm_out=tr_pond_cesm, tr_pond_lvl_out=tr_pond_lvl, & + tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) + !----------------------------------------------------------------- ! restoring on grid boundaries !----------------------------------------------------------------- @@ -156,7 +189,7 @@ if (restore_ice) call ice_HaloRestore !----------------------------------------------------------------- - ! initialize diagnostics + ! initialize diagnostics and save initial state values !----------------------------------------------------------------- call ice_timer_start(timer_diags) ! diagnostics/history @@ -172,40 +205,46 @@ call t_stopf ('cice_run_presc') endif + call save_init + call ice_timer_start(timer_column) ! column physics call ice_timer_start(timer_thermo) ! thermodynamics !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks + if (ktherm >= 0) then + !----------------------------------------------------------------- - ! Scale radiation fields + ! scale radiation fields !----------------------------------------------------------------- - if (calc_Tsfc) call prep_radiation (dt, iblk) + if (calc_Tsfc) call prep_radiation (iblk) - plabeld = 'post prep_radiation' - call debug_ice (iblk, plabeld) + plabeld = 'post prep_radiation' + call debug_ice (iblk, plabeld) !----------------------------------------------------------------- ! thermodynamics and biogeochemistry !----------------------------------------------------------------- - call step_therm1 (dt, iblk) ! vertical thermodynamics + call step_therm1 (dt, iblk) ! vertical thermodynamics - plabeld = 'post step_therm1' - call debug_ice (iblk, plabeld) + plabeld = 'post step_therm1' + call debug_ice (iblk, plabeld) - call biogeochemistry (dt, iblk) ! biogeochemistry + call biogeochemistry (dt, iblk) ! biogeochemistry - plabeld = 'post biogeochemistry' - call debug_ice (iblk, plabeld) + plabeld = 'post biogeochemistry' + call debug_ice (iblk, plabeld) - if (.not.prescribed_ice) & - call step_therm2 (dt, iblk) ! ice thickness distribution thermo + if (.not.prescribed_ice) & + call step_therm2 (dt, iblk) ! ice thickness distribution thermo - plabeld = 'post step_therm2' - call debug_ice (iblk, plabeld) + plabeld = 'post step_therm2' + call debug_ice (iblk, plabeld) + + endif enddo ! iblk !$OMP END PARALLEL DO @@ -227,10 +266,13 @@ ! momentum, stress, transport call step_dyn_horiz (dt_dyn) + plabeld = 'post step_dyn_horiz' + call debug_ice (iblk, plabeld) + ! ridging !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - call step_dyn_ridge (dt_dyn, ndtd, iblk) + if (kridge > 0) call step_dyn_ridge (dt_dyn, ndtd, iblk) enddo !$OMP END PARALLEL DO @@ -244,6 +286,7 @@ do iblk = 1, nblocks call debug_ice (iblk, plabeld) enddo + endif !----------------------------------------------------------------- @@ -256,7 +299,7 @@ !$OMP PARALLEL DO PRIVATE(iblk) do iblk = 1, nblocks - call step_radiation (dt, iblk) + if (ktherm >= 0) call step_radiation (dt, iblk) plabeld = 'post step_radiation' call debug_ice (iblk, plabeld) @@ -288,9 +331,9 @@ call ice_timer_start(timer_diags) ! diagnostics if (mod(istep,diagfreq) == 0) then call runtime_diags(dt) ! log file - if (solve_zsal) call zsal_diags(dt) - if (skl_bgc .or. z_tracers) call bgc_diags (dt) - if (tr_brine) call hbrine_diags (dt) + if (solve_zsal) call zsal_diags + if (skl_bgc .or. z_tracers) call bgc_diags + if (tr_brine) call hbrine_diags endif call ice_timer_stop(timer_diags) ! diagnostics @@ -329,21 +372,21 @@ use ice_arrays_column, only: alvdfn, alidfn, alvdrn, alidrn, & albicen, albsnon, albpndn, apeffn, fzsal_g, fzsal, snowfracn - use ice_blocks, only: block, nx_block, ny_block + use ice_blocks, only: nx_block, ny_block, get_block, block + use ice_domain, only: blocks_ice use ice_calendar, only: dt, nstreams - use ice_colpkg_shared, only: calc_Tsfc, oceanmixed_ice, max_aero - use ice_colpkg_tracers, only: nbtrcr - use ice_constants, only: c0, c1, puny, rhofresh use ice_domain_size, only: ncat use ice_flux, only: alvdf, alidf, alvdr, alidr, albice, albsno, & - albpnd, albcnt, apeff_ai, coszen, fpond, fresh, l_mpond_fresh, & + albpnd, albcnt, apeff_ai, fpond, fresh, l_mpond_fresh, & alvdf_ai, alidf_ai, alvdr_ai, alidr_ai, fhocn_ai, & fresh_ai, fsalt_ai, fsalt, & fswthru_ai, fhocn, fswthru, scale_factor, snowfrac, & - swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyt, & - fsens, flat, fswabs, flwout, evap, Tref, Qref, Uref, & - fsurfn_f, flatn_f, scale_fluxes, frzmlt_init, frzmlt, wind - use ice_flux_bgc, only: faero_ocn, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai + swvdr, swidr, swvdf, swidf, Tf, Tair, Qa, strairxT, strairyT, & + fsens, flat, fswabs, flwout, evap, Tref, Qref, & + scale_fluxes, frzmlt_init, frzmlt, Uref, wind, fsurfn_f, flatn_f + use ice_flux_bgc, only: faero_ocn, fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai, & + fnit, fsil, famm, fdmsp, fdms, fhum, fdust, falgalN, & + fdoc, fdic, fdon, ffep, ffed, bgcflux_ice_to_ocn use ice_grid, only: tmask use ice_state, only: aicen, aice, aice_init use ice_step_mod, only: ocean_mixed_layer @@ -355,14 +398,37 @@ ! local variables integer (kind=int_kind) :: & + ilo,ihi,jlo,jhi, & ! beginning and end of physical domain n , & ! thickness category index i,j , & ! horizontal indices - k ! tracer index + k , & ! tracer index + nbtrcr ! + + type (block) :: & + this_block ! block information for current block + + logical (kind=log_kind) :: & + skl_bgc , & ! + calc_Tsfc ! real (kind=dbl_kind) :: & cszn , & ! counter for history averaging + puny , & ! + rhofresh , & ! netsw ! flag for shortwave radiation presence + character(len=*), parameter :: subname = '(coupling_prep)' + + !----------------------------------------------------------------- + + call icepack_query_parameters(puny_out=puny, rhofresh_out=rhofresh) + call icepack_query_parameters(skl_bgc_out=skl_bgc) + call icepack_query_tracer_numbers(nbtrcr_out=nbtrcr) + call icepack_query_parameters(calc_Tsfc_out=calc_Tsfc) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) + !----------------------------------------------------------------- ! Save current value of frzmlt for diagnostics. ! Update mixed layer with heat and radiation from ice. @@ -405,11 +471,18 @@ enddo enddo enddo + + this_block = get_block(blocks_ice(iblk),iblk) + ilo = this_block%ilo + ihi = this_block%ihi + jlo = this_block%jlo + jhi = this_block%jhi + do n = 1, ncat - do j = 1, ny_block - do i = 1, nx_block + do j = jlo, jhi + do i = ilo, ihi if (aicen(i,j,n,iblk) > puny) then - + alvdf(i,j,iblk) = alvdf(i,j,iblk) & + alvdfn(i,j,n,iblk)*aicen(i,j,n,iblk) alidf(i,j,iblk) = alidf(i,j,iblk) & @@ -434,7 +507,7 @@ + apeffn(i,j,n,iblk)*aicen(i,j,n,iblk) snowfrac(i,j,iblk) = snowfrac(i,j,iblk) & ! for history + snowfracn(i,j,n,iblk)*aicen(i,j,n,iblk) - + endif ! aicen > puny enddo enddo @@ -492,7 +565,7 @@ !----------------------------------------------------------------- call scale_fluxes (nx_block, ny_block, & - tmask (:,:,iblk), nbtrcr, max_aero, & + tmask (:,:,iblk), nbtrcr, icepack_max_aero, & aice (:,:,iblk), Tf (:,:,iblk), & Tair (:,:,iblk), Qa (:,:,iblk), & strairxT (:,:,iblk), strairyT(:,:,iblk), & @@ -509,6 +582,22 @@ flux_bio(:,:,1:nbtrcr,iblk), & Uref=Uref(:,:,iblk), wind=wind(:,:,iblk) ) + !----------------------------------------------------------------- + ! Define ice-ocean bgc fluxes + !----------------------------------------------------------------- + + if (nbtrcr > 0 .or. skl_bgc) then + call bgcflux_ice_to_ocn (nx_block, ny_block, & + flux_bio(:,:,1:nbtrcr,iblk), & + fnit(:,:,iblk), fsil(:,:,iblk), & + famm(:,:,iblk), fdmsp(:,:,iblk), & + fdms(:,:,iblk), fhum(:,:,iblk), & + fdust(:,:,iblk), falgalN(:,:,:,iblk), & + fdoc(:,:,:,iblk), fdic(:,:,:,iblk), & + fdon(:,:,:,iblk), ffep(:,:,:,iblk), & + ffed(:,:,:,iblk)) + endif + !echmod - comment this out for efficiency, if .not. calc_Tsfc if (.not. calc_Tsfc) then @@ -550,21 +639,17 @@ integer (kind=int_kind), intent(in) :: & nx_block, ny_block ! block dimensions - logical (kind=log_kind), dimension (nx_block,ny_block), & - intent(in) :: & + logical (kind=log_kind), dimension (nx_block,ny_block), intent(in) :: & tmask ! land/boundary mask, thickness (T-cell) - real (kind=dbl_kind), dimension(nx_block,ny_block), & - intent(in):: & + real (kind=dbl_kind), dimension(nx_block,ny_block), intent(in):: & aice ! initial ice concentration - real (kind=dbl_kind), dimension(nx_block,ny_block,ncat), & - intent(in) :: & + real (kind=dbl_kind), dimension(nx_block,ny_block,ncat), intent(in) :: & fsurfn_f, & ! net surface heat flux (provided as forcing) flatn_f ! latent heat flux (provided as forcing) - real (kind=dbl_kind), dimension(nx_block,ny_block), & - intent(inout):: & + real (kind=dbl_kind), dimension(nx_block,ny_block), intent(inout):: & fresh , & ! fresh water flux to ocean (kg/m2/s) fhocn ! actual ocn/ice heat flx (W/m**2) @@ -575,8 +660,15 @@ i, j, n ! horizontal indices real (kind=dbl_kind) :: & + puny, & ! rLsub ! 1/Lsub + character(len=*), parameter :: subname = '(sfcflux_to_ocn)' + + call icepack_query_parameters(puny_out=puny) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(error_message=subname, & + file=__FILE__, line=__LINE__) rLsub = c1 / Lsub do n = 1, ncat @@ -596,42 +688,6 @@ end subroutine sfcflux_to_ocn -!======================================================================= -! -! Wrapper for the print_state debugging routine. -! Useful for debugging in the main driver (see ice.F_debug) -! ip, jp, mtask are set in ice_diagnostics.F -! -! author Elizabeth C. Hunke, LANL -! - subroutine debug_ice(iblk, plabeld) - - use ice_kinds_mod - use ice_calendar, only: istep1 - use ice_communicate, only: my_task - use ice_diagnostics, only: check_step, iblkp, ip, jp, mtask, print_state - use ice_domain, only: nblocks - use ice_blocks, only: nx_block, ny_block - - character (char_len), intent(in) :: plabeld - integer (kind=int_kind), intent(in) :: iblk - - ! local - integer (kind=int_kind) :: i, j - - if (istep1 >= check_step .and. & - iblk==iblkp .and. my_task==mtask) then - - do j = 1, ny_block - do i = 1, nx_block - if (i==ip .and. j==jp) call print_state(plabeld,i,j,iblk) - enddo - enddo - - endif - - end subroutine debug_ice - !======================================================================= end module CICE_RunMod diff --git a/cicecore/drivers/cesm/ice_prescribed_mod.F90 b/cicecore/drivers/cesm/ice_prescribed_mod.F90 index 89ea4005b..10c71cc84 100644 --- a/cicecore/drivers/cesm/ice_prescribed_mod.F90 +++ b/cicecore/drivers/cesm/ice_prescribed_mod.F90 @@ -88,7 +88,7 @@ module ice_prescribed_mod type(shr_strdata_type) :: sdat ! prescribed data stream character(len=char_len_long) :: fldList ! list of fields in data stream - real(kind=dbl_kind) :: ice_cov(nx_block,ny_block,max_blocks) ! ice cover + real(kind=dbl_kind), allocatable :: ice_cov(:,:,:) ! ice cover ! real (kind=dbl_kind), parameter :: & ! cp_sno = 0.0_dbl_kind & ! specific heat of snow (J/kg/K) @@ -317,7 +317,11 @@ subroutine ice_prescribed_run(mDateIn, secIn) !------------------------------------------------------------------------ call shr_strdata_advance(sdat,mDateIn,SecIn,MPI_COMM_ICE,'cice_pice') - + + if (first_time) then + allocate(ice_cov(nx_block,ny_block,max_blocks)) + endif + ice_cov(:,:,:) = c0 ! This initializes ghost cells as well n=0 @@ -540,17 +544,17 @@ subroutine ice_prescribed_phys ! compute aggregate ice state and open water area !-------------------------------------------------------------------- if (tmask(i,j,iblk)) & - call icepack_aggregate (ncat, & - aicen(i,j,:,iblk), trcrn(i,j,:,:,iblk), & + call icepack_aggregate (ncat, & + aicen(i,j,:,iblk), trcrn(i,j,1:ntrcr,:,iblk), & vicen(i,j,:,iblk), vsnon(i,j, :,iblk), & - aice (i,j, iblk), trcr (i,j,:, iblk), & + aice (i,j, iblk), trcr (i,j,1:ntrcr, iblk), & vice (i,j, iblk), vsno (i,j, iblk), & aice0(i,j, iblk), & ntrcr, & - trcr_depend(:), & - trcr_base(:,:), & - n_trcr_strata(:), & - nt_strata(:,:)) + trcr_depend(1:ntrcr), & + trcr_base(1:ntrcr,:), & + n_trcr_strata(1:ntrcr), & + nt_strata(1:ntrcr,:)) enddo ! i enddo ! j diff --git a/cicecore/drivers/cice/CICE_FinalMod.F90 b/cicecore/drivers/cice/CICE_FinalMod.F90 index c76be767f..0cd1ff177 100644 --- a/cicecore/drivers/cice/CICE_FinalMod.F90 +++ b/cicecore/drivers/cice/CICE_FinalMod.F90 @@ -11,6 +11,7 @@ module CICE_FinalMod use ice_kinds_mod + use ice_communicate, only: my_task, master_task use ice_exit, only: end_run, abort_ice use ice_fileunits, only: nu_diag, release_all_fileunits use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted @@ -30,10 +31,9 @@ module CICE_FinalMod subroutine CICE_Finalize use ice_restart_shared, only: runid - use ice_communicate, only: my_task, master_task use ice_timers, only: ice_timer_stop, ice_timer_print_all, timer_total - character(len=*), parameter :: subname='(CICE_Finalize)' + character(len=*), parameter :: subname = '(CICE_Finalize)' !------------------------------------------------------------------- ! stop timers and print timer info @@ -81,10 +81,9 @@ end subroutine CICE_Finalize subroutine writeout_finished_file() use ice_restart_shared, only: restart_dir - use ice_communicate, only: my_task, master_task character(len=char_len_long) :: filename - character(len=*), parameter :: subname='(writeout_finished_file)' + character(len=*), parameter :: subname = '(writeout_finished_file)' if (my_task == master_task) then diff --git a/cicecore/drivers/cice/CICE_InitMod.F90 b/cicecore/drivers/cice/CICE_InitMod.F90 index dd88ac532..1acbcb873 100644 --- a/cicecore/drivers/cice/CICE_InitMod.F90 +++ b/cicecore/drivers/cice/CICE_InitMod.F90 @@ -151,9 +151,13 @@ subroutine cice_init call ice_HaloRestore_init ! restored boundary conditions call icepack_query_parameters(skl_bgc_out=skl_bgc, z_tracers_out=z_tracers) + call icepack_warnings_flush(nu_diag) + if (icepack_warnings_aborted()) call abort_ice(trim(subname), & + file=__FILE__,line= __LINE__) + if (skl_bgc .or. z_tracers) call alloc_forcing_bgc ! allocate biogeochemistry arrays - call init_restart ! initialize restart variables + call init_restart ! initialize restart variables call init_diags ! initialize diagnostic output points call init_history_therm ! initialize thermo history variables call init_history_dyn ! initialize dynamic history variables @@ -405,7 +409,7 @@ subroutine init_restart vice (i,j, iblk), & vsno (i,j, iblk), & aice0(i,j, iblk), & - ntrcr, & + ntrcr, & trcr_depend, & trcr_base, & n_trcr_strata, & diff --git a/cicecore/drivers/cice/CICE_RunMod.F90_debug b/cicecore/drivers/cice/CICE_RunMod.F90_debug index d1db6344a..5caedab5a 100644 --- a/cicecore/drivers/cice/CICE_RunMod.F90_debug +++ b/cicecore/drivers/cice/CICE_RunMod.F90_debug @@ -260,8 +260,8 @@ ! momentum, stress, transport call step_dyn_horiz (dt_dyn) - plabeld = 'post step_dyn_horiz' - call debug_ice (iblk, plabeld) + plabeld = 'post step_dyn_horiz' + call debug_ice (iblk, plabeld) ! ridging !$OMP PARALLEL DO PRIVATE(iblk) diff --git a/icepack b/icepack index c88604761..45df1ab41 160000 --- a/icepack +++ b/icepack @@ -1 +1 @@ -Subproject commit c88604761c011e39792a67bec20b35272313bb9a +Subproject commit 45df1ab41d50c30b16516ef131d1381f38a8e298