MODFLOW 6  version 6.6.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, 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 step (this)
 netcdf export step More...
 
subroutine export_input_array (this, pkgtype, pkgname, mempath, idt)
 netcdf export an input array More...
 
subroutine export_input_arrays (this, pkgtype, pkgname, mempath, param_dfns)
 write package gridded input data More...
 
subroutine package_step_ilayer (this, export_pkg, ilayer_varname, ilayer)
 netcdf export package dynamic input with ilayer index variable More...
 
subroutine package_step (this, export_pkg)
 netcdf export package dynamic input More...
 
subroutine export_layer_3d (this, export_pkg, idt, ilayer_read, ialayer, dbl1d, nc_varname, input_attr, iaux)
 export layer variable as full grid 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_projection (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, iper, iaux, nc_tag, nc_fname)
 put variable internal modflow6 attributes More...
 
subroutine nc_export_int1d (ncid, dim_ids, var_ids, dis, p_mem, nc_varname, pkgname, tagname, shapestr, longname, nc_tag, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, nc_fname)
 netcdf export 1D integer More...
 
subroutine nc_export_int2d (ncid, dim_ids, var_ids, dis, p_mem, nc_varname, pkgname, tagname, shapestr, longname, nc_tag, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
 netcdf export 2D integer More...
 
subroutine nc_export_int3d (ncid, dim_ids, var_ids, dis, p_mem, nc_varname, pkgname, tagname, shapestr, longname, nc_tag, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
 netcdf export 3D integer More...
 
subroutine nc_export_dbl1d (ncid, dim_ids, var_ids, dis, p_mem, nc_varname, pkgname, tagname, shapestr, longname, nc_tag, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, nc_fname)
 netcdf export 1D double More...
 
subroutine nc_export_dbl2d (ncid, dim_ids, var_ids, dis, p_mem, nc_varname, pkgname, tagname, shapestr, longname, nc_tag, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
 netcdf export 2D double More...
 
subroutine nc_export_dbl3d (ncid, dim_ids, var_ids, dis, p_mem, nc_varname, pkgname, tagname, shapestr, longname, nc_tag, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, iaux, nc_fname)
 netcdf export 3D double More...
 
character(len=linelength) function export_varname (pkgname, idt, iper, iaux)
 build netcdf variable name 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 645 of file DisNCStructured.f90.

646  class(DisNCStructuredType), intent(inout) :: this
647  ! -- file scoped title
648  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'title', &
649  this%annotation%title), this%nc_fname)
650  ! -- source (MODFLOW 6)
651  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'source', &
652  this%annotation%source), this%nc_fname)
653  ! -- export type (MODFLOW 6)
654  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow6_grid', &
655  this%annotation%grid), this%nc_fname)
656  ! -- MODFLOW 6 model type
657  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'modflow6_model', &
658  this%annotation%model), this%nc_fname)
659  ! -- generation datetime
660  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'history', &
661  this%annotation%history), this%nc_fname)
662  ! -- supported conventions
663  call nf_verify(nf90_put_att(this%ncid, nf90_global, 'Conventions', &
664  this%annotation%conventions), &
665  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 878 of file DisNCStructured.f90.

879  class(DisNCStructuredType), intent(inout) :: this
880  integer(I4B) :: ibnd, n !, k, i, j
881  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
882  real(DP), dimension(:), allocatable :: x, y
883  !
884  allocate (x(size(this%dis%cellx)))
885  allocate (y(size(this%dis%celly)))
886 
887  do n = 1, size(this%dis%cellx)
888  x(n) = this%dis%cellx(n) + this%dis%xorigin
889  end do
890 
891  do n = 1, size(this%dis%celly)
892  y(n) = this%dis%celly(n) + this%dis%yorigin
893  end do
894 
895  call nf_verify(nf90_put_var(this%ncid, this%var_ids%x, x), &
896  this%nc_fname)
897  call nf_verify(nf90_put_var(this%ncid, this%var_ids%y, y), &
898  this%nc_fname)
899  ! -- TODO see cf-conventions 4.3.3. Parametric Vertical Coordinate
900  call nf_verify(nf90_put_var(this%ncid, this%var_ids%z, this%layers), &
901  this%nc_fname)
902 
903  deallocate (x)
904  deallocate (y)
905 
906  !
907  ! -- bounds x
908  allocate (dbl2d(2, size(this%dis%cellx)))
909  ibnd = 1
910  do n = 1, size(this%dis%cellx)
911  if (ibnd == 1) then
912  dbl2d(1, ibnd) = this%dis%xorigin
913  dbl2d(2, ibnd) = this%dis%xorigin + this%dis%delr(ibnd)
914  else
915  dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) + this%dis%delr(ibnd)
916  dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) + this%dis%delr(ibnd)
917  end if
918  ibnd = ibnd + 1
919  end do
920  call nf_verify(nf90_put_var(this%ncid, this%var_ids%x_bnds, dbl2d), &
921  this%nc_fname)
922  deallocate (dbl2d)
923 
924  ! -- bounds y
925  allocate (dbl2d(2, size(this%dis%celly)))
926  ibnd = 1
927  do n = size(this%dis%celly), 1, -1
928  if (ibnd == 1) then
929  dbl2d(1, ibnd) = this%dis%yorigin + sum(this%dis%delc) - this%dis%delc(n)
930  dbl2d(2, ibnd) = this%dis%yorigin + sum(this%dis%delc)
931  else
932  dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) - this%dis%delc(n)
933  dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) - this%dis%delc(n)
934  end if
935  ibnd = ibnd + 1
936  end do
937  call nf_verify(nf90_put_var(this%ncid, this%var_ids%y_bnds, dbl2d), &
938  this%nc_fname)
939  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 588 of file DisNCStructured.f90.

594  class(DisNCStructuredType), intent(inout) :: this
595  character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
596  type(CharacterStringType), dimension(:), contiguous, &
597  pointer :: pkgtypes => null()
598  type(CharacterStringType), dimension(:), contiguous, &
599  pointer :: pkgnames => null()
600  type(CharacterStringType), dimension(:), contiguous, &
601  pointer :: mempaths => null()
602  type(InputParamDefinitionType), dimension(:), pointer :: param_dfns
603  character(len=LENMEMPATH) :: input_mempath, mempath
604  integer(I4B) :: n
605  integer(I4B), pointer :: export_arrays
606  logical(LGP) :: found
607  !
608  input_mempath = create_mem_path(component=this%modelname, context=idm_context)
609  !
610  ! -- set pointers to model path package info
611  call mem_setptr(pkgtypes, 'PKGTYPES', input_mempath)
612  call mem_setptr(pkgnames, 'PKGNAMES', input_mempath)
613  call mem_setptr(mempaths, 'MEMPATHS', input_mempath)
614  !
615  do n = 1, size(mempaths)
616  !
617  ! -- allocate export_arrays
618  allocate (export_arrays)
619  export_arrays = 0
620  !
621  ! -- set package attributes
622  mempath = mempaths(n)
623  pname = pkgnames(n)
624  ptype = pkgtypes(n)
625  !
626  ! -- export input arrays
627  if (mempath /= '') then
628  ! -- update export
629  call mem_set_value(export_arrays, 'EXPORT_NC', mempath, found)
630  !
631  if (export_arrays > 0) then
632  pkgtype = idm_subcomponent_type(this%modeltype, ptype)
633  param_dfns => param_definitions(this%modeltype, pkgtype)
634  call this%export_input_arrays(ptype, pname, mempath, param_dfns)
635  end if
636  end if
637  !
638  ! -- cleanup
639  deallocate (export_arrays)
640  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 858 of file DisNCStructured.f90.

859  class(DisNCStructuredType), intent(inout) :: this
860  if (this%latlon .and. this%ogc_wkt /= '') then
861  ! -- lat
862  !
863  call nf_verify(nf90_put_var(this%ncid, this%var_ids%lat, &
864  this%lat, start=(/1, 1/), &
865  count=(/this%dis%ncol, this%dis%nrow/)), &
866  this%nc_fname)
867  ! -- lon
868  !
869  call nf_verify(nf90_put_var(this%ncid, this%var_ids%lon, &
870  this%lon, start=(/1, 1/), &
871  count=(/this%dis%ncol, this%dis%nrow/)), &
872  this%nc_fname)
873  end if
Here is the call graph for this function:

◆ define_dependent()

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

Definition at line 771 of file DisNCStructured.f90.

772  use constantsmodule, only: dhnoflo
773  class(DisNCStructuredType), intent(inout) :: this
774  !
775  call nf_verify(nf90_def_var(this%ncid, this%xname, nf90_double, &
776  (/this%dim_ids%x, this%dim_ids%y, &
777  this%dim_ids%z, this%dim_ids%time/), &
778  this%var_ids%dependent), &
779  this%nc_fname)
780  ! -- apply chunking parameters
781  if (this%chunking_active) then
782  call nf_verify(nf90_def_var_chunking(this%ncid, &
783  this%var_ids%dependent, &
784  nf90_chunked, &
785  (/this%chunk_x, this%chunk_y, &
786  this%chunk_z, this%chunk_time/)), &
787  this%nc_fname)
788  end if
789  ! -- deflate and shuffle
790  call ncvar_deflate(this%ncid, this%var_ids%dependent, this%deflate, &
791  this%shuffle, this%nc_fname)
792  !
793  ! -- put attr
794  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
795  'units', 'm'), this%nc_fname)
796  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
797  'standard_name', this%annotation%stdname), &
798  this%nc_fname)
799  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, 'long_name', &
800  this%annotation%longname), this%nc_fname)
801  call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, '_FillValue', &
802  (/dhnoflo/)), this%nc_fname)
803  !
804  ! -- add grid mapping
805  call ncvar_gridmap(this%ncid, this%var_ids%dependent, this%gridmap_name, &
806  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 670 of file DisNCStructured.f90.

671  use constantsmodule, only: mvalidate
672  use simvariablesmodule, only: isim_mode
673  class(DisNCStructuredType), intent(inout) :: this
674 
675  ! bound dim
676  call nf_verify(nf90_def_dim(this%ncid, 'bnd', 2, this%dim_ids%bnd), &
677  this%nc_fname)
678  !
679  ! -- Time
680  if (isim_mode /= mvalidate) then
681  call nf_verify(nf90_def_dim(this%ncid, 'time', this%totnstp, &
682  this%dim_ids%time), this%nc_fname)
683  call nf_verify(nf90_def_var(this%ncid, 'time', nf90_double, &
684  this%dim_ids%time, this%var_ids%time), &
685  this%nc_fname)
686  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'calendar', &
687  'standard'), this%nc_fname)
688  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'units', &
689  this%datetime), this%nc_fname)
690  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'axis', 'T'), &
691  this%nc_fname)
692  !call nf_verify(nf90_put_att(ncid, var_ids%time, 'bounds', 'time_bnds'), this%nc_fname)
693  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'standard_name', &
694  'time'), this%nc_fname)
695  call nf_verify(nf90_put_att(this%ncid, this%var_ids%time, 'long_name', &
696  'time'), this%nc_fname)
697  end if
698  !
699  ! -- Z dimension
700  call nf_verify(nf90_def_dim(this%ncid, 'z', this%dis%nlay, this%dim_ids%z), &
701  this%nc_fname)
702  call nf_verify(nf90_def_var(this%ncid, 'z', nf90_double, this%dim_ids%z, &
703  this%var_ids%z), this%nc_fname)
704  call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'units', 'layer'), &
705  this%nc_fname)
706  call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'long_name', &
707  'layer number'), this%nc_fname)
708  !call nf_verify(nf90_put_att(this%ncid, this%var_ids%z, 'bounds', 'z_bnds'), &
709  ! this%nc_fname)
710  !call nf_verify(nf90_def_var(this%ncid, 'z_bnds', NF90_DOUBLE, &
711  ! (/this%dim_ids%bnd, this%dim_ids%z/), &
712  ! this%var_ids%z_bnds), this%nc_fname)
713  !call nf_verify(nf90_put_var(this%ncid, this%var_ids%z_bnds, &
714  ! this%elev_bnds), this%nc_fname)
715  !
716  ! -- Y dimension
717  call nf_verify(nf90_def_dim(this%ncid, 'y', this%dis%nrow, this%dim_ids%y), &
718  this%nc_fname)
719  call nf_verify(nf90_def_var(this%ncid, 'y', nf90_double, this%dim_ids%y, &
720  this%var_ids%y), this%nc_fname)
721  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'units', 'm'), &
722  this%nc_fname)
723  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'axis', 'Y'), &
724  this%nc_fname)
725  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'standard_name', &
726  'projection_y_coordinate'), this%nc_fname)
727  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'long_name', &
728  'Northing'), this%nc_fname)
729  if (this%ogc_wkt /= '') then
730  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'grid_mapping', &
731  this%gridmap_name), this%nc_fname)
732  end if
733  call nf_verify(nf90_put_att(this%ncid, this%var_ids%y, 'bounds', 'y_bnds'), &
734  this%nc_fname)
735  call nf_verify(nf90_def_var(this%ncid, 'y_bnds', nf90_double, &
736  (/this%dim_ids%bnd, this%dim_ids%y/), &
737  this%var_ids%y_bnds), this%nc_fname)
738  !
739  ! -- X dimension
740  call nf_verify(nf90_def_dim(this%ncid, 'x', this%dis%ncol, this%dim_ids%x), &
741  this%nc_fname)
742  call nf_verify(nf90_def_var(this%ncid, 'x', nf90_double, this%dim_ids%x, &
743  this%var_ids%x), this%nc_fname)
744  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'units', 'm'), &
745  this%nc_fname)
746  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'axis', 'X'), &
747  this%nc_fname)
748  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'standard_name', &
749  'projection_x_coordinate'), this%nc_fname)
750  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'long_name', &
751  'Easting'), this%nc_fname)
752  if (this%ogc_wkt /= '') then
753  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'grid_mapping', &
754  this%gridmap_name), this%nc_fname)
755  end if
756  call nf_verify(nf90_put_att(this%ncid, this%var_ids%x, 'bounds', 'x_bnds'), &
757  this%nc_fname)
758  call nf_verify(nf90_def_var(this%ncid, 'x_bnds', nf90_double, &
759  (/this%dim_ids%bnd, this%dim_ids%x/), &
760  this%var_ids%x_bnds), this%nc_fname)
761 
762  !
763  ! -- NCPL dimension
764  call nf_verify(nf90_def_dim(this%ncid, 'ncpl', &
765  this%dis%ncol * this%dis%nrow, &
766  this%dim_ids%ncpl), 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_gridmap()

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

Definition at line 811 of file DisNCStructured.f90.

812  class(DisNCStructuredType), intent(inout) :: this
813  integer(I4B) :: var_id
814  if (this%ogc_wkt /= '') then
815  call nf_verify(nf90_redef(this%ncid), this%nc_fname)
816  call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
817  var_id), this%nc_fname)
818  ! -- TODO: consider variants epsg_code, spatial_ref, esri_pe_string, wkt, etc
819  call nf_verify(nf90_put_att(this%ncid, var_id, 'crs_wkt', this%ogc_wkt), &
820  this%nc_fname)
821  call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
822  call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
823  this%nc_fname)
824  end if
Here is the call graph for this function:

◆ define_projection()

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

Definition at line 829 of file DisNCStructured.f90.

830  class(DisNCStructuredType), intent(inout) :: this
831  if (this%latlon .and. this%ogc_wkt /= '') then
832  ! -- lat
833  call nf_verify(nf90_def_var(this%ncid, 'lat', nf90_double, &
834  (/this%dim_ids%x, this%dim_ids%y/), &
835  this%var_ids%lat), this%nc_fname)
836  call nf_verify(nf90_put_att(this%ncid, this%var_ids%lat, 'units', &
837  'degrees_north'), this%nc_fname)
838  call nf_verify(nf90_put_att(this%ncid, this%var_ids%lat, 'standard_name', &
839  'latitude'), this%nc_fname)
840  call nf_verify(nf90_put_att(this%ncid, this%var_ids%lat, 'long_name', &
841  'latitude'), this%nc_fname)
842  !
843  ! -- lon
844  call nf_verify(nf90_def_var(this%ncid, 'lon', nf90_double, &
845  (/this%dim_ids%x, this%dim_ids%y/), &
846  this%var_ids%lon), this%nc_fname)
847  call nf_verify(nf90_put_att(this%ncid, this%var_ids%lon, 'units', &
848  'degrees_east'), this%nc_fname)
849  call nf_verify(nf90_put_att(this%ncid, this%var_ids%lon, 'standard_name', &
850  'longitude'), this%nc_fname)
851  call nf_verify(nf90_put_att(this%ncid, this%var_ids%lon, 'long_name', &
852  'longitude'), this%nc_fname)
853  end if
Here is the call graph for this function:

◆ df()

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

Definition at line 177 of file DisNCStructured.f90.

178  use constantsmodule, only: mvalidate
179  use simvariablesmodule, only: isim_mode
180  class(DisNCStructuredType), intent(inout) :: this
181  ! -- put root group file scope attributes
182  call this%add_global_att()
183  ! -- define root group dimensions and coordinate variables
184  call this%define_dim()
185  ! -- define grid projection variables
186  call this%define_projection()
187  if (isim_mode /= mvalidate) then
188  ! -- define the dependent variable
189  call this%define_dependent()
190  end if
191  ! -- exit define mode
192  call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
193  ! -- add data locations
194  call this%add_grid_data()
195  ! -- add projection data
196  call this%add_proj_data()
197  ! -- define and set package input griddata
198  call this%add_pkg_data()
199  ! -- define and set gridmap variable
200  call this%define_gridmap()
201  ! -- synchronize file
202  call nf_verify(nf90_sync(this%ncid), this%nc_fname)
Here is the call graph for this function:

◆ dis_export_destroy()

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

Definition at line 158 of file DisNCStructured.f90.

159  class(DisNCStructuredType), intent(inout) :: this
160  call nf_verify(nf90_close(this%ncid), this%nc_fname)
161  !
162  deallocate (this%chunk_z)
163  deallocate (this%chunk_y)
164  deallocate (this%chunk_x)
165  deallocate (this%layers)
166  !
167  nullify (this%chunk_z)
168  nullify (this%chunk_y)
169  nullify (this%chunk_x)
170  !
171  ! -- destroy base class
172  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,
integer(i4b), intent(in)  disenum,
integer(i4b), intent(in)  nctype,
integer(i4b), intent(in)  iout 
)
private

Definition at line 93 of file DisNCStructured.f90.

97  class(DisNCStructuredType), intent(inout) :: this
98  character(len=*), intent(in) :: modelname
99  character(len=*), intent(in) :: modeltype
100  character(len=*), intent(in) :: modelfname
101  integer(I4B), intent(in) :: disenum
102  integer(I4B), intent(in) :: nctype
103  integer(I4B), intent(in) :: iout
104  integer(I4B) :: k, latsz, lonsz
105  logical(LGP) :: found
106  !
107  ! -- set nlay
108  this%nlay = this%dis%nlay
109  !
110  ! -- allocate
111  allocate (this%chunk_z)
112  allocate (this%chunk_y)
113  allocate (this%chunk_x)
114  allocate (this%layers(this%nlay))
115  !
116  ! -- initialize
117  this%chunk_z = -1
118  this%chunk_y = -1
119  this%chunk_x = -1
120  do k = 1, this%nlay
121  this%layers(k) = k
122  end do
123  !
124  this%latlon = .false.
125  !
126  ! -- initialize base class
127  call this%NCModelExportType%init(modelname, modeltype, modelfname, disenum, &
128  nctype, iout)
129  ! -- update values from input context
130  if (this%ncf_mempath /= '') then
131  call mem_set_value(this%chunk_z, 'CHUNK_Z', this%ncf_mempath, found)
132  call mem_set_value(this%chunk_y, 'CHUNK_Y', this%ncf_mempath, found)
133  call mem_set_value(this%chunk_x, 'CHUNK_X', this%ncf_mempath, found)
134  !
135  if (this%chunk_time > 0 .and. this%chunk_z > 0 .and. &
136  this%chunk_y > 0 .and. this%chunk_x > 0) then
137  this%chunking_active = .true.
138  end if
139  !
140  call get_isize('LAT', this%ncf_mempath, latsz)
141  call get_isize('LON', this%ncf_mempath, lonsz)
142  !
143  if (latsz > 0 .and. lonsz > 0) then
144  this%latlon = .true.
145  call mem_setptr(this%lat, 'LAT', this%ncf_mempath)
146  call mem_setptr(this%lon, 'LON', this%ncf_mempath)
147  end if
148  end if
149  !
150  ! -- create the netcdf file
151  call nf_verify(nf90_create(this%nc_fname, &
152  ior(nf90_clobber, nf90_netcdf4), this%ncid), &
153  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_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 255 of file DisNCStructured.f90.

256  class(DisNCStructuredType), intent(inout) :: this
257  character(len=*), intent(in) :: pkgtype
258  character(len=*), intent(in) :: pkgname
259  character(len=*), intent(in) :: mempath
260  type(InputParamDefinitionType), pointer, intent(in) :: idt
261  integer(I4B), dimension(:), pointer, contiguous :: int1d
262  integer(I4B), dimension(:, :), pointer, contiguous :: int2d
263  integer(I4B), dimension(:, :, :), pointer, contiguous :: int3d
264  real(DP), dimension(:), pointer, contiguous :: dbl1d
265  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
266  real(DP), dimension(:, :, :), pointer, contiguous :: dbl3d
267  character(len=LINELENGTH) :: nc_varname, input_attr
268  integer(I4B) :: iper, iaux
269  !
270  ! -- initialize
271  iper = 0
272  iaux = 0
273  !
274  ! -- set variable name and input attribute string
275  nc_varname = export_varname(pkgname, idt)
276  input_attr = this%input_attribute(pkgname, idt)
277  !
278  select case (idt%datatype)
279  case ('INTEGER1D')
280  call mem_setptr(int1d, idt%mf6varname, mempath)
281  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
282  int1d, nc_varname, pkgname, idt%tagname, &
283  idt%shape, idt%longname, input_attr, &
284  this%gridmap_name, this%latlon, this%deflate, &
285  this%shuffle, this%chunk_z, this%chunk_y, &
286  this%chunk_x, iper, this%nc_fname)
287  case ('INTEGER2D')
288  call mem_setptr(int2d, idt%mf6varname, mempath)
289  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
290  int2d, nc_varname, pkgname, idt%tagname, &
291  idt%shape, idt%longname, input_attr, &
292  this%gridmap_name, this%latlon, this%deflate, &
293  this%shuffle, this%chunk_z, this%chunk_y, &
294  this%chunk_x, this%nc_fname)
295  case ('INTEGER3D')
296  call mem_setptr(int3d, idt%mf6varname, mempath)
297  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
298  int3d, nc_varname, pkgname, idt%tagname, &
299  idt%shape, idt%longname, input_attr, &
300  this%gridmap_name, this%latlon, this%deflate, &
301  this%shuffle, this%chunk_z, this%chunk_y, &
302  this%chunk_x, this%nc_fname)
303  case ('DOUBLE1D')
304  call mem_setptr(dbl1d, idt%mf6varname, mempath)
305  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
306  dbl1d, nc_varname, pkgname, idt%tagname, &
307  idt%shape, idt%longname, input_attr, &
308  this%gridmap_name, this%latlon, this%deflate, &
309  this%shuffle, this%chunk_z, this%chunk_y, &
310  this%chunk_x, iper, this%nc_fname)
311  case ('DOUBLE2D')
312  call mem_setptr(dbl2d, idt%mf6varname, mempath)
313  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
314  dbl2d, nc_varname, pkgname, idt%tagname, &
315  idt%shape, idt%longname, input_attr, &
316  this%gridmap_name, this%latlon, this%deflate, &
317  this%shuffle, this%chunk_z, this%chunk_y, &
318  this%chunk_x, this%nc_fname)
319  case ('DOUBLE3D')
320  call mem_setptr(dbl3d, idt%mf6varname, mempath)
321  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
322  dbl3d, nc_varname, pkgname, idt%tagname, &
323  idt%shape, idt%longname, input_attr, &
324  this%gridmap_name, this%latlon, this%deflate, &
325  this%shuffle, this%chunk_z, this%chunk_y, &
326  this%chunk_x, iper, iaux, this%nc_fname)
327  case default
328  ! -- no-op, no other datatypes exported
329  end select
Here is the call graph for this function:

◆ 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 
)
private

Definition at line 334 of file DisNCStructured.f90.

335  use memorymanagermodule, only: get_isize
336  class(DisNCStructuredType), intent(inout) :: this
337  character(len=*), intent(in) :: pkgtype
338  character(len=*), intent(in) :: pkgname
339  character(len=*), intent(in) :: mempath
340  type(InputParamDefinitionType), dimension(:), pointer, &
341  intent(in) :: param_dfns
342  type(InputParamDefinitionType), pointer :: idt
343  integer(I4B) :: iparam, isize
344  !
345  do iparam = 1, size(param_dfns)
346  ! -- assign param definition pointer
347  idt => param_dfns(iparam)
348  ! -- for now
349  if (idt%blockname == 'GRIDDATA') then
350  ! -- check if variable is already allocated
351  call get_isize(idt%mf6varname, mempath, isize)
352  !
353  if (isize > 0) then
354  call this%export_input_array(pkgtype, pkgname, mempath, idt)
355  end if
356  end if
357  end do
Here is the call graph for this function:

◆ export_layer_3d()

subroutine disncstructuredmodule::export_layer_3d ( class(disncstructuredtype), intent(inout)  this,
class(exportpackagetype), intent(in), pointer  export_pkg,
type(inputparamdefinitiontype), intent(in), pointer  idt,
logical(lgp), intent(in)  ilayer_read,
integer(i4b), dimension(:), intent(in), pointer, contiguous  ialayer,
real(dp), dimension(:), intent(in), pointer, contiguous  dbl1d,
character(len=*), intent(inout)  nc_varname,
character(len=*), intent(in)  input_attr,
integer(i4b), intent(in), optional  iaux 
)

Definition at line 525 of file DisNCStructured.f90.

527  use constantsmodule, only: dnodata, dzero
528  use tdismodule, only: kper
530  class(DisNCStructuredType), intent(inout) :: this
531  class(ExportPackageType), pointer, intent(in) :: export_pkg
532  type(InputParamDefinitionType), pointer, intent(in) :: idt
533  logical(LGP), intent(in) :: ilayer_read
534  integer(I4B), dimension(:), pointer, contiguous, intent(in) :: ialayer
535  real(DP), dimension(:), pointer, contiguous, intent(in) :: dbl1d
536  character(len=*), intent(inout) :: nc_varname
537  character(len=*), intent(in) :: input_attr
538  integer(I4B), optional, intent(in) :: iaux
539  ! -- local
540  real(DP), dimension(:, :, :), pointer, contiguous :: dbl3d
541  integer(I4B) :: n, i, j, k, nvals, idxaux
542  real(DP), dimension(:, :), contiguous, pointer :: dbl2d_ptr
543  !
544  ! -- initialize
545  idxaux = 0
546  if (present(iaux)) then
547  nc_varname = export_varname(export_pkg%mf6_input%subcomponent_name, &
548  idt, iper=kper, iaux=iaux)
549  idxaux = iaux
550  end if
551 
552  allocate (dbl3d(export_pkg%mshape(3), export_pkg%mshape(2), &
553  export_pkg%mshape(1)))
554  !
555  if (ilayer_read) then
556  do k = 1, size(dbl3d, dim=3)
557  n = 0
558  do i = 1, size(dbl3d, dim=2)
559  do j = 1, size(dbl3d, dim=1)
560  n = n + 1
561  if (ialayer(n) == k) then
562  dbl3d(j, i, k) = dbl1d(n)
563  else
564  dbl3d(j, i, k) = dnodata
565  end if
566  end do
567  end do
568  end do
569  else
570  dbl3d = dnodata
571  nvals = export_pkg%mshape(3) * export_pkg%mshape(2)
572  dbl2d_ptr(1:export_pkg%mshape(3), 1:export_pkg%mshape(2)) => dbl1d(1:nvals)
573  dbl3d(:, :, 1) = dbl2d_ptr(:, :)
574  end if
575  !
576  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, dbl3d, &
577  nc_varname, export_pkg%mf6_input%subcomponent_name, &
578  idt%tagname, idt%shape, idt%longname, input_attr, &
579  this%gridmap_name, this%latlon, this%deflate, &
580  this%shuffle, this%chunk_z, this%chunk_y, this%chunk_x, &
581  export_pkg%iper, idxaux, this%nc_fname)
582 
583  deallocate (dbl3d)
real(dp), parameter dnodata
real no data constant
Definition: Constants.f90:95
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:65
This module contains the NCModelExportModule.
Definition: NCModel.f90:8
integer(i4b), pointer, public kper
current stress period number
Definition: tdis.f90:23
Here is the call graph for this function:

◆ export_varname()

character(len=linelength) function disncstructuredmodule::export_varname ( character(len=*), intent(in)  pkgname,
type(inputparamdefinitiontype), intent(in), pointer  idt,
integer(i4b), intent(in), optional  iper,
integer(i4b), intent(in), optional  iaux 
)

Definition at line 1482 of file DisNCStructured.f90.

1483  use inputoutputmodule, only: lowcase
1484  character(len=*), intent(in) :: pkgname
1485  type(InputParamDefinitionType), pointer, intent(in) :: idt
1486  integer(I4B), optional, intent(in) :: iper
1487  integer(I4B), optional, intent(in) :: iaux
1488  character(len=LINELENGTH) :: varname
1489  character(len=LINELENGTH) :: pname, vname
1490  !
1491  pname = pkgname
1492  vname = idt%mf6varname
1493  call lowcase(pname)
1494  call lowcase(vname)
1495  if (present(iper)) then
1496  if (present(iaux)) then
1497  write (varname, '(a,i0,a,i0)') trim(pname)//'_'//trim(vname)// &
1498  '_p', iper, 'a', iaux
1499  else
1500  write (varname, '(a,i0)') trim(pname)//'_'//trim(vname)//'_p', iper
1501  end if
1502  else
1503  varname = trim(pname)//'_'//trim(vname)
1504  end if
subroutine, public lowcase(word)
Convert to lower case.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nc_export_dbl1d()

subroutine disncstructuredmodule::nc_export_dbl1d ( integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
real(dp), dimension(:), intent(in), pointer, contiguous  p_mem,
character(len=*), intent(in)  nc_varname,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  tagname,
character(len=*), intent(in)  shapestr,
character(len=*), intent(in)  longname,
character(len=*), intent(in)  nc_tag,
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 1250 of file DisNCStructured.f90.

1254  use constantsmodule, only: dnodata
1255  integer(I4B), intent(in) :: ncid
1256  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1257  type(StructuredNCVarIdType), intent(inout) :: var_ids
1258  type(DisType), pointer, intent(in) :: dis
1259  real(DP), dimension(:), pointer, contiguous, intent(in) :: p_mem
1260  character(len=*), intent(in) :: nc_varname
1261  character(len=*), intent(in) :: pkgname
1262  character(len=*), intent(in) :: tagname
1263  character(len=*), intent(in) :: shapestr
1264  character(len=*), intent(in) :: longname
1265  character(len=*), intent(in) :: nc_tag
1266  character(len=*), intent(in) :: gridmap_name
1267  logical(LGP), intent(in) :: latlon
1268  integer(I4B), intent(in) :: deflate
1269  integer(I4B), intent(in) :: shuffle
1270  integer(I4B), intent(in) :: chunk_z
1271  integer(I4B), intent(in) :: chunk_y
1272  integer(I4B), intent(in) :: chunk_x
1273  integer(I4B), intent(in) :: iper
1274  character(len=*), intent(in) :: nc_fname
1275  ! -- local
1276  integer(I4B) :: var_id, axis_sz
1277  real(DP) :: fill_value
1278  character(len=LINELENGTH) :: longname_l
1279  !
1280  if (shapestr == 'NROW' .or. &
1281  shapestr == 'NCOL' .or. &
1282  shapestr == 'NCPL') then
1283  !
1284  select case (shapestr)
1285  case ('NROW')
1286  axis_sz = dim_ids%y
1287  case ('NCOL')
1288  axis_sz = dim_ids%x
1289  case ('NCPL')
1290  axis_sz = dim_ids%ncpl
1291  end select
1292  !
1293  ! -- reenter define mode and create variable
1294  call nf_verify(nf90_redef(ncid), nc_fname)
1295  call nf_verify(nf90_def_var(ncid, nc_varname, nf90_double, &
1296  (/axis_sz/), var_id), &
1297  nc_fname)
1298  !
1299  ! -- NROW/NCOL shapes use default chunking
1300  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1301  !
1302  ! -- put attr
1303  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1304  (/nf90_fill_double/)), nc_fname)
1305  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1306  longname), nc_fname)
1307  !
1308  ! -- add mf6 attr
1309  call ncvar_mf6attr(ncid, var_id, 0, 0, nc_tag, nc_fname)
1310  !
1311  ! -- exit define mode and write data
1312  call nf_verify(nf90_enddef(ncid), nc_fname)
1313  call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1314  nc_fname)
1315 
1316  else
1317  !
1318  if (iper > 0) then
1319  fill_value = dnodata
1320  else
1321  fill_value = nf90_fill_double
1322  end if
1323  !
1324  longname_l = export_longname(longname, pkgname, tagname, layer=0, iper=iper)
1325  !
1326  ! -- reenter define mode and create variable
1327  call nf_verify(nf90_redef(ncid), nc_fname)
1328  call nf_verify(nf90_def_var(ncid, nc_varname, nf90_double, &
1329  (/dim_ids%x, dim_ids%y, dim_ids%z/), var_id), &
1330  nc_fname)
1331  !
1332  ! -- apply chunking parameters
1333  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1334  ! -- deflate and shuffle
1335  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1336  !
1337  ! -- put attr
1338  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1339  (/fill_value/)), nc_fname)
1340  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1341  longname_l), nc_fname)
1342  !
1343  ! -- add grid mapping and mf6 attr
1344  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1345  call ncvar_mf6attr(ncid, var_id, iper, 0, nc_tag, nc_fname)
1346  !
1347  ! -- exit define mode and write data
1348  call nf_verify(nf90_enddef(ncid), nc_fname)
1349  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1350  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1351  nc_fname)
1352  end if

◆ nc_export_dbl2d()

subroutine disncstructuredmodule::nc_export_dbl2d ( integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
real(dp), dimension(:, :), intent(in), pointer, contiguous  p_mem,
character(len=*), intent(in)  nc_varname,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  tagname,
character(len=*), intent(in)  shapestr,
character(len=*), intent(in)  longname,
character(len=*), intent(in)  nc_tag,
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 1357 of file DisNCStructured.f90.

1361  integer(I4B), intent(in) :: ncid
1362  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1363  type(StructuredNCVarIdType), intent(inout) :: var_ids
1364  type(DisType), pointer, intent(in) :: dis
1365  real(DP), dimension(:, :), pointer, contiguous, intent(in) :: p_mem
1366  character(len=*), intent(in) :: nc_varname
1367  character(len=*), intent(in) :: pkgname
1368  character(len=*), intent(in) :: tagname
1369  character(len=*), intent(in) :: shapestr
1370  character(len=*), intent(in) :: longname
1371  character(len=*), intent(in) :: nc_tag
1372  character(len=*), intent(in) :: gridmap_name
1373  logical(LGP), intent(in) :: latlon
1374  integer(I4B), intent(in) :: deflate
1375  integer(I4B), intent(in) :: shuffle
1376  integer(I4B), intent(in) :: chunk_z
1377  integer(I4B), intent(in) :: chunk_y
1378  integer(I4B), intent(in) :: chunk_x
1379  character(len=*), intent(in) :: nc_fname
1380  ! -- local
1381  integer(I4B) :: var_id
1382  !
1383  ! -- reenter define mode and create variable
1384  call nf_verify(nf90_redef(ncid), nc_fname)
1385  call nf_verify(nf90_def_var(ncid, nc_varname, nf90_double, &
1386  (/dim_ids%x, dim_ids%y/), var_id), &
1387  nc_fname)
1388  !
1389  ! -- apply chunking parameters
1390  call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1391  ! -- deflate and shuffle
1392  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1393  !
1394  ! -- put attr
1395  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1396  (/nf90_fill_double/)), nc_fname)
1397  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1398  longname), nc_fname)
1399  !
1400  ! -- add grid mapping and mf6 attr
1401  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1402  call ncvar_mf6attr(ncid, var_id, 0, 0, nc_tag, nc_fname)
1403  !
1404  ! -- exit define mode and write data
1405  call nf_verify(nf90_enddef(ncid), nc_fname)
1406  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1407  count=(/dis%ncol, dis%nrow/)), &
1408  nc_fname)

◆ nc_export_dbl3d()

subroutine disncstructuredmodule::nc_export_dbl3d ( integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
real(dp), dimension(:, :, :), intent(in), pointer, contiguous  p_mem,
character(len=*), intent(in)  nc_varname,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  tagname,
character(len=*), intent(in)  shapestr,
character(len=*), intent(in)  longname,
character(len=*), intent(in)  nc_tag,
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 1413 of file DisNCStructured.f90.

1417  use constantsmodule, only: dnodata
1418  integer(I4B), intent(in) :: ncid
1419  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1420  type(StructuredNCVarIdType), intent(inout) :: var_ids
1421  type(DisType), pointer, intent(in) :: dis
1422  real(DP), dimension(:, :, :), pointer, contiguous, intent(in) :: p_mem
1423  character(len=*), intent(in) :: nc_varname
1424  character(len=*), intent(in) :: pkgname
1425  character(len=*), intent(in) :: tagname
1426  character(len=*), intent(in) :: shapestr
1427  character(len=*), intent(in) :: longname
1428  character(len=*), intent(in) :: nc_tag
1429  character(len=*), intent(in) :: gridmap_name
1430  logical(LGP), intent(in) :: latlon
1431  integer(I4B), intent(in) :: deflate
1432  integer(I4B), intent(in) :: shuffle
1433  integer(I4B), intent(in) :: chunk_z
1434  integer(I4B), intent(in) :: chunk_y
1435  integer(I4B), intent(in) :: chunk_x
1436  integer(I4B), intent(in) :: iper
1437  integer(I4B), intent(in) :: iaux
1438  character(len=*), intent(in) :: nc_fname
1439  ! -- local
1440  integer(I4B) :: var_id
1441  real(DP) :: fill_value
1442  character(len=LINELENGTH) :: longname_l
1443  !
1444  if (iper > 0) then
1445  fill_value = dnodata
1446  else
1447  fill_value = nf90_fill_double
1448  end if
1449  !
1450  longname_l = export_longname(longname, pkgname, tagname, layer=0, iper=iper)
1451  !
1452  ! -- reenter define mode and create variable
1453  call nf_verify(nf90_redef(ncid), nc_fname)
1454  call nf_verify(nf90_def_var(ncid, nc_varname, nf90_double, &
1455  (/dim_ids%x, dim_ids%y, dim_ids%z/), var_id), &
1456  nc_fname)
1457  !
1458  ! -- apply chunking parameters
1459  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1460  ! -- deflate and shuffle
1461  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1462  !
1463  ! -- put attr
1464  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1465  (/fill_value/)), nc_fname)
1466  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1467  longname_l), nc_fname)
1468  !
1469  ! -- add grid mapping and mf6 attr
1470  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1471  call ncvar_mf6attr(ncid, var_id, iper, iaux, nc_tag, nc_fname)
1472  !
1473  ! -- exit define mode and write data
1474  call nf_verify(nf90_enddef(ncid), nc_fname)
1475  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1476  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1477  nc_fname)

◆ nc_export_int1d()

subroutine disncstructuredmodule::nc_export_int1d ( integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
integer(i4b), dimension(:), intent(in), pointer, contiguous  p_mem,
character(len=*), intent(in)  nc_varname,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  tagname,
character(len=*), intent(in)  shapestr,
character(len=*), intent(in)  longname,
character(len=*), intent(in)  nc_tag,
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 1039 of file DisNCStructured.f90.

1043  integer(I4B), intent(in) :: ncid
1044  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1045  type(StructuredNCVarIdType), intent(inout) :: var_ids
1046  type(DisType), pointer, intent(in) :: dis
1047  integer(I4B), dimension(:), pointer, contiguous, intent(in) :: p_mem
1048  character(len=*), intent(in) :: nc_varname
1049  character(len=*), intent(in) :: pkgname
1050  character(len=*), intent(in) :: tagname
1051  character(len=*), intent(in) :: shapestr
1052  character(len=*), intent(in) :: longname
1053  character(len=*), intent(in) :: nc_tag
1054  character(len=*), intent(in) :: gridmap_name
1055  logical(LGP), intent(in) :: latlon
1056  integer(I4B), intent(in) :: deflate
1057  integer(I4B), intent(in) :: shuffle
1058  integer(I4B), intent(in) :: chunk_z
1059  integer(I4B), intent(in) :: chunk_y
1060  integer(I4B), intent(in) :: chunk_x
1061  integer(I4B), intent(in) :: iper
1062  character(len=*), intent(in) :: nc_fname
1063  ! -- local
1064  integer(I4B) :: var_id, axis_sz
1065  character(len=LINELENGTH) :: longname_l
1066  !
1067  if (shapestr == 'NROW' .or. &
1068  shapestr == 'NCOL' .or. &
1069  shapestr == 'NCPL') then
1070  !
1071  select case (shapestr)
1072  case ('NROW')
1073  axis_sz = dim_ids%y
1074  case ('NCOL')
1075  axis_sz = dim_ids%x
1076  case ('NCPL')
1077  axis_sz = dim_ids%ncpl
1078  end select
1079  !
1080  longname_l = export_longname(longname, pkgname, tagname, layer=0, iper=iper)
1081  !
1082  ! -- reenter define mode and create variable
1083  call nf_verify(nf90_redef(ncid), nc_fname)
1084  call nf_verify(nf90_def_var(ncid, nc_varname, nf90_int, &
1085  (/axis_sz/), var_id), &
1086  nc_fname)
1087  !
1088  ! -- NROW/NCOL shapes use default chunking
1089  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1090  !
1091  ! -- put attr
1092  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1093  (/nf90_fill_int/)), nc_fname)
1094  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1095  longname_l), nc_fname)
1096  !
1097  ! -- add mf6 attr
1098  call ncvar_mf6attr(ncid, var_id, iper, 0, nc_tag, nc_fname)
1099  !
1100  ! -- exit define mode and write data
1101  call nf_verify(nf90_enddef(ncid), nc_fname)
1102  call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1103  nc_fname)
1104 
1105  else
1106  !
1107  ! -- reenter define mode and create variable
1108  call nf_verify(nf90_redef(ncid), nc_fname)
1109  call nf_verify(nf90_def_var(ncid, nc_varname, nf90_int, &
1110  (/dim_ids%x, dim_ids%y, dim_ids%z/), var_id), &
1111  nc_fname)
1112  !
1113  ! -- apply chunking parameters
1114  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1115  ! -- deflate and shuffle
1116  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1117  !
1118  ! -- put attr
1119  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1120  (/nf90_fill_int/)), nc_fname)
1121  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1122  longname), nc_fname)
1123  !
1124  ! -- add grid mapping and mf6 attr
1125  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1126  call ncvar_mf6attr(ncid, var_id, 0, 0, nc_tag, nc_fname)
1127  !
1128  ! -- exit define mode and write data
1129  call nf_verify(nf90_enddef(ncid), nc_fname)
1130  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1131  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1132  nc_fname)
1133  end if

◆ nc_export_int2d()

subroutine disncstructuredmodule::nc_export_int2d ( integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
integer(i4b), dimension(:, :), intent(in), pointer, contiguous  p_mem,
character(len=*), intent(in)  nc_varname,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  tagname,
character(len=*), intent(in)  shapestr,
character(len=*), intent(in)  longname,
character(len=*), intent(in)  nc_tag,
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 1138 of file DisNCStructured.f90.

1142  integer(I4B), intent(in) :: ncid
1143  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1144  type(StructuredNCVarIdType), intent(inout) :: var_ids
1145  type(DisType), pointer, intent(in) :: dis
1146  integer(I4B), dimension(:, :), pointer, contiguous, intent(in) :: p_mem
1147  character(len=*), intent(in) :: nc_varname
1148  character(len=*), intent(in) :: pkgname
1149  character(len=*), intent(in) :: tagname
1150  character(len=*), intent(in) :: shapestr
1151  character(len=*), intent(in) :: longname
1152  character(len=*), intent(in) :: nc_tag
1153  character(len=*), intent(in) :: gridmap_name
1154  logical(LGP), intent(in) :: latlon
1155  integer(I4B), intent(in) :: deflate
1156  integer(I4B), intent(in) :: shuffle
1157  integer(I4B), intent(in) :: chunk_z
1158  integer(I4B), intent(in) :: chunk_y
1159  integer(I4B), intent(in) :: chunk_x
1160  character(len=*), intent(in) :: nc_fname
1161  ! -- local
1162  integer(I4B) :: var_id
1163  !
1164  ! -- reenter define mode and create variable
1165  call nf_verify(nf90_redef(ncid), nc_fname)
1166  call nf_verify(nf90_def_var(ncid, nc_varname, nf90_int, &
1167  (/dim_ids%x, dim_ids%y/), var_id), &
1168  nc_fname)
1169  !
1170  ! -- apply chunking parameters
1171  call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1172  ! -- deflate and shuffle
1173  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1174  !
1175  ! -- put attr
1176  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1177  (/nf90_fill_int/)), nc_fname)
1178  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1179  longname), nc_fname)
1180  !
1181  ! -- add grid mapping and mf6 attr
1182  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1183  call ncvar_mf6attr(ncid, var_id, 0, 0, nc_tag, nc_fname)
1184  !
1185  ! -- exit define mode and write data
1186  call nf_verify(nf90_enddef(ncid), nc_fname)
1187  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1188  count=(/dis%ncol, dis%nrow/)), &
1189  nc_fname)

◆ nc_export_int3d()

subroutine disncstructuredmodule::nc_export_int3d ( integer(i4b), intent(in)  ncid,
type(structuredncdimidtype), intent(inout)  dim_ids,
type(structuredncvaridtype), intent(inout)  var_ids,
type(distype), intent(in), pointer  dis,
integer(i4b), dimension(:, :, :), intent(in), pointer, contiguous  p_mem,
character(len=*), intent(in)  nc_varname,
character(len=*), intent(in)  pkgname,
character(len=*), intent(in)  tagname,
character(len=*), intent(in)  shapestr,
character(len=*), intent(in)  longname,
character(len=*), intent(in)  nc_tag,
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 1194 of file DisNCStructured.f90.

1198  integer(I4B), intent(in) :: ncid
1199  type(StructuredNCDimIdType), intent(inout) :: dim_ids
1200  type(StructuredNCVarIdType), intent(inout) :: var_ids
1201  type(DisType), pointer, intent(in) :: dis
1202  integer(I4B), dimension(:, :, :), pointer, contiguous, intent(in) :: p_mem
1203  character(len=*), intent(in) :: nc_varname
1204  character(len=*), intent(in) :: pkgname
1205  character(len=*), intent(in) :: tagname
1206  character(len=*), intent(in) :: shapestr
1207  character(len=*), intent(in) :: longname
1208  character(len=*), intent(in) :: nc_tag
1209  character(len=*), intent(in) :: gridmap_name
1210  logical(LGP), intent(in) :: latlon
1211  integer(I4B), intent(in) :: deflate
1212  integer(I4B), intent(in) :: shuffle
1213  integer(I4B), intent(in) :: chunk_z
1214  integer(I4B), intent(in) :: chunk_y
1215  integer(I4B), intent(in) :: chunk_x
1216  character(len=*), intent(in) :: nc_fname
1217  ! -- local
1218  integer(I4B) :: var_id
1219  !
1220  ! -- reenter define mode and create variable
1221  call nf_verify(nf90_redef(ncid), nc_fname)
1222  call nf_verify(nf90_def_var(ncid, nc_varname, nf90_int, &
1223  (/dim_ids%x, dim_ids%y, dim_ids%z/), var_id), &
1224  nc_fname)
1225  !
1226  ! -- apply chunking parameters
1227  call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1228  ! -- deflate and shuffle
1229  call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1230  !
1231  ! -- put attr
1232  call nf_verify(nf90_put_att(ncid, var_id, '_FillValue', &
1233  (/nf90_fill_int/)), nc_fname)
1234  call nf_verify(nf90_put_att(ncid, var_id, 'long_name', &
1235  longname), nc_fname)
1236  !
1237  ! -- add grid mapping and mf6 attr
1238  call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, nc_fname)
1239  call ncvar_mf6attr(ncid, var_id, 0, 0, nc_tag, nc_fname)
1240  !
1241  ! -- exit define mode and write data
1242  call nf_verify(nf90_enddef(ncid), nc_fname)
1243  call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1244  count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1245  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 944 of file DisNCStructured.f90.

945  integer(I4B), intent(in) :: ncid
946  integer(I4B), intent(in) :: varid
947  integer(I4B), intent(in) :: chunk_x
948  integer(I4B), intent(in) :: chunk_y
949  character(len=*), intent(in) :: nc_fname
950  !
951  if (chunk_y > 0 .and. chunk_x > 0) then
952  call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
953  (/chunk_x, chunk_y/)), nc_fname)
954  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 959 of file DisNCStructured.f90.

960  integer(I4B), intent(in) :: ncid
961  integer(I4B), intent(in) :: varid
962  integer(I4B), intent(in) :: chunk_x
963  integer(I4B), intent(in) :: chunk_y
964  integer(I4B), intent(in) :: chunk_z
965  character(len=*), intent(in) :: nc_fname
966  !
967  if (chunk_z > 0 .and. chunk_y > 0 .and. chunk_x > 0) then
968  call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
969  (/chunk_x, chunk_y, chunk_z/)), &
970  nc_fname)
971  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 976 of file DisNCStructured.f90.

977  integer(I4B), intent(in) :: ncid
978  integer(I4B), intent(in) :: varid
979  integer(I4B), intent(in) :: deflate
980  integer(I4B), intent(in) :: shuffle
981  character(len=*), intent(in) :: nc_fname
982  ! -- deflate and shuffle
983  if (deflate >= 0) then
984  call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
985  deflate=1, deflate_level=deflate), &
986  nc_fname)
987  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 992 of file DisNCStructured.f90.

993  integer(I4B), intent(in) :: ncid
994  integer(I4B), intent(in) :: varid
995  character(len=*), intent(in) :: gridmap_name
996  logical(LGP), intent(in) :: latlon
997  character(len=*), intent(in) :: nc_fname
998  !
999  if (gridmap_name /= '') then
1000  if (latlon) then
1001  call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'lon lat'), &
1002  nc_fname)
1003  else
1004  call nf_verify(nf90_put_att(ncid, varid, 'coordinates', 'x y'), &
1005  nc_fname)
1006  end if
1007  call nf_verify(nf90_put_att(ncid, varid, 'grid_mapping', gridmap_name), &
1008  nc_fname)
1009  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)  iper,
integer(i4b), intent(in)  iaux,
character(len=*), intent(in)  nc_tag,
character(len=*), intent(in)  nc_fname 
)
private

Definition at line 1014 of file DisNCStructured.f90.

1015  integer(I4B), intent(in) :: ncid
1016  integer(I4B), intent(in) :: varid
1017  integer(I4B), intent(in) :: iper
1018  integer(I4B), intent(in) :: iaux
1019  character(len=*), intent(in) :: nc_tag
1020  character(len=*), intent(in) :: nc_fname
1021  !
1022  if (nc_tag /= '') then
1023  call nf_verify(nf90_put_att(ncid, varid, 'modflow6_input', &
1024  nc_tag), nc_fname)
1025  if (iper > 0) then
1026  call nf_verify(nf90_put_att(ncid, varid, 'modflow6_iper', &
1027  iper), nc_fname)
1028  end if
1029  !
1030  if (iaux > 0) then
1031  call nf_verify(nf90_put_att(ncid, varid, 'modflow6_iaux', &
1032  iaux), nc_fname)
1033  end if
1034  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 458 of file DisNCStructured.f90.

459  use tdismodule, only: kper
462  class(DisNCStructuredType), intent(inout) :: this
463  class(ExportPackageType), pointer, intent(in) :: export_pkg
464  integer(I4B), dimension(:), pointer, contiguous :: int1d
465  real(DP), dimension(:), pointer, contiguous :: dbl1d
466  type(InputParamDefinitionType), pointer :: idt
467  character(len=LINELENGTH) :: nc_varname, input_attr
468  integer(I4B) :: iparam
469  !
470  do iparam = 1, export_pkg%nparam
471  !
472  ! -- set input definition
473  idt => get_param_definition_type(export_pkg%mf6_input%param_dfns, &
474  export_pkg%mf6_input%component_type, &
475  export_pkg%mf6_input%subcomponent_type, &
476  'PERIOD', export_pkg%param_names(iparam), &
477  this%nc_fname)
478  !
479  ! -- set variable name and input attribute string
480  nc_varname = export_varname(export_pkg%mf6_input%subcomponent_name, idt, &
481  iper=kper)
482  input_attr = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
483  idt)
484  !
485  ! -- export arrays
486  select case (idt%datatype)
487  case ('INTEGER1D')
488  !
489  call mem_setptr(int1d, export_pkg%param_names(iparam), &
490  export_pkg%mf6_input%mempath)
491  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
492  int1d, nc_varname, &
493  export_pkg%mf6_input%subcomponent_name, &
494  idt%tagname, idt%shape, idt%longname, input_attr, &
495  this%gridmap_name, this%latlon, this%deflate, &
496  this%shuffle, this%chunk_z, this%chunk_y, &
497  this%chunk_x, kper, this%nc_fname)
498  !
499  case ('DOUBLE1D')
500  !
501  call mem_setptr(dbl1d, export_pkg%param_names(iparam), &
502  export_pkg%mf6_input%mempath)
503  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
504  dbl1d, nc_varname, &
505  export_pkg%mf6_input%subcomponent_name, &
506  idt%tagname, idt%shape, idt%longname, input_attr, &
507  this%gridmap_name, this%latlon, this%deflate, &
508  this%shuffle, this%chunk_z, this%chunk_y, &
509  this%chunk_x, kper, this%nc_fname)
510  !
511  case default
512  !
513  errmsg = 'EXPORT unsupported datatype='//trim(idt%datatype)
514  call store_error(errmsg, .true.)
515  !
516  end select
517  end do
518  !
519  ! -- synchronize file
520  call nf_verify(nf90_sync(this%ncid), this%nc_fname)
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename)
Return parameter definition.
Here is the call graph for this function:

◆ package_step_ilayer()

subroutine disncstructuredmodule::package_step_ilayer ( class(disncstructuredtype), intent(inout)  this,
class(exportpackagetype), intent(in), pointer  export_pkg,
character(len=*), intent(in)  ilayer_varname,
integer(i4b), intent(in)  ilayer 
)

Definition at line 362 of file DisNCStructured.f90.

363  use constantsmodule, only: dnodata, dzero
364  use tdismodule, only: kper
367  class(DisNCStructuredType), intent(inout) :: this
368  class(ExportPackageType), pointer, intent(in) :: export_pkg
369  character(len=*), intent(in) :: ilayer_varname
370  integer(I4B), intent(in) :: ilayer
371  type(InputParamDefinitionType), pointer :: idt
372  ! -- local
373  integer(I4B), dimension(:), pointer, contiguous :: int1d
374  real(DP), dimension(:), pointer, contiguous :: dbl1d
375  real(DP), dimension(:, :), pointer, contiguous :: dbl2d
376  integer(I4B), dimension(:), pointer, contiguous :: ialayer
377  real(DP), dimension(:), contiguous, pointer :: dbl1d_ptr
378  character(len=LINELENGTH) :: nc_varname, input_attr
379  integer(I4B) :: n, iparam, nvals
380  logical(LGP) :: ilayer_read
381  !
382  ! -- initialize
383  nullify (ialayer)
384  ilayer_read = .false.
385  !
386  ! -- set pointer to ilayer variable
387  call mem_setptr(ialayer, export_pkg%param_names(ilayer), &
388  export_pkg%mf6_input%mempath)
389  !
390  ! -- check if layer index variable was read
391  if (export_pkg%param_reads(ilayer)%invar == 1) then
392  ilayer_read = .true.
393  end if
394  !
395  ! -- export defined period input
396  do iparam = 1, export_pkg%nparam
397  !
398  ! -- check if variable was read this period
399  if (export_pkg%param_reads(iparam)%invar < 1) cycle
400  !
401  ! -- set input definition
402  idt => &
403  get_param_definition_type(export_pkg%mf6_input%param_dfns, &
404  export_pkg%mf6_input%component_type, &
405  export_pkg%mf6_input%subcomponent_type, &
406  'PERIOD', export_pkg%param_names(iparam), &
407  this%nc_fname)
408  !
409  ! -- set variable name and input attrs
410  nc_varname = export_varname(export_pkg%mf6_input%subcomponent_name, idt, &
411  iper=kper)
412  input_attr = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
413  idt)
414  !
415  ! -- export arrays
416  select case (idt%datatype)
417  case ('INTEGER1D')
418  call mem_setptr(int1d, idt%mf6varname, export_pkg%mf6_input%mempath)
419  call nc_export_array(this%ncid, this%dim_ids, this%var_ids, this%dis, &
420  int1d, nc_varname, &
421  export_pkg%mf6_input%subcomponent_name, &
422  idt%tagname, idt%shape, idt%longname, input_attr, &
423  this%gridmap_name, this%latlon, this%deflate, &
424  this%shuffle, this%chunk_z, this%chunk_y, &
425  this%chunk_x, export_pkg%iper, this%nc_fname)
426  case ('DOUBLE1D')
427  call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
428  call this%export_layer_3d(export_pkg, idt, ilayer_read, ialayer, &
429  dbl1d, nc_varname, input_attr)
430  case ('DOUBLE2D')
431  call mem_setptr(dbl2d, idt%mf6varname, export_pkg%mf6_input%mempath)
432  nvals = this%dis%ncol * this%dis%nrow
433  !
434  do n = 1, size(dbl2d, dim=1) ! naux
435  dbl1d_ptr(1:nvals) => dbl2d(n, :)
436  if (all(dbl1d_ptr == dzero)) then
437  else
438  call this%export_layer_3d(export_pkg, idt, ilayer_read, ialayer, &
439  dbl1d_ptr, nc_varname, input_attr, n)
440  end if
441  end do
442  case default
443  !
444  errmsg = 'EXPORT ilayer unsupported datatype='//trim(idt%datatype)
445  call store_error(errmsg, .true.)
446  end select
447  end do
448  !
449  ! -- synchronize file
450  call nf_verify(nf90_sync(this%ncid), this%nc_fname)
451  !
452  ! -- return
453  return
Here is the call graph for this function:

◆ step()

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

Definition at line 207 of file DisNCStructured.f90.

208  use constantsmodule, only: dhnoflo
209  use tdismodule, only: totim
210  class(DisNCStructuredType), intent(inout) :: this
211  real(DP), dimension(:), pointer, contiguous :: dbl1d
212  integer(I4B) :: n
213  !
214  this%stepcnt = this%stepcnt + 1
215  !
216  if (size(this%dis%nodeuser) < &
217  size(this%dis%nodereduced)) then
218  allocate (dbl1d(size(this%dis%nodereduced)))
219  dbl1d = dhnoflo
220  do n = 1, size(this%dis%nodereduced)
221  if (this%dis%nodereduced(n) > 0) then
222  dbl1d(n) = this%x(this%dis%nodereduced(n))
223  end if
224  end do
225  ! -- write step data to dependent variable
226  call nf_verify(nf90_put_var(this%ncid, &
227  this%var_ids%dependent, dbl1d, &
228  start=(/1, 1, 1, this%stepcnt/), &
229  count=(/this%dis%ncol, &
230  this%dis%nrow, &
231  this%dis%nlay, 1/)), &
232  this%nc_fname)
233  deallocate (dbl1d)
234  else
235  ! -- write step data to dependent variable
236  call nf_verify(nf90_put_var(this%ncid, &
237  this%var_ids%dependent, this%x, &
238  start=(/1, 1, 1, this%stepcnt/), &
239  count=(/this%dis%ncol, &
240  this%dis%nrow, &
241  this%dis%nlay, 1/)), &
242  this%nc_fname)
243  end if
244  !
245  ! -- write to time coordinate variable
246  call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
247  totim, start=(/this%stepcnt/)), &
248  this%nc_fname)
249  ! -- synchronize file
250  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: