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

This module contains the MeshDisModelModule. More...

Data Types

type  mesh2ddisexporttype

Functions/Subroutines

subroutine dis_export_init (this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
 netcdf export dis init
subroutine dis_export_destroy (this)
 netcdf export dis destroy
subroutine df (this)
 netcdf export define
subroutine step (this)
 netcdf export step
subroutine package_step (this, export_pkg)
 netcdf export package dynamic input
subroutine export_input_array (this, pkgtype, pkgname, mempath, idt)
 netcdf export an input array
subroutine define_dim (this)
 netcdf export define dimensions
subroutine add_mesh_data (this)
 netcdf export add mesh information
subroutine nc_export_int1d (p_mem, ncid, dim_ids, x_dim, y_dim, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, deflate, shuffle, chunk_face, iper, nc_fname)
 netcdf export 1D integer
subroutine nc_export_int2d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, deflate, shuffle, chunk_face, nc_fname)
 netcdf export 2D integer
subroutine nc_export_int3d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, deflate, shuffle, chunk_face, nc_fname)
 netcdf export 3D integer
subroutine nc_export_dbl1d (p_mem, ncid, dim_ids, x_dim, y_dim, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, deflate, shuffle, chunk_face, iper, iaux, nc_fname)
 netcdf export 1D double
subroutine nc_export_dbl2d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, deflate, shuffle, chunk_face, nc_fname)
 netcdf export 2D double
subroutine nc_export_dbl3d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, deflate, shuffle, chunk_face, nc_fname)
 netcdf export 3D double

Detailed Description

This module defines UGRID layered mesh compliant netcdf export type for DIS models. It is dependent on netcdf libraries.

Function/Subroutine Documentation

◆ add_mesh_data()

subroutine meshdismodelmodule::add_mesh_data ( class(mesh2ddisexporttype), intent(inout) this)
private

Definition at line 498 of file DisNCMesh.f90.

500 class(Mesh2dDisExportType), intent(inout) :: this
501 integer(I4B) :: cnt, maxvert, m, k
502 integer(I4B), dimension(:), allocatable :: verts, layers
503 real(DP), dimension(:), allocatable :: bnds
504 integer(I4B) :: i, j
505 real(DP) :: x, y, x_transform, y_transform
506 real(DP), dimension(:), allocatable :: node_x, node_y
507 real(DP), dimension(:), allocatable :: cell_x, cell_y
508 real(DP), dimension(:), allocatable :: elev_face
509
510 ! initialize max vertices required to define cell
511 maxvert = 4
512
513 ! set mesh container variable value to 1
514 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh, 1), &
515 this%nc_fname)
516
517 ! write layer coordinate data
518 allocate (layers(this%nlay))
519 do k = 1, this%nlay
520 layers(k) = k
521 end do
522 call nf_verify(nf90_put_var(this%ncid, this%var_ids%layer, layers), &
523 this%nc_fname)
524 deallocate (layers)
525
526 ! allocate temporary arrays
527 allocate (verts(maxvert))
528 allocate (bnds(maxvert))
529 allocate (node_x(((this%dis%ncol + 1) * (this%dis%nrow + 1))))
530 allocate (node_y(((this%dis%ncol + 1) * (this%dis%nrow + 1))))
531 allocate (cell_x((this%dis%ncol * this%dis%nrow)))
532 allocate (cell_y((this%dis%ncol * this%dis%nrow)))
533
534 ! set node_x and node_y arrays
535 cnt = 0
536 node_x = nf90_fill_double
537 node_y = nf90_fill_double
538 y = sum(this%dis%delc)
539 do j = this%dis%nrow, 0, -1
540 x = 0
541 do i = this%dis%ncol, 0, -1
542 cnt = cnt + 1
543 call dis_transform_xy(x, y, &
544 this%dis%xorigin, &
545 this%dis%yorigin, &
546 this%dis%angrot, &
547 x_transform, y_transform)
548 node_x(cnt) = x_transform
549 node_y(cnt) = y_transform
550 if (i > 0) x = x + this%dis%delr(i)
551 end do
552 if (j > 0) y = y - this%dis%delc(j)
553 end do
554
555 ! write node_x and node_y arrays to netcdf file
556 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_node_x, node_x), &
557 this%nc_fname)
558 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_node_y, node_y), &
559 this%nc_fname)
560
561 ! set cell_x and cell_y arrays
562 cnt = 1
563 cell_x = nf90_fill_double
564 cell_y = nf90_fill_double
565 do j = 1, this%dis%nrow
566 y = this%dis%celly(j)
567 do i = 1, this%dis%ncol
568 x = this%dis%cellx(i)
569 call dis_transform_xy(x, y, &
570 this%dis%xorigin, &
571 this%dis%yorigin, &
572 this%dis%angrot, &
573 x_transform, y_transform)
574 cell_x(cnt) = x_transform
575 cell_y(cnt) = y_transform
576 cnt = cnt + 1
577 end do
578 end do
579
580 ! write face_x and face_y arrays to netcdf file
581 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_x, cell_x), &
582 this%nc_fname)
583 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_y, cell_y), &
584 this%nc_fname)
585
586 ! set and write z_l1, z_l2, ... face-flattened cell center elevation
587 ! arrays, reusing the same (row outer, col inner, cnt incrementing)
588 ! face-order convention as cell_x/cell_y above
589 allocate (elev_face((this%dis%ncol * this%dis%nrow)))
590 do k = 1, this%nlay
591 cnt = 1
592 do j = 1, this%dis%nrow
593 do i = 1, this%dis%ncol
594 if (k == 1) then
595 elev_face(cnt) = (this%dis%top2d(i, j) + &
596 this%dis%bot3d(i, j, k)) * dhalf
597 else
598 elev_face(cnt) = (this%dis%bot3d(i, j, k - 1) + &
599 this%dis%bot3d(i, j, k)) * dhalf
600 end if
601 cnt = cnt + 1
602 end do
603 end do
604 call nf_verify(nf90_put_var(this%ncid, this%var_ids%elevation(k), &
605 elev_face), this%nc_fname)
606 end do
607 deallocate (elev_face)
608
609 ! set face nodes array
610 cnt = 0
611 do i = 1, this%dis%nrow
612 do j = 1, this%dis%ncol
613 cnt = cnt + 1
614 verts = nf90_fill_int
615 verts(1) = cnt + this%dis%ncol + i
616 verts(2) = cnt + this%dis%ncol + i + 1
617 if (i > 1) then
618 verts(3) = cnt + i
619 verts(4) = cnt + i - 1
620 else
621 verts(3) = cnt + 1
622 verts(4) = cnt
623 end if
624
625 ! write face nodes array to netcdf file
626 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_nodes, &
627 verts, start=(/1, cnt/), &
628 count=(/maxvert, 1/)), &
629 this%nc_fname)
630
631 ! set face y bounds array
632 bnds = nf90_fill_double
633 do m = 1, size(bnds)
634 if (verts(m) /= nf90_fill_int) then
635 bnds(m) = node_y(verts(m))
636 end if
637 ! write face y bounds array to netcdf file
638 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_ybnds, &
639 bnds, start=(/1, cnt/), &
640 count=(/maxvert, 1/)), &
641 this%nc_fname)
642 end do
643
644 ! set face x bounds array
645 bnds = nf90_fill_double
646 do m = 1, size(bnds)
647 if (verts(m) /= nf90_fill_int) then
648 bnds(m) = node_x(verts(m))
649 end if
650 ! write face x bounds array to netcdf file
651 call nf_verify(nf90_put_var(this%ncid, this%var_ids%mesh_face_xbnds, &
652 bnds, start=(/1, cnt/), &
653 count=(/maxvert, 1/)), &
654 this%nc_fname)
655 end do
656 end do
657 end do
658
659 ! cleanup
660 deallocate (bnds)
661 deallocate (verts)
662 deallocate (node_x)
663 deallocate (node_y)
664 deallocate (cell_x)
665 deallocate (cell_y)
subroutine, public dis_transform_xy(x, y, xorigin, yorigin, angrot, xglo, yglo)
Get global (x, y) coordinates from cell-local coordinates.
Here is the call graph for this function:

◆ define_dim()

subroutine meshdismodelmodule::define_dim ( class(mesh2ddisexporttype), intent(inout) this)
private

Definition at line 396 of file DisNCMesh.f90.

397 use constantsmodule, only: mvalidate
399 class(Mesh2dDisExportType), intent(inout) :: this
400 integer(I4B) :: k
401 character(len=LINELENGTH) :: varname
402 character(len=LINELENGTH) :: elev_longname
403
404 if (isim_mode /= mvalidate .or. this%pkglist%Count() > 0) then
405 ! time
406 call nf_verify(nf90_def_dim(this%ncid, 'time', this%totnstp, &
407 this%dim_ids%time), this%nc_fname)
408 call nf_verify(nf90_def_var(this%ncid, 'time', nf90_double, &
409 this%dim_ids%time, this%var_ids%time), &
410 this%nc_fname)
411 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'calendar', &
412 'standard'), this%nc_fname)
413 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'units', &
414 this%datetime), this%nc_fname)
415 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'axis', 'T'), &
416 this%nc_fname)
417 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'standard_name', &
418 'time'), this%nc_fname)
419 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'long_name', &
420 'time'), this%nc_fname)
421 ! stress period bounds of the time coordinate (CF-1.13 7.1)
422 if (isim_mode == mvalidate) then
423 call nf_verify(nf90_def_dim(this%ncid, 'bnd', 2, this%dim_ids%bnd), &
424 this%nc_fname)
425 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'bounds', &
426 'time_bnds'), this%nc_fname)
427 call nf_verify(nf90_def_var(this%ncid, 'time_bnds', nf90_double, &
428 (/this%dim_ids%bnd, this%dim_ids%time/), &
429 this%var_ids%time_bnds), this%nc_fname)
430 end if
431 end if
432
433 ! mesh
434 call nf_verify(nf90_def_dim(this%ncid, 'nmesh_node', &
435 ((this%dis%ncol + 1) * (this%dis%nrow + 1)), &
436 this%dim_ids%nmesh_node), this%nc_fname)
437 call nf_verify(nf90_def_dim(this%ncid, 'nmesh_face', &
438 (this%dis%ncol * this%dis%nrow), &
439 this%dim_ids%nmesh_face), this%nc_fname)
440 call nf_verify(nf90_def_dim(this%ncid, 'max_nmesh_face_nodes', 4, &
441 this%dim_ids%max_nmesh_face_nodes), &
442 this%nc_fname)
443
444 ! x, y
445 call nf_verify(nf90_def_dim(this%ncid, 'x', this%dis%ncol, &
446 this%x_dim), this%nc_fname)
447 call nf_verify(nf90_def_dim(this%ncid, 'y', this%dis%nrow, &
448 this%y_dim), this%nc_fname)
449
450 ! layer
451 call nf_verify(nf90_def_dim(this%ncid, 'layer', this%nlay, &
452 this%dim_ids%layer), this%nc_fname)
453 call nf_verify(nf90_def_var(this%ncid, 'layer', nf90_int, &
454 this%dim_ids%layer, this%var_ids%layer), &
455 this%nc_fname)
456 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer, 'units', '1'), &
457 this%nc_fname)
458 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer, 'axis', 'Z'), &
459 this%nc_fname)
460 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer, 'positive', &
461 'down'), this%nc_fname)
462 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer, 'long_name', &
463 'model layer'), this%nc_fname)
464
465 ! z_l1, z_l2, ... : per-layer cell center elevation auxiliary
466 ! coordinates -- real vertical position, unlike the discrete layer
467 ! index. Always written, independent of CRS/NCF configuration; split
468 ! per layer since face-indexed variables carry no layer dimension to
469 ! legally reference a combined z(layer, nmesh_face) coordinate
470 ! (CF-1.13 5.2).
471 allocate (this%var_ids%elevation(this%nlay))
472 do k = 1, this%nlay
473 write (varname, '(a,i0)') 'z_l', k
474 call nf_verify(nf90_def_var(this%ncid, trim(varname), nf90_double, &
475 (/this%dim_ids%nmesh_face/), &
476 this%var_ids%elevation(k)), this%nc_fname)
477 call ncvar_chunk(this%ncid, this%var_ids%elevation(k), this%chunk_face, &
478 this%nc_fname)
479 call ncvar_deflate(this%ncid, this%var_ids%elevation(k), this%deflate, &
480 this%shuffle, this%nc_fname)
481 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation(k), &
482 'units', this%lenunits), this%nc_fname)
483 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation(k), &
484 'standard_name', 'altitude'), this%nc_fname)
485 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation(k), &
486 'positive', 'up'), this%nc_fname)
487 write (elev_longname, '(a,i0,a)') 'cell center elevation (layer ', &
488 k, ')'
489 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation(k), &
490 'long_name', trim(elev_longname)), &
491 this%nc_fname)
492 call ncvar_layer(this%ncid, this%var_ids%elevation(k), k, this%nc_fname)
493 end do
This module contains simulation constants.
Definition Constants.f90:9
@ mvalidate
validation mode - do not run time steps
This module contains simulation variables.
integer(i4b) isim_mode
simulation mode
Here is the call graph for this function:

◆ df()

subroutine meshdismodelmodule::df ( class(mesh2ddisexporttype), intent(inout) this)
private

Definition at line 86 of file DisNCMesh.f90.

87 use constantsmodule, only: mvalidate
89 class(Mesh2dDisExportType), intent(inout) :: this
90 ! put root group file scope attributes
91 call this%add_global_att()
92 ! define root group dimensions and coordinate variables
93 call this%define_dim()
94 ! define mesh variables
95 call this%create_mesh()
96 if (isim_mode == mvalidate) then
97 ! define period input arrays
98 call this%df_export()
99 else
100 ! define the dependent variable
101 call this%define_dependent()
102 end if
103 ! exit define mode
104 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
105 ! create mesh
106 call this%add_mesh_data()
107 if (isim_mode == mvalidate) then
108 ! define and set package input griddata
109 call this%add_pkg_data()
110 end if
111 ! define and set gridmap variable
112 call this%define_gridmap()
113 ! synchronize file
114 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
Here is the call graph for this function:

◆ dis_export_destroy()

subroutine meshdismodelmodule::dis_export_destroy ( class(mesh2ddisexporttype), intent(inout) this)
private

Definition at line 76 of file DisNCMesh.f90.

77 class(Mesh2dDisExportType), intent(inout) :: this
78 deallocate (this%var_ids%dependent)
79 ! destroy base class
80 call this%mesh_destroy()
81 call this%NCModelExportType%destroy()

◆ dis_export_init()

subroutine meshdismodelmodule::dis_export_init ( class(mesh2ddisexporttype), 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) iout )

Definition at line 50 of file DisNCMesh.f90.

53 class(Mesh2dDisExportType), intent(inout) :: this
54 character(len=*), intent(in) :: modelname
55 character(len=*), intent(in) :: modeltype
56 character(len=*), intent(in) :: modelfname
57 character(len=*), intent(in) :: nc_fname
58 integer(I4B), intent(in) :: disenum
59 integer(I4B), intent(in) :: nctype
60 integer(I4B), intent(in) :: iout
61
62 ! set nlay
63 this%nlay = this%dis%nlay
64
65 ! allocate var_id arrays
66 allocate (this%var_ids%dependent(this%nlay))
67 allocate (this%var_ids%export(this%nlay))
68
69 ! initialize base class
70 call this%mesh_init(modelname, modeltype, modelfname, nc_fname, disenum, &
71 nctype, this%dis%lenuni, iout)

◆ export_input_array()

subroutine meshdismodelmodule::export_input_array ( class(mesh2ddisexporttype), intent(inout) this,
character(len=*), intent(in) pkgtype,
character(len=*), intent(in) pkgname,
character(len=*), intent(in) mempath,
type(inputparamdefinitiontype), intent(in), pointer idt )
private

Definition at line 330 of file DisNCMesh.f90.

331 class(Mesh2dDisExportType), intent(inout) :: this
332 character(len=*), intent(in) :: pkgtype
333 character(len=*), intent(in) :: pkgname
334 character(len=*), intent(in) :: mempath
335 type(InputParamDefinitionType), pointer, intent(in) :: idt
336 integer(I4B), dimension(:), pointer, contiguous :: int1d
337 integer(I4B), dimension(:, :), pointer, contiguous :: int2d
338 integer(I4B), dimension(:, :, :), pointer, contiguous :: int3d
339 real(DP), dimension(:), pointer, contiguous :: dbl1d
340 real(DP), dimension(:, :), pointer, contiguous :: dbl2d
341 real(DP), dimension(:, :, :), pointer, contiguous :: dbl3d
342 character(len=LINELENGTH) :: nc_tag
343 integer(I4B) :: iper, iaux
344
345 iper = 0
346 iaux = 0
347
348 ! set package input tag
349 nc_tag = this%input_attribute(pkgname, idt)
350
351 select case (idt%datatype)
352 case ('INTEGER1D')
353 call mem_setptr(int1d, idt%mf6varname, mempath)
354 call nc_export_int1d(int1d, this%ncid, this%dim_ids, this%x_dim, &
355 this%y_dim, this%var_ids, this%dis, idt, mempath, &
356 nc_tag, pkgname, this%gridmap_name, this%deflate, &
357 this%shuffle, this%chunk_face, iper, this%nc_fname)
358 case ('INTEGER2D')
359 call mem_setptr(int2d, idt%mf6varname, mempath)
360 call nc_export_int2d(int2d, this%ncid, this%dim_ids, this%var_ids, &
361 this%dis, idt, mempath, nc_tag, pkgname, &
362 this%gridmap_name, this%deflate, this%shuffle, &
363 this%chunk_face, this%nc_fname)
364 case ('INTEGER3D')
365 call mem_setptr(int3d, idt%mf6varname, mempath)
366 call nc_export_int3d(int3d, this%ncid, this%dim_ids, this%var_ids, &
367 this%dis, idt, mempath, nc_tag, pkgname, &
368 this%gridmap_name, this%deflate, this%shuffle, &
369 this%chunk_face, this%nc_fname)
370 case ('DOUBLE1D')
371 call mem_setptr(dbl1d, idt%mf6varname, mempath)
372 call nc_export_dbl1d(dbl1d, this%ncid, this%dim_ids, this%x_dim, &
373 this%y_dim, this%var_ids, this%dis, idt, mempath, &
374 nc_tag, pkgname, this%gridmap_name, this%deflate, &
375 this%shuffle, this%chunk_face, iper, iaux, &
376 this%nc_fname)
377 case ('DOUBLE2D')
378 call mem_setptr(dbl2d, idt%mf6varname, mempath)
379 call nc_export_dbl2d(dbl2d, this%ncid, this%dim_ids, this%var_ids, &
380 this%dis, idt, mempath, nc_tag, pkgname, &
381 this%gridmap_name, this%deflate, this%shuffle, &
382 this%chunk_face, this%nc_fname)
383 case ('DOUBLE3D')
384 call mem_setptr(dbl3d, idt%mf6varname, mempath)
385 call nc_export_dbl3d(dbl3d, this%ncid, this%dim_ids, this%var_ids, &
386 this%dis, idt, mempath, nc_tag, pkgname, &
387 this%gridmap_name, this%deflate, this%shuffle, &
388 this%chunk_face, this%nc_fname)
389 case default
390 ! no-op, no other datatypes exported
391 end select
Here is the call graph for this function:

◆ nc_export_dbl1d()

subroutine meshdismodelmodule::nc_export_dbl1d ( real(dp), dimension(:), intent(in), pointer, contiguous p_mem,
integer(i4b), intent(in) ncid,
type(meshncdimidtype), intent(inout) dim_ids,
integer(i4b), intent(in) x_dim,
integer(i4b), intent(in) y_dim,
type(meshncvaridtype), intent(in) var_ids,
type(distype), intent(in), pointer dis,
type(inputparamdefinitiontype), pointer idt,
character(len=*), intent(in) mempath,
character(len=*), intent(in) nc_tag,
character(len=*), intent(in) pkgname,
character(len=*), intent(in) gridmap_name,
integer(i4b), intent(in) deflate,
integer(i4b), intent(in) shuffle,
integer(i4b), intent(in) chunk_face,
integer(i4b), intent(in) iper,
integer(i4b), intent(in) iaux,
character(len=*), intent(in) nc_fname )
private

Definition at line 950 of file DisNCMesh.f90.

953 use tdismodule, only: kper
954 real(DP), dimension(:), pointer, contiguous, intent(in) :: p_mem
955 integer(I4B), intent(in) :: ncid
956 type(MeshNCDimIdType), intent(inout) :: dim_ids
957 integer(I4B), intent(in) :: x_dim
958 integer(I4B), intent(in) :: y_dim
959 type(MeshNCVarIdType), intent(in) :: var_ids
960 type(DisType), pointer, intent(in) :: dis
961 type(InputParamDefinitionType), pointer :: idt
962 character(len=*), intent(in) :: mempath
963 character(len=*), intent(in) :: nc_tag
964 character(len=*), intent(in) :: pkgname
965 character(len=*), intent(in) :: gridmap_name
966 integer(I4B), intent(in) :: deflate
967 integer(I4B), intent(in) :: shuffle
968 integer(I4B), intent(in) :: chunk_face
969 integer(I4B), intent(in) :: iper
970 integer(I4B), intent(in) :: iaux
971 character(len=*), intent(in) :: nc_fname
972 real(DP), dimension(:, :, :), pointer, contiguous :: dbl3d
973 real(DP), dimension(:), pointer, contiguous :: dbl1d
974 integer(I4B) :: axis_dim, nvals, k
975 integer(I4B), dimension(:), allocatable :: var_id
976 character(len=LINELENGTH) :: longname, varname
977
978 if (idt%shape == 'NROW' .or. &
979 idt%shape == 'NCOL' .or. &
980 idt%shape == 'NCPL' .or. &
981 idt%shape == 'NAUX NCPL') then
982
983 if (iper == 0) then
984
985 select case (idt%shape)
986 case ('NROW')
987 axis_dim = y_dim
988 case ('NCOL')
989 axis_dim = x_dim
990 case ('NCPL', 'NAUX NCPL')
991 axis_dim = dim_ids%nmesh_face
992 end select
993
994 ! set names
995 varname = export_varname(pkgname, idt%tagname, mempath, iaux=iaux)
996 longname = export_longname(idt%longname, pkgname, idt%tagname, &
997 mempath, iaux=iaux, &
998 component_type=idt%component_type, &
999 subcomponent_type=idt%subcomponent_type)
1000
1001 allocate (var_id(1))
1002
1003 ! reenter define mode and create variable
1004 call nf_verify(nf90_redef(ncid), nc_fname)
1005 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1006 (/axis_dim/), var_id(1)), &
1007 nc_fname)
1008
1009 ! apply chunking for face-indexed variables; NROW/NCOL use default
1010 if (axis_dim == dim_ids%nmesh_face) then
1011 call ncvar_chunk(ncid, var_id(1), chunk_face, nc_fname)
1012 end if
1013 call ncvar_deflate(ncid, var_id(1), deflate, shuffle, nc_fname)
1014
1015 ! put attr
1016 call nf_verify(nf90_put_att(ncid, var_id(1), '_FillValue', &
1017 (/nf90_fill_double/)), nc_fname)
1018 call nf_verify(nf90_put_att(ncid, var_id(1), 'long_name', &
1019 longname), nc_fname)
1020
1021 ! add grid mapping for face-indexed variables
1022 if (axis_dim == dim_ids%nmesh_face) then
1023 call ncvar_gridmap(ncid, var_id(1), gridmap_name, 0, nc_fname)
1024 end if
1025
1026 ! add mf6 attr
1027 call ncvar_mf6attr(ncid, var_id(1), 0, iaux, nc_tag, nc_fname)
1028
1029 ! exit define mode and write data
1030 call nf_verify(nf90_enddef(ncid), nc_fname)
1031 call nf_verify(nf90_put_var(ncid, var_id(1), p_mem), &
1032 nc_fname)
1033 else
1034 nvals = dis%nrow * dis%ncol
1035 call nf_verify(nf90_put_var(ncid, &
1036 var_ids%export(1), p_mem, &
1037 start=(/1, kper/), &
1038 count=(/nvals, 1/)), nc_fname)
1039 end if
1040
1041 else
1042 ! reshape input
1043 dbl3d(1:dis%ncol, 1:dis%nrow, 1:dis%nlay) => p_mem(1:dis%nodesuser)
1044
1045 ! set nvals as ncpl
1046 nvals = dis%nrow * dis%ncol
1047
1048 if (iper == 0) then
1049 ! not a timeseries, create variables and write griddata
1050
1051 ! allocate local variable id storage
1052 allocate (var_id(dis%nlay))
1053
1054 ! reenter define mode and create layer variables
1055 call nf_verify(nf90_redef(ncid), nc_fname)
1056 do k = 1, dis%nlay
1057 ! set names
1058 varname = export_varname(pkgname, idt%tagname, mempath, layer=k, &
1059 iaux=iaux)
1060 longname = export_longname(idt%longname, pkgname, idt%tagname, &
1061 mempath, layer=k, iaux=iaux, &
1062 component_type=idt%component_type, &
1063 subcomponent_type=idt%subcomponent_type)
1064
1065 ! create layer variable
1066 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1067 (/dim_ids%nmesh_face/), var_id(k)), &
1068 nc_fname)
1069
1070 ! apply chunking parameters
1071 call ncvar_chunk(ncid, var_id(k), chunk_face, nc_fname)
1072 ! deflate and shuffle
1073 call ncvar_deflate(ncid, var_id(k), deflate, shuffle, nc_fname)
1074
1075 ! put attr
1076 call nf_verify(nf90_put_att(ncid, var_id(k), '_FillValue', &
1077 (/nf90_fill_double/)), nc_fname)
1078 call nf_verify(nf90_put_att(ncid, var_id(k), 'long_name', &
1079 longname), nc_fname)
1080
1081 ! add grid mapping and mf6 attr
1082 call ncvar_gridmap(ncid, var_id(k), gridmap_name, k, nc_fname)
1083 call ncvar_mf6attr(ncid, var_id(k), k, iaux, nc_tag, nc_fname)
1084 end do
1085
1086 ! exit define mode
1087 call nf_verify(nf90_enddef(ncid), nc_fname)
1088
1089 ! write layer data
1090 do k = 1, dis%nlay
1091 dbl1d(1:nvals) => dbl3d(:, :, k)
1092 call nf_verify(nf90_put_var(ncid, var_id(k), dbl1d), nc_fname)
1093 end do
1094
1095 ! cleanup
1096 deallocate (var_id)
1097 else
1098 ! timeseries, add period data
1099 do k = 1, dis%nlay
1100 dbl1d(1:nvals) => dbl3d(:, :, k)
1101 call nf_verify(nf90_put_var(ncid, &
1102 var_ids%export(k), dbl1d, &
1103 start=(/1, kper/), &
1104 count=(/nvals, 1/)), nc_fname)
1105 end do
1106 end if
1107 end if
integer(i4b), pointer, public kper
current stress period number
Definition tdis.f90:26
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nc_export_dbl2d()

subroutine meshdismodelmodule::nc_export_dbl2d ( real(dp), dimension(:, :), intent(in), pointer, contiguous p_mem,
integer(i4b), intent(in) ncid,
type(meshncdimidtype), intent(inout) dim_ids,
type(meshncvaridtype), intent(inout) var_ids,
type(distype), intent(in), pointer dis,
type(inputparamdefinitiontype), pointer idt,
character(len=*), intent(in) mempath,
character(len=*), intent(in) nc_tag,
character(len=*), intent(in) pkgname,
character(len=*), intent(in) gridmap_name,
integer(i4b), intent(in) deflate,
integer(i4b), intent(in) shuffle,
integer(i4b), intent(in) chunk_face,
character(len=*), intent(in) nc_fname )
private

Definition at line 1112 of file DisNCMesh.f90.

1115 real(DP), dimension(:, :), pointer, contiguous, intent(in) :: p_mem
1116 integer(I4B), intent(in) :: ncid
1117 type(MeshNCDimIdType), intent(inout) :: dim_ids
1118 type(MeshNCVarIdType), intent(inout) :: var_ids
1119 type(DisType), pointer, intent(in) :: dis
1120 type(InputParamDefinitionType), pointer :: idt
1121 character(len=*), intent(in) :: mempath
1122 character(len=*), intent(in) :: nc_tag
1123 character(len=*), intent(in) :: pkgname
1124 character(len=*), intent(in) :: gridmap_name
1125 integer(I4B), intent(in) :: deflate
1126 integer(I4B), intent(in) :: shuffle
1127 integer(I4B), intent(in) :: chunk_face
1128 character(len=*), intent(in) :: nc_fname
1129 integer(I4B) :: var_id, nvals
1130 character(len=LINELENGTH) :: longname, varname
1131 real(DP), dimension(:), pointer, contiguous :: dbl1d
1132
1133 ! set names
1134 varname = export_varname(pkgname, idt%tagname, mempath)
1135 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1136 component_type=idt%component_type, &
1137 subcomponent_type=idt%subcomponent_type)
1138
1139 ! reenter define mode and create variable
1140 call nf_verify(nf90_redef(ncid), nc_fname)
1141 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1142 (/dim_ids%nmesh_face/), var_id), &
1143 nc_fname)
1144
1145 ! apply chunking parameters
1146 call ncvar_chunk(ncid, var_id, chunk_face, nc_fname)
1147 ! deflate and shuffle
1148 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1149
1150 ! put attr
1151 call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1152 (/nf90_fill_double/)), nc_fname)
1153 call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1154 longname), nc_fname)
1155
1156 ! add grid mapping and mf6 attr
1157 call ncvar_gridmap(ncid, var_id, gridmap_name, 0, nc_fname)
1158 call ncvar_mf6attr(ncid, var_id, 0, 0, nc_tag, nc_fname)
1159
1160 ! exit define mode and write data
1161 call nf_verify(nf90_enddef(ncid), nc_fname)
1162 nvals = dis%nrow * dis%ncol
1163 dbl1d(1:nvals) => p_mem
1164 call nf_verify(nf90_put_var(ncid, var_id, dbl1d), nc_fname)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nc_export_dbl3d()

subroutine meshdismodelmodule::nc_export_dbl3d ( real(dp), dimension(:, :, :), intent(in), pointer, contiguous p_mem,
integer(i4b), intent(in) ncid,
type(meshncdimidtype), intent(inout) dim_ids,
type(meshncvaridtype), intent(inout) var_ids,
type(distype), intent(in), pointer dis,
type(inputparamdefinitiontype), pointer idt,
character(len=*), intent(in) mempath,
character(len=*), intent(in) nc_tag,
character(len=*), intent(in) pkgname,
character(len=*), intent(in) gridmap_name,
integer(i4b), intent(in) deflate,
integer(i4b), intent(in) shuffle,
integer(i4b), intent(in) chunk_face,
character(len=*), intent(in) nc_fname )
private

Definition at line 1169 of file DisNCMesh.f90.

1172 real(DP), dimension(:, :, :), pointer, contiguous, intent(in) :: p_mem
1173 integer(I4B), intent(in) :: ncid
1174 type(MeshNCDimIdType), intent(inout) :: dim_ids
1175 type(MeshNCVarIdType), intent(inout) :: var_ids
1176 type(DisType), pointer, intent(in) :: dis
1177 type(InputParamDefinitionType), pointer :: idt
1178 character(len=*), intent(in) :: mempath
1179 character(len=*), intent(in) :: nc_tag
1180 character(len=*), intent(in) :: pkgname
1181 character(len=*), intent(in) :: gridmap_name
1182 integer(I4B), intent(in) :: deflate
1183 integer(I4B), intent(in) :: shuffle
1184 integer(I4B), intent(in) :: chunk_face
1185 character(len=*), intent(in) :: nc_fname
1186 integer(I4B), dimension(:), allocatable :: var_id
1187 real(DP), dimension(:), pointer, contiguous :: dbl1d
1188 character(len=LINELENGTH) :: longname, varname
1189 integer(I4B) :: k, nvals
1190
1191 ! set nvals as ncpl
1192 nvals = dis%nrow * dis%ncol
1193
1194 allocate (var_id(dis%nlay))
1195
1196 ! reenter define mode and create variable
1197 call nf_verify(nf90_redef(ncid), nc_fname)
1198 do k = 1, dis%nlay
1199 ! set names
1200 varname = export_varname(pkgname, idt%tagname, mempath, layer=k)
1201 longname = export_longname(idt%longname, pkgname, idt%tagname, &
1202 mempath, layer=k, &
1203 component_type=idt%component_type, &
1204 subcomponent_type=idt%subcomponent_type)
1205
1206 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1207 (/dim_ids%nmesh_face/), var_id(k)), &
1208 nc_fname)
1209
1210 ! apply chunking parameters
1211 call ncvar_chunk(ncid, var_id(k), chunk_face, nc_fname)
1212 ! deflate and shuffle
1213 call ncvar_deflate(ncid, var_id(k), deflate, shuffle, nc_fname)
1214
1215 ! put attr
1216 call nf_verify(nf90_put_att(ncid, var_id(k), '_FillValue', &
1217 (/nf90_fill_double/)), nc_fname)
1218 call nf_verify(nf90_put_att(ncid, var_id(k), 'long_name', &
1219 longname), nc_fname)
1220
1221 ! add grid mapping and mf6 attr
1222 call ncvar_gridmap(ncid, var_id(k), gridmap_name, k, nc_fname)
1223 call ncvar_mf6attr(ncid, var_id(k), k, 0, nc_tag, nc_fname)
1224 end do
1225
1226 ! exit define mode and write data
1227 call nf_verify(nf90_enddef(ncid), nc_fname)
1228 do k = 1, dis%nlay
1229 dbl1d(1:nvals) => p_mem(:, :, k)
1230 call nf_verify(nf90_put_var(ncid, var_id(k), dbl1d), nc_fname)
1231 end do
1232
1233 ! cleanup
1234 deallocate (var_id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nc_export_int1d()

subroutine meshdismodelmodule::nc_export_int1d ( integer(i4b), dimension(:), intent(in), pointer, contiguous p_mem,
integer(i4b), intent(in) ncid,
type(meshncdimidtype), intent(inout) dim_ids,
integer(i4b), intent(in) x_dim,
integer(i4b), intent(in) y_dim,
type(meshncvaridtype), intent(inout) var_ids,
type(distype), intent(in), pointer dis,
type(inputparamdefinitiontype), pointer idt,
character(len=*), intent(in) mempath,
character(len=*), intent(in) nc_tag,
character(len=*), intent(in) pkgname,
character(len=*), intent(in) gridmap_name,
integer(i4b), intent(in) deflate,
integer(i4b), intent(in) shuffle,
integer(i4b), intent(in) chunk_face,
integer(i4b), intent(in) iper,
character(len=*), intent(in) nc_fname )
private

Definition at line 670 of file DisNCMesh.f90.

673 use tdismodule, only: kper
674 integer(I4B), dimension(:), pointer, contiguous, intent(in) :: p_mem
675 integer(I4B), intent(in) :: ncid
676 type(MeshNCDimIdType), intent(inout) :: dim_ids
677 integer(I4B), intent(in) :: x_dim
678 integer(I4B), intent(in) :: y_dim
679 type(MeshNCVarIdType), intent(inout) :: var_ids
680 type(DisType), pointer, intent(in) :: dis
681 type(InputParamDefinitionType), pointer :: idt
682 character(len=*), intent(in) :: mempath
683 character(len=*), intent(in) :: nc_tag
684 character(len=*), intent(in) :: pkgname
685 character(len=*), intent(in) :: gridmap_name
686 integer(I4B), intent(in) :: deflate
687 integer(I4B), intent(in) :: shuffle
688 integer(I4B), intent(in) :: chunk_face
689 integer(I4B), intent(in) :: iper
690 character(len=*), intent(in) :: nc_fname
691 integer(I4B), dimension(:, :, :), pointer, contiguous :: int3d
692 integer(I4B), dimension(:), pointer, contiguous :: int1d
693 integer(I4B) :: axis_dim, nvals, k
694 integer(I4B), dimension(:), allocatable :: var_id
695 character(len=LINELENGTH) :: longname, varname
696
697 if (idt%shape == 'NROW' .or. &
698 idt%shape == 'NCOL' .or. &
699 idt%shape == 'NCPL' .or. &
700 idt%shape == 'NAUX NCPL') then
701
702 if (iper == 0) then
703
704 select case (idt%shape)
705 case ('NROW')
706 axis_dim = y_dim
707 case ('NCOL')
708 axis_dim = x_dim
709 case ('NCPL', 'NAUX NCPL')
710 axis_dim = dim_ids%nmesh_face
711 end select
712
713 ! set names
714 varname = export_varname(pkgname, idt%tagname, mempath)
715 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
716 component_type=idt%component_type, &
717 subcomponent_type=idt%subcomponent_type)
718
719 allocate (var_id(1))
720
721 ! reenter define mode and create variable
722 call nf_verify(nf90_redef(ncid), nc_fname)
723 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
724 (/axis_dim/), var_id(1)), &
725 nc_fname)
726
727 ! apply chunking for face-indexed variables; NROW/NCOL use default
728 if (axis_dim == dim_ids%nmesh_face) then
729 call ncvar_chunk(ncid, var_id(1), chunk_face, nc_fname)
730 end if
731 call ncvar_deflate(ncid, var_id(1), deflate, shuffle, nc_fname)
732
733 ! put attr
734 call nf_verify(nf90_put_att(ncid, var_id(1), '_FillValue', &
735 (/nf90_fill_int/)), nc_fname)
736 call nf_verify(nf90_put_att(ncid, var_id(1), 'long_name', &
737 longname), nc_fname)
738
739 ! add grid mapping for face-indexed variables
740 if (axis_dim == dim_ids%nmesh_face) then
741 call ncvar_gridmap(ncid, var_id(1), gridmap_name, 0, nc_fname)
742 end if
743
744 ! add mf6 attr
745 call ncvar_mf6attr(ncid, var_id(1), 0, 0, nc_tag, nc_fname)
746
747 ! exit define mode and write data
748 call nf_verify(nf90_enddef(ncid), nc_fname)
749 call nf_verify(nf90_put_var(ncid, var_id(1), p_mem), &
750 nc_fname)
751 else
752 nvals = dis%nrow * dis%ncol
753 call nf_verify(nf90_put_var(ncid, &
754 var_ids%export(1), p_mem, &
755 start=(/1, kper/), &
756 count=(/nvals, 1/)), nc_fname)
757 end if
758
759 else
760 ! reshape input
761 int3d(1:dis%ncol, 1:dis%nrow, 1:dis%nlay) => p_mem(1:dis%nodesuser)
762
763 ! set nvals as ncpl
764 nvals = dis%nrow * dis%ncol
765
766 if (iper == 0) then
767 ! not a timeseries, create variables and write griddata
768 allocate (var_id(dis%nlay))
769
770 ! reenter define mode and create variable
771 call nf_verify(nf90_redef(ncid), nc_fname)
772 do k = 1, dis%nlay
773 ! set names
774 varname = export_varname(pkgname, idt%tagname, mempath, &
775 layer=k)
776 longname = export_longname(idt%longname, pkgname, idt%tagname, &
777 mempath, layer=k, &
778 component_type=idt%component_type, &
779 subcomponent_type=idt%subcomponent_type)
780
781 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
782 (/dim_ids%nmesh_face/), var_id(k)), &
783 nc_fname)
784
785 ! apply chunking parameters
786 call ncvar_chunk(ncid, var_id(k), chunk_face, nc_fname)
787 ! deflate and shuffle
788 call ncvar_deflate(ncid, var_id(k), deflate, shuffle, nc_fname)
789
790 ! put attr
791 call nf_verify(nf90_put_att(ncid, var_id(k), '_FillValue', &
792 (/nf90_fill_int/)), nc_fname)
793 call nf_verify(nf90_put_att(ncid, var_id(k), 'long_name', &
794 longname), nc_fname)
795
796 ! add grid mapping and mf6 attr
797 call ncvar_gridmap(ncid, var_id(k), gridmap_name, k, nc_fname)
798 call ncvar_mf6attr(ncid, var_id(k), k, 0, nc_tag, nc_fname)
799 end do
800
801 ! exit define mode and write data
802 call nf_verify(nf90_enddef(ncid), nc_fname)
803 do k = 1, dis%nlay
804 int1d(1:nvals) => int3d(:, :, k)
805 call nf_verify(nf90_put_var(ncid, var_id(k), int1d), nc_fname)
806 end do
807
808 ! cleanup
809 deallocate (var_id)
810 else
811 ! timeseries, add period data
812 do k = 1, dis%nlay
813 int1d(1:nvals) => int3d(:, :, k)
814 call nf_verify(nf90_put_var(ncid, &
815 var_ids%export(k), int1d, &
816 start=(/1, kper/), &
817 count=(/nvals, 1/)), nc_fname)
818 end do
819 end if
820 end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nc_export_int2d()

subroutine meshdismodelmodule::nc_export_int2d ( integer(i4b), dimension(:, :), intent(in), pointer, contiguous p_mem,
integer(i4b), intent(in) ncid,
type(meshncdimidtype), intent(inout) dim_ids,
type(meshncvaridtype), intent(inout) var_ids,
type(distype), intent(in), pointer dis,
type(inputparamdefinitiontype), pointer idt,
character(len=*), intent(in) mempath,
character(len=*), intent(in) nc_tag,
character(len=*), intent(in) pkgname,
character(len=*), intent(in) gridmap_name,
integer(i4b), intent(in) deflate,
integer(i4b), intent(in) shuffle,
integer(i4b), intent(in) chunk_face,
character(len=*), intent(in) nc_fname )
private

Definition at line 825 of file DisNCMesh.f90.

828 integer(I4B), dimension(:, :), pointer, contiguous, intent(in) :: p_mem
829 integer(I4B), intent(in) :: ncid
830 type(MeshNCDimIdType), intent(inout) :: dim_ids
831 type(MeshNCVarIdType), intent(inout) :: var_ids
832 type(DisType), pointer, intent(in) :: dis
833 type(InputParamDefinitionType), pointer :: idt
834 character(len=*), intent(in) :: mempath
835 character(len=*), intent(in) :: nc_tag
836 character(len=*), intent(in) :: pkgname
837 character(len=*), intent(in) :: gridmap_name
838 integer(I4B), intent(in) :: deflate
839 integer(I4B), intent(in) :: shuffle
840 integer(I4B), intent(in) :: chunk_face
841 character(len=*), intent(in) :: nc_fname
842 integer(I4B) :: var_id, nvals
843 integer(I4B), dimension(:), pointer, contiguous :: int1d
844 character(len=LINELENGTH) :: longname, varname
845
846 ! set names
847 varname = export_varname(pkgname, idt%tagname, mempath)
848 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
849 component_type=idt%component_type, &
850 subcomponent_type=idt%subcomponent_type)
851
852 ! reenter define mode and create variable
853 call nf_verify(nf90_redef(ncid), nc_fname)
854 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
855 (/dim_ids%nmesh_face/), var_id), &
856 nc_fname)
857
858 ! apply chunking parameters
859 call ncvar_chunk(ncid, var_id, chunk_face, nc_fname)
860 ! deflate and shuffle
861 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
862
863 ! put attr
864 call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
865 (/nf90_fill_int/)), nc_fname)
866 call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
867 longname), nc_fname)
868
869 ! add grid mapping and mf6 attr
870 call ncvar_gridmap(ncid, var_id, gridmap_name, 0, nc_fname)
871 call ncvar_mf6attr(ncid, var_id, 0, 0, nc_tag, nc_fname)
872
873 ! exit define mode and write data
874 call nf_verify(nf90_enddef(ncid), nc_fname)
875 nvals = dis%nrow * dis%ncol
876 int1d(1:nvals) => p_mem
877 call nf_verify(nf90_put_var(ncid, var_id, int1d), nc_fname)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nc_export_int3d()

subroutine meshdismodelmodule::nc_export_int3d ( integer(i4b), dimension(:, :, :), intent(in), pointer, contiguous p_mem,
integer(i4b), intent(in) ncid,
type(meshncdimidtype), intent(inout) dim_ids,
type(meshncvaridtype), intent(inout) var_ids,
type(distype), intent(in), pointer dis,
type(inputparamdefinitiontype), pointer idt,
character(len=*), intent(in) mempath,
character(len=*), intent(in) nc_tag,
character(len=*), intent(in) pkgname,
character(len=*), intent(in) gridmap_name,
integer(i4b), intent(in) deflate,
integer(i4b), intent(in) shuffle,
integer(i4b), intent(in) chunk_face,
character(len=*), intent(in) nc_fname )
private

Definition at line 882 of file DisNCMesh.f90.

885 integer(I4B), dimension(:, :, :), pointer, contiguous, intent(in) :: p_mem
886 integer(I4B), intent(in) :: ncid
887 type(MeshNCDimIdType), intent(inout) :: dim_ids
888 type(MeshNCVarIdType), intent(inout) :: var_ids
889 type(DisType), pointer, intent(in) :: dis
890 type(InputParamDefinitionType), pointer :: idt
891 character(len=*), intent(in) :: mempath
892 character(len=*), intent(in) :: nc_tag
893 character(len=*), intent(in) :: pkgname
894 character(len=*), intent(in) :: gridmap_name
895 integer(I4B), intent(in) :: deflate
896 integer(I4B), intent(in) :: shuffle
897 integer(I4B), intent(in) :: chunk_face
898 character(len=*), intent(in) :: nc_fname
899 integer(I4B), dimension(:), allocatable :: var_id
900 integer(I4B), dimension(:), pointer, contiguous :: int1d
901 character(len=LINELENGTH) :: longname, varname
902 integer(I4B) :: k, nvals
903
904 allocate (var_id(dis%nlay))
905
906 ! reenter define mode and create variable
907 call nf_verify(nf90_redef(ncid), nc_fname)
908 do k = 1, dis%nlay
909 ! set names
910 varname = export_varname(pkgname, idt%tagname, mempath, layer=k)
911 longname = export_longname(idt%longname, pkgname, idt%tagname, &
912 mempath, layer=k, &
913 component_type=idt%component_type, &
914 subcomponent_type=idt%subcomponent_type)
915
916 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
917 (/dim_ids%nmesh_face/), var_id(k)), &
918 nc_fname)
919
920 ! apply chunking parameters
921 call ncvar_chunk(ncid, var_id(k), chunk_face, nc_fname)
922 ! deflate and shuffle
923 call ncvar_deflate(ncid, var_id(k), deflate, shuffle, nc_fname)
924
925 ! put attr
926 call nf_verify(nf90_put_att(ncid, var_id(k), '_FillValue', &
927 (/nf90_fill_int/)), nc_fname)
928 call nf_verify(nf90_put_att(ncid, var_id(k), 'long_name', &
929 longname), nc_fname)
930
931 ! add grid mapping and mf6 attr
932 call ncvar_gridmap(ncid, var_id(k), gridmap_name, k, nc_fname)
933 call ncvar_mf6attr(ncid, var_id(k), k, 0, nc_tag, nc_fname)
934 end do
935
936 ! exit define mode and write data
937 call nf_verify(nf90_enddef(ncid), nc_fname)
938 nvals = dis%nrow * dis%ncol
939 do k = 1, dis%nlay
940 int1d(1:nvals) => p_mem(:, :, k)
941 call nf_verify(nf90_put_var(ncid, var_id(k), int1d), nc_fname)
942 end do
943
944 ! cleanup
945 deallocate (var_id)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ package_step()

subroutine meshdismodelmodule::package_step ( class(mesh2ddisexporttype), intent(inout) this,
class(exportpackagetype), intent(in), pointer export_pkg )
private

Definition at line 185 of file DisNCMesh.f90.

186 use tdismodule, only: totim, kper, perlen
189 class(Mesh2dDisExportType), intent(inout) :: this
190 class(ExportPackageType), pointer, intent(in) :: export_pkg
191 type(InputParamDefinitionType), pointer :: idt
192 integer(I4B), dimension(:), pointer, contiguous :: int1d
193 real(DP), dimension(:), pointer, contiguous :: dbl1d, nodes
194 real(DP), dimension(:, :), pointer, contiguous :: dbl2d
195 character(len=LINELENGTH) :: nc_tag
196 integer(I4B) :: iaux, iparam, nvals
197 integer(I4B) :: k, n
198
199 ! initialize
200 iaux = 0
201
202 ! update input in effect for this period
203 call export_pkg%update_state()
204
205 ! export period input in effect
206 do iparam = 1, export_pkg%nparam
207 ! check if variable has input in effect
208 if (.not. export_pkg%param_state(iparam)) cycle
209
210 ! set input definition
211 idt => &
212 get_param_definition_type(export_pkg%mf6_input%param_dfns, &
213 export_pkg%mf6_input%component_type, &
214 export_pkg%mf6_input%subcomponent_type, &
215 'PERIOD', export_pkg%param_names(iparam), '')
216
217 ! set variable input tag
218 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
219 idt)
220
221 ! export arrays
222 select case (idt%datatype)
223 case ('INTEGER1D')
224 call mem_setptr(int1d, idt%mf6varname, export_pkg%mf6_input%mempath)
225 this%var_ids%export(1) = export_pkg%varids_param(iparam, 1)
226 call nc_export_int1d(int1d, this%ncid, this%dim_ids, this%x_dim, &
227 this%y_dim, this%var_ids, this%dis, idt, &
228 export_pkg%mf6_input%mempath, nc_tag, &
229 export_pkg%mf6_input%subcomponent_name, &
230 this%gridmap_name, this%deflate, this%shuffle, &
231 this%chunk_face, kper, this%nc_fname)
232 case ('DOUBLE1D')
233 call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
234 select case (idt%shape)
235 case ('NCPL')
236 this%var_ids%export(1) = export_pkg%varids_param(iparam, 1)
237 call nc_export_dbl1d(dbl1d, this%ncid, this%dim_ids, this%x_dim, &
238 this%y_dim, this%var_ids, this%dis, idt, &
239 export_pkg%mf6_input%mempath, nc_tag, &
240 export_pkg%mf6_input%subcomponent_name, &
241 this%gridmap_name, this%deflate, this%shuffle, &
242 this%chunk_face, kper, iaux, this%nc_fname)
243 case ('NODES')
244 nvals = this%dis%nodesuser
245 allocate (nodes(nvals))
246 nodes = dnodata
247 do k = 1, this%dis%nlay
248 this%var_ids%export(k) = export_pkg%varids_param(iparam, k)
249 end do
250 call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
251 call export_pkg%user_nodes(dbl1d, nodes)
252 call nc_export_dbl1d(nodes, this%ncid, this%dim_ids, this%x_dim, &
253 this%y_dim, this%var_ids, this%dis, idt, &
254 export_pkg%mf6_input%mempath, nc_tag, &
255 export_pkg%mf6_input%subcomponent_name, &
256 this%gridmap_name, this%deflate, this%shuffle, &
257 this%chunk_face, kper, iaux, this%nc_fname)
258 deallocate (nodes)
259 case default
260 end select
261 case ('DOUBLE2D')
262 call mem_setptr(dbl2d, idt%mf6varname, export_pkg%mf6_input%mempath)
263 select case (idt%shape)
264 case ('NAUX NCPL')
265 nvals = this%dis%nrow * this%dis%ncol
266 allocate (nodes(nvals))
267 do iaux = 1, size(dbl2d, dim=1) !naux
268 if (.not. export_pkg%aux_state(iaux)) cycle
269 this%var_ids%export(1) = export_pkg%varids_aux(iaux, 1)
270 do n = 1, nvals
271 nodes(n) = dbl2d(iaux, n)
272 end do
273 call nc_export_dbl1d(nodes, this%ncid, this%dim_ids, this%x_dim, &
274 this%y_dim, this%var_ids, this%dis, idt, &
275 export_pkg%mf6_input%mempath, nc_tag, &
276 export_pkg%mf6_input%subcomponent_name, &
277 this%gridmap_name, this%deflate, this%shuffle, &
278 this%chunk_face, kper, iaux, this%nc_fname)
279 end do
280 deallocate (nodes)
281 case ('NAUX NODES')
282 nvals = this%dis%nodesuser
283 allocate (nodes(nvals))
284 do iaux = 1, size(dbl2d, dim=1) ! naux
285 if (.not. export_pkg%aux_state(iaux)) cycle
286 nodes = dnodata
287 do k = 1, this%dis%nlay
288 this%var_ids%export(k) = export_pkg%varids_aux(iaux, k)
289 end do
290 call export_pkg%user_nodes(dbl2d(iaux, :), nodes)
291 call nc_export_dbl1d(nodes, this%ncid, this%dim_ids, this%x_dim, &
292 this%y_dim, this%var_ids, this%dis, idt, &
293 export_pkg%mf6_input%mempath, nc_tag, &
294 export_pkg%mf6_input%subcomponent_name, &
295 this%gridmap_name, this%deflate, this%shuffle, &
296 this%chunk_face, kper, iaux, this%nc_fname)
297
298 end do
299 deallocate (nodes)
300 case default
301 end select
302 case default
303 ! no-op, no other datatypes exported
304 end select
305 end do
306
307 ! write to time coordinate variable
308 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
309 totim, start=(/kper/)), &
310 this%nc_fname)
311
312 ! write stress period time bounds; the period start is also the end
313 ! of the previous period
314 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time_bnds, &
315 (/totim, totim + perlen(kper)/), &
316 start=(/1, kper/), count=(/2, 1/)), &
317 this%nc_fname)
318 if (kper > 1) then
319 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time_bnds, &
320 totim, start=(/2, kper - 1/)), &
321 this%nc_fname)
322 end if
323
324 ! synchronize file
325 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
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.
This module contains the NCModelExportModule.
Definition NCModel.f90:8
real(dp), dimension(:), pointer, public, contiguous perlen
length of each stress period
Definition tdis.f90:41
real(dp), pointer, public totim
time relative to start of simulation
Definition tdis.f90:35
Here is the call graph for this function:

◆ step()

subroutine meshdismodelmodule::step ( class(mesh2ddisexporttype), intent(inout) this)
private

Definition at line 119 of file DisNCMesh.f90.

120 use constantsmodule, only: dhnoflo
121 use tdismodule, only: totim
122 class(Mesh2dDisExportType), intent(inout) :: this
123 real(DP), dimension(:), pointer, contiguous :: dbl1d
124 integer(I4B) :: n, k, nvals, istp
125 integer(I4B), dimension(2) :: dis_shape
126 real(DP), dimension(:, :), pointer, contiguous :: dbl2d
127
128 ! initialize
129 nullify (dbl1d)
130 nullify (dbl2d)
131
132 ! set global step index
133 istp = this%istp()
134
135 dis_shape(1) = this%dis%ncol * this%dis%nrow
136 dis_shape(2) = this%dis%nlay
137
138 nvals = product(dis_shape)
139
140 ! add data to dependent variable
141 if (size(this%dis%nodeuser) < &
142 size(this%dis%nodereduced)) then
143 ! allocate nodereduced size 1d array
144 allocate (dbl1d(size(this%dis%nodereduced)))
145
146 ! initialize DHNOFLO for non-active cells
147 dbl1d = dhnoflo
148
149 ! update active cells
150 do n = 1, size(this%dis%nodereduced)
151 if (this%dis%nodereduced(n) > 0) then
152 dbl1d(n) = this%x(this%dis%nodereduced(n))
153 end if
154 end do
155
156 dbl2d(1:dis_shape(1), 1:dis_shape(2)) => dbl1d(1:nvals)
157 else
158 dbl2d(1:dis_shape(1), 1:dis_shape(2)) => this%x(1:nvals)
159 end if
160
161 do k = 1, this%dis%nlay
162 ! extend array with step data
163 call nf_verify(nf90_put_var(this%ncid, &
164 this%var_ids%dependent(k), dbl2d(:, k), &
165 start=(/1, istp/), &
166 count=(/(this%dis%ncol * this%dis%nrow), 1/)), &
167 this%nc_fname)
168 end do
169
170 ! write to time coordinate variable
171 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
172 totim, start=(/istp/)), &
173 this%nc_fname)
174 ! update file
175 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
176
177 ! cleanup
178 if (associated(dbl1d)) deallocate (dbl1d)
179 nullify (dbl1d)
180 nullify (dbl2d)
real(dp), parameter dhnoflo
real no flow constant
Definition Constants.f90:93
Here is the call graph for this function: