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

PIO standalone capability and IO testing additions #447

Merged
merged 9 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from 7 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
20 changes: 9 additions & 11 deletions cicecore/cicedynB/analysis/ice_history.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
module ice_history

use ice_kinds_mod
use ice_communicate, only: my_task, master_task
use ice_constants, only: c0, c1, c2, c100, c360, c180, &
p001, p25, p5, mps_to_cmpdy, kg_to_g, spval
use ice_fileunits, only: nu_nml, nml_filename, nu_diag, &
get_fileunit, release_fileunit
get_fileunit, release_fileunit, flush_fileunit
use ice_exit, only: abort_ice
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted
use icepack_intfc, only: icepack_snow_temperature, icepack_ice_temperature
Expand Down Expand Up @@ -62,7 +63,6 @@ subroutine init_hist (dt)

use ice_blocks, only: nx_block, ny_block
use ice_broadcast, only: broadcast_scalar, broadcast_array
use ice_communicate, only: my_task, master_task
use ice_calendar, only: yday, days_per_year, histfreq, &
histfreq_n, nstreams
use ice_domain_size, only: max_blocks, max_nstrm, nilyr, nslyr, nblyr, ncat, nfsd
Expand Down Expand Up @@ -1570,10 +1570,6 @@ subroutine init_hist (dt)
if (allocated(Tsnz4d)) deallocate(Tsnz4d)
allocate(Tsnz4d(nx_block,ny_block,nzslyr,ncat_hist))
endif
if (f_Sinz (1:1) /= 'x') then
if (allocated(Sinz4d)) deallocate(Sinz4d)
allocate(Sinz4d(nx_block,ny_block,nzilyr,ncat_hist))
endif

!-----------------------------------------------------------------
! 4D (floe size, thickness categories) variables looped separately
Expand Down Expand Up @@ -1616,6 +1612,8 @@ subroutine init_hist (dt)
ntmp(:) = 0
if (my_task == master_task) then
write(nu_diag,*) ' '
write(nu_diag,*) 'total number of history fields = ',num_avail_hist_fields_tot
write(nu_diag,*) 'max number of history fields = ',max_avail_hist_fields
write(nu_diag,*) 'The following variables will be ', &
'written to the history tape: '
write(nu_diag,101) 'description','units','variable','frequency','x'
Expand Down Expand Up @@ -1687,7 +1685,7 @@ subroutine init_hist (dt)
if (allocated(a3Df)) a3Df(:,:,:,:,:) = c0
if (allocated(a4Di)) a4Di(:,:,:,:,:,:) = c0
if (allocated(a4Ds)) a4Ds(:,:,:,:,:,:) = c0
if (allocated(a4Ds)) a4Df(:,:,:,:,:,:) = c0
if (allocated(a4Df)) a4Df(:,:,:,:,:,:) = c0
avgct(:) = c0
albcnt(:,:,:,:) = c0

