MODFLOW 6 version 6.9.0.dev0
USGS Modular Hydrologic Model
Loading...
Searching...
No Matches
meshmodelmodule Module Reference

This module contains the MeshModelModule. More...

Data Types

type  meshncdimidtype
 type for storing model export dimension ids More...
type  meshncvaridtype
 type for storing model export variable ids More...
type  meshmodeltype
 base ugrid netcdf export type More...
interface  nc_array_export_if
 abstract interfaces for derived ugrid netcd export types More...
type  mesh2dmodeltype

Functions/Subroutines

subroutine mesh_init (this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, lenuni, iout)
 initialize
subroutine mesh_destroy (this)
 initialize
subroutine df_export (this)
 define timeseries input variables
subroutine export_df (this, export_pkg)
 define export package
subroutine create_timeseries (this, idt, iparam, iaux, layer, export_pkg)
 create timeseries export variable
subroutine add_global_att (this)
 create file (group) attributes
subroutine export_input_arrays (this, pkgtype, pkgname, mempath, param_dfns)
 write package gridded input data
subroutine add_pkg_data (this)
 determine packages to write gridded input
subroutine define_dependent (this)
 create the model layer dependent variables
subroutine define_gridmap (this)
 create the file grid mapping container variable
subroutine create_mesh (this)
 create the file mesh container variable
subroutine, public ncvar_chunk (ncid, varid, chunk_face, nc_fname)
 define variable chunking
subroutine, public ncvar_deflate (ncid, varid, deflate, shuffle, nc_fname)
 define variable compression
subroutine, public ncvar_gridmap (ncid, varid, gridmap_name, layer, nc_fname)
 put variable gridmap attributes
subroutine, public ncvar_mf6attr (ncid, varid, layer, iaux, nc_tag, nc_fname)
 put variable internal attributes
subroutine, public ncvar_layer (ncid, varid, layer, nc_fname)
 put the layer attribute (only when layer > 0)

Detailed Description

This module defines a base class for UGRID based (mesh) model netcdf exports. It is dependent on external netcdf libraries.

Function/Subroutine Documentation

◆ add_global_att()

subroutine meshmodelmodule::add_global_att ( class(meshmodeltype), intent(inout) this)
private

Definition at line 335 of file MeshNCModel.f90.

336 class(MeshModelType), intent(inout) :: this
337 ! file scoped title
338 call nf_verify(nf90_put_att(this%ncid, nf90_global, 'title', &
339 this%annotation%title), this%nc_fname)
340 ! source (MODFLOW 6)
341 call nf_verify(nf90_put_att(this%ncid, nf90_global, 'source', &
342 this%annotation%source), this%nc_fname)
343 ! grid type (MODFLOW 6)
344 call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow_grid', &
345 this%annotation%grid), this%nc_fname)
346 ! mesh type (MODFLOW 6)
347 if (this%annotation%mesh /= '') then
348 call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow_mesh', &
349 this%annotation%mesh), this%nc_fname)
350
351 end if
352 ! MODFLOW 6 model type
353 call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow_model', &
354 this%annotation%model), this%nc_fname)
355 ! generation datetime
356 call nf_verify(nf90_put_att(this%ncid, nf90_global, 'history', &
357 this%annotation%history), this%nc_fname)
358 ! supported conventions
359 call nf_verify(nf90_put_att(this%ncid, nf90_global, 'Conventions', &
360 this%annotation%conventions), &
361 this%nc_fname)
Here is the call graph for this function:

◆ add_pkg_data()

subroutine meshmodelmodule::add_pkg_data ( class(meshmodeltype), intent(inout) this)
private

Definition at line 393 of file MeshNCModel.f90.

