diff --git a/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 b/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 index d1daa0105b04df67d0c5bd707c22c230c1836cd1..aa479c9ef6df4a9d8f1b92dd64719e11eecc6445 100644 --- a/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 +++ b/src/LIB/SURCOUCHE/src/mode_io_tools_nc4.f90 @@ -349,8 +349,8 @@ if ( tpfile%ctype == 'MNHDIACHRONIC' ) then if ( .not. lbu_kcp ) call IO_Add_dim_nc4( tpfile, NMNHDIM_BUDGET_CART_LEVEL_W, 'cart_level_w', nbukmax ) if ( nbutotwrite > 0 ) call IO_Add_dim_nc4( tpfile, NMNHDIM_BUDGET_TIME, 'time_budget', nbutotwrite ) else if ( cbutype == 'MASK' ) then - if ( nbukmax > 0 ) call IO_Add_dim_nc4( tpfile, NMNHDIM_BUDGET_MASK_LEVEL, 'mask_level', nbukmax ) - if ( nbukmax > 0 ) call IO_Add_dim_nc4( tpfile, NMNHDIM_BUDGET_MASK_LEVEL_W, 'mask_level_w', nbukmax ) + if ( .not. lbu_kcp ) call IO_Add_dim_nc4( tpfile, NMNHDIM_BUDGET_MASK_LEVEL, 'mask_level', nbukmax ) + if ( .not. lbu_kcp ) call IO_Add_dim_nc4( tpfile, NMNHDIM_BUDGET_MASK_LEVEL_W, 'mask_level_w', nbukmax ) if ( nbutotwrite > 0 ) call IO_Add_dim_nc4( tpfile, NMNHDIM_BUDGET_TIME, 'time_budget', nbutotwrite ) if ( nbumask > 0 ) call IO_Add_dim_nc4( tpfile, NMNHDIM_BUDGET_MASK_NBUMASK, 'nbumask', nbumask ) end if diff --git a/src/MNH/write_budget.f90 b/src/MNH/write_budget.f90 index a50d7435f1376462b047f2face9c896b429a46ab..553d535359844cb673ef2acb1a6c775a254552ac 100644 --- a/src/MNH/write_budget.f90 +++ b/src/MNH/write_budget.f90 @@ -529,12 +529,17 @@ subroutine Store_one_budget_rho( tpdiafile, tpdates, tprhodj, kp, knocompress, p else if ( ybutype == 'MASK' ) then tzfield%ndimlist(1) = NMNHDIM_UNUSED tzfield%ndimlist(2) = NMNHDIM_UNUSED - select case ( tzfield%ngrid ) - case ( 1, 2, 3 ) - tzfield%ndimlist(3) = NMNHDIM_BUDGET_MASK_LEVEL - case ( 4 ) - tzfield%ndimlist(3) = NMNHDIM_BUDGET_MASK_LEVEL_W - end select + if ( .not. lbu_kcp ) then + select case ( tzfield%ngrid ) + case ( 1, 2, 3 ) + tzfield%ndimlist(3) = NMNHDIM_BUDGET_MASK_LEVEL + case ( 4 ) + tzfield%ndimlist(3) = NMNHDIM_BUDGET_MASK_LEVEL_W + end select + else + tzfield%ndims = tzfield%ndims - 1 + tzfield%ndimlist(3) = NMNHDIM_UNUSED + end if tzfield%ndimlist(4) = NMNHDIM_BUDGET_TIME tzfield%ndimlist(5) = NMNHDIM_BUDGET_MASK_NBUMASK tzfield%ndimlist(6) = NMNHDIM_UNUSED @@ -755,12 +760,17 @@ subroutine Store_one_budget( tpdiafile, tpdates, tpbudget, prhodjn, knocompress, else if ( ybutype == 'MASK' ) then tzfields(jproc)%ndimlist(1) = NMNHDIM_UNUSED tzfields(jproc)%ndimlist(2) = NMNHDIM_UNUSED - select case ( tzfields(jproc)%ngrid ) - case ( 1, 2, 3 ) - tzfields(jproc)%ndimlist(3) = NMNHDIM_BUDGET_MASK_LEVEL - case ( 4 ) - tzfields(jproc)%ndimlist(3) = NMNHDIM_BUDGET_MASK_LEVEL_W - end select + if ( .not. lbu_kcp ) then + select case ( tzfields(jproc)%ngrid ) + case ( 1, 2, 3 ) + tzfields(jproc)%ndimlist(3) = NMNHDIM_BUDGET_MASK_LEVEL + case ( 4 ) + tzfields(jproc)%ndimlist(3) = NMNHDIM_BUDGET_MASK_LEVEL_W + end select + else + tzfields(jproc)%ndims = tzfields(jproc)%ndims - 1 + tzfields(jproc)%ndimlist(3) = NMNHDIM_UNUSED + end if tzfields(jproc)%ndimlist(4) = NMNHDIM_BUDGET_TIME tzfields(jproc)%ndimlist(5) = NMNHDIM_BUDGET_MASK_NBUMASK tzfields(jproc)%ndimlist(6) = NMNHDIM_BUDGET_NGROUPS diff --git a/src/MNH/write_diachro.f90 b/src/MNH/write_diachro.f90 index d33e532e96b039f2724faab550e1209767a90820..819e593462ea1bb65ce856ebbce17c87d911b14e 100644 --- a/src/MNH/write_diachro.f90 +++ b/src/MNH/write_diachro.f90 @@ -1373,6 +1373,40 @@ select case ( idims ) deallocate( zdata1d ) + else if ( tpfields(1)%ndimlist(4) == NMNHDIM_BUDGET_TIME .and. tpfields(1)%ndimlist(5) == NMNHDIM_BUDGET_MASK_NBUMASK ) then + if ( Size( tpfields ) /= 1 ) call Print_msg( NVERB_FATAL, 'IO', 'Write_diachro_nc4', & + 'wrong size of tpfields (variable '//trim(tpfields(1)%cmnhname)//')' ) + + tzfield%ndimlist(1) = tpfields(1)%ndimlist(4) + tzfield%ndimlist(2) = tpfields(1)%ndimlist(5) + tzfield%ndimlist(3:) = NMNHDIM_UNUSED + + Allocate( zdata2d(Size( pvar, 4 ), Size( pvar, 5 )) ) + + zdata2d(:,:) = pvar(1, 1, 1, :, :, 1) + + tzfield%cmnhname = tpfields(1)%cmnhname + tzfield%cstdname = tpfields(1)%cstdname + tzfield%clongname = tpfields(1)%clongname + tzfield%cunits = tpfields(1)%cunits + tzfield%cdir = '--' + tzfield%ccomment = tpfields(1)%ccomment + tzfield%ngrid = tpfields(1)%ngrid + tzfield%ntype = tpfields(1)%ntype + tzfield%ndims = 2 + tzfield%ltimedep = .false. + + if ( gsplit ) then + !Create the metadata of the field (has to be done only once) + if ( nbutshift == 1 ) call IO_Field_create( tzfile, tzfield ) + + call IO_Field_write( tzfile, tzfield, zdata2d, koffset= [ ( nbutshift - 1 ) * nbusubwrite, 0 ] ) + else + call IO_Field_write( tzfile, tzfield, zdata2d ) + end if + + Deallocate( zdata2d ) + else if ( ( tpfields(1)%ndimlist(4) == NMNHDIM_BUDGET_LES_TIME & .or. tpfields(1)%ndimlist(4) == NMNHDIM_BUDGET_LES_AVG_TIME ) & .and. tpfields(1)%ndimlist(5) == NMNHDIM_BUDGET_LES_SV ) then @@ -2060,6 +2094,43 @@ select case ( idims ) end do deallocate( zdata2d ) + + else if ( tpfields(1)%ndimlist(4) == NMNHDIM_BUDGET_TIME & + .and. tpfields(1)%ndimlist(5) == NMNHDIM_BUDGET_MASK_NBUMASK & + .and. tpfields(1)%ndimlist(6) == NMNHDIM_BUDGET_NGROUPS ) then + tzfield%ndimlist(1) = tpfields(1)%ndimlist(4) + tzfield%ndimlist(2) = tpfields(1)%ndimlist(5) + tzfield%ndimlist(3:) = NMNHDIM_UNUSED + + Allocate( zdata2d(Size( pvar, 4 ), Size( pvar, 5 )) ) + + ! Loop on the processes (1 written variable per process) + do ji = 1, Size( pvar, 6 ) + zdata2d(:,:) = pvar(1, 1, 1, :, :, ji) + + tzfield%cmnhname = tpfields(ji)%cmnhname + tzfield%cstdname = tpfields(ji)%cstdname + tzfield%clongname = tpfields(ji)%clongname + tzfield%cunits = tpfields(ji)%cunits + tzfield%cdir = '--' + tzfield%ccomment = tpfields(ji)%ccomment + tzfield%ngrid = tpfields(ji)%ngrid + tzfield%ntype = tpfields(ji)%ntype + tzfield%ndims = 2 + tzfield%ltimedep = .false. + + if ( gsplit ) then + !Create the metadata of the field (has to be done only once) + if ( nbutshift == 1 ) call IO_Field_create( tzfile, tzfield ) + + call IO_Field_write( tzfile, tzfield, zdata2d, koffset= [ ( nbutshift - 1 ) * nbusubwrite, 0 ] ) + else + call IO_Field_write( tzfile, tzfield, zdata2d ) + end if + end do + + Deallocate( zdata2d ) + else call Print_msg( NVERB_FATAL, 'IO', 'Write_diachro_nc4', & 'case not yet implemented (variable '//trim(tpfields(1)%cmnhname)//')' )