45 integer(I4B) :: elevation
47 integer(I4B) :: time_bnds
48 integer(I4B) :: dependent
49 integer(I4B) :: x_bnds
50 integer(I4B) :: y_bnds
51 integer(I4B) :: latitude
52 integer(I4B) :: longitude
53 integer(I4B) :: export
62 real(dp),
dimension(:),
pointer,
contiguous :: latitude => null()
63 real(dp),
dimension(:),
pointer,
contiguous :: longitude => null()
64 integer(I4B),
pointer :: chunk_z
65 integer(I4B),
pointer :: chunk_y
66 integer(I4B),
pointer :: chunk_x
67 integer(I4B),
dimension(:),
allocatable :: layers
68 logical(LGP) :: latlon
101 disenum, nctype, iout)
105 character(len=*),
intent(in) :: modelname
106 character(len=*),
intent(in) :: modeltype
107 character(len=*),
intent(in) :: modelfname
108 character(len=*),
intent(in) :: nc_fname
109 integer(I4B),
intent(in) :: disenum
110 integer(I4B),
intent(in) :: nctype
111 integer(I4B),
intent(in) :: iout
112 integer(I4B) :: k, latsz, lonsz
113 logical(LGP) :: found
116 this%nlay = this%dis%nlay
119 allocate (this%chunk_z)
120 allocate (this%chunk_y)
121 allocate (this%chunk_x)
122 allocate (this%layers(this%nlay))
132 this%latlon = .false.
135 call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
136 disenum, nctype, iout)
139 if (this%ncf_mempath /=
'')
then
140 call mem_set_value(this%chunk_z,
'CHUNK_Z', this%ncf_mempath, found)
141 call mem_set_value(this%chunk_y,
'CHUNK_Y', this%ncf_mempath, found)
142 call mem_set_value(this%chunk_x,
'CHUNK_X', this%ncf_mempath, found)
144 if (this%chunk_time > 0 .and. this%chunk_z > 0 .and. &
145 this%chunk_y > 0 .and. this%chunk_x > 0)
then
146 this%chunking_active = .true.
147 else if (this%chunk_time > 0 .or. this%chunk_z > 0 .or. &
148 this%chunk_y > 0 .or. this%chunk_x > 0)
then
153 write (
warnmsg,
'(a)')
'Ignoring user provided NetCDF chunking &
154 ¶meters. Define chunk_time, chunk_x, chunk_y and chunk_z input &
155 ¶meters to see an effect in file "'//trim(nc_fname)//
'".'
159 call get_isize(
'LATITUDE', this%ncf_mempath, latsz)
160 call get_isize(
'LONGITUDE', this%ncf_mempath, lonsz)
162 if (latsz > 0 .and. lonsz > 0)
then
164 if (this%wkt /=
'' .or. this%crs_wkt /=
'')
then
165 write (
warnmsg,
'(a)')
'Ignoring user provided NetCDF wkt/crs_wkt &
166 ¶meter(s) as longitude and latitude arrays have been provided. &
167 &Applies to file "'//trim(nc_fname)//
'".'
171 this%gridmap_name =
''
173 call mem_setptr(this%latitude,
'LATITUDE', this%ncf_mempath)
174 call mem_setptr(this%longitude,
'LONGITUDE', this%ncf_mempath)
175 if (this%dis%angrot /=
dzero)
then
176 write (
warnmsg,
'(a)')
'Structured rotated grid with &
177 &user-provided latitude/longitude: MF6 cannot verify these &
178 &values correctly account for grid rotation (angrot). They &
179 &must be computed from each cell''s true rotated position, &
180 ¬ from grid-local x/y. Applies to file "'// &
186 if (this%gridmap_name /=
'')
then
187 if (this%dis%angrot /=
dzero)
then
188 write (
warnmsg,
'(a)')
'CRS parameter set with structured rotated &
189 &grid. The x/y coordinate variables have grid-local, not &
190 &real-world, values. A CRS-aware consumer must apply the full &
191 &crs_wkt (which encodes rotation when a valid WKT2 PROJCRS was &
192 &supplied) via proper reprojection to resolve the true &
193 &position; deriving real longitude/latitude directly from x/y &
194 &and the flat/numeric CF grid_mapping parameters alone will be &
195 &incorrect, since those parameters never encode grid rotation. &
196 &Applies to file "'//trim(nc_fname)//
'".'
202 if (this%dis%lenuni == 1)
then
204 else if (this%dis%lenuni == 3)
then
211 call nf_verify(nf90_create(this%nc_fname, &
212 ior(nf90_clobber, nf90_netcdf4), this%ncid), &
220 call nf_verify(nf90_close(this%ncid), this%nc_fname)
221 deallocate (this%chunk_z)
222 deallocate (this%chunk_y)
223 deallocate (this%chunk_x)
224 deallocate (this%layers)
225 nullify (this%chunk_z)
226 nullify (this%chunk_y)
227 nullify (this%chunk_x)
229 call this%NCModelExportType%destroy()
239 call this%add_global_att()
241 call this%define_dim()
243 call this%define_geocoords()
246 call this%df_export()
249 call this%define_dependent()
252 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
254 call this%add_grid_data()
256 call this%add_proj_data()
259 call this%add_pkg_data()
262 call this%define_gridmap()
264 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
274 do idx = 1, this%pkglist%Count()
275 export_pkg => this%get(idx)
276 call this%export_df(export_pkg)
286 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
287 integer(I4B) :: n, istp
292 if (
size(this%dis%nodeuser) < &
293 size(this%dis%nodereduced))
then
294 allocate (dbl1d(
size(this%dis%nodereduced)))
296 do n = 1,
size(this%dis%nodereduced)
297 if (this%dis%nodereduced(n) > 0)
then
298 dbl1d(n) = this%x(this%dis%nodereduced(n))
303 this%var_ids%dependent, dbl1d, &
304 start=(/1, 1, 1, istp/), &
305 count=(/this%dis%ncol, &
307 this%dis%nlay, 1/)), &
313 this%var_ids%dependent, this%x, &
314 start=(/1, 1, 1, istp/), &
315 count=(/this%dis%ncol, &
317 this%dis%nlay, 1/)), &
322 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
323 totim, start=(/istp/)), &
327 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
334 character(len=*),
intent(in) :: pkgtype
335 character(len=*),
intent(in) :: pkgname
336 character(len=*),
intent(in) :: mempath
338 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
339 integer(I4B),
dimension(:, :),
pointer,
contiguous :: int2d
340 integer(I4B),
dimension(:, :, :),
pointer,
contiguous :: int3d
341 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
342 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
343 real(DP),
dimension(:, :, :),
pointer,
contiguous :: dbl3d
344 character(len=LINELENGTH) :: nc_tag
345 integer(I4B) :: iper, iaux
352 nc_tag = this%input_attribute(pkgname, idt)
354 select case (idt%datatype)
356 call mem_setptr(int1d, idt%mf6varname, mempath)
358 this%dis, idt, mempath, nc_tag, pkgname, &
359 this%gridmap_name, this%latlon, this%deflate, &
360 this%shuffle, this%chunk_z, this%chunk_y, &
361 this%chunk_x, iper, this%nc_fname)
363 call mem_setptr(int2d, idt%mf6varname, mempath)
365 this%dis, idt, mempath, nc_tag, pkgname, &
366 this%gridmap_name, this%latlon, this%deflate, &
367 this%shuffle, this%chunk_z, this%chunk_y, &
368 this%chunk_x, this%nc_fname)
370 call mem_setptr(int3d, idt%mf6varname, mempath)
372 this%dis, idt, mempath, nc_tag, pkgname, &
373 this%gridmap_name, this%latlon, this%deflate, &
374 this%shuffle, this%chunk_z, this%chunk_y, &
375 this%chunk_x, this%nc_fname)
377 call mem_setptr(dbl1d, idt%mf6varname, mempath)
379 this%dis, idt, mempath, nc_tag, pkgname, &
380 this%gridmap_name, this%latlon, this%deflate, &
381 this%shuffle, this%chunk_z, this%chunk_y, &
382 this%chunk_x, iper, iaux, this%nc_fname)
384 call mem_setptr(dbl2d, idt%mf6varname, mempath)
386 this%dis, idt, mempath, nc_tag, pkgname, &
387 this%gridmap_name, this%latlon, this%deflate, &
388 this%shuffle, this%chunk_z, this%chunk_y, &
389 this%chunk_x, this%nc_fname)
391 call mem_setptr(dbl3d, idt%mf6varname, mempath)
393 this%dis, idt, mempath, nc_tag, pkgname, &
394 this%gridmap_name, this%latlon, this%deflate, &
395 this%shuffle, this%chunk_z, this%chunk_y, &
396 this%chunk_x, this%nc_fname)
410 integer(I4B) :: iparam, iaux
413 do iparam = 1, export_pkg%nparam
419 export_pkg%mf6_input%component_type, &
420 export_pkg%mf6_input%subcomponent_type, &
421 'PERIOD', export_pkg%param_names(iparam),
'')
422 select case (idt%shape)
423 case (
'NCPL',
'NODES')
424 call this%create_timeseries(idt, iparam, iaux, export_pkg)
425 case (
'NAUX NCPL',
'NAUX NODES')
426 do iaux = 1, export_pkg%naux
427 call this%create_timeseries(idt, iparam, iaux, export_pkg)
440 integer(I4B),
intent(in) :: iparam
441 integer(I4B),
intent(in) :: iaux
443 character(len=LINELENGTH) :: varname, longname, nc_tag
444 integer(I4B) :: varid
445 logical(LGP) :: has_layer
447 has_layer = .not. (idt%shape ==
'NCPL' .or. idt%shape ==
'NAUX NCPL')
450 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
454 varname =
export_varname(export_pkg%mf6_input%subcomponent_name, &
455 idt%tagname, export_pkg%mf6_input%mempath, &
458 export_pkg%mf6_input%subcomponent_name, &
459 idt%tagname, export_pkg%mf6_input%mempath, &
461 component_type=idt%component_type, &
462 subcomponent_type=idt%subcomponent_type)
465 select case (idt%datatype)
466 case (
'DOUBLE1D',
'DOUBLE2D')
467 if (idt%shape ==
'NCPL' .or. &
468 idt%shape ==
'NAUX NCPL')
then
469 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
472 this%dim_ids%time/), varid), &
475 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
478 this%dim_ids%layer, &
479 this%dim_ids%time/), varid), &
482 call nf_verify(nf90_put_att(this%ncid, varid, &
483 '_FillValue', (/dnodata/)), &
486 call nf_verify(nf90_put_att(this%ncid, varid,
'cell_methods', &
487 'time: mean'), this%nc_fname)
489 if (idt%shape ==
'NCPL' .or. &
490 idt%shape ==
'NAUX NCPL')
then
491 call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
494 this%dim_ids%time/), varid), &
497 call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
500 this%dim_ids%layer, &
501 this%dim_ids%time/), varid), &
504 call nf_verify(nf90_put_att(this%ncid, varid, &
505 '_FillValue', (/nf90_fill_int/)), &
510 if (this%chunking_active)
then
511 call nf_verify(nf90_def_var_chunking(this%ncid, &
514 (/this%chunk_x, this%chunk_y, &
515 this%chunk_z, this%chunk_time/)), &
521 this%shuffle, this%nc_fname)
524 call nf_verify(nf90_put_att(this%ncid, varid, &
525 'long_name', longname), this%nc_fname)
528 call ncvar_gridmap(this%ncid, varid, this%gridmap_name, this%latlon, &
529 has_layer, this%nc_fname)
530 call ncvar_mf6attr(this%ncid, varid, iaux, nc_tag, this%nc_fname)
533 if (idt%tagname ==
'AUX')
then
534 export_pkg%varids_aux(iaux, 1) = varid
536 export_pkg%varids_param(iparam, 1) = varid
545 character(len=*),
intent(in) :: pkgtype
546 character(len=*),
intent(in) :: pkgname
547 character(len=*),
intent(in) :: mempath
549 intent(in) :: param_dfns
551 integer(I4B) :: iparam, isize
552 do iparam = 1,
size(param_dfns)
554 idt => param_dfns(iparam)
556 if (idt%blockname ==
'GRIDDATA')
then
558 call get_isize(idt%mf6varname, mempath, isize)
560 call this%export_input_array(pkgtype, pkgname, mempath, idt)
575 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
576 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d, nodes
577 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
578 character(len=LINELENGTH) :: nc_tag
579 integer(I4B) :: iaux, iparam, nvals, n
585 call export_pkg%update_state()
588 do iparam = 1, export_pkg%nparam
590 if (.not. export_pkg%param_state(iparam)) cycle
595 export_pkg%mf6_input%component_type, &
596 export_pkg%mf6_input%subcomponent_type, &
597 'PERIOD', export_pkg%param_names(iparam),
'')
600 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
604 select case (idt%datatype)
606 call mem_setptr(int1d, idt%mf6varname, export_pkg%mf6_input%mempath)
607 this%var_ids%export = export_pkg%varids_param(iparam, 1)
609 this%dis, idt, export_pkg%mf6_input%mempath, &
610 nc_tag, export_pkg%mf6_input%subcomponent_name, &
611 this%gridmap_name, this%latlon, this%deflate, &
612 this%shuffle, this%chunk_z, this%chunk_y, &
613 this%chunk_x,
kper, this%nc_fname)
615 call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
616 this%var_ids%export = export_pkg%varids_param(iparam, 1)
617 select case (idt%shape)
620 this%dis, idt, export_pkg%mf6_input%mempath, &
621 nc_tag, export_pkg%mf6_input%subcomponent_name, &
622 this%gridmap_name, this%latlon, this%deflate, &
623 this%shuffle, this%chunk_z, this%chunk_y, &
624 this%chunk_x,
kper, iaux, this%nc_fname)
626 nvals = this%dis%nodesuser
627 allocate (nodes(nvals))
629 call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
630 call export_pkg%user_nodes(dbl1d, nodes)
632 this%dis, idt, export_pkg%mf6_input%mempath, &
633 nc_tag, export_pkg%mf6_input%subcomponent_name, &
634 this%gridmap_name, this%latlon, this%deflate, &
635 this%shuffle, this%chunk_z, this%chunk_y, &
636 this%chunk_x,
kper, iaux, this%nc_fname)
641 call mem_setptr(dbl2d, idt%mf6varname, export_pkg%mf6_input%mempath)
642 select case (idt%shape)
644 nvals = this%dis%nrow * this%dis%ncol
645 allocate (nodes(nvals))
646 do iaux = 1,
size(dbl2d, dim=1)
647 if (.not. export_pkg%aux_state(iaux)) cycle
648 this%var_ids%export = export_pkg%varids_aux(iaux, 1)
650 nodes(n) = dbl2d(iaux, n)
653 this%dis, idt, export_pkg%mf6_input%mempath, &
654 nc_tag, export_pkg%mf6_input%subcomponent_name, &
655 this%gridmap_name, this%latlon, this%deflate, &
656 this%shuffle, this%chunk_z, this%chunk_y, &
657 this%chunk_x,
kper, iaux, this%nc_fname)
661 nvals = this%dis%nodesuser
662 allocate (nodes(nvals))
663 do iaux = 1,
size(dbl2d, dim=1)
664 if (.not. export_pkg%aux_state(iaux)) cycle
666 this%var_ids%export = export_pkg%varids_aux(iaux, 1)
667 call export_pkg%user_nodes(dbl2d(iaux, :), nodes)
669 this%dis, idt, export_pkg%mf6_input%mempath, &
670 nc_tag, export_pkg%mf6_input%subcomponent_name, &
671 this%gridmap_name, this%latlon, this%deflate, &
672 this%shuffle, this%chunk_z, this%chunk_y, &
673 this%chunk_x,
kper, iaux, this%nc_fname)
685 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
691 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time_bnds, &
693 start=(/1,
kper/), count=(/2, 1/)), &
696 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time_bnds, &
702 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
714 character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
716 pointer :: pkgtypes => null()
718 pointer :: pkgnames => null()
720 pointer :: mempaths => null()
722 character(len=LENMEMPATH) :: input_mempath, mempath
724 integer(I4B),
pointer :: export_arrays
725 logical(LGP) :: found
730 call mem_setptr(pkgtypes,
'PKGTYPES', input_mempath)
731 call mem_setptr(pkgnames,
'PKGNAMES', input_mempath)
732 call mem_setptr(mempaths,
'MEMPATHS', input_mempath)
734 do n = 1,
size(mempaths)
736 allocate (export_arrays)
740 mempath = mempaths(n)
745 if (mempath /=
'')
then
747 call mem_set_value(export_arrays,
'EXPORT_NC', mempath, found, &
750 if (export_arrays > 0)
then
753 call this%export_input_arrays(ptype, pname, mempath, param_dfns)
758 deallocate (export_arrays)
767 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'title', &
768 this%annotation%title), this%nc_fname)
770 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'source', &
771 this%annotation%source), this%nc_fname)
773 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_grid', &
774 this%annotation%grid), this%nc_fname)
776 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_model', &
777 this%annotation%model), this%nc_fname)
779 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'history', &
780 this%annotation%history), this%nc_fname)
782 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'Conventions', &
783 this%annotation%conventions), &
795 call nf_verify(nf90_def_dim(this%ncid,
'bnd', 2, this%dim_ids%bnd), &
800 call nf_verify(nf90_def_dim(this%ncid,
'time', this%totnstp, &
801 this%dim_ids%time), this%nc_fname)
802 call nf_verify(nf90_def_var(this%ncid,
'time', nf90_double, &
803 this%dim_ids%time, this%var_ids%time), &
805 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'calendar', &
806 'standard'), this%nc_fname)
807 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'units', &
808 this%datetime), this%nc_fname)
809 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'axis',
'T'), &
811 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'standard_name', &
812 'time'), this%nc_fname)
813 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'long_name', &
814 'time'), this%nc_fname)
817 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'bounds', &
818 'time_bnds'), this%nc_fname)
819 call nf_verify(nf90_def_var(this%ncid,
'time_bnds', nf90_double, &
820 (/this%dim_ids%bnd, this%dim_ids%time/), &
821 this%var_ids%time_bnds), this%nc_fname)
826 call nf_verify(nf90_def_dim(this%ncid,
'layer', this%dis%nlay, &
827 this%dim_ids%layer), this%nc_fname)
828 call nf_verify(nf90_def_var(this%ncid,
'layer', nf90_int, &
829 this%dim_ids%layer, this%var_ids%layer), &
831 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'units',
'1'), &
833 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'axis',
'Z'), &
835 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'positive', &
836 'down'), this%nc_fname)
837 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'long_name', &
838 'model layer'), this%nc_fname)
841 call nf_verify(nf90_def_dim(this%ncid,
'y', this%dis%nrow, this%dim_ids%y), &
843 call nf_verify(nf90_def_var(this%ncid,
'y', nf90_double, this%dim_ids%y, &
844 this%var_ids%y), this%nc_fname)
845 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'units', &
846 this%lenunits), this%nc_fname)
847 if (this%dis%angrot ==
dzero .or. &
848 wrap_rotated_crs(this%crs_wkt, this%dis%xorigin, this%dis%yorigin, &
849 this%dis%angrot) /=
'')
then
856 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'axis',
'Y'), &
858 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'standard_name', &
859 'projection_y_coordinate'), this%nc_fname)
861 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'long_name', &
862 'Northing'), this%nc_fname)
863 if (this%gridmap_name /=
'')
then
864 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'grid_mapping', &
865 this%gridmap_name), this%nc_fname)
867 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'bounds',
'y_bnds'), &
869 call nf_verify(nf90_def_var(this%ncid,
'y_bnds', nf90_double, &
870 (/this%dim_ids%bnd, this%dim_ids%y/), &
871 this%var_ids%y_bnds), this%nc_fname)
874 call nf_verify(nf90_def_dim(this%ncid,
'x', this%dis%ncol, this%dim_ids%x), &
876 call nf_verify(nf90_def_var(this%ncid,
'x', nf90_double, this%dim_ids%x, &
877 this%var_ids%x), this%nc_fname)
878 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'units', &
879 this%lenunits), this%nc_fname)
880 if (this%dis%angrot ==
dzero .or. &
881 wrap_rotated_crs(this%crs_wkt, this%dis%xorigin, this%dis%yorigin, &
882 this%dis%angrot) /=
'')
then
884 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'axis',
'X'), &
886 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'standard_name', &
887 'projection_x_coordinate'), this%nc_fname)
889 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'long_name', &
890 'Easting'), this%nc_fname)
891 if (this%gridmap_name /=
'')
then
892 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'grid_mapping', &
893 this%gridmap_name), this%nc_fname)
895 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'bounds',
'x_bnds'), &
897 call nf_verify(nf90_def_var(this%ncid,
'x_bnds', nf90_double, &
898 (/this%dim_ids%bnd, this%dim_ids%x/), &
899 this%var_ids%x_bnds), this%nc_fname)
904 call nf_verify(nf90_def_var(this%ncid,
'z', nf90_double, &
905 (/this%dim_ids%x, this%dim_ids%y, &
906 this%dim_ids%layer/), &
907 this%var_ids%elevation), this%nc_fname)
908 call ncvar_chunk3d(this%ncid, this%var_ids%elevation, this%chunk_x, &
909 this%chunk_y, this%chunk_z, this%nc_fname)
910 call ncvar_deflate(this%ncid, this%var_ids%elevation, this%deflate, &
911 this%shuffle, this%nc_fname)
912 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation,
'units', &
913 this%lenunits), this%nc_fname)
914 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
915 'standard_name',
'altitude'), this%nc_fname)
916 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
917 'positive',
'up'), this%nc_fname)
918 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
919 'long_name',
'cell center elevation'), &
929 call nf_verify(nf90_def_var(this%ncid, this%xname, nf90_double, &
930 (/this%dim_ids%x, this%dim_ids%y, &
931 this%dim_ids%layer, this%dim_ids%time/), &
932 this%var_ids%dependent), &
936 if (this%chunking_active)
then
937 call nf_verify(nf90_def_var_chunking(this%ncid, &
938 this%var_ids%dependent, &
940 (/this%chunk_x, this%chunk_y, &
941 this%chunk_z, this%chunk_time/)), &
946 call ncvar_deflate(this%ncid, this%var_ids%dependent, this%deflate, &
947 this%shuffle, this%nc_fname)
951 if (this%modeltype ==
'GWF')
then
952 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
953 'units', this%lenunits), this%nc_fname)
955 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent,
'long_name', &
956 this%annotation%longname), this%nc_fname)
957 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent,
'_FillValue', &
965 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
966 'cell_methods',
'time: point'), this%nc_fname)
969 call ncvar_gridmap(this%ncid, this%var_ids%dependent, this%gridmap_name, &
970 this%latlon, .true., this%nc_fname)
977 integer(I4B) :: var_id
978 character(len=LINELENGTH) :: gmname
979 character(len=LENBIGLINE) :: effective_crs_wkt, derived_wkt
980 character(len=100) :: rotinfo
981 real(DP) :: longitude_of_central_meridian, latitude_of_projection_origin
982 real(DP) :: scale_factor_at_central_meridian, false_easting, false_northing
983 real(DP) :: semi_major_axis, inverse_flattening
984 real(DP) :: standard_parallel_1, standard_parallel_2
985 logical(LGP) :: params_found, is_2sp
987 if (this%wkt /=
'' .or. this%crs_wkt /=
'')
then
988 call nf_verify(nf90_redef(this%ncid), this%nc_fname)
989 call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
990 var_id), this%nc_fname)
994 if (this%wkt /=
'')
then
995 call nf_verify(nf90_put_att(this%ncid, var_id,
'wkt', this%wkt), &
999 if (this%crs_wkt /=
'')
then
1000 effective_crs_wkt = this%crs_wkt
1002 effective_crs_wkt = this%wkt
1010 if (this%dis%angrot /= dzero)
then
1011 if (this%crs_wkt ==
'')
then
1012 write (warnmsg,
'(a)')
'Structured rotated grid with no CRS_WKT &
1013 &input: no rotation-positioning information will be written &
1014 &to the output CRS; x/y coordinate values will not reflect &
1015 &the true rotated position. Applies to file "'// &
1016 trim(this%nc_fname)//
'".'
1019 derived_wkt = wrap_rotated_crs(this%crs_wkt, this%dis%xorigin, &
1020 this%dis%yorigin, this%dis%angrot)
1021 if (derived_wkt /=
'')
then
1022 write (rotinfo,
'(a,g0,a,g0,a,g0,a)')
'xorigin=', &
1023 this%dis%xorigin,
', yorigin=', this%dis%yorigin, &
1024 ', angrot=', this%dis%angrot,
' deg'
1025 write (warnmsg,
'(a)')
'Structured rotated grid: wrapped &
1026 &CRS_WKT in a derived CRS to encode grid rotation ('// &
1027 trim(rotinfo)//
'). Applies to file "'// &
1028 trim(this%nc_fname)//
'".'
1030 effective_crs_wkt = derived_wkt
1032 write (warnmsg,
'(a)')
'Structured rotated grid: CRS_WKT is &
1033 ¬ a recognized WKT2 PROJCRS; no rotation-positioning &
1034 &information will be written to the output CRS; x/y &
1035 &coordinate values will not reflect the true rotated &
1036 &position. Applies to file "'//trim(this%nc_fname)//
'".'
1041 call nf_verify(nf90_put_att(this%ncid, var_id,
'crs_wkt', &
1042 trim(effective_crs_wkt)), this%nc_fname)
1044 gmname = wkt_to_cf_gridmapping(trim(effective_crs_wkt))
1045 if (gmname /=
'')
then
1046 call nf_verify(nf90_put_att(this%ncid, var_id,
'grid_mapping_name', &
1047 trim(gmname)), this%nc_fname)
1060 if (trim(gmname) ==
'transverse_mercator')
then
1061 call wkt_transverse_mercator_params(trim(effective_crs_wkt), &
1062 longitude_of_central_meridian, &
1063 latitude_of_projection_origin, &
1064 scale_factor_at_central_meridian, &
1065 false_easting, false_northing, &
1066 semi_major_axis, inverse_flattening, &
1068 if (params_found)
then
1069 call nf_verify(nf90_put_att(this%ncid, var_id, &
1070 'longitude_of_central_meridian', &
1071 longitude_of_central_meridian), &
1073 call nf_verify(nf90_put_att(this%ncid, var_id, &
1074 'latitude_of_projection_origin', &
1075 latitude_of_projection_origin), &
1077 call nf_verify(nf90_put_att(this%ncid, var_id, &
1078 'scale_factor_at_central_meridian', &
1079 scale_factor_at_central_meridian), &
1081 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1082 false_easting), this%nc_fname)
1083 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1084 false_northing), this%nc_fname)
1085 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1086 semi_major_axis), this%nc_fname)
1087 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1088 inverse_flattening), this%nc_fname)
1090 write (warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1091 &transverse_mercator grid_mapping parameters from CRS_WKT; &
1092 &some netCDF readers may not correctly position this grid. &
1093 &Applies to file "'//trim(this%nc_fname)//
'".'
1096 else if (trim(gmname) ==
'lambert_conformal_conic')
then
1097 call wkt_lambert_conformal_conic_params(trim(effective_crs_wkt), &
1098 standard_parallel_1, &
1099 standard_parallel_2, &
1100 longitude_of_central_meridian, &
1101 latitude_of_projection_origin, &
1102 false_easting, false_northing, &
1104 inverse_flattening, is_2sp, &
1106 if (params_found)
then
1107 call nf_verify(nf90_put_att(this%ncid, var_id,
'standard_parallel', &
1108 (/standard_parallel_1, &
1109 standard_parallel_2/)), this%nc_fname)
1110 call nf_verify(nf90_put_att(this%ncid, var_id, &
1111 'longitude_of_central_meridian', &
1112 longitude_of_central_meridian), &
1114 call nf_verify(nf90_put_att(this%ncid, var_id, &
1115 'latitude_of_projection_origin', &
1116 latitude_of_projection_origin), &
1118 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1119 false_easting), this%nc_fname)
1120 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1121 false_northing), this%nc_fname)
1122 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1123 semi_major_axis), this%nc_fname)
1124 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1125 inverse_flattening), this%nc_fname)
1126 else if (.not. is_2sp)
then
1127 write (warnmsg,
'(a)')
'Structured grid: 1SP lambert_conformal_conic &
1128 &variants are not supported for CF grid_mapping parameter &
1129 &extraction (CF has no scale_factor attribute for this method); &
1130 &some netCDF readers may not correctly position this grid. &
1131 &Applies to file "'//trim(this%nc_fname)//
'".'
1134 write (warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1135 &lambert_conformal_conic grid_mapping parameters from CRS_WKT; &
1136 &some netCDF readers may not correctly position this grid. &
1137 &Applies to file "'//trim(this%nc_fname)//
'".'
1140 else if (trim(gmname) ==
'albers_conical_equal_area')
then
1141 call wkt_albers_conical_equal_area_params(trim(effective_crs_wkt), &
1142 standard_parallel_1, &
1143 standard_parallel_2, &
1144 longitude_of_central_meridian, &
1145 latitude_of_projection_origin, &
1146 false_easting, false_northing, &
1148 inverse_flattening, &
1150 if (params_found)
then
1151 call nf_verify(nf90_put_att(this%ncid, var_id,
'standard_parallel', &
1152 (/standard_parallel_1, &
1153 standard_parallel_2/)), this%nc_fname)
1154 call nf_verify(nf90_put_att(this%ncid, var_id, &
1155 'longitude_of_central_meridian', &
1156 longitude_of_central_meridian), &
1158 call nf_verify(nf90_put_att(this%ncid, var_id, &
1159 'latitude_of_projection_origin', &
1160 latitude_of_projection_origin), &
1162 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1163 false_easting), this%nc_fname)
1164 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1165 false_northing), this%nc_fname)
1166 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1167 semi_major_axis), this%nc_fname)
1168 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1169 inverse_flattening), this%nc_fname)
1171 write (warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1172 &albers_conical_equal_area grid_mapping parameters from &
1173 &CRS_WKT; some netCDF readers may not correctly position this &
1174 &grid. Applies to file "'//trim(this%nc_fname)//
'".'
1182 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
1183 call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
1192 if (this%latlon)
then
1194 call nf_verify(nf90_def_var(this%ncid,
'lat', nf90_double, &
1195 (/this%dim_ids%x, this%dim_ids%y/), &
1196 this%var_ids%latitude), this%nc_fname)
1197 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1198 'units',
'degrees_north'), this%nc_fname)
1199 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1200 'standard_name',
'latitude'), this%nc_fname)
1201 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1202 'long_name',
'latitude'), this%nc_fname)
1205 call nf_verify(nf90_def_var(this%ncid,
'lon', nf90_double, &
1206 (/this%dim_ids%x, this%dim_ids%y/), &
1207 this%var_ids%longitude), this%nc_fname)
1208 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1209 'units',
'degrees_east'), this%nc_fname)
1210 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1211 'standard_name',
'longitude'), this%nc_fname)
1212 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1213 'long_name',
'longitude'), this%nc_fname)
1221 if (this%latlon)
then
1223 call nf_verify(nf90_put_var(this%ncid, this%var_ids%latitude, &
1224 this%latitude, start=(/1, 1/), &
1225 count=(/this%dis%ncol, this%dis%nrow/)), &
1229 call nf_verify(nf90_put_var(this%ncid, this%var_ids%longitude, &
1230 this%longitude, start=(/1, 1/), &
1231 count=(/this%dis%ncol, this%dis%nrow/)), &
1240 integer(I4B) :: ibnd, n, k
1241 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
1242 real(DP),
dimension(:),
allocatable :: x, y
1243 real(DP),
dimension(:, :, :),
allocatable :: elev3d
1244 real(DP) :: xoff, yoff
1246 if (this%dis%angrot /= dzero)
then
1250 xoff = this%dis%xorigin
1251 yoff = this%dis%yorigin
1254 allocate (x(
size(this%dis%cellx)))
1255 allocate (y(
size(this%dis%celly)))
1257 do n = 1,
size(this%dis%cellx)
1258 x(n) = this%dis%cellx(n) + xoff
1261 do n = 1,
size(this%dis%celly)
1262 y(n) = this%dis%celly(n) + yoff
1265 call nf_verify(nf90_put_var(this%ncid, this%var_ids%x, x), &
1267 call nf_verify(nf90_put_var(this%ncid, this%var_ids%y, y), &
1270 call nf_verify(nf90_put_var(this%ncid, this%var_ids%layer, this%layers), &
1278 allocate (elev3d(this%dis%ncol, this%dis%nrow, this%nlay))
1281 elev3d(:, :, k) = (this%dis%top2d(:, :) + this%dis%bot3d(:, :, k)) * &
1284 elev3d(:, :, k) = (this%dis%bot3d(:, :, k - 1) + &
1285 this%dis%bot3d(:, :, k)) * dhalf
1288 call nf_verify(nf90_put_var(this%ncid, this%var_ids%elevation, elev3d), &
1293 allocate (dbl2d(2,
size(this%dis%cellx)))
1295 do n = 1,
size(this%dis%cellx)
1297 dbl2d(1, ibnd) = xoff
1298 dbl2d(2, ibnd) = xoff + this%dis%delr(ibnd)
1300 dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) + this%dis%delr(ibnd)
1301 dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) + this%dis%delr(ibnd)
1305 call nf_verify(nf90_put_var(this%ncid, this%var_ids%x_bnds, dbl2d), &
1310 allocate (dbl2d(2,
size(this%dis%celly)))
1312 do n =
size(this%dis%celly), 1, -1
1314 dbl2d(1, ibnd) = yoff + sum(this%dis%delc) - this%dis%delc(n)
1315 dbl2d(2, ibnd) = yoff + sum(this%dis%delc)
1317 dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) - this%dis%delc(n)
1318 dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) - this%dis%delc(n)
1322 call nf_verify(nf90_put_var(this%ncid, this%var_ids%y_bnds, dbl2d), &
1330 integer(I4B),
intent(in) :: ncid
1331 integer(I4B),
intent(in) :: varid
1332 integer(I4B),
intent(in) :: chunk_x
1333 integer(I4B),
intent(in) :: chunk_y
1334 character(len=*),
intent(in) :: nc_fname
1335 if (chunk_y > 0 .and. chunk_x > 0)
then
1336 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1337 (/chunk_x, chunk_y/)), nc_fname)
1344 integer(I4B),
intent(in) :: ncid
1345 integer(I4B),
intent(in) :: varid
1346 integer(I4B),
intent(in) :: chunk_x
1347 integer(I4B),
intent(in) :: chunk_y
1348 integer(I4B),
intent(in) :: chunk_z
1349 character(len=*),
intent(in) :: nc_fname
1350 if (chunk_z > 0 .and. chunk_y > 0 .and. chunk_x > 0)
then
1351 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1352 (/chunk_x, chunk_y, chunk_z/)), &
1360 integer(I4B),
intent(in) :: ncid
1361 integer(I4B),
intent(in) :: varid
1362 integer(I4B),
intent(in) :: deflate
1363 integer(I4B),
intent(in) :: shuffle
1364 character(len=*),
intent(in) :: nc_fname
1366 if (deflate >= 0)
then
1367 call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
1368 deflate=1, deflate_level=deflate), &
1384 integer(I4B),
intent(in) :: ncid
1385 integer(I4B),
intent(in) :: varid
1386 character(len=*),
intent(in) :: gridmap_name
1387 logical(LGP),
intent(in) :: latlon
1388 logical(LGP),
intent(in) :: has_layer
1389 character(len=*),
intent(in) :: nc_fname
1390 character(len=LINELENGTH) :: coords
1400 if (len_trim(coords) > 0)
then
1401 coords = trim(coords)//
' z'
1406 if (len_trim(coords) > 0)
then
1407 call nf_verify(nf90_put_att(ncid, varid,
'coordinates', trim(coords)), &
1410 if (gridmap_name /=
'')
then
1411 call nf_verify(nf90_put_att(ncid, varid,
'grid_mapping', gridmap_name), &
1419 integer(I4B),
intent(in) :: ncid
1420 integer(I4B),
intent(in) :: varid
1421 integer(I4B),
intent(in) :: iaux
1422 character(len=*),
intent(in) :: nc_tag
1423 character(len=*),
intent(in) :: nc_fname
1424 if (nc_tag /=
'')
then
1425 call nf_verify(nf90_put_att(ncid, varid,
'modflow_input', &
1428 call nf_verify(nf90_put_att(ncid, varid,
'modflow_iaux', &
1437 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1438 shuffle, chunk_z, chunk_y, chunk_x, iper, nc_fname)
1440 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: p_mem
1441 integer(I4B),
intent(in) :: ncid
1444 type(
distype),
pointer,
intent(in) :: dis
1446 character(len=*),
intent(in) :: mempath
1447 character(len=*),
intent(in) :: nc_tag
1448 character(len=*),
intent(in) :: pkgname
1449 character(len=*),
intent(in) :: gridmap_name
1450 logical(LGP),
intent(in) :: latlon
1451 integer(I4B),
intent(in) :: deflate
1452 integer(I4B),
intent(in) :: shuffle
1453 integer(I4B),
intent(in) :: chunk_z
1454 integer(I4B),
intent(in) :: chunk_y
1455 integer(I4B),
intent(in) :: chunk_x
1456 integer(I4B),
intent(in) :: iper
1457 character(len=*),
intent(in) :: nc_fname
1458 integer(I4B) :: var_id, axis_sz
1459 character(len=LINELENGTH) :: varname, longname
1461 varname = export_varname(pkgname, idt%tagname, mempath)
1463 if (idt%shape ==
'NROW' .or. &
1464 idt%shape ==
'NCOL' .or. &
1465 idt%shape ==
'NCPL' .or. &
1466 idt%shape ==
'NAUX NCPL')
then
1469 select case (idt%shape)
1476 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1477 component_type=idt%component_type, &
1478 subcomponent_type=idt%subcomponent_type)
1481 call nf_verify(nf90_redef(ncid), nc_fname)
1482 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1483 (/axis_sz/), var_id), &
1487 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1490 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1491 (/nf90_fill_int/)), nc_fname)
1492 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1493 longname), nc_fname)
1499 call nf_verify(nf90_enddef(ncid), nc_fname)
1500 call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1505 var_ids%export, p_mem, &
1506 start=(/1, 1,
kper/), &
1507 count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1514 call nf_verify(nf90_redef(ncid), nc_fname)
1515 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1516 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1520 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1522 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1525 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1526 (/nf90_fill_int/)), nc_fname)
1527 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1528 idt%longname), nc_fname)
1531 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1536 call nf_verify(nf90_enddef(ncid), nc_fname)
1537 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1538 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1543 var_ids%export, p_mem, &
1544 start=(/1, 1, 1,
kper/), &
1545 count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1554 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1555 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1556 integer(I4B),
dimension(:, :),
pointer,
contiguous,
intent(in) :: p_mem
1557 integer(I4B),
intent(in) :: ncid
1560 type(
distype),
pointer,
intent(in) :: dis
1562 character(len=*),
intent(in) :: mempath
1563 character(len=*),
intent(in) :: nc_tag
1564 character(len=*),
intent(in) :: pkgname
1565 character(len=*),
intent(in) :: gridmap_name
1566 logical(LGP),
intent(in) :: latlon
1567 integer(I4B),
intent(in) :: deflate
1568 integer(I4B),
intent(in) :: shuffle
1569 integer(I4B),
intent(in) :: chunk_z
1570 integer(I4B),
intent(in) :: chunk_y
1571 integer(I4B),
intent(in) :: chunk_x
1572 character(len=*),
intent(in) :: nc_fname
1573 character(len=LINELENGTH) :: varname
1574 integer(I4B) :: var_id
1576 varname = export_varname(pkgname, idt%tagname, mempath)
1579 call nf_verify(nf90_redef(ncid), nc_fname)
1580 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1581 (/dim_ids%x, dim_ids%y/), var_id), &
1585 call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1587 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1590 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1591 (/nf90_fill_int/)), nc_fname)
1592 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1593 idt%longname), nc_fname)
1596 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .false., &
1601 call nf_verify(nf90_enddef(ncid), nc_fname)
1602 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1603 count=(/dis%ncol, dis%nrow/)), &
1610 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1611 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1612 integer(I4B),
dimension(:, :, :),
pointer,
contiguous,
intent(in) :: p_mem
1613 integer(I4B),
intent(in) :: ncid
1616 type(
distype),
pointer,
intent(in) :: dis
1618 character(len=*),
intent(in) :: mempath
1619 character(len=*),
intent(in) :: nc_tag
1620 character(len=*),
intent(in) :: pkgname
1621 character(len=*),
intent(in) :: gridmap_name
1622 logical(LGP),
intent(in) :: latlon
1623 integer(I4B),
intent(in) :: deflate
1624 integer(I4B),
intent(in) :: shuffle
1625 integer(I4B),
intent(in) :: chunk_z
1626 integer(I4B),
intent(in) :: chunk_y
1627 integer(I4B),
intent(in) :: chunk_x
1628 character(len=*),
intent(in) :: nc_fname
1629 character(len=LINELENGTH) :: varname
1630 integer(I4B) :: var_id
1632 varname = export_varname(pkgname, idt%tagname, mempath)
1635 call nf_verify(nf90_redef(ncid), nc_fname)
1636 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1637 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1641 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1643 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1646 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1647 (/nf90_fill_int/)), nc_fname)
1648 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1649 idt%longname), nc_fname)
1652 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1657 call nf_verify(nf90_enddef(ncid), nc_fname)
1658 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1659 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1666 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1667 shuffle, chunk_z, chunk_y, chunk_x, iper, iaux, &
1670 real(DP),
dimension(:),
pointer,
contiguous,
intent(in) :: p_mem
1671 integer(I4B),
intent(in) :: ncid
1674 type(
distype),
pointer,
intent(in) :: dis
1676 character(len=*),
intent(in) :: mempath
1677 character(len=*),
intent(in) :: nc_tag
1678 character(len=*),
intent(in) :: pkgname
1679 character(len=*),
intent(in) :: gridmap_name
1680 logical(LGP),
intent(in) :: latlon
1681 integer(I4B),
intent(in) :: deflate
1682 integer(I4B),
intent(in) :: shuffle
1683 integer(I4B),
intent(in) :: chunk_z
1684 integer(I4B),
intent(in) :: chunk_y
1685 integer(I4B),
intent(in) :: chunk_x
1686 integer(I4B),
intent(in) :: iper
1687 integer(I4B),
intent(in) :: iaux
1688 character(len=*),
intent(in) :: nc_fname
1689 integer(I4B) :: var_id, axis_sz
1690 character(len=LINELENGTH) :: varname, longname
1692 if (idt%shape ==
'NROW' .or. &
1693 idt%shape ==
'NCOL' .or. &
1694 idt%shape ==
'NCPL' .or. &
1695 idt%shape ==
'NAUX NCPL')
then
1698 select case (idt%shape)
1705 varname = export_varname(pkgname, idt%tagname, mempath)
1706 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1708 component_type=idt%component_type, &
1709 subcomponent_type=idt%subcomponent_type)
1712 call nf_verify(nf90_redef(ncid), nc_fname)
1713 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1714 (/axis_sz/), var_id), &
1718 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1721 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1722 (/nf90_fill_double/)), nc_fname)
1723 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1724 longname), nc_fname)
1730 call nf_verify(nf90_enddef(ncid), nc_fname)
1731 call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1736 var_ids%export, p_mem, &
1737 start=(/1, 1,
kper/), &
1738 count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1744 varname = export_varname(pkgname, idt%tagname, mempath, iaux=iaux)
1745 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1747 component_type=idt%component_type, &
1748 subcomponent_type=idt%subcomponent_type)
1751 call nf_verify(nf90_redef(ncid), nc_fname)
1752 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1753 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1757 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1759 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1762 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1763 (/nf90_fill_double/)), nc_fname)
1764 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1765 longname), nc_fname)
1768 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1773 call nf_verify(nf90_enddef(ncid), nc_fname)
1774 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1775 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1780 var_ids%export, p_mem, &
1781 start=(/1, 1, 1,
kper/), &
1782 count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1791 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1792 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1793 real(DP),
dimension(:, :),
pointer,
contiguous,
intent(in) :: p_mem
1794 integer(I4B),
intent(in) :: ncid
1797 type(
distype),
pointer,
intent(in) :: dis
1799 character(len=*),
intent(in) :: mempath
1800 character(len=*),
intent(in) :: nc_tag
1801 character(len=*),
intent(in) :: pkgname
1802 character(len=*),
intent(in) :: gridmap_name
1803 logical(LGP),
intent(in) :: latlon
1804 integer(I4B),
intent(in) :: deflate
1805 integer(I4B),
intent(in) :: shuffle
1806 integer(I4B),
intent(in) :: chunk_z
1807 integer(I4B),
intent(in) :: chunk_y
1808 integer(I4B),
intent(in) :: chunk_x
1809 character(len=*),
intent(in) :: nc_fname
1810 character(len=LINELENGTH) :: varname
1811 integer(I4B) :: var_id
1813 varname = export_varname(pkgname, idt%tagname, mempath)
1816 call nf_verify(nf90_redef(ncid), nc_fname)
1817 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1818 (/dim_ids%x, dim_ids%y/), var_id), &
1822 call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1824 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1827 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1828 (/nf90_fill_double/)), nc_fname)
1829 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1830 idt%longname), nc_fname)
1833 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .false., &
1838 call nf_verify(nf90_enddef(ncid), nc_fname)
1839 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1840 count=(/dis%ncol, dis%nrow/)), &
1847 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1848 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1849 real(DP),
dimension(:, :, :),
pointer,
contiguous,
intent(in) :: p_mem
1850 integer(I4B),
intent(in) :: ncid
1853 type(
distype),
pointer,
intent(in) :: dis
1855 character(len=*),
intent(in) :: mempath
1856 character(len=*),
intent(in) :: nc_tag
1857 character(len=*),
intent(in) :: pkgname
1858 character(len=*),
intent(in) :: gridmap_name
1859 logical(LGP),
intent(in) :: latlon
1860 integer(I4B),
intent(in) :: deflate
1861 integer(I4B),
intent(in) :: shuffle
1862 integer(I4B),
intent(in) :: chunk_z
1863 integer(I4B),
intent(in) :: chunk_y
1864 integer(I4B),
intent(in) :: chunk_x
1865 character(len=*),
intent(in) :: nc_fname
1866 integer(I4B) :: var_id
1867 character(len=LINELENGTH) :: varname, longname
1869 varname = export_varname(pkgname, idt%tagname, mempath)
1870 longname = export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1871 component_type=idt%component_type, &
1872 subcomponent_type=idt%subcomponent_type)
1875 call nf_verify(nf90_redef(ncid), nc_fname)
1876 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1877 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1881 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1883 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1886 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1887 (/nf90_fill_double/)), nc_fname)
1888 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1889 longname), nc_fname)
1892 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1897 call nf_verify(nf90_enddef(ncid), nc_fname)
1898 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1899 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
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
real(dp), parameter dnodata
real no data constant
integer(i4b), parameter lenbigline
maximum length of a big line
real(dp), parameter dhnoflo
real no flow constant
@ dis
DIS6 discretization.
real(dp), parameter dhalf
real constant 1/2
real(dp), parameter dzero
real constant zero
integer(i4b), parameter lenmempath
maximum length of the memory path
This module contains the DefinitionSelectModule.
type(inputparamdefinitiontype) function, pointer, public get_param_definition_type(input_definition_types, component_type, subcomponent_type, blockname, tagname, filename, found)
Return parameter definition.
This module contains the DisNCStructuredModule.
subroutine add_pkg_data(this)
determine packages to write gridded input
subroutine ncvar_mf6attr(ncid, varid, iaux, nc_tag, nc_fname)
put variable internal modflow6 attributes
subroutine dis_export_destroy(this)
netcdf export dis destroy
subroutine nc_export_int3d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
netcdf export 3D integer
subroutine ncvar_gridmap(ncid, varid, gridmap_name, latlon, has_layer, nc_fname)
put variable gridmap attributes
subroutine add_global_att(this)
create file (group) attributes
subroutine dis_export_init(this, modelname, modeltype, modelfname, nc_fname, disenum, nctype, iout)
netcdf export dis init
subroutine export_input_arrays(this, pkgtype, pkgname, mempath, param_dfns)
write package gridded input data
subroutine add_grid_data(this)
add grid coordinates
subroutine define_geocoords(this)
define grid projection variables
subroutine df(this)
netcdf export define
subroutine nc_export_dbl3d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
netcdf export 3D double
subroutine nc_export_dbl2d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
netcdf export 2D double
subroutine ncvar_chunk2d(ncid, varid, chunk_x, chunk_y, nc_fname)
define 2d variable chunking
subroutine nc_export_int1d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, nc_fname)
netcdf export 1D integer
subroutine add_proj_data(this)
add grid projection data
subroutine df_export(this)
define timeseries input variables
subroutine step(this)
netcdf export step
subroutine ncvar_deflate(ncid, varid, deflate, shuffle, nc_fname)
define variable compression
subroutine export_df(this, export_pkg)
define export package
subroutine define_dependent(this)
create the model layer dependent variables
subroutine create_timeseries(this, idt, iparam, iaux, export_pkg)
create timeseries export variable
subroutine export_input_array(this, pkgtype, pkgname, mempath, idt)
netcdf export an input array
subroutine ncvar_chunk3d(ncid, varid, chunk_x, chunk_y, chunk_z, nc_fname)
define 3d variable chunking
subroutine nc_export_int2d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
netcdf export 2D integer
subroutine define_dim(this)
netcdf export define dimensions
subroutine package_step(this, export_pkg)
netcdf export package dynamic input
subroutine nc_export_dbl1d(p_mem, ncid, dim_ids, var_ids, dis, idt, mempath, nc_tag, pkgname, gridmap_name, latlon, deflate, shuffle, chunk_z, chunk_y, chunk_x, iper, iaux, nc_fname)
netcdf export 1D double
subroutine define_gridmap(this)
create the file grid mapping container variable
type(inputparamdefinitiontype) function, dimension(:), pointer, public param_definitions(component, subcomponent)
This module defines variable data types.
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
subroutine, public get_isize(name, mem_path, isize)
@ brief Get the number of elements for this variable
This module contains the NCModelExportModule.
character(len=lenbigline) function, public wrap_rotated_crs(wkt, xorigin, yorigin, angrot)
wrap a WKT2 PROJCRS in a derived CRS encoding grid rotation
character(len=linelength) function, public wkt_to_cf_gridmapping(wkt)
map a WKT string to a CF-1.13 grid_mapping_name
character(len=linelength) function, public export_varname(pkgname, tagname, mempath, layer, iaux)
build netcdf variable name
subroutine, public wkt_lambert_conformal_conic_params(wkt, standard_parallel_1, standard_parallel_2, longitude_of_central_meridian, latitude_of_projection_origin, false_easting, false_northing, semi_major_axis, inverse_flattening, is_2sp, found)
extract CF lambert_conformal_conic grid_mapping parameters
subroutine, public wkt_transverse_mercator_params(wkt, longitude_of_central_meridian, latitude_of_projection_origin, scale_factor_at_central_meridian, false_easting, false_northing, semi_major_axis, inverse_flattening, found)
extract CF transverse_mercator grid_mapping parameters
character(len=linelength) function, public export_longname(longname, pkgname, tagname, mempath, layer, iaux, component_type, subcomponent_type)
build netcdf variable longname
subroutine, public wkt_albers_conical_equal_area_params(wkt, standard_parallel_1, standard_parallel_2, longitude_of_central_meridian, latitude_of_projection_origin, false_easting, false_northing, semi_major_axis, inverse_flattening, found)
extract CF albers_conical_equal_area grid_mapping parameters
This module contains the NetCDFCommonModule.
subroutine, public nf_verify(res, nc_fname)
error check a netcdf-fortran interface call
This module contains simulation methods.
subroutine, public store_warning(msg, substring)
Store warning message.
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
character(len=maxcharlen) warnmsg
warning message string
integer(i4b) isim_mode
simulation mode
This module contains the SourceCommonModule.
character(len=lencomponentname) function, public idm_subcomponent_type(component, subcomponent)
component from package or model type
real(dp), dimension(:), pointer, public, contiguous perlen
length of each stress period
real(dp), pointer, public totim
time relative to start of simulation
integer(i4b), pointer, public kper
current stress period number
This class is used to store a single deferred-length character string. It was designed to work in an ...
Structured grid discretization.
abstract type for model netcdf export type