34 integer(I4B) :: nmesh_node
35 integer(I4B) :: nmesh_face
36 integer(I4B) :: max_nmesh_face_nodes
46 integer(I4B) :: mesh_node_x
47 integer(I4B) :: mesh_node_y
48 integer(I4B) :: mesh_face_x
49 integer(I4B) :: mesh_face_y
50 integer(I4B) :: mesh_face_xbnds
51 integer(I4B) :: mesh_face_ybnds
52 integer(I4B) :: mesh_face_nodes
54 integer(I4B),
dimension(:),
allocatable :: dependent
64 integer(I4B),
pointer :: chunk_face
82 character(len=*),
intent(in) :: pkgtype
83 character(len=*),
intent(in) :: pkgname
84 character(len=*),
intent(in) :: mempath
98 subroutine mesh_init(this, modelname, modeltype, modelfname, nc_fname, &
99 disenum, nctype, lenuni, iout)
102 character(len=*),
intent(in) :: modelname
103 character(len=*),
intent(in) :: modeltype
104 character(len=*),
intent(in) :: modelfname
105 character(len=*),
intent(in) :: nc_fname
106 integer(I4B),
intent(in) :: disenum
107 integer(I4B),
intent(in) :: nctype
108 integer(I4B),
intent(in) :: lenuni
109 integer(I4B),
intent(in) :: iout
110 logical(LGP) :: found
113 call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
114 disenum, nctype, iout)
117 allocate (this%chunk_face)
121 if (this%ncf_mempath /=
'')
then
122 call mem_set_value(this%chunk_face,
'CHUNK_FACE', this%ncf_mempath, found)
125 if (this%chunk_time > 0 .and. this%chunk_face > 0)
then
126 this%chunking_active = .true.
127 else if (this%chunk_time > 0 .or. this%chunk_face > 0)
then
130 write (
warnmsg,
'(a)')
'Ignoring user provided NetCDF chunking parameter. &
131 &Define chunk_time and chunk_face input parameters to see an effect in &
132 &file "'//trim(nc_fname)//
'".'
136 if (lenuni == 1)
then
143 call nf_verify(nf90_create(this%nc_fname, &
144 ior(nf90_clobber, nf90_netcdf4), this%ncid), &
153 call nf_verify(nf90_close(this%ncid), this%nc_fname)
154 deallocate (this%chunk_face)
155 nullify (this%chunk_face)
163 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'title', &
164 this%annotation%title), this%nc_fname)
166 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'source', &
167 this%annotation%source), this%nc_fname)
169 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_grid', &
170 this%annotation%grid), this%nc_fname)
172 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_model', &
173 this%annotation%model), this%nc_fname)
175 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'history', &
176 this%annotation%history), this%nc_fname)
178 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'Conventions', &
179 this%annotation%conventions), &
188 character(len=*),
intent(in) :: pkgtype
189 character(len=*),
intent(in) :: pkgname
190 character(len=*),
intent(in) :: mempath
192 intent(in) :: param_dfns
194 integer(I4B) :: iparam, isize
196 do iparam = 1,
size(param_dfns)
198 idt => param_dfns(iparam)
200 if (idt%blockname ==
'GRIDDATA')
then
202 call get_isize(idt%mf6varname, mempath, isize)
204 call this%export_input_array(pkgtype, pkgname, mempath, idt)
220 character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
221 character(len=LENMEMPATH) :: input_mempath
223 pointer :: pkgtypes => null()
225 pointer :: pkgnames => null()
227 pointer :: mempaths => null()
229 character(len=LENMEMPATH) :: mempath
231 integer(I4B),
pointer :: export_arrays
232 logical(LGP) :: found
237 call mem_setptr(pkgtypes,
'PKGTYPES', input_mempath)
238 call mem_setptr(pkgnames,
'PKGNAMES', input_mempath)
239 call mem_setptr(mempaths,
'MEMPATHS', input_mempath)
241 allocate (export_arrays)
243 do n = 1,
size(mempaths)
248 mempath = mempaths(n)
253 if (mempath /=
'')
then
255 call mem_set_value(export_arrays,
'EXPORT_NC', mempath, found)
256 if (export_arrays > 0)
then
258 param_dfns => param_definitions(this%modeltype, pkgtype)
259 call this%export_input_arrays(ptype, pname, mempath, param_dfns)
265 deallocate (export_arrays)
272 character(len=LINELENGTH) :: varname, longname
282 write (varname,
'(a,i0)') trim(this%xname)//
'_l', k
283 write (longname,
'(a,i0,a)') trim(this%annotation%longname)// &
287 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
288 (/this%dim_ids%nmesh_face, &
289 this%dim_ids%time/), &
290 this%var_ids%dependent(k)), &
294 if (this%chunking_active)
then
295 call nf_verify(nf90_def_var_chunking(this%ncid, &
296 this%var_ids%dependent(k), &
299 this%chunk_time/)), &
304 call ncvar_deflate(this%ncid, this%var_ids%dependent(k), this%deflate, &
305 this%shuffle, this%nc_fname)
308 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
309 'units', this%lenunits), this%nc_fname)
310 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
311 'standard_name', this%annotation%stdname), &
313 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
314 'long_name', longname), this%nc_fname)
315 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
318 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
319 'mesh', this%mesh_name), this%nc_fname)
320 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
321 'location',
'face'), this%nc_fname)
325 this%gridmap_name, this%nc_fname)
333 integer(I4B) :: var_id
336 if (this%wkt /=
'')
then
338 call nf_verify(nf90_redef(this%ncid), this%nc_fname)
339 call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
340 var_id), this%nc_fname)
345 call nf_verify(nf90_put_att(this%ncid, var_id,
'wkt', this%wkt), &
347 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
348 call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
359 call nf_verify(nf90_def_var(this%ncid, this%mesh_name, nf90_int, &
360 this%var_ids%mesh), this%nc_fname)
363 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'cf_role', &
364 'mesh_topology'), this%nc_fname)
365 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'long_name', &
366 '2D mesh topology'), this%nc_fname)
367 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
368 'topology_dimension', 2), this%nc_fname)
369 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'face_dimension', &
370 'nmesh_face'), this%nc_fname)
371 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
372 'node_coordinates',
'mesh_node_x mesh_node_y'), &
374 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
375 'face_coordinates',
'mesh_face_x mesh_face_y'), &
377 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
378 'face_node_connectivity',
'mesh_face_nodes'), &
382 call nf_verify(nf90_def_var(this%ncid,
'mesh_node_x', nf90_double, &
383 (/this%dim_ids%nmesh_node/), &
384 this%var_ids%mesh_node_x), this%nc_fname)
387 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
388 'units', this%lenunits), this%nc_fname)
389 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
390 'standard_name',
'projection_x_coordinate'), &
392 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
393 'long_name',
'Easting'), this%nc_fname)
395 if (this%wkt /=
'')
then
397 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
398 'grid_mapping', this%gridmap_name), &
403 call nf_verify(nf90_def_var(this%ncid,
'mesh_node_y', nf90_double, &
404 (/this%dim_ids%nmesh_node/), &
405 this%var_ids%mesh_node_y), this%nc_fname)
408 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
409 'units', this%lenunits), this%nc_fname)
410 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
411 'standard_name',
'projection_y_coordinate'), &
413 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
414 'long_name',
'Northing'), this%nc_fname)
416 if (this%wkt /=
'')
then
418 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
419 'grid_mapping', this%gridmap_name), &
424 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_x', nf90_double, &
425 (/this%dim_ids%nmesh_face/), &
426 this%var_ids%mesh_face_x), this%nc_fname)
429 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
430 'units', this%lenunits), this%nc_fname)
431 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
432 'standard_name',
'projection_x_coordinate'), &
434 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
435 'long_name',
'Easting'), this%nc_fname)
436 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x,
'bounds', &
437 'mesh_face_xbnds'), this%nc_fname)
438 if (this%wkt /=
'')
then
440 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
441 'grid_mapping', this%gridmap_name), &
446 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_xbnds', nf90_double, &
447 (/this%dim_ids%max_nmesh_face_nodes, &
448 this%dim_ids%nmesh_face/), &
449 this%var_ids%mesh_face_xbnds), &
453 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_y', nf90_double, &
454 (/this%dim_ids%nmesh_face/), &
455 this%var_ids%mesh_face_y), this%nc_fname)
458 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
459 'units', this%lenunits), this%nc_fname)
460 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
461 'standard_name',
'projection_y_coordinate'), &
463 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
464 'long_name',
'Northing'), this%nc_fname)
465 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y,
'bounds', &
466 'mesh_face_ybnds'), this%nc_fname)
468 if (this%wkt /=
'')
then
470 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
471 'grid_mapping', this%gridmap_name), &
476 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_ybnds', nf90_double, &
477 (/this%dim_ids%max_nmesh_face_nodes, &
478 this%dim_ids%nmesh_face/), &
479 this%var_ids%mesh_face_ybnds), &
483 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_nodes', nf90_int, &
484 (/this%dim_ids%max_nmesh_face_nodes, &
485 this%dim_ids%nmesh_face/), &
486 this%var_ids%mesh_face_nodes), &
490 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
491 'cf_role',
'face_node_connectivity'), &
493 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
495 'Vertices bounding cell (counterclockwise)'), &
497 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
498 '_FillValue', (/nf90_fill_int/)), &
500 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
501 'start_index', 1), this%nc_fname)
507 integer(I4B),
intent(in) :: ncid
508 integer(I4B),
intent(in) :: varid
509 integer(I4B),
intent(in) :: chunk_face
510 character(len=*),
intent(in) :: nc_fname
511 if (chunk_face > 0)
then
512 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
513 (/chunk_face/)), nc_fname)
520 integer(I4B),
intent(in) :: ncid
521 integer(I4B),
intent(in) :: varid
522 integer(I4B),
intent(in) :: deflate
523 integer(I4B),
intent(in) :: shuffle
524 character(len=*),
intent(in) :: nc_fname
525 if (deflate >= 0)
then
526 call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
527 deflate=1, deflate_level=deflate), &
535 integer(I4B),
intent(in) :: ncid
536 integer(I4B),
intent(in) :: varid
537 character(len=*),
intent(in) :: gridmap_name
538 character(len=*),
intent(in) :: nc_fname
539 if (gridmap_name /=
'')
then
540 call nf_verify(nf90_put_att(ncid, varid,
'coordinates', &
541 'mesh_face_x mesh_face_y'), nc_fname)
542 call nf_verify(nf90_put_att(ncid, varid,
'grid_mapping', &
543 gridmap_name), nc_fname)
550 integer(I4B),
intent(in) :: ncid
551 integer(I4B),
intent(in) :: varid
552 integer(I4B),
intent(in) :: layer
553 integer(I4B),
intent(in) :: iper
554 integer(I4B),
intent(in) :: iaux
555 character(len=*),
intent(in) :: nc_tag
556 character(len=*),
intent(in) :: nc_fname
557 if (nc_tag /=
'')
then
558 call nf_verify(nf90_put_att(ncid, varid,
'modflow6_input', &
561 call nf_verify(nf90_put_att(ncid, varid,
'modflow6_layer', &
565 call nf_verify(nf90_put_att(ncid, varid,
'modflow6_iper', &
569 call nf_verify(nf90_put_att(ncid, varid,
'modflow6_iaux', &
579 character(len=*),
intent(in) :: varname
580 integer(I4B),
optional,
intent(in) :: layer
581 integer(I4B),
optional,
intent(in) :: iper
582 integer(I4B),
optional,
intent(in) :: iaux
583 character(len=LINELENGTH) :: vname
585 if (varname /=
'')
then
588 if (
present(layer))
then
590 write (vname,
'(a,i0)') trim(vname)//
'_l', layer
593 if (
present(iper))
then
595 write (vname,
'(a,i0)') trim(vname)//
'_p', iper
598 if (
present(iaux))
then
600 write (vname,
'(a,i0)') trim(vname)//
'a', iaux
abstract interfaces for derived ugrid netcd export types
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lencomponentname
maximum length of a component name
real(dp), parameter dnodata
real no data constant
real(dp), parameter dhnoflo
real no flow constant
integer(i4b), parameter lenmempath
maximum length of the memory path
type(inputparamdefinitiontype) function, dimension(:), pointer, public param_definitions(component, subcomponent)
logical function, public idm_multi_package(component, subcomponent)
This module defines variable data types.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains the MeshModelModule.
subroutine define_gridmap(this)
create the file grid mapping container variable
character(len=linelength) function, public export_varname(varname, layer, iper, iaux)
build netcdf variable name
subroutine, public ncvar_gridmap(ncid, varid, gridmap_name, nc_fname)
put variable gridmap attributes
subroutine, public ncvar_chunk(ncid, varid, chunk_face, nc_fname)
define variable chunking
subroutine mesh_init(this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, lenuni, iout)
initialize
subroutine mesh_destroy(this)
initialize
subroutine add_global_att(this)
create file (group) attributes
subroutine add_pkg_data(this)
determine packages to write gridded input
subroutine export_input_arrays(this, pkgtype, pkgname, mempath, param_dfns)
write package gridded input data
subroutine define_dependent(this)
create the model layer dependent variables
subroutine, public ncvar_deflate(ncid, varid, deflate, shuffle, nc_fname)
define variable compression
subroutine, public ncvar_mf6attr(ncid, varid, layer, iper, iaux, nc_tag, nc_fname)
put variable internal attributes
subroutine create_mesh(this)
create the file mesh container variable
This module contains the NCModelExportModule.
This module contains the NetCDFCommonModule.
subroutine, public nf_verify(res, nc_fname)
error check a netcdf-fortran interface call
This module contains simulation methods.
subroutine, public store_warning(msg, substring)
Store warning message.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
character(len=maxcharlen) warnmsg
warning message string
This module contains the SourceCommonModule.
character(len=lencomponentname) function, public idm_subcomponent_type(component, subcomponent)
component from package or model type
This class is used to store a single deferred-length character string. It was designed to work in an ...
base ugrid netcdf export type
type for storing model export dimension ids
type for storing model export variable ids
abstract type for model netcdf export type