39 character(len=LINELENGTH),
dimension(:),
allocatable :: param_names
41 integer(I4B),
dimension(:, :),
allocatable :: varids_param
42 integer(I4B),
dimension(:, :),
allocatable :: varids_aux
43 integer(I4B),
dimension(:),
pointer,
contiguous :: mshape => null()
44 integer(I4B),
pointer :: iper
46 integer(I4B) :: nparam
56 character(len=LINELENGTH) :: title
57 character(len=LINELENGTH) :: model
58 character(len=LINELENGTH) :: mesh
59 character(len=LINELENGTH) :: grid
60 character(len=LINELENGTH) :: history
61 character(len=LINELENGTH) :: source
62 character(len=LINELENGTH) :: conventions
63 character(len=LINELENGTH) :: stdname
64 character(len=LINELENGTH) :: longname
73 character(len=LENMODELNAME) :: modelname
74 character(len=LENCOMPONENTNAME) :: modeltype
75 character(len=LINELENGTH) :: modelfname
76 character(len=LINELENGTH) :: nc_fname
77 character(len=LINELENGTH) :: gridmap_name
78 character(len=LINELENGTH) :: mesh_name =
'mesh'
79 character(len=LENMEMPATH) :: dis_mempath
80 character(len=LENMEMPATH) :: ncf_mempath
81 character(len=LENBIGLINE) :: wkt
82 character(len=LINELENGTH) :: datetime
83 character(len=LINELENGTH) :: xname
84 character(len=LINELENGTH) :: lenunits
86 real(dp),
dimension(:),
pointer,
contiguous :: x
87 integer(I4B) :: disenum
89 integer(I4B) :: totnstp
90 integer(I4B),
pointer :: deflate
91 integer(I4B),
pointer :: shuffle
92 integer(I4B),
pointer :: input_attr
93 integer(I4B),
pointer :: chunk_time
95 logical(LGP) :: chunking_active
136 character(len=*),
intent(in) :: ilayer_varname
137 integer(I4B),
intent(in) :: ilayer
145 subroutine epkg_init(this, mf6_input, mshape, naux, param_names, &
153 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: mshape
154 integer(I4B),
intent(in) :: naux
155 character(len=LINELENGTH),
dimension(:),
allocatable, &
156 intent(in) :: param_names
157 integer(I4B),
intent(in) :: nparam
159 character(len=LENVARNAME) :: rs_varname
160 character(len=LENMEMPATH) :: input_mempath
161 integer(I4B),
pointer :: rsvar
163 this%mf6_input = mf6_input
164 this%mshape => mshape
170 subcomponent=mf6_input%subcomponent_name, &
174 allocate (this%param_names(nparam))
175 allocate (this%param_reads(nparam))
176 allocate (this%varids_param(nparam, mshape(1)))
177 allocate (this%varids_aux(naux, mshape(1)))
181 this%param_names(n) = param_names(n)
182 rs_varname =
rsv_name(param_names(n))
183 call mem_setptr(rsvar, rs_varname, mf6_input%mempath)
184 this%param_reads(n)%invar => rsvar
188 call mem_setptr(this%iper,
'IPER', mf6_input%mempath)
196 if (
allocated(this%param_names))
deallocate (this%param_names)
201 subroutine set(this, modelname, modeltype, modelfname, nctype, disenum)
204 character(len=*),
intent(in) :: modelname
205 character(len=*),
intent(in) :: modeltype
206 character(len=*),
intent(in) :: modelfname
207 integer(I4B),
intent(in) :: nctype
208 integer(I4B),
intent(in) :: disenum
217 this%conventions =
''
222 this%conventions =
'CF-1.11'
224 trim(this%conventions)//
' UGRID-1.0'
227 select case (modeltype)
229 this%title = trim(modelname)//
' hydraulic head'
230 this%longname =
'head'
232 this%title = trim(modelname)//
' concentration'
233 this%longname =
'concentration'
235 this%title = trim(modelname)//
' temperature'
236 this%longname =
'temperature'
238 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
244 this%title = trim(this%title)//
' array input'
249 this%mesh =
'LAYERED'
253 if (disenum ==
dis)
then
254 this%grid =
'STRUCTURED'
255 else if (disenum ==
disv)
then
260 this%model = trim(modeltype)//
'6: '//trim(modelname)
263 this%source =
'MODFLOW 6 '//trim(adjustl(
version))
266 call date_and_time(values=values)
267 write (this%history,
'(a,i0,a,i0,a,i0,a,i0,a,i0,a,i0,a,i0)') &
268 'first created ', values(1),
'/', values(2),
'/', values(3),
' ', &
269 values(5),
':', values(6),
':', values(7),
'.', values(8)
274 subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, &
275 disenum, nctype, iout)
283 character(len=*),
intent(in) :: modelname
284 character(len=*),
intent(in) :: modeltype
285 character(len=*),
intent(in) :: modelfname
286 character(len=*),
intent(in) :: nc_fname
287 integer(I4B),
intent(in) :: disenum
288 integer(I4B),
intent(in) :: nctype
289 integer(I4B),
intent(in) :: iout
290 character(len=LENMEMPATH) :: model_mempath
292 logical(LGP) :: found_mempath
295 allocate (this%deflate)
296 allocate (this%shuffle)
297 allocate (this%input_attr)
298 allocate (this%chunk_time)
301 this%modelname = modelname
302 this%modeltype = modeltype
303 this%modelfname = modelfname
304 this%nc_fname = nc_fname
305 this%gridmap_name =
''
306 this%ncf_mempath =
''
311 this%disenum = disenum
319 this%chunking_active = .false.
322 call this%annotation%set(modelname, modeltype, modelfname, nctype, disenum)
325 select case (modeltype)
329 this%xname =
'concentration'
331 this%xname =
'temperature'
333 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
339 if (disenum ==
dis)
then
341 else if (disenum ==
disu)
then
343 else if (disenum ==
disv)
then
352 call mem_set_value(this%ncf_mempath,
'NCF6_MEMPATH', this%dis_mempath, &
355 if (found_mempath)
then
358 call mem_set_value(this%deflate,
'DEFLATE', this%ncf_mempath, &
360 call mem_set_value(this%shuffle,
'SHUFFLE', this%ncf_mempath, &
362 call mem_set_value(this%input_attr,
'ATTR_OFF', this%ncf_mempath, &
364 call mem_set_value(this%chunk_time,
'CHUNK_TIME', this%ncf_mempath, &
365 ncf_found%chunk_time)
368 if (ncf_found%wkt)
then
369 this%gridmap_name =
'projection'
373 if (ncf_found%attr_off)
then
379 this%datetime =
'days since '//trim(
datetime0)
382 this%datetime =
'days since 1970-01-01T00:00:00'
389 this%totnstp = sum(
nstp)
398 integer(I4B),
intent(in) :: idx
400 class(*),
pointer :: obj
402 obj => this%pkglist%GetItem(idx)
403 if (
associated(obj))
then
418 character(len=*),
intent(in) :: pkgname
420 character(len=LINELENGTH) :: attr
422 if (this%input_attr > 0)
then
433 integer(I4B) :: n,
istp
449 character(len=*),
intent(in) :: pkgname
450 character(len=*),
intent(in) :: tagname
451 character(len=*),
intent(in) :: mempath
452 integer(I4B),
optional,
intent(in) :: layer
453 integer(I4B),
optional,
intent(in) :: iaux
454 character(len=LINELENGTH) :: varname
456 contiguous :: auxnames
457 character(len=LINELENGTH) :: pname, vname
461 if (
present(iaux))
then
463 if (tagname ==
'AUX')
then
465 call mem_setptr(auxnames,
'AUXILIARY', mempath)
466 vname = auxnames(iaux)
473 varname = trim(pname)//
'_'//trim(vname)
475 if (
present(layer))
then
478 write (varname,
'(a,i0)') trim(varname)//
'_l', layer
490 character(len=*),
intent(in) :: longname
491 character(len=*),
intent(in) :: pkgname
492 character(len=*),
intent(in) :: tagname
493 character(len=*),
intent(in) :: mempath
494 integer(I4B),
optional,
intent(in) :: layer
495 integer(I4B),
optional,
intent(in) :: iaux
496 character(len=LINELENGTH) :: lname
498 contiguous :: auxnames
499 character(len=LINELENGTH) :: pname, vname, auxname
504 if (longname ==
'')
then
505 lname = trim(pname)//
' '//trim(vname)
510 if (
present(iaux))
then
512 if (tagname ==
'AUX')
then
514 call mem_setptr(auxnames,
'AUXILIARY', mempath)
515 auxname = auxnames(iaux)
517 lname = trim(lname)//
' '//trim(auxname)
522 if (
present(layer))
then
524 write (lname,
'(a,i0)') trim(lname)//
' layer ', layer
536 do idx = 1, this%pkglist%Count()
537 export_pkg => this%get(idx)
539 if (export_pkg%eper >=
kper) cycle
541 call this%package_step(export_pkg)
543 export_pkg%eper =
kper
554 deallocate (this%deflate)
555 deallocate (this%shuffle)
556 deallocate (this%input_attr)
557 deallocate (this%chunk_time)
559 if (this%ncf_mempath /=
'')
then
abstract interfaces for model netcdf export type
This module contains simulation constants.
integer(i4b), parameter linelength
maximum length of a standard line
integer(i4b), parameter lencomponentname
maximum length of a component name
@ mvalidate
validation mode - do not run time steps
integer(i4b), parameter lenmodelname
maximum length of the model name
integer(i4b), parameter lenbigline
maximum length of a big line
@ disu
DISV6 discretization.
@ dis
DIS6 discretization.
@ disv
DISU6 discretization.
integer(i4b), parameter lenvarname
maximum length of a variable name
integer(i4b), parameter lenmempath
maximum length of the memory path
This module defines variable data types.
This module contains the LoadContextModule.
character(len=lenvarname) function, public rsv_name(mf6varname)
create read state variable name
character(len=lenmemseparator), parameter mempathseparator
used to build up the memory address for the stored variables
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public memorystore_remove(component, subcomponent, context)
This module contains the NCModelExportModule.
class(exportpackagetype) function, pointer export_get(this, idx)
retrieve dynamic export object from package list
character(len=linelength) function, public export_varname(pkgname, tagname, mempath, layer, iaux)
build netcdf variable name
integer(i4b) function istp(this)
step index for timeseries data
subroutine epkg_init(this, mf6_input, mshape, naux, param_names, nparam)
initialize dynamic package export object
@, public netcdf_structured
netcdf structrured export
subroutine export_destroy(this)
destroy model netcdf export object
character(len=linelength) function, public export_longname(longname, pkgname, tagname, mempath, layer, iaux)
build netcdf variable longname
subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
initialization of model netcdf export
@, public netcdf_mesh2d
netcdf ugrid layered mesh export
@, public netcdf_undef
undefined netcdf export type
subroutine set(this, modelname, modeltype, modelfname, nctype, disenum)
set netcdf file scoped attributes
character(len=linelength) function input_attribute(this, pkgname, idt)
build modflow_input attribute string
subroutine epkg_destroy(this)
destroy dynamic package export object
subroutine export_input(this)
netcdf dynamic package period export
This module contains simulation methods.
subroutine, public store_error(msg, terminate)
Store an error message.
subroutine, public store_error_filename(filename, terminate)
Store the erroring file name.
This module contains simulation variables.
character(len=maxcharlen) errmsg
error message string
character(len=linelength) idm_context
integer(i4b) isim_mode
simulation mode
integer(i4b), dimension(:), pointer, public, contiguous nstp
number of time steps in each stress period
character(len=lendatetime), pointer, public datetime0
starting date and time for the simulation
integer(i4b), pointer, public kstp
current time step number
integer(i4b), pointer, public kper
current stress period number
integer(i4b), pointer, public nper
number of stress period
This module contains version information.
character(len=40), parameter version
This class is used to store a single deferred-length character string. It was designed to work in an ...
A generic heterogeneous doubly-linked list.
Pointer type for read state variable.
abstract type for model netcdf export type
netcdf export attribute annotations
base class for an export model