39 character(len=LINELENGTH),
dimension(:),
allocatable :: param_names
41 integer(I4B),
dimension(:),
pointer,
contiguous :: mshape => null()
42 integer(I4B),
pointer :: iper
43 integer(I4B) :: iper_export
44 integer(I4B) :: nparam
53 character(len=LINELENGTH) :: title
54 character(len=LINELENGTH) :: model
55 character(len=LINELENGTH) :: grid
56 character(len=LINELENGTH) :: history
57 character(len=LINELENGTH) :: source
58 character(len=LINELENGTH) :: conventions
59 character(len=LINELENGTH) :: stdname
60 character(len=LINELENGTH) :: longname
69 character(len=LENMODELNAME) :: modelname
70 character(len=LENCOMPONENTNAME) :: modeltype
71 character(len=LINELENGTH) :: modelfname
72 character(len=LINELENGTH) :: nc_fname
73 character(len=LINELENGTH) :: gridmap_name
74 character(len=LINELENGTH) :: mesh_name =
'mesh'
75 character(len=LENMEMPATH) :: dis_mempath
76 character(len=LENMEMPATH) :: ncf_mempath
77 character(len=LENBIGLINE) :: wkt
78 character(len=LINELENGTH) :: datetime
79 character(len=LINELENGTH) :: xname
80 character(len=LINELENGTH) :: lenunits
82 real(dp),
dimension(:),
pointer,
contiguous :: x
83 integer(I4B) :: disenum
85 integer(I4B) :: stepcnt
86 integer(I4B) :: totnstp
87 integer(I4B),
pointer :: deflate
88 integer(I4B),
pointer :: shuffle
89 integer(I4B),
pointer :: input_attr
90 integer(I4B),
pointer :: chunk_time
92 logical(LGP) :: chunking_active
132 character(len=*),
intent(in) :: ilayer_varname
133 integer(I4B),
intent(in) :: ilayer
141 subroutine epkg_init(this, mf6_input, mshape, param_names, &
149 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: mshape
150 character(len=LINELENGTH),
dimension(:),
allocatable, &
151 intent(in) :: param_names
152 integer(I4B),
intent(in) :: nparam
154 character(len=LENVARNAME) :: rs_varname
155 character(len=LENMEMPATH) :: input_mempath
156 integer(I4B),
pointer :: rsvar
158 this%mf6_input = mf6_input
159 this%mshape => mshape
164 subcomponent=mf6_input%subcomponent_name, &
168 allocate (this%param_names(nparam))
169 allocate (this%param_reads(nparam))
173 this%param_names(n) = param_names(n)
174 rs_varname =
rsv_name(param_names(n))
175 call mem_setptr(rsvar, rs_varname, mf6_input%mempath)
176 this%param_reads(n)%invar => rsvar
180 call mem_setptr(this%iper,
'IPER', mf6_input%mempath)
188 if (
allocated(this%param_names))
deallocate (this%param_names)
193 subroutine set(this, modelname, modeltype, modelfname, nctype)
196 character(len=*),
intent(in) :: modelname
197 character(len=*),
intent(in) :: modeltype
198 character(len=*),
intent(in) :: modelfname
199 integer(I4B),
intent(in) :: nctype
200 character(len=LINELENGTH) :: fullname
208 this%conventions =
''
213 this%conventions =
'CF-1.11'
215 trim(this%conventions)//
' UGRID-1.0'
218 select case (modeltype)
220 fullname =
'Groundwater Flow'
221 this%title = trim(modelname)//
' hydraulic head'
222 this%longname =
'head'
224 fullname =
'Groundwater Transport'
225 this%title = trim(modelname)//
' concentration'
226 this%longname =
'concentration'
228 fullname =
'Groundwater Energy'
229 this%title = trim(modelname)//
' temperature'
230 this%longname =
'temperature'
232 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
238 this%title = trim(this%title)//
' array input'
243 this%grid =
'LAYERED MESH'
245 this%grid =
'STRUCTURED'
249 this%model = trim(modelname)//
': MODFLOW 6 '//trim(fullname)// &
250 ' ('//trim(modeltype)//
') model'
253 this%source =
'MODFLOW 6 '//trim(adjustl(
version))
256 call date_and_time(values=values)
257 write (this%history,
'(a,i0,a,i0,a,i0,a,i0,a,i0,a,i0,a,i0)') &
258 'first created ', values(1),
'/', values(2),
'/', values(3),
' ', &
259 values(5),
':', values(6),
':', values(7),
'.', values(8)
264 subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, &
265 disenum, nctype, iout)
273 character(len=*),
intent(in) :: modelname
274 character(len=*),
intent(in) :: modeltype
275 character(len=*),
intent(in) :: modelfname
276 character(len=*),
intent(in) :: nc_fname
277 integer(I4B),
intent(in) :: disenum
278 integer(I4B),
intent(in) :: nctype
279 integer(I4B),
intent(in) :: iout
280 character(len=LENMEMPATH) :: model_mempath
282 logical(LGP) :: found_mempath
285 allocate (this%deflate)
286 allocate (this%shuffle)
287 allocate (this%input_attr)
288 allocate (this%chunk_time)
291 this%modelname = modelname
292 this%modeltype = modeltype
293 this%modelfname = modelfname
294 this%nc_fname = nc_fname
295 this%gridmap_name =
''
296 this%ncf_mempath =
''
301 this%disenum = disenum
310 this%chunking_active = .false.
313 call this%annotation%set(modelname, modeltype, modelfname, nctype)
316 select case (modeltype)
320 this%xname =
'concentration'
322 this%xname =
'temperature'
324 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
330 if (disenum ==
dis)
then
332 else if (disenum ==
disu)
then
334 else if (disenum ==
disv)
then
343 call mem_set_value(this%ncf_mempath,
'NCF6_MEMPATH', this%dis_mempath, &
346 if (found_mempath)
then
349 call mem_set_value(this%deflate,
'DEFLATE', this%ncf_mempath, &
351 call mem_set_value(this%shuffle,
'SHUFFLE', this%ncf_mempath, &
353 call mem_set_value(this%input_attr,
'ATTR_OFF', this%ncf_mempath, &
355 call mem_set_value(this%chunk_time,
'CHUNK_TIME', this%ncf_mempath, &
356 ncf_found%chunk_time)
359 if (ncf_found%wkt)
then
360 this%gridmap_name =
'projection'
364 if (ncf_found%attr_off)
then
370 this%datetime =
'days since '//trim(
datetime0)
373 this%datetime =
'days since 1970-01-01T00:00:00'
377 this%totnstp = sum(
nstp)
385 integer(I4B),
intent(in) :: idx
387 class(*),
pointer :: obj
389 obj => this%pkglist%GetItem(idx)
390 if (
associated(obj))
then
405 character(len=*),
intent(in) :: pkgname
407 character(len=LINELENGTH) :: attr
409 if (this%input_attr > 0)
then
419 character(len=*),
intent(in) :: longname
420 character(len=*),
intent(in) :: pkgname
421 character(len=*),
intent(in) :: tagname
422 integer(I4B),
intent(in) :: layer
423 integer(I4B),
optional,
intent(in) :: iper
424 character(len=LINELENGTH) :: lname
425 character(len=LINELENGTH) :: pname, vname
430 if (longname ==
'')
then
431 lname = trim(pname)//
' '//trim(vname)
436 write (lname,
'(a,i0)') trim(lname)//
' layer=', layer
438 if (
present(iper))
then
440 write (lname,
'(a,i0)') trim(lname)//
' period=', iper
451 integer(I4B) :: idx, ilayer
453 character(len=LENVARNAME) :: ilayer_varname
455 do idx = 1, this%pkglist%Count()
456 export_pkg => this%get(idx)
458 if (export_pkg%iper /=
kper) cycle
460 if (export_pkg%iper_export >= export_pkg%iper) cycle
462 export_pkg%iper_export = export_pkg%iper
468 ilayer_varname =
'I'//trim(export_pkg%mf6_input%subcomponent_type(1:3))
471 ilayer =
ifind(export_pkg%param_names, ilayer_varname)
474 if (ilayer == 1)
then
475 call this%package_step_ilayer(export_pkg, ilayer_varname, ilayer)
477 call this%package_step(export_pkg)
489 deallocate (this%deflate)
490 deallocate (this%shuffle)
491 deallocate (this%input_attr)
492 deallocate (this%chunk_time)
494 if (this%ncf_mempath /=
'')
then
abstract interfaces for model netcdf export type
This module contains the BoundInputContextModule.
character(len=lenvarname) function, public rsv_name(mf6varname)
create read state variable name
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.
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
subroutine epkg_init(this, mf6_input, mshape, param_names, nparam)
initialize dynamic package export object
@, public netcdf_structured
netcdf structrured export
character(len=linelength) function, public export_longname(longname, pkgname, tagname, layer, iper)
build netcdf variable longname
subroutine export_destroy(this)
destroy model netcdf export object
subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
initialization of model netcdf export
subroutine set(this, modelname, modeltype, modelfname, nctype)
set netcdf file scoped attributes
@, public netcdf_mesh2d
netcdf ugrid layered mesh export
@, public netcdf_undef
undefined netcdf export type
character(len=linelength) function input_attribute(this, pkgname, idt)
build modflow6_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 kper
current stress period number
This module contains version information.
character(len=40), parameter version
Pointer type for read state variable.
A generic heterogeneous doubly-linked list.
abstract type for model netcdf export type
netcdf export attribute annotations
base class for an export model