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 15439 – NEMO

Changeset 15439


Ignore:
Timestamp:
2021-10-22T19:53:09+02:00 (3 years ago)
Author:
clem
Message:

trunk: 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/trunk/src/OCE/SBC/sbcfwb.F90

    r15004 r15439  
    3636 
    3737   REAL(wp) ::   rn_fwb0   ! initial freshwater adjustment flux [kg/m2/s] (nn_fwb = 2 only) 
    38    REAL(wp) ::   a_fwb     ! annual domain averaged freshwater budget from the 
    39                            ! previous year 
     38   REAL(wp) ::   a_fwb     ! annual domain averaged freshwater budget from the previous year 
     39   REAL(wp) ::   a_fwb_b   ! annual domain averaged freshwater budget from the year before or at initial state 
     40   REAL(wp) ::   a_fwb_ini ! initial domain averaged freshwater budget 
    4041   REAL(wp) ::   area      ! global mean ocean surface (interior domain) 
    4142 
     
    129130         ! 
    130131      CASE ( 2 )                             !==  fw adjustment based on fw budget at the end of the previous year  ==! 
    131          ! 
    132          IF( kt == nit000 ) THEN                                                                    ! initialisation 
    133             !                                                                                       ! set the fw adjustment (a_fwb) 
    134             IF ( ln_rstart .AND. iom_varid( numror, 'a_fwb',   ldstop = .FALSE. ) > 0 ) THEN        !    as read from restart file 
    135                IF(lwp) WRITE(numout,*) 'sbc_fwb : reading FW-budget adjustment from restart file' 
    136                CALL iom_get( numror, 'a_fwb',   a_fwb ) 
    137             ELSE                                                                                    !    as specified in namelist 
    138                a_fwb = rn_fwb0 
     132         !                                                simulation is supposed to start 1st of January 
     133         IF( kt == nit000 ) THEN                                                                 ! initialisation 
     134            !                                                                                    ! set the fw adjustment (a_fwb) 
     135            IF ( ln_rstart .AND. iom_varid( numror, 'a_fwb_b', ldstop = .FALSE. ) > 0     &      !    as read from restart file 
     136               &           .AND. iom_varid( numror, 'a_fwb',   ldstop = .FALSE. ) > 0 ) THEN 
     137               IF(lwp)   WRITE(numout,*) 'sbc_fwb : reading freshwater-budget from restart file' 
     138               CALL iom_get( numror, 'a_fwb_b', a_fwb_b ) 
     139               CALL iom_get( numror, 'a_fwb'  , a_fwb ) 
     140               ! 
     141               a_fwb_ini = a_fwb_b 
     142            ELSE                                                                                 !    as specified in namelist 
     143               IF(lwp)   WRITE(numout,*) 'sbc_fwb : setting freshwater-budget from namelist rn_fwb0' 
     144               a_fwb   = rn_fwb0 
     145               a_fwb_b = 0._wp   ! used only the first year then it is replaced by a_fwb_ini 
     146               ! 
     147               a_fwb_ini = glob_sum( 'sbcfwb', e1e2t(:,:) * ( ssh(:,:,Kmm) + snwice_mass(:,:) * r1_rho0 ) ) & 
     148                  &      * rho0 / ( area * rday * REAL(nyear_len(1), wp) ) 
    139149            END IF 
    140150            ! 
    141             IF(lwp)WRITE(numout,*) 
    142             IF(lwp)WRITE(numout,*)'sbc_fwb : initial freshwater-budget adjustment = ', a_fwb, 'kg/m2/s' 
    143             ! 
    144          ENDIF    
    145          !                                         ! Update a_fwb if new year start 
    146          ikty = 365 * 86400 / rn_Dt                  !!bug  use of 365 days leap year or 360d year !!!!!!! 
    147          IF( MOD( kt, ikty ) == 0 ) THEN 
    148                                                       ! mean sea level taking into account the ice+snow 
    149                                                       ! sum over the global domain 
    150             a_fwb   = glob_sum( 'sbcfwb', e1e2t(:,:) * ( ssh(:,:,Kmm) + snwice_mass(:,:) * r1_rho0 ) ) 
    151             a_fwb   = a_fwb * 1.e+3 / ( area * rday * 365. )     ! convert in Kg/m3/s = mm/s 
    152 !!gm        !                                                      !!bug 365d year  
    153          ENDIF 
    154          !  
    155          IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN         ! correct the freshwater fluxes 
    156             zcoef = a_fwb * rcp 
    157             emp(:,:) = emp(:,:) + a_fwb              * tmask(:,:,1) 
    158             qns(:,:) = qns(:,:) - zcoef * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction 
     151            IF(lwp)   WRITE(numout,*) 
     152            IF(lwp)   WRITE(numout,*)'sbc_fwb : freshwater-budget at the end of previous year = ', a_fwb    , 'kg/m2/s' 
     153            IF(lwp)   WRITE(numout,*)'          freshwater-budget at initial state            = ', a_fwb_ini, 'kg/m2/s' 
     154            ! 
     155         ELSE 
     156            ! at the end of year n: 
     157            ikty = nyear_len(1) * 86400 / NINT(rn_Dt) 
     158            IF( MOD( kt, ikty ) == 0 ) THEN   ! Update a_fwb at the last time step of a year 
     159               !                                It should be the first time step of a year MOD(kt-1,ikty) but then the restart would be wrong 
     160               !                                Hence, we make a small error here but the code is restartable 
     161               a_fwb_b = a_fwb_ini 
     162               ! mean sea level taking into account ice+snow 
     163               a_fwb   = glob_sum( 'sbcfwb', e1e2t(:,:) * ( ssh(:,:,Kmm) + snwice_mass(:,:) * r1_rho0 ) ) 
     164               a_fwb   = a_fwb * rho0 / ( area * rday * REAL(nyear_len(1), wp) )   ! convert in kg/m2/s 
     165            ENDIF 
     166            ! 
     167         ENDIF 
     168         ! 
     169         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN         ! correct the freshwater fluxes using previous year budget minus initial state 
     170            zcoef = ( a_fwb - a_fwb_b ) 
     171            emp(:,:) = emp(:,:) + zcoef * tmask(:,:,1) 
     172            qns(:,:) = qns(:,:) - zcoef * rcp * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction 
    159173            ! outputs 
    160             IF( iom_use('hflx_fwb_cea') )  CALL iom_put( 'hflx_fwb_cea', -zcoef * sst_m(:,:) * tmask(:,:,1) ) 
    161             IF( iom_use('vflx_fwb_cea') )  CALL iom_put( 'vflx_fwb_cea', -a_fwb              * tmask(:,:,1) ) 
     174            IF( iom_use('hflx_fwb_cea') )  CALL iom_put( 'hflx_fwb_cea', -zcoef * rcp * sst_m(:,:) * tmask(:,:,1) ) 
     175            IF( iom_use('vflx_fwb_cea') )  CALL iom_put( 'vflx_fwb_cea', -zcoef * tmask(:,:,1) ) 
    162176         ENDIF 
    163177         ! Output restart information 
     
    166180            IF(lwp) WRITE(numout,*) 'sbc_fwb : writing FW-budget adjustment to ocean restart file at it = ', kt 
    167181            IF(lwp) WRITE(numout,*) '~~~~' 
    168             CALL iom_rstput( kt, nitrst, numrow, 'a_fwb',   a_fwb ) 
     182            CALL iom_rstput( kt, nitrst, numrow, 'a_fwb_b', a_fwb_b ) 
     183            CALL iom_rstput( kt, nitrst, numrow, 'a_fwb',   a_fwb   ) 
    169184         END IF 
    170185         ! 
    171          IF( kt == nitend .AND. lwp ) WRITE(numout,*) 'sbc_fwb : final freshwater-budget adjustment = ', a_fwb, 'kg/m2/s' 
     186         IF( kt == nitend .AND. lwp ) THEN 
     187            WRITE(numout,*) 'sbc_fwb : freshwater-budget at the end of simulation (year now) = ', a_fwb  , 'kg/m2/s' 
     188            WRITE(numout,*) '          freshwater-budget at initial state                    = ', a_fwb_b, 'kg/m2/s' 
     189         ENDIF 
    172190         ! 
    173191      CASE ( 3 )                             !==  global fwf set to zero and spread out over erp area  ==! 
Note: See TracChangeset for help on using the changeset viewer.