diff --git a/doc/mf6io/mf6ivar/dfn/utl-ncf.dfn b/doc/mf6io/mf6ivar/dfn/utl-ncf.dfn index 75075c8cce1..57352c546c0 100644 --- a/doc/mf6io/mf6ivar/dfn/utl-ncf.dfn +++ b/doc/mf6io/mf6ivar/dfn/utl-ncf.dfn @@ -10,7 +10,7 @@ shape lenbigline reader urword optional true longname CRS well-known text (WKT) string -description is the coordinate reference system (CRS) well-known text (WKT) string. +description is the coordinate reference system (CRS) well-known text (WKT) string. Ignored if latitude and longitude griddata arrays have been provided for NETCDF\_STRUCTURED export type. block options name deflate @@ -96,7 +96,7 @@ shape (ncpl) optional true reader readarray longname cell center latitude -description cell center latitude. +description cell center latitude. Only supported for NETCDF\_STRUCTURED export type. block griddata name longitude @@ -105,4 +105,4 @@ shape (ncpl) optional true reader readarray longname cell center longitude -description cell center longitude. +description cell center longitude. Only supported for NETCDF\_STRUCTURED export type. diff --git a/src/Utilities/Export/DisNCMesh.f90 b/src/Utilities/Export/DisNCMesh.f90 index 80ba4bf1777..3396a37c61d 100644 --- a/src/Utilities/Export/DisNCMesh.f90 +++ b/src/Utilities/Export/DisNCMesh.f90 @@ -69,7 +69,7 @@ subroutine dis_export_init(this, modelname, modeltype, modelfname, nc_fname, & ! initialize base class call this%mesh_init(modelname, modeltype, modelfname, nc_fname, disenum, & - nctype, iout) + nctype, this%dis%lenuni, iout) end subroutine dis_export_init !> @brief netcdf export dis destroy @@ -457,12 +457,13 @@ end subroutine define_dim !> @brief netcdf export add mesh information !< subroutine add_mesh_data(this) + use BaseDisModule, only: dis_transform_xy class(Mesh2dDisExportType), intent(inout) :: this integer(I4B) :: cnt, maxvert, m integer(I4B), dimension(:), allocatable :: verts real(DP), dimension(:), allocatable :: bnds integer(I4B) :: i, j - real(DP) :: x, y + real(DP) :: x, y, x_transform, y_transform real(DP), dimension(:), allocatable :: node_x, node_y real(DP), dimension(:), allocatable :: cell_x, cell_y @@ -485,13 +486,18 @@ subroutine add_mesh_data(this) cnt = 0 node_x = NF90_FILL_DOUBLE node_y = NF90_FILL_DOUBLE - y = this%dis%yorigin + sum(this%dis%delc) + y = sum(this%dis%delc) do j = this%dis%nrow, 0, -1 - x = this%dis%xorigin + x = 0 do i = this%dis%ncol, 0, -1 cnt = cnt + 1 - node_x(cnt) = x - node_y(cnt) = y + call dis_transform_xy(x, y, & + this%dis%xorigin, & + this%dis%yorigin, & + this%dis%angrot, & + x_transform, y_transform) + node_x(cnt) = x_transform + node_y(cnt) = y_transform if (i > 0) x = x + this%dis%delr(i) end do if (j > 0) y = y - this%dis%delc(j) @@ -508,13 +514,17 @@ subroutine add_mesh_data(this) cell_x = NF90_FILL_DOUBLE cell_y = NF90_FILL_DOUBLE do j = 1, this%dis%nrow - x = this%dis%xorigin - y = this%dis%celly(j) + this%dis%yorigin + y = this%dis%celly(j) do i = 1, this%dis%ncol - cell_x(cnt) = x - cell_y(cnt) = y + x = this%dis%cellx(i) + call dis_transform_xy(x, y, & + this%dis%xorigin, & + this%dis%yorigin, & + this%dis%angrot, & + x_transform, y_transform) + cell_x(cnt) = x_transform + cell_y(cnt) = y_transform cnt = cnt + 1 - x = this%dis%cellx(i) + this%dis%xorigin end do end do diff --git a/src/Utilities/Export/DisNCStructured.f90 b/src/Utilities/Export/DisNCStructured.f90 index 823cfe36661..403a243ad25 100644 --- a/src/Utilities/Export/DisNCStructured.f90 +++ b/src/Utilities/Export/DisNCStructured.f90 @@ -9,7 +9,7 @@ module DisNCStructuredModule use KindModule, only: DP, I4B, LGP use ConstantsModule, only: LINELENGTH, LENBIGLINE, LENCOMPONENTNAME, & - LENMEMPATH, LENVARNAME + LENMEMPATH, LENVARNAME, DNODATA, DZERO use SimVariablesModule, only: errmsg, warnmsg use SimModule, only: store_error, store_warning, store_error_filename use MemoryManagerModule, only: mem_setptr @@ -75,7 +75,7 @@ module DisNCStructuredModule procedure :: define_dim procedure :: define_dependent procedure :: define_gridmap - procedure :: define_projection + procedure :: define_geocoords procedure :: add_proj_data procedure :: add_grid_data end type DisNCStructuredType @@ -127,6 +127,7 @@ subroutine dis_export_init(this, modelname, modeltype, modelfname, nc_fname, & ! initialize base class call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, & disenum, nctype, iout) + ! update values from input context if (this%ncf_mempath /= '') then call mem_set_value(this%chunk_z, 'CHUNK_Z', this%ncf_mempath, found) @@ -144,7 +145,7 @@ subroutine dis_export_init(this, modelname, modeltype, modelfname, nc_fname, & this%chunk_x = -1 write (warnmsg, '(a)') 'Ignoring user provided NetCDF chunking & ¶meters. Define chunk_time, chunk_x, chunk_y and chunk_z input & - ¶meters to see an effect.' + ¶meters to see an effect in file "'//trim(nc_fname)//'".' call store_warning(warnmsg) end if @@ -153,9 +154,32 @@ subroutine dis_export_init(this, modelname, modeltype, modelfname, nc_fname, & if (latsz > 0 .and. lonsz > 0) then this%latlon = .true. + if (this%wkt /= '') then + write (warnmsg, '(a)') 'Ignoring user provided NetCDF wkt parameter & + &as longitude and latitude arrays have been provided. & + &Applies to file "'//trim(nc_fname)//'".' + call store_warning(warnmsg) + this%wkt = '' + this%gridmap_name = '' + end if call mem_setptr(this%latitude, 'LATITUDE', this%ncf_mempath) call mem_setptr(this%longitude, 'LONGITUDE', this%ncf_mempath) end if + + if (this%wkt /= '') then + if (this%dis%angrot /= DZERO) then + write (warnmsg, '(a)') 'WKT parameter set with structured rotated & + &grid. Projected coordinates will have grid local values. & + &Applies to file "'//trim(nc_fname)//'".' + call store_warning(warnmsg) + end if + end if + end if + + if (this%dis%lenuni == 1) then + this%lenunits = 'ft' + else + this%lenunits = 'm' end if ! create the netcdf file @@ -191,7 +215,7 @@ subroutine df(this) ! define root group dimensions and coordinate variables call this%define_dim() ! define grid projection variables - call this%define_projection() + call this%define_geocoords() if (isim_mode /= MVALIDATE) then ! define the dependent variable call this%define_dependent() @@ -367,7 +391,6 @@ end subroutine export_input_arrays !> @brief netcdf export package dynamic input with ilayer index variable !< subroutine package_step_ilayer(this, export_pkg, ilayer_varname, ilayer) - use ConstantsModule, only: DNODATA, DZERO use TdisModule, only: kper use NCModelExportModule, only: ExportPackageType use DefinitionSelectModule, only: get_param_definition_type @@ -515,7 +538,6 @@ end subroutine package_step !< subroutine export_layer_3d(this, export_pkg, idt, ilayer_read, ialayer, & dbl1d, nc_varname, input_attr, iaux) - use ConstantsModule, only: DNODATA, DZERO use TdisModule, only: kper use NCModelExportModule, only: ExportPackageType class(DisNCStructuredType), intent(inout) :: this @@ -640,10 +662,10 @@ subroutine add_global_att(this) call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'source', & this%annotation%source), this%nc_fname) ! export type (MODFLOW 6) - call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'modflow6_grid', & + call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'modflow_grid', & this%annotation%grid), this%nc_fname) ! MODFLOW 6 model type - call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'modflow6_model', & + call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'modflow_model', & this%annotation%model), this%nc_fname) ! generation datetime call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'history', & @@ -707,8 +729,8 @@ subroutine define_dim(this) this%nc_fname) call nf_verify(nf90_def_var(this%ncid, 'y', NF90_DOUBLE, this%dim_ids%y, & this%var_ids%y), this%nc_fname) - call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'units', 'm'), & - this%nc_fname) + call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'units', & + this%lenunits), this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'axis', 'Y'), & this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'standard_name', & @@ -730,8 +752,8 @@ subroutine define_dim(this) this%nc_fname) call nf_verify(nf90_def_var(this%ncid, 'x', NF90_DOUBLE, this%dim_ids%x, & this%var_ids%x), this%nc_fname) - call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'units', 'm'), & - this%nc_fname) + call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'units', & + this%lenunits), this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'axis', 'X'), & this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'standard_name', & @@ -782,7 +804,7 @@ subroutine define_dependent(this) ! put attr call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, & - 'units', 'm'), this%nc_fname) + 'units', this%lenunits), this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, & 'standard_name', this%annotation%stdname), & this%nc_fname) @@ -816,9 +838,9 @@ end subroutine define_gridmap !> @brief define grid projection variables !< - subroutine define_projection(this) + subroutine define_geocoords(this) class(DisNCStructuredType), intent(inout) :: this - if (this%latlon .and. this%wkt /= '') then + if (this%latlon) then ! lat call nf_verify(nf90_def_var(this%ncid, 'lat', NF90_DOUBLE, & (/this%dim_ids%x, this%dim_ids%y/), & @@ -841,13 +863,13 @@ subroutine define_projection(this) call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, & 'long_name', 'longitude'), this%nc_fname) end if - end subroutine define_projection + end subroutine define_geocoords !> @brief add grid projection data !< subroutine add_proj_data(this) class(DisNCStructuredType), intent(inout) :: this - if (this%latlon .and. this%wkt /= '') then + if (this%latlon) then ! lat call nf_verify(nf90_put_var(this%ncid, this%var_ids%latitude, & this%latitude, start=(/1, 1/), & @@ -869,16 +891,25 @@ subroutine add_grid_data(this) integer(I4B) :: ibnd, n !, k, i, j real(DP), dimension(:, :), pointer, contiguous :: dbl2d real(DP), dimension(:), allocatable :: x, y + real(DP) :: xoff, yoff + + if (this%dis%angrot /= DZERO) then + xoff = DZERO + yoff = DZERO + else + xoff = this%dis%xorigin + yoff = this%dis%yorigin + end if allocate (x(size(this%dis%cellx))) allocate (y(size(this%dis%celly))) do n = 1, size(this%dis%cellx) - x(n) = this%dis%cellx(n) + this%dis%xorigin + x(n) = this%dis%cellx(n) + xoff end do do n = 1, size(this%dis%celly) - y(n) = this%dis%celly(n) + this%dis%yorigin + y(n) = this%dis%celly(n) + yoff end do call nf_verify(nf90_put_var(this%ncid, this%var_ids%x, x), & @@ -897,8 +928,8 @@ subroutine add_grid_data(this) ibnd = 1 do n = 1, size(this%dis%cellx) if (ibnd == 1) then - dbl2d(1, ibnd) = this%dis%xorigin - dbl2d(2, ibnd) = this%dis%xorigin + this%dis%delr(ibnd) + dbl2d(1, ibnd) = xoff + dbl2d(2, ibnd) = xoff + this%dis%delr(ibnd) else dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) + this%dis%delr(ibnd) dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) + this%dis%delr(ibnd) @@ -914,8 +945,8 @@ subroutine add_grid_data(this) ibnd = 1 do n = size(this%dis%celly), 1, -1 if (ibnd == 1) then - dbl2d(1, ibnd) = this%dis%yorigin + sum(this%dis%delc) - this%dis%delc(n) - dbl2d(2, ibnd) = this%dis%yorigin + sum(this%dis%delc) + dbl2d(1, ibnd) = yoff + sum(this%dis%delc) - this%dis%delc(n) + dbl2d(2, ibnd) = yoff + sum(this%dis%delc) else dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) - this%dis%delc(n) dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) - this%dis%delc(n) @@ -982,15 +1013,13 @@ subroutine ncvar_gridmap(ncid, varid, gridmap_name, latlon, nc_fname) logical(LGP), intent(in) :: latlon character(len=*), intent(in) :: nc_fname if (gridmap_name /= '') then - if (latlon) then - call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'lon lat'), & - nc_fname) - else - call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'x y'), & - nc_fname) - end if + call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'x y'), & + nc_fname) call nf_verify(nf90_put_att(ncid, varid, 'grid_mapping', gridmap_name), & nc_fname) + else if (latlon) then + call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'lon lat'), & + nc_fname) end if end subroutine ncvar_gridmap diff --git a/src/Utilities/Export/DisvNCMesh.f90 b/src/Utilities/Export/DisvNCMesh.f90 index 07b5a6a06ac..43e44e89b43 100644 --- a/src/Utilities/Export/DisvNCMesh.f90 +++ b/src/Utilities/Export/DisvNCMesh.f90 @@ -67,7 +67,7 @@ subroutine disv_export_init(this, modelname, modeltype, modelfname, nc_fname, & ! initialize base class call this%mesh_init(modelname, modeltype, modelfname, nc_fname, disenum, & - nctype, iout) + nctype, this%disv%lenuni, iout) end subroutine disv_export_init !> @brief netcdf export disv destroy @@ -434,6 +434,7 @@ end subroutine define_dim !> @brief netcdf export add mesh information !< subroutine add_mesh_data(this) + use BaseDisModule, only: dis_transform_xy class(Mesh2dDisvExportType), intent(inout) :: this integer(I4B), dimension(:), contiguous, pointer :: icell2d => null() integer(I4B), dimension(:), contiguous, pointer :: ncvert => null() @@ -442,6 +443,11 @@ subroutine add_mesh_data(this) real(DP), dimension(:), contiguous, pointer :: cell_y => null() real(DP), dimension(:), contiguous, pointer :: vert_x => null() real(DP), dimension(:), contiguous, pointer :: vert_y => null() + real(DP), dimension(:), contiguous, pointer :: cell_xt => null() + real(DP), dimension(:), contiguous, pointer :: cell_yt => null() + real(DP), dimension(:), contiguous, pointer :: vert_xt => null() + real(DP), dimension(:), contiguous, pointer :: vert_yt => null() + real(DP) :: x_transform, y_transform integer(I4B) :: n, m, idx, cnt, iv, maxvert integer(I4B), dimension(:), allocatable :: verts real(DP), dimension(:), allocatable :: bnds @@ -456,28 +462,56 @@ subroutine add_mesh_data(this) call mem_setptr(vert_x, 'XV', this%dis_mempath) call mem_setptr(vert_y, 'YV', this%dis_mempath) - ! initialize max vertices required to define cell - maxvert = maxval(ncvert) + ! allocate x, y transform arrays + allocate (cell_xt(size(cell_x))) + allocate (cell_yt(size(cell_y))) + allocate (vert_xt(size(vert_x))) + allocate (vert_yt(size(vert_y))) ! set mesh container variable value to 1 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh, 1), & this%nc_fname) - ! allocate temporary arrays - allocate (verts(maxvert)) - allocate (bnds(maxvert)) + ! transform vert x and y + do n = 1, size(vert_x) + call dis_transform_xy(vert_x(n), vert_y(n), & + this%disv%xorigin, & + this%disv%yorigin, & + this%disv%angrot, & + x_transform, y_transform) + vert_xt(n) = x_transform + vert_yt(n) = y_transform + end do + + ! transform cell x and y + do n = 1, size(cell_x) + call dis_transform_xy(cell_x(n), cell_y(n), & + this%disv%xorigin, & + this%disv%yorigin, & + this%disv%angrot, & + x_transform, y_transform) + cell_xt(n) = x_transform + cell_yt(n) = y_transform + end do ! write node_x and node_y arrays to netcdf file call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_node_x, & - vert_x + this%disv%xorigin), this%nc_fname) + vert_xt), this%nc_fname) call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_node_y, & - vert_y + this%disv%yorigin), this%nc_fname) + vert_yt), this%nc_fname) ! write face_x and face_y arrays to netcdf file call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_x, & - cell_x + this%disv%xorigin), this%nc_fname) + cell_xt), this%nc_fname) call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_y, & - cell_y + this%disv%yorigin), this%nc_fname) + cell_yt), this%nc_fname) + + ! initialize max vertices required to define cell + maxvert = maxval(ncvert) + + ! allocate temporary arrays + allocate (verts(maxvert)) + allocate (bnds(maxvert)) ! set face nodes array cnt = 0 @@ -502,7 +536,7 @@ subroutine add_mesh_data(this) bnds = NF90_FILL_DOUBLE do m = 1, size(bnds) if (verts(m) /= NF90_FILL_INT) then - bnds(m) = vert_y(verts(m)) + bnds(m) = vert_yt(verts(m)) end if ! write face y bounds array to netcdf file call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_ybnds, & @@ -515,7 +549,7 @@ subroutine add_mesh_data(this) bnds = NF90_FILL_DOUBLE do m = 1, size(bnds) if (verts(m) /= NF90_FILL_INT) then - bnds(m) = vert_x(verts(m)) + bnds(m) = vert_xt(verts(m)) end if ! write face x bounds array to netcdf file call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_xbnds, & @@ -528,6 +562,10 @@ subroutine add_mesh_data(this) ! cleanup deallocate (bnds) deallocate (verts) + deallocate (cell_xt) + deallocate (cell_yt) + deallocate (vert_xt) + deallocate (vert_yt) end subroutine add_mesh_data !> @brief netcdf export 1D integer array diff --git a/src/Utilities/Export/MeshNCModel.f90 b/src/Utilities/Export/MeshNCModel.f90 index 0062e8e7fc6..3a7fb58e3e6 100644 --- a/src/Utilities/Export/MeshNCModel.f90 +++ b/src/Utilities/Export/MeshNCModel.f90 @@ -96,7 +96,7 @@ subroutine nc_array_export_if(this, pkgtype, pkgname, mempath, idt) !> @brief initialize !< subroutine mesh_init(this, modelname, modeltype, modelfname, nc_fname, & - disenum, nctype, iout) + disenum, nctype, lenuni, iout) use MemoryManagerExtModule, only: mem_set_value class(MeshModelType), intent(inout) :: this character(len=*), intent(in) :: modelname @@ -105,6 +105,7 @@ subroutine mesh_init(this, modelname, modeltype, modelfname, nc_fname, & character(len=*), intent(in) :: nc_fname integer(I4B), intent(in) :: disenum integer(I4B), intent(in) :: nctype + integer(I4B), intent(in) :: lenuni integer(I4B), intent(in) :: iout logical(LGP) :: found @@ -127,10 +128,17 @@ subroutine mesh_init(this, modelname, modeltype, modelfname, nc_fname, & this%chunk_face = -1 this%chunk_time = -1 write (warnmsg, '(a)') 'Ignoring user provided NetCDF chunking parameter. & - &Define chunk_time and chunk_face input parameters to see an effect.' + &Define chunk_time and chunk_face input parameters to see an effect in & + &file "'//trim(nc_fname)//'".' call store_warning(warnmsg) end if + if (lenuni == 1) then + this%lenunits = 'ft' + else + this%lenunits = 'm' + end if + ! create the netcdf file call nf_verify(nf90_create(this%nc_fname, & IOR(NF90_CLOBBER, NF90_NETCDF4), this%ncid), & @@ -158,10 +166,10 @@ subroutine add_global_att(this) call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'source', & this%annotation%source), this%nc_fname) ! export type (MODFLOW 6) - call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'modflow6_grid', & + call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'modflow_grid', & this%annotation%grid), this%nc_fname) ! MODFLOW 6 model type - call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'modflow6_model', & + call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'modflow_model', & this%annotation%model), this%nc_fname) ! generation datetime call nf_verify(nf90_put_att(this%ncid, NF90_GLOBAL, 'history', & @@ -298,7 +306,7 @@ subroutine define_dependent(this) ! assign variable attributes call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), & - 'units', 'm'), this%nc_fname) + 'units', this%lenunits), this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), & 'standard_name', this%annotation%stdname), & this%nc_fname) @@ -377,7 +385,7 @@ subroutine create_mesh(this) ! assign mesh x node variable attributes call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, & - 'units', 'm'), this%nc_fname) + 'units', this%lenunits), this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, & 'standard_name', 'projection_x_coordinate'), & this%nc_fname) @@ -398,7 +406,7 @@ subroutine create_mesh(this) ! assign mesh y variable attributes call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, & - 'units', 'm'), this%nc_fname) + 'units', this%lenunits), this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, & 'standard_name', 'projection_y_coordinate'), & this%nc_fname) @@ -419,7 +427,7 @@ subroutine create_mesh(this) ! assign mesh x face variable attributes call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, & - 'units', 'm'), this%nc_fname) + 'units', this%lenunits), this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, & 'standard_name', 'projection_x_coordinate'), & this%nc_fname) @@ -448,7 +456,7 @@ subroutine create_mesh(this) ! assign mesh y face variable attributes call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, & - 'units', 'm'), this%nc_fname) + 'units', this%lenunits), this%nc_fname) call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, & 'standard_name', 'projection_y_coordinate'), & this%nc_fname) diff --git a/src/Utilities/Export/NCModel.f90 b/src/Utilities/Export/NCModel.f90 index cb4d83d28c7..e2d3558a4a5 100644 --- a/src/Utilities/Export/NCModel.f90 +++ b/src/Utilities/Export/NCModel.f90 @@ -77,6 +77,7 @@ module NCModelExportModule character(len=LENBIGLINE) :: wkt !< wkt user string character(len=LINELENGTH) :: datetime !< export file creation time character(len=LINELENGTH) :: xname !< dependent variable name + character(len=LINELENGTH) :: lenunits !< unidata udunits length units type(NCExportAnnotation) :: annotation !< export file annotation real(DP), dimension(:), pointer, contiguous :: x !< dependent variable pointer integer(I4B) :: disenum !< type of discretization @@ -296,6 +297,7 @@ subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, & this%wkt = '' this%datetime = '' this%xname = '' + this%lenunits = '' this%disenum = disenum this%ncid = 0 this%stepcnt = 0 diff --git a/src/Utilities/Idm/netcdf/NCContextBuild.f90 b/src/Utilities/Idm/netcdf/NCContextBuild.f90 index 1340f6ae516..72127e2d3c3 100644 --- a/src/Utilities/Idm/netcdf/NCContextBuild.f90 +++ b/src/Utilities/Idm/netcdf/NCContextBuild.f90 @@ -116,7 +116,7 @@ subroutine add_package_var(modeltype, modelname, nc_vars, input_name, varid, & end if end subroutine add_package_var - !> @brief verify global attribute modflow6_grid is present and return value + !> @brief verify global attribute modflow_grid is present and return value !< function verify_global_attr(modeltype, modelname, input_name, nc_fname, ncid) & result(grid) @@ -132,12 +132,12 @@ function verify_global_attr(modeltype, modelname, input_name, nc_fname, ncid) & grid = '' ! verify expected mf6_modeltype file attribute - if (nf90_get_att(ncid, NF90_GLOBAL, "modflow6_grid", & + if (nf90_get_att(ncid, NF90_GLOBAL, "modflow_grid", & grid) == NF90_NOERR) then ! set grid to upper case call upcase(grid) else - errmsg = 'NetCDF input file global attribute "grid" not found.' + errmsg = 'NetCDF input file global attribute "modflow_grid" not found.' call store_error(errmsg) call store_error_filename(nc_fname) end if