45 integer(I4B) :: elevation
47 integer(I4B) :: dependent
48 integer(I4B) :: x_bnds
49 integer(I4B) :: y_bnds
50 integer(I4B) :: latitude
51 integer(I4B) :: longitude
52 integer(I4B) :: export
61 real(dp),
dimension(:),
pointer,
contiguous :: latitude => null()
62 real(dp),
dimension(:),
pointer,
contiguous :: longitude => null()
63 integer(I4B),
pointer :: chunk_z
64 integer(I4B),
pointer :: chunk_y
65 integer(I4B),
pointer :: chunk_x
66 integer(I4B),
dimension(:),
allocatable :: layers
67 logical(LGP) :: latlon
100 disenum, nctype, iout)
104 character(len=*),
intent(in) :: modelname
105 character(len=*),
intent(in) :: modeltype
106 character(len=*),
intent(in) :: modelfname
107 character(len=*),
intent(in) :: nc_fname
108 integer(I4B),
intent(in) :: disenum
109 integer(I4B),
intent(in) :: nctype
110 integer(I4B),
intent(in) :: iout
111 integer(I4B) :: k, latsz, lonsz
112 logical(LGP) :: found
115 this%nlay = this%dis%nlay
118 allocate (this%chunk_z)
119 allocate (this%chunk_y)
120 allocate (this%chunk_x)
121 allocate (this%layers(this%nlay))
131 this%latlon = .false.
134 call this%NCModelExportType%init(modelname, modeltype, modelfname, nc_fname, &
135 disenum, nctype, iout)
138 if (this%ncf_mempath /=
'')
then
139 call mem_set_value(this%chunk_z,
'CHUNK_Z', this%ncf_mempath, found)
140 call mem_set_value(this%chunk_y,
'CHUNK_Y', this%ncf_mempath, found)
141 call mem_set_value(this%chunk_x,
'CHUNK_X', this%ncf_mempath, found)
143 if (this%chunk_time > 0 .and. this%chunk_z > 0 .and. &
144 this%chunk_y > 0 .and. this%chunk_x > 0)
then
145 this%chunking_active = .true.
146 else if (this%chunk_time > 0 .or. this%chunk_z > 0 .or. &
147 this%chunk_y > 0 .or. this%chunk_x > 0)
then
152 write (
warnmsg,
'(a)')
'Ignoring user provided NetCDF chunking &
153 ¶meters. Define chunk_time, chunk_x, chunk_y and chunk_z input &
154 ¶meters to see an effect in file "'//trim(nc_fname)//
'".'
158 call get_isize(
'LATITUDE', this%ncf_mempath, latsz)
159 call get_isize(
'LONGITUDE', this%ncf_mempath, lonsz)
161 if (latsz > 0 .and. lonsz > 0)
then
163 if (this%wkt /=
'' .or. this%crs_wkt /=
'')
then
164 write (
warnmsg,
'(a)')
'Ignoring user provided NetCDF wkt/crs_wkt &
165 ¶meter(s) as longitude and latitude arrays have been provided. &
166 &Applies to file "'//trim(nc_fname)//
'".'
170 this%gridmap_name =
''
172 call mem_setptr(this%latitude,
'LATITUDE', this%ncf_mempath)
173 call mem_setptr(this%longitude,
'LONGITUDE', this%ncf_mempath)
174 if (this%dis%angrot /=
dzero)
then
175 write (
warnmsg,
'(a)')
'Structured rotated grid with &
176 &user-provided latitude/longitude: MF6 cannot verify these &
177 &values correctly account for grid rotation (angrot). They &
178 &must be computed from each cell''s true rotated position, &
179 ¬ from grid-local x/y. Applies to file "'// &
185 if (this%gridmap_name /=
'')
then
186 if (this%dis%angrot /=
dzero)
then
187 write (
warnmsg,
'(a)')
'CRS parameter set with structured rotated &
188 &grid. The x/y coordinate variables have grid-local, not &
189 &real-world, values. A CRS-aware consumer must apply the full &
190 &crs_wkt (which encodes rotation when a valid WKT2 PROJCRS was &
191 &supplied) via proper reprojection to resolve the true &
192 &position; deriving real longitude/latitude directly from x/y &
193 &and the flat/numeric CF grid_mapping parameters alone will be &
194 &incorrect, since those parameters never encode grid rotation. &
195 &Applies to file "'//trim(nc_fname)//
'".'
201 if (this%dis%lenuni == 1)
then
203 else if (this%dis%lenuni == 3)
then
210 call nf_verify(nf90_create(this%nc_fname, &
211 ior(nf90_clobber, nf90_netcdf4), this%ncid), &
219 call nf_verify(nf90_close(this%ncid), this%nc_fname)
220 deallocate (this%chunk_z)
221 deallocate (this%chunk_y)
222 deallocate (this%chunk_x)
223 deallocate (this%layers)
224 nullify (this%chunk_z)
225 nullify (this%chunk_y)
226 nullify (this%chunk_x)
228 call this%NCModelExportType%destroy()
238 call this%add_global_att()
240 call this%define_dim()
242 call this%define_geocoords()
245 call this%df_export()
248 call this%define_dependent()
251 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
253 call this%add_grid_data()
255 call this%add_proj_data()
258 call this%add_pkg_data()
261 call this%define_gridmap()
263 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
273 do idx = 1, this%pkglist%Count()
274 export_pkg => this%get(idx)
275 call this%export_df(export_pkg)
285 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
286 integer(I4B) :: n, istp
291 if (
size(this%dis%nodeuser) < &
292 size(this%dis%nodereduced))
then
293 allocate (dbl1d(
size(this%dis%nodereduced)))
295 do n = 1,
size(this%dis%nodereduced)
296 if (this%dis%nodereduced(n) > 0)
then
297 dbl1d(n) = this%x(this%dis%nodereduced(n))
302 this%var_ids%dependent, dbl1d, &
303 start=(/1, 1, 1, istp/), &
304 count=(/this%dis%ncol, &
306 this%dis%nlay, 1/)), &
312 this%var_ids%dependent, this%x, &
313 start=(/1, 1, 1, istp/), &
314 count=(/this%dis%ncol, &
316 this%dis%nlay, 1/)), &
321 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
322 totim, start=(/istp/)), &
326 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
333 character(len=*),
intent(in) :: pkgtype
334 character(len=*),
intent(in) :: pkgname
335 character(len=*),
intent(in) :: mempath
337 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
338 integer(I4B),
dimension(:, :),
pointer,
contiguous :: int2d
339 integer(I4B),
dimension(:, :, :),
pointer,
contiguous :: int3d
340 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d
341 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
342 real(DP),
dimension(:, :, :),
pointer,
contiguous :: dbl3d
343 character(len=LINELENGTH) :: nc_tag
344 integer(I4B) :: iper, iaux
351 nc_tag = this%input_attribute(pkgname, idt)
353 select case (idt%datatype)
355 call mem_setptr(int1d, idt%mf6varname, mempath)
357 this%dis, idt, mempath, nc_tag, pkgname, &
358 this%gridmap_name, this%latlon, this%deflate, &
359 this%shuffle, this%chunk_z, this%chunk_y, &
360 this%chunk_x, iper, this%nc_fname)
362 call mem_setptr(int2d, idt%mf6varname, mempath)
364 this%dis, idt, mempath, nc_tag, pkgname, &
365 this%gridmap_name, this%latlon, this%deflate, &
366 this%shuffle, this%chunk_z, this%chunk_y, &
367 this%chunk_x, this%nc_fname)
369 call mem_setptr(int3d, idt%mf6varname, mempath)
371 this%dis, idt, mempath, nc_tag, pkgname, &
372 this%gridmap_name, this%latlon, this%deflate, &
373 this%shuffle, this%chunk_z, this%chunk_y, &
374 this%chunk_x, this%nc_fname)
376 call mem_setptr(dbl1d, idt%mf6varname, mempath)
378 this%dis, idt, mempath, nc_tag, pkgname, &
379 this%gridmap_name, this%latlon, this%deflate, &
380 this%shuffle, this%chunk_z, this%chunk_y, &
381 this%chunk_x, iper, iaux, this%nc_fname)
383 call mem_setptr(dbl2d, idt%mf6varname, mempath)
385 this%dis, idt, mempath, nc_tag, pkgname, &
386 this%gridmap_name, this%latlon, this%deflate, &
387 this%shuffle, this%chunk_z, this%chunk_y, &
388 this%chunk_x, this%nc_fname)
390 call mem_setptr(dbl3d, idt%mf6varname, mempath)
392 this%dis, idt, mempath, nc_tag, pkgname, &
393 this%gridmap_name, this%latlon, this%deflate, &
394 this%shuffle, this%chunk_z, this%chunk_y, &
395 this%chunk_x, this%nc_fname)
409 integer(I4B) :: iparam, iaux
412 do iparam = 1, export_pkg%nparam
418 export_pkg%mf6_input%component_type, &
419 export_pkg%mf6_input%subcomponent_type, &
420 'PERIOD', export_pkg%param_names(iparam),
'')
421 select case (idt%shape)
422 case (
'NCPL',
'NODES')
423 call this%create_timeseries(idt, iparam, iaux, export_pkg)
424 case (
'NAUX NCPL',
'NAUX NODES')
425 do iaux = 1, export_pkg%naux
426 call this%create_timeseries(idt, iparam, iaux, export_pkg)
439 integer(I4B),
intent(in) :: iparam
440 integer(I4B),
intent(in) :: iaux
442 character(len=LINELENGTH) :: varname, longname, nc_tag
443 integer(I4B) :: varid
444 logical(LGP) :: has_layer
446 has_layer = .not. (idt%shape ==
'NCPL' .or. idt%shape ==
'NAUX NCPL')
449 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
453 varname = export_varname(export_pkg%mf6_input%subcomponent_name, &
454 idt%tagname, export_pkg%mf6_input%mempath, &
456 longname = export_longname(idt%longname, &
457 export_pkg%mf6_input%subcomponent_name, &
458 idt%tagname, export_pkg%mf6_input%mempath, &
460 component_type=idt%component_type, &
461 subcomponent_type=idt%subcomponent_type)
464 select case (idt%datatype)
465 case (
'DOUBLE1D',
'DOUBLE2D')
466 if (idt%shape ==
'NCPL' .or. &
467 idt%shape ==
'NAUX NCPL')
then
468 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
471 this%dim_ids%time/), varid), &
474 call nf_verify(nf90_def_var(this%ncid, varname, nf90_double, &
477 this%dim_ids%layer, &
478 this%dim_ids%time/), varid), &
481 call nf_verify(nf90_put_att(this%ncid, varid, &
485 if (idt%shape ==
'NCPL' .or. &
486 idt%shape ==
'NAUX NCPL')
then
487 call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
490 this%dim_ids%time/), varid), &
493 call nf_verify(nf90_def_var(this%ncid, varname, nf90_int, &
496 this%dim_ids%layer, &
497 this%dim_ids%time/), varid), &
500 call nf_verify(nf90_put_att(this%ncid, varid, &
501 '_FillValue', (/nf90_fill_int/)), &
506 if (this%chunking_active)
then
507 call nf_verify(nf90_def_var_chunking(this%ncid, &
510 (/this%chunk_x, this%chunk_y, &
511 this%chunk_z, this%chunk_time/)), &
517 this%shuffle, this%nc_fname)
520 call nf_verify(nf90_put_att(this%ncid, varid, &
521 'units', this%lenunits), this%nc_fname)
522 call nf_verify(nf90_put_att(this%ncid, varid, &
523 'long_name', longname), this%nc_fname)
526 call ncvar_gridmap(this%ncid, varid, this%gridmap_name, this%latlon, &
527 has_layer, this%nc_fname)
528 call ncvar_mf6attr(this%ncid, varid, iaux, nc_tag, this%nc_fname)
531 if (idt%tagname ==
'AUX')
then
532 export_pkg%varids_aux(iaux, 1) = varid
534 export_pkg%varids_param(iparam, 1) = varid
543 character(len=*),
intent(in) :: pkgtype
544 character(len=*),
intent(in) :: pkgname
545 character(len=*),
intent(in) :: mempath
547 intent(in) :: param_dfns
549 integer(I4B) :: iparam, isize
550 do iparam = 1,
size(param_dfns)
552 idt => param_dfns(iparam)
554 if (idt%blockname ==
'GRIDDATA')
then
556 call get_isize(idt%mf6varname, mempath, isize)
558 call this%export_input_array(pkgtype, pkgname, mempath, idt)
573 integer(I4B),
dimension(:),
pointer,
contiguous :: int1d
574 real(DP),
dimension(:),
pointer,
contiguous :: dbl1d, nodes
575 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
576 character(len=LINELENGTH) :: nc_tag
577 integer(I4B) :: iaux, iparam, nvals, n
578 integer(I4B),
pointer :: nbound
584 do iparam = 1, export_pkg%nparam
585 if (export_pkg%iper /=
kper) cycle
587 if (export_pkg%param_reads(iparam)%invar < 1) cycle
592 export_pkg%mf6_input%component_type, &
593 export_pkg%mf6_input%subcomponent_type, &
594 'PERIOD', export_pkg%param_names(iparam),
'')
597 nc_tag = this%input_attribute(export_pkg%mf6_input%subcomponent_name, &
601 select case (idt%datatype)
603 call mem_setptr(int1d, idt%mf6varname, export_pkg%mf6_input%mempath)
604 this%var_ids%export = export_pkg%varids_param(iparam, 1)
606 this%dis, idt, export_pkg%mf6_input%mempath, &
607 nc_tag, export_pkg%mf6_input%subcomponent_name, &
608 this%gridmap_name, this%latlon, this%deflate, &
609 this%shuffle, this%chunk_z, this%chunk_y, &
610 this%chunk_x,
kper, this%nc_fname)
612 call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
613 this%var_ids%export = export_pkg%varids_param(iparam, 1)
614 select case (idt%shape)
617 this%dis, idt, export_pkg%mf6_input%mempath, &
618 nc_tag, export_pkg%mf6_input%subcomponent_name, &
619 this%gridmap_name, this%latlon, this%deflate, &
620 this%shuffle, this%chunk_z, this%chunk_y, &
621 this%chunk_x,
kper, iaux, this%nc_fname)
623 nvals = this%dis%nodesuser
624 allocate (nodes(nvals))
626 call mem_setptr(dbl1d, idt%mf6varname, export_pkg%mf6_input%mempath)
627 call mem_setptr(int1d,
'NODEULIST', export_pkg%mf6_input%mempath)
628 call mem_setptr(nbound,
'NBOUND', export_pkg%mf6_input%mempath)
630 nodes(int1d(n)) = dbl1d(n)
633 this%dis, idt, export_pkg%mf6_input%mempath, &
634 nc_tag, export_pkg%mf6_input%subcomponent_name, &
635 this%gridmap_name, this%latlon, this%deflate, &
636 this%shuffle, this%chunk_z, this%chunk_y, &
637 this%chunk_x,
kper, iaux, this%nc_fname)
642 call mem_setptr(dbl2d, idt%mf6varname, export_pkg%mf6_input%mempath)
643 select case (idt%shape)
645 nvals = this%dis%nrow * this%dis%ncol
646 allocate (nodes(nvals))
647 do iaux = 1,
size(dbl2d, dim=1)
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 call mem_setptr(int1d,
'NODEULIST', export_pkg%mf6_input%mempath)
664 call mem_setptr(nbound,
'NBOUND', export_pkg%mf6_input%mempath)
665 do iaux = 1,
size(dbl2d, dim=1)
667 this%var_ids%export = export_pkg%varids_aux(iaux, 1)
669 nodes(int1d(n)) = dbl2d(iaux, n)
672 this%dis, idt, export_pkg%mf6_input%mempath, &
673 nc_tag, export_pkg%mf6_input%subcomponent_name, &
674 this%gridmap_name, this%latlon, this%deflate, &
675 this%shuffle, this%chunk_z, this%chunk_y, &
676 this%chunk_x,
kper, iaux, this%nc_fname)
688 call nf_verify(nf90_put_var(this%ncid, this%var_ids%time, &
693 call nf_verify(nf90_sync(this%ncid), this%nc_fname)
705 character(LENCOMPONENTNAME) :: ptype, pname, pkgtype
707 pointer :: pkgtypes => null()
709 pointer :: pkgnames => null()
711 pointer :: mempaths => null()
713 character(len=LENMEMPATH) :: input_mempath, mempath
715 integer(I4B),
pointer :: export_arrays
716 logical(LGP) :: found
721 call mem_setptr(pkgtypes,
'PKGTYPES', input_mempath)
722 call mem_setptr(pkgnames,
'PKGNAMES', input_mempath)
723 call mem_setptr(mempaths,
'MEMPATHS', input_mempath)
725 do n = 1,
size(mempaths)
727 allocate (export_arrays)
731 mempath = mempaths(n)
736 if (mempath /=
'')
then
738 call mem_set_value(export_arrays,
'EXPORT_NC', mempath, found, &
741 if (export_arrays > 0)
then
744 call this%export_input_arrays(ptype, pname, mempath, param_dfns)
749 deallocate (export_arrays)
758 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'title', &
759 this%annotation%title), this%nc_fname)
761 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'source', &
762 this%annotation%source), this%nc_fname)
764 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_grid', &
765 this%annotation%grid), this%nc_fname)
767 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'modflow_model', &
768 this%annotation%model), this%nc_fname)
770 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'history', &
771 this%annotation%history), this%nc_fname)
773 call nf_verify(nf90_put_att(this%ncid, nf90_global,
'Conventions', &
774 this%annotation%conventions), &
786 call nf_verify(nf90_def_dim(this%ncid,
'bnd', 2, this%dim_ids%bnd), &
791 call nf_verify(nf90_def_dim(this%ncid,
'time', this%totnstp, &
792 this%dim_ids%time), this%nc_fname)
793 call nf_verify(nf90_def_var(this%ncid,
'time', nf90_double, &
794 this%dim_ids%time, this%var_ids%time), &
796 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'calendar', &
797 'standard'), this%nc_fname)
798 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'units', &
799 this%datetime), this%nc_fname)
800 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'axis',
'T'), &
803 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'standard_name', &
804 'time'), this%nc_fname)
805 call nf_verify(nf90_put_att(this%ncid, this%var_ids%time,
'long_name', &
806 'time'), this%nc_fname)
810 call nf_verify(nf90_def_dim(this%ncid,
'layer', this%dis%nlay, &
811 this%dim_ids%layer), this%nc_fname)
812 call nf_verify(nf90_def_var(this%ncid,
'layer', nf90_int, &
813 this%dim_ids%layer, this%var_ids%layer), &
815 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'units',
'1'), &
817 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'axis',
'Z'), &
819 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'positive', &
820 'down'), this%nc_fname)
821 call nf_verify(nf90_put_att(this%ncid, this%var_ids%layer,
'long_name', &
822 'model layer'), this%nc_fname)
825 call nf_verify(nf90_def_dim(this%ncid,
'y', this%dis%nrow, this%dim_ids%y), &
827 call nf_verify(nf90_def_var(this%ncid,
'y', nf90_double, this%dim_ids%y, &
828 this%var_ids%y), this%nc_fname)
829 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'units', &
830 this%lenunits), this%nc_fname)
831 if (this%dis%angrot == dzero .or. &
833 this%dis%angrot) /=
'')
then
840 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'axis',
'Y'), &
842 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'standard_name', &
843 'projection_y_coordinate'), this%nc_fname)
845 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'long_name', &
846 'Northing'), this%nc_fname)
847 if (this%gridmap_name /=
'')
then
848 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'grid_mapping', &
849 this%gridmap_name), this%nc_fname)
851 call nf_verify(nf90_put_att(this%ncid, this%var_ids%y,
'bounds',
'y_bnds'), &
853 call nf_verify(nf90_def_var(this%ncid,
'y_bnds', nf90_double, &
854 (/this%dim_ids%bnd, this%dim_ids%y/), &
855 this%var_ids%y_bnds), this%nc_fname)
858 call nf_verify(nf90_def_dim(this%ncid,
'x', this%dis%ncol, this%dim_ids%x), &
860 call nf_verify(nf90_def_var(this%ncid,
'x', nf90_double, this%dim_ids%x, &
861 this%var_ids%x), this%nc_fname)
862 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'units', &
863 this%lenunits), this%nc_fname)
864 if (this%dis%angrot == dzero .or. &
866 this%dis%angrot) /=
'')
then
868 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'axis',
'X'), &
870 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'standard_name', &
871 'projection_x_coordinate'), this%nc_fname)
873 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'long_name', &
874 'Easting'), this%nc_fname)
875 if (this%gridmap_name /=
'')
then
876 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'grid_mapping', &
877 this%gridmap_name), this%nc_fname)
879 call nf_verify(nf90_put_att(this%ncid, this%var_ids%x,
'bounds',
'x_bnds'), &
881 call nf_verify(nf90_def_var(this%ncid,
'x_bnds', nf90_double, &
882 (/this%dim_ids%bnd, this%dim_ids%x/), &
883 this%var_ids%x_bnds), this%nc_fname)
888 call nf_verify(nf90_def_var(this%ncid,
'z', nf90_double, &
889 (/this%dim_ids%x, this%dim_ids%y, &
890 this%dim_ids%layer/), &
891 this%var_ids%elevation), this%nc_fname)
892 call ncvar_chunk3d(this%ncid, this%var_ids%elevation, this%chunk_x, &
893 this%chunk_y, this%chunk_z, this%nc_fname)
894 call ncvar_deflate(this%ncid, this%var_ids%elevation, this%deflate, &
895 this%shuffle, this%nc_fname)
896 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation,
'units', &
897 this%lenunits), this%nc_fname)
898 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
899 'standard_name',
'altitude'), this%nc_fname)
900 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
901 'positive',
'up'), this%nc_fname)
902 call nf_verify(nf90_put_att(this%ncid, this%var_ids%elevation, &
903 'long_name',
'cell center elevation'), &
913 call nf_verify(nf90_def_var(this%ncid, this%xname, nf90_double, &
914 (/this%dim_ids%x, this%dim_ids%y, &
915 this%dim_ids%layer, this%dim_ids%time/), &
916 this%var_ids%dependent), &
920 if (this%chunking_active)
then
921 call nf_verify(nf90_def_var_chunking(this%ncid, &
922 this%var_ids%dependent, &
924 (/this%chunk_x, this%chunk_y, &
925 this%chunk_z, this%chunk_time/)), &
930 call ncvar_deflate(this%ncid, this%var_ids%dependent, this%deflate, &
931 this%shuffle, this%nc_fname)
934 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
935 'units', this%lenunits), this%nc_fname)
936 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent,
'long_name', &
937 this%annotation%longname), this%nc_fname)
938 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent,
'_FillValue', &
946 call nf_verify(nf90_put_att(this%ncid, this%var_ids%dependent, &
947 'cell_methods',
'time: point'), this%nc_fname)
950 call ncvar_gridmap(this%ncid, this%var_ids%dependent, this%gridmap_name, &
951 this%latlon, .true., this%nc_fname)
958 integer(I4B) :: var_id
959 character(len=LINELENGTH) :: gmname
960 character(len=LENBIGLINE) :: effective_crs_wkt, derived_wkt
961 character(len=100) :: rotinfo
962 real(DP) :: longitude_of_central_meridian, latitude_of_projection_origin
963 real(DP) :: scale_factor_at_central_meridian, false_easting, false_northing
964 real(DP) :: semi_major_axis, inverse_flattening
965 real(DP) :: standard_parallel_1, standard_parallel_2
966 logical(LGP) :: params_found, is_2sp
968 if (this%wkt /=
'' .or. this%crs_wkt /=
'')
then
969 call nf_verify(nf90_redef(this%ncid), this%nc_fname)
970 call nf_verify(nf90_def_var(this%ncid, this%gridmap_name, nf90_int, &
971 var_id), this%nc_fname)
975 if (this%wkt /=
'')
then
976 call nf_verify(nf90_put_att(this%ncid, var_id,
'wkt', this%wkt), &
980 if (this%crs_wkt /=
'')
then
981 effective_crs_wkt = this%crs_wkt
983 effective_crs_wkt = this%wkt
991 if (this%dis%angrot /=
dzero)
then
992 if (this%crs_wkt ==
'')
then
993 write (
warnmsg,
'(a)')
'Structured rotated grid with no CRS_WKT &
994 &input: no rotation-positioning information will be written &
995 &to the output CRS; x/y coordinate values will not reflect &
996 &the true rotated position. Applies to file "'// &
997 trim(this%nc_fname)//
'".'
1001 this%dis%yorigin, this%dis%angrot)
1002 if (derived_wkt /=
'')
then
1003 write (rotinfo,
'(a,g0,a,g0,a,g0,a)')
'xorigin=', &
1004 this%dis%xorigin,
', yorigin=', this%dis%yorigin, &
1005 ', angrot=', this%dis%angrot,
' deg'
1006 write (
warnmsg,
'(a)')
'Structured rotated grid: wrapped &
1007 &CRS_WKT in a derived CRS to encode grid rotation ('// &
1008 trim(rotinfo)//
'). Applies to file "'// &
1009 trim(this%nc_fname)//
'".'
1011 effective_crs_wkt = derived_wkt
1013 write (
warnmsg,
'(a)')
'Structured rotated grid: CRS_WKT is &
1014 ¬ a recognized WKT2 PROJCRS; no rotation-positioning &
1015 &information will be written to the output CRS; x/y &
1016 &coordinate values will not reflect the true rotated &
1017 &position. Applies to file "'//trim(this%nc_fname)//
'".'
1022 call nf_verify(nf90_put_att(this%ncid, var_id,
'crs_wkt', &
1023 trim(effective_crs_wkt)), this%nc_fname)
1026 if (gmname /=
'')
then
1027 call nf_verify(nf90_put_att(this%ncid, var_id,
'grid_mapping_name', &
1028 trim(gmname)), this%nc_fname)
1041 if (trim(gmname) ==
'transverse_mercator')
then
1043 longitude_of_central_meridian, &
1044 latitude_of_projection_origin, &
1045 scale_factor_at_central_meridian, &
1046 false_easting, false_northing, &
1047 semi_major_axis, inverse_flattening, &
1049 if (params_found)
then
1050 call nf_verify(nf90_put_att(this%ncid, var_id, &
1051 'longitude_of_central_meridian', &
1052 longitude_of_central_meridian), &
1054 call nf_verify(nf90_put_att(this%ncid, var_id, &
1055 'latitude_of_projection_origin', &
1056 latitude_of_projection_origin), &
1058 call nf_verify(nf90_put_att(this%ncid, var_id, &
1059 'scale_factor_at_central_meridian', &
1060 scale_factor_at_central_meridian), &
1062 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1063 false_easting), this%nc_fname)
1064 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1065 false_northing), this%nc_fname)
1066 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1067 semi_major_axis), this%nc_fname)
1068 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1069 inverse_flattening), this%nc_fname)
1071 write (
warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1072 &transverse_mercator grid_mapping parameters from CRS_WKT; &
1073 &some netCDF readers may not correctly position this grid. &
1074 &Applies to file "'//trim(this%nc_fname)//
'".'
1077 else if (trim(gmname) ==
'lambert_conformal_conic')
then
1079 standard_parallel_1, &
1080 standard_parallel_2, &
1081 longitude_of_central_meridian, &
1082 latitude_of_projection_origin, &
1083 false_easting, false_northing, &
1085 inverse_flattening, is_2sp, &
1087 if (params_found)
then
1088 call nf_verify(nf90_put_att(this%ncid, var_id,
'standard_parallel', &
1089 (/standard_parallel_1, &
1090 standard_parallel_2/)), this%nc_fname)
1091 call nf_verify(nf90_put_att(this%ncid, var_id, &
1092 'longitude_of_central_meridian', &
1093 longitude_of_central_meridian), &
1095 call nf_verify(nf90_put_att(this%ncid, var_id, &
1096 'latitude_of_projection_origin', &
1097 latitude_of_projection_origin), &
1099 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1100 false_easting), this%nc_fname)
1101 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1102 false_northing), this%nc_fname)
1103 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1104 semi_major_axis), this%nc_fname)
1105 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1106 inverse_flattening), this%nc_fname)
1107 else if (.not. is_2sp)
then
1108 write (
warnmsg,
'(a)')
'Structured grid: 1SP lambert_conformal_conic &
1109 &variants are not supported for CF grid_mapping parameter &
1110 &extraction (CF has no scale_factor attribute for this method); &
1111 &some netCDF readers may not correctly position this grid. &
1112 &Applies to file "'//trim(this%nc_fname)//
'".'
1115 write (
warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1116 &lambert_conformal_conic grid_mapping parameters from CRS_WKT; &
1117 &some netCDF readers may not correctly position this grid. &
1118 &Applies to file "'//trim(this%nc_fname)//
'".'
1121 else if (trim(gmname) ==
'albers_conical_equal_area')
then
1123 standard_parallel_1, &
1124 standard_parallel_2, &
1125 longitude_of_central_meridian, &
1126 latitude_of_projection_origin, &
1127 false_easting, false_northing, &
1129 inverse_flattening, &
1131 if (params_found)
then
1132 call nf_verify(nf90_put_att(this%ncid, var_id,
'standard_parallel', &
1133 (/standard_parallel_1, &
1134 standard_parallel_2/)), this%nc_fname)
1135 call nf_verify(nf90_put_att(this%ncid, var_id, &
1136 'longitude_of_central_meridian', &
1137 longitude_of_central_meridian), &
1139 call nf_verify(nf90_put_att(this%ncid, var_id, &
1140 'latitude_of_projection_origin', &
1141 latitude_of_projection_origin), &
1143 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_easting', &
1144 false_easting), this%nc_fname)
1145 call nf_verify(nf90_put_att(this%ncid, var_id,
'false_northing', &
1146 false_northing), this%nc_fname)
1147 call nf_verify(nf90_put_att(this%ncid, var_id,
'semi_major_axis', &
1148 semi_major_axis), this%nc_fname)
1149 call nf_verify(nf90_put_att(this%ncid, var_id,
'inverse_flattening', &
1150 inverse_flattening), this%nc_fname)
1152 write (
warnmsg,
'(a)')
'Structured grid: unable to extract CF &
1153 &albers_conical_equal_area grid_mapping parameters from &
1154 &CRS_WKT; some netCDF readers may not correctly position this &
1155 &grid. Applies to file "'//trim(this%nc_fname)//
'".'
1163 call nf_verify(nf90_enddef(this%ncid), this%nc_fname)
1164 call nf_verify(nf90_put_var(this%ncid, var_id, 1), &
1173 if (this%latlon)
then
1175 call nf_verify(nf90_def_var(this%ncid,
'lat', nf90_double, &
1176 (/this%dim_ids%x, this%dim_ids%y/), &
1177 this%var_ids%latitude), this%nc_fname)
1178 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1179 'units',
'degrees_north'), this%nc_fname)
1180 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1181 'standard_name',
'latitude'), this%nc_fname)
1182 call nf_verify(nf90_put_att(this%ncid, this%var_ids%latitude, &
1183 'long_name',
'latitude'), this%nc_fname)
1186 call nf_verify(nf90_def_var(this%ncid,
'lon', nf90_double, &
1187 (/this%dim_ids%x, this%dim_ids%y/), &
1188 this%var_ids%longitude), this%nc_fname)
1189 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1190 'units',
'degrees_east'), this%nc_fname)
1191 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1192 'standard_name',
'longitude'), this%nc_fname)
1193 call nf_verify(nf90_put_att(this%ncid, this%var_ids%longitude, &
1194 'long_name',
'longitude'), this%nc_fname)
1202 if (this%latlon)
then
1204 call nf_verify(nf90_put_var(this%ncid, this%var_ids%latitude, &
1205 this%latitude, start=(/1, 1/), &
1206 count=(/this%dis%ncol, this%dis%nrow/)), &
1210 call nf_verify(nf90_put_var(this%ncid, this%var_ids%longitude, &
1211 this%longitude, start=(/1, 1/), &
1212 count=(/this%dis%ncol, this%dis%nrow/)), &
1221 integer(I4B) :: ibnd, n, k
1222 real(DP),
dimension(:, :),
pointer,
contiguous :: dbl2d
1223 real(DP),
dimension(:),
allocatable :: x, y
1224 real(DP),
dimension(:, :, :),
allocatable :: elev3d
1225 real(DP) :: xoff, yoff
1227 if (this%dis%angrot /=
dzero)
then
1231 xoff = this%dis%xorigin
1232 yoff = this%dis%yorigin
1235 allocate (x(
size(this%dis%cellx)))
1236 allocate (y(
size(this%dis%celly)))
1238 do n = 1,
size(this%dis%cellx)
1239 x(n) = this%dis%cellx(n) + xoff
1242 do n = 1,
size(this%dis%celly)
1243 y(n) = this%dis%celly(n) + yoff
1246 call nf_verify(nf90_put_var(this%ncid, this%var_ids%x, x), &
1248 call nf_verify(nf90_put_var(this%ncid, this%var_ids%y, y), &
1251 call nf_verify(nf90_put_var(this%ncid, this%var_ids%layer, this%layers), &
1259 allocate (elev3d(this%dis%ncol, this%dis%nrow, this%nlay))
1262 elev3d(:, :, k) = (this%dis%top2d(:, :) + this%dis%bot3d(:, :, k)) * &
1265 elev3d(:, :, k) = (this%dis%bot3d(:, :, k - 1) + &
1266 this%dis%bot3d(:, :, k)) *
dhalf
1269 call nf_verify(nf90_put_var(this%ncid, this%var_ids%elevation, elev3d), &
1274 allocate (dbl2d(2,
size(this%dis%cellx)))
1276 do n = 1,
size(this%dis%cellx)
1278 dbl2d(1, ibnd) = xoff
1279 dbl2d(2, ibnd) = xoff + this%dis%delr(ibnd)
1281 dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) + this%dis%delr(ibnd)
1282 dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) + this%dis%delr(ibnd)
1286 call nf_verify(nf90_put_var(this%ncid, this%var_ids%x_bnds, dbl2d), &
1291 allocate (dbl2d(2,
size(this%dis%celly)))
1293 do n =
size(this%dis%celly), 1, -1
1295 dbl2d(1, ibnd) = yoff + sum(this%dis%delc) - this%dis%delc(n)
1296 dbl2d(2, ibnd) = yoff + sum(this%dis%delc)
1298 dbl2d(1, ibnd) = dbl2d(1, ibnd - 1) - this%dis%delc(n)
1299 dbl2d(2, ibnd) = dbl2d(2, ibnd - 1) - this%dis%delc(n)
1303 call nf_verify(nf90_put_var(this%ncid, this%var_ids%y_bnds, dbl2d), &
1311 integer(I4B),
intent(in) :: ncid
1312 integer(I4B),
intent(in) :: varid
1313 integer(I4B),
intent(in) :: chunk_x
1314 integer(I4B),
intent(in) :: chunk_y
1315 character(len=*),
intent(in) :: nc_fname
1316 if (chunk_y > 0 .and. chunk_x > 0)
then
1317 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1318 (/chunk_x, chunk_y/)), nc_fname)
1325 integer(I4B),
intent(in) :: ncid
1326 integer(I4B),
intent(in) :: varid
1327 integer(I4B),
intent(in) :: chunk_x
1328 integer(I4B),
intent(in) :: chunk_y
1329 integer(I4B),
intent(in) :: chunk_z
1330 character(len=*),
intent(in) :: nc_fname
1331 if (chunk_z > 0 .and. chunk_y > 0 .and. chunk_x > 0)
then
1332 call nf_verify(nf90_def_var_chunking(ncid, varid, nf90_chunked, &
1333 (/chunk_x, chunk_y, chunk_z/)), &
1341 integer(I4B),
intent(in) :: ncid
1342 integer(I4B),
intent(in) :: varid
1343 integer(I4B),
intent(in) :: deflate
1344 integer(I4B),
intent(in) :: shuffle
1345 character(len=*),
intent(in) :: nc_fname
1347 if (deflate >= 0)
then
1348 call nf_verify(nf90_def_var_deflate(ncid, varid, shuffle=shuffle, &
1349 deflate=1, deflate_level=deflate), &
1365 integer(I4B),
intent(in) :: ncid
1366 integer(I4B),
intent(in) :: varid
1367 character(len=*),
intent(in) :: gridmap_name
1368 logical(LGP),
intent(in) :: latlon
1369 logical(LGP),
intent(in) :: has_layer
1370 character(len=*),
intent(in) :: nc_fname
1371 character(len=LINELENGTH) :: coords
1381 if (len_trim(coords) > 0)
then
1382 coords = trim(coords)//
' z'
1387 if (len_trim(coords) > 0)
then
1388 call nf_verify(nf90_put_att(ncid, varid,
'coordinates', trim(coords)), &
1391 if (gridmap_name /=
'')
then
1392 call nf_verify(nf90_put_att(ncid, varid,
'grid_mapping', gridmap_name), &
1400 integer(I4B),
intent(in) :: ncid
1401 integer(I4B),
intent(in) :: varid
1402 integer(I4B),
intent(in) :: iaux
1403 character(len=*),
intent(in) :: nc_tag
1404 character(len=*),
intent(in) :: nc_fname
1405 if (nc_tag /=
'')
then
1406 call nf_verify(nf90_put_att(ncid, varid,
'modflow_input', &
1409 call nf_verify(nf90_put_att(ncid, varid,
'modflow_iaux', &
1418 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1419 shuffle, chunk_z, chunk_y, chunk_x, iper, nc_fname)
1421 integer(I4B),
dimension(:),
pointer,
contiguous,
intent(in) :: p_mem
1422 integer(I4B),
intent(in) :: ncid
1425 type(
distype),
pointer,
intent(in) :: dis
1427 character(len=*),
intent(in) :: mempath
1428 character(len=*),
intent(in) :: nc_tag
1429 character(len=*),
intent(in) :: pkgname
1430 character(len=*),
intent(in) :: gridmap_name
1431 logical(LGP),
intent(in) :: latlon
1432 integer(I4B),
intent(in) :: deflate
1433 integer(I4B),
intent(in) :: shuffle
1434 integer(I4B),
intent(in) :: chunk_z
1435 integer(I4B),
intent(in) :: chunk_y
1436 integer(I4B),
intent(in) :: chunk_x
1437 integer(I4B),
intent(in) :: iper
1438 character(len=*),
intent(in) :: nc_fname
1439 integer(I4B) :: var_id, axis_sz
1440 character(len=LINELENGTH) :: varname, longname
1444 if (idt%shape ==
'NROW' .or. &
1445 idt%shape ==
'NCOL' .or. &
1446 idt%shape ==
'NCPL' .or. &
1447 idt%shape ==
'NAUX NCPL')
then
1450 select case (idt%shape)
1457 longname =
export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1458 component_type=idt%component_type, &
1459 subcomponent_type=idt%subcomponent_type)
1462 call nf_verify(nf90_redef(ncid), nc_fname)
1463 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1464 (/axis_sz/), var_id), &
1468 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1471 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1472 (/nf90_fill_int/)), nc_fname)
1473 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1474 longname), nc_fname)
1480 call nf_verify(nf90_enddef(ncid), nc_fname)
1481 call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1486 var_ids%export, p_mem, &
1487 start=(/1, 1,
kper/), &
1488 count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1495 call nf_verify(nf90_redef(ncid), nc_fname)
1496 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1497 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1501 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1503 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1506 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1507 (/nf90_fill_int/)), nc_fname)
1508 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1509 idt%longname), nc_fname)
1512 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1517 call nf_verify(nf90_enddef(ncid), nc_fname)
1518 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1519 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1524 var_ids%export, p_mem, &
1525 start=(/1, 1, 1,
kper/), &
1526 count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1535 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1536 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1537 integer(I4B),
dimension(:, :),
pointer,
contiguous,
intent(in) :: p_mem
1538 integer(I4B),
intent(in) :: ncid
1541 type(
distype),
pointer,
intent(in) :: dis
1543 character(len=*),
intent(in) :: mempath
1544 character(len=*),
intent(in) :: nc_tag
1545 character(len=*),
intent(in) :: pkgname
1546 character(len=*),
intent(in) :: gridmap_name
1547 logical(LGP),
intent(in) :: latlon
1548 integer(I4B),
intent(in) :: deflate
1549 integer(I4B),
intent(in) :: shuffle
1550 integer(I4B),
intent(in) :: chunk_z
1551 integer(I4B),
intent(in) :: chunk_y
1552 integer(I4B),
intent(in) :: chunk_x
1553 character(len=*),
intent(in) :: nc_fname
1554 character(len=LINELENGTH) :: varname
1555 integer(I4B) :: var_id
1560 call nf_verify(nf90_redef(ncid), nc_fname)
1561 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1562 (/dim_ids%x, dim_ids%y/), var_id), &
1566 call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1568 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1571 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1572 (/nf90_fill_int/)), nc_fname)
1573 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1574 idt%longname), nc_fname)
1577 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .false., &
1582 call nf_verify(nf90_enddef(ncid), nc_fname)
1583 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1584 count=(/dis%ncol, dis%nrow/)), &
1591 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1592 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1593 integer(I4B),
dimension(:, :, :),
pointer,
contiguous,
intent(in) :: p_mem
1594 integer(I4B),
intent(in) :: ncid
1597 type(
distype),
pointer,
intent(in) :: dis
1599 character(len=*),
intent(in) :: mempath
1600 character(len=*),
intent(in) :: nc_tag
1601 character(len=*),
intent(in) :: pkgname
1602 character(len=*),
intent(in) :: gridmap_name
1603 logical(LGP),
intent(in) :: latlon
1604 integer(I4B),
intent(in) :: deflate
1605 integer(I4B),
intent(in) :: shuffle
1606 integer(I4B),
intent(in) :: chunk_z
1607 integer(I4B),
intent(in) :: chunk_y
1608 integer(I4B),
intent(in) :: chunk_x
1609 character(len=*),
intent(in) :: nc_fname
1610 character(len=LINELENGTH) :: varname
1611 integer(I4B) :: var_id
1616 call nf_verify(nf90_redef(ncid), nc_fname)
1617 call nf_verify(nf90_def_var(ncid, varname, nf90_int, &
1618 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1622 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1624 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1627 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1628 (/nf90_fill_int/)), nc_fname)
1629 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1630 idt%longname), nc_fname)
1633 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1638 call nf_verify(nf90_enddef(ncid), nc_fname)
1639 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1640 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1647 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1648 shuffle, chunk_z, chunk_y, chunk_x, iper, iaux, &
1651 real(DP),
dimension(:),
pointer,
contiguous,
intent(in) :: p_mem
1652 integer(I4B),
intent(in) :: ncid
1655 type(
distype),
pointer,
intent(in) :: dis
1657 character(len=*),
intent(in) :: mempath
1658 character(len=*),
intent(in) :: nc_tag
1659 character(len=*),
intent(in) :: pkgname
1660 character(len=*),
intent(in) :: gridmap_name
1661 logical(LGP),
intent(in) :: latlon
1662 integer(I4B),
intent(in) :: deflate
1663 integer(I4B),
intent(in) :: shuffle
1664 integer(I4B),
intent(in) :: chunk_z
1665 integer(I4B),
intent(in) :: chunk_y
1666 integer(I4B),
intent(in) :: chunk_x
1667 integer(I4B),
intent(in) :: iper
1668 integer(I4B),
intent(in) :: iaux
1669 character(len=*),
intent(in) :: nc_fname
1670 integer(I4B) :: var_id, axis_sz
1671 character(len=LINELENGTH) :: varname, longname
1673 if (idt%shape ==
'NROW' .or. &
1674 idt%shape ==
'NCOL' .or. &
1675 idt%shape ==
'NCPL' .or. &
1676 idt%shape ==
'NAUX NCPL')
then
1679 select case (idt%shape)
1687 longname =
export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1689 component_type=idt%component_type, &
1690 subcomponent_type=idt%subcomponent_type)
1693 call nf_verify(nf90_redef(ncid), nc_fname)
1694 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1695 (/axis_sz/), var_id), &
1699 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1702 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1703 (/nf90_fill_double/)), nc_fname)
1704 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1705 longname), nc_fname)
1711 call nf_verify(nf90_enddef(ncid), nc_fname)
1712 call nf_verify(nf90_put_var(ncid, var_id, p_mem), &
1717 var_ids%export, p_mem, &
1718 start=(/1, 1,
kper/), &
1719 count=(/dis%ncol, dis%nrow, 1/)), nc_fname)
1725 varname =
export_varname(pkgname, idt%tagname, mempath, iaux=iaux)
1726 longname =
export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1728 component_type=idt%component_type, &
1729 subcomponent_type=idt%subcomponent_type)
1732 call nf_verify(nf90_redef(ncid), nc_fname)
1733 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1734 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1738 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1740 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1743 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1744 (/nf90_fill_double/)), nc_fname)
1745 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1746 longname), nc_fname)
1749 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1754 call nf_verify(nf90_enddef(ncid), nc_fname)
1755 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1756 count=(/dis%ncol, dis%nrow, dis%nlay/)), &
1761 var_ids%export, p_mem, &
1762 start=(/1, 1, 1,
kper/), &
1763 count=(/dis%ncol, dis%nrow, dis%nlay, 1/)), &
1772 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1773 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1774 real(DP),
dimension(:, :),
pointer,
contiguous,
intent(in) :: p_mem
1775 integer(I4B),
intent(in) :: ncid
1778 type(
distype),
pointer,
intent(in) :: dis
1780 character(len=*),
intent(in) :: mempath
1781 character(len=*),
intent(in) :: nc_tag
1782 character(len=*),
intent(in) :: pkgname
1783 character(len=*),
intent(in) :: gridmap_name
1784 logical(LGP),
intent(in) :: latlon
1785 integer(I4B),
intent(in) :: deflate
1786 integer(I4B),
intent(in) :: shuffle
1787 integer(I4B),
intent(in) :: chunk_z
1788 integer(I4B),
intent(in) :: chunk_y
1789 integer(I4B),
intent(in) :: chunk_x
1790 character(len=*),
intent(in) :: nc_fname
1791 character(len=LINELENGTH) :: varname
1792 integer(I4B) :: var_id
1797 call nf_verify(nf90_redef(ncid), nc_fname)
1798 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1799 (/dim_ids%x, dim_ids%y/), var_id), &
1803 call ncvar_chunk2d(ncid, var_id, chunk_x, chunk_y, nc_fname)
1805 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1808 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1809 (/nf90_fill_double/)), nc_fname)
1810 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1811 idt%longname), nc_fname)
1814 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .false., &
1819 call nf_verify(nf90_enddef(ncid), nc_fname)
1820 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1/), &
1821 count=(/dis%ncol, dis%nrow/)), &
1828 nc_tag, pkgname, gridmap_name, latlon, deflate, &
1829 shuffle, chunk_z, chunk_y, chunk_x, nc_fname)
1830 real(DP),
dimension(:, :, :),
pointer,
contiguous,
intent(in) :: p_mem
1831 integer(I4B),
intent(in) :: ncid
1834 type(
distype),
pointer,
intent(in) :: dis
1836 character(len=*),
intent(in) :: mempath
1837 character(len=*),
intent(in) :: nc_tag
1838 character(len=*),
intent(in) :: pkgname
1839 character(len=*),
intent(in) :: gridmap_name
1840 logical(LGP),
intent(in) :: latlon
1841 integer(I4B),
intent(in) :: deflate
1842 integer(I4B),
intent(in) :: shuffle
1843 integer(I4B),
intent(in) :: chunk_z
1844 integer(I4B),
intent(in) :: chunk_y
1845 integer(I4B),
intent(in) :: chunk_x
1846 character(len=*),
intent(in) :: nc_fname
1847 integer(I4B) :: var_id
1848 character(len=LINELENGTH) :: varname, longname
1851 longname =
export_longname(idt%longname, pkgname, idt%tagname, mempath, &
1852 component_type=idt%component_type, &
1853 subcomponent_type=idt%subcomponent_type)
1856 call nf_verify(nf90_redef(ncid), nc_fname)
1857 call nf_verify(nf90_def_var(ncid, varname, nf90_double, &
1858 (/dim_ids%x, dim_ids%y, dim_ids%layer/), &
1862 call ncvar_chunk3d(ncid, var_id, chunk_x, chunk_y, chunk_z, nc_fname)
1864 call ncvar_deflate(ncid, var_id, deflate, shuffle, nc_fname)
1867 call nf_verify(nf90_put_att(ncid, var_id,
'_FillValue', &
1868 (/nf90_fill_double/)), nc_fname)
1869 call nf_verify(nf90_put_att(ncid, var_id,
'long_name', &
1870 longname), nc_fname)
1873 call ncvar_gridmap(ncid, var_id, gridmap_name, latlon, .true., &
1878 call nf_verify(nf90_enddef(ncid), nc_fname)
1879 call nf_verify(nf90_put_var(ncid, var_id, p_mem, start=(/1, 1, 1/), &
1880 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
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), 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