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
45 integer(I4B) :: iper_export
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
135 character(len=*),
intent(in) :: ilayer_varname
136 integer(I4B),
intent(in) :: ilayer
144 subroutine epkg_init(this, mf6_input, mshape, naux, param_names, &
152 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: mshape
153 integer(I4B),
intent(in) :: naux
154 character(len=LINELENGTH),
dimension(:),
allocatable, &
155 intent(in) :: param_names
156 integer(I4B),
intent(in) :: nparam
158 character(len=LENVARNAME) :: rs_varname
159 character(len=LENMEMPATH) :: input_mempath
160 integer(I4B),
pointer :: rsvar
162 this%mf6_input = mf6_input
163 this%mshape => mshape
169 subcomponent=mf6_input%subcomponent_name, &
173 allocate (this%param_names(nparam))
174 allocate (this%param_reads(nparam))
175 allocate (this%varids_param(nparam, mshape(1)))
176 allocate (this%varids_aux(naux, mshape(1)))
180 this%param_names(n) = param_names(n)
181 rs_varname =
rsv_name(param_names(n))
182 call mem_setptr(rsvar, rs_varname, mf6_input%mempath)
183 this%param_reads(n)%invar => rsvar
187 call mem_setptr(this%iper,
'IPER', mf6_input%mempath)
195 if (
allocated(this%param_names))
deallocate (this%param_names)
200 subroutine set(this, modelname, modeltype, modelfname, nctype, disenum)
203 character(len=*),
intent(in) :: modelname
204 character(len=*),
intent(in) :: modeltype
205 character(len=*),
intent(in) :: modelfname
206 integer(I4B),
intent(in) :: nctype
207 integer(I4B),
intent(in) :: disenum
208 character(len=LINELENGTH) :: fullname
217 this%conventions =
''
222 this%conventions =
'CF-1.11'
224 trim(this%conventions)//
' UGRID-1.0'
227 select case (modeltype)
229 fullname =
'Groundwater Flow'
230 this%title = trim(modelname)//
' hydraulic head'
231 this%longname =
'head'
233 fullname =
'Groundwater Transport'
234 this%title = trim(modelname)//
' concentration'
235 this%longname =
'concentration'
237 fullname =
'Groundwater Energy'
238 this%title = trim(modelname)//
' temperature'
239 this%longname =
'temperature'
241 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
247 this%title = trim(this%title)//
' array input'
252 this%mesh =
'LAYERED'
256 if (disenum ==
dis)
then
257 this%grid =
'STRUCTURED'
258 else if (disenum ==
disv)
then
263 this%model = trim(modelname)//
': MODFLOW 6 '//trim(fullname)// &
264 ' ('//trim(modeltype)//
') model'
267 this%source =
'MODFLOW 6 '//trim(adjustl(
version))
270 call date_and_time(values=values)
271 write (this%history,
'(a,i0,a,i0,a,i0,a,i0,a,i0,a,i0,a,i0)') &
272 'first created ', values(1),
'/', values(2),
'/', values(3),
' ', &
273 values(5),
':', values(6),
':', values(7),
'.', values(8)
278 subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, &
279 disenum, nctype, iout)
287 character(len=*),
intent(in) :: modelname
288 character(len=*),
intent(in) :: modeltype
289 character(len=*),
intent(in) :: modelfname
290 character(len=*),
intent(in) :: nc_fname
291 integer(I4B),
intent(in) :: disenum
292 integer(I4B),
intent(in) :: nctype
293 integer(I4B),
intent(in) :: iout
294 character(len=LENMEMPATH) :: model_mempath
296 logical(LGP) :: found_mempath
299 allocate (this%deflate)
300 allocate (this%shuffle)
301 allocate (this%input_attr)
302 allocate (this%chunk_time)
305 this%modelname = modelname
306 this%modeltype = modeltype
307 this%modelfname = modelfname
308 this%nc_fname = nc_fname
309 this%gridmap_name =
''
310 this%ncf_mempath =
''
315 this%disenum = disenum
323 this%chunking_active = .false.
326 call this%annotation%set(modelname, modeltype, modelfname, nctype, disenum)
329 select case (modeltype)
333 this%xname =
'concentration'
335 this%xname =
'temperature'
337 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
343 if (disenum ==
dis)
then
345 else if (disenum ==
disu)
then
347 else if (disenum ==
disv)
then
356 call mem_set_value(this%ncf_mempath,
'NCF6_MEMPATH', this%dis_mempath, &
359 if (found_mempath)
then
362 call mem_set_value(this%deflate,
'DEFLATE', this%ncf_mempath, &
364 call mem_set_value(this%shuffle,
'SHUFFLE', this%ncf_mempath, &
366 call mem_set_value(this%input_attr,
'ATTR_OFF', this%ncf_mempath, &
368 call mem_set_value(this%chunk_time,
'CHUNK_TIME', this%ncf_mempath, &
369 ncf_found%chunk_time)
372 if (ncf_found%wkt)
then
373 this%gridmap_name =
'projection'
377 if (ncf_found%attr_off)
then
383 this%datetime =
'days since '//trim(
datetime0)
386 this%datetime =
'days since 1970-01-01T00:00:00'
391 errmsg =
'Adaptive time stepping not currently supported &
392 &with NetCDF exports.'
398 this%totnstp = sum(
nstp)
406 integer(I4B),
intent(in) :: idx
408 class(*),
pointer :: obj
410 obj => this%pkglist%GetItem(idx)
411 if (
associated(obj))
then
426 character(len=*),
intent(in) :: pkgname
428 character(len=LINELENGTH) :: attr
430 if (this%input_attr > 0)
then
443 character(len=*),
intent(in) :: pkgname
444 character(len=*),
intent(in) :: tagname
445 character(len=*),
intent(in) :: mempath
446 integer(I4B),
optional,
intent(in) :: layer
447 integer(I4B),
optional,
intent(in) :: iaux
448 character(len=LINELENGTH) :: varname
450 contiguous :: auxnames
451 character(len=LINELENGTH) :: pname, vname
455 if (
present(iaux))
then
457 if (tagname ==
'AUX')
then
459 call mem_setptr(auxnames,
'AUXILIARY', mempath)
460 vname = auxnames(iaux)
467 varname = trim(pname)//
'_'//trim(vname)
469 if (
present(layer))
then
472 write (varname,
'(a,i0)') trim(varname)//
'_l', layer
484 character(len=*),
intent(in) :: longname
485 character(len=*),
intent(in) :: pkgname
486 character(len=*),
intent(in) :: tagname
487 character(len=*),
intent(in) :: mempath
488 integer(I4B),
optional,
intent(in) :: layer
489 integer(I4B),
optional,
intent(in) :: iaux
490 character(len=LINELENGTH) :: lname
492 contiguous :: auxnames
493 character(len=LINELENGTH) :: pname, vname, auxname
498 if (longname ==
'')
then
499 lname = trim(pname)//
' '//trim(vname)
504 if (
present(iaux))
then
506 if (tagname ==
'AUX')
then
508 call mem_setptr(auxnames,
'AUXILIARY', mempath)
509 auxname = auxnames(iaux)
511 lname = trim(lname)//
' '//trim(auxname)
516 if (
present(layer))
then
518 write (lname,
'(a,i0)') trim(lname)//
' layer=', layer
530 do idx = 1, this%pkglist%Count()
531 export_pkg => this%get(idx)
533 if (export_pkg%iper /=
kper) cycle
535 if (export_pkg%iper_export >= export_pkg%iper) cycle
537 export_pkg%iper_export = export_pkg%iper
539 call this%package_step(export_pkg)
550 deallocate (this%deflate)
551 deallocate (this%shuffle)
552 deallocate (this%input_attr)
553 deallocate (this%chunk_time)
555 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
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 inats
flag indicating ats active for simulation
integer(i4b), pointer, public kper
current stress period number
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