400 class(MeshModelType), intent(inout) :: this
401 character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
402 character(len=LENMEMPATH) :: input_mempath
403 type(CharacterStringType), dimension(:), contiguous, &
404 pointer :: pkgtypes => null()
405 type(CharacterStringType), dimension(:), contiguous, &
406 pointer :: pkgnames => null()
407 type(CharacterStringType), dimension(:), contiguous, &
408 pointer :: mempaths => null()
409 type(InputParamDefinitionType), dimension(:), pointer :: param_dfns
410 character(len=LENMEMPATH) :: mempath
411 integer(I4B) :: n
412 integer(I4B), pointer :: export_arrays
413 logical(LGP) :: found
414
415 input_mempath = create_mem_path(component=this%modelname, context=idm_context)
416
417 ! set pointers to model path package info
418 call mem_setptr(pkgtypes, 'PKGTYPES', input_mempath)
419 call mem_setptr(pkgnames, 'PKGNAMES', input_mempath)
420 call mem_setptr(mempaths, 'MEMPATHS', input_mempath)
421
422 allocate (export_arrays)
423
424 do n = 1, size(mempaths)
425 ! initialize export_arrays
426 export_arrays = 0
427
428 ! set package attributes
429 mempath = mempaths(n)
430 pname = pkgnames(n)
431 ptype = pkgtypes(n)
432
433 ! export input arrays
434 if (mempath /= '') then
435 ! update export
436 call mem_set_value(export_arrays, 'EXPORT_NC', mempath, found, &
437 release=.false.)
438 if (export_arrays > 0) then
439 pkgtype = idm_subcomponent_type(this%modeltype, ptype)
440 param_dfns => param_definitions(this%modeltype, pkgtype)
441 call this%export_input_arrays(ptype, pname, mempath, param_dfns)
442 end if
443 end if
444 end do
445
446 ! cleanup
447 deallocate (export_arrays)
type(inputparamdefinitiontype) function, dimension(:), pointer, public param_definitions(component, subcomponent)
logical function, public idm_multi_package(component, subcomponent)
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains simulation variables.
character(len=linelength) idm_context
This module contains the SourceCommonModule.
character(len=lencomponentname) function, public idm_subcomponent_type(component, subcomponent)
component from package or model type
Here is the call graph for this function:

◆ create_mesh()

subroutine meshmodelmodule::create_mesh ( class(mesh2dmodeltype), intent(inout) this)
private

Definition at line 561 of file MeshNCModel.f90.

