Changeset 15438
- Timestamp:
- 2021-10-22T16:56:07+02:00 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
NEMO/releases/r4.0/r4.0-HEAD/src/OCE/SBC/sbcfwb.F90
r14717 r15438 35 35 PUBLIC sbc_fwb ! routine called by step 36 36 37 REAL(wp) :: a_fwb _b ! annual domain averaged freshwater budget38 REAL(wp) :: a_fwb ! for 2 year before (_b) and before year.39 REAL(wp) :: fwfold ! fwfold to be suppressed37 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 40 40 REAL(wp) :: area ! global mean ocean surface (interior domain) 41 41 … … 117 117 ENDIF 118 118 ! 119 CASE ( 2 ) !== fw f budget adjusted fromthe previous year ==!120 ! 121 IF( kt == nit000 ) THEN ! initialisation122 ! ! 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 124 124 & .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' 126 126 CALL iom_get( numror, 'a_fwb_b', a_fwb_b, ldxios = lrxios ) 127 127 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' 129 132 CALL ctl_opn( inum, 'EMPave_old.dat', 'OLD', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE. ) 130 133 READ ( inum, "(24X,I8,2ES24.16)" ) iyear, a_fwb_b, a_fwb 131 134 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) ) 132 138 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' 139 143 ! 140 144 IF( lwxios ) THEN ! Activate output of restart variables … … 142 146 CALL iom_set_rstw_var_active( 'a_fwb' ) 143 147 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 ! 155 161 ENDIF 156 162 ! 157 IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN ! correct the freshwater fluxes 158 zcoef = fwfold * rcp159 emp(:,:) = emp(:,:) + fwfold* tmask(:,:,1)160 qns(:,:) = qns(:,:) - zcoef * sst_m(:,:) * tmask(:,:,1) ! account for change to the heat budget due to fw correction163 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 161 167 ! 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) ) 164 170 ENDIF 165 171 ! Output restart information … … 174 180 END IF 175 181 ! 176 IF( kt == nitend .AND. lwm ) THEN ! save fwfoldvalue in a file (only one required)182 IF( kt == nitend .AND. lwm ) THEN ! save a_fwb value in a file (only one required) 177 183 CALL ctl_opn( inum, 'EMPave.dat', 'REPLACE', 'FORMATTED', 'SEQUENTIAL', -1, numout, .FALSE., narea ) 178 184 WRITE( inum, "(24X,I8,2ES24.16)" ) nyear, a_fwb_b, a_fwb 179 185 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' 180 191 ENDIF 181 192 !
Note: See TracChangeset
for help on using the changeset viewer.