40 character(len=LINELENGTH),
dimension(:),
allocatable :: param_names
42 integer(I4B),
dimension(:, :),
allocatable :: varids_param
43 integer(I4B),
dimension(:, :),
allocatable :: varids_aux
44 integer(I4B),
dimension(:),
pointer,
contiguous :: mshape => null()
45 integer(I4B),
pointer :: iper
47 integer(I4B) :: nparam
57 character(len=LINELENGTH) :: title
58 character(len=LINELENGTH) :: model
59 character(len=LINELENGTH) :: mesh
60 character(len=LINELENGTH) :: grid
61 character(len=LINELENGTH) :: history
62 character(len=LINELENGTH) :: source
63 character(len=LINELENGTH) :: conventions
64 character(len=LINELENGTH) :: stdname
65 character(len=LINELENGTH) :: longname
74 character(len=LENMODELNAME) :: modelname
75 character(len=LENCOMPONENTNAME) :: modeltype
76 character(len=LINELENGTH) :: modelfname
77 character(len=LINELENGTH) :: nc_fname
78 character(len=LINELENGTH) :: gridmap_name
79 character(len=LINELENGTH) :: mesh_name =
'mesh'
80 character(len=LENMEMPATH) :: dis_mempath
81 character(len=LENMEMPATH) :: ncf_mempath
82 character(len=LENBIGLINE) :: wkt
83 character(len=LENBIGLINE) :: crs_wkt
84 character(len=LINELENGTH) :: datetime
85 character(len=LINELENGTH) :: xname
86 character(len=LINELENGTH) :: lenunits
88 real(dp),
dimension(:),
pointer,
contiguous :: x
89 integer(I4B) :: disenum
91 integer(I4B) :: totnstp
92 integer(I4B),
pointer :: deflate
93 integer(I4B),
pointer :: shuffle
94 integer(I4B),
pointer :: input_attr
95 integer(I4B),
pointer :: chunk_time
97 logical(LGP) :: chunking_active
138 character(len=*),
intent(in) :: ilayer_varname
139 integer(I4B),
intent(in) :: ilayer
147 subroutine epkg_init(this, mf6_input, mshape, naux, param_names, &
155 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: mshape
156 integer(I4B),
intent(in) :: naux
157 character(len=LINELENGTH),
dimension(:),
allocatable, &
158 intent(in) :: param_names
159 integer(I4B),
intent(in) :: nparam
161 character(len=LENVARNAME) :: rs_varname
162 character(len=LENMEMPATH) :: input_mempath
163 integer(I4B),
pointer :: rsvar
165 this%mf6_input = mf6_input
166 this%mshape => mshape
172 subcomponent=mf6_input%subcomponent_name, &
176 allocate (this%param_names(nparam))
177 allocate (this%param_reads(nparam))
178 allocate (this%varids_param(nparam, mshape(1)))
179 allocate (this%varids_aux(naux, mshape(1)))
183 this%param_names(n) = param_names(n)
184 rs_varname =
rsv_name(param_names(n))
185 call mem_setptr(rsvar, rs_varname, mf6_input%mempath)
186 this%param_reads(n)%invar => rsvar
190 call mem_setptr(this%iper,
'IPER', mf6_input%mempath)
198 if (
allocated(this%param_names))
deallocate (this%param_names)
203 subroutine set(this, modelname, modeltype, modelfname, nctype, disenum)
207 character(len=*),
intent(in) :: modelname
208 character(len=*),
intent(in) :: modeltype
209 character(len=*),
intent(in) :: modelfname
210 integer(I4B),
intent(in) :: nctype
211 integer(I4B),
intent(in) :: disenum
220 this%conventions =
''
225 this%conventions =
'CF-1.11'
227 trim(this%conventions)//
' UGRID-1.0'
230 select case (modeltype)
232 this%title = trim(modelname)//
' hydraulic head'
233 this%longname =
'head'
235 this%title = trim(modelname)//
' concentration'
236 this%longname =
'concentration'
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(modeltype)//
': '//trim(modelname)
267 this%source =
'MODFLOW 6 '//trim(adjustl(
fullversion))
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)
288 character(len=*),
intent(in) :: modelname
289 character(len=*),
intent(in) :: modeltype
290 character(len=*),
intent(in) :: modelfname
291 character(len=*),
intent(in) :: nc_fname
292 integer(I4B),
intent(in) :: disenum
293 integer(I4B),
intent(in) :: nctype
294 integer(I4B),
intent(in) :: iout
295 character(len=LENMEMPATH) :: model_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 =
''
316 this%disenum = disenum
324 this%chunking_active = .false.
327 call this%annotation%set(modelname, modeltype, modelfname, nctype, disenum)
330 select case (modeltype)
334 this%xname =
'concentration'
336 this%xname =
'temperature'
338 errmsg = trim(modeltype)//
' models not supported for NetCDF export.'
344 if (disenum ==
dis)
then
346 else if (disenum ==
disu)
then
348 else if (disenum ==
disv)
then
357 if (
filein_fname(this%ncf_mempath,
'NCF6_MEMPATH', this%dis_mempath, &
361 call mem_set_value(this%crs_wkt,
'CRS_WKT', this%ncf_mempath, &
363 call mem_set_value(this%deflate,
'DEFLATE', this%ncf_mempath, &
365 call mem_set_value(this%shuffle,
'SHUFFLE', this%ncf_mempath, &
367 call mem_set_value(this%input_attr,
'ATTR_OFF', this%ncf_mempath, &
369 call mem_set_value(this%chunk_time,
'CHUNK_TIME', this%ncf_mempath, &
370 ncf_found%chunk_time)
373 if (ncf_found%wkt .or. ncf_found%crs_wkt)
then
374 this%gridmap_name =
'projection'
378 if (ncf_found%attr_off)
then
384 this%datetime =
'days since '//trim(
datetime0)
387 this%datetime =
'days since 1970-01-01T00:00:00'
394 this%totnstp = sum(
nstp)
403 integer(I4B),
intent(in) :: idx
405 class(*),
pointer :: obj
407 obj => this%pkglist%GetItem(idx)
408 if (
associated(obj))
then
423 character(len=*),
intent(in) :: pkgname
425 character(len=LINELENGTH) :: attr
427 if (this%input_attr > 0)
then
439 integer(I4B) :: n,
istp
455 character(len=*),
intent(in) :: pkgname
456 character(len=*),
intent(in) :: tagname
457 character(len=*),
intent(in) :: mempath
458 integer(I4B),
optional,
intent(in) :: layer
459 integer(I4B),
optional,
intent(in) :: iaux
460 character(len=LINELENGTH) :: varname
462 contiguous :: auxnames
463 character(len=LINELENGTH) :: pname, vname
467 if (
present(iaux))
then
469 if (tagname ==
'AUX')
then
471 call mem_setptr(auxnames,
'AUXILIARY', mempath)
472 vname = auxnames(iaux)
479 varname = trim(pname)//
'_'//trim(vname)
481 if (
present(layer))
then
484 write (varname,
'(a,i0)') trim(varname)//
'_l', layer
492 component_type, subcomponent_type)
result(lname)
497 character(len=*),
intent(in) :: longname
498 character(len=*),
intent(in) :: pkgname
499 character(len=*),
intent(in) :: tagname
500 character(len=*),
intent(in) :: mempath
501 integer(I4B),
optional,
intent(in) :: layer
502 integer(I4B),
optional,
intent(in) :: iaux
503 character(len=*),
optional,
intent(in) :: component_type
504 character(len=*),
optional,
intent(in) :: subcomponent_type
505 character(len=LINELENGTH) :: lname
507 contiguous :: auxnames
508 character(len=LINELENGTH) :: pname, vname, auxname
513 if (longname ==
'')
then
514 lname = trim(pname)//
' '//trim(vname)
517 if (
present(component_type) .and.
present(subcomponent_type))
then
519 lname = trim(pname)//
' '//trim(lname)
524 if (
present(iaux))
then
526 if (tagname ==
'AUX')
then
528 call mem_setptr(auxnames,
'AUXILIARY', mempath)
529 auxname = auxnames(iaux)
531 lname = trim(lname)//
' '//trim(auxname)
536 if (
present(layer))
then
538 write (lname,
'(a,i0)') trim(lname)//
' layer ', layer
550 do idx = 1, this%pkglist%Count()
551 export_pkg => this%get(idx)
553 if (export_pkg%eper >=
kper) cycle
555 call this%package_step(export_pkg)
557 export_pkg%eper =
kper
572 character(len=*),
intent(in) :: wkt
573 character(len=LINELENGTH) :: gmname
574 character(len=LINELENGTH) :: proj_name
575 character(len=LENBIGLINE) :: wkt_upper
576 integer :: istart, iend
586 istart = index(wkt_upper,
'PROJECTION[')
587 if (istart /= 0)
then
588 istart = istart + len(
'PROJECTION[')
589 do while (istart <= len(wkt))
590 if (wkt(istart:istart) ==
'"')
exit
593 if (istart > len(wkt))
return
595 iend = index(wkt(istart:),
'"')
596 if (iend == 0)
return
597 iend = istart + iend - 2
598 if (iend < istart)
return
599 proj_name = wkt(istart:iend)
601 select case (trim(proj_name))
602 case (
'TRANSVERSE_MERCATOR')
603 gmname =
'transverse_mercator'
604 case (
'LAMBERT_CONFORMAL_CONIC_2SP',
'LAMBERT_CONFORMAL_CONIC_1SP')
605 gmname =
'lambert_conformal_conic'
606 case (
'ALBERS_CONIC_EQUAL_AREA')
607 gmname =
'albers_conical_equal_area'
608 case (
'MERCATOR_1SP',
'MERCATOR_2SP')
610 case (
'POLAR_STEREOGRAPHIC')
611 gmname =
'polar_stereographic'
617 istart = index(wkt_upper,
'METHOD[')
618 if (istart == 0)
return
619 istart = istart + len(
'METHOD[')
620 do while (istart <= len(wkt))
621 if (wkt(istart:istart) ==
'"')
exit
624 if (istart > len(wkt))
return
626 iend = index(wkt(istart:),
'"')
627 if (iend == 0)
return
628 iend = istart + iend - 2
629 if (iend < istart)
return
630 proj_name = wkt(istart:iend)
632 select case (trim(proj_name))
633 case (
'TRANSVERSE MERCATOR')
634 gmname =
'transverse_mercator'
635 case (
'LAMBERT CONIC CONFORMAL (2SP)',
'LAMBERT CONIC CONFORMAL (1SP)')
636 gmname =
'lambert_conformal_conic'
637 case (
'ALBERS EQUAL AREA')
638 gmname =
'albers_conical_equal_area'
639 case (
'MERCATOR (VARIANT A)',
'MERCATOR (VARIANT B)')
641 case (
'POLAR STEREOGRAPHIC (VARIANT A)',
'POLAR STEREOGRAPHIC (VARIANT B)')
642 gmname =
'polar_stereographic'
653 deallocate (this%deflate)
654 deallocate (this%shuffle)
655 deallocate (this%input_attr)
656 deallocate (this%chunk_time)
658 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
logical function, public idm_multi_package(component, subcomponent)
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 wkt_to_cf_gridmapping(wkt)
map a WKT string to a CF-1.11 grid_mapping_name
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
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
character(len=linelength) function, public export_longname(longname, pkgname, tagname, mempath, layer, iaux, component_type, subcomponent_type)
build netcdf variable longname
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
This module contains the SourceCommonModule.
logical(lgp) function, public filein_fname(filename, tagname, input_mempath, input_fname)
enforce and set a single input filename provided via FILEIN keyword
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= *), parameter fullversion
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