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

Modified CICE to support RASM coupling #152

Merged
merged 8 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from 5 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
19 changes: 19 additions & 0 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,25 @@ subroutine input_data
restart = .false.
endif

! tcx tcraig added, is this correct?
if (trim(runtype) /= 'continue' .and. ice_ic == 'none' .or. ice_ic == 'default') then
if (my_task == master_task) &
write(nu_diag,*) 'WARNING: ice_ic = none or default, setting restart flags to .false.'
restart = .false.
restart_ext = .false.
restart_aero = .false.
restart_age = .false.
restart_fy = .false.
restart_lvl = .false.
restart_pond_cesm = .false.
restart_pond_lvl = .false.
restart_pond_topo = .false.
! restart_bgc = .false.
! restart_hbrine = .false.
! restart_zsal = .false.
endif
! tcx

if (trim(runtype) == 'initial' .and. .not.(restart) .and. &
ice_ic /= 'none' .and. ice_ic /= 'default') then
if (my_task == master_task) then
Expand Down
143 changes: 106 additions & 37 deletions cicecore/cicedynB/infrastructure/ice_domain.F90
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module ice_domain
use ice_kinds_mod
use ice_constants, only: shlat, nhlat, c180
use ice_communicate, only: my_task, master_task, get_num_procs
use ice_broadcast, only: broadcast_scalar
use ice_broadcast, only: broadcast_scalar, broadcast_array
use ice_blocks, only: block, get_block, create_blocks, nghost, &
nblocks_x, nblocks_y, nblocks_tot, nx_block, ny_block
use ice_distribution, only: distrb
Expand All @@ -27,6 +27,10 @@ module ice_domain
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_query_parameters

#ifdef ncdf
use netcdf
#endif

implicit none
private

Expand Down Expand Up @@ -69,6 +73,9 @@ module ice_domain
distribution_wght ! method for weighting work per block
! 'block' = POP default configuration
! 'latitude' = no. ocean points * |lat|
! 'file' = read distribution_wgth_file
character (char_len_long) :: &
distribution_wght_file ! file for distribution_wght=file

integer (int_kind) :: &
nprocs ! num of processors
Expand Down Expand Up @@ -107,6 +114,7 @@ subroutine init_domain_blocks
processor_shape, &
distribution_type, &
distribution_wght, &
distribution_wght_file, &
ew_boundary_type, &
ns_boundary_type, &
maskhalo_dyn, &
Expand All @@ -123,6 +131,7 @@ subroutine init_domain_blocks
processor_shape = 'slenderX2'
distribution_type = 'cartesian'
distribution_wght = 'latitude'
distribution_wght_file = 'unknown'
ew_boundary_type = 'cyclic'
ns_boundary_type = 'open'
maskhalo_dyn = .false. ! if true, use masked halos for dynamics
Expand Down Expand Up @@ -153,6 +162,7 @@ subroutine init_domain_blocks
call broadcast_scalar(processor_shape, master_task)
call broadcast_scalar(distribution_type, master_task)
call broadcast_scalar(distribution_wght, master_task)
call broadcast_scalar(distribution_wght_file, master_task)
call broadcast_scalar(ew_boundary_type, master_task)
call broadcast_scalar(ns_boundary_type, master_task)
call broadcast_scalar(maskhalo_dyn, master_task)
Expand Down Expand Up @@ -210,15 +220,17 @@ subroutine init_domain_blocks
write(nu_diag,'(a26,i6)') ' No. of ice layers: ni = ',nilyr
write(nu_diag,'(a26,i6)') ' No. of snow layers:ns = ',nslyr
write(nu_diag,'(a26,i6)') ' Processors: total = ',nprocs
write(nu_diag,'(a25,a10)') ' Processor shape: ', &
write(nu_diag,'(a25,a16)') ' Processor shape: ', &
trim(processor_shape)
write(nu_diag,'(a25,a10)') ' Distribution type: ', &
write(nu_diag,'(a25,a16)') ' Distribution type: ', &
trim(distribution_type)
write(nu_diag,'(a25,a10)') ' Distribution weight: ', &
write(nu_diag,'(a25,a16)') ' Distribution weight: ', &
trim(distribution_wght)
write(nu_diag,'(a25,a10)') ' ew_boundary_type: ', &
write(nu_diag,'(a25,a )') ' Distribution wght file: ', &
trim(distribution_wght_file)
write(nu_diag,'(a25,a16)') ' ew_boundary_type: ', &
trim(ew_boundary_type)
write(nu_diag,'(a25,a10)') ' ns_boundary_type: ', &
write(nu_diag,'(a25,a16)') ' ns_boundary_type: ', &
trim(ns_boundary_type)
write(nu_diag,'(a26,l6)') ' maskhalo_dyn = ', &
maskhalo_dyn
Expand Down Expand Up @@ -269,6 +281,9 @@ subroutine init_domain_distribution(KMTG,ULATG)
i,j,n ,&! dummy loop indices
ig,jg ,&! global indices
work_unit ,&! size of quantized work unit
fid ,&! file id
varid ,&! var id
status ,&! netcdf return code
tblocks_tmp ,&! total number of blocks
nblocks_tmp ,&! temporary value of nblocks
nblocks_max ! max blocks on proc
Expand All @@ -284,6 +299,9 @@ subroutine init_domain_distribution(KMTG,ULATG)
type (block) :: &
this_block ! block information for current block

