Skip to content

Commit

Permalink
Add chunking to the lateral boundary file.
Browse files Browse the repository at this point in the history
Fixes #689.
  • Loading branch information
GeorgeGayno-NOAA committed Oct 18, 2022
1 parent 6ca174b commit 9e662d7
Showing 1 changed file with 65 additions and 49 deletions.
114 changes: 65 additions & 49 deletions sorc/chgres_cube.fd/write_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet)
integer :: dim_lonp, dim_halo
integer :: dim_halop, dim_latm
integer :: dim_lev, dim_levp1
integer :: j_target2, halo, halo_p1
integer :: num_lat, num_latm, halo, halo_p1
integer :: id_i_bottom, id_j_bottom
integer :: id_i_top, id_j_top
integer :: id_i_right, id_j_right
Expand Down Expand Up @@ -210,15 +210,15 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet)
error = nf90_def_dim(ncid, 'lon', i_target, dim_lon)
call netcdf_err(error, 'defining lon dimension')

j_target2 = j_target - (2*halo_bndy)
error = nf90_def_dim(ncid, 'lat', j_target2, dim_lat)
num_lat = j_target - (2*halo_bndy)
error = nf90_def_dim(ncid, 'lat', num_lat, dim_lat)
call netcdf_err(error, 'DEFINING LAT DIMENSION')

error = nf90_def_dim(ncid, 'lonp', ip1_target, dim_lonp)
call netcdf_err(error, 'DEFINING LONP DIMENSION')

j_target2 = j_target - (2*halo_bndy) - 1
error = nf90_def_dim(ncid, 'latm', j_target2, dim_latm)
num_latm = j_target - (2*halo_bndy) - 1
error = nf90_def_dim(ncid, 'latm', num_latm, dim_latm)
call netcdf_err(error, 'DEFINING LATM DIMENSION')

error = nf90_def_dim(ncid, 'halo', halo, dim_halo)
Expand Down Expand Up @@ -266,89 +266,89 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet)
call netcdf_err(error, 'DEFINING J_LEFT')

error = nf90_def_var(ncid, 'ps_bottom', NF90_FLOAT, &
(/dim_lon, dim_halo/), id_ps_bottom)
(/dim_lon, dim_halo/), id_ps_bottom, chunksizes=(/i_target,halo/))
call netcdf_err(error, 'DEFINING PS_BOTTOM')

error = nf90_def_var(ncid, 'ps_top', NF90_FLOAT, &
(/dim_lon, dim_halo/), id_ps_top)
(/dim_lon, dim_halo/), id_ps_top, chunksizes=(/i_target,halo/))
call netcdf_err(error, 'DEFINING PS_TOP')

error = nf90_def_var(ncid, 'ps_right', NF90_FLOAT, &
(/dim_halo, dim_lat/), id_ps_right)
(/dim_halo, dim_lat/), id_ps_right, chunksizes=(/halo,num_lat/))
call netcdf_err(error, 'DEFINING PS_RIGHT')

error = nf90_def_var(ncid, 'ps_left', NF90_FLOAT, &
(/dim_halo, dim_lat/), id_ps_left)
(/dim_halo, dim_lat/), id_ps_left, chunksizes=(/halo,num_lat/))
call netcdf_err(error, 'DEFINING PS_LEFT')

error = nf90_def_var(ncid, 't_bottom', NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_t_bottom)
(/dim_lon, dim_halo, dim_lev/), id_t_bottom, chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING T_BOTTOM')

error = nf90_def_var(ncid, 't_top', NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_t_top)
(/dim_lon, dim_halo, dim_lev/), id_t_top, chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING T_TOP')

error = nf90_def_var(ncid, 't_right', NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_t_right)
(/dim_halo, dim_lat, dim_lev/), id_t_right, chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING T_RIGHT')

error = nf90_def_var(ncid, 't_left', NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_t_left)
(/dim_halo, dim_lat, dim_lev/), id_t_left, chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING T_LEFT')

error = nf90_def_var(ncid, 'w_bottom', NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_w_bottom)
(/dim_lon, dim_halo, dim_lev/), id_w_bottom, chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING W_BOTTOM')

error = nf90_def_var(ncid, 'w_top', NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_w_top)
(/dim_lon, dim_halo, dim_lev/), id_w_top, chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING W_TOP')

error = nf90_def_var(ncid, 'w_right', NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_w_right)
(/dim_halo, dim_lat, dim_lev/), id_w_right, chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING W_RIGHT')

error = nf90_def_var(ncid, 'w_left', NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_w_left)
(/dim_halo, dim_lat, dim_lev/), id_w_left, chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING W_LEFT')

error = nf90_def_var(ncid, 'zh_bottom', NF90_FLOAT, &
(/dim_lon, dim_halo, dim_levp1/), id_zh_bottom)
(/dim_lon, dim_halo, dim_levp1/), id_zh_bottom, chunksizes=(/i_target,halo,levp1_target/))
call netcdf_err(error, 'DEFINING ZH_BOTTOM')

error = nf90_def_var(ncid, 'zh_top', NF90_FLOAT, &
(/dim_lon, dim_halo, dim_levp1/), id_zh_top)
(/dim_lon, dim_halo, dim_levp1/), id_zh_top, chunksizes=(/i_target,halo,levp1_target/))
call netcdf_err(error, 'DEFINING ZH_TOP')

error = nf90_def_var(ncid, 'zh_right', NF90_FLOAT, &
(/dim_halo, dim_lat, dim_levp1/), id_zh_right)
(/dim_halo, dim_lat, dim_levp1/), id_zh_right, chunksizes=(/halo,num_lat,levp1_target/))
call netcdf_err(error, 'DEFINING ZH_RIGHT')

error = nf90_def_var(ncid, 'zh_left', NF90_FLOAT, &
(/dim_halo, dim_lat, dim_levp1/), id_zh_left)
(/dim_halo, dim_lat, dim_levp1/), id_zh_left, chunksizes=(/halo,num_lat,levp1_target/))
call netcdf_err(error, 'DEFINING ZH_LEFT')

do n = 1, num_tracers

name = trim(tracers(n)) // "_bottom"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_tracer_bottom(n))
(/dim_lon, dim_halo, dim_lev/), id_tracer_bottom(n), chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING TRACER_BOTTOM')

name = trim(tracers(n)) // "_top"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_tracer_top(n))
(/dim_lon, dim_halo, dim_lev/), id_tracer_top(n), chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING TRACER_TOP')

name = trim(tracers(n)) // "_right"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_tracer_right(n))
(/dim_halo, dim_lat, dim_lev/), id_tracer_right(n), chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING TRACER_RIGHT')

name = trim(tracers(n)) // "_left"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_tracer_left(n))
(/dim_halo, dim_lat, dim_lev/), id_tracer_left(n), chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING TRACER_LEFT')

enddo
Expand All @@ -357,42 +357,42 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet)

name = "ice_aero_bottom"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_qnifa_bottom)
(/dim_lon, dim_halo, dim_lev/), id_qnifa_bottom, chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING QNIFA_BOTTOM')

name = "ice_aero_top"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_qnifa_top)
(/dim_lon, dim_halo, dim_lev/), id_qnifa_top, chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING QNIFA_TOP')

name = "ice_aero_right"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_qnifa_right)
(/dim_halo, dim_lat, dim_lev/), id_qnifa_right, chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING QNIFA_RIGHT')

name = "ice_aero_left"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_qnifa_left)
(/dim_halo, dim_lat, dim_lev/), id_qnifa_left, chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING QNIFA_LEFT')

name = "liq_aero_bottom"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_qnwfa_bottom)
(/dim_lon, dim_halo, dim_lev/), id_qnwfa_bottom, chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING QNWFA_BOTTOM')

name = "liq_aero_top"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_lon, dim_halo, dim_lev/), id_qnwfa_top)
(/dim_lon, dim_halo, dim_lev/), id_qnwfa_top, chunksizes=(/i_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING QNWFA_TOP')

name = "liq_aero_right"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_qnwfa_right)
(/dim_halo, dim_lat, dim_lev/), id_qnwfa_right, chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING QNWFA_RIGHT')

name = "liq_aero_left"
error = nf90_def_var(ncid, name, NF90_FLOAT, &
(/dim_halo, dim_lat, dim_lev/), id_qnwfa_left)
(/dim_halo, dim_lat, dim_lev/), id_qnwfa_left, chunksizes=(/halo,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING QNWFA_LEFT')

endif
Expand Down Expand Up @@ -430,35 +430,43 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet)
call netcdf_err(error, 'DEFINING J_W_LEFT')

error = nf90_def_var(ncid, 'u_w_bottom', NF90_FLOAT, &
(/dim_lonp, dim_halo, dim_lev/), id_u_w_bottom)
(/dim_lonp, dim_halo, dim_lev/), id_u_w_bottom, &
chunksizes=(/ip1_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING U_W_BOTTOM')

error = nf90_def_var(ncid, 'u_w_top', NF90_FLOAT, &
(/dim_lonp, dim_halo, dim_lev/), id_u_w_top)
(/dim_lonp, dim_halo, dim_lev/), id_u_w_top, &
chunksizes=(/ip1_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING U_W_TOP')

error = nf90_def_var(ncid, 'u_w_right', NF90_FLOAT, &
(/dim_halop, dim_lat, dim_lev/), id_u_w_right)
(/dim_halop, dim_lat, dim_lev/), id_u_w_right, &
chunksizes=(/halo_p1,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING U_W_RIGHT')

error = nf90_def_var(ncid, 'u_w_left', NF90_FLOAT, &
(/dim_halop, dim_lat, dim_lev/), id_u_w_left)
(/dim_halop, dim_lat, dim_lev/), id_u_w_left, &
chunksizes=(/halo_p1,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING U_W_LEFT')

error = nf90_def_var(ncid, 'v_w_bottom', NF90_FLOAT, &
(/dim_lonp, dim_halo, dim_lev/), id_v_w_bottom)
(/dim_lonp, dim_halo, dim_lev/), id_v_w_bottom, &
chunksizes=(/ip1_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING V_W_BOTTOM')

error = nf90_def_var(ncid, 'v_w_top', NF90_FLOAT, &
(/dim_lonp, dim_halo, dim_lev/), id_v_w_top)
(/dim_lonp, dim_halo, dim_lev/), id_v_w_top, &
chunksizes=(/ip1_target,halo,lev_target/))
call netcdf_err(error, 'DEFINING V_W_TOP')

error = nf90_def_var(ncid, 'v_w_right', NF90_FLOAT, &
(/dim_halop, dim_lat, dim_lev/), id_v_w_right)
(/dim_halop, dim_lat, dim_lev/), id_v_w_right, &
chunksizes=(/halo_p1,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING V_W_RIGHT')

error = nf90_def_var(ncid, 'v_w_left', NF90_FLOAT, &
(/dim_halop, dim_lat, dim_lev/), id_v_w_left)
(/dim_halop, dim_lat, dim_lev/), id_v_w_left, &
chunksizes=(/halo_p1,num_lat,lev_target/))
call netcdf_err(error, 'DEFINING V_W_LEFT')

error = nf90_def_var(ncid, 'i_s_bottom', NF90_INT, &
Expand Down Expand Up @@ -494,35 +502,43 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet)
call netcdf_err(error, 'DEFINING J_S_LEFT')

error = nf90_def_var(ncid, 'u_s_bottom', NF90_FLOAT, &
(/dim_lon, dim_halop, dim_lev/), id_u_s_bottom)
(/dim_lon, dim_halop, dim_lev/), id_u_s_bottom, &
chunksizes=(/i_target,halo_p1,lev_target/))
call netcdf_err(error, 'DEFINING U_S_BOTTOM')

error = nf90_def_var(ncid, 'u_s_top', NF90_FLOAT, &
(/dim_lon, dim_halop, dim_lev/), id_u_s_top)
(/dim_lon, dim_halop, dim_lev/), id_u_s_top, &
chunksizes=(/i_target,halo_p1,lev_target/))
call netcdf_err(error, 'DEFINING U_S_TOP')

error = nf90_def_var(ncid, 'u_s_right', NF90_FLOAT, &
(/dim_halo, dim_latm, dim_lev/), id_u_s_right)
(/dim_halo, dim_latm, dim_lev/), id_u_s_right, &
chunksizes=(/halo,num_latm,lev_target/))
call netcdf_err(error, 'DEFINING U_S_RIGHT')

error = nf90_def_var(ncid, 'u_s_left', NF90_FLOAT, &
(/dim_halo, dim_latm, dim_lev/), id_u_s_left)
(/dim_halo, dim_latm, dim_lev/), id_u_s_left, &
chunksizes=(/halo,num_latm,lev_target/))
call netcdf_err(error, 'DEFINING U_S_LEFT')

error = nf90_def_var(ncid, 'v_s_bottom', NF90_FLOAT, &
(/dim_lon, dim_halop, dim_lev/), id_v_s_bottom)
(/dim_lon, dim_halop, dim_lev/), id_v_s_bottom, &
chunksizes=(/i_target,halo_p1,lev_target/))
call netcdf_err(error, 'DEFINING V_S_BOTTOM')

error = nf90_def_var(ncid, 'v_s_top', NF90_FLOAT, &
(/dim_lon, dim_halop, dim_lev/), id_v_s_top)
(/dim_lon, dim_halop, dim_lev/), id_v_s_top, &
chunksizes=(/i_target,halo_p1,lev_target/))
call netcdf_err(error, 'DEFINING V_S_TOP')

error = nf90_def_var(ncid, 'v_s_right', NF90_FLOAT, &
(/dim_halo, dim_latm, dim_lev/), id_v_s_right)
(/dim_halo, dim_latm, dim_lev/), id_v_s_right, &
chunksizes=(/halo,num_latm,lev_target/))
call netcdf_err(error, 'DEFINING V_S_RIGHT')

error = nf90_def_var(ncid, 'v_s_left', NF90_FLOAT, &
(/dim_halo, dim_latm, dim_lev/), id_v_s_left)
(/dim_halo, dim_latm, dim_lev/), id_v_s_left, &
chunksizes=(/halo,num_latm,lev_target/))
call netcdf_err(error, 'DEFINING V_S_LEFT')

!--- define global attributes
Expand Down

0 comments on commit 9e662d7

Please sign in to comment.