Newer
Older

WAUTELET Philippe
committed
!MNH_LIC Copyright 1994-2020 CNRS, Meteo-France and Universite Paul Sabatier
!MNH_LIC This is part of the Meso-NH software governed by the CeCILL-C licence

WAUTELET Philippe
committed
!MNH_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
!MNH_LIC for details. version 1.
!-----------------------------------------------------------------
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
! Modifications
! P. Wautelet 28/01/2020: new subroutines: Budget_store_init, Budget_store_end and Budget_source_id_find in new module mode_budget
!-----------------------------------------------------------------
!#################
module mode_budget
!#################
use modd_budget, only: cbutype, nbutime, tbudgetdata
use modi_cart_compress, only: Cart_compress
use modi_mask_compress, only: Mask_compress
use mode_msg
implicit none
private
public :: Budget_store_init
public :: Budget_store_end
contains
subroutine Budget_store_init( tpbudget, hsource, pvars )
type(tbudgetdata), intent(inout) :: tpbudget ! Budget datastructure
character(len=*), intent(in) :: hsource ! Name of the source term
real, dimension(:,:,:), intent(in) :: pvars ! Current value to be stored
integer :: iid ! Reference number of the current source term
call Print_msg( NVERB_DEBUG, 'BUD', 'Budget_store_init', trim( tpbudget%cname )//':'//trim( hsource ) )
call Budget_source_id_find( tpbudget, hsource, iid )
if ( tpbudget%ntmpstoresource /= 0 ) then
call Print_msg( NVERB_ERROR, 'BUD', 'Budget_store_init', 'ntmpstoresource already set (previous call to ' &
//'Budget_store_end missing?) for '//trim( tpbudget%cname )//':'//trim( hsource ) )
end if
if ( tpbudget%tsources(iid)%ldonotinit ) then
! If ldonotinit is set, this subroutine should not be called
call Print_msg( NVERB_ERROR, 'BUD', 'Budget_store_init', 'should not be called for ' &
//trim( tpbudget%cname )//':'//trim( hsource ) )
return
end if
if ( tpbudget%tsources(iid)%lenabled ) then
if ( tpbudget%ntmpstoresource /= 0 ) then
call Print_msg( NVERB_ERROR, 'BUD', 'Budget_store_init', 'xtmpstore already used by ' &
//trim( tpbudget%tsources(tpbudget%ntmpstoresource)%cmnhname ) )
return
end if
tpbudget%ntmpstoresource = iid
!Store data into the budget temporary array
!This value will be subtracted from the next one (in Budget_store_end) to get the evolution of the array between the 2 calls
if ( cbutype == 'CART' ) then
tpbudget%xtmpstore(:, :, : ) = Cart_compress( pvars(:, :, : ) )
else if ( cbutype == 'MASK' ) then
tpbudget%xtmpstore(:, nbutime, : ) = Mask_compress( pvars(:, :, : ) )
else
call Print_msg( NVERB_ERROR, 'BUD', 'Budget_store_init', 'unknown cbutype: '//trim( cbutype ) )
end if
end if
end subroutine Budget_store_init
subroutine Budget_store_end( tpbudget, hsource, pvars )
use modd_budget,only:nbusil,NBUSJL,NBUKL
type(tbudgetdata), intent(inout) :: tpbudget ! Budget datastructure
character(len=*), intent(in) :: hsource ! Name of the source term
real, dimension(:,:,:), intent(in) :: pvars ! Current value to be stored
integer :: iid ! Reference number of the current source term
integer :: igroup ! Number of the group where to store the source term
call Print_msg( NVERB_DEBUG, 'BUD', 'Budget_store_end', trim( tpbudget%cname )//':'//trim( hsource ) )
call Budget_source_id_find( tpbudget, hsource, iid )
if ( tpbudget%tsources(iid )%lenabled ) then
if ( iid /= tpbudget%ntmpstoresource .and. .not.tpbudget%tsources(iid )%ldonotinit ) then
if ( tpbudget%ntmpstoresource == 0 ) then
call Print_msg( NVERB_ERROR, 'BUD', 'Budget_store_end', 'ntmpstoresource not set for ' &
//trim( tpbudget%tsources(iid)%cmnhname ) )
else
call Print_msg( NVERB_ERROR, 'BUD', 'Budget_store_end', 'xtmpstore used by an other source: ' &
//trim( tpbudget%tsources(tpbudget%ntmpstoresource)%cmnhname )//', expected: ' &
//trim( tpbudget%tsources(iid)%cmnhname ) )
end if
end if
!Store data into the budget array
!The values are computed by the difference between the values stored in the temporary array (filled in Budget_store_init)
!and the current values added to the already stored ones.
!Except if ldonotinit is true. In that case, overwrite the array.
igroup = tpbudget%tsources(iid)%ngroup
if ( cbutype == 'CART' ) then
if ( tpbudget%tsources(iid )%ldonotinit ) then
if ( tpbudget%tsources(iid )%loverwrite ) then
tpbudget%tgroups(igroup )%xdata(:, :, : ) = Cart_compress( pvars(:, :, : ) )
else
tpbudget%tgroups(igroup )%xdata(:, :, : ) = tpbudget%tgroups(igroup )%xdata(:, :, : ) &
+ Cart_compress( pvars(:, :, : ) )
end if
else
if ( tpbudget%tsources(iid )%loverwrite ) then
tpbudget%tgroups(igroup )%xdata(:, :, : ) = Cart_compress( pvars(:, :, : ) ) &
- tpbudget%xtmpstore(:, :, : )
else
tpbudget%tgroups(igroup )%xdata(:, :, : ) = tpbudget%tgroups(igroup )%xdata(:, :, : ) &
+ Cart_compress( pvars(:, :, : ) ) &
- tpbudget%xtmpstore(:, :, : )
end if
end if
else if ( cbutype == 'MASK' ) then
if ( tpbudget%tsources(iid )%ldonotinit ) then
if ( tpbudget%tsources(iid )%loverwrite ) then
tpbudget%tgroups(igroup )%xdata(:, nbutime, : ) = Mask_compress( pvars(:, :, : ) )
else
tpbudget%tgroups(igroup )%xdata(:, nbutime, : ) = tpbudget%tgroups(igroup )%xdata(:, nbutime, : ) &
+ Mask_compress( pvars(:, :, : ) )
end if
else
if ( tpbudget%tsources(iid )%loverwrite ) then
tpbudget%tgroups(igroup )%xdata(:, nbutime, : ) = Mask_compress( pvars(:, :, : ) ) &
- tpbudget%xtmpstore(:, nbutime, : )
else
tpbudget%tgroups(igroup )%xdata(:, nbutime, : ) = tpbudget%tgroups(igroup )%xdata(:, nbutime, : ) &
+ Mask_compress( pvars(:, :, : ) ) &
- tpbudget%xtmpstore(:, nbutime, : )
end if
end if
else
call Print_msg( NVERB_ERROR, 'BUD', 'Budget_store_end', 'unknown cbutype: '//trim( cbutype ) )
end if
! Release the budget temporary array
tpbudget%ntmpstoresource = 0
end if
end subroutine Budget_store_end
subroutine Budget_source_id_find( tpbudget, hsource, kid )
type(tbudgetdata), intent(in) :: tpbudget ! Budget datastructure
character(len=*), intent(in) :: hsource ! Name of the source term
integer, intent(out) :: kid ! Reference number of the current source term
integer :: iid
integer :: ji
call Print_msg( NVERB_DEBUG, 'BUD', 'Budget_source_id_find', trim( tpbudget%cname )//':'//trim( hsource ) )
iid = 0
do ji = 1, tpbudget%nsources
if ( trim( hsource ) == trim( tpbudget%tsources(ji)%cmnhname ) ) then
iid = ji
exit
end if
end do
if ( iid > 0 ) then
call Print_msg( NVERB_DEBUG, 'BUD', 'Budget_source_id_find', trim( tpbudget%cname )//':'//trim( hsource )//' found' )
else
call Print_msg( NVERB_ERROR, 'BUD', 'Budget_source_id_find', trim( tpbudget%cname )//':'//trim( hsource )//' not found' )
end if
kid = iid
end subroutine Budget_source_id_find
end module mode_budget
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
!##################
MODULE MODI_BUDGET
!##################
!
INTERFACE
!
SUBROUTINE BUDGET(PVARS,KBUDN,HBUVAR)
!
!
REAL, DIMENSION(:,:,:), INTENT(IN) :: PVARS ! Source
INTEGER , INTENT(IN) :: KBUDN ! variable number
CHARACTER (LEN=*) , INTENT(IN) :: HBUVAR ! Identifier of the Budget of the
! variable that is considered
!
END SUBROUTINE BUDGET
!
END INTERFACE
!
END MODULE MODI_BUDGET
! #####################################
SUBROUTINE BUDGET(PVARS,KBUDN,HBUVAR)
! #####################################
!
!!**** *BUDGET* - routine to call the BUDGET routine.
!!
!!
!! PURPOSE
!! -------
! This routine selects the variable RVAR, the budget of which is
! processed in the inner routine BUDGET_CASE. !
!!** METHOD
!! ------
!!
!!
!!
!! EXTERNAL
!! --------
!! CART_COMPRESS
!! MASK_COMPRESS
!!
!! IMPLICIT ARGUMENTS
!! ------------------
!! Module MODD_BUDGET
!! XBURU : budget array of the variable RU
!! XBURV : budget array of the variable RV
!! XBURW : budget array of the variable RW
!! XBURTH : budget array of the variable RTH
!! XBURTKE : budget array of the variable RTKE
!! XBURRV : budget array of the variable RRV
!! XBURRC : budget array of the variable RRC
!! XBURRR : budget array of the variable RRR
!! XBURRI : budget array of the variable RRI
!! XBURRS : budget array of the variable RRS
!! XBURRG : budget array of the variable RRG
!! XBURRH : budget array of the variable RRH
!! XBURTKE : budget array of the variable RTKE
!! XBURSV(x) : budget array of the variable RSVx
!!
!! REFERENCE
!! ---------
!! None
!!
!! AUTHOR
!! ------
!! J. Nicolau * Meteo France *
!!
!! MODIFICATIONS
!! -------------
!! Original 30/08/94
!! J. Stein 26/06/96 add the 'OF','NO' option
!! J.-P. Pinty 12/12/96 simplifies the coding
!! V. Masson 06/10/02 add LES budgets
!! J.Escobar : 15/09/2015 : WENO5 & JPHEXT <> 1
!! Philippe Wautelet: 05/2016-04/2018: new data structures and calls for I/O

Juan Escobar
committed
!! J.Escobar : 09/07/2019 : for bit reproductiblity use MPPDB_CHECK with PRECISION=0.0 error
!!
!-------------------------------------------------------------------------------
!
!* 0. DECLARATIONS
! ------------
!
USE MODD_BUDGET
USE MODD_LUNIT
!USE MODD_CONF_n
USE MODD_CONF, ONLY : LCHECK
USE MODD_NSV, ONLY : NSV
!
USE MODI_LES_BUDGET
USE MODI_CART_COMPRESS
USE MODI_MASK_COMPRESS
!
USE MODI_SECOND_MNH
!
IMPLICIT NONE
!
!
!* 0.1 Declarations of arguments :
!
INTEGER , INTENT(IN) :: KBUDN ! variable number
REAL, DIMENSION(:,:,:), INTENT(IN) :: PVARS ! source of the variable
CHARACTER (LEN=*) , INTENT(IN) :: HBUVAR ! Identifier of the Budget of the
! variable that is considered
INTEGER :: IBUSV ! Index of the SV
!
INTEGER :: ILUOUT0 ! Logical unit number for output-listing
INTEGER :: IRESP ! Return code of FM-routines
!
REAL :: ZTIME1 ! CPU time counter
REAL :: ZTIME2 ! CPU time counter
!
!-------------------------------------------------------------------------------
!

WAUTELET Philippe
committed
call Print_msg( NVERB_DEBUG, 'BUD', 'Budget', 'called for '//trim( hbuvar ) )
!* Reproductivity checks
! Warning: requires an adaptation of the makefile in order to run two runs in
! parallel for comparison
!
IF (LCHECK) THEN
print*,'BUDGET :',HBUVAR

Juan Escobar
committed
CALL MPPDB_CHECK3D(PVARS,HBUVAR,PRECISION)
!* call to LES budgets
!
IF (LLES_CALL) CALL LES_BUDGET(PVARS,KBUDN,HBUVAR)
!
!* call to prognostic variables budgets
!
IF (.NOT. LBU_ENABLE) RETURN
!
SELECT CASE (KBUDN)

WAUTELET Philippe
committed
CASE ( NBUDGET_U )

WAUTELET Philippe
committed
CASE ( NBUDGET_V )

WAUTELET Philippe
committed
CASE ( NBUDGET_W )
IF (.NOT. LBU_RW) RETURN
CASE (NBUDGET_TH)

WAUTELET Philippe
committed
CASE ( NBUDGET_TKE )

WAUTELET Philippe
committed
CASE ( NBUDGET_RV )

WAUTELET Philippe
committed
CASE ( NBUDGET_RC )

WAUTELET Philippe
committed
CASE (NBUDGET_RR )

WAUTELET Philippe
committed
CASE ( NBUDGET_RI )

WAUTELET Philippe
committed
CASE ( NBUDGET_RS )

WAUTELET Philippe
committed
CASE ( NBUDGET_RG )

WAUTELET Philippe
committed
CASE ( NBUDGET_RH )

WAUTELET Philippe
committed
CASE ( NBUDGET_SV1 : )
IF (.NOT. LBU_RSV) RETURN
END SELECT
!
!-------------------------------------------------------------------------------
!
CALL SECOND_MNH(ZTIME1)
!
SELECT CASE (KBUDN)
!

WAUTELET Philippe
committed
CASE ( NBUDGET_U ) ! ==> RU BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_V ) ! ==> RV BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_W ) ! ==> RW BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_TH ) ! ==> RTH BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_TKE ) ! ==> RTKE BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_RV ) ! ==> RRV BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_RC ) ! ==> RRC BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_RR ) ! ==> RRR BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_RI ) ! ==> RRI BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_RS ) ! ==> RRS BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_RG ) ! ==> RRG BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_RH ) ! ==> RRH BUDGET

WAUTELET Philippe
committed
CASE ( NBUDGET_SV1 : ) ! ==> RSVx BUDGET
IBUSV = KBUDN - ( NBUDGET_SV1 - 1 )
IF( IBUSV <= NSV ) THEN
CALL BUDGET_CASE(XBURSV(:,:,:,:,IBUSV))
ELSE
WRITE(UNIT=ILUOUT0,FMT='("BUDGET: SCALAR VARIABLE",I2," IS ABSENT !!")') &
IBUSV
WRITE(UNIT=ILUOUT0,FMT='("CHECK FOR THE CALL BUDGET OF THAT VARIABLE")')
!callabortstop

WAUTELET Philippe
committed
CALL PRINT_MSG(NVERB_FATAL,'BUD','BUDGET','')
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
END IF
END SELECT
!
CALL SECOND_MNH(ZTIME2)
!
XTIME_BU_PROCESS = XTIME_BU_PROCESS + ZTIME2 - ZTIME1
XTIME_BU = XTIME_BU + ZTIME2 - ZTIME1
!
!----------------------------------------------------------------------
CONTAINS
!----------------------------------------------------------------------
! ###############################
SUBROUTINE BUDGET_CASE(PBURVAR)
! ###############################
!
!!**** *BUDGET_CASE* - routine to call the BUDGET_CASE routine.
!!
!!
!! PURPOSE
!! -------
! This routine chooses the right call to the functions CART_COMPRESS
! or MASK_COMPRESS (which realize the compression of the source PVARS
! in the different directions) and achieves in function of HACTION (which
! determines the operations to be executed) the budget for the variable
! corresponding to the number KBUDN. The budget process counter is
! incremented by NBUINC depending on the number of active processes in the
! model.
!
!!** METHOD
!! ------
!!
!!
!!
!! EXTERNAL
!! --------
!! CART_COMPRESS
!! MASK_COMPRESS
!!
!! IMPLICIT ARGUMENTS
!! ------------------
!! Module MODD_BUDGET
!! CBUACTION : type of operation
!! CBUTYPE : budget type (CART,MASK or NONE)
!! NBUTIME : number of the budget step
!! NBUPROCCTR : process counter for each budget variable
!! PBURVAR : budget array of the variable RVAR
!!
!! REFERENCE
!! ---------
!! None
!!
!! AUTHOR
!! ------
!! J.-P. Pinty *Laboratoire d'Aerologie*
!!
!! MODIFICATIONS
!! -------------
!! Original 12/12/96
!! Modification 24/06/99 N. Asencio : budget // , the dimensions of the
!! budget arrays are implicit
!!
!-------------------------------------------------------------------------------
!
!* 0. DECLARATIONS
! ------------
!
USE MODI_CART_COMPRESS
USE MODI_MASK_COMPRESS
!
IMPLICIT NONE
!
!
!* 0.1 Declarations of arguments :
!
REAL, DIMENSION(:,:,:,:), INTENT(INOUT):: PBURVAR ! budget of variable RVAR
!
!* 0.2 Declarations of local variables :
CHARACTER (LEN=99) :: YBUVAR_ADJUSTED ! Adjusted string
CHARACTER (LEN=99) :: YBUCOMMENT_ADJUSTED ! Adjusted string
CHARACTER (LEN=99) :: YBUVAR ! local string
CHARACTER (LEN=99) :: YBUCOMMENT ! local string
INTEGER :: ILEN ! Number of non-blank char.
!
!
!* 1. SECURITY TEST
! -------------
!
YBUVAR = HBUVAR
YBUCOMMENT = CBUCOMMENT(KBUDN,NBUPROCCTR(KBUDN))
YBUVAR_ADJUSTED = ADJUSTR(YBUVAR)
YBUCOMMENT_ADJUSTED = ADJUSTR(YBUCOMMENT)
ILEN = LEN_TRIM( ADJUSTL(YBUVAR))
!
IF( CBUACTION(KBUDN,NBUCTR_ACTV(KBUDN))/='NO'.AND. &
CBUACTION(KBUDN,NBUCTR_ACTV(KBUDN))/='OF'.AND. &
CBUACTION(KBUDN,NBUCTR_ACTV(KBUDN))/='CC' ) THEN
IF( YBUVAR_ADJUSTED(100-ILEN:99) /= YBUCOMMENT_ADJUSTED(100-ILEN:99) &
.OR. ILEN==0 ) THEN
WRITE(UNIT=ILUOUT0,FMT='("BUDGET: WRONG BUDGET IDENTIFICATION !!")')
WRITE(UNIT=ILUOUT0,FMT='("BUDGET: PRESENT VARIABLE: ",I2)') KBUDN
WRITE(UNIT=ILUOUT0,FMT='("BUDGET: PRESENT IDENTIFIER: ",A99)') &
YBUVAR_ADJUSTED
WRITE(UNIT=ILUOUT0,FMT='("BUDGET: EXPECTED IDENTIFIER: ",A99)') &
YBUCOMMENT_ADJUSTED
WRITE(UNIT=ILUOUT0,FMT='("PLEASE CHECK THE CALL BUDGET OF THE VARIABLE")')
WRITE(UNIT=ILUOUT0,FMT='("AND THE BUDGET PROCESS ORDER IN INI_BUDGET !")')
!callabortstop

WAUTELET Philippe
committed
CALL PRINT_MSG(NVERB_FATAL,'BUD','BUDGET','')
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
END IF
END IF
!
! Budget integration in case of successful test
!
SELECT CASE (CBUTYPE)
!
!* 2. "CART" CASE
! -----------
!
CASE ('CART')
!
SELECT CASE (CBUACTION(KBUDN,NBUCTR_ACTV(KBUDN)))
!
!* 2.1 Budget beginning : initial fields
! filled in budget tabulars (NBUPROCCTR=1)
!
CASE('IG')
PBURVAR(:,:,:,1)=CART_COMPRESS(PVARS)
!
!* 2.2 average tendancy filled every time
! step in budget tabulars (NBUPROCCTR=3)
!
CASE('ES')
PBURVAR(:,:,:,3)=PBURVAR(:,:,:,3)+CART_COMPRESS(PVARS)/NBUSTEP
!
!* 2.3 Cumul of the sources
!
CASE('CC')
PBURVAR(:,:,:,2)=CART_COMPRESS(PVARS)
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
!
!* 2.4 Difference in order to compute the budget
! for the process NBUPROCCTR
!
CASE('DD')
PBURVAR(:,:,:,NBUPROCCTR(KBUDN))= PBURVAR(:,:,:,NBUPROCCTR(KBUDN)) &
+ CART_COMPRESS(PVARS) &
- PBURVAR(:,:,:,2)
NBUPROCCTR(KBUDN)=NBUPROCCTR(KBUDN)+1
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
!
!* 2.5 Difference in order to compute the budget for the
! process NBUPROCCTR and Cumul of the sources (NBUPROCCTR=2)
!
CASE('DC')
PBURVAR(:,:,:,NBUPROCCTR(KBUDN)) = PBURVAR(:,:,:,NBUPROCCTR(KBUDN))&
+ CART_COMPRESS(PVARS) &
- PBURVAR(:,:,:,2)
PBURVAR(:,:,:,2)=CART_COMPRESS(PVARS)
NBUPROCCTR(KBUDN)=NBUPROCCTR(KBUDN)+1
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
CASE('NO')
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
CASE('OF')
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
RETURN
END SELECT
!
!* 3. "MASK" CASE
! -----------
!
CASE ('MASK')
!
SELECT CASE (CBUACTION(KBUDN,NBUCTR_ACTV(KBUDN)))
!
!* 3.1 Budget beginning : initial fields
! filled in budget tabulars (NBUPROC=1)
!
CASE('IG')
PBURVAR(:,NBUTIME,:,1) = MASK_COMPRESS(PVARS)
!
!* 3.2 average tendancy filled every time
! step in budget tabulars (NBUPROCCTR=3)
!
CASE('ES')
PBURVAR(:,NBUTIME,:,3) = PBURVAR(:,NBUTIME,:,3) &
+ MASK_COMPRESS(PVARS)/NBUSTEP
!
!* 3.3 Cumul of the sources
!
CASE('CC')
PBURVAR(:,NBUTIME,:,2)=MASK_COMPRESS(PVARS)
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
!
!* 3.4 Difference in order to compute the budget
! for the process NBUPROCCTR
!
CASE('DD')
PBURVAR(:,NBUTIME,:,NBUPROCCTR(KBUDN)) &
= PBURVAR(:,NBUTIME,:,NBUPROCCTR(KBUDN)) &
+ MASK_COMPRESS(PVARS) &
- PBURVAR(:,NBUTIME,:,2)
NBUPROCCTR(KBUDN)=NBUPROCCTR(KBUDN)+1
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
!
!* 3.5 Difference in order to compute the budget for the
! process NBUPROCCTR and Cumul of the sources (NBUPROCCTR=2)
!
CASE('DC')
PBURVAR(:,NBUTIME,:,NBUPROCCTR(KBUDN)) &
= PBURVAR(:,NBUTIME,:,NBUPROCCTR(KBUDN)) &
+MASK_COMPRESS(PVARS) &
-PBURVAR(:,NBUTIME,:,2)
PBURVAR(:,NBUTIME,:,2)=MASK_COMPRESS(PVARS)
NBUPROCCTR(KBUDN)=NBUPROCCTR(KBUDN)+1
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
CASE('NO')
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
CASE('OF')
!
! advance the process counter
!
NBUCTR_ACTV(KBUDN) = NBUCTR_ACTV(KBUDN) &
+ NBUINC(KBUDN,NBUCTR_ACTV(KBUDN))
RETURN

WAUTELET Philippe
committed
END SELECT
END SELECT
!
END SUBROUTINE BUDGET_CASE
!
!-------------------------------------------------------------------------------
!
!
END SUBROUTINE BUDGET