real (dbl_kind), dimension(:,:), allocatable :: &
wght ! wghts from file

!----------------------------------------------------------------------
!
! check that there are at least nghost+1 rows or columns of land cells
Expand Down Expand Up @@ -382,61 +400,112 @@ subroutine init_domain_distribution(KMTG,ULATG)
!----------------------------------------------------------------------

if (distribution_wght == 'latitude') then
flat = NINT(abs(ULATG*rad_to_deg), int_kind) + 1 ! linear function
flat = NINT(abs(ULATG*rad_to_deg), int_kind) ! linear function
else
flat = 1
endif

allocate(nocn(nblocks_tot))

nocn = 0
do n=1,nblocks_tot
this_block = get_block(n,n)
do j=this_block%jlo,this_block%jhi
if (this_block%j_glob(j) > 0) then
do i=this_block%ilo,this_block%ihi
if (this_block%i_glob(i) > 0) then
ig = this_block%i_glob(i)
jg = this_block%j_glob(j)
if (KMTG(ig,jg) > puny .and. &
(ULATG(ig,jg) < shlat/rad_to_deg .or. &
ULATG(ig,jg) > nhlat/rad_to_deg) ) &
nocn(n) = nocn(n) + flat(ig,jg)
endif
end do
if (distribution_wght == 'file') then
allocate(wght(nx_global,ny_global))
if (my_task == master_task) then
! cannot use ice_read_write due to circular dependency
#ifdef ncdf
write(nu_diag,*) 'read ',trim(distribution_wght_file),minval(wght),maxval(wght)
status = nf90_open(distribution_wght_file, NF90_NOWRITE, fid)
if (status /= nf90_noerr) then
call abort_ice ('ice_domain nf_open: Cannot open '//trim(distribution_wght_file))
endif
end do

!*** with array syntax, we actually do work on non-ocean
!*** points, so where the block is not completely land,
!*** reset nocn to be the full size of the block
status = nf90_inq_varid(fid, 'wght', varid)
status = nf90_get_var(fid, varid, wght)
status = nf90_close(fid)
#else
call abort_ice ('ice_domain distribution_wght = file needs netcdf ')
#endif
endif
call broadcast_array(wght, master_task)
nocn = 0
do n=1,nblocks_tot
this_block = get_block(n,n)
do j=this_block%jlo,this_block%jhi
if (this_block%j_glob(j) > 0) then
do i=this_block%ilo,this_block%ihi
if (this_block%i_glob(i) > 0) then
ig = this_block%i_glob(i)
jg = this_block%j_glob(j)
! if (KMTG(ig,jg) > puny) &
! nocn(n) = max(nocn(n),nint(wght(ig,jg)+1.0_dbl_kind))
if (KMTG(ig,jg) > puny) then
if (wght(ig,jg) > 0.00001_dbl_kind) then
nocn(n) = nocn(n)+nint(wght(ig,jg))
else
nocn(n) = max(nocn(n),1)
endif
endif
endif
end do
endif
end do
enddo
deallocate(wght)
else
nocn = 0
do n=1,nblocks_tot
this_block = get_block(n,n)
do j=this_block%jlo,this_block%jhi
if (this_block%j_glob(j) > 0) then
do i=this_block%ilo,this_block%ihi
if (this_block%i_glob(i) > 0) then
ig = this_block%i_glob(i)
jg = this_block%j_glob(j)
if (KMTG(ig,jg) > puny .and. &
(ULATG(ig,jg) < shlat/rad_to_deg .or. &
ULATG(ig,jg) > nhlat/rad_to_deg) ) &
nocn(n) = nocn(n) + flat(ig,jg)
endif
end do
endif
end do

! use processor_shape = 'square-pop' and distribution_wght = 'block'
! to make CICE and POP decompositions/distributions identical.
!*** with array syntax, we actually do work on non-ocean
!*** points, so where the block is not completely land,
!*** reset nocn to be the full size of the block

! use processor_shape = 'square-pop' and distribution_wght = 'block'
! to make CICE and POP decompositions/distributions identical.

#ifdef CICE_IN_NEMO
! Keep all blocks even the ones only containing land points
if (distribution_wght == 'block') nocn(n) = nx_block*ny_block
! Keep all blocks even the ones only containing land points
if (distribution_wght == 'block') nocn(n) = nx_block*ny_block
#else
if (distribution_wght == 'block' .and. & ! POP style
nocn(n) > 0) nocn(n) = nx_block*ny_block
if (distribution_wght == 'block' .and. & ! POP style
nocn(n) > 0) nocn(n) = nx_block*ny_block
#endif
end do
end do
endif ! distribution_wght = file

work_unit = maxval(nocn)/max_work_unit + 1

!*** find number of work units per block

allocate(work_per_block(nblocks_tot))

where (nocn > 0)
where (nocn > 1)
work_per_block = nocn/work_unit + 2
elsewhere (nocn == 1)
work_per_block = nocn/work_unit + 1
elsewhere
work_per_block = 0
end where
if (my_task == master_task) then
write(nu_diag,*) 'ice_domain work_unit, max_work_unit = ',work_unit, max_work_unit
write(nu_diag,*) 'ice_domain nocn = ',minval(nocn),maxval(nocn),sum(nocn)
write(nu_diag,*) 'ice_domain work_per_block = ',minval(work_per_block),maxval(work_per_block),sum(work_per_block)
endif
deallocate(nocn)


!----------------------------------------------------------------------
!
! determine the distribution of blocks across processors
Expand Down Expand Up @@ -477,12 +546,12 @@ subroutine init_domain_distribution(KMTG,ULATG)

if (nblocks_max > max_blocks) then
write(outstring,*) &
'ERROR: no. blocks exceed max: increase max to', nblocks_max
'ERROR: ice no. blocks exceed max: increase max to', nblocks_max
call abort_ice("subname"//trim(outstring), &
file=__FILE__, line=__LINE__)
else if (nblocks_max < max_blocks) then
write(outstring,*) &
'WARNING: no. blocks too large: decrease max to', nblocks_max
'WARNING: ice no. blocks too large: decrease max to', nblocks_max
if (my_task == master_task) then
write(nu_diag,*) ' ********WARNING***********'
write(nu_diag,*) "subname",trim(outstring)
Expand Down
3 changes: 2 additions & 1 deletion cicecore/cicedynB/infrastructure/ice_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ subroutine latlongrid
real (kind=dbl_kind) :: &
pos_scmlon,& ! temporary
pi, &
puny, &
scamdata ! temporary

!-----------------------------------------------------------------
Expand All @@ -823,7 +824,7 @@ subroutine latlongrid
!-----------------------------------------------------------------
#ifdef CESMCOUPLED

call icepack_query_parameters(pi_out=pi)
call icepack_query_parameters(pi_out=pi, puny_out=puny)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message="subname", &
file=__FILE__, line=__LINE__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ module ice_history_write
use ice_fileunits, only: nu_diag
use ice_exit, only: abort_ice
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_query_parameters

implicit none
private
Expand All @@ -45,7 +46,7 @@ subroutine ice_write_hist (ns)
use ice_calendar, only: time, sec, idate, idate0, write_ic, &
histfreq, dayyr, days_per_year, use_leap_years
use ice_communicate, only: my_task, master_task
use ice_constants, only: c0, c360, secday, spval, spval_dbl, rad_to_deg
use ice_constants, only: c0, c360, spval, spval_dbl
use ice_domain, only: distrb_info, nblocks
use ice_domain_size, only: nx_global, ny_global, max_blocks, max_nstrm
use ice_gather_scatter, only: gather_global
Expand Down Expand Up @@ -133,6 +134,11 @@ subroutine ice_write_hist (ns)
integer (kind=int_kind), dimension(2) :: &
bnd_start,bnd_length ! dimension quantities for netCDF

real (kind=dbl_kind) :: secday
real (kind=dbl_kind) :: rad_to_deg

call icepack_query_parameters(secday_out=secday)
call icepack_query_parameters(rad_to_deg_out=rad_to_deg)

if (my_task == master_task) then
call construct_filename(ncfile(ns),'nc',ns)
Expand Down
44 changes: 35 additions & 9 deletions cicecore/cicedynB/infrastructure/io/io_pio/ice_restart.F90
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ module ice_restart
use ice_pio
use pio
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_query_tracer_flags, icepack_query_tracer_indices
use icepack_intfc, only: icepack_query_parameters, icepack_query_tracer_numbers

implicit none
private
Expand Down Expand Up @@ -125,16 +127,23 @@ subroutine init_restart_write(filename_spec)
n_aero, nblyr, n_zaero, n_algae, n_doc, &
n_dic, n_don, n_fed, n_fep
use ice_dyn_shared, only: kdyn
use icepack_intfc, only: oceanmixed_ice, solve_zsal, skl_bgc, z_tracers
use icepack_intfc, only: tr_iage, tr_FY, tr_lvl, tr_aero, tr_pond_cesm, &
tr_pond_topo, tr_pond_lvl, tr_brine, nbtrcr, &
tr_bgc_N, tr_bgc_C, tr_bgc_Nit, &
tr_bgc_Sil, tr_bgc_DMS, &
tr_bgc_chl, tr_bgc_Am, &
tr_bgc_PON, tr_bgc_DON, &
tr_zaero, tr_bgc_Fe, &
tr_bgc_hum
use ice_arrays_column, only: oceanmixed_ice

logical (kind=log_kind) :: &
solve_zsal, skl_bgc, z_tracers

logical (kind=log_kind) :: &
tr_iage, tr_FY, tr_lvl, tr_aero, tr_pond_cesm, &
tr_pond_topo, tr_pond_lvl, tr_brine, &
tr_bgc_N, tr_bgc_C, tr_bgc_Nit, &
tr_bgc_Sil, tr_bgc_DMS, &
tr_bgc_chl, tr_bgc_Am, &
tr_bgc_PON, tr_bgc_DON, &
tr_zaero, tr_bgc_Fe, &
tr_bgc_hum

integer (kind=int_kind) :: &
nbtrcr

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

Expand All @@ -156,6 +165,23 @@ subroutine init_restart_write(filename_spec)

character (len=3) :: nchar, ncharb

call icepack_query_tracer_numbers(nbtrcr_out=nbtrcr)
call icepack_query_tracer_flags( &
tr_iage_out=tr_iage, tr_FY_out=tr_FY, tr_lvl_out=tr_lvl, &
tr_aero_out=tr_aero, tr_pond_cesm_out=tr_pond_cesm, &
tr_pond_topo_out=tr_pond_topo, tr_pond_lvl_out=tr_pond_lvl, tr_brine_out=tr_brine, &
tr_bgc_N_out=tr_bgc_N, tr_bgc_C_out=tr_bgc_C, tr_bgc_Nit_out=tr_bgc_Nit, &
tr_bgc_Sil_out=tr_bgc_Sil, tr_bgc_DMS_out=tr_bgc_DMS, &
tr_bgc_chl_out=tr_bgc_chl, tr_bgc_Am_out=tr_bgc_Am, &
tr_bgc_PON_out=tr_bgc_PON, tr_bgc_DON_out=tr_bgc_DON, &
tr_zaero_out=tr_zaero, tr_bgc_Fe_out=tr_bgc_Fe, &
tr_bgc_hum_out=tr_bgc_hum)
call icepack_query_parameters(solve_zsal_out=solve_zsal, skl_bgc_out=skl_bgc, &
z_tracers_out=z_tracers)
call icepack_warnings_flush(nu_diag)
if (icepack_warnings_aborted()) call abort_ice(error_message="subname", &
file=__FILE__, line=__LINE__)

! construct path/file
if (present(filename_spec)) then
filename = trim(filename_spec)
Expand Down
Loading