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 9987 for branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90 – NEMO

Ignore:
Timestamp:
2018-07-23T11:33:03+02:00 (6 years ago)
Author:
emmafiedler
Message:

Merge with GO6 FOAMv14 package branch r9288

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r5518_obs_oper_update_icethick/NEMOGCM/NEMO/OPA_SRC/SBC/sbcisf.F90

    r7960 r9987  
    2626   USE zdfbfr 
    2727   USE fldread         ! read input field at current time step 
    28  
    29  
     28   USE lib_fortran, ONLY: glob_sum 
    3029 
    3130   IMPLICIT NONE 
     
    5352   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  risfLeff               !:effective length (Leff) BG03 nn_isf==2 
    5453   REAL(wp)   , PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  ttbl, stbl, utbl, vtbl !:top boundary layer variable at T point 
    55 #if defined key_agrif 
    56    ! AGRIF can not handle these arrays as integers. The reason is a mystery but problems avoided by declaring them as reals 
    57    REAL(wp),    PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  misfkt, misfkb         !:Level of ice shelf base 
    58                                                                                           !: (first wet level and last level include in the tbl) 
    59 #else 
    6054   INTEGER,    PUBLIC, ALLOCATABLE, SAVE, DIMENSION (:,:)     ::  misfkt, misfkb         !:Level of ice shelf base 
    61 #endif 
    6255 
    6356 
     
    9083    INTEGER                      ::   ji, jj, jk, ijkmin, inum, ierror 
    9184    INTEGER                      ::   ikt, ikb   ! top and bottom level of the isf boundary layer 
     85    REAL(wp)                     ::   zgreenland_fwfisf_sum, zantarctica_fwfisf_sum 
    9286    REAL(wp)                     ::   rmin 
    9387    REAL(wp)                     ::   zhk 
    94     CHARACTER(len=256)           ::   cfisf, cvarzisf, cvarhisf   ! name for isf file 
     88    REAL(wp)                     ::   zt_frz, zpress 
     89    CHARACTER(len=256)           ::   cfisf , cvarzisf, cvarhisf   ! name for isf file 
    9590    CHARACTER(LEN=256)           :: cnameis                     ! name of iceshelf file 
    9691    CHARACTER (LEN=32)           :: cvarLeff                    ! variable name for efficient Length scale 
    9792    INTEGER           ::   ios           ! Local integer output status for namelist read 
     93 
     94    REAL(wp), DIMENSION(:,:,:), POINTER :: zfwfisf3d, zqhcisf3d, zqlatisf3d 
     95    REAL(wp), DIMENSION(:,:  ), POINTER :: zqhcisf2d 
    9896      ! 
    9997      !!--------------------------------------------------------------------- 
     
    176174              DO jj = 1, jpj 
    177175                  jk = 2 
    178                   DO WHILE ( jk .LE. mbkt(ji,jj) .AND. fsdepw(ji,jj,jk) < rzisf_tbl(ji,jj) ) ;  jk = jk + 1 ;  END DO 
     176                  DO WHILE ( jk .LE. mbkt(ji,jj) .AND. gdepw_0(ji,jj,jk) < rzisf_tbl(ji,jj) ) ;  jk = jk + 1 ;  END DO 
    179177                  misfkt(ji,jj) = jk-1 
    180178               END DO 
     
    194192         END IF 
    195193          
     194         ! save initial top boundary layer thickness          
    196195         rhisf_tbl_0(:,:) = rhisf_tbl(:,:) 
     196 
     197      END IF 
     198 
     199      !                                            ! ---------------------------------------- ! 
     200      IF( kt /= nit000 ) THEN                      !          Swap of forcing fields          ! 
     201         !                                         ! ---------------------------------------- ! 
     202         fwfisf_b  (:,:  ) = fwfisf  (:,:  )               ! Swap the ocean forcing fields except at nit000 
     203         risf_tsc_b(:,:,:) = risf_tsc(:,:,:)               ! where before fields are set at the end of the routine 
     204         ! 
     205      ENDIF 
     206 
     207      IF( MOD( kt-1, nn_fsbc) == 0 ) THEN 
    197208 
    198209         ! compute bottom level of isf tbl and thickness of tbl below the ice shelf 
     
    205216 
    206217               ! determine the deepest level influenced by the boundary layer 
    207                ! test on tmask useless ????? 
    208218               DO jk = ikt, mbkt(ji,jj) 
    209219                  IF ( (SUM(fse3t_n(ji,jj,ikt:jk-1)) .LT. rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk 
     
    217227            END DO 
    218228         END DO 
    219           
    220       END IF 
    221  
    222       !                                            ! ---------------------------------------- ! 
    223       IF( kt /= nit000 ) THEN                      !          Swap of forcing fields          ! 
    224          !                                         ! ---------------------------------------- ! 
    225          fwfisf_b  (:,:  ) = fwfisf  (:,:  )               ! Swap the ocean forcing fields except at nit000 
    226          risf_tsc_b(:,:,:) = risf_tsc(:,:,:)               ! where before fields are set at the end of the routine 
    227          ! 
    228       ENDIF 
    229  
    230       IF( MOD( kt-1, nn_fsbc) == 0 ) THEN 
    231  
    232229 
    233230         ! compute salf and heat flux 
     
    256253            CALL fld_read ( kt, nn_fsbc, sf_rnfisf   ) 
    257254            fwfisf(:,:) = - sf_rnfisf(1)%fnow(:,:,1)         ! fresh water flux from the isf (fwfisf <0 mean melting)  
     255 
     256            IF( lk_oasis) THEN 
     257            ! nn_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true 
     258            IF( nn_coupled_iceshelf_fluxes .gt. 0 ) THEN 
     259 
     260              ! Adjust total iceshelf melt rates so that sum of iceberg calving and iceshelf melting in the northern 
     261              ! and southern hemispheres equals rate of increase of mass of greenland and antarctic ice sheets 
     262              ! to preserve total freshwater conservation in coupled models without an active ice sheet model. 
     263  
     264              ! All related global sums must be done bit reproducibly 
     265               zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) ) 
     266 
     267               ! use ABS function because we need to preserve the sign of fwfisf 
     268               WHERE( greenland_icesheet_mask(:,:) == 1.0 )                                                                  & 
     269              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( greenland_icesheet_mass_rate_of_change * (1.0-rn_greenland_calving_fraction) & 
     270              &                           / ( zgreenland_fwfisf_sum + 1.0e-10_wp ) ) 
     271 
     272               ! check 
     273               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting climatology (kg/s) : ',zgreenland_fwfisf_sum 
     274 
     275               zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) ) 
     276 
     277               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting adjusted value (kg/s) : ',zgreenland_fwfisf_sum 
     278 
     279               zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) ) 
     280 
     281               ! use ABS function because we need to preserve the sign of fwfisf 
     282               WHERE( antarctica_icesheet_mask(:,:) == 1.0 ) & 
     283              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( antarctica_icesheet_mass_rate_of_change * (1.0-rn_antarctica_calving_fraction) & 
     284              &                           / ( zantarctica_fwfisf_sum + 1.0e-10_wp ) ) 
     285       
     286               ! check 
     287               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting climatology (kg/s) : ',zantarctica_fwfisf_sum 
     288 
     289               zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) ) 
     290 
     291               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting adjusted value (kg/s) : ',zantarctica_fwfisf_sum 
     292 
     293            ENDIF 
     294            ENDIF 
     295 
    258296            qisf(:,:)   = fwfisf(:,:) * lfusisf              ! heat        flux 
    259297            stbl(:,:)   = soce 
     
    264302            !CALL fld_read ( kt, nn_fsbc, sf_qisf   ) 
    265303            fwfisf(:,:) = sf_fwfisf(1)%fnow(:,:,1)            ! fwf 
     304 
     305            IF( lk_oasis) THEN 
     306            ! nn_coupled_iceshelf_fluxes uninitialised unless lk_oasis=true 
     307            IF( nn_coupled_iceshelf_fluxes .gt. 0 ) THEN 
     308 
     309              ! Adjust total iceshelf melt rates so that sum of iceberg calving and iceshelf melting in the northern 
     310              ! and southern hemispheres equals rate of increase of mass of greenland and antarctic ice sheets 
     311              ! to preserve total freshwater conservation in coupled models without an active ice sheet model. 
     312 
     313              ! All related global sums must be done bit reproducibly 
     314               zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) ) 
     315 
     316               ! use ABS function because we need to preserve the sign of fwfisf 
     317               WHERE( greenland_icesheet_mask(:,:) == 1.0 )                                                                  & 
     318              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( greenland_icesheet_mass_rate_of_change * (1.0-rn_greenland_calving_fraction) & 
     319              &                           / ( zgreenland_fwfisf_sum + 1.0e-10_wp ) ) 
     320 
     321               ! check 
     322               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting climatology (kg/s) : ',zgreenland_fwfisf_sum 
     323 
     324               zgreenland_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * greenland_icesheet_mask(:,:) ) 
     325 
     326               IF(lwp) WRITE(numout, *) 'Greenland iceshelf melting adjusted value (kg/s) : ',zgreenland_fwfisf_sum 
     327 
     328               zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) ) 
     329 
     330               ! use ABS function because we need to preserve the sign of fwfisf 
     331               WHERE( antarctica_icesheet_mask(:,:) == 1.0 ) & 
     332              &    fwfisf(:,:) = fwfisf(:,:)  * ABS( antarctica_icesheet_mass_rate_of_change * (1.0-rn_antarctica_calving_fraction) & 
     333              &                           / ( zantarctica_fwfisf_sum + 1.0e-10_wp ) ) 
     334       
     335               ! check 
     336               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting climatology (kg/s) : ',zantarctica_fwfisf_sum 
     337 
     338               zantarctica_fwfisf_sum = glob_sum( fwfisf(:,:) * e1t(:,:) * e2t(:,:) * antarctica_icesheet_mask(:,:) ) 
     339 
     340               IF(lwp) WRITE(numout, *) 'Antarctica iceshelf melting adjusted value (kg/s) : ',zantarctica_fwfisf_sum 
     341 
     342            ENDIF 
     343            ENDIF 
     344 
    266345            qisf(:,:)   = fwfisf(:,:) * lfusisf              ! heat        flux 
    267346            !qisf(:,:)   = sf_qisf(1)%fnow(:,:,1)              ! heat flux 
     
    270349         END IF 
    271350         ! compute tsc due to isf 
    272          ! WARNING water add at temp = 0C, correction term is added in trasbc, maybe better here but need a 3D variable). 
    273          risf_tsc(:,:,jp_tem) = qisf(:,:) * r1_rau0_rcp ! 
     351         ! WARNING water add at temp = 0C, correction term is added, maybe better here but need a 3D variable). 
     352!         zpress = grav*rau0*fsdept(ji,jj,jk)*1.e-04 
     353         zt_frz = -1.9 !eos_fzp( tsn(ji,jj,jk,jp_sal), zpress ) 
     354         risf_tsc(:,:,jp_tem) = qisf(:,:) * r1_rau0_rcp - rdivisf * fwfisf(:,:) * zt_frz * r1_rau0 ! 
    274355          
    275356         ! salt effect already take into account in vertical advection 
    276357         risf_tsc(:,:,jp_sal) = (1.0_wp-rdivisf) * fwfisf(:,:) * stbl(:,:) * r1_rau0 
    277            
     358 
     359         ! output 
     360         IF( iom_use('qlatisf' ) )   CALL iom_put('qlatisf', qisf) 
     361         IF( iom_use('fwfisf'  ) )   CALL iom_put('fwfisf' , fwfisf * stbl(:,:) / soce ) 
     362 
     363         ! if apply only on the trend and not as a volume flux (rdivisf = 0), fwfisf have to be set to 0 now 
     364         fwfisf(:,:) = rdivisf * fwfisf(:,:)          
     365  
    278366         ! lbclnk 
    279367         CALL lbc_lnk(risf_tsc(:,:,jp_tem),'T',1.) 
     
    281369         CALL lbc_lnk(fwfisf(:,:)   ,'T',1.) 
    282370         CALL lbc_lnk(qisf(:,:)     ,'T',1.) 
     371 
     372!============================================================================================================================================= 
     373         IF ( iom_use('fwfisf3d') .OR. iom_use('qlatisf3d') .OR. iom_use('qhcisf3d') .OR. iom_use('qhcisf')) THEN 
     374            CALL wrk_alloc( jpi,jpj,jpk, zfwfisf3d, zqhcisf3d, zqlatisf3d ) 
     375            CALL wrk_alloc( jpi,jpj,     zqhcisf2d                        ) 
     376 
     377            zfwfisf3d(:,:,:) = 0.0_wp                         ! 3d ice shelf melting (kg/m2/s) 
     378            zqhcisf3d(:,:,:) = 0.0_wp                         ! 3d heat content flux (W/m2) 
     379            zqlatisf3d(:,:,:)= 0.0_wp                         ! 3d ice shelf melting latent heat flux (W/m2) 
     380            zqhcisf2d(:,:)   = fwfisf(:,:) * zt_frz * rcp     ! 2d heat content flux (W/m2) 
     381 
     382            DO jj = 1,jpj 
     383               DO ji = 1,jpi 
     384                  ikt = misfkt(ji,jj) 
     385                  ikb = misfkb(ji,jj) 
     386                  DO jk = ikt, ikb - 1 
     387                     zfwfisf3d (ji,jj,jk) = zfwfisf3d (ji,jj,jk) + fwfisf   (ji,jj) * r1_hisf_tbl(ji,jj) * fse3t(ji,jj,jk) 
     388                     zqhcisf3d (ji,jj,jk) = zqhcisf3d (ji,jj,jk) + zqhcisf2d(ji,jj) * r1_hisf_tbl(ji,jj) * fse3t(ji,jj,jk) 
     389                     zqlatisf3d(ji,jj,jk) = zqlatisf3d(ji,jj,jk) + qisf     (ji,jj) * r1_hisf_tbl(ji,jj) * fse3t(ji,jj,jk) 
     390                  END DO 
     391                  zfwfisf3d (ji,jj,jk) = zfwfisf3d (ji,jj,jk) + fwfisf   (ji,jj) * r1_hisf_tbl(ji,jj) * ralpha(ji,jj) * fse3t(ji,jj,jk) 
     392                  zqhcisf3d (ji,jj,jk) = zqhcisf3d (ji,jj,jk) + zqhcisf2d(ji,jj) * r1_hisf_tbl(ji,jj) * ralpha(ji,jj) * fse3t(ji,jj,jk) 
     393                  zqlatisf3d(ji,jj,jk) = zqlatisf3d(ji,jj,jk) + qisf     (ji,jj) * r1_hisf_tbl(ji,jj) * ralpha(ji,jj) * fse3t(ji,jj,jk) 
     394               END DO 
     395            END DO 
     396 
     397            CALL iom_put('fwfisf3d' , zfwfisf3d (:,:,:)) 
     398            CALL iom_put('qlatisf3d', zqlatisf3d(:,:,:)) 
     399            CALL iom_put('qhcisf3d' , zqhcisf3d (:,:,:)) 
     400            CALL iom_put('qhcisf'   , zqhcisf2d (:,:  )) 
     401 
     402            CALL wrk_dealloc( jpi,jpj,jpk, zfwfisf3d, zqhcisf3d, zqlatisf3d ) 
     403            CALL wrk_dealloc( jpi,jpj,     zqhcisf2d                        ) 
     404         END IF 
     405!============================================================================================================================================= 
    283406 
    284407         IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    ! 
     
    295418         ENDIF 
    296419         !  
    297          ! output 
    298          CALL iom_put('qisf'  , qisf) 
    299          IF( iom_use('fwfisf') )   CALL iom_put('fwfisf', fwfisf * stbl(:,:) / soce ) 
    300420      END IF 
    301421   
     
    370490             ! Calculate freezing temperature 
    371491                zpress = grav*rau0*fsdept(ji,jj,ik)*1.e-04  
    372                 zt_frz = eos_fzp(tsb(ji,jj,ik,jp_sal), zpress)  
     492                CALL eos_fzp(tsb(ji,jj,ik,jp_sal), zt_frz, zpress)  
    373493                zt_sum = zt_sum + (tsn(ji,jj,ik,jp_tem)-zt_frz) * fse3t(ji,jj,ik) * tmask(ji,jj,ik)  ! sum temp 
    374494             ENDDO 
     
    452572      zti(:,:)=tinsitu( ttbl, stbl, zpress ) 
    453573! Calculate freezing temperature 
    454       zfrz(:,:)=eos_fzp( sss_m(:,:), zpress ) 
     574      CALL eos_fzp( sss_m(:,:), zfrz(:,:), zpress ) 
    455575 
    456576       
     
    472592 
    473593                     nit = nit + 1 
    474                      IF (nit .GE. 100) THEN 
    475                         !WRITE(numout,*) "sbcisf : too many iteration ... ", zhtflx, zhtflx_b,zgammat, rn_gammat0, rn_tfri2, nn_gammablk, ji,jj 
    476                         !WRITE(numout,*) "sbcisf : too many iteration ... ", (zhtflx - zhtflx_b)/zhtflx 
    477                         CALL ctl_stop( 'STOP', 'sbc_isf_hol99 : too many iteration ...' ) 
    478                      END IF 
     594                     IF (nit .GE. 100) CALL ctl_stop( 'STOP', 'sbc_isf_hol99 : too many iteration ...' ) 
     595 
    479596! save gammat and compute zhtflx_b 
    480597                     zgammat2d(ji,jj)=zgammat 
     
    794911               ! test on tmask useless ????? 
    795912               DO jk = ikt, mbkt(ji,jj) 
    796 !                  IF ( (SUM(fse3t(ji,jj,ikt:jk-1)) .LT. rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk 
     913                  IF ( (SUM(fse3t(ji,jj,ikt:jk-1)) .LT. rhisf_tbl(ji,jj)) .AND. (tmask(ji,jj,jk) == 1) ) ikb = jk 
    797914               END DO 
    798915               rhisf_tbl(ji,jj) = MIN(rhisf_tbl(ji,jj), SUM(fse3t(ji,jj,ikt:ikb)))  ! limit the tbl to water thickness. 
Note: See TracChangeset for help on using the changeset viewer.