Skip to content

Commit

Permalink
New 1d evp solver
Browse files Browse the repository at this point in the history
  • Loading branch information
TillRasmussen committed Nov 1, 2023
1 parent 8916b9f commit 07d5787
Show file tree
Hide file tree
Showing 13 changed files with 2,519 additions and 2,395 deletions.
664 changes: 664 additions & 0 deletions cicecore/cicedyn/dynamics/ice_dyn_core1d.F90

Large diffs are not rendered by default.

805 changes: 396 additions & 409 deletions cicecore/cicedyn/dynamics/ice_dyn_evp.F90

Large diffs are not rendered by default.

1,393 changes: 1,393 additions & 0 deletions cicecore/cicedyn/dynamics/ice_dyn_evp1d.F90

Large diffs are not rendered by default.

1,921 changes: 0 additions & 1,921 deletions cicecore/cicedyn/dynamics/ice_dyn_evp_1d.F90

This file was deleted.

7 changes: 3 additions & 4 deletions cicecore/cicedyn/dynamics/ice_dyn_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2302,16 +2302,15 @@ end subroutine strain_rates_U
! by combining tensile strength and a parameterization for grounded ridges.
! J. Geophys. Res. Oceans, 121, 7354-7368.

subroutine visc_replpress(strength, DminArea, Delta, &
zetax2, etax2, rep_prs, capping)
pure subroutine visc_replpress(strength, DminArea, Delta, &
zetax2, etax2, rep_prs)

real (kind=dbl_kind), intent(in):: &
strength, & !
DminArea !

real (kind=dbl_kind), intent(in):: &
Delta , & !
capping !
Delta

real (kind=dbl_kind), intent(out):: &
zetax2 , & ! bulk viscosity
Expand Down
12 changes: 4 additions & 8 deletions cicecore/cicedyn/dynamics/ice_dyn_vp.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1221,20 +1221,16 @@ subroutine calc_zeta_dPr (nx_block, ny_block, &

call visc_replpress (strength(i,j) , DminTarea(i,j) , &
Deltane , zetax2 (i,j,1), &
etax2 (i,j,1), rep_prs (i,j,1), &
capping)
etax2 (i,j,1), rep_prs (i,j,1))
call visc_replpress (strength(i,j) , DminTarea(i,j) , &
Deltanw , zetax2 (i,j,2), &
etax2 (i,j,2), rep_prs (i,j,2), &
capping)
etax2 (i,j,2), rep_prs (i,j,2))
call visc_replpress (strength(i,j) , DminTarea(i,j) , &
Deltasw , zetax2 (i,j,3), &
etax2 (i,j,3), rep_prs (i,j,3), &
capping)
etax2 (i,j,3), rep_prs (i,j,3))
call visc_replpress (strength(i,j) , DminTarea(i,j) , &
Deltase , zetax2 (i,j,4), &
etax2 (i,j,4), rep_prs (i,j,4), &
capping)
etax2 (i,j,4), rep_prs (i,j,4))

!-----------------------------------------------------------------
! the stresses ! kg/s^2
Expand Down
13 changes: 7 additions & 6 deletions cicecore/cicedyn/dynamics/ice_transport_remap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,12 @@ subroutine horizontal_remap (dt, ntrace, &
endif ! nghost

! tcraig, this OMP loop sometimes fails with cce/14.0.3, compiler bug??
!$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block,n, &
!$OMP edgearea_e,edgearea_n,edge,iflux,jflux, &
!$OMP xp,yp,indxing,indxjng,mflxe,mflxn, &
!$OMP mtflxe,mtflxn,triarea,istop,jstop,l_stop) &
!$OMP SCHEDULE(runtime)
! TILL I can trigger the same with ifort (IFORT) 18.0.0 20170811
!TILL !$OMP PARALLEL DO PRIVATE(iblk,i,j,ilo,ihi,jlo,jhi,this_block,n, &
!TILL !$OMP edgearea_e,edgearea_n,edge,iflux,jflux, &
!TILL !$OMP xp,yp,indxing,indxjng,mflxe,mflxn, &
!TILL !$OMP mtflxe,mtflxn,triarea,istop,jstop,l_stop) &
!TILL !$OMP SCHEDULE(runtime)
do iblk = 1, nblocks

l_stop = .false.
Expand Down Expand Up @@ -865,7 +866,7 @@ subroutine horizontal_remap (dt, ntrace, &
enddo ! n

enddo ! iblk
!$OMP END PARALLEL DO
!TILL !$OMP END PARALLEL DO

end subroutine horizontal_remap

Expand Down
15 changes: 12 additions & 3 deletions cicecore/cicedyn/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1294,10 +1294,10 @@ subroutine input_data
endif

if (grid_ice == 'C' .or. grid_ice == 'CD') then
if (kdyn > 1) then
if (kdyn > 1 .or. (kdyn == 1 .and. evp_algorithm /= 'standard_2d')) then
if (my_task == master_task) then
write(nu_diag,*) subname//' ERROR: grid_ice = C | CD only supported with kdyn<=1 (evp or off)'
write(nu_diag,*) subname//' ERROR: kdyn and grid_ice inconsistency'
write(nu_diag,*) subname//' ERROR: grid_ice = C | CD only supported with kdyn=1 and evp_algorithm=standard_2d'
write(nu_diag,*) subname//' ERROR: kdyn and/or evp_algorithm and grid_ice inconsistency'
endif
abort_list = trim(abort_list)//":46"
endif
Expand All @@ -1310,6 +1310,15 @@ subroutine input_data
endif
endif

if (evp_algorithm == 'shared_mem_1d' .and. &
grid_type == 'tripole') then
if (my_task == master_task) then
write(nu_diag,*) subname//' ERROR: evp_algorithm=shared_mem_1d is not testet for gridtype=tripole'
write(nu_diag,*) subname//' ERROR: change evp_algorithm to standard_2d'
endif
abort_list = trim(abort_list)//":49"
endif

capping = -9.99e30
if (kdyn == 1 .or. kdyn == 3) then
if (capping_method == 'max') then
Expand Down
14 changes: 7 additions & 7 deletions cicecore/drivers/nuopc/dmi/CICE_FinalMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ subroutine CICE_Finalize

character(len=*), parameter :: subname = '(CICE_Finalize)'

!-------------------------------------------------------------------
! stop timers and print timer info
!-------------------------------------------------------------------
!-------------------------------------------------------------------
! stop timers and print timer info
!-------------------------------------------------------------------

call ice_timer_stop(timer_total) ! stop timing entire run
call ice_timer_print_all(stats=.false.) ! print timing information
call ice_timer_print_all(stats=timer_stats) ! print timing information

call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
Expand All @@ -55,9 +55,9 @@ subroutine CICE_Finalize
!echmod if (nu_diag /= 6) close (nu_diag) ! diagnostic output
call release_all_fileunits

!-------------------------------------------------------------------
! quit MPI
!-------------------------------------------------------------------
!-------------------------------------------------------------------
! quit MPI
!-------------------------------------------------------------------

#ifndef coupled
#ifndef CICE_DMI
Expand Down
12 changes: 5 additions & 7 deletions cicecore/drivers/nuopc/dmi/CICE_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,6 @@ subroutine init_restart
use ice_domain_size, only: ncat, n_iso, n_aero, nfsd, nslyr
use ice_dyn_eap, only: read_restart_eap
use ice_dyn_shared, only: kdyn
use ice_flux, only: Tf
use ice_grid, only: tmask
use ice_init, only: ice_ic
use ice_init_column, only: init_age, init_FY, init_lvl, init_snowtracers, &
Expand All @@ -292,7 +291,8 @@ subroutine init_restart
restart_iso, read_restart_iso, &
restart_aero, read_restart_aero, &
restart_hbrine, read_restart_hbrine, &
restart_zsal, restart_bgc
restart_bgc
use ice_flux, only: Tf
use ice_restart_driver, only: restartfile
use ice_restart_shared, only: runtype, restart
use ice_state ! almost everything
Expand All @@ -303,7 +303,7 @@ subroutine init_restart
logical(kind=log_kind) :: &
tr_iage, tr_FY, tr_lvl, tr_pond_lvl, &
tr_pond_topo, tr_snow, tr_fsd, tr_iso, tr_aero, tr_brine, &
skl_bgc, z_tracers, solve_zsal
skl_bgc, z_tracers
integer(kind=int_kind) :: &
ntrcr
integer(kind=int_kind) :: &
Expand All @@ -319,7 +319,7 @@ subroutine init_restart
file=__FILE__, line=__LINE__)

call icepack_query_parameters(skl_bgc_out=skl_bgc, &
z_tracers_out=z_tracers, 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_lvl_out=tr_pond_lvl, &
tr_pond_topo_out=tr_pond_topo, tr_aero_out=tr_aero, tr_brine_out=tr_brine, &
Expand Down Expand Up @@ -465,8 +465,6 @@ subroutine init_restart
if (trim(runtype) == 'continue') then
if (tr_brine) &
restart_hbrine = .true.
if (solve_zsal) &
restart_zsal = .true.
if (skl_bgc .or. z_tracers) &
restart_bgc = .true.
endif
Expand All @@ -476,7 +474,7 @@ subroutine init_restart
if (tr_brine .and. restart_hbrine) call read_restart_hbrine
endif

if (solve_zsal .or. skl_bgc .or. z_tracers) then ! biogeochemistry
if (skl_bgc .or. z_tracers) then ! biogeochemistry
if (tr_fsd) then
write (nu_diag,*) 'FSD implementation incomplete for use with BGC'
call icepack_warnings_flush(nu_diag)
Expand Down
51 changes: 25 additions & 26 deletions cicecore/drivers/nuopc/dmi/CICE_RunMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
module CICE_RunMod

use ice_kinds_mod
use ice_communicate, only: my_task, master_task
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 ice_memusage, only: ice_memusage_print
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_max_iso, icepack_max_aero
use icepack_intfc, only: icepack_query_parameters
Expand All @@ -43,7 +45,7 @@ module CICE_RunMod

subroutine CICE_Run(stop_now_cpl)

use ice_calendar, only: istep, istep1, dt, stop_now, advance_timestep
use ice_calendar, only: dt, stop_now, advance_timestep
use ice_forcing, only: get_forcing_atmo, get_forcing_ocn, &
get_wave_spec
use ice_forcing_bgc, only: get_forcing_bgc, get_atm_bgc, &
Expand Down Expand Up @@ -74,9 +76,9 @@ subroutine CICE_Run(stop_now_cpl)
file=__FILE__, line=__LINE__)

#ifndef CICE_IN_NEMO
!--------------------------------------------------------------------
! timestep loop
!--------------------------------------------------------------------
!--------------------------------------------------------------------
! timestep loop
!--------------------------------------------------------------------
#ifndef CICE_DMI
timeLoop: do
#endif
Expand Down Expand Up @@ -147,7 +149,7 @@ subroutine ice_step
use ice_boundary, only: ice_HaloUpdate
use ice_calendar, only: dt, dt_dyn, ndtd, diagfreq, write_restart, istep
use ice_diagnostics, only: init_mass_diags, runtime_diags, debug_model, debug_ice
use ice_diagnostics_bgc, only: hbrine_diags, zsal_diags, bgc_diags
use ice_diagnostics_bgc, only: hbrine_diags, bgc_diags
use ice_domain, only: halo_info, nblocks
use ice_dyn_eap, only: write_restart_eap
use ice_dyn_shared, only: kdyn, kridge
Expand Down Expand Up @@ -181,7 +183,7 @@ subroutine ice_step
logical (kind=log_kind) :: &
tr_iage, tr_FY, tr_lvl, tr_fsd, tr_snow, &
tr_pond_lvl, tr_pond_topo, tr_brine, tr_iso, tr_aero, &
calc_Tsfc, skl_bgc, solve_zsal, z_tracers, wave_spec
calc_Tsfc, skl_bgc, z_tracers, wave_spec

character(len=*), parameter :: subname = '(ice_step)'

Expand All @@ -195,8 +197,7 @@ subroutine ice_step
endif

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, &
wave_spec_out=wave_spec)
z_tracers_out=z_tracers, ktherm_out=ktherm, wave_spec_out=wave_spec)
call icepack_query_tracer_flags(tr_iage_out=tr_iage, tr_FY_out=tr_FY, &
tr_lvl_out=tr_lvl, tr_pond_lvl_out=tr_pond_lvl, &
tr_pond_topo_out=tr_pond_topo, tr_brine_out=tr_brine, tr_aero_out=tr_aero, &
Expand Down Expand Up @@ -226,10 +227,9 @@ subroutine ice_step

call step_prep

!$OMP PARALLEL DO PRIVATE(iblk)
do iblk = 1, nblocks

if (ktherm >= 0) then
if (ktherm >= 0) then
!$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime)
do iblk = 1, nblocks

!-----------------------------------------------------------------
! scale radiation fields
Expand Down Expand Up @@ -267,10 +267,9 @@ subroutine ice_step
call debug_ice (iblk, plabeld)
endif

endif ! ktherm > 0

enddo ! iblk
!$OMP END PARALLEL DO
enddo
!$OMP END PARALLEL DO
endif ! ktherm > 0

! clean up, update tendency diagnostics
offset = dt
Expand Down Expand Up @@ -300,7 +299,7 @@ subroutine ice_step
endif

! ridging
!$OMP PARALLEL DO PRIVATE(iblk)
!$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime)
do iblk = 1, nblocks
if (kridge > 0) call step_dyn_ridge (dt_dyn, ndtd, iblk)
enddo
Expand Down Expand Up @@ -334,9 +333,11 @@ subroutine ice_step
!-----------------------------------------------------------------

if (tr_snow) then ! advanced snow physics
!$OMP PARALLEL DO PRIVATE(iblk) SCHEDULE(runtime)
do iblk = 1, nblocks
call step_snow (dt, iblk)
enddo
!$OMP END PARALLEL DO
call update_state (dt) ! clean up
endif

Expand Down Expand Up @@ -384,9 +385,11 @@ 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
if (skl_bgc .or. z_tracers) call bgc_diags
if (tr_brine) call hbrine_diags
if (my_task == master_task) then
call ice_memusage_print(nu_diag,subname)
endif
endif
call ice_timer_stop(timer_diags) ! diagnostics

Expand All @@ -406,13 +409,12 @@ subroutine ice_step
if (tr_fsd) call write_restart_fsd
if (tr_iso) call write_restart_iso
if (tr_aero) call write_restart_aero
if (solve_zsal .or. skl_bgc .or. z_tracers) &
if (skl_bgc .or. z_tracers) &
call write_restart_bgc
if (tr_brine) call write_restart_hbrine
if (kdyn == 2) call write_restart_eap
call final_restart
endif

call ice_timer_stop(timer_readwrite) ! reading/writing

end subroutine ice_step
Expand All @@ -426,7 +428,7 @@ end subroutine ice_step
subroutine coupling_prep (iblk)

use ice_arrays_column, only: alvdfn, alidfn, alvdrn, alidrn, &
albicen, albsnon, albpndn, apeffn, fzsal_g, fzsal, snowfracn
albicen, albsnon, albpndn, apeffn, snowfracn
use ice_blocks, only: nx_block, ny_block, get_block, block
use ice_domain, only: blocks_ice
use ice_calendar, only: dt, nstreams
Expand All @@ -441,7 +443,7 @@ subroutine coupling_prep (iblk)
fsens, flat, fswabs, flwout, evap, Tref, Qref, &
scale_fluxes, frzmlt_init, frzmlt
use ice_flux_bgc, only: faero_ocn, fiso_ocn, Qref_iso, fiso_evap, &
fzsal_ai, fzsal_g_ai, flux_bio, flux_bio_ai
flux_bio, flux_bio_ai
use ice_grid, only: tmask
use ice_state, only: aicen, aice
#ifdef CICE_IN_NEMO
Expand Down Expand Up @@ -592,8 +594,6 @@ subroutine coupling_prep (iblk)
fsalt_ai (i,j,iblk) = fsalt (i,j,iblk)
fhocn_ai (i,j,iblk) = fhocn (i,j,iblk)
fswthru_ai(i,j,iblk) = fswthru(i,j,iblk)
fzsal_ai (i,j,iblk) = fzsal (i,j,iblk)
fzsal_g_ai(i,j,iblk) = fzsal_g(i,j,iblk)

if (nbtrcr > 0) then
do k = 1, nbtrcr
Expand Down Expand Up @@ -639,8 +639,7 @@ subroutine coupling_prep (iblk)
faero_ocn(:,:,:,iblk), &
alvdr (:,:,iblk), alidr (:,:,iblk), &
alvdf (:,:,iblk), alidf (:,:,iblk), &
fzsal (:,:,iblk), fzsal_g (:,:,iblk), &
flux_bio (:,:,1:nbtrcr,iblk), &
flux_bio =flux_bio (:,:,1:nbtrcr,iblk), &
Qref_iso =Qref_iso (:,:,:,iblk), &
fiso_evap=fiso_evap(:,:,:,iblk), &
fiso_ocn =fiso_ocn (:,:,:,iblk))
Expand Down
1 change: 0 additions & 1 deletion cicecore/drivers/standalone/cice/CICE_InitMod.F90
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ subroutine cice_init
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

logical(kind=log_kind) :: tr_aero, tr_zaero, skl_bgc, z_tracers, &
tr_iso, tr_fsd, wave_spec, tr_snow
character(len=char_len) :: snw_aging_table
Expand Down
6 changes: 3 additions & 3 deletions configuration/scripts/machines/Macros.freya_intel
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ CFLAGS := -c -O2 -fp-model precise
# Additional flags
FIXEDFLAGS := -132
FREEFLAGS := -FR
FFLAGS := -fp-model source -convert big_endian -assume byterecl -ftz -traceback -no-wrap-margin
FFLAGS := -convert big_endian -assume byterecl
#-xHost

ifeq ($(ICE_BLDDEBUG), true)
FFLAGS += -O0 -g -check -fpe0 -ftrapuv -fp-model except -check noarg_temp_created
FFLAGS += -O0 -g -check -fpe0 -ftrapuv -fp-model except -check noarg_temp_created -fp-model source -ftz -traceback -no-wrap-margin
# -heap-arrays 1024
else
FFLAGS += -O2
FFLAGS += -O3 -xCORE-AVX512 -qopt-zmm-usage=high -finline-functions -finline -parallel
endif
LD := $(FC)
LDFLAGS := $(FFLAGS) -v
Expand Down

0 comments on commit 07d5787

Please sign in to comment.