Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarts for C and CD #56

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 102 additions & 13 deletions cicecore/cicedynB/infrastructure/ice_restart_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module ice_restart_driver
use ice_arrays_column, only: oceanmixed_ice
use ice_constants, only: c0, c1, p5, &
field_loc_center, field_loc_NEcorner, &
field_loc_Eface, field_loc_Nface, &
field_type_scalar, field_type_vector
use ice_restart_shared, only: restart_dir, pointer_file, &
runid, use_restart_time, lenstr, restart_coszen
Expand Down Expand Up @@ -54,15 +55,16 @@ subroutine dumpfile(filename_spec)
use ice_domain, only: nblocks
use ice_domain_size, only: nilyr, nslyr, ncat, max_blocks
use ice_flux, only: scale_factor, swvdr, swvdf, swidr, swidf, &
strocnxT, strocnyT, sst, frzmlt, iceumask, &
strocnxT, strocnyT, sst, frzmlt, iceumask, iceemask, icenmask, &
stressp_1, stressp_2, stressp_3, stressp_4, &
stressm_1, stressm_2, stressm_3, stressm_4, &
stress12_1, stress12_2, stress12_3, stress12_4, &
stresspT, stressmT, stress12T, &
stresspU, stressmU, stress12U
stresspU, stressmU, stress12U
use ice_flux, only: coszen
use ice_grid, only: grid_ice
use ice_state, only: aicen, vicen, vsnon, trcrn, uvel, vvel
use ice_state, only: aicen, vicen, vsnon, trcrn, uvel, vvel, &
uvelE, vvelE, uvelN, vvelN

character(len=char_len_long), intent(in), optional :: filename_spec

Expand Down Expand Up @@ -130,6 +132,18 @@ subroutine dumpfile(filename_spec)
call write_restart_field(nu_dump,0,uvel,'ruf8','uvel',1,diag)
call write_restart_field(nu_dump,0,vvel,'ruf8','vvel',1,diag)

if (grid_ice == 'CD') then
call write_restart_field(nu_dump,0,uvelE,'ruf8','uvelE',1,diag)
call write_restart_field(nu_dump,0,vvelE,'ruf8','vvelE',1,diag)
call write_restart_field(nu_dump,0,uvelN,'ruf8','uvelN',1,diag)
call write_restart_field(nu_dump,0,vvelN,'ruf8','vvelN',1,diag)
endif

if (grid_ice == 'C') then
call write_restart_field(nu_dump,0,uvelE,'ruf8','uvelE',1,diag)
call write_restart_field(nu_dump,0,vvelN,'ruf8','vvelN',1,diag)
endif

!-----------------------------------------------------------------
! radiation fields
!-----------------------------------------------------------------
Expand Down Expand Up @@ -167,7 +181,7 @@ subroutine dumpfile(filename_spec)
call write_restart_field(nu_dump,0,stress12_2,'ruf8','stress12_2',1,diag)
call write_restart_field(nu_dump,0,stress12_4,'ruf8','stress12_4',1,diag)

if (grid_ice == 'CD') then
if (grid_ice == 'CD' .or. grid_ice == 'C') then
call write_restart_field(nu_dump,0,stresspT ,'ruf8','stresspT' ,1,diag)
call write_restart_field(nu_dump,0,stressmT ,'ruf8','stressmT' ,1,diag)
call write_restart_field(nu_dump,0,stress12T,'ruf8','stress12T',1,diag)
Expand All @@ -192,6 +206,34 @@ subroutine dumpfile(filename_spec)
!$OMP END PARALLEL DO
call write_restart_field(nu_dump,0,work1,'ruf8','iceumask',1,diag)

if (grid_ice == 'CD' .or. grid_ice == 'C') then

!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
work1(i,j,iblk) = c0
if (icenmask(i,j,iblk)) work1(i,j,iblk) = c1
enddo
enddo
enddo
!$OMP END PARALLEL DO
call write_restart_field(nu_dump,0,work1,'ruf8','icenmask',1,diag)

!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
work1(i,j,iblk) = c0
if (iceemask(i,j,iblk)) work1(i,j,iblk) = c1
enddo
enddo
enddo
!$OMP END PARALLEL DO
call write_restart_field(nu_dump,0,work1,'ruf8','iceemask',1,diag)

endif