562 class(Mesh2dModelType), intent(inout) :: this
563
564 ! create mesh container variable
565 call nf_verify(nf90_def_var(this%ncid, this%mesh_name, nf90_int, &
566 this%var_ids%mesh), this%nc_fname)
567
568 ! assign container variable attributes
569 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, 'cf_role', &
570 'mesh_topology'), this%nc_fname)
571 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, 'long_name', &
572 '2D mesh topology'), this%nc_fname)
573 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
574 'topology_dimension', 2), this%nc_fname)
575 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, 'face_dimension', &
576 'nmesh_face'), this%nc_fname)
577 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
578 'node_coordinates', 'mesh_node_x mesh_node_y'), &
579 this%nc_fname)
580 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
581 'face_coordinates', 'mesh_face_x mesh_face_y'), &
582 this%nc_fname)
583 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh, &
584 'face_node_connectivity', 'mesh_face_nodes'), &
585 this%nc_fname)
586
587 ! create mesh x node (mesh vertex) variable
588 call nf_verify(nf90_def_var(this%ncid, 'mesh_node_x', nf90_double, &
589 (/this%dim_ids%nmesh_node/), &
590 this%var_ids%mesh_node_x), this%nc_fname)
591
592 ! assign mesh x node variable attributes
593 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
594 'units', this%lenunits), this%nc_fname)
595 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
596 'standard_name', 'projection_x_coordinate'), &
597 this%nc_fname)
598 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
599 'long_name', 'Easting'), this%nc_fname)
600
601 if (this%gridmap_name /= '') then
602 ! associate with projection
603 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_x, &
604 'grid_mapping', this%gridmap_name), &
605 this%nc_fname)
606 end if
607
608 ! create mesh y node (mesh vertex) variable
609 call nf_verify(nf90_def_var(this%ncid, 'mesh_node_y', nf90_double, &
610 (/this%dim_ids%nmesh_node/), &
611 this%var_ids%mesh_node_y), this%nc_fname)
612
613 ! assign mesh y variable attributes
614 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
615 'units', this%lenunits), this%nc_fname)
616 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
617 'standard_name', 'projection_y_coordinate'), &
618 this%nc_fname)
619 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
620 'long_name', 'Northing'), this%nc_fname)
621
622 if (this%gridmap_name /= '') then
623 ! associate with projection
624 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_node_y, &
625 'grid_mapping', this%gridmap_name), &
626 this%nc_fname)
627 end if
628
629 ! create mesh x face (cell vertex) variable
630 call nf_verify(nf90_def_var(this%ncid, 'mesh_face_x', nf90_double, &
631 (/this%dim_ids%nmesh_face/), &
632 this%var_ids%mesh_face_x), this%nc_fname)
633
634 ! assign mesh x face variable attributes
635 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
636 'units', this%lenunits), this%nc_fname)
637 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
638 'standard_name', 'projection_x_coordinate'), &
639 this%nc_fname)
640 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
641 'long_name', 'Easting'), this%nc_fname)
642 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, 'bounds', &
643 'mesh_face_xbnds'), this%nc_fname)
644 if (this%gridmap_name /= '') then
645 ! associate with projection
646 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_x, &
647 'grid_mapping', this%gridmap_name), &
648 this%nc_fname)
649 end if
650
651 ! create mesh x cell bounds variable
652 call nf_verify(nf90_def_var(this%ncid, 'mesh_face_xbnds', nf90_double, &
653 (/this%dim_ids%max_nmesh_face_nodes, &
654 this%dim_ids%nmesh_face/), &
655 this%var_ids%mesh_face_xbnds), &
656 this%nc_fname)
657
658 ! create mesh y face (cell vertex) variable
659 call nf_verify(nf90_def_var(this%ncid, 'mesh_face_y', nf90_double, &
660 (/this%dim_ids%nmesh_face/), &
661 this%var_ids%mesh_face_y), this%nc_fname)
662
663 ! assign mesh y face variable attributes
664 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
665 'units', this%lenunits), this%nc_fname)
666 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
667 'standard_name', 'projection_y_coordinate'), &
668 this%nc_fname)
669 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
670 'long_name', 'Northing'), this%nc_fname)
671 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, 'bounds', &
672 'mesh_face_ybnds'), this%nc_fname)
673
674 if (this%gridmap_name /= '') then
675 ! associate with projection
676 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_y, &
677 'grid_mapping', this%gridmap_name), &
678 this%nc_fname)
679 end if
680
681 ! create mesh y cell bounds variable
682 call nf_verify(nf90_def_var(this%ncid, 'mesh_face_ybnds', nf90_double, &
683 (/this%dim_ids%max_nmesh_face_nodes, &
684 this%dim_ids%nmesh_face/), &
685 this%var_ids%mesh_face_ybnds), &
686 this%nc_fname)
687
688 ! create mesh face nodes variable
689 call nf_verify(nf90_def_var(this%ncid, 'mesh_face_nodes', nf90_int, &
690 (/this%dim_ids%max_nmesh_face_nodes, &
691 this%dim_ids%nmesh_face/), &
692 this%var_ids%mesh_face_nodes), &
693 this%nc_fname)
694
695 ! assign variable attributes
696 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
697 'cf_role', 'face_node_connectivity'), &
698 this%nc_fname)
699 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
700 'long_name', &
701 'Vertices bounding cell (counterclockwise)'), &
702 this%nc_fname)
703 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
704 '_FillValue', (/nf90_fill_int/)), &
705 this%nc_fname)
706 call nf_verify(nf90_put_att(this%ncid, this%var_ids%mesh_face_nodes, &
707 'start_index', 1), this%nc_fname)
Here is the call graph for this function:

◆ create_timeseries()

subroutine meshmodelmodule::create_timeseries ( class(meshmodeltype), intent(inout) this,
type(inputparamdefinitiontype), intent(in), pointer idt,
integer(i4b), intent(in) iparam,
integer(i4b), intent(in) iaux,
integer(i4b), intent(in) layer,
class(exportpackagetype), intent(in), pointer export_pkg )
private

Definition at line 242 of file MeshNCModel.f90.

