New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
Changeset 15438 – NEMO

Changeset 15438


Ignore:
Timestamp:
2021-10-22T16:56:07+02:00 (10 months ago)
Author:
clem
Message:

4.0-HEAD: freshwater budget is now corrected for option nn_fwb=2. The option could be improved. There is a drift the 1st year and the correction applied can lead to oscillations in the solution. It is related to tickets #2718 and part of #2487 though the fix is somewhat different than proposed in the tickets.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • NEMO/releases/r4.0/r4.0-HEAD/src/OCE/SBC/sbcfwb.F90

    r14717 r15438  
    3535   PUBLIC   sbc_fwb    ! routine called by step 
    3636 
    37    REAL(wp) ::   a_fwb_b   ! annual domain averaged freshwater budget 
    38    REAL(wp) ::   a_fwb     ! for 2 year before (_b) and before year. 
    39    REAL(wp) ::   fwfold    ! fwfold to be suppressed 
     37   REAL(wp) ::   a_fwb     ! annual domain averaged freshwater budget from the previous year 
     38   REAL(wp) ::   a_fwb_b   ! annual domain averaged freshwater budget from the year before or at initial state 
     39   REAL(wp) ::   a_fwb_ini ! initial domain averaged freshwater budget 
    4040   REAL(wp) ::   area      ! global mean ocean surface (interior domain) 
    4141 
     
    117117         ENDIF 
    118118         ! 
    119       CASE ( 2 )                             !==  fwf budget adjusted from the previous year  ==! 
    120          ! 
    121          IF( kt == nit000 ) THEN                      ! initialisation 
    122             !                                         ! Read the corrective factor on precipitations (fwfold) 
    123             IF ( ln_rstart .AND. iom_varid( numror, 'a_fwb_b', ldstop = .FALSE. ) > 0     & 
     119      CASE ( 2 )                             !==  fw adjustment based on fw budget at the end of the previous year  ==! 
     120         !                                                simulation is supposed to start 1st of January 
     121         IF( kt == nit000 ) THEN                                                                 ! initialisation 
     122            !                                                                                    ! set the fw adjustment (a_fwb) 
     123            IF ( ln_rstart .AND. iom_varid( numror, 'a_fwb_b', ldstop = .FALSE. ) > 0     &      !    as read from restart file 
    124124               &           .AND. iom_varid( numror, 'a_fwb',   ldstop = .FALSE. ) > 0 ) THEN 
    125                IF(lwp) WRITE(numout,*) 'sbc_fwb : reading FW-budget adjustment from restart file' 
     125               IF(lwp)   WRITE(numout,*) 'sbc_fwb : reading freshwater-budget from restart file' 
    126126               CALL iom_get( numror, 'a_fwb_b', a_fwb_b, ldxios = lrxios ) 
    127127               CALL iom_get( numror, 'a_fwb',   a_fwb,   ldxios = lrxios ) 
    128             ELSE 
     128               ! 
     129               a_fwb_ini = a_fwb_b 
     130            ELSE                                                                                 !    as read from EMPave_old.dat file 
     131               IF(lwp)   WRITE(numout,*) 'sbc_fwb : reading freshwater-budget from EMPave_old.dat file' 
    129132               CALL ctl_opn( inum, 'EMPave_old.dat', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. ) 
    130133               READ ( inum, "(24X,I8,2ES24.16)" ) iyear, a_fwb_b, a_fwb 
    131134               CLOSE( inum ) 
     135               ! 
     136               a_fwb_ini = glob_sum( 'sbcfwb', e1e2t(:,:) * ( sshn(:,:) + snwice_mass(:,:) * r1_rau0 ) ) & 
     137                  &      * rau0 / ( area * rday * REAL(nyear_len(1), wp) ) 
    132138            END IF 
    133             fwfold = a_fwb                            ! current year freshwater budget correction 
    134             !                                         ! estimate from the previous year budget 
    135             IF(lwp)WRITE(numout,*) 
    136             IF(lwp)WRITE(numout,*)'sbc_fwb : year = ',iyear  , ' freshwater budget correction = ', fwfold 
    137             IF(lwp)WRITE(numout,*)'          year = ',iyear-1, ' freshwater budget read       = ', a_fwb 
    138             IF(lwp)WRITE(numout,*)'          year = ',iyear-2, ' freshwater budget read       = ', a_fwb_b 
     139            ! 
     140            IF(lwp)   WRITE(numout,*) 
     141            IF(lwp)   WRITE(numout,*)'sbc_fwb : freshwater-budget at the end of previous year = ', a_fwb    , 'kg/m2/s' 
     142            IF(lwp)   WRITE(numout,*)'          freshwater-budget at initial state            = ', a_fwb_ini, 'kg/m2/s' 
    139143            ! 
    140144            IF( lwxios ) THEN                         ! Activate output of restart variables 
     
    142146               CALL iom_set_rstw_var_active( 'a_fwb'   ) 
    143147            END IF 
    144          ENDIF    
    145          !                                         ! Update fwfold if new year start 
    146          ikty = 365 * 86400 / rdt                  !!bug  use of 365 days leap year or 360d year !!!!!!! 
    147          IF( MOD( kt, ikty ) == 0 ) THEN 
    148             a_fwb_b = a_fwb                           ! mean sea level taking into account the ice+snow 
    149                                                       ! sum over the global domain 
    150             a_fwb   = glob_sum( 'sbcfwb', e1e2t(:,:) * ( sshn(:,:) + snwice_mass(:,:) * r1_rau0 ) ) 
    151             a_fwb   = a_fwb * 1.e+3 / ( area * rday * 365. )     ! convert in Kg/m3/s = mm/s 
    152 !!gm        !                                                      !!bug 365d year  
    153             fwfold =  a_fwb                           ! current year freshwater budget correction 
    154             !                                         ! estimate from the previous year budget 
     148            ! 
     149         ELSE 
     150            ! at the end of year n: 
     151            ikty = nyear_len(1) * 86400 / NINT(rdt) 
     152            IF( MOD( kt, ikty ) == 0 ) THEN   ! Update a_fwb at the last time step of a year 
     153               !                                It should be the first time step of a year MOD(kt-1,ikty) but then the restart would be wrong 
     154               !                                Hence, we make a small error here but the code is restartable 
     155               a_fwb_b = a_fwb_ini 
     156               ! mean sea level taking into account ice+snow 
     157               a_fwb   = glob_sum( 'sbcfwb', e1e2t(:,:) * ( sshn(:,:) + snwice_mass(:,:) * r1_rau0 ) ) 
     158               a_fwb   = a_fwb * rau0 / ( area * rday * REAL(nyear_len(1), wp) )   ! convert in kg/m2/s 
     159            ENDIF 
     160            ! 
    155161         ENDIF 
    156162         !  
    157          IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN         ! correct the freshwater fluxes 
    158             zcoef = fwfold * rcp 
    159             emp(:,:) = emp(:,:) + fwfold            * tmask(:,:,1) 
    160             qns(:,:) = qns(:,:) - zcoef * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction 
     163         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN         ! correct the freshwater fluxes using previous year budget 
     164            zcoef = ( a_fwb - a_fwb_b ) 
     165            emp(:,:) = emp(:,:) + zcoef * tmask(:,:,1) 
     166            qns(:,:) = qns(:,:) - zcoef * rcp * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction 
    161167            ! outputs 
    162             IF( iom_use('hflx_fwb_cea') )  CALL iom_put( 'hflx_fwb_cea', -zcoef * sst_m(:,:) * tmask(:,:,1) ) 
    163             IF( iom_use('vflx_fwb_cea') )  CALL iom_put( 'vflx_fwb_cea', -fwfold            * tmask(:,:,1) ) 
     168            IF( iom_use('hflx_fwb_cea') )  CALL iom_put( 'hflx_fwb_cea', -zcoef * rcp * sst_m(:,:) * tmask(:,:,1) ) 
     169            IF( iom_use('vflx_fwb_cea') )  CALL iom_put( 'vflx_fwb_cea', -zcoef * tmask(:,:,1) ) 
    164170         ENDIF 
    165171         ! Output restart information 
     
    174180         END IF 
    175181         ! 
    176          IF( kt == nitend .AND. lwm ) THEN            ! save fwfold value in a file (only one required) 
     182         IF( kt == nitend .AND. lwm ) THEN            ! save a_fwb value in a file (only one required) 
    177183            CALL ctl_opn( inum, 'EMPave.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea ) 
    178184            WRITE( inum, "(24X,I8,2ES24.16)" ) nyear, a_fwb_b, a_fwb 
    179185            CLOSE( inum ) 
     186         ENDIF 
     187         ! 
     188         IF( kt == nitend .AND. lwp ) THEN 
     189            WRITE(numout,*) 'sbc_fwb : freshwater-budget at the end of simulation (year now) = ', a_fwb  , 'kg/m2/s' 
     190            WRITE(numout,*) '          freshwater-budget at initial state                    = ', a_fwb_b, 'kg/m2/s' 
    180191         ENDIF 
    181192         ! 
Note: See TracChangeset for help on using the changeset viewer.