! for mixed layer model
if (oceanmixed_ice) then
call write_restart_field(nu_dump,0,sst,'ruf8','sst',1,diag)
Expand All @@ -215,7 +257,7 @@ subroutine restartfile (ice_ic)
use ice_domain_size, only: nilyr, nslyr, ncat, &
max_blocks
use ice_flux, only: scale_factor, swvdr, swvdf, swidr, swidf, &
strocnxT, strocnyT, sst, frzmlt, iceumask, &
strocnxT, strocnyT, sst, frzmlt, iceumask, iceemask, icenmask, &
stressp_1, stressp_2, stressp_3, stressp_4, &
stressm_1, stressm_2, stressm_3, stressm_4, &
stress12_1, stress12_2, stress12_3, stress12_4, &
Expand All @@ -225,6 +267,7 @@ subroutine restartfile (ice_ic)
use ice_grid, only: tmask, grid_type, grid_ice
use ice_state, only: trcr_depend, aice, vice, vsno, trcr, &
aice0, aicen, vicen, vsnon, trcrn, aice_init, uvel, vvel, &
uvelE, vvelE, uvelN, vvelN, &
trcr_base, nt_strata, n_trcr_strata

character (*), optional :: ice_ic
Expand Down Expand Up @@ -314,6 +357,24 @@ subroutine restartfile (ice_ic)
call read_restart_field(nu_restart,0,vvel,'ruf8', &
'vvel',1,diag,field_loc_NEcorner, field_type_vector)

if (grid_ice == 'CD') then
call read_restart_field(nu_restart,0,uvelE,'ruf8', &
'uvelE',1,diag,field_loc_Eface, field_type_vector)
call read_restart_field(nu_restart,0,vvelE,'ruf8', &
'vvelE',1,diag,field_loc_Eface, field_type_vector)
call read_restart_field(nu_restart,0,uvelN,'ruf8', &
'uvelN',1,diag,field_loc_Nface, field_type_vector)
call read_restart_field(nu_restart,0,vvelN,'ruf8', &
'vvelN',1,diag,field_loc_Nface, field_type_vector)
endif

if (grid_ice == 'C') then
call read_restart_field(nu_restart,0,uvelE,'ruf8', &
'uvelE',1,diag,field_loc_Eface, field_type_vector)
call read_restart_field(nu_restart,0,vvelN,'ruf8', &
'vvelN',1,diag,field_loc_Nface, field_type_vector)
endif

!-----------------------------------------------------------------
! radiation fields
!-----------------------------------------------------------------
Expand Down Expand Up @@ -381,24 +442,20 @@ subroutine restartfile (ice_ic)
call read_restart_field(nu_restart,0,stress12_4,'ruf8', &
'stress12_4',1,diag,field_loc_center,field_type_scalar) ! stress12_4

! tcraig, comment these out now to allow restarts from B grid file
! this will affect exact restart when we get to that point
#if (1 == 0)
if (grid_ice == 'CD') then
if (grid_ice == 'CD' .or. grid_ice == 'C') then
call read_restart_field(nu_restart,0,stresspT,'ruf8', &
'stresspT' ,1,diag,field_loc_center,field_type_scalar) ! stresspT
call read_restart_field(nu_restart,0,stressmT,'ruf8', &
'stressmT' ,1,diag,field_loc_center,field_type_scalar) ! stressmT
call read_restart_field(nu_restart,0,stress12T,'ruf8', &
'stress12T',1,diag,field_loc_center,field_type_scalar) ! stress12T
call read_restart_field(nu_restart,0,stresspU,'ruf8', &
'stresspU' ,1,diag,field_loc_center,field_type_scalar) ! stresspU
'stresspU' ,1,diag,field_loc_NEcorner,field_type_scalar) ! stresspU
call read_restart_field(nu_restart,0,stressmU,'ruf8', &
'stressmU' ,1,diag,field_loc_center,field_type_scalar) ! stressmU
'stressmU' ,1,diag,field_loc_NEcorner,field_type_scalar) ! stressmU
call read_restart_field(nu_restart,0,stress12U,'ruf8', &
'stress12U',1,diag,field_loc_center,field_type_scalar) ! stress12U
'stress12U',1,diag,field_loc_NEcorner,field_type_scalar) ! stress12U
endif
#endif

