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 :: export
55 integer(I4B),
dimension(:),
allocatable :: dependent
65 integer(I4B),
pointer :: chunk_face
86 character(len=*),
intent(in) :: pkgtype
87 character(len=*),
intent(in) :: pkgname
88 character(len=*),
intent(in) :: mempath
102 subroutine mesh_init(this, modelname, modeltype, modelfname, nc_fname, &
103 disenum, nctype, lenuni, iout)
106 character(len=*),
intent(in) :: modelname
107 character(len=*),
intent(in) :: modeltype
108 character(len=*),
intent(in) :: modelfname
109 character(len=*),
intent(in) :: nc_fname
110 integer(I4B),
intent(in) :: disenum
111 integer(I4B),
intent(in) :: nctype
112 integer(I4B),
intent(in) :: lenuni
113 integer(I4B),
intent(in) :: iout
114 logical(LGP) :: found
117 call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
118 disenum, nctype, iout)
121 allocate (this%chunk_face)
125 if (this%ncf_mempath /=
'')
then
126 call mem_set_value(this%chunk_face,
'CHUNK_FACE', this%ncf_mempath, found)
129 if (this%chunk_time > 0 .and. this%chunk_face > 0)
then
130 this%chunking_active = .true.
131 else if (this%chunk_time > 0 .or. this%chunk_face > 0)
then
134 write (
warnmsg,
'(a)')
'Ignoring user provided NetCDF chunking parameter. &
135 &Define chunk_time and chunk_face input parameters to see an effect in &
136 &file "'//trim(nc_fname)//
'".'
140 if (lenuni == 1)
then
147 call nf_verify(nf90_create(this%nc_fname, &
148 ior(nf90_clobber, nf90_netcdf4), this%ncid), &
157 call nf_verify(nf90_close(this%ncid), this%nc_fname)
158 deallocate (this%chunk_face)
159 nullify (this%chunk_face)
169 do idx = 1, this%pkglist%Count()
170 export_pkg => this%get(idx)
171 call this%export_df(export_pkg)
183 integer(I4B) :: iparam, iaux, layer
186 do iparam = 1, export_pkg%nparam
193 export_pkg%mf6_input%component_type, &
194 export_pkg%mf6_input%subcomponent_type, &
195 'PERIOD', export_pkg%param_names(iparam),
'')
197 select case (idt%shape)
199 call this%create_timeseries(idt, iparam, iaux, layer, export_pkg)
201 do layer = 1, this%nlay
202 call this%create_timeseries(idt, iparam, iaux, layer, export_pkg)
205 do iaux = 1, export_pkg%naux
206 call this%create_timeseries(idt, iparam, iaux, layer, export_pkg)
209 do iaux = 1, export_pkg%naux
210 do layer = 1, this%nlay
211 call this%create_timeseries(idt, iparam, iaux, layer, export_pkg)
226 integer(I4B),
intent(in) :: iparam
227 integer(I4B),
intent(in) :: iaux
228 integer(I4B),
intent(in) :: layer
230 character(len=LINELENGTH) :: varname, longname, nc_tag
231 integer(I4B) :: varid
234 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
238 varname = export_varname(export_pkg%mf6_input%subcomponent_name, &
239 idt%tagname, export_pkg%mf6_input%mempath, &
240 layer=layer, iaux=iaux)
241 longname = export_longname(idt%longname, &
242 export_pkg%mf6_input%subcomponent_name, &
243 idt%tagname, export_pkg%mf6_input%mempath, &
244 layer=layer, iaux=iaux)
247 select case (idt%datatype)
248 case (
'DOUBLE1D',
'DOUBLE2D')
249 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
250 (/this%dim_ids%nmesh_face, &
251 this%dim_ids%time/), &
254 call nf_verify(nf90_put_att(this%ncid, varid, &
258 call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
259 (/this%dim_ids%nmesh_face, &
260 this%dim_ids%time/), &
263 call nf_verify(nf90_put_att(this%ncid, varid, &
264 '_FillValue', (/nf90_fill_int/)), &
269 if (this%chunking_active)
then
270 call nf_verify(nf90_def_var_chunking(this%ncid, &
274 this%chunk_time/)), &
280 this%shuffle, this%nc_fname)
283 call nf_verify(nf90_put_att(this%ncid, varid, &
284 'units', this%lenunits), this%nc_fname)
285 call nf_verify(nf90_put_att(this%ncid, varid, &
286 'long_name', longname), this%nc_fname)
287 call nf_verify(nf90_put_att(this%ncid, varid, &
288 'mesh', this%mesh_name), this%nc_fname)
289 call nf_verify(nf90_put_att(this%ncid, varid, &
290 'location',
'face'), this%nc_fname)
294 this%gridmap_name, this%nc_fname)
295 call ncvar_mf6attr(this%ncid, varid, layer, iaux, nc_tag, this%nc_fname)
298 if (idt%tagname ==
'AUX')
then
300 export_pkg%varids_aux(iaux, layer) = varid
302 export_pkg%varids_aux(iaux, 1) = varid
306 export_pkg%varids_param(iparam, layer) = varid
308 export_pkg%varids_param(iparam, 1) = varid
318 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'title', &
319 this%annotation%title), this%nc_fname)
321 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'source', &
322 this%annotation%source), this%nc_fname)
324 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_grid', &
325 this%annotation%grid), this%nc_fname)
327 if (this%annotation%mesh /=
'')
then
328 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'mesh', &
329 this%annotation%mesh), this%nc_fname)
333 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_model', &
334 this%annotation%model), this%nc_fname)
336 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'history', &
337 this%annotation%history), this%nc_fname)
339 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'Conventions', &
340 this%annotation%conventions), &
349 character(len=*),
intent(in) :: pkgtype
350 character(len=*),
intent(in) :: pkgname
351 character(len=*),
intent(in) :: mempath
353 intent(in) :: param_dfns
355 integer(I4B) :: iparam, isize
357 do iparam = 1,
size(param_dfns)
359 idt => param_dfns(iparam)
361 if (idt%blockname ==
'GRIDDATA')
then
363 call get_isize(idt%mf6varname, mempath, isize)
365 call this%export_input_array(pkgtype, pkgname, mempath, idt)
381 character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
382 character(len=LENMEMPATH) :: input_mempath
384 pointer :: pkgtypes => null()
386 pointer :: pkgnames => null()
388 pointer :: mempaths => null()
390 character(len=LENMEMPATH) :: mempath
392 integer(I4B),
pointer :: export_arrays
393 logical(LGP) :: found
398 call mem_setptr(pkgtypes,
'PKGTYPES', input_mempath)
399 call mem_setptr(pkgnames,
'PKGNAMES', input_mempath)
400 call mem_setptr(mempaths,
'MEMPATHS', input_mempath)
402 allocate (export_arrays)
404 do n = 1,
size(mempaths)
409 mempath = mempaths(n)
414 if (mempath /=
'')
then
416 call mem_set_value(export_arrays,
'EXPORT_NC', mempath, found)
417 if (export_arrays > 0)
then
419 param_dfns => param_definitions(this%modeltype, pkgtype)
420 call this%export_input_arrays(ptype, pname, mempath, param_dfns)
426 deallocate (export_arrays)
433 character(len=LINELENGTH) :: varname, longname
443 write (varname,
'(a,i0)') trim(this%xname)//
'_l', k
444 write (longname,
'(a,i0,a)') trim(this%annotation%longname)// &
448 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
449 (/this%dim_ids%nmesh_face, &
450 this%dim_ids%time/), &
451 this%var_ids%dependent(k)), &
455 if (this%chunking_active)
then
456 call nf_verify(nf90_def_var_chunking(this%ncid, &
457 this%var_ids%dependent(k), &
460 this%chunk_time/)), &
465 call ncvar_deflate(this%ncid, this%var_ids%dependent(k), this%deflate, &
466 this%shuffle, this%nc_fname)
469 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
470 'units', this%lenunits), this%nc_fname)
471 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
472 'standard_name', this%annotation%stdname), &
474 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
475 'long_name', longname), this%nc_fname)
476 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
479 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
480 'mesh', this%mesh_name), this%nc_fname)
481 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
482 'location',
'face'), this%nc_fname)
486 this%gridmap_name, this%nc_fname)
494 integer(I4B) :: var_id
497 if (this%wkt /=
'')
then
499 call nf_verify(nf90_redef(this%ncid), this%nc_fname)
500 call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
501 var_id), this%nc_fname)
506 call nf_verify(nf90_put_att(this%ncid, var_id,
'wkt', this%wkt), &
508 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
509 call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
520 call nf_verify(nf90_def_var(this%ncid, this%mesh_name, nf90_int, &
521 this%var_ids%mesh), this%nc_fname)
524 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'cf_role', &
525 'mesh_topology'), this%nc_fname)
526 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'long_name', &
527 '2D mesh topology'), this%nc_fname)
528 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
529 'topology_dimension', 2), this%nc_fname)
530 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh,
'face_dimension', &
531 'nmesh_face'), this%nc_fname)
532 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
533 'node_coordinates',
'mesh_node_x mesh_node_y'), &
535 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
536 'face_coordinates',
'mesh_face_x mesh_face_y'), &
538 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
539 'face_node_connectivity',
'mesh_face_nodes'), &
543 call nf_verify(nf90_def_var(this%ncid,
'mesh_node_x', nf90_double, &
544 (/this%dim_ids%nmesh_node/), &
545 this%var_ids%mesh_node_x), this%nc_fname)
548 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
549 'units', this%lenunits), this%nc_fname)
550 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
551 'standard_name',
'projection_x_coordinate'), &
553 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
554 'long_name',
'Easting'), this%nc_fname)
556 if (this%wkt /=
'')
then
558 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
559 'grid_mapping', this%gridmap_name), &
564 call nf_verify(nf90_def_var(this%ncid,
'mesh_node_y', nf90_double, &
565 (/this%dim_ids%nmesh_node/), &
566 this%var_ids%mesh_node_y), this%nc_fname)
569 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
570 'units', this%lenunits), this%nc_fname)
571 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
572 'standard_name',
'projection_y_coordinate'), &
574 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
575 'long_name',
'Northing'), this%nc_fname)
577 if (this%wkt /=
'')
then
579 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
580 'grid_mapping', this%gridmap_name), &
585 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_x', nf90_double, &
586 (/this%dim_ids%nmesh_face/), &
587 this%var_ids%mesh_face_x), this%nc_fname)
590 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
591 'units', this%lenunits), this%nc_fname)
592 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
593 'standard_name',
'projection_x_coordinate'), &
595 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
596 'long_name',
'Easting'), this%nc_fname)
597 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x,
'bounds', &
598 'mesh_face_xbnds'), this%nc_fname)
599 if (this%wkt /=
'')
then
601 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
602 'grid_mapping', this%gridmap_name), &
607 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_xbnds', nf90_double, &
608 (/this%dim_ids%max_nmesh_face_nodes, &
609 this%dim_ids%nmesh_face/), &
610 this%var_ids%mesh_face_xbnds), &
614 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_y', nf90_double, &
615 (/this%dim_ids%nmesh_face/), &
616 this%var_ids%mesh_face_y), this%nc_fname)
619 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
620 'units', this%lenunits), this%nc_fname)
621 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
622 'standard_name',
'projection_y_coordinate'), &
624 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
625 'long_name',
'Northing'), this%nc_fname)
626 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y,
'bounds', &
627 'mesh_face_ybnds'), this%nc_fname)
629 if (this%wkt /=
'')
then
631 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
632 'grid_mapping', this%gridmap_name), &
637 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_ybnds', nf90_double, &
638 (/this%dim_ids%max_nmesh_face_nodes, &
639 this%dim_ids%nmesh_face/), &
640 this%var_ids%mesh_face_ybnds), &
644 call nf_verify(nf90_def_var(this%ncid,
'mesh_face_nodes', nf90_int, &
645 (/this%dim_ids%max_nmesh_face_nodes, &
646 this%dim_ids%nmesh_face/), &
647 this%var_ids%mesh_face_nodes), &
651 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
652 'cf_role',
'face_node_connectivity'), &
654 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
656 'Vertices bounding cell (counterclockwise)'), &
658 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
659 '_FillValue', (/nf90_fill_int/)), &
661 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
662 'start_index', 1), this%nc_fname)
668 integer(I4B),
intent(in) :: ncid
669 integer(I4B),
intent(in) :: varid
670 integer(I4B),
intent(in) :: chunk_face
671 character(len=*),
intent(in) :: nc_fname
672 if (chunk_face > 0)
then
673 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
674 (/chunk_face/)), nc_fname)
681 integer(I4B),
intent(in) :: ncid
682 integer(I4B),
intent(in) :: varid
683 integer(I4B),
intent(in) :: deflate
684 integer(I4B),
intent(in) :: shuffle
685 character(len=*),
intent(in) :: nc_fname
686 if (deflate >= 0)
then
687 call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
688 deflate=1, deflate_level=deflate), &
696 integer(I4B),
intent(in) :: ncid
697 integer(I4B),
intent(in) :: varid
698 character(len=*),
intent(in) :: gridmap_name
699 character(len=*),
intent(in) :: nc_fname
700 if (gridmap_name /=
'')
then
701 call nf_verify(nf90_put_att(ncid, varid,
'coordinates', &
702 'mesh_face_x mesh_face_y'), nc_fname)
703 call nf_verify(nf90_put_att(ncid, varid,
'grid_mapping', &
704 gridmap_name), nc_fname)
711 integer(I4B),
intent(in) :: ncid
712 integer(I4B),
intent(in) :: varid
713 integer(I4B),
intent(in) :: layer
714 integer(I4B),
intent(in) :: iaux
715 character(len=*),
intent(in) :: nc_tag
716 character(len=*),
intent(in) :: nc_fname
717 if (nc_tag /=
'')
then
718 call nf_verify(nf90_put_att(ncid, varid,
'modflow_input', &
721 call nf_verify(nf90_put_att(ncid, varid,
'layer', &
725 call nf_verify(nf90_put_att(ncid, varid,
'modflow_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
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename)
Return parameter definition.
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, public ncvar_mf6attr(ncid, varid, layer, iaux, nc_tag, nc_fname)
put variable internal attributes
subroutine define_gridmap(this)
create the file grid mapping container variable
subroutine create_timeseries(this, idt, iparam, iaux, layer, export_pkg)
create timeseries export variable
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 df_export(this)
define timeseries input variables
subroutine export_df(this, export_pkg)
define export package
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 create_mesh(this)
create the file mesh container variable
This module contains the NCModelExportModule.
character(len=linelength) function, public export_varname(pkgname, tagname, mempath, layer, iaux)
build netcdf variable name
character(len=linelength) function, public export_longname(longname, pkgname, tagname, mempath, layer, iaux)
build netcdf variable longname
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