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

Modify chgres_cube output netcdf4 files. #704

Merged
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
16 changes: 4 additions & 12 deletions sorc/chgres_cube.fd/write_data.F90
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ subroutine write_fv3_atm_header_netcdf(localpet)

character(len=13) :: outfile

integer :: fsize=65536, initial = 0
integer :: header_buffer_val = 16384
integer :: error, ncid, dim_nvcoord
integer :: dim_levp1, id_ntrac, id_vcoord
Expand All @@ -55,8 +54,7 @@ subroutine write_fv3_atm_header_netcdf(localpet)

print*,"- WRITE ATMOSPHERIC HEADER FILE: ", trim(outfile)

error = nf90_create(outfile, IOR(NF90_NETCDF4,NF90_CLASSIC_MODEL), &
ncid, initialsize=initial, chunksize=fsize)
error = nf90_create(outfile, NF90_NETCDF4, ncid)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change loses the NF90_CLASSIC_MODEL flag, and that's fine.

The CLASSIC_MODEL flag ensures that the created file follows netCDF classic rules, so it can be processed by netcdf-classic (i.e. pre-netCDF4) code. Although the CLASSIC_MODEL enforces some restrictions on the netCDF-4 file, it is not really necessary.

If we refrain from using netCDF-4 user-defined types, hierarchical groups, and unsigned integer types (and this is the current plan, AFAIK), then the output files will continue to be readable by netCDF classic code. The NC4_CLASSIC_MODEL flag is not needed for this, we will still get it.

Eliminating the initialsize and chunksize optional parameters is good. They are ignored for NC_NETCDF4 files. NetCDF-4 chunksizes are set on a per-variable basis, when the variable is defined. If you don't explicitly set the variable chunksizes, then netCDF will take a guess and come up with chunksizes for each var.

So this is a good change.

call netcdf_err(error, 'CREATING FILE='//trim(outfile) )

error = nf90_def_dim(ncid, 'nvcoord', nvcoord_target, dim_nvcoord)
Expand Down Expand Up @@ -135,7 +133,6 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet)

character(len=50) :: name

integer :: fsize=65536, initial = 0
integer :: header_buffer_val = 16384
integer :: ncid, error, tile, i, n
integer :: dim_lon, dim_lat
Expand Down Expand Up @@ -207,8 +204,7 @@ subroutine write_fv3_atm_bndy_data_netcdf(localpet)
if (localpet == 0) then

!--- open the file
error = nf90_create("./gfs.bndy.nc", IOR(NF90_NETCDF4,NF90_CLASSIC_MODEL), &
ncid, initialsize=initial, chunksize=fsize)
error = nf90_create("./gfs.bndy.nc", NF90_NETCDF4, ncid)
call netcdf_err(error, 'CREATING BNDY FILE' )

error = nf90_def_dim(ncid, 'lon', i_target, dim_lon)
Expand Down Expand Up @@ -1231,7 +1227,6 @@ subroutine write_fv3_atm_data_netcdf(localpet)
character(len=128) :: outfile

integer :: error, ncid, tile, n
integer :: fsize=65536, initial = 0
integer :: header_buffer_val = 16384
integer :: dim_lon, dim_lat
integer :: dim_lonp, dim_latp
Expand Down Expand Up @@ -1289,8 +1284,7 @@ subroutine write_fv3_atm_data_netcdf(localpet)
endif

!--- open the file
error = nf90_create(outfile, IOR(NF90_NETCDF4,NF90_CLASSIC_MODEL), &
ncid, initialsize=initial, chunksize=fsize)
error = nf90_create(outfile, NF90_NETCDF4, ncid)
call netcdf_err(error, 'CREATING FILE='//trim(outfile) )

!--- define dimension
Expand Down Expand Up @@ -1875,7 +1869,6 @@ subroutine write_fv3_sfc_data_netcdf(localpet)
integer, intent(in) :: localpet
character(len=128) :: outfile

integer :: fsize=65536, initial = 0
integer :: header_buffer_val = 16384
integer :: dim_x, dim_y, dim_lsoil, dim_time
integer :: error, i, ncid, tile
Expand Down Expand Up @@ -1967,8 +1960,7 @@ subroutine write_fv3_sfc_data_netcdf(localpet)
endif

!--- open the file
error = nf90_create(outfile, IOR(NF90_NETCDF4,NF90_CLASSIC_MODEL), &
ncid, initialsize=initial, chunksize=fsize)
error = nf90_create(outfile, NF90_NETCDF4, ncid)
call netcdf_err(error, 'CREATING FILE='//trim(outfile) )

!--- define dimensions
Expand Down