if (trim(grid_type) == 'tripole') then
call ice_HaloUpdate_stress(stressp_1, stressp_3, halo_info, &
Expand Down Expand Up @@ -450,6 +507,38 @@ subroutine restartfile (ice_ic)
enddo
!$OMP END PARALLEL DO

if (grid_ice == 'CD' .or. grid_ice == 'C') then

call read_restart_field(nu_restart,0,work1,'ruf8', &
'icenmask',1,diag,field_loc_center, field_type_scalar)

icenmask(:,:,:) = .false.
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
if (work1(i,j,iblk) > p5) icenmask(i,j,iblk) = .true.
enddo
enddo
enddo
!$OMP END PARALLEL DO

call read_restart_field(nu_restart,0,work1,'ruf8', &
'iceemask',1,diag,field_loc_center, field_type_scalar)

iceemask(:,:,:) = .false.
!$OMP PARALLEL DO PRIVATE(iblk,i,j)
do iblk = 1, nblocks
do j = 1, ny_block
do i = 1, nx_block
if (work1(i,j,iblk) > p5) iceemask(i,j,iblk) = .true.
enddo
enddo
enddo
!$OMP END PARALLEL DO

endif

! for mixed layer model
if (oceanmixed_ice) then

Expand Down
19 changes: 17 additions & 2 deletions cicecore/cicedynB/infrastructure/io/io_netcdf/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ subroutine init_restart_write(filename_spec)

call define_rest_field(ncid,'uvel',dims)
call define_rest_field(ncid,'vvel',dims)

if (grid_ice == 'CD') then
call define_rest_field(ncid,'uvelE',dims)
call define_rest_field(ncid,'vvelE',dims)
call define_rest_field(ncid,'uvelN',dims)
call define_rest_field(ncid,'vvelN',dims)
endif

if (grid_ice == 'C') then
call define_rest_field(ncid,'uvelE',dims)
call define_rest_field(ncid,'vvelN',dims)
endif

if (restart_coszen) call define_rest_field(ncid,'coszen',dims)

Expand Down Expand Up @@ -274,16 +286,19 @@ subroutine init_restart_write(filename_spec)
call define_rest_field(ncid,'stress12_3',dims)
call define_rest_field(ncid,'stress12_4',dims)

if (grid_ice == 'CD') then
call define_rest_field(ncid,'iceumask',dims)

if (grid_ice == 'CD' .or. grid_ice == 'C') then
call define_rest_field(ncid,'stresspT' ,dims)
call define_rest_field(ncid,'stressmT' ,dims)
call define_rest_field(ncid,'stress12T',dims)
call define_rest_field(ncid,'stresspU' ,dims)
call define_rest_field(ncid,'stressmU' ,dims)
call define_rest_field(ncid,'stress12U',dims)
call define_rest_field(ncid,'icenmask',dims)
call define_rest_field(ncid,'iceemask',dims)
endif

call define_rest_field(ncid,'iceumask',dims)

if (oceanmixed_ice) then
call define_rest_field(ncid,'sst',dims)
Expand Down
22 changes: 19 additions & 3 deletions cicecore/cicedynB/infrastructure/io/io_pio2/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,20 @@ subroutine init_restart_write(filename_spec)

call define_rest_field(File,'uvel',dims)
call define_rest_field(File,'vvel',dims)

if (grid_ice == 'CD') then
call define_rest_field(ncid,'uvelE',dims)
call define_rest_field(ncid,'vvelE',dims)
call define_rest_field(ncid,'uvelN',dims)
call define_rest_field(ncid,'vvelN',dims)
endif

if (grid_ice == 'C') then
call define_rest_field(ncid,'uvelE',dims)
call define_rest_field(ncid,'vvelN',dims)
endif


if (restart_coszen) call define_rest_field(File,'coszen',dims)
call define_rest_field(File,'scale_factor',dims)
call define_rest_field(File,'swvdr',dims)
Expand All @@ -277,17 +291,19 @@ subroutine init_restart_write(filename_spec)
call define_rest_field(File,'stress12_3',dims)
call define_rest_field(File,'stress12_4',dims)

if (grid_ice == 'CD') then
call define_rest_field(File,'iceumask',dims)

if (grid_ice == 'CD' .or. grid_ice == 'C') then
call define_rest_field(File,'stresspT' ,dims)
call define_rest_field(File,'stressmT' ,dims)
call define_rest_field(File,'stress12T',dims)
call define_rest_field(File,'stresspU' ,dims)
call define_rest_field(File,'stressmU' ,dims)
call define_rest_field(File,'stress12U',dims)
call define_rest_field(File,'icenmask',dims)
call define_rest_field(File,'iceemask',dims)
endif

call define_rest_field(File,'iceumask',dims)

if (oceanmixed_ice) then
call define_rest_field(File,'sst',dims)
call define_rest_field(File,'frzmlt',dims)
Expand Down