243 use constantsmodule, only: dnodata
245 class(MeshModelType), intent(inout) :: this
246 type(InputParamDefinitionType), pointer, intent(in) :: idt
247 integer(I4B), intent(in) :: iparam
248 integer(I4B), intent(in) :: iaux
249 integer(I4B), intent(in) :: layer
250 class(ExportPackageType), pointer, intent(in) :: export_pkg
251 character(len=LINELENGTH) :: varname, longname, nc_tag
252 integer(I4B) :: varid
253
254 ! set variable input tag
255 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
256 idt)
257
258 ! set names
259 varname = export_varname(export_pkg%mf6_input%subcomponent_name, &
260 idt%tagname, export_pkg%mf6_input%mempath, &
261 layer=layer, iaux=iaux)
262 longname = export_longname(idt%longname, &
263 export_pkg%mf6_input%subcomponent_name, &
264 idt%tagname, export_pkg%mf6_input%mempath, &
265 layer=layer, iaux=iaux, &
266 component_type=idt%component_type, &
267 subcomponent_type=idt%subcomponent_type)
268
269 ! create the netcdf dependent layer variable
270 select case (idt%datatype)
271 case ('DOUBLE1D', 'DOUBLE2D')
272 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
273 (/this%dim_ids%nmesh_face, &
274 this%dim_ids%time/), &
275 varid), &
276 this%nc_fname)
277 call nf_verify(nf90_put_att(this%ncid, varid, &
278 '_FillValue', (/dnodata/)), &
279 this%nc_fname)
280 ! input in effect over the stress period (CF-1.13 7.3)
281 call nf_verify(nf90_put_att(this%ncid, varid, 'cell_methods', &
282 'time: mean'), this%nc_fname)
283 case ('INTEGER1D')
284 call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
285 (/this%dim_ids%nmesh_face, &
286 this%dim_ids%time/), &
287 varid), &
288 this%nc_fname)
289 call nf_verify(nf90_put_att(this%ncid, varid, &
290 '_FillValue', (/nf90_fill_int/)), &
291 this%nc_fname)
292 end select
293
294 ! apply chunking parameters
295 if (this%chunking_active) then
296 call nf_verify(nf90_def_var_chunking(this%ncid, &
297 varid, &
298 nf90_chunked, &
299 (/this%chunk_face, &
300 this%chunk_time/)), &
301 this%nc_fname)
302 end if
303
304 ! deflate and shuffle
305 call ncvar_deflate(this%ncid, varid, this%deflate, &
306 this%shuffle, this%nc_fname)
307
308 ! assign variable attributes
309 call nf_verify(nf90_put_att(this%ncid, varid, &
310 'long_name', longname), this%nc_fname)
311
312 ! add grid mapping and mf6 attr (mesh, location, coordinates, grid_mapping)
313 call ncvar_gridmap(this%ncid, varid, &
314 this%gridmap_name, layer, this%nc_fname)
315 call ncvar_mf6attr(this%ncid, varid, layer, iaux, nc_tag, this%nc_fname)
316
317 ! store variable id
318 if (idt%tagname == 'AUX') then
319 if (layer > 0) then
320 export_pkg%varids_aux(iaux, layer) = varid
321 else
322 export_pkg%varids_aux(iaux, 1) = varid
323 end if
324 else
325 if (layer > 0) then
326 export_pkg%varids_param(iparam, layer) = varid
327 else
328 export_pkg%varids_param(iparam, 1) = varid
329 end if
330 end if
This module contains simulation constants.
Definition Constants.f90:9
real(dp), parameter dnodata
real no data constant
Definition Constants.f90:95
This module contains the NCModelExportModule.
Definition NCModel.f90:8
character(len=linelength) function, public export_varname(pkgname, tagname, mempath, layer, iaux)
build netcdf variable name
Definition NCModel.f90:562
character(len=linelength) function, public export_longname(longname, pkgname, tagname, mempath, layer, iaux, component_type, subcomponent_type)
build netcdf variable longname
Definition NCModel.f90:603
Here is the call graph for this function:

◆ define_dependent()

subroutine meshmodelmodule::define_dependent ( class(meshmodeltype), intent(inout) this)
private

Definition at line 452 of file MeshNCModel.f90.

453 class(MeshModelType), intent(inout) :: this
454 character(len=LINELENGTH) :: varname, longname
455 integer(I4B) :: k
456
457 ! create a dependent variable for each layer
458 do k = 1, this%nlay
459 ! initialize names
460 varname = ''
461 longname = ''
462
463 ! set layer variable and longnames
464 write (varname, '(a,i0)') trim(this%xname)//'_l', k
465 write (longname, '(a,i0,a)') trim(this%annotation%longname)// &
466 ' (layer ', k, ')'
467
468 ! create the netcdf dependent layer variable
469 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
470 (/this%dim_ids%nmesh_face, &
471 this%dim_ids%time/), &
472 this%var_ids%dependent(k)), &
473 this%nc_fname)
474
475 ! apply chunking parameters
476 if (this%chunking_active) then
477 call nf_verify(nf90_def_var_chunking(this%ncid, &
478 this%var_ids%dependent(k), &
479 nf90_chunked, &
480 (/this%chunk_face, &
481 this%chunk_time/)), &
482 this%nc_fname)
483 end if
484
485 ! deflate and shuffle
486 call ncvar_deflate(this%ncid, this%var_ids%dependent(k), this%deflate, &
487 this%shuffle, this%nc_fname)
488
489 ! assign variable attributes; head is a length, other dependent
490 ! variables have no units known from the input
491 if (this%modeltype == 'GWF') then
492 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
493 'units', this%lenunits), this%nc_fname)
494 end if
495 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
496 'long_name', longname), this%nc_fname)
497 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
498 '_FillValue', (/dhnoflo/)), &
499 this%nc_fname)
500 ! cell_methods (CF-1.13 7.3): dependent variable values are the
501 ! instantaneous simulated state at each output time, not a time
502 ! mean/accumulation over the interval -- an intensive quantity whose
503 ! default method is already "point" per CF's own Appendix E, stated
504 ! explicitly here per CF's recommendation to do so for every
505 ! spatio-temporal dimension.
506 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent(k), &
507 'cell_methods', 'time: point'), &
508 this%nc_fname)
509
510 ! add grid mapping (mesh, location, coordinates, grid_mapping)
511 call ncvar_gridmap(this%ncid, this%var_ids%dependent(k), &
512 this%gridmap_name, k, this%nc_fname)
513
514 ! add layer attribute
515 call ncvar_layer(this%ncid, this%var_ids%dependent(k), k, &
516 this%nc_fname)
517 end do
Here is the call graph for this function:

◆ define_gridmap()

subroutine meshmodelmodule::define_gridmap ( class(meshmodeltype), intent(inout) this)
private

Definition at line 522 of file MeshNCModel.f90.

523 class(MeshModelType), intent(inout) :: this
524 integer(I4B) :: var_id
525 character(len=LINELENGTH) :: gmname
526 character(len=LENBIGLINE) :: effective_crs_wkt
527
528 ! was projection info provided
529 if (this%wkt /= '' .or. this%crs_wkt /= '') then
530 ! create projection variable
531 call nf_verify(nf90_redef(this%ncid), this%nc_fname)
532 call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
533 var_id), this%nc_fname)
534 ! wkt (WKT1, OGC 01-009) -- for legacy/QGIS compatibility
535 if (this%wkt /= '') then
536 call nf_verify(nf90_put_att(this%ncid, var_id, 'wkt', this%wkt), &
537 this%nc_fname)
538 end if
539 ! crs_wkt (WKT2, ISO 19162:2019) -- required by CF-1.13
540 if (this%crs_wkt /= '') then
541 effective_crs_wkt = this%crs_wkt
542 else
543 effective_crs_wkt = this%wkt
544 end if
545 call nf_verify(nf90_put_att(this%ncid, var_id, 'crs_wkt', &
546 trim(effective_crs_wkt)), this%nc_fname)
547 ! grid_mapping_name derived from WKT projection keyword
548 gmname = wkt_to_cf_gridmapping(trim(effective_crs_wkt))
549 if (gmname /= '') then
550 call nf_verify(nf90_put_att(this%ncid, var_id, 'grid_mapping_name', &
551 trim(gmname)), this%nc_fname)
552 end if
553 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
554 call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
555 this%nc_fname)
556 end if
Here is the call graph for this function:

◆ df_export()

subroutine meshmodelmodule::df_export ( class(meshmodeltype), intent(inout) this)
private

Definition at line 185 of file MeshNCModel.f90.

187 class(MeshModelType), intent(inout) :: this
188 class(ExportPackageType), pointer :: export_pkg
189 integer(I4B) :: idx
190 do idx = 1, this%pkglist%Count()
191 export_pkg => this%get(idx)
192 call this%export_df(export_pkg)
193 end do

◆ export_df()

subroutine meshmodelmodule::export_df ( class(meshmodeltype), intent(inout) this,
class(exportpackagetype), intent(in), pointer export_pkg )
private

Definition at line 198 of file MeshNCModel.f90.

201 class(MeshModelType), intent(inout) :: this
202 class(ExportPackageType), pointer, intent(in) :: export_pkg
203 type(InputParamDefinitionType), pointer :: idt
204 integer(I4B) :: iparam, iaux, layer
205
206 ! export defined period input
207 do iparam = 1, export_pkg%nparam
208 ! initialize
209 iaux = 0
210 layer = 0
211 ! set input definition
212 idt => &
213 get_param_definition_type(export_pkg%mf6_input%param_dfns, &
214 export_pkg%mf6_input%component_type, &
215 export_pkg%mf6_input%subcomponent_type, &
216 'PERIOD', export_pkg%param_names(iparam), '')
217
218 select case (idt%shape)
219 case ('NCPL')
220 call this%create_timeseries(idt, iparam, iaux, layer, export_pkg)
221 case ('NODES')
222 do layer = 1, this%nlay
223 call this%create_timeseries(idt, iparam, iaux, layer, export_pkg)
224 end do
225 case ('NAUX NCPL')
226 do iaux = 1, export_pkg%naux
227 call this%create_timeseries(idt, iparam, iaux, layer, export_pkg)
228 end do
229 case ('NAUX NODES')
230 do iaux = 1, export_pkg%naux
231 do layer = 1, this%nlay
232 call this%create_timeseries(idt, iparam, iaux, layer, export_pkg)
233 end do
234 end do
235 case default
236 end select
237 end do
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
Here is the call graph for this function:

◆ export_input_arrays()

subroutine meshmodelmodule::export_input_arrays ( class(meshmodeltype), intent(inout) this,
character(len=*), intent(in) pkgtype,
character(len=*), intent(in) pkgname,
character(len=*), intent(in) mempath,
type(inputparamdefinitiontype), dimension(:), intent(in), pointer param_dfns )
private

Definition at line 366 of file MeshNCModel.f90.

368 class(MeshModelType), intent(inout) :: this
369 character(len=*), intent(in) :: pkgtype
370 character(len=*), intent(in) :: pkgname
371 character(len=*), intent(in) :: mempath
372 type(InputParamDefinitionType), dimension(:), pointer, &
373 intent(in) :: param_dfns
374 type(InputParamDefinitionType), pointer :: idt
375 integer(I4B) :: iparam, isize
376 ! export griddata block parameters
377 do iparam = 1, size(param_dfns)
378 ! assign param definition pointer
379 idt => param_dfns(iparam)
380 ! for now only griddata is exported
381 if (idt%blockname == 'GRIDDATA') then
382 ! veriy variable is allocated
383 call get_isize(idt%mf6varname, mempath, isize)
384 if (isize > 0) then
385 call this%export_input_array(pkgtype, pkgname, mempath, idt)
386 end if
387 end if
388 end do
subroutine, public get_isize(name, mem_path, isize)
Get the number of elements for this variable.
Here is the call graph for this function:

◆ mesh_destroy()

subroutine meshmodelmodule::mesh_destroy ( class(meshmodeltype), intent(inout) this)
private

Definition at line 175 of file MeshNCModel.f90.

177 class(MeshModelType), intent(inout) :: this
178 call nf_verify(nf90_close(this%ncid), this%nc_fname)
179 deallocate (this%chunk_face)
180 nullify (this%chunk_face)
Here is the call graph for this function:

◆ mesh_init()

subroutine meshmodelmodule::mesh_init ( class(meshmodeltype), intent(inout) this,
character(len=*), intent(in) modelname,
character(len=*), intent(in) modeltype,
character(len=*), intent(in) modelfname,
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 )

Definition at line 107 of file MeshNCModel.f90.

110 class(MeshModelType), intent(inout) :: this
111 character(len=*), intent(in) :: modelname
112 character(len=*), intent(in) :: modeltype
113 character(len=*), intent(in) :: modelfname
114 character(len=*), intent(in) :: nc_fname
115 integer(I4B), intent(in) :: disenum
116 integer(I4B), intent(in) :: nctype
117 integer(I4B), intent(in) :: lenuni
118 integer(I4B), intent(in) :: iout
119 logical(LGP) :: found
120 integer(I4B) :: latsz, lonsz
121
122 ! initialize base class
123 call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
124 disenum, nctype, iout)
125
126 if (this%ncf_mempath /= '') then
127 latsz = 0
128 lonsz = 0
129 call get_isize('LATITUDE', this%ncf_mempath, latsz)
130 call get_isize('LONGITUDE', this%ncf_mempath, lonsz)
131 if (latsz > 0 .or. lonsz > 0) then
132 write (warnmsg, '(a)') 'LATITUDE and LONGITUDE griddata are not &
133 &supported for a NETCDF_MESH2D export and will be ignored. &
134 &Applies to file "'//trim(nc_fname)//'".'
135 call store_warning(warnmsg)
136 end if
137 end if
138
139 ! allocate and initialize
140 allocate (this%chunk_face)
141 this%chunk_face = -1
142
143 ! update values from input context
144 if (this%ncf_mempath /= '') then
145 call mem_set_value(this%chunk_face, 'CHUNK_FACE', this%ncf_mempath, found)
146 end if
147
148 if (this%chunk_time > 0 .and. this%chunk_face > 0) then
149 this%chunking_active = .true.
150 else if (this%chunk_time > 0 .or. this%chunk_face > 0) then
151 this%chunk_face = -1
152 this%chunk_time = -1
153 write (warnmsg, '(a)') 'Ignoring user provided NetCDF chunking parameter. &
154 &Define chunk_time and chunk_face input parameters to see an effect in &
155 &file "'//trim(nc_fname)//'".'
156 call store_warning(warnmsg)
157 end if
158
159 if (lenuni == 1) then
160 this%lenunits = 'ft'
161 else if (lenuni == 3) then
162 this%lenunits = 'cm'
163 else
164 this%lenunits = 'm'
165 end if
166
167 ! create the netcdf file
168 call nf_verify(nf90_create(this%nc_fname, &
169 ior(nf90_clobber, nf90_netcdf4), this%ncid), &
170 this%nc_fname)
Here is the call graph for this function:

◆ ncvar_chunk()

subroutine, public meshmodelmodule::ncvar_chunk ( integer(i4b), intent(in) ncid,
integer(i4b), intent(in) varid,
integer(i4b), intent(in) chunk_face,
character(len=*), intent(in) nc_fname )

Definition at line 712 of file MeshNCModel.f90.

713 integer(I4B), intent(in) :: ncid
714 integer(I4B), intent(in) :: varid
715 integer(I4B), intent(in) :: chunk_face
716 character(len=*), intent(in) :: nc_fname
717 if (chunk_face > 0) then
718 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
719 (/chunk_face/)), nc_fname)
720 end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvar_deflate()

subroutine, public meshmodelmodule::ncvar_deflate ( integer(i4b), intent(in) ncid,
integer(i4b), intent(in) varid,
integer(i4b), intent(in) deflate,
integer(i4b), intent(in) shuffle,
character(len=*), intent(in) nc_fname )

Definition at line 725 of file MeshNCModel.f90.

726 integer(I4B), intent(in) :: ncid
727 integer(I4B), intent(in) :: varid
728 integer(I4B), intent(in) :: deflate
729 integer(I4B), intent(in) :: shuffle
730 character(len=*), intent(in) :: nc_fname
731 if (deflate >= 0) then
732 call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
733 deflate=1, deflate_level=deflate), &
734 nc_fname)
735 end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvar_gridmap()

subroutine, public meshmodelmodule::ncvar_gridmap ( integer(i4b), intent(in) ncid,
integer(i4b), intent(in) varid,
character(len=*), intent(in) gridmap_name,
integer(i4b), intent(in) layer,
character(len=*), intent(in) nc_fname )

layer must be the 1-based layer number when varid is a per-layer variable (e.g. npf_k_l3), or 0 when it is not layered (e.g. a flat NCPL-shaped array). z_l{layer} is only referenced from coordinates when layer > 0, since it is the only case where z_l{layer} shares nmesh_face with varid (CF-1.13 5.2 subset rule).

Definition at line 746 of file MeshNCModel.f90.

747 integer(I4B), intent(in) :: ncid
748 integer(I4B), intent(in) :: varid
749 character(len=*), intent(in) :: gridmap_name
750 integer(I4B), intent(in) :: layer
751 character(len=*), intent(in) :: nc_fname
752 character(len=LINELENGTH) :: coords
753 ! UGRID topology attrs are CRS-independent -- always written on face vars
754 call nf_verify(nf90_put_att(ncid, varid, 'mesh', 'mesh'), nc_fname)
755 call nf_verify(nf90_put_att(ncid, varid, 'location', 'face'), nc_fname)
756 if (layer > 0) then
757 write (coords, '(a,i0)') 'mesh_face_x mesh_face_y z_l', layer
758 else
759 coords = 'mesh_face_x mesh_face_y'
760 end if
761 call nf_verify(nf90_put_att(ncid, varid, 'coordinates', trim(coords)), &
762 nc_fname)
763 ! grid_mapping only written when a CRS is configured
764 if (gridmap_name /= '') then
765 call nf_verify(nf90_put_att(ncid, varid, 'grid_mapping', &
766 gridmap_name), nc_fname)
767 end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvar_layer()

subroutine, public meshmodelmodule::ncvar_layer ( integer(i4b), intent(in) ncid,
integer(i4b), intent(in) varid,
integer(i4b), intent(in) layer,
character(len=*), intent(in) nc_fname )

layer identifies which layer a per-layer-split mesh variable belongs to (e.g. head_l3, npf_k_l3) – distinct from the layer dimension coordinate. Not a CF/UGRID attribute; MF6-internal. Applies to every per-layer-split variable.

Definition at line 797 of file MeshNCModel.f90.

798 integer(I4B), intent(in) :: ncid
799 integer(I4B), intent(in) :: varid
800 integer(I4B), intent(in) :: layer
801 character(len=*), intent(in) :: nc_fname
802 if (layer > 0) then
803 call nf_verify(nf90_put_att(ncid, varid, 'layer', layer), nc_fname)
804 end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvar_mf6attr()

subroutine, public meshmodelmodule::ncvar_mf6attr ( integer(i4b), intent(in) ncid,
integer(i4b), intent(in) varid,
integer(i4b), intent(in) layer,
integer(i4b), intent(in) iaux,
character(len=*), intent(in) nc_tag,
character(len=*), intent(in) nc_fname )

Definition at line 772 of file MeshNCModel.f90.

773 integer(I4B), intent(in) :: ncid
774 integer(I4B), intent(in) :: varid
775 integer(I4B), intent(in) :: layer
776 integer(I4B), intent(in) :: iaux
777 character(len=*), intent(in) :: nc_tag
778 character(len=*), intent(in) :: nc_fname
779 if (nc_tag /= '') then
780 call nf_verify(nf90_put_att(ncid, varid, 'modflow_input', &
781 nc_tag), nc_fname)
782 call ncvar_layer(ncid, varid, layer, nc_fname)
783 if (iaux > 0) then
784 call nf_verify(nf90_put_att(ncid, varid, 'modflow_iaux', &
785 iaux), nc_fname)
786 end if
787 end if
Here is the call graph for this function:
Here is the caller graph for this function: