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) :: ogc_wkt
78 character(len=LINELENGTH) :: datetime
79 character(len=LINELENGTH) :: xname
81 real(dp),
dimension(:),
pointer,
contiguous :: x
82 integer(I4B) :: disenum
84 integer(I4B) :: stepcnt
85 integer(I4B) :: totnstp
86 integer(I4B),
pointer :: deflate
87 integer(I4B),
pointer :: shuffle
88 integer(I4B),
pointer :: input_attr
89 integer(I4B),
pointer :: chunk_time
91 logical(LGP) :: chunking_active
131 character(len=*),
intent(in) :: ilayer_varname
132 integer(I4B),
intent(in) :: ilayer
140 subroutine epkg_init(this, mf6_input, mshape, param_names, &
148 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: mshape
149 character(len=LINELENGTH),
dimension(:),
allocatable, &
150 intent(in) :: param_names
151 integer(I4B),
intent(in) :: nparam
153 character(len=LENVARNAME) :: rs_varname
154 character(len=LENMEMPATH) :: input_mempath
155 integer(I4B),
pointer :: rsvar
157 this%mf6_input = mf6_input
158 this%mshape => mshape
163 subcomponent=mf6_input%subcomponent_name, &
167 allocate (this%param_names(nparam))
168 allocate (this%param_reads(nparam))
172 this%param_names(n) = param_names(n)
173 rs_varname =
rsv_name(param_names(n))
174 call mem_setptr(rsvar, rs_varname, mf6_input%mempath)
175 this%param_reads(n)%invar => rsvar
179 call mem_setptr(this%iper,
'IPER', mf6_input%mempath)
187 if (
allocated(this%param_names))
deallocate (this%param_names)
192 subroutine set(this, modelname, modeltype, modelfname, nctype)
195 character(len=*),
intent(in) :: modelname
196 character(len=*),
intent(in) :: modeltype
197 character(len=*),
intent(in) :: modelfname
198 integer(I4B),
intent(in) :: nctype
199 character(len=LINELENGTH) :: fullname
207 this%conventions =
''
212 this%conventions =
'CF-1.11'
214 trim(this%conventions)//
' UGRID-1.0'
217 select case (modeltype)
219 fullname =
'Groundwater Flow'
220 this%title = trim(modelname)//
' hydraulic head'
221 this%longname =
'head'
223 fullname =
'Groundwater Transport'
224 this%title = trim(modelname)//
' concentration'
225 this%longname =
'concentration'
227 fullname =
'Groundwater Energy'
228 this%title = trim(modelname)//
' temperature'
229 this%longname =
'temperature'
231 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
237 this%title = trim(this%title)//
' array input'
242 this%grid =
'LAYERED MESH'
244 this%grid =
'STRUCTURED'
248 this%model = trim(modelname)//
': MODFLOW 6 '//trim(fullname)// &
249 ' ('//trim(modeltype)//
') model'
252 this%source =
'MODFLOW 6 '//trim(adjustl(
version))
255 call date_and_time(values=values)
256 write (this%history,
'(a,i0,a,i0,a,i0,a,i0,a,i0,a,i0,a,i0)') &
257 'first created ', values(1),
'/', values(2),
'/', values(3),
' ', &
258 values(5),
':', values(6),
':', values(7),
'.', values(8)
263 subroutine export_init(this, modelname, modeltype, modelfname, nc_fname, &
264 disenum, nctype, iout)
272 character(len=*),
intent(in) :: modelname
273 character(len=*),
intent(in) :: modeltype
274 character(len=*),
intent(in) :: modelfname
275 character(len=*),
intent(in) :: nc_fname
276 integer(I4B),
intent(in) :: disenum
277 integer(I4B),
intent(in) :: nctype
278 integer(I4B),
intent(in) :: iout
279 character(len=LENMEMPATH) :: model_mempath
281 logical(LGP) :: found_mempath
284 allocate (this%deflate)
285 allocate (this%shuffle)
286 allocate (this%input_attr)
287 allocate (this%chunk_time)
290 this%modelname = modelname
291 this%modeltype = modeltype
292 this%modelfname = modelfname
293 this%nc_fname = nc_fname
294 this%gridmap_name =
''
295 this%ncf_mempath =
''
299 this%disenum = disenum
308 this%chunking_active = .false.
311 call this%annotation%set(modelname, modeltype, modelfname, nctype)
314 select case (modeltype)
318 this%xname =
'concentration'
320 this%xname =
'temperature'
322 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
328 if (disenum ==
dis)
then
330 else if (disenum ==
disu)
then
332 else if (disenum ==
disv)
then
341 call mem_set_value(this%ncf_mempath,
'NCF6_MEMPATH', this%dis_mempath, &
344 if (found_mempath)
then
345 call mem_set_value(this%ogc_wkt,
'OGC_WKT', this%ncf_mempath, &
347 call mem_set_value(this%deflate,
'DEFLATE', this%ncf_mempath, &
349 call mem_set_value(this%shuffle,
'SHUFFLE', this%ncf_mempath, &
351 call mem_set_value(this%input_attr,
'ATTR_OFF', this%ncf_mempath, &
353 call mem_set_value(this%chunk_time,
'CHUNK_TIME', this%ncf_mempath, &
354 ncf_found%chunk_time)
357 if (ncf_found%ogc_wkt)
then
358 this%gridmap_name =
'projection'
362 if (ncf_found%attr_off)
then
368 errmsg =
'TDIS parameter START_DATE_TIME required for NetCDF export.'
372 this%datetime =
'days since '//trim(
datetime0)
376 this%totnstp = sum(
nstp)
384 integer(I4B),
intent(in) :: idx
386 class(*),
pointer :: obj
388 obj => this%pkglist%GetItem(idx)
389 if (
associated(obj))
then
404 character(len=*),
intent(in) :: pkgname
406 character(len=LINELENGTH) :: attr
408 if (this%input_attr > 0)
then
418 character(len=*),
intent(in) :: longname
419 character(len=*),
intent(in) :: pkgname
420 character(len=*),
intent(in) :: tagname
421 integer(I4B),
intent(in) :: layer
422 integer(I4B),
optional,
intent(in) :: iper
423 character(len=LINELENGTH) :: lname
424 character(len=LINELENGTH) :: pname, vname
429 if (longname ==
'')
then
430 lname = trim(pname)//
' '//trim(vname)
435 write (lname,
'(a,i0)') trim(lname)//
' layer=', layer
437 if (
present(iper))
then
439 write (lname,
'(a,i0)') trim(lname)//
' period=', iper
450 integer(I4B) :: idx, ilayer
452 character(len=LENVARNAME) :: ilayer_varname
454 do idx = 1, this%pkglist%Count()
455 export_pkg => this%get(idx)
457 if (export_pkg%iper /=
kper) cycle
459 if (export_pkg%iper_export >= export_pkg%iper) cycle
461 export_pkg%iper_export = export_pkg%iper
467 ilayer_varname =
'I'//trim(export_pkg%mf6_input%subcomponent_type(1:3))
470 ilayer =
ifind(export_pkg%param_names, ilayer_varname)
473 if (ilayer == 1)
then
474 call this%package_step_ilayer(export_pkg, ilayer_varname, ilayer)
476 call this%package_step(export_pkg)
488 deallocate (this%deflate)
489 deallocate (this%shuffle)
490 deallocate (this%input_attr)
491 deallocate (this%chunk_time)
493 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