Expand Down Expand Up @@ -2970,7 +2968,7 @@ subroutine accum_hist (dt)
enddo
enddo
enddo
call accum_hist_field(n_Tinz-n3Dacum, iblk, nzilyr, ncat_hist, &
call accum_hist_field(n_Tinz-n3Dfcum, iblk, nzilyr, ncat_hist, &
Tinz4d(:,:,1:nzilyr,1:ncat_hist), a4Di)
endif
if (f_Sinz (1:1) /= 'x') then
Expand All @@ -2984,7 +2982,7 @@ subroutine accum_hist (dt)
enddo
enddo
enddo
call accum_hist_field(n_Sinz-n3Dacum, iblk, nzilyr, ncat_hist, &
call accum_hist_field(n_Sinz-n3Dfcum, iblk, nzilyr, ncat_hist, &
Sinz4d(:,:,1:nzilyr,1:ncat_hist), a4Di)
endif

Expand Down Expand Up @@ -3796,7 +3794,7 @@ subroutine accum_hist (dt)
enddo ! n

do n = 1, num_avail_hist_fields_4Di
nn = n3Dacum + n
nn = n3Dfcum + n
if (avail_hist_fields(nn)%vhistfreq == histfreq(ns)) then
do k = 1, nzilyr
do ic = 1, ncat_hist
Expand Down Expand Up @@ -4025,7 +4023,7 @@ subroutine accum_hist (dt)
if (avail_hist_fields(n)%vhistfreq == histfreq(ns)) a3Df(:,:,:,nn,:) = c0
enddo
do n = n3Dfcum + 1, n4Dicum
nn = n - n3Dacum
nn = n - n3Dfcum
if (avail_hist_fields(n)%vhistfreq == histfreq(ns)) a4Di(:,:,:,:,nn,:) = c0
enddo
do n = n4Dicum + 1, n4Dscum
Expand Down
22 changes: 9 additions & 13 deletions cicecore/cicedynB/analysis/ice_history_fsd.F90
Original file line number Diff line number Diff line change
Expand Up @@ -428,11 +428,6 @@ subroutine accum_hist_fsd (iblk)
call accum_hist_field(n_fsdperim, iblk, worka, a2D)
endif






endif ! a2D allocated

! 3D category fields
Expand Down Expand Up @@ -474,19 +469,20 @@ subroutine accum_hist_fsd (iblk)
if (allocated(a4Df)) then

if (f_afsdn(1:1) /= 'x') then
do n = 1, ncat_hist
do k = 1, nfsd_hist
do j = 1, ny_block
do i = 1, nx_block
do n = 1, ncat_hist
do k = 1, nfsd_hist
workd(i,j,k,n) = trcrn(i,j,nt_fsd+k-1,n,iblk) &
* aicen_init(i,j,n,iblk)/floe_binwidth(k)
end do
end do
workd(i,j,k,n) = trcrn(i,j,nt_fsd+k-1,n,iblk) &
* aicen_init(i,j,n,iblk)/floe_binwidth(k)
end do
end do
end do
call accum_hist_field(n_afsdn-n4Dscum, iblk, &
nfsd_hist, ncat_hist, workd, a4Df)
end do
call accum_hist_field(n_afsdn-n4Dscum, iblk, nfsd_hist, ncat_hist, &
workd(:,:,1:nfsd_hist,1:ncat_hist), a4Df)
endif

endif ! a4Df allocated

endif ! tr_fsd
Expand Down
27 changes: 20 additions & 7 deletions cicecore/cicedynB/analysis/ice_history_shared.F90
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
module ice_history_shared

use ice_kinds_mod
use ice_communicate, only: my_task, master_task
use ice_domain_size, only: max_nstrm
use ice_exit, only: abort_ice
use ice_fileunits, only: nu_diag
use icepack_intfc, only: icepack_warnings_flush, icepack_warnings_aborted

implicit none
Expand All @@ -52,6 +54,9 @@ module ice_history_shared
character (len=char_len), public :: &
version_name

character (len=char_len), public :: &
history_format

!---------------------------------------------------------------
! Instructions for adding a field: (search for 'example')
! Here:
Expand Down Expand Up @@ -79,7 +84,7 @@ module ice_history_shared
end type

integer (kind=int_kind), parameter, public :: &
max_avail_hist_fields = 600 ! Max number of history fields
max_avail_hist_fields = 800 ! Max number of history fields

integer (kind=int_kind), public :: &
num_avail_hist_fields_tot = 0, & ! Current, total number of defined fields
Expand Down Expand Up @@ -111,8 +116,8 @@ module ice_history_shared
nzblyr , & ! bio grid
nzalyr ! aerosols (2 snow & nblyr+2 bio)

type (ice_hist_field), dimension(max_avail_hist_fields), public :: &
avail_hist_fields
type (ice_hist_field), public :: &
avail_hist_fields(max_avail_hist_fields)

integer (kind=int_kind), parameter, public :: &
nvar = 12 , & ! number of grid fields that can be written
Expand Down Expand Up @@ -806,8 +811,13 @@ subroutine define_hist_field(id, vname, vunit, vcoord, vcellmeas, &
num_avail_hist_fields_4Df = num_avail_hist_fields_4Df + 1
endif

if (num_avail_hist_fields_tot > max_avail_hist_fields) &
call abort_ice(subname//'ERROR: Need to increase max_avail_hist_fields')
if (num_avail_hist_fields_tot > max_avail_hist_fields) then
if (my_task == master_task) then
write(nu_diag,*) subname,' num_avail_hist_fields_tot = ',num_avail_hist_fields_tot
write(nu_diag,*) subname,' max_avail_hist_fields = ',max_avail_hist_fields
endif
call abort_ice(subname//'ERROR: Need in computation of max_avail_hist_fields')
endif

if (num_avail_hist_fields_tot /= &
num_avail_hist_fields_2D + &
Expand All @@ -819,8 +829,11 @@ subroutine define_hist_field(id, vname, vunit, vcoord, vcellmeas, &
num_avail_hist_fields_4Di + &
num_avail_hist_fields_4Ds + &
num_avail_hist_fields_4Df) then
call abort_ice(subname//'ERROR: num_avail_hist_fields error')
endif
if (my_task == master_task) then
write(nu_diag,*) subname,' num_avail_hist_fields_tot = ',num_avail_hist_fields_tot
endif
call abort_ice(subname//'ERROR: in num_avail_hist_fields')
endif

id(ns) = num_avail_hist_fields_tot

Expand Down
3 changes: 1 addition & 2 deletions cicecore/cicedynB/dynamics/ice_dyn_eap.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,6 @@ subroutine read_restart_eap()
use ice_domain, only: nblocks, halo_info
use ice_grid, only: grid_type
use ice_restart, only: read_restart_field
use ice_restart_shared, only: restart_format

! local variables

Expand Down Expand Up @@ -2183,7 +2182,7 @@ subroutine read_restart_eap()
call read_restart_field(nu_restart_eap,0,a12_4,'ruf8', &
'a12_4',1,diag,field_loc_center,field_type_scalar) ! a12_4

if (trim(grid_type) == 'tripole' .and. trim(restart_format) == 'pio') then
if (trim(grid_type) == 'tripole') then

call ice_HaloUpdate_stress(a11_1, a11_3, halo_info, &
field_loc_center, field_type_scalar)
Expand Down
42 changes: 22 additions & 20 deletions cicecore/cicedynB/dynamics/ice_transport_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -147,68 +147,70 @@ subroutine init_transport

! diagnostic output
if (my_task == master_task) then
write (nu_diag, *) 'tracer index depend type has_dependents'
write (nu_diag, *) 'tracer index depend type has_dependents'
nt = 1
write(nu_diag,*) ' hi ',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'hi ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
nt = 2
write(nu_diag,*) ' hs ',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'hs ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
k=2
do nt = k+1, k+ntrcr
if (nt-k==nt_Tsfc) &
write(nu_diag,*) 'nt_Tsfc',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_Tsfc ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_qice) &
write(nu_diag,*) 'nt_qice',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_qice ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_qsno) &
write(nu_diag,*) 'nt_qsno',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_qsno ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_sice) &
write(nu_diag,*) 'nt_sice',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_sice ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_fbri) &
write(nu_diag,*) 'nt_fbri',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_fbri ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_iage) &
write(nu_diag,*) 'nt_iage',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_iage ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_FY) &
write(nu_diag,*) 'nt_FY ', nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_FY ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_alvl) &
write(nu_diag,*) 'nt_alvl',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_alvl ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_vlvl) &
write(nu_diag,*) 'nt_vlvl',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_vlvl ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_apnd) &
write(nu_diag,*) 'nt_apnd',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_apnd ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_hpnd) &
write(nu_diag,*) 'nt_hpnd',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_hpnd ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_ipnd) &
write(nu_diag,*) 'nt_ipnd',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_ipnd ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_fsd) &
write(nu_diag,*) 'nt_fsd ',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_fsd ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_isosno) &
write(nu_diag,*) 'nt_isosno',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_isosno ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_isoice) &
write(nu_diag,*) 'nt_isoice',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_isoice ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_bgc_Nit) &
write(nu_diag,*) 'nt_bgc_Nit',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_bgc_Nit ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
if (nt-k==nt_bgc_S) &
write(nu_diag,*) 'nt_bgc_S',nt,depend(nt),tracer_type(nt),&
write(nu_diag,1000) 'nt_bgc_S ',nt,depend(nt),tracer_type(nt),&
has_dependents(nt)
enddo
write(nu_diag,*) ' '
endif ! master_task
1000 format (1x,a,2x,i6,2x,i6,2x,i4,4x,l4)

if (trim(advection)=='remap') call init_remap ! grid quantities

Expand Down
16 changes: 10 additions & 6 deletions cicecore/cicedynB/general/ice_init.F90
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ subroutine input_data
runid, runtype, use_restart_time, restart_format, lcdf64
use ice_history_shared, only: hist_avg, history_dir, history_file, &
incond_dir, incond_file, version_name, &
history_precision
history_precision, history_format
use ice_flux, only: update_ocn_f, l_mpond_fresh
use ice_flux, only: default_season
use ice_flux_bgc, only: cpl_bgc
Expand Down Expand Up @@ -150,7 +150,7 @@ subroutine input_data
ice_ic, restart, restart_dir, restart_file, &
restart_ext, use_restart_time, restart_format, lcdf64, &
pointer_file, dumpfreq, dumpfreq_n, dump_last, &
diagfreq, diag_type, diag_file, &
diagfreq, diag_type, diag_file, history_format,&
print_global, print_points, latpnt, lonpnt, &
dbug, histfreq, histfreq_n, hist_avg, &
history_dir, history_file, history_precision, cpl_bgc, &
Expand Down Expand Up @@ -250,6 +250,7 @@ subroutine input_data
histfreq(5) = 'y' ! output frequency option for different streams
histfreq_n(:) = 1 ! output frequency
hist_avg = .true. ! if true, write time-averages (not snapshots)
history_format = 'default' ! history file format
history_dir = './' ! write to executable dir for default
history_file = 'iceh' ! history file name prefix
history_precision = 4 ! precision of history files
Expand All @@ -264,9 +265,9 @@ subroutine input_data
restart_dir = './' ! write to executable dir for default
restart_file = 'iced' ! restart file name prefix
restart_ext = .false. ! if true, read/write ghost cells
use_restart_time = .true. ! if true, use time info written in file
use_restart_time = .true. ! if true, use time info written in file
pointer_file = 'ice.restart_file'
restart_format = 'nc' ! file format ('bin'=binary or 'nc'=netcdf or 'pio')
restart_format = 'default' ! restart file format
lcdf64 = .false. ! 64 bit offset for netCDF
ice_ic = 'default' ! latitude and sst-dependent
grid_format = 'bin' ! file format ('bin'=binary or 'nc'=netcdf)
Expand Down Expand Up @@ -539,6 +540,7 @@ subroutine input_data
call broadcast_scalar(history_dir, master_task)
call broadcast_scalar(history_file, master_task)
call broadcast_scalar(history_precision, master_task)
call broadcast_scalar(history_format, master_task)
call broadcast_scalar(write_ic, master_task)
call broadcast_scalar(cpl_bgc, master_task)
call broadcast_scalar(incond_dir, master_task)
Expand Down Expand Up @@ -1002,6 +1004,8 @@ subroutine input_data
write(nu_diag,*) ' history_file = ', &
trim(history_file)
write(nu_diag,1020) ' history_precision = ', history_precision
write(nu_diag,*) ' history_format = ', &
trim(history_format)
if (write_ic) then
write(nu_diag,*) 'Initial condition will be written in ', &
trim(incond_dir)
Expand Down Expand Up @@ -1165,8 +1169,8 @@ subroutine input_data
oceanmixed_ice
write(nu_diag,1010) ' wave_spec = ', wave_spec
if (wave_spec) then
write(nu_diag,*) ' wave_spec_type = ', wave_spec_type
write(nu_diag,*) ' wave_spec_file = ', wave_spec_file
write(nu_diag,*) ' wave_spec_type = ', trim(wave_spec_type)
write(nu_diag,*) ' wave_spec_file = ', trim(wave_spec_file)
endif
write(nu_diag,1020) ' nfreq = ', nfreq
write(nu_diag,*) ' tfrz_option = ', &
Expand Down
2 changes: 1 addition & 1 deletion cicecore/cicedynB/infrastructure/ice_grid.F90
Original file line number Diff line number Diff line change
Expand Up @@ -2411,7 +2411,7 @@ subroutine get_bathymetry_popfile
! create thickness profile
k1 = min(5,nlevel)
do k = 1,k1
thick(k) = max(10000._dbl_kind/float(nlevel),500.)
thick(k) = max(10000._dbl_kind/float(nlevel),500._dbl_kind)
enddo
do k = k1+1,nlevel
thick(k) = min(thick(k-1)*1.2_dbl_kind,20000._dbl_kind)
Expand Down
2 changes: 1 addition & 1 deletion cicecore/cicedynB/infrastructure/ice_restart_driver.F90
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ subroutine restartfile_v4 (ice_ic)
if (icepack_warnings_aborted()) call abort_ice(error_message=subname, &
file=__FILE__, line=__LINE__)

! creates netcdf if restart_format = 'nc'
! creates new file
filename = trim(restart_dir) // '/iced.converted'
call dumpfile(filename)
call final_restart
Expand Down
Loading