MODFLOW 6  version 6.7.0.dev2
USGS Modular Hydrologic Model
disncstructuredmodule Module Reference

This module contains the DisNCStructuredModule. More...

Data Types

type  structuredncdimidtype
 
type  structuredncvaridtype
 
type  disncstructuredtype
 
interface  nc_export_array
 

Functions/Subroutines

subroutine dis_export_init (this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
 netcdf export dis init More...
 
subroutine dis_export_destroy (this)
 netcdf export dis destroy More...
 
subroutine df (this)
 netcdf export define More...
 
subroutine df_export (this)
 define timeseries input variables More...
 
subroutine step (this)
 netcdf export step More...
 
subroutine export_input_array (this, pkgtype, pkgname, mempath, idt)
 netcdf export an input array More...
 
subroutine export_df (this, export_pkg)
 define export package More...
 
subroutine create_timeseries (this, idt, iparam, iaux, export_pkg)
 create timeseries export variable More...
 
subroutine export_input_arrays (this, pkgtype, pkgname, mempath, param_dfns)
 write package gridded input data More...
 
subroutine package_step (this, export_pkg)
 netcdf export package dynamic input More...
 
subroutine add_pkg_data (this)
 determine packages to write gridded input More...
 
subroutine add_global_att (this)
 create file (group) attributes More...
 
subroutine define_dim (this)
 netcdf export define dimensions More...
 
subroutine define_dependent (this)
 create the model layer dependent variables More...
 
subroutine define_gridmap (this)
 create the file grid mapping container variable More...
 
subroutine define_geocoords (this)
 define grid projection variables More...
 
subroutine add_proj_data (this)
 add grid projection data More...
 
subroutine add_grid_data (this)
 add grid coordinates More...
 
subroutine ncvar_chunk2d (ncid, varid, chunk_x, chunk_y, nc_fname)
 define 2d variable chunking More...
 
subroutine ncvar_chunk3d (ncid, varid, chunk_x, chunk_y, chunk_z, nc_fname)
 define 3d variable chunking More...
 
subroutine ncvar_deflate (ncid, varid, deflate, shuffle, nc_fname)
 define variable compression More...
 
subroutine ncvar_gridmap (ncid, varid, gridmap_name, latlon, nc_fname)
 put variable gridmap attributes More...
 
subroutine ncvar_mf6attr (ncid, varid, iaux, nc_tag, nc_fname)
 put variable internal modflow6 attributes More...
 
subroutine nc_export_int1d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, nc_fname)
 netcdf export 1D integer More...
 
subroutine nc_export_int2d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
 netcdf export 2D integer More...
 
subroutine nc_export_int3d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
 netcdf export 3D integer More...
 
subroutine nc_export_dbl1d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, iaux, nc_fname)
 netcdf export 1D double More...
 
subroutine nc_export_dbl2d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
 netcdf export 2D double More...
 
subroutine nc_export_dbl3d (p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
 netcdf export 3D double More...
 

Detailed Description

This module defines a STRUCTURED (non-ugrid) netcdf export type for DIS models. It is dependent on netcdf libraries.

Function/Subroutine Documentation

◆ add_global_att()

subroutine disncstructuredmodule::add_global_att ( class(disncstructuredtype), intent(inout)  this)

Definition at line 720 of file DisNCStructured.f90.

721  class(DisNCStructuredType), intent(inout) :: this
722  ! file scoped title
723  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'title', &
724  this%annotation%title), this%nc_fname)
725  ! source (MODFLOW 6)
726  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'source', &
727  this%annotation%source), this%nc_fname)
728  ! grid type (MODFLOW 6)
729  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow_grid', &
730  this%annotation%grid), this%nc_fname)
731  ! MODFLOW 6 model type
732  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow_model', &
733  this%annotation%model), this%nc_fname)
734  ! generation datetime
735  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'history', &
736  this%annotation%history), this%nc_fname)
737  ! supported conventions
738  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'Conventions', &
739  this%annotation%conventions), &
740  this%nc_fname)
Here is the call graph for this function:

◆ add_grid_data()

subroutine disncstructuredmodule::add_grid_data ( class(disncstructuredtype), intent(inout)  this)
private

Definition at line 949 of file DisNCStructured.f90.

950  class(DisNCStructuredType), intent(inout) :: this
951  integer(I4B) :: ibnd, n !, k, i, j
952  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
953  real(DP), dimension(:), allocatable :: x, y
954  real(DP) :: xoff, yoff
955 
956  if (this%dis%angrot /= dzero) then
957  xoff = dzero
958  yoff = dzero
959  else
960  xoff = this%dis%xorigin
961  yoff = this%dis%yorigin
962  end if
963 
964  allocate (x(size(this%dis%cellx)))
965  allocate (y(size(this%dis%celly)))
966 
967  do n = 1, size(this%dis%cellx)
968  x(n) = this%dis%cellx(n) + xoff
969  end do
970 
971  do n = 1, size(this%dis%celly)
972  y(n) = this%dis%celly(n) + yoff
973  end do
974 
975  call nf_verify(nf90_put_var(this%ncid, this%var_ids%x, x), &
976  this%nc_fname)
977  call nf_verify(nf90_put_var(this%ncid, this%var_ids%y, y), &
978  this%nc_fname)
979  ! TODO see cf-conventions 4.3.3. Parametric Vertical Coordinate
980  call nf_verify(nf90_put_var(this%ncid, this%var_ids%z, this%layers), &
981  this%nc_fname)
982 
983  deallocate (x)
984  deallocate (y)
985 
986  ! bounds x
987  allocate (dbl2d(2, size(this%dis%cellx)))
988  ibnd = 1
989  do n = 1, size(this%dis%cellx)
990  if (ibnd == 1) then
991  dbl2d(1, ibnd) = xoff
992  dbl2d(2, ibnd) = xoff + this%dis%delr(ibnd)
993  else
994  dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) + this%dis%delr(ibnd)
995  dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) + this%dis%delr(ibnd)
996  end if
997  ibnd = ibnd + 1
998  end do
999  call nf_verify(nf90_put_var(this%ncid, this%var_ids%x_bnds, dbl2d), &
1000  this%nc_fname)
1001  deallocate (dbl2d)
1002 
1003  ! bounds y
1004  allocate (dbl2d(2, size(this%dis%celly)))
1005  ibnd = 1
1006  do n = size(this%dis%celly), 1, -1
1007  if (ibnd == 1) then
1008  dbl2d(1, ibnd) = yoff + sum(this%dis%delc) - this%dis%delc(n)
1009  dbl2d(2, ibnd) = yoff + sum(this%dis%delc)
1010  else
1011  dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) - this%dis%delc(n)
1012  dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) - this%dis%delc(n)
1013  end if
1014  ibnd = ibnd + 1
1015  end do
1016  call nf_verify(nf90_put_var(this%ncid, this%var_ids%y_bnds, dbl2d), &
1017  this%nc_fname)
1018  deallocate (dbl2d)
Here is the call graph for this function:

◆ add_pkg_data()

subroutine disncstructuredmodule::add_pkg_data ( class(disncstructuredtype), intent(inout)  this)

Definition at line 664 of file DisNCStructured.f90.

670  class(DisNCStructuredType), intent(inout) :: this
671  character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
672  type(CharacterStringType), dimension(:), contiguous, &
673  pointer :: pkgtypes => null()
674  type(CharacterStringType), dimension(:), contiguous, &
675  pointer :: pkgnames => null()
676  type(CharacterStringType), dimension(:), contiguous, &
677  pointer :: mempaths => null()
678  type(InputParamDefinitionType), dimension(:), pointer :: param_dfns
679  character(len=LENMEMPATH) :: input_mempath, mempath
680  integer(I4B) :: n
681  integer(I4B), pointer :: export_arrays
682  logical(LGP) :: found
683 
684  input_mempath = create_mem_path(component=this%modelname, context=idm_context)
685 
686  ! set pointers to model path package info
687  call mem_setptr(pkgtypes, 'PKGTYPES', input_mempath)
688  call mem_setptr(pkgnames, 'PKGNAMES', input_mempath)
689  call mem_setptr(mempaths, 'MEMPATHS', input_mempath)
690 
691  do n = 1, size(mempaths)
692  ! allocate export_arrays
693  allocate (export_arrays)
694  export_arrays = 0
695 
696  ! set package attributes
697  mempath = mempaths(n)
698  pname = pkgnames(n)
699  ptype = pkgtypes(n)
700 
701  ! export input arrays
702  if (mempath /= '') then
703  ! update export
704  call mem_set_value(export_arrays, 'EXPORT_NC', mempath, found)
705 
706  if (export_arrays > 0) then
707  pkgtype = idm_subcomponent_type(this%modeltype, ptype)
708  param_dfns => param_definitions(this%modeltype, pkgtype)
709  call this%export_input_arrays(ptype, pname, mempath, param_dfns)
710  end if
711  end if
712 
713  ! cleanup
714  deallocate (export_arrays)
715  end do
type(inputparamdefinitiontype) function, dimension(:), pointer, public param_definitions(component, subcomponent)
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
This module contains simulation variables.
Definition: SimVariables.f90:9
character(len=linelength) idm_context
This module contains the SourceCommonModule.
Definition: SourceCommon.f90:7
character(len=lencomponentname) function, public idm_subcomponent_type(component, subcomponent)
component from package or model type
Here is the call graph for this function:

◆ add_proj_data()

subroutine disncstructuredmodule::add_proj_data ( class(disncstructuredtype), intent(inout)  this)
private

Definition at line 930 of file DisNCStructured.f90.

931  class(DisNCStructuredType), intent(inout) :: this
932  if (this%latlon) then
933  ! lat
934  call nf_verify(nf90_put_var(this%ncid, this%var_ids%latitude, &
935  this%latitude, start=(/1, 1/), &
936  count=(/this%dis%ncol, this%dis%nrow/)), &
937  this%nc_fname)
938 
939  ! lon
940  call nf_verify(nf90_put_var(this%ncid, this%var_ids%longitude, &
941  this%longitude, start=(/1, 1/), &
942  count=(/this%dis%ncol, this%dis%nrow/)), &
943  this%nc_fname)
944  end if
Here is the call graph for this function:

◆ create_timeseries()

subroutine disncstructuredmodule::create_timeseries ( class(disncstructuredtype), intent(inout)  this,
type(inputparamdefinitiontype), intent(in), pointer  idt,
integer(i4b), intent(in)  iparam,
integer(i4b), intent(in)  iaux,
class(exportpackagetype), intent(in), pointer  export_pkg 
)

Definition at line 412 of file DisNCStructured.f90.

414  class(DisNCStructuredType), intent(inout) :: this
415  type(InputParamDefinitionType), pointer, intent(in) :: idt
416  integer(I4B), intent(in) :: iparam
417  integer(I4B), intent(in) :: iaux
418  class(ExportPackageType), pointer, intent(in) :: export_pkg
419  character(len=LINELENGTH) :: varname, longname, nc_tag
420  integer(I4B) :: varid
421 
422  ! set variable input tag
423  nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
424  idt)
425 
426  ! set names
427  varname = export_varname(export_pkg%mf6_input%subcomponent_name, &
428  idt%tagname, export_pkg%mf6_input%mempath, &
429  iaux=iaux)
430  longname = export_longname(idt%longname, &
431  export_pkg%mf6_input%subcomponent_name, &
432  idt%tagname, export_pkg%mf6_input%mempath, &
433  iaux=iaux)
434 
435  ! create the netcdf timeseries variable
436  select case (idt%datatype)
437  case ('DOUBLE1D', 'DOUBLE2D')
438  if (idt%shape == 'NCPL' .or. &
439  idt%shape == 'NAUX NCPL') then
440  call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
441  (/this%dim_ids%x, &
442  this%dim_ids%y, &
443  this%dim_ids%time/), varid), &
444  this%nc_fname)
445  else
446  call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
447  (/this%dim_ids%x, &
448  this%dim_ids%y, &
449  this%dim_ids%z, &
450  this%dim_ids%time/), varid), &
451  this%nc_fname)
452  end if
453  call nf_verify(nf90_put_att(this%ncid, varid, &
454  '_FillValue', (/dnodata/)), &
455  this%nc_fname)
456  case ('INTEGER1D')
457  if (idt%shape == 'NCPL' .or. &
458  idt%shape == 'NAUX NCPL') then
459  call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
460  (/this%dim_ids%x, &
461  this%dim_ids%y, &
462  this%dim_ids%time/), varid), &
463  this%nc_fname)
464  else
465  call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
466  (/this%dim_ids%x, &
467  this%dim_ids%y, &
468  this%dim_ids%z, &
469  this%dim_ids%time/), varid), &
470  this%nc_fname)
471  end if
472  call nf_verify(nf90_put_att(this%ncid, varid, &
473  '_FillValue', (/nf90_fill_int/)), &
474  this%nc_fname)
475  end select
476 
477  ! apply chunking parameters
478  if (this%chunking_active) then
479  call nf_verify(nf90_def_var_chunking(this%ncid, &
480  varid, &
481  nf90_chunked, &
482  (/this%chunk_x, this%chunk_y, &
483  this%chunk_z, this%chunk_time/)), &
484  this%nc_fname)
485  end if
486 
487  ! deflate and shuffle
488  call ncvar_deflate(this%ncid, varid, this%deflate, &
489  this%shuffle, this%nc_fname)
490 
491  ! variable attributes
492  call nf_verify(nf90_put_att(this%ncid, varid, &
493  'units', this%lenunits), this%nc_fname)
494  call nf_verify(nf90_put_att(this%ncid, varid, &
495  'long_name', longname), this%nc_fname)
496 
497  ! add grid mapping and mf6 attr
498  call ncvar_gridmap(this%ncid, varid, this%gridmap_name, this%latlon, &
499  this%nc_fname)
500  call ncvar_mf6attr(this%ncid, varid, iaux, nc_tag, this%nc_fname)
501 
502  ! store variable id
503  if (idt%tagname == 'AUX') then
504  export_pkg%varids_aux(iaux, 1) = varid
505  else
506  export_pkg%varids_param(iparam, 1) = varid
507  end if
This module contains the NCModelExportModule.
Definition: NCModel.f90:8
Here is the call graph for this function:

◆ define_dependent()

subroutine disncstructuredmodule::define_dependent ( class(disncstructuredtype), intent(inout)  this)
private

Definition at line 841 of file DisNCStructured.f90.

842  use constantsmodule, only: dhnoflo
843  class(DisNCStructuredType), intent(inout) :: this
844 
845  call nf_verify(nf90_def_var(this%ncid, this%xname, nf90_double, &
846  (/this%dim_ids%x, this%dim_ids%y, &
847  this%dim_ids%z, this%dim_ids%time/), &
848  this%var_ids%dependent), &
849  this%nc_fname)
850 
851  ! apply chunking parameters
852  if (this%chunking_active) then
853  call nf_verify(nf90_def_var_chunking(this%ncid, &
854  this%var_ids%dependent, &
855  nf90_chunked, &
856  (/this%chunk_x, this%chunk_y, &
857  this%chunk_z, this%chunk_time/)), &
858  this%nc_fname)
859  end if
860 
861  ! deflate and shuffle
862  call ncvar_deflate(this%ncid, this%var_ids%dependent, this%deflate, &
863  this%shuffle, this%nc_fname)
864 
865  ! put attr
866  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
867  'units', this%lenunits), this%nc_fname)
868  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
869  'standard_name', this%annotation%stdname), &
870  this%nc_fname)
871  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, 'long_name', &
872  this%annotation%longname), this%nc_fname)
873  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, '_FillValue', &
874  (/dhnoflo/)), this%nc_fname)
875 
876  ! add grid mapping
877  call ncvar_gridmap(this%ncid, this%var_ids%dependent, this%gridmap_name, &
878  this%latlon, this%nc_fname)
This module contains simulation constants.
Definition: Constants.f90:9
real(dp), parameter dhnoflo
real no flow constant
Definition: Constants.f90:93
Here is the call graph for this function:

◆ define_dim()

subroutine disncstructuredmodule::define_dim ( class(disncstructuredtype), intent(inout)  this)
private

Definition at line 745 of file DisNCStructured.f90.

746  class(DisNCStructuredType), intent(inout) :: this
747 
748  ! bound dim
749  call nf_verify(nf90_def_dim(this%ncid, 'bnd', 2, this%dim_ids%bnd), &
750  this%nc_fname)
751 
752  ! Time
753  call nf_verify(nf90_def_dim(this%ncid, 'time', this%totnstp, &
754  this%dim_ids%time), this%nc_fname)
755  call nf_verify(nf90_def_var(this%ncid, 'time', nf90_double, &
756  this%dim_ids%time, this%var_ids%time), &
757  this%nc_fname)
758  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'calendar', &
759  'standard'), this%nc_fname)
760  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'units', &
761  this%datetime), this%nc_fname)
762  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'axis', 'T'), &
763  this%nc_fname)
764  !call nf_verify(nf90_put_att(ncid, var_ids%time, 'bounds', 'time_bnds'), this%nc_fname)
765  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'standard_name', &
766  'time'), this%nc_fname)
767  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'long_name', &
768  'time'), this%nc_fname)
769 
770  ! Z dimension
771  call nf_verify(nf90_def_dim(this%ncid, 'z', this%dis%nlay, this%dim_ids%z), &
772  this%nc_fname)
773  call nf_verify(nf90_def_var(this%ncid, 'z', nf90_double, this%dim_ids%z, &
774  this%var_ids%z), this%nc_fname)
775  call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'units', 'layer'), &
776  this%nc_fname)
777  call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'long_name', &
778  'layer number'), this%nc_fname)
779  !call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'bounds', 'z_bnds'), &
780  ! this%nc_fname)
781  !call nf_verify(nf90_def_var(this%ncid, 'z_bnds', NF90_DOUBLE, &
782  ! (/this%dim_ids%bnd, this%dim_ids%z/), &
783  ! this%var_ids%z_bnds), this%nc_fname)
784  !call nf_verify(nf90_put_var(this%ncid, this%var_ids%z_bnds, &
785  ! this%elev_bnds), this%nc_fname)
786 
787  ! Y dimension
788  call nf_verify(nf90_def_dim(this%ncid, 'y', this%dis%nrow, this%dim_ids%y), &
789  this%nc_fname)
790  call nf_verify(nf90_def_var(this%ncid, 'y', nf90_double, this%dim_ids%y, &
791  this%var_ids%y), this%nc_fname)
792  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'units', &
793  this%lenunits), this%nc_fname)
794  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'axis', 'Y'), &
795  this%nc_fname)
796  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'standard_name', &
797  'projection_y_coordinate'), this%nc_fname)
798  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'long_name', &
799  'Northing'), this%nc_fname)
800  if (this%wkt /= '') then
801  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'grid_mapping', &
802  this%gridmap_name), this%nc_fname)
803  end if
804  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'bounds', 'y_bnds'), &
805  this%nc_fname)
806  call nf_verify(nf90_def_var(this%ncid, 'y_bnds', nf90_double, &
807  (/this%dim_ids%bnd, this%dim_ids%y/), &
808  this%var_ids%y_bnds), this%nc_fname)
809 
810  ! X dimension
811  call nf_verify(nf90_def_dim(this%ncid, 'x', this%dis%ncol, this%dim_ids%x), &
812  this%nc_fname)
813  call nf_verify(nf90_def_var(this%ncid, 'x', nf90_double, this%dim_ids%x, &
814  this%var_ids%x), this%nc_fname)
815  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'units', &
816  this%lenunits), this%nc_fname)
817  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'axis', 'X'), &
818  this%nc_fname)
819  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'standard_name', &
820  'projection_x_coordinate'), this%nc_fname)
821  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'long_name', &
822  'Easting'), this%nc_fname)
823  if (this%wkt /= '') then
824  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'grid_mapping', &
825  this%gridmap_name), this%nc_fname)
826  end if
827  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'bounds', 'x_bnds'), &
828  this%nc_fname)
829  call nf_verify(nf90_def_var(this%ncid, 'x_bnds', nf90_double, &
830  (/this%dim_ids%bnd, this%dim_ids%x/), &
831  this%var_ids%x_bnds), this%nc_fname)
832 
833  ! NCPL dimension
834  call nf_verify(nf90_def_dim(this%ncid, 'ncpl', &
835  this%dis%ncol * this%dis%nrow, &
836  this%dim_ids%ncpl), this%nc_fname)
Here is the call graph for this function:

◆ define_geocoords()

subroutine disncstructuredmodule::define_geocoords ( class(disncstructuredtype), intent(inout)  this)
private

Definition at line 901 of file DisNCStructured.f90.

902  class(DisNCStructuredType), intent(inout) :: this
903  if (this%latlon) then
904  ! lat
905  call nf_verify(nf90_def_var(this%ncid, 'lat', nf90_double, &
906  (/this%dim_ids%x, this%dim_ids%y/), &
907  this%var_ids%latitude), this%nc_fname)
908  call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
909  'units', 'degrees_north'), this%nc_fname)
910  call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
911  'standard_name', 'latitude'), this%nc_fname)
912  call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
913  'long_name', 'latitude'), this%nc_fname)
914 
915  ! lon
916  call nf_verify(nf90_def_var(this%ncid, 'lon', nf90_double, &
917  (/this%dim_ids%x, this%dim_ids%y/), &
918  this%var_ids%longitude), this%nc_fname)
919  call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
920  'units', 'degrees_east'), this%nc_fname)
921  call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
922  'standard_name', 'longitude'), this%nc_fname)
923  call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
924  'long_name', 'longitude'), this%nc_fname)
925  end if
Here is the call graph for this function:

◆ define_gridmap()

subroutine disncstructuredmodule::define_gridmap ( class(disncstructuredtype), intent(inout)  this)

Definition at line 883 of file DisNCStructured.f90.

884  class(DisNCStructuredType), intent(inout) :: this
885  integer(I4B) :: var_id
886  if (this%wkt /= '') then
887  call nf_verify(nf90_redef(this%ncid), this%nc_fname)
888  call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
889  var_id), this%nc_fname)
890  ! TODO: consider variants epsg_code, spatial_ref, esri_pe_string, wkt, etc
891  call nf_verify(nf90_put_att(this%ncid, var_id, 'crs_wkt', this%wkt), &
892  this%nc_fname)
893  call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
894  call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
895  this%nc_fname)
896  end if
Here is the call graph for this function:

◆ df()

subroutine disncstructuredmodule::df ( class(disncstructuredtype), intent(inout)  this)
private

Definition at line 212 of file DisNCStructured.f90.

213  use constantsmodule, only: mvalidate
214  use simvariablesmodule, only: isim_mode
215  class(DisNCStructuredType), intent(inout) :: this
216  ! put root group file scope attributes
217  call this%add_global_att()
218  ! define root group dimensions and coordinate variables
219  call this%define_dim()
220  ! define grid projection variables
221  call this%define_geocoords()
222  if (isim_mode /= mvalidate) then
223  ! define the dependent variable
224  call this%define_dependent()
225  end if
226  ! define period input arrays
227  call this%df_export()
228  ! exit define mode
229  call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
230  ! add data locations
231  call this%add_grid_data()
232  ! add projection data
233  call this%add_proj_data()
234  ! define and set package input griddata
235  call this%add_pkg_data()
236  ! define and set gridmap variable
237  call this%define_gridmap()
238  ! synchronize file
239  call nf_verify(nf90_sync(this%ncid), this%nc_fname)
@ mvalidate
validation mode - do not run time steps
Definition: Constants.f90:205
integer(i4b) isim_mode
simulation mode
Here is the call graph for this function:

◆ df_export()

subroutine disncstructuredmodule::df_export ( class(disncstructuredtype), intent(inout)  this)

Definition at line 244 of file DisNCStructured.f90.

246  class(DisNCStructuredType), intent(inout) :: this
247  class(ExportPackageType), pointer :: export_pkg
248  integer(I4B) :: idx
249  do idx = 1, this%pkglist%Count()
250  export_pkg => this%get(idx)
251  call this%export_df(export_pkg)
252  end do

◆ dis_export_destroy()

subroutine disncstructuredmodule::dis_export_destroy ( class(disncstructuredtype), intent(inout)  this)

Definition at line 196 of file DisNCStructured.f90.

197  class(DisNCStructuredType), intent(inout) :: this
198  call nf_verify(nf90_close(this%ncid), this%nc_fname)
199  deallocate (this%chunk_z)
200  deallocate (this%chunk_y)
201  deallocate (this%chunk_x)
202  deallocate (this%layers)
203  nullify (this%chunk_z)
204  nullify (this%chunk_y)
205  nullify (this%chunk_x)
206  ! destroy base class
207  call this%NCModelExportType%destroy()
Here is the call graph for this function:

◆ dis_export_init()

subroutine disncstructuredmodule::dis_export_init ( class(disncstructuredtype), 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 
)
private

Definition at line 96 of file DisNCStructured.f90.

100  class(DisNCStructuredType), intent(inout) :: this
101  character(len=*), intent(in) :: modelname
102  character(len=*), intent(in) :: modeltype
103  character(len=*), intent(in) :: modelfname
104  character(len=*), intent(in) :: nc_fname
105  integer(I4B), intent(in) :: disenum
106  integer(I4B), intent(in) :: nctype
107  integer(I4B), intent(in) :: iout
108  integer(I4B) :: k, latsz, lonsz
109  logical(LGP) :: found
110 
111  ! set nlay
112  this%nlay = this%dis%nlay
113 
114  ! allocate
115  allocate (this%chunk_z)
116  allocate (this%chunk_y)
117  allocate (this%chunk_x)
118  allocate (this%layers(this%nlay))
119 
120  ! initialize
121  this%chunk_z = -1
122  this%chunk_y = -1
123  this%chunk_x = -1
124  do k = 1, this%nlay
125  this%layers(k) = k
126  end do
127 
128  this%latlon = .false.
129 
130  ! initialize base class
131  call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
132  disenum, nctype, iout)
133 
134  ! update values from input context
135  if (this%ncf_mempath /= '') then
136  call mem_set_value(this%chunk_z, 'CHUNK_Z', this%ncf_mempath, found)
137  call mem_set_value(this%chunk_y, 'CHUNK_Y', this%ncf_mempath, found)
138  call mem_set_value(this%chunk_x, 'CHUNK_X', this%ncf_mempath, found)
139 
140  if (this%chunk_time > 0 .and. this%chunk_z > 0 .and. &
141  this%chunk_y > 0 .and. this%chunk_x > 0) then
142  this%chunking_active = .true.
143  else if (this%chunk_time > 0 .or. this%chunk_z > 0 .or. &
144  this%chunk_y > 0 .or. this%chunk_x > 0) then
145  this%chunk_time = -1
146  this%chunk_z = -1
147  this%chunk_y = -1
148  this%chunk_x = -1
149  write (warnmsg, '(a)') 'Ignoring user provided NetCDF chunking &
150  &parameters. Define chunk_time, chunk_x, chunk_y and chunk_z input &
151  &parameters to see an effect in file "'//trim(nc_fname)//'".'
152  call store_warning(warnmsg)
153  end if
154 
155  call get_isize('LATITUDE', this%ncf_mempath, latsz)
156  call get_isize('LONGITUDE', this%ncf_mempath, lonsz)
157 
158  if (latsz > 0 .and. lonsz > 0) then
159  this%latlon = .true.
160  if (this%wkt /= '') then
161  write (warnmsg, '(a)') 'Ignoring user provided NetCDF wkt parameter &
162  &as longitude and latitude arrays have been provided. &
163  &Applies to file "'//trim(nc_fname)//'".'
164  call store_warning(warnmsg)
165  this%wkt = ''
166  this%gridmap_name = ''
167  end if
168  call mem_setptr(this%latitude, 'LATITUDE', this%ncf_mempath)
169  call mem_setptr(this%longitude, 'LONGITUDE', this%ncf_mempath)
170  end if
171 
172  if (this%wkt /= '') then
173  if (this%dis%angrot /= dzero) then
174  write (warnmsg, '(a)') 'WKT parameter set with structured rotated &
175  &grid. Projected coordinates will have grid local values. &
176  &Applies to file "'//trim(nc_fname)//'".'
177  call store_warning(warnmsg)
178  end if
179  end if
180  end if
181 
182  if (this%dis%lenuni == 1) then
183  this%lenunits = 'ft'
184  else
185  this%lenunits = 'm'
186  end if
187 
188  ! create the netcdf file
189  call nf_verify(nf90_create(this%nc_fname, &
190  ior(nf90_clobber, nf90_netcdf4), this%ncid), &
191  this%nc_fname)
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
Here is the call graph for this function:

◆ export_df()

subroutine disncstructuredmodule::export_df ( class(disncstructuredtype), intent(inout)  this,
class(exportpackagetype), intent(in), pointer  export_pkg 
)
private

Definition at line 380 of file DisNCStructured.f90.

383  class(DisNCStructuredType), intent(inout) :: this
384  class(ExportPackageType), pointer, intent(in) :: export_pkg
385  type(InputParamDefinitionType), pointer :: idt
386  integer(I4B) :: iparam, iaux
387 
388  ! export defined period input
389  do iparam = 1, export_pkg%nparam
390  ! initialize
391  iaux = 0
392  ! set input definition
393  idt => &
394  get_param_definition_type(export_pkg%mf6_input%param_dfns, &
395  export_pkg%mf6_input%component_type, &
396  export_pkg%mf6_input%subcomponent_type, &
397  'PERIOD', export_pkg%param_names(iparam), '')
398  select case (idt%shape)
399  case ('NCPL', 'NODES')
400  call this%create_timeseries(idt, iparam, iaux, export_pkg)
401  case ('NAUX NCPL', 'NAUX NODES')
402  do iaux = 1, export_pkg%naux
403  call this%create_timeseries(idt, iparam, iaux, export_pkg)
404  end do
405  case default
406  end select
407  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)
Return parameter definition.
Here is the call graph for this function:

◆ export_input_array()

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

Definition at line 308 of file DisNCStructured.f90.

309  class(DisNCStructuredType), intent(inout) :: this
310  character(len=*), intent(in) :: pkgtype
311  character(len=*), intent(in) :: pkgname
312  character(len=*), intent(in) :: mempath
313  type(InputParamDefinitionType), pointer, intent(in) :: idt
314  integer(I4B), dimension(:), pointer, contiguous :: int1d
315  integer(I4B), dimension(:, :), pointer, contiguous :: int2d
316  integer(I4B), dimension(:, :, :), pointer, contiguous :: int3d
317  real(DP), dimension(:), pointer, contiguous :: dbl1d
318  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
319  real(DP), dimension(:, :, :), pointer, contiguous :: dbl3d
320  character(len=LINELENGTH) :: nc_tag
321  integer(I4B) :: iper, iaux
322 
323  ! initialize
324  iper = 0
325  iaux = 0
326 
327  ! set variable name and input attribute string
328  nc_tag = this%input_attribute(pkgname, idt)
329 
330  select case (idt%datatype)
331  case ('INTEGER1D')
332  call mem_setptr(int1d, idt%mf6varname, mempath)
333  call nc_export_array(int1d, this%ncid, this%dim_ids, this%var_ids, &
334  this%dis, idt, mempath, nc_tag, pkgname, &
335  this%gridmap_name, this%latlon, this%deflate, &
336  this%shuffle, this%chunk_z, this%chunk_y, &
337  this%chunk_x, iper, this%nc_fname)
338  case ('INTEGER2D')
339  call mem_setptr(int2d, idt%mf6varname, mempath)
340  call nc_export_array(int2d, this%ncid, this%dim_ids, this%var_ids, &
341  this%dis, idt, mempath, nc_tag, pkgname, &
342  this%gridmap_name, this%latlon, this%deflate, &
343  this%shuffle, this%chunk_z, this%chunk_y, &
344  this%chunk_x, this%nc_fname)
345  case ('INTEGER3D')
346  call mem_setptr(int3d, idt%mf6varname, mempath)
347  call nc_export_array(int3d, this%ncid, this%dim_ids, this%var_ids, &
348  this%dis, idt, mempath, nc_tag, pkgname, &
349  this%gridmap_name, this%latlon, this%deflate, &
350  this%shuffle, this%chunk_z, this%chunk_y, &
351  this%chunk_x, this%nc_fname)
352  case ('DOUBLE1D')
353  call mem_setptr(dbl1d, idt%mf6varname, mempath)
354  call nc_export_array(dbl1d, this%ncid, this%dim_ids, this%var_ids, &
355  this%dis, idt, mempath, nc_tag, pkgname, &
356  this%gridmap_name, this%latlon, this%deflate, &
357  this%shuffle, this%chunk_z, this%chunk_y, &
358  this%chunk_x, iper, iaux, this%nc_fname)
359  case ('DOUBLE2D')
360  call mem_setptr(dbl2d, idt%mf6varname, mempath)
361  call nc_export_array(dbl2d, this%ncid, this%dim_ids, this%var_ids, &
362  this%dis, idt, mempath, nc_tag, pkgname, &
363  this%gridmap_name, this%latlon, this%deflate, &
364  this%shuffle, this%chunk_z, this%chunk_y, &
365  this%chunk_x, this%nc_fname)
366  case ('DOUBLE3D')
367  call mem_setptr(dbl3d, idt%mf6varname, mempath)
368  call nc_export_array(dbl3d, this%ncid, this%dim_ids, this%var_ids, &
369  this%dis, idt, mempath, nc_tag, pkgname, &
370  this%gridmap_name, this%latlon, this%deflate, &
371  this%shuffle, this%chunk_z, this%chunk_y, &
372  this%chunk_x, this%nc_fname)
373  case default
374  ! no-op, no other datatypes exported
375  end select

◆ export_input_arrays()

subroutine disncstructuredmodule::export_input_arrays ( class(disncstructuredtype), 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 
)

Definition at line 512 of file DisNCStructured.f90.

513  use memorymanagermodule, only: get_isize
514  class(DisNCStructuredType), intent(inout) :: this
515  character(len=*), intent(in) :: pkgtype
516  character(len=*), intent(in) :: pkgname
517  character(len=*), intent(in) :: mempath
518  type(InputParamDefinitionType), dimension(:), pointer, &
519  intent(in) :: param_dfns
520  type(InputParamDefinitionType), pointer :: idt
521  integer(I4B) :: iparam, isize
522  do iparam = 1, size(param_dfns)
523  ! assign param definition pointer
524  idt => param_dfns(iparam)
525  ! for now only griddata is exported
526  if (idt%blockname == 'GRIDDATA') then
527  ! check if variable is already allocated
528  call get_isize(idt%mf6varname, mempath, isize)
529  if (isize > 0) then
530  call this%export_input_array(pkgtype, pkgname, mempath, idt)
531  end if
532  end if
533  end do
Here is the call graph for this function:

◆ nc_export_dbl1d()

subroutine disncstructuredmodule::nc_export_dbl1d ( real(dp), dimension(:), intent(in), pointer, contiguous  p_mem,
integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
type(inputparamdefinitiontype), intent(in), pointer  idt,
character(len=*), intent(in)  mempath,
character(len=*), intent(in)  nc_tag,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  gridmap_name,
logical(lgp), intent(in)  latlon,
integer(i4b), intent(in)  deflate,
integer(i4b), intent(in)  shuffle,
integer(i4b), intent(in)  chunk_z,
integer(i4b), intent(in)  chunk_y,
integer(i4b), intent(in)  chunk_x,
integer(i4b), intent(in)  iper,
integer(i4b), intent(in)  iaux,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1334 of file DisNCStructured.f90.

1338  use netcdfcommonmodule, only: ixstp
1339  real(DP), dimension(:), pointer, contiguous, intent(in) :: p_mem
1340  integer(I4B), intent(in) :: ncid
1341  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1342  type(StructuredNCVarIdType), intent(inout) :: var_ids
1343  type(DisType), pointer, intent(in) :: dis
1344  type(InputParamDefinitionType), pointer, intent(in) :: idt
1345  character(len=*), intent(in) :: mempath
1346  character(len=*), intent(in) :: nc_tag
1347  character(len=*), intent(in) :: pkgname
1348  character(len=*), intent(in) :: gridmap_name
1349  logical(LGP), intent(in) :: latlon
1350  integer(I4B), intent(in) :: deflate
1351  integer(I4B), intent(in) :: shuffle
1352  integer(I4B), intent(in) :: chunk_z
1353  integer(I4B), intent(in) :: chunk_y
1354  integer(I4B), intent(in) :: chunk_x
1355  integer(I4B), intent(in) :: iper
1356  integer(I4B), intent(in) :: iaux
1357  character(len=*), intent(in) :: nc_fname
1358  integer(I4B) :: var_id, axis_sz, istp
1359  character(len=LINELENGTH) :: varname, longname
1360 
1361  if (idt%shape == 'NROW' .or. &
1362  idt%shape == 'NCOL' .or. &
1363  idt%shape == 'NCPL' .or. &
1364  idt%shape == 'NAUX NCPL') then
1365 
1366  if (iper == 0) then
1367  select case (idt%shape)
1368  case ('NROW')
1369  axis_sz = dim_ids%y
1370  case ('NCOL')
1371  axis_sz = dim_ids%x
1372  case ('NCPL', 'NAUX NCPL')
1373  axis_sz = dim_ids%ncpl
1374  end select
1375 
1376  varname = export_varname(pkgname, idt%tagname, mempath)
1377  longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1378  iaux=iaux)
1379 
1380  ! reenter define mode and create variable
1381  call nf_verify(nf90_redef(ncid), nc_fname)
1382  call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1383  (/axis_sz/), var_id), &
1384  nc_fname)
1385 
1386  ! NROW/NCOL shapes use default chunking
1387  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1388 
1389  ! put attr
1390  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1391  (/nf90_fill_double/)), nc_fname)
1392  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1393  longname), nc_fname)
1394 
1395  ! add mf6 attr
1396  call ncvar_mf6attr(ncid, var_id, iaux, nc_tag, nc_fname)
1397 
1398  ! exit define mode and write data
1399  call nf_verify(nf90_enddef(ncid), nc_fname)
1400  call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1401  nc_fname)
1402  else
1403  ! timeseries
1404  istp = ixstp()
1405  call nf_verify(nf90_put_var(ncid, &
1406  var_ids%export, p_mem, &
1407  start=(/1, istp/), &
1408  count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1409  end if
1410 
1411  else
1412 
1413  if (iper == 0) then
1414  varname = export_varname(pkgname, idt%tagname, mempath, iaux=iaux)
1415  longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1416  iaux=iaux)
1417 
1418  ! reenter define mode and create variable
1419  call nf_verify(nf90_redef(ncid), nc_fname)
1420  call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1421  (/dim_ids%x, dim_ids%y, dim_ids%z/), &
1422  var_id), nc_fname)
1423 
1424  ! apply chunking parameters
1425  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1426  ! deflate and shuffle
1427  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1428 
1429  ! put attr
1430  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1431  (/nf90_fill_double/)), nc_fname)
1432  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1433  longname), nc_fname)
1434 
1435  ! add grid mapping and mf6 attr
1436  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1437  call ncvar_mf6attr(ncid, var_id, iaux, nc_tag, nc_fname)
1438 
1439  ! exit define mode and write data
1440  call nf_verify(nf90_enddef(ncid), nc_fname)
1441  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1442  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1443  nc_fname)
1444  else
1445  ! timeseries
1446  istp = ixstp()
1447  call nf_verify(nf90_put_var(ncid, &
1448  var_ids%export, p_mem, &
1449  start=(/1, 1, 1, istp/), &
1450  count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1451  nc_fname)
1452  end if
1453  end if
This module contains the NetCDFCommonModule.
Definition: NetCDFCommon.f90:6
integer(i4b) function, public ixstp()
step index for timeseries data

◆ nc_export_dbl2d()

subroutine disncstructuredmodule::nc_export_dbl2d ( real(dp), dimension(:, :), intent(in), pointer, contiguous  p_mem,
integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
type(inputparamdefinitiontype), intent(in), pointer  idt,
character(len=*), intent(in)  mempath,
character(len=*), intent(in)  nc_tag,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  gridmap_name,
logical(lgp), intent(in)  latlon,
integer(i4b), intent(in)  deflate,
integer(i4b), intent(in)  shuffle,
integer(i4b), intent(in)  chunk_z,
integer(i4b), intent(in)  chunk_y,
integer(i4b), intent(in)  chunk_x,
character(len=*), intent(in)  nc_fname 
)

Definition at line 1458 of file DisNCStructured.f90.

1461  real(DP), dimension(:, :), pointer, contiguous, intent(in) :: p_mem
1462  integer(I4B), intent(in) :: ncid
1463  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1464  type(StructuredNCVarIdType), intent(inout) :: var_ids
1465  type(DisType), pointer, intent(in) :: dis
1466  type(InputParamDefinitionType), pointer, intent(in) :: idt
1467  character(len=*), intent(in) :: mempath
1468  character(len=*), intent(in) :: nc_tag
1469  character(len=*), intent(in) :: pkgname
1470  character(len=*), intent(in) :: gridmap_name
1471  logical(LGP), intent(in) :: latlon
1472  integer(I4B), intent(in) :: deflate
1473  integer(I4B), intent(in) :: shuffle
1474  integer(I4B), intent(in) :: chunk_z
1475  integer(I4B), intent(in) :: chunk_y
1476  integer(I4B), intent(in) :: chunk_x
1477  character(len=*), intent(in) :: nc_fname
1478  character(len=LINELENGTH) :: varname
1479  integer(I4B) :: var_id
1480 
1481  varname = export_varname(pkgname, idt%tagname, mempath)
1482 
1483  ! reenter define mode and create variable
1484  call nf_verify(nf90_redef(ncid), nc_fname)
1485  call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1486  (/dim_ids%x, dim_ids%y/), var_id), &
1487  nc_fname)
1488 
1489  ! apply chunking parameters
1490  call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1491  ! deflate and shuffle
1492  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1493 
1494  ! put attr
1495  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1496  (/nf90_fill_double/)), nc_fname)
1497  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1498  idt%longname), nc_fname)
1499 
1500  ! add grid mapping and mf6 attr
1501  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1502  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1503 
1504  ! exit define mode and write data
1505  call nf_verify(nf90_enddef(ncid), nc_fname)
1506  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1507  count=(/dis%ncol, dis%nrow/)), &
1508  nc_fname)

◆ nc_export_dbl3d()

subroutine disncstructuredmodule::nc_export_dbl3d ( real(dp), dimension(:, :, :), intent(in), pointer, contiguous  p_mem,
integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
type(inputparamdefinitiontype), intent(in), pointer  idt,
character(len=*), intent(in)  mempath,
character(len=*), intent(in)  nc_tag,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  gridmap_name,
logical(lgp), intent(in)  latlon,
integer(i4b), intent(in)  deflate,
integer(i4b), intent(in)  shuffle,
integer(i4b), intent(in)  chunk_z,
integer(i4b), intent(in)  chunk_y,
integer(i4b), intent(in)  chunk_x,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1513 of file DisNCStructured.f90.

1516  real(DP), dimension(:, :, :), pointer, contiguous, intent(in) :: p_mem
1517  integer(I4B), intent(in) :: ncid
1518  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1519  type(StructuredNCVarIdType), intent(inout) :: var_ids
1520  type(DisType), pointer, intent(in) :: dis
1521  type(InputParamDefinitionType), pointer, intent(in) :: idt
1522  character(len=*), intent(in) :: mempath
1523  character(len=*), intent(in) :: nc_tag
1524  character(len=*), intent(in) :: pkgname
1525  character(len=*), intent(in) :: gridmap_name
1526  logical(LGP), intent(in) :: latlon
1527  integer(I4B), intent(in) :: deflate
1528  integer(I4B), intent(in) :: shuffle
1529  integer(I4B), intent(in) :: chunk_z
1530  integer(I4B), intent(in) :: chunk_y
1531  integer(I4B), intent(in) :: chunk_x
1532  character(len=*), intent(in) :: nc_fname
1533  integer(I4B) :: var_id
1534  character(len=LINELENGTH) :: varname, longname
1535 
1536  varname = export_varname(pkgname, idt%tagname, mempath)
1537  longname = export_longname(idt%longname, pkgname, idt%tagname, mempath)
1538 
1539  ! reenter define mode and create variable
1540  call nf_verify(nf90_redef(ncid), nc_fname)
1541  call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1542  (/dim_ids%x, dim_ids%y, dim_ids%z/), var_id), &
1543  nc_fname)
1544 
1545  ! apply chunking parameters
1546  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1547  ! deflate and shuffle
1548  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1549 
1550  ! put attr
1551  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1552  (/nf90_fill_double/)), nc_fname)
1553  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1554  longname), nc_fname)
1555 
1556  ! add grid mapping and mf6 attr
1557  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1558  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1559 
1560  ! exit define mode and write data
1561  call nf_verify(nf90_enddef(ncid), nc_fname)
1562  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1563  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1564  nc_fname)

◆ nc_export_int1d()

subroutine disncstructuredmodule::nc_export_int1d ( integer(i4b), dimension(:), intent(in), pointer, contiguous  p_mem,
integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
type(inputparamdefinitiontype), intent(in), pointer  idt,
character(len=*), intent(in)  mempath,
character(len=*), intent(in)  nc_tag,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  gridmap_name,
logical(lgp), intent(in)  latlon,
integer(i4b), intent(in)  deflate,
integer(i4b), intent(in)  shuffle,
integer(i4b), intent(in)  chunk_z,
integer(i4b), intent(in)  chunk_y,
integer(i4b), intent(in)  chunk_x,
integer(i4b), intent(in)  iper,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1106 of file DisNCStructured.f90.

1109  use netcdfcommonmodule, only: ixstp
1110  integer(I4B), dimension(:), pointer, contiguous, intent(in) :: p_mem
1111  integer(I4B), intent(in) :: ncid
1112  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1113  type(StructuredNCVarIdType), intent(inout) :: var_ids
1114  type(DisType), pointer, intent(in) :: dis
1115  type(InputParamDefinitionType), pointer, intent(in) :: idt
1116  character(len=*), intent(in) :: mempath
1117  character(len=*), intent(in) :: nc_tag
1118  character(len=*), intent(in) :: pkgname
1119  character(len=*), intent(in) :: gridmap_name
1120  logical(LGP), intent(in) :: latlon
1121  integer(I4B), intent(in) :: deflate
1122  integer(I4B), intent(in) :: shuffle
1123  integer(I4B), intent(in) :: chunk_z
1124  integer(I4B), intent(in) :: chunk_y
1125  integer(I4B), intent(in) :: chunk_x
1126  integer(I4B), intent(in) :: iper
1127  character(len=*), intent(in) :: nc_fname
1128  integer(I4B) :: var_id, axis_sz, istp
1129  character(len=LINELENGTH) :: varname, longname
1130 
1131  varname = export_varname(pkgname, idt%tagname, mempath)
1132 
1133  if (idt%shape == 'NROW' .or. &
1134  idt%shape == 'NCOL' .or. &
1135  idt%shape == 'NCPL' .or. &
1136  idt%shape == 'NAUX NCPL') then
1137 
1138  if (iper == 0) then
1139  select case (idt%shape)
1140  case ('NROW')
1141  axis_sz = dim_ids%y
1142  case ('NCOL')
1143  axis_sz = dim_ids%x
1144  case ('NCPL', 'NAUX NCPL')
1145  axis_sz = dim_ids%ncpl
1146  end select
1147 
1148  longname = export_longname(idt%longname, pkgname, idt%tagname, mempath)
1149 
1150  ! reenter define mode and create variable
1151  call nf_verify(nf90_redef(ncid), nc_fname)
1152  call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1153  (/axis_sz/), var_id), &
1154  nc_fname)
1155 
1156  ! NROW/NCOL shapes use default chunking
1157  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1158 
1159  ! put attr
1160  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1161  (/nf90_fill_int/)), nc_fname)
1162  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1163  longname), nc_fname)
1164 
1165  ! add mf6 attr
1166  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1167 
1168  ! exit define mode and write data
1169  call nf_verify(nf90_enddef(ncid), nc_fname)
1170  call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1171  nc_fname)
1172  else
1173  ! timeseries
1174  istp = ixstp()
1175  call nf_verify(nf90_put_var(ncid, &
1176  var_ids%export, p_mem, &
1177  start=(/1, istp/), &
1178  count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1179  end if
1180 
1181  else
1182 
1183  if (iper == 0) then
1184  ! reenter define mode and create variable
1185  call nf_verify(nf90_redef(ncid), nc_fname)
1186  call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1187  (/dim_ids%x, dim_ids%y, dim_ids%z/), &
1188  var_id), nc_fname)
1189 
1190  ! apply chunking parameters
1191  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1192  ! deflate and shuffle
1193  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1194 
1195  ! put attr
1196  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1197  (/nf90_fill_int/)), nc_fname)
1198  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1199  idt%longname), nc_fname)
1200 
1201  ! add grid mapping and mf6 attr
1202  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1203  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1204 
1205  ! exit define mode and write data
1206  call nf_verify(nf90_enddef(ncid), nc_fname)
1207  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1208  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1209  nc_fname)
1210  else
1211  ! timeseries
1212  istp = ixstp()
1213  call nf_verify(nf90_put_var(ncid, &
1214  var_ids%export, p_mem, &
1215  start=(/1, 1, 1, istp/), &
1216  count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1217  nc_fname)
1218  end if
1219  end if

◆ nc_export_int2d()

subroutine disncstructuredmodule::nc_export_int2d ( integer(i4b), dimension(:, :), intent(in), pointer, contiguous  p_mem,
integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
type(inputparamdefinitiontype), intent(in), pointer  idt,
character(len=*), intent(in)  mempath,
character(len=*), intent(in)  nc_tag,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  gridmap_name,
logical(lgp), intent(in)  latlon,
integer(i4b), intent(in)  deflate,
integer(i4b), intent(in)  shuffle,
integer(i4b), intent(in)  chunk_z,
integer(i4b), intent(in)  chunk_y,
integer(i4b), intent(in)  chunk_x,
character(len=*), intent(in)  nc_fname 
)

Definition at line 1224 of file DisNCStructured.f90.

1227  integer(I4B), dimension(:, :), pointer, contiguous, intent(in) :: p_mem
1228  integer(I4B), intent(in) :: ncid
1229  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1230  type(StructuredNCVarIdType), intent(inout) :: var_ids
1231  type(DisType), pointer, intent(in) :: dis
1232  type(InputParamDefinitionType), pointer, intent(in) :: idt
1233  character(len=*), intent(in) :: mempath
1234  character(len=*), intent(in) :: nc_tag
1235  character(len=*), intent(in) :: pkgname
1236  character(len=*), intent(in) :: gridmap_name
1237  logical(LGP), intent(in) :: latlon
1238  integer(I4B), intent(in) :: deflate
1239  integer(I4B), intent(in) :: shuffle
1240  integer(I4B), intent(in) :: chunk_z
1241  integer(I4B), intent(in) :: chunk_y
1242  integer(I4B), intent(in) :: chunk_x
1243  character(len=*), intent(in) :: nc_fname
1244  character(len=LINELENGTH) :: varname
1245  integer(I4B) :: var_id
1246 
1247  varname = export_varname(pkgname, idt%tagname, mempath)
1248 
1249  ! reenter define mode and create variable
1250  call nf_verify(nf90_redef(ncid), nc_fname)
1251  call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1252  (/dim_ids%x, dim_ids%y/), var_id), &
1253  nc_fname)
1254 
1255  ! apply chunking parameters
1256  call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1257  ! deflate and shuffle
1258  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1259 
1260  ! put attr
1261  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1262  (/nf90_fill_int/)), nc_fname)
1263  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1264  idt%longname), nc_fname)
1265 
1266  ! add grid mapping and mf6 attr
1267  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1268  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1269 
1270  ! exit define mode and write data
1271  call nf_verify(nf90_enddef(ncid), nc_fname)
1272  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1273  count=(/dis%ncol, dis%nrow/)), &
1274  nc_fname)

◆ nc_export_int3d()

subroutine disncstructuredmodule::nc_export_int3d ( integer(i4b), dimension(:, :, :), intent(in), pointer, contiguous  p_mem,
integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
type(inputparamdefinitiontype), intent(in), pointer  idt,
character(len=*), intent(in)  mempath,
character(len=*), intent(in)  nc_tag,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  gridmap_name,
logical(lgp), intent(in)  latlon,
integer(i4b), intent(in)  deflate,
integer(i4b), intent(in)  shuffle,
integer(i4b), intent(in)  chunk_z,
integer(i4b), intent(in)  chunk_y,
integer(i4b), intent(in)  chunk_x,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1279 of file DisNCStructured.f90.

1282  integer(I4B), dimension(:, :, :), pointer, contiguous, intent(in) :: p_mem
1283  integer(I4B), intent(in) :: ncid
1284  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1285  type(StructuredNCVarIdType), intent(inout) :: var_ids
1286  type(DisType), pointer, intent(in) :: dis
1287  type(InputParamDefinitionType), pointer, intent(in) :: idt
1288  character(len=*), intent(in) :: mempath
1289  character(len=*), intent(in) :: nc_tag
1290  character(len=*), intent(in) :: pkgname
1291  character(len=*), intent(in) :: gridmap_name
1292  logical(LGP), intent(in) :: latlon
1293  integer(I4B), intent(in) :: deflate
1294  integer(I4B), intent(in) :: shuffle
1295  integer(I4B), intent(in) :: chunk_z
1296  integer(I4B), intent(in) :: chunk_y
1297  integer(I4B), intent(in) :: chunk_x
1298  character(len=*), intent(in) :: nc_fname
1299  character(len=LINELENGTH) :: varname
1300  integer(I4B) :: var_id
1301 
1302  varname = export_varname(pkgname, idt%tagname, mempath)
1303 
1304  ! reenter define mode and create variable
1305  call nf_verify(nf90_redef(ncid), nc_fname)
1306  call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1307  (/dim_ids%x, dim_ids%y, dim_ids%z/), var_id), &
1308  nc_fname)
1309 
1310  ! apply chunking parameters
1311  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1312  ! deflate and shuffle
1313  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1314 
1315  ! put attr
1316  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1317  (/nf90_fill_int/)), nc_fname)
1318  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1319  idt%longname), nc_fname)
1320 
1321  ! add grid mapping and mf6 attr
1322  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1323  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1324 
1325  ! exit define mode and write data
1326  call nf_verify(nf90_enddef(ncid), nc_fname)
1327  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1328  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1329  nc_fname)

◆ ncvar_chunk2d()

subroutine disncstructuredmodule::ncvar_chunk2d ( integer(i4b), intent(in)  ncid,
integer(i4b), intent(in)  varid,
integer(i4b), intent(in)  chunk_x,
integer(i4b), intent(in)  chunk_y,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1023 of file DisNCStructured.f90.

1024  integer(I4B), intent(in) :: ncid
1025  integer(I4B), intent(in) :: varid
1026  integer(I4B), intent(in) :: chunk_x
1027  integer(I4B), intent(in) :: chunk_y
1028  character(len=*), intent(in) :: nc_fname
1029  if (chunk_y > 0 .and. chunk_x > 0) then
1030  call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1031  (/chunk_x, chunk_y/)), nc_fname)
1032  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvar_chunk3d()

subroutine disncstructuredmodule::ncvar_chunk3d ( integer(i4b), intent(in)  ncid,
integer(i4b), intent(in)  varid,
integer(i4b), intent(in)  chunk_x,
integer(i4b), intent(in)  chunk_y,
integer(i4b), intent(in)  chunk_z,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1037 of file DisNCStructured.f90.

1038  integer(I4B), intent(in) :: ncid
1039  integer(I4B), intent(in) :: varid
1040  integer(I4B), intent(in) :: chunk_x
1041  integer(I4B), intent(in) :: chunk_y
1042  integer(I4B), intent(in) :: chunk_z
1043  character(len=*), intent(in) :: nc_fname
1044  if (chunk_z > 0 .and. chunk_y > 0 .and. chunk_x > 0) then
1045  call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1046  (/chunk_x, chunk_y, chunk_z/)), &
1047  nc_fname)
1048  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvar_deflate()

subroutine disncstructuredmodule::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 
)
private

Definition at line 1053 of file DisNCStructured.f90.

1054  integer(I4B), intent(in) :: ncid
1055  integer(I4B), intent(in) :: varid
1056  integer(I4B), intent(in) :: deflate
1057  integer(I4B), intent(in) :: shuffle
1058  character(len=*), intent(in) :: nc_fname
1059  ! deflate and shuffle
1060  if (deflate >= 0) then
1061  call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
1062  deflate=1, deflate_level=deflate), &
1063  nc_fname)
1064  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvar_gridmap()

subroutine disncstructuredmodule::ncvar_gridmap ( integer(i4b), intent(in)  ncid,
integer(i4b), intent(in)  varid,
character(len=*), intent(in)  gridmap_name,
logical(lgp), intent(in)  latlon,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1069 of file DisNCStructured.f90.

1070  integer(I4B), intent(in) :: ncid
1071  integer(I4B), intent(in) :: varid
1072  character(len=*), intent(in) :: gridmap_name
1073  logical(LGP), intent(in) :: latlon
1074  character(len=*), intent(in) :: nc_fname
1075  if (gridmap_name /= '') then
1076  call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'x y'), &
1077  nc_fname)
1078  call nf_verify(nf90_put_att(ncid, varid, 'grid_mapping', gridmap_name), &
1079  nc_fname)
1080  else if (latlon) then
1081  call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'lon lat'), &
1082  nc_fname)
1083  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ncvar_mf6attr()

subroutine disncstructuredmodule::ncvar_mf6attr ( integer(i4b), intent(in)  ncid,
integer(i4b), intent(in)  varid,
integer(i4b), intent(in)  iaux,
character(len=*), intent(in)  nc_tag,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1088 of file DisNCStructured.f90.

1089  integer(I4B), intent(in) :: ncid
1090  integer(I4B), intent(in) :: varid
1091  integer(I4B), intent(in) :: iaux
1092  character(len=*), intent(in) :: nc_tag
1093  character(len=*), intent(in) :: nc_fname
1094  if (nc_tag /= '') then
1095  call nf_verify(nf90_put_att(ncid, varid, 'modflow_input', &
1096  nc_tag), nc_fname)
1097  if (iaux > 0) then
1098  call nf_verify(nf90_put_att(ncid, varid, 'modflow_iaux', &
1099  iaux), nc_fname)
1100  end if
1101  end if
Here is the call graph for this function:
Here is the caller graph for this function:

◆ package_step()

subroutine disncstructuredmodule::package_step ( class(disncstructuredtype), intent(inout)  this,
class(exportpackagetype), intent(in), pointer  export_pkg 
)

Definition at line 538 of file DisNCStructured.f90.

539  use tdismodule, only: kper
542  class(DisNCStructuredType), intent(inout) :: this
543  class(ExportPackageType), pointer, intent(in) :: export_pkg
544  type(InputParamDefinitionType), pointer :: idt
545  integer(I4B), dimension(:), pointer, contiguous :: int1d
546  real(DP), dimension(:), pointer, contiguous :: dbl1d, nodes
547  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
548  character(len=LINELENGTH) :: nc_tag
549  integer(I4B) :: iaux, iparam, nvals, n
550  integer(I4B), pointer :: nbound
551 
552  ! initialize
553  iaux = 0
554 
555  ! export defined period input
556  do iparam = 1, export_pkg%nparam
557  ! check if variable was read this period
558  if (export_pkg%param_reads(iparam)%invar < 1) cycle
559 
560  ! set input definition
561  idt => &
562  get_param_definition_type(export_pkg%mf6_input%param_dfns, &
563  export_pkg%mf6_input%component_type, &
564  export_pkg%mf6_input%subcomponent_type, &
565  'PERIOD', export_pkg%param_names(iparam), '')
566 
567  ! set variable input tag
568  nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
569  idt)
570 
571  ! export arrays
572  select case (idt%datatype)
573  case ('INTEGER1D')
574  call mem_setptr(int1d, idt%mf6varname, export_pkg%mf6_input%mempath)
575  this%var_ids%export = export_pkg%varids_param(iparam, 1)
576  call nc_export_array(int1d, this%ncid, this%dim_ids, this%var_ids, &
577  this%dis, idt, export_pkg%mf6_input%mempath, &
578  nc_tag, export_pkg%mf6_input%subcomponent_name, &
579  this%gridmap_name, this%latlon, this%deflate, &
580  this%shuffle, this%chunk_z, this%chunk_y, &
581  this%chunk_x, kper, this%nc_fname)
582  case ('DOUBLE1D')
583  call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
584  this%var_ids%export = export_pkg%varids_param(iparam, 1)
585  select case (idt%shape)
586  case ('NCPL')
587  call nc_export_array(dbl1d, this%ncid, this%dim_ids, this%var_ids, &
588  this%dis, idt, export_pkg%mf6_input%mempath, &
589  nc_tag, export_pkg%mf6_input%subcomponent_name, &
590  this%gridmap_name, this%latlon, this%deflate, &
591  this%shuffle, this%chunk_z, this%chunk_y, &
592  this%chunk_x, kper, iaux, this%nc_fname)
593  case ('NODES')
594  nvals = this%dis%nodesuser
595  allocate (nodes(nvals))
596  nodes = dnodata
597  call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
598  call mem_setptr(int1d, 'NODEULIST', export_pkg%mf6_input%mempath)
599  call mem_setptr(nbound, 'NBOUND', export_pkg%mf6_input%mempath)
600  do n = 1, nbound
601  nodes(int1d(n)) = dbl1d(n)
602  end do
603  call nc_export_array(nodes, this%ncid, this%dim_ids, this%var_ids, &
604  this%dis, idt, export_pkg%mf6_input%mempath, &
605  nc_tag, export_pkg%mf6_input%subcomponent_name, &
606  this%gridmap_name, this%latlon, this%deflate, &
607  this%shuffle, this%chunk_z, this%chunk_y, &
608  this%chunk_x, kper, iaux, this%nc_fname)
609  deallocate (nodes)
610  case default
611  end select
612  case ('DOUBLE2D')
613  call mem_setptr(dbl2d, idt%mf6varname, export_pkg%mf6_input%mempath)
614  select case (idt%shape)
615  case ('NAUX NCPL')
616  nvals = this%dis%nrow * this%dis%ncol
617  allocate (nodes(nvals))
618  do iaux = 1, size(dbl2d, dim=1) !naux
619  this%var_ids%export = export_pkg%varids_aux(iaux, 1)
620  do n = 1, nvals
621  nodes(n) = dbl2d(iaux, n)
622  end do
623  call nc_export_array(nodes, this%ncid, this%dim_ids, this%var_ids, &
624  this%dis, idt, export_pkg%mf6_input%mempath, &
625  nc_tag, export_pkg%mf6_input%subcomponent_name, &
626  this%gridmap_name, this%latlon, this%deflate, &
627  this%shuffle, this%chunk_z, this%chunk_y, &
628  this%chunk_x, kper, iaux, this%nc_fname)
629  end do
630  deallocate (nodes)
631  case ('NAUX NODES')
632  nvals = this%dis%nodesuser
633  allocate (nodes(nvals))
634  call mem_setptr(int1d, 'NODEULIST', export_pkg%mf6_input%mempath)
635  call mem_setptr(nbound, 'NBOUND', export_pkg%mf6_input%mempath)
636  do iaux = 1, size(dbl2d, dim=1) ! naux
637  nodes = dnodata
638  this%var_ids%export = export_pkg%varids_aux(iaux, 1)
639  do n = 1, nbound
640  nodes(int1d(n)) = dbl2d(iaux, n)
641  end do
642  call nc_export_array(nodes, this%ncid, this%dim_ids, this%var_ids, &
643  this%dis, idt, export_pkg%mf6_input%mempath, &
644  nc_tag, export_pkg%mf6_input%subcomponent_name, &
645  this%gridmap_name, this%latlon, this%deflate, &
646  this%shuffle, this%chunk_z, this%chunk_y, &
647  this%chunk_x, kper, iaux, this%nc_fname)
648 
649  end do
650  deallocate (nodes)
651  case default
652  end select
653  case default
654  ! no-op, no other datatypes exported
655  end select
656  end do
657 
658  ! synchronize file
659  call nf_verify(nf90_sync(this%ncid), this%nc_fname)
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:23
Here is the call graph for this function:

◆ step()

subroutine disncstructuredmodule::step ( class(disncstructuredtype), intent(inout)  this)

Definition at line 257 of file DisNCStructured.f90.

258  use constantsmodule, only: dhnoflo
259  use tdismodule, only: totim
260  use netcdfcommonmodule, only: ixstp
261  class(DisNCStructuredType), intent(inout) :: this
262  real(DP), dimension(:), pointer, contiguous :: dbl1d
263  integer(I4B) :: n, istp
264 
265  ! set global step index
266  istp = ixstp()
267 
268  if (size(this%dis%nodeuser) < &
269  size(this%dis%nodereduced)) then
270  allocate (dbl1d(size(this%dis%nodereduced)))
271  dbl1d = dhnoflo
272  do n = 1, size(this%dis%nodereduced)
273  if (this%dis%nodereduced(n) > 0) then
274  dbl1d(n) = this%x(this%dis%nodereduced(n))
275  end if
276  end do
277  ! write step data to dependent variable
278  call nf_verify(nf90_put_var(this%ncid, &
279  this%var_ids%dependent, dbl1d, &
280  start=(/1, 1, 1, istp/), &
281  count=(/this%dis%ncol, &
282  this%dis%nrow, &
283  this%dis%nlay, 1/)), &
284  this%nc_fname)
285  deallocate (dbl1d)
286  else
287  ! write step data to dependent variable
288  call nf_verify(nf90_put_var(this%ncid, &
289  this%var_ids%dependent, this%x, &
290  start=(/1, 1, 1, istp/), &
291  count=(/this%dis%ncol, &
292  this%dis%nrow, &
293  this%dis%nlay, 1/)), &
294  this%nc_fname)
295  end if
296 
297  ! write to time coordinate variable
298  call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
299  totim, start=(/istp/)), &
300  this%nc_fname)
301 
302  ! synchronize file
303  call nf_verify(nf90_sync(this%ncid), this%nc_fname)
real(dp), pointer, public totim
time relative to start of simulation
Definition: tdis.f90:32
Here is the call graph for this function: