MODFLOW 6  version 6.8.0.dev0
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 731 of file DisNCStructured.f90.

732  class(DisNCStructuredType), intent(inout) :: this
733  ! file scoped title
734  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'title', &
735  this%annotation%title), this%nc_fname)
736  ! source (MODFLOW 6)
737  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'source', &
738  this%annotation%source), this%nc_fname)
739  ! grid type (MODFLOW 6)
740  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow_grid', &
741  this%annotation%grid), this%nc_fname)
742  ! MODFLOW 6 model type
743  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow_model', &
744  this%annotation%model), this%nc_fname)
745  ! generation datetime
746  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'history', &
747  this%annotation%history), this%nc_fname)
748  ! supported conventions
749  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'Conventions', &
750  this%annotation%conventions), &
751  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 979 of file DisNCStructured.f90.

980  class(DisNCStructuredType), intent(inout) :: this
981  integer(I4B) :: ibnd, n !, k, i, j
982  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
983  real(DP), dimension(:), allocatable :: x, y
984  real(DP) :: xoff, yoff
985 
986  if (this%dis%angrot /= dzero) then
987  xoff = dzero
988  yoff = dzero
989  else
990  xoff = this%dis%xorigin
991  yoff = this%dis%yorigin
992  end if
993 
994  allocate (x(size(this%dis%cellx)))
995  allocate (y(size(this%dis%celly)))
996 
997  do n = 1, size(this%dis%cellx)
998  x(n) = this%dis%cellx(n) + xoff
999  end do
1000 
1001  do n = 1, size(this%dis%celly)
1002  y(n) = this%dis%celly(n) + yoff
1003  end do
1004 
1005  call nf_verify(nf90_put_var(this%ncid, this%var_ids%x, x), &
1006  this%nc_fname)
1007  call nf_verify(nf90_put_var(this%ncid, this%var_ids%y, y), &
1008  this%nc_fname)
1009  ! TODO see cf-conventions 4.3.3. Parametric Vertical Coordinate
1010  call nf_verify(nf90_put_var(this%ncid, this%var_ids%z, this%layers), &
1011  this%nc_fname)
1012 
1013  deallocate (x)
1014  deallocate (y)
1015 
1016  ! bounds x
1017  allocate (dbl2d(2, size(this%dis%cellx)))
1018  ibnd = 1
1019  do n = 1, size(this%dis%cellx)
1020  if (ibnd == 1) then
1021  dbl2d(1, ibnd) = xoff
1022  dbl2d(2, ibnd) = xoff + this%dis%delr(ibnd)
1023  else
1024  dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) + this%dis%delr(ibnd)
1025  dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) + this%dis%delr(ibnd)
1026  end if
1027  ibnd = ibnd + 1
1028  end do
1029  call nf_verify(nf90_put_var(this%ncid, this%var_ids%x_bnds, dbl2d), &
1030  this%nc_fname)
1031  deallocate (dbl2d)
1032 
1033  ! bounds y
1034  allocate (dbl2d(2, size(this%dis%celly)))
1035  ibnd = 1
1036  do n = size(this%dis%celly), 1, -1
1037  if (ibnd == 1) then
1038  dbl2d(1, ibnd) = yoff + sum(this%dis%delc) - this%dis%delc(n)
1039  dbl2d(2, ibnd) = yoff + sum(this%dis%delc)
1040  else
1041  dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) - this%dis%delc(n)
1042  dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) - this%dis%delc(n)
1043  end if
1044  ibnd = ibnd + 1
1045  end do
1046  call nf_verify(nf90_put_var(this%ncid, this%var_ids%y_bnds, dbl2d), &
1047  this%nc_fname)
1048  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 674 of file DisNCStructured.f90.

680  class(DisNCStructuredType), intent(inout) :: this
681  character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
682  type(CharacterStringType), dimension(:), contiguous, &
683  pointer :: pkgtypes => null()
684  type(CharacterStringType), dimension(:), contiguous, &
685  pointer :: pkgnames => null()
686  type(CharacterStringType), dimension(:), contiguous, &
687  pointer :: mempaths => null()
688  type(InputParamDefinitionType), dimension(:), pointer :: param_dfns
689  character(len=LENMEMPATH) :: input_mempath, mempath
690  integer(I4B) :: n
691  integer(I4B), pointer :: export_arrays
692  logical(LGP) :: found
693 
694  input_mempath = create_mem_path(component=this%modelname, context=idm_context)
695 
696  ! set pointers to model path package info
697  call mem_setptr(pkgtypes, 'PKGTYPES', input_mempath)
698  call mem_setptr(pkgnames, 'PKGNAMES', input_mempath)
699  call mem_setptr(mempaths, 'MEMPATHS', input_mempath)
700 
701  do n = 1, size(mempaths)
702  ! allocate export_arrays
703  allocate (export_arrays)
704  export_arrays = 0
705 
706  ! set package attributes
707  mempath = mempaths(n)
708  pname = pkgnames(n)
709  ptype = pkgtypes(n)
710 
711  ! export input arrays
712  if (mempath /= '') then
713  ! update export
714  call mem_set_value(export_arrays, 'EXPORT_NC', mempath, found, &
715  release=.false.)
716 
717  if (export_arrays > 0) then
718  pkgtype = idm_subcomponent_type(this%modeltype, ptype)
719  param_dfns => param_definitions(this%modeltype, pkgtype)
720  call this%export_input_arrays(ptype, pname, mempath, param_dfns)
721  end if
722  end if
723 
724  ! cleanup
725  deallocate (export_arrays)
726  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 960 of file DisNCStructured.f90.

961  class(DisNCStructuredType), intent(inout) :: this
962  if (this%latlon) then
963  ! lat
964  call nf_verify(nf90_put_var(this%ncid, this%var_ids%latitude, &
965  this%latitude, start=(/1, 1/), &
966  count=(/this%dis%ncol, this%dis%nrow/)), &
967  this%nc_fname)
968 
969  ! lon
970  call nf_verify(nf90_put_var(this%ncid, this%var_ids%longitude, &
971  this%longitude, start=(/1, 1/), &
972  count=(/this%dis%ncol, this%dis%nrow/)), &
973  this%nc_fname)
974  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 414 of file DisNCStructured.f90.

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

Definition at line 855 of file DisNCStructured.f90.

856  use constantsmodule, only: dhnoflo
857  class(DisNCStructuredType), intent(inout) :: this
858 
859  call nf_verify(nf90_def_var(this%ncid, this%xname, nf90_double, &
860  (/this%dim_ids%x, this%dim_ids%y, &
861  this%dim_ids%z, this%dim_ids%time/), &
862  this%var_ids%dependent), &
863  this%nc_fname)
864 
865  ! apply chunking parameters
866  if (this%chunking_active) then
867  call nf_verify(nf90_def_var_chunking(this%ncid, &
868  this%var_ids%dependent, &
869  nf90_chunked, &
870  (/this%chunk_x, this%chunk_y, &
871  this%chunk_z, this%chunk_time/)), &
872  this%nc_fname)
873  end if
874 
875  ! deflate and shuffle
876  call ncvar_deflate(this%ncid, this%var_ids%dependent, this%deflate, &
877  this%shuffle, this%nc_fname)
878 
879  ! put attr
880  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
881  'units', this%lenunits), this%nc_fname)
882  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, 'long_name', &
883  this%annotation%longname), this%nc_fname)
884  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, '_FillValue', &
885  (/dhnoflo/)), this%nc_fname)
886 
887  ! add grid mapping
888  call ncvar_gridmap(this%ncid, this%var_ids%dependent, this%gridmap_name, &
889  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 756 of file DisNCStructured.f90.

757  use constantsmodule, only: mvalidate
758  use simvariablesmodule, only: isim_mode
759  class(DisNCStructuredType), intent(inout) :: this
760 
761  ! bound dim
762  call nf_verify(nf90_def_dim(this%ncid, 'bnd', 2, this%dim_ids%bnd), &
763  this%nc_fname)
764 
765  if (isim_mode /= mvalidate .or. this%pkglist%Count() > 0) then
766  ! Time
767  call nf_verify(nf90_def_dim(this%ncid, 'time', this%totnstp, &
768  this%dim_ids%time), this%nc_fname)
769  call nf_verify(nf90_def_var(this%ncid, 'time', nf90_double, &
770  this%dim_ids%time, this%var_ids%time), &
771  this%nc_fname)
772  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'calendar', &
773  'standard'), this%nc_fname)
774  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'units', &
775  this%datetime), this%nc_fname)
776  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'axis', 'T'), &
777  this%nc_fname)
778  !call nf_verify(nf90_put_att(ncid, var_ids%time, 'bounds', 'time_bnds'), this%nc_fname)
779  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'standard_name', &
780  'time'), this%nc_fname)
781  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'long_name', &
782  'time'), this%nc_fname)
783  end if
784 
785  ! Z dimension
786  call nf_verify(nf90_def_dim(this%ncid, 'layer', this%dis%nlay, &
787  this%dim_ids%z), this%nc_fname)
788  call nf_verify(nf90_def_var(this%ncid, 'layer', nf90_int, this%dim_ids%z, &
789  this%var_ids%z), this%nc_fname)
790  call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'units', '1'), &
791  this%nc_fname)
792  call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'axis', 'Z'), &
793  this%nc_fname)
794  call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'positive', 'down'), &
795  this%nc_fname)
796  call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'long_name', &
797  'model layer'), this%nc_fname)
798  !call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'bounds', 'z_bnds'), &
799  ! this%nc_fname)
800  !call nf_verify(nf90_def_var(this%ncid, 'z_bnds', NF90_DOUBLE, &
801  ! (/this%dim_ids%bnd, this%dim_ids%z/), &
802  ! this%var_ids%z_bnds), this%nc_fname)
803  !call nf_verify(nf90_put_var(this%ncid, this%var_ids%z_bnds, &
804  ! this%elev_bnds), this%nc_fname)
805 
806  ! Y dimension
807  call nf_verify(nf90_def_dim(this%ncid, 'y', this%dis%nrow, this%dim_ids%y), &
808  this%nc_fname)
809  call nf_verify(nf90_def_var(this%ncid, 'y', nf90_double, this%dim_ids%y, &
810  this%var_ids%y), this%nc_fname)
811  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'units', &
812  this%lenunits), this%nc_fname)
813  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'axis', 'Y'), &
814  this%nc_fname)
815  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'standard_name', &
816  'projection_y_coordinate'), this%nc_fname)
817  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'long_name', &
818  'Northing'), this%nc_fname)
819  if (this%gridmap_name /= '') then
820  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'grid_mapping', &
821  this%gridmap_name), this%nc_fname)
822  end if
823  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'bounds', 'y_bnds'), &
824  this%nc_fname)
825  call nf_verify(nf90_def_var(this%ncid, 'y_bnds', nf90_double, &
826  (/this%dim_ids%bnd, this%dim_ids%y/), &
827  this%var_ids%y_bnds), this%nc_fname)
828 
829  ! X dimension
830  call nf_verify(nf90_def_dim(this%ncid, 'x', this%dis%ncol, this%dim_ids%x), &
831  this%nc_fname)
832  call nf_verify(nf90_def_var(this%ncid, 'x', nf90_double, this%dim_ids%x, &
833  this%var_ids%x), this%nc_fname)
834  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'units', &
835  this%lenunits), this%nc_fname)
836  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'axis', 'X'), &
837  this%nc_fname)
838  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'standard_name', &
839  'projection_x_coordinate'), this%nc_fname)
840  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'long_name', &
841  'Easting'), this%nc_fname)
842  if (this%gridmap_name /= '') then
843  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'grid_mapping', &
844  this%gridmap_name), this%nc_fname)
845  end if
846  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'bounds', 'x_bnds'), &
847  this%nc_fname)
848  call nf_verify(nf90_def_var(this%ncid, 'x_bnds', nf90_double, &
849  (/this%dim_ids%bnd, this%dim_ids%x/), &
850  this%var_ids%x_bnds), 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:

◆ define_geocoords()

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

Definition at line 931 of file DisNCStructured.f90.

932  class(DisNCStructuredType), intent(inout) :: this
933  if (this%latlon) then
934  ! lat
935  call nf_verify(nf90_def_var(this%ncid, 'lat', nf90_double, &
936  (/this%dim_ids%x, this%dim_ids%y/), &
937  this%var_ids%latitude), this%nc_fname)
938  call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
939  'units', 'degrees_north'), this%nc_fname)
940  call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
941  'standard_name', 'latitude'), this%nc_fname)
942  call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
943  'long_name', 'latitude'), this%nc_fname)
944 
945  ! lon
946  call nf_verify(nf90_def_var(this%ncid, 'lon', nf90_double, &
947  (/this%dim_ids%x, this%dim_ids%y/), &
948  this%var_ids%longitude), this%nc_fname)
949  call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
950  'units', 'degrees_east'), this%nc_fname)
951  call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
952  'standard_name', 'longitude'), this%nc_fname)
953  call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
954  'long_name', 'longitude'), this%nc_fname)
955  end if
Here is the call graph for this function:

◆ define_gridmap()

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

Definition at line 894 of file DisNCStructured.f90.

895  class(DisNCStructuredType), intent(inout) :: this
896  integer(I4B) :: var_id
897  character(len=LINELENGTH) :: gmname
898  character(len=LENBIGLINE) :: effective_crs_wkt
899 
900  if (this%wkt /= '' .or. this%crs_wkt /= '') then
901  call nf_verify(nf90_redef(this%ncid), this%nc_fname)
902  call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
903  var_id), this%nc_fname)
904  ! wkt (WKT1, OGC 01-009) -- for legacy/QGIS compatibility
905  if (this%wkt /= '') then
906  call nf_verify(nf90_put_att(this%ncid, var_id, 'wkt', this%wkt), &
907  this%nc_fname)
908  end if
909  ! crs_wkt (WKT2, ISO 19162:2019) -- required by CF-1.11
910  if (this%crs_wkt /= '') then
911  effective_crs_wkt = this%crs_wkt
912  else
913  effective_crs_wkt = this%wkt
914  end if
915  call nf_verify(nf90_put_att(this%ncid, var_id, 'crs_wkt', &
916  trim(effective_crs_wkt)), this%nc_fname)
917  ! grid_mapping_name derived from WKT projection keyword
918  gmname = wkt_to_cf_gridmapping(trim(effective_crs_wkt))
919  if (gmname /= '') then
920  call nf_verify(nf90_put_att(this%ncid, var_id, 'grid_mapping_name', &
921  trim(gmname)), this%nc_fname)
922  end if
923  call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
924  call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
925  this%nc_fname)
926  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 period input arrays
224  call this%df_export()
225  else
226  ! define the dependent variable
227  call this%define_dependent()
228  end if
229  ! exit define mode
230  call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
231  ! add data locations
232  call this%add_grid_data()
233  ! add projection data
234  call this%add_proj_data()
235  if (isim_mode == mvalidate) then
236  ! define and set package input griddata
237  call this%add_pkg_data()
238  end if
239  ! define and set gridmap variable
240  call this%define_gridmap()
241  ! synchronize file
242  call nf_verify(nf90_sync(this%ncid), this%nc_fname)
Here is the call graph for this function:

◆ df_export()

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

Definition at line 247 of file DisNCStructured.f90.

249  class(DisNCStructuredType), intent(inout) :: this
250  class(ExportPackageType), pointer :: export_pkg
251  integer(I4B) :: idx
252  do idx = 1, this%pkglist%Count()
253  export_pkg => this%get(idx)
254  call this%export_df(export_pkg)
255  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 95 of file DisNCStructured.f90.

99  class(DisNCStructuredType), intent(inout) :: this
100  character(len=*), intent(in) :: modelname
101  character(len=*), intent(in) :: modeltype
102  character(len=*), intent(in) :: modelfname
103  character(len=*), intent(in) :: nc_fname
104  integer(I4B), intent(in) :: disenum
105  integer(I4B), intent(in) :: nctype
106  integer(I4B), intent(in) :: iout
107  integer(I4B) :: k, latsz, lonsz
108  logical(LGP) :: found
109 
110  ! set nlay
111  this%nlay = this%dis%nlay
112 
113  ! allocate
114  allocate (this%chunk_z)
115  allocate (this%chunk_y)
116  allocate (this%chunk_x)
117  allocate (this%layers(this%nlay))
118 
119  ! initialize
120  this%chunk_z = -1
121  this%chunk_y = -1
122  this%chunk_x = -1
123  do k = 1, this%nlay
124  this%layers(k) = k
125  end do
126 
127  this%latlon = .false.
128 
129  ! initialize base class
130  call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
131  disenum, nctype, iout)
132 
133  ! update values from input context
134  if (this%ncf_mempath /= '') then
135  call mem_set_value(this%chunk_z, 'CHUNK_Z', this%ncf_mempath, found)
136  call mem_set_value(this%chunk_y, 'CHUNK_Y', this%ncf_mempath, found)
137  call mem_set_value(this%chunk_x, 'CHUNK_X', this%ncf_mempath, found)
138 
139  if (this%chunk_time > 0 .and. this%chunk_z > 0 .and. &
140  this%chunk_y > 0 .and. this%chunk_x > 0) then
141  this%chunking_active = .true.
142  else if (this%chunk_time > 0 .or. this%chunk_z > 0 .or. &
143  this%chunk_y > 0 .or. this%chunk_x > 0) then
144  this%chunk_time = -1
145  this%chunk_z = -1
146  this%chunk_y = -1
147  this%chunk_x = -1
148  write (warnmsg, '(a)') 'Ignoring user provided NetCDF chunking &
149  &parameters. Define chunk_time, chunk_x, chunk_y and chunk_z input &
150  &parameters to see an effect in file "'//trim(nc_fname)//'".'
151  call store_warning(warnmsg)
152  end if
153 
154  call get_isize('LATITUDE', this%ncf_mempath, latsz)
155  call get_isize('LONGITUDE', this%ncf_mempath, lonsz)
156 
157  if (latsz > 0 .and. lonsz > 0) then
158  this%latlon = .true.
159  if (this%wkt /= '' .or. this%crs_wkt /= '') then
160  write (warnmsg, '(a)') 'Ignoring user provided NetCDF wkt/crs_wkt &
161  &parameter(s) as longitude and latitude arrays have been provided. &
162  &Applies to file "'//trim(nc_fname)//'".'
163  call store_warning(warnmsg)
164  this%wkt = ''
165  this%crs_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%gridmap_name /= '') then
173  if (this%dis%angrot /= dzero) then
174  write (warnmsg, '(a)') 'CRS 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 382 of file DisNCStructured.f90.

385  class(DisNCStructuredType), intent(inout) :: this
386  class(ExportPackageType), pointer, intent(in) :: export_pkg
387  type(InputParamDefinitionType), pointer :: idt
388  integer(I4B) :: iparam, iaux
389 
390  ! export defined period input
391  do iparam = 1, export_pkg%nparam
392  ! initialize
393  iaux = 0
394  ! set input definition
395  idt => &
396  get_param_definition_type(export_pkg%mf6_input%param_dfns, &
397  export_pkg%mf6_input%component_type, &
398  export_pkg%mf6_input%subcomponent_type, &
399  'PERIOD', export_pkg%param_names(iparam), '')
400  select case (idt%shape)
401  case ('NCPL', 'NODES')
402  call this%create_timeseries(idt, iparam, iaux, export_pkg)
403  case ('NAUX NCPL', 'NAUX NODES')
404  do iaux = 1, export_pkg%naux
405  call this%create_timeseries(idt, iparam, iaux, export_pkg)
406  end do
407  case default
408  end select
409  end do
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
Here is the call graph for this function:

◆ export_input_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 310 of file DisNCStructured.f90.

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

517  use memorymanagermodule, only: get_isize
518  class(DisNCStructuredType), intent(inout) :: this
519  character(len=*), intent(in) :: pkgtype
520  character(len=*), intent(in) :: pkgname
521  character(len=*), intent(in) :: mempath
522  type(InputParamDefinitionType), dimension(:), pointer, &
523  intent(in) :: param_dfns
524  type(InputParamDefinitionType), pointer :: idt
525  integer(I4B) :: iparam, isize
526  do iparam = 1, size(param_dfns)
527  ! assign param definition pointer
528  idt => param_dfns(iparam)
529  ! for now only griddata is exported
530  if (idt%blockname == 'GRIDDATA') then
531  ! check if variable is already allocated
532  call get_isize(idt%mf6varname, mempath, isize)
533  if (isize > 0) then
534  call this%export_input_array(pkgtype, pkgname, mempath, idt)
535  end if
536  end if
537  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 1362 of file DisNCStructured.f90.

1366  use tdismodule, only: kper
1367  real(DP), dimension(:), pointer, contiguous, intent(in) :: p_mem
1368  integer(I4B), intent(in) :: ncid
1369  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1370  type(StructuredNCVarIdType), intent(inout) :: var_ids
1371  type(DisType), pointer, intent(in) :: dis
1372  type(InputParamDefinitionType), pointer, intent(in) :: idt
1373  character(len=*), intent(in) :: mempath
1374  character(len=*), intent(in) :: nc_tag
1375  character(len=*), intent(in) :: pkgname
1376  character(len=*), intent(in) :: gridmap_name
1377  logical(LGP), intent(in) :: latlon
1378  integer(I4B), intent(in) :: deflate
1379  integer(I4B), intent(in) :: shuffle
1380  integer(I4B), intent(in) :: chunk_z
1381  integer(I4B), intent(in) :: chunk_y
1382  integer(I4B), intent(in) :: chunk_x
1383  integer(I4B), intent(in) :: iper
1384  integer(I4B), intent(in) :: iaux
1385  character(len=*), intent(in) :: nc_fname
1386  integer(I4B) :: var_id, axis_sz
1387  character(len=LINELENGTH) :: varname, longname
1388 
1389  if (idt%shape == 'NROW' .or. &
1390  idt%shape == 'NCOL' .or. &
1391  idt%shape == 'NCPL' .or. &
1392  idt%shape == 'NAUX NCPL') then
1393 
1394  if (iper == 0) then
1395  select case (idt%shape)
1396  case ('NROW')
1397  axis_sz = dim_ids%y
1398  case ('NCOL')
1399  axis_sz = dim_ids%x
1400  end select
1401 
1402  varname = export_varname(pkgname, idt%tagname, mempath)
1403  longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1404  iaux=iaux, &
1405  component_type=idt%component_type, &
1406  subcomponent_type=idt%subcomponent_type)
1407 
1408  ! reenter define mode and create variable
1409  call nf_verify(nf90_redef(ncid), nc_fname)
1410  call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1411  (/axis_sz/), var_id), &
1412  nc_fname)
1413 
1414  ! NROW/NCOL shapes use default chunking
1415  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1416 
1417  ! put attr
1418  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1419  (/nf90_fill_double/)), nc_fname)
1420  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1421  longname), nc_fname)
1422 
1423  ! add mf6 attr
1424  call ncvar_mf6attr(ncid, var_id, iaux, nc_tag, nc_fname)
1425 
1426  ! exit define mode and write data
1427  call nf_verify(nf90_enddef(ncid), nc_fname)
1428  call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1429  nc_fname)
1430  else
1431  ! timeseries
1432  call nf_verify(nf90_put_var(ncid, &
1433  var_ids%export, p_mem, &
1434  start=(/1, 1, kper/), &
1435  count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1436  end if
1437 
1438  else
1439 
1440  if (iper == 0) then
1441  varname = export_varname(pkgname, idt%tagname, mempath, iaux=iaux)
1442  longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1443  iaux=iaux, &
1444  component_type=idt%component_type, &
1445  subcomponent_type=idt%subcomponent_type)
1446 
1447  ! reenter define mode and create variable
1448  call nf_verify(nf90_redef(ncid), nc_fname)
1449  call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1450  (/dim_ids%x, dim_ids%y, dim_ids%z/), &
1451  var_id), nc_fname)
1452 
1453  ! apply chunking parameters
1454  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1455  ! deflate and shuffle
1456  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1457 
1458  ! put attr
1459  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1460  (/nf90_fill_double/)), nc_fname)
1461  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1462  longname), nc_fname)
1463 
1464  ! add grid mapping and mf6 attr
1465  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1466  call ncvar_mf6attr(ncid, var_id, iaux, nc_tag, nc_fname)
1467 
1468  ! exit define mode and write data
1469  call nf_verify(nf90_enddef(ncid), nc_fname)
1470  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1471  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1472  nc_fname)
1473  else
1474  ! timeseries
1475  call nf_verify(nf90_put_var(ncid, &
1476  var_ids%export, p_mem, &
1477  start=(/1, 1, 1, kper/), &
1478  count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1479  nc_fname)
1480  end if
1481  end if
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:26

◆ 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 1486 of file DisNCStructured.f90.

1489  real(DP), dimension(:, :), pointer, contiguous, intent(in) :: p_mem
1490  integer(I4B), intent(in) :: ncid
1491  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1492  type(StructuredNCVarIdType), intent(inout) :: var_ids
1493  type(DisType), pointer, intent(in) :: dis
1494  type(InputParamDefinitionType), pointer, intent(in) :: idt
1495  character(len=*), intent(in) :: mempath
1496  character(len=*), intent(in) :: nc_tag
1497  character(len=*), intent(in) :: pkgname
1498  character(len=*), intent(in) :: gridmap_name
1499  logical(LGP), intent(in) :: latlon
1500  integer(I4B), intent(in) :: deflate
1501  integer(I4B), intent(in) :: shuffle
1502  integer(I4B), intent(in) :: chunk_z
1503  integer(I4B), intent(in) :: chunk_y
1504  integer(I4B), intent(in) :: chunk_x
1505  character(len=*), intent(in) :: nc_fname
1506  character(len=LINELENGTH) :: varname
1507  integer(I4B) :: var_id
1508 
1509  varname = export_varname(pkgname, idt%tagname, mempath)
1510 
1511  ! reenter define mode and create variable
1512  call nf_verify(nf90_redef(ncid), nc_fname)
1513  call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1514  (/dim_ids%x, dim_ids%y/), var_id), &
1515  nc_fname)
1516 
1517  ! apply chunking parameters
1518  call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1519  ! deflate and shuffle
1520  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1521 
1522  ! put attr
1523  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1524  (/nf90_fill_double/)), nc_fname)
1525  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1526  idt%longname), nc_fname)
1527 
1528  ! add grid mapping and mf6 attr
1529  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1530  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1531 
1532  ! exit define mode and write data
1533  call nf_verify(nf90_enddef(ncid), nc_fname)
1534  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1535  count=(/dis%ncol, dis%nrow/)), &
1536  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 1541 of file DisNCStructured.f90.

1544  real(DP), dimension(:, :, :), pointer, contiguous, intent(in) :: p_mem
1545  integer(I4B), intent(in) :: ncid
1546  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1547  type(StructuredNCVarIdType), intent(inout) :: var_ids
1548  type(DisType), pointer, intent(in) :: dis
1549  type(InputParamDefinitionType), pointer, intent(in) :: idt
1550  character(len=*), intent(in) :: mempath
1551  character(len=*), intent(in) :: nc_tag
1552  character(len=*), intent(in) :: pkgname
1553  character(len=*), intent(in) :: gridmap_name
1554  logical(LGP), intent(in) :: latlon
1555  integer(I4B), intent(in) :: deflate
1556  integer(I4B), intent(in) :: shuffle
1557  integer(I4B), intent(in) :: chunk_z
1558  integer(I4B), intent(in) :: chunk_y
1559  integer(I4B), intent(in) :: chunk_x
1560  character(len=*), intent(in) :: nc_fname
1561  integer(I4B) :: var_id
1562  character(len=LINELENGTH) :: varname, longname
1563 
1564  varname = export_varname(pkgname, idt%tagname, mempath)
1565  longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1566  component_type=idt%component_type, &
1567  subcomponent_type=idt%subcomponent_type)
1568 
1569  ! reenter define mode and create variable
1570  call nf_verify(nf90_redef(ncid), nc_fname)
1571  call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1572  (/dim_ids%x, dim_ids%y, dim_ids%z/), var_id), &
1573  nc_fname)
1574 
1575  ! apply chunking parameters
1576  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1577  ! deflate and shuffle
1578  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1579 
1580  ! put attr
1581  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1582  (/nf90_fill_double/)), nc_fname)
1583  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1584  longname), nc_fname)
1585 
1586  ! add grid mapping and mf6 attr
1587  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1588  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1589 
1590  ! exit define mode and write data
1591  call nf_verify(nf90_enddef(ncid), nc_fname)
1592  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1593  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1594  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 1136 of file DisNCStructured.f90.

1139  use tdismodule, only: kper
1140  integer(I4B), dimension(:), pointer, contiguous, intent(in) :: p_mem
1141  integer(I4B), intent(in) :: ncid
1142  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1143  type(StructuredNCVarIdType), intent(inout) :: var_ids
1144  type(DisType), pointer, intent(in) :: dis
1145  type(InputParamDefinitionType), pointer, intent(in) :: idt
1146  character(len=*), intent(in) :: mempath
1147  character(len=*), intent(in) :: nc_tag
1148  character(len=*), intent(in) :: pkgname
1149  character(len=*), intent(in) :: gridmap_name
1150  logical(LGP), intent(in) :: latlon
1151  integer(I4B), intent(in) :: deflate
1152  integer(I4B), intent(in) :: shuffle
1153  integer(I4B), intent(in) :: chunk_z
1154  integer(I4B), intent(in) :: chunk_y
1155  integer(I4B), intent(in) :: chunk_x
1156  integer(I4B), intent(in) :: iper
1157  character(len=*), intent(in) :: nc_fname
1158  integer(I4B) :: var_id, axis_sz
1159  character(len=LINELENGTH) :: varname, longname
1160 
1161  varname = export_varname(pkgname, idt%tagname, mempath)
1162 
1163  if (idt%shape == 'NROW' .or. &
1164  idt%shape == 'NCOL' .or. &
1165  idt%shape == 'NCPL' .or. &
1166  idt%shape == 'NAUX NCPL') then
1167 
1168  if (iper == 0) then
1169  select case (idt%shape)
1170  case ('NROW')
1171  axis_sz = dim_ids%y
1172  case ('NCOL')
1173  axis_sz = dim_ids%x
1174  end select
1175 
1176  longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1177  component_type=idt%component_type, &
1178  subcomponent_type=idt%subcomponent_type)
1179 
1180  ! reenter define mode and create variable
1181  call nf_verify(nf90_redef(ncid), nc_fname)
1182  call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1183  (/axis_sz/), var_id), &
1184  nc_fname)
1185 
1186  ! NROW/NCOL shapes use default chunking
1187  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1188 
1189  ! put attr
1190  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1191  (/nf90_fill_int/)), nc_fname)
1192  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1193  longname), nc_fname)
1194 
1195  ! add mf6 attr
1196  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1197 
1198  ! exit define mode and write data
1199  call nf_verify(nf90_enddef(ncid), nc_fname)
1200  call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1201  nc_fname)
1202  else
1203  ! timeseries
1204  call nf_verify(nf90_put_var(ncid, &
1205  var_ids%export, p_mem, &
1206  start=(/1, 1, kper/), &
1207  count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1208  end if
1209 
1210  else
1211 
1212  if (iper == 0) then
1213  ! reenter define mode and create variable
1214  call nf_verify(nf90_redef(ncid), nc_fname)
1215  call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1216  (/dim_ids%x, dim_ids%y, dim_ids%z/), &
1217  var_id), nc_fname)
1218 
1219  ! apply chunking parameters
1220  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1221  ! deflate and shuffle
1222  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1223 
1224  ! put attr
1225  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1226  (/nf90_fill_int/)), nc_fname)
1227  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1228  idt%longname), nc_fname)
1229 
1230  ! add grid mapping and mf6 attr
1231  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1232  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1233 
1234  ! exit define mode and write data
1235  call nf_verify(nf90_enddef(ncid), nc_fname)
1236  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1237  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1238  nc_fname)
1239  else
1240  ! timeseries
1241  call nf_verify(nf90_put_var(ncid, &
1242  var_ids%export, p_mem, &
1243  start=(/1, 1, 1, kper/), &
1244  count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1245  nc_fname)
1246  end if
1247  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 1252 of file DisNCStructured.f90.

1255  integer(I4B), dimension(:, :), pointer, contiguous, intent(in) :: p_mem
1256  integer(I4B), intent(in) :: ncid
1257  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1258  type(StructuredNCVarIdType), intent(inout) :: var_ids
1259  type(DisType), pointer, intent(in) :: dis
1260  type(InputParamDefinitionType), pointer, intent(in) :: idt
1261  character(len=*), intent(in) :: mempath
1262  character(len=*), intent(in) :: nc_tag
1263  character(len=*), intent(in) :: pkgname
1264  character(len=*), intent(in) :: gridmap_name
1265  logical(LGP), intent(in) :: latlon
1266  integer(I4B), intent(in) :: deflate
1267  integer(I4B), intent(in) :: shuffle
1268  integer(I4B), intent(in) :: chunk_z
1269  integer(I4B), intent(in) :: chunk_y
1270  integer(I4B), intent(in) :: chunk_x
1271  character(len=*), intent(in) :: nc_fname
1272  character(len=LINELENGTH) :: varname
1273  integer(I4B) :: var_id
1274 
1275  varname = export_varname(pkgname, idt%tagname, mempath)
1276 
1277  ! reenter define mode and create variable
1278  call nf_verify(nf90_redef(ncid), nc_fname)
1279  call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1280  (/dim_ids%x, dim_ids%y/), var_id), &
1281  nc_fname)
1282 
1283  ! apply chunking parameters
1284  call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1285  ! deflate and shuffle
1286  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1287 
1288  ! put attr
1289  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1290  (/nf90_fill_int/)), nc_fname)
1291  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1292  idt%longname), nc_fname)
1293 
1294  ! add grid mapping and mf6 attr
1295  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1296  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1297 
1298  ! exit define mode and write data
1299  call nf_verify(nf90_enddef(ncid), nc_fname)
1300  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1301  count=(/dis%ncol, dis%nrow/)), &
1302  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 1307 of file DisNCStructured.f90.

1310  integer(I4B), dimension(:, :, :), pointer, contiguous, intent(in) :: p_mem
1311  integer(I4B), intent(in) :: ncid
1312  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1313  type(StructuredNCVarIdType), intent(inout) :: var_ids
1314  type(DisType), pointer, intent(in) :: dis
1315  type(InputParamDefinitionType), pointer, intent(in) :: idt
1316  character(len=*), intent(in) :: mempath
1317  character(len=*), intent(in) :: nc_tag
1318  character(len=*), intent(in) :: pkgname
1319  character(len=*), intent(in) :: gridmap_name
1320  logical(LGP), intent(in) :: latlon
1321  integer(I4B), intent(in) :: deflate
1322  integer(I4B), intent(in) :: shuffle
1323  integer(I4B), intent(in) :: chunk_z
1324  integer(I4B), intent(in) :: chunk_y
1325  integer(I4B), intent(in) :: chunk_x
1326  character(len=*), intent(in) :: nc_fname
1327  character(len=LINELENGTH) :: varname
1328  integer(I4B) :: var_id
1329 
1330  varname = export_varname(pkgname, idt%tagname, mempath)
1331 
1332  ! reenter define mode and create variable
1333  call nf_verify(nf90_redef(ncid), nc_fname)
1334  call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1335  (/dim_ids%x, dim_ids%y, dim_ids%z/), var_id), &
1336  nc_fname)
1337 
1338  ! apply chunking parameters
1339  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1340  ! deflate and shuffle
1341  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1342 
1343  ! put attr
1344  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1345  (/nf90_fill_int/)), nc_fname)
1346  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1347  idt%longname), nc_fname)
1348 
1349  ! add grid mapping and mf6 attr
1350  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1351  call ncvar_mf6attr(ncid, var_id, 0, nc_tag, nc_fname)
1352 
1353  ! exit define mode and write data
1354  call nf_verify(nf90_enddef(ncid), nc_fname)
1355  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1356  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1357  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 1053 of file DisNCStructured.f90.

1054  integer(I4B), intent(in) :: ncid
1055  integer(I4B), intent(in) :: varid
1056  integer(I4B), intent(in) :: chunk_x
1057  integer(I4B), intent(in) :: chunk_y
1058  character(len=*), intent(in) :: nc_fname
1059  if (chunk_y > 0 .and. chunk_x > 0) then
1060  call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1061  (/chunk_x, chunk_y/)), nc_fname)
1062  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 1067 of file DisNCStructured.f90.

1068  integer(I4B), intent(in) :: ncid
1069  integer(I4B), intent(in) :: varid
1070  integer(I4B), intent(in) :: chunk_x
1071  integer(I4B), intent(in) :: chunk_y
1072  integer(I4B), intent(in) :: chunk_z
1073  character(len=*), intent(in) :: nc_fname
1074  if (chunk_z > 0 .and. chunk_y > 0 .and. chunk_x > 0) then
1075  call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1076  (/chunk_x, chunk_y, chunk_z/)), &
1077  nc_fname)
1078  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 1083 of file DisNCStructured.f90.

1084  integer(I4B), intent(in) :: ncid
1085  integer(I4B), intent(in) :: varid
1086  integer(I4B), intent(in) :: deflate
1087  integer(I4B), intent(in) :: shuffle
1088  character(len=*), intent(in) :: nc_fname
1089  ! deflate and shuffle
1090  if (deflate >= 0) then
1091  call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
1092  deflate=1, deflate_level=deflate), &
1093  nc_fname)
1094  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 1099 of file DisNCStructured.f90.

1100  integer(I4B), intent(in) :: ncid
1101  integer(I4B), intent(in) :: varid
1102  character(len=*), intent(in) :: gridmap_name
1103  logical(LGP), intent(in) :: latlon
1104  character(len=*), intent(in) :: nc_fname
1105  if (gridmap_name /= '') then
1106  call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'x y'), &
1107  nc_fname)
1108  call nf_verify(nf90_put_att(ncid, varid, 'grid_mapping', gridmap_name), &
1109  nc_fname)
1110  else if (latlon) then
1111  call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'lon lat'), &
1112  nc_fname)
1113  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 1118 of file DisNCStructured.f90.

1119  integer(I4B), intent(in) :: ncid
1120  integer(I4B), intent(in) :: varid
1121  integer(I4B), intent(in) :: iaux
1122  character(len=*), intent(in) :: nc_tag
1123  character(len=*), intent(in) :: nc_fname
1124  if (nc_tag /= '') then
1125  call nf_verify(nf90_put_att(ncid, varid, 'modflow_input', &
1126  nc_tag), nc_fname)
1127  if (iaux > 0) then
1128  call nf_verify(nf90_put_att(ncid, varid, 'modflow_iaux', &
1129  iaux), nc_fname)
1130  end if
1131  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 542 of file DisNCStructured.f90.

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

Definition at line 260 of file DisNCStructured.f90.

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