@@ -281,7 +281,7 @@ subroutine export_input_array(this, pkgtype, pkgname, mempath, idt)
281
281
iaux = 0
282
282
283
283
! set variable name and input attribute string
284
- nc_varname = export_varname(pkgname, idt)
284
+ nc_varname = export_varname(pkgname, idt% mf6varname )
285
285
input_attr = this% input_attribute(pkgname, idt)
286
286
287
287
select case (idt% datatype)
@@ -411,8 +411,8 @@ subroutine package_step_ilayer(this, export_pkg, ilayer_varname, ilayer)
411
411
' PERIOD' , export_pkg% param_names(iparam), &
412
412
this% nc_fname)
413
413
! set variable name and input attrs
414
- nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, idt, &
415
- iper= kper)
414
+ nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, &
415
+ idt % mf6varname, iper= kper)
416
416
input_attr = this% input_attribute(export_pkg% mf6_input% subcomponent_name, &
417
417
idt)
418
418
! export arrays
@@ -457,13 +457,19 @@ subroutine package_step(this, export_pkg)
457
457
use TdisModule, only: kper
458
458
use NCModelExportModule, only: ExportPackageType
459
459
use DefinitionSelectModule, only: get_param_definition_type
460
+ use ConstantsModule, only: DNODATA, LENAUXNAME
460
461
class(DisNCStructuredType), intent (inout ) :: this
461
462
class(ExportPackageType), pointer , intent (in ) :: export_pkg
462
463
integer (I4B), dimension (:), pointer , contiguous :: int1d
463
464
real (DP), dimension (:), pointer , contiguous :: dbl1d
465
+ real (DP), dimension (:, :), pointer , contiguous :: dbl2d
466
+ real (DP), dimension (:, :, :), pointer , contiguous :: dbl3d
464
467
type (InputParamDefinitionType), pointer :: idt
465
468
character (len= LINELENGTH) :: nc_varname, input_attr
466
- integer (I4B) :: iparam
469
+ character (len= LENAUXNAME) :: aux
470
+ type (CharacterStringType), dimension (:), pointer , &
471
+ contiguous :: auxname_cst
472
+ integer (I4B) :: iparam, n
467
473
468
474
do iparam = 1 , export_pkg% nparam
469
475
! set input definition
@@ -474,8 +480,8 @@ subroutine package_step(this, export_pkg)
474
480
this% nc_fname)
475
481
476
482
! set variable name and input attribute string
477
- nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, idt, &
478
- iper= kper)
483
+ nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, &
484
+ idt % mf6varname, iper= kper)
479
485
input_attr = this% input_attribute(export_pkg% mf6_input% subcomponent_name, &
480
486
idt)
481
487
@@ -501,6 +507,26 @@ subroutine package_step(this, export_pkg)
501
507
this% gridmap_name, this% latlon, this% deflate, &
502
508
this% shuffle, this% chunk_z, this% chunk_y, &
503
509
this% chunk_x, kper, this% nc_fname)
510
+ case (' DOUBLE2D' )
511
+ call mem_setptr(dbl2d, idt% mf6varname, export_pkg% mf6_input% mempath)
512
+ call mem_setptr(auxname_cst, ' AUXILIARY' , export_pkg% mf6_input% mempath)
513
+ do n = 1 , size (dbl2d, dim= 1 ) ! naux
514
+ ! reset varname to auxname
515
+ aux = auxname_cst(n)
516
+ nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, &
517
+ aux, iper= kper)
518
+
519
+ ! export the 1d array as a structured 3d array
520
+ dbl3d(1 :export_pkg% mshape(3 ), 1 :export_pkg% mshape(2 ), &
521
+ 1 :export_pkg% mshape(1 )) = > dbl2d(n, :)
522
+ call nc_export_array(this% ncid, this% dim_ids, this% var_ids, &
523
+ this% dis, dbl3d, nc_varname, &
524
+ export_pkg% mf6_input% subcomponent_name, &
525
+ aux, ' NCOL NROW NLAY' , idt% longname, input_attr, &
526
+ this% gridmap_name, this% latlon, this% deflate, &
527
+ this% shuffle, this% chunk_z, this% chunk_y, &
528
+ this% chunk_x, kper, n, this% nc_fname)
529
+ end do
504
530
case default
505
531
errmsg = ' EXPORT unsupported datatype=' // trim (idt% datatype)
506
532
call store_error(errmsg, .true. )
@@ -515,7 +541,7 @@ end subroutine package_step
515
541
! <
516
542
subroutine export_layer_3d (this , export_pkg , idt , ilayer_read , ialayer , &
517
543
dbl1d , nc_varname , input_attr , iaux )
518
- use ConstantsModule, only: DNODATA, DZERO
544
+ use ConstantsModule, only: DNODATA, DZERO, LENAUXNAME
519
545
use TdisModule, only: kper
520
546
use NCModelExportModule, only: ExportPackageType
521
547
class(DisNCStructuredType), intent (inout ) :: this
@@ -530,12 +556,17 @@ subroutine export_layer_3d(this, export_pkg, idt, ilayer_read, ialayer, &
530
556
real (DP), dimension (:, :, :), pointer , contiguous :: dbl3d
531
557
integer (I4B) :: n, i, j, k, nvals, idxaux
532
558
real (DP), dimension (:, :), contiguous, pointer :: dbl2d_ptr
559
+ character (len= LENAUXNAME) :: aux
560
+ type (CharacterStringType), dimension (:), pointer , &
561
+ contiguous :: auxname_cst
533
562
534
563
! initialize
535
564
idxaux = 0
536
565
if (present (iaux)) then
566
+ call mem_setptr(auxname_cst, ' AUXILIARY' , export_pkg% mf6_input% mempath)
567
+ aux = auxname_cst(iaux)
537
568
nc_varname = export_varname(export_pkg% mf6_input% subcomponent_name, &
538
- idt , iper= kper, iaux = iaux )
569
+ aux , iper= kper)
539
570
idxaux = iaux
540
571
end if
541
572
@@ -1454,27 +1485,21 @@ end subroutine nc_export_dbl3d
1454
1485
1455
1486
! > @brief build netcdf variable name
1456
1487
! <
1457
- function export_varname (pkgname , idt , iper , iaux ) result(varname )
1488
+ function export_varname (pkgname , varname , iper ) result(fullname )
1458
1489
use InputOutputModule, only: lowcase
1459
1490
character (len=* ), intent (in ) :: pkgname
1460
- type (InputParamDefinitionType ), pointer , intent (in ) :: idt
1491
+ character (len =* ), intent (in ) :: varname
1461
1492
integer (I4B), optional , intent (in ) :: iper
1462
- integer (I4B), optional , intent (in ) :: iaux
1463
- character (len= LINELENGTH) :: varname
1493
+ character (len= LINELENGTH) :: fullname
1464
1494
character (len= LINELENGTH) :: pname, vname
1465
1495
pname = pkgname
1466
- vname = idt % mf6varname
1496
+ vname = varname
1467
1497
call lowcase(pname)
1468
1498
call lowcase(vname)
1469
1499
if (present (iper)) then
1470
- if (present (iaux)) then
1471
- write (varname, ' (a,i0,a,i0)' ) trim (pname)// ' _' // trim (vname)// &
1472
- ' _p' , iper, ' a' , iaux
1473
- else
1474
- write (varname, ' (a,i0)' ) trim (pname)// ' _' // trim (vname)// ' _p' , iper
1475
- end if
1500
+ write (fullname, ' (a,i0)' ) trim (pname)// ' _' // trim (vname)// ' _p' , iper
1476
1501
else
1477
- varname = trim (pname)// ' _' // trim (vname)
1502
+ fullname = trim (pname)// ' _' // trim (vname)
1478
1503
end if
1479
1504
end function export_varname
1480
1505
0 commit comments