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 11555 for branches – NEMO

Changeset 11555 for branches


Ignore:
Timestamp:
2019-09-17T14:20:09+02:00 (5 years ago)
Author:
mattmartin
Message:

Code changes after Dan's review (comments and alignment changes only).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r5518_GO6_package_FOAMv14_updated_pcbias/NEMOGCM/NEMO/OPA_SRC/DYN/dynhpg.F90

    r11478 r11555  
    8585      !!---------------------------------------------------------------------- 
    8686      INTEGER, INTENT(in) ::   kt   ! ocean time-step index 
    87       INTEGER                                   ::   ji, jj, jk   ! dummy loop indices 
    88       INTEGER                                   ::   iku, ikv          ! k indices for bottom level at u and v points 
     87      INTEGER                                   ::   ji, jj, jk                 ! dummy loop indices 
     88      INTEGER                                   ::   iku, ikv                   ! k indices for bottom level at u and v points 
    8989      REAL(wp), POINTER, DIMENSION(:,:,:)       ::   ztrdu, ztrdv 
    90       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z_rhd_st   ! tmp density storage for pressure corr 
    91       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z_ua, z_va ! tmp store for ua and va including hpg but not pressure correction  
    92       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z_ua_bpc, z_va_bpc ! ua calculated with bias pressure correction   
    93  
     90      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z_rhd_st                   ! tmp density storage for pressure corr 
     91      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z_ua, z_va                 ! tmp store for ua and va including hpg but not pressure correction  
     92      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)   ::   z_ua_bpc, z_va_bpc         ! ua calculated with bias pressure correction   
    9493      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     ::   z_gru_st, z_grv_st         ! tmp ua and va trends storage for pressure corr 
    9594      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     ::   z_ua_bpc_bot, z_va_bpc_bot ! bias pc fields calculated at the ocean bottom 
     
    108107      IF ( ln_bias .AND. ln_bias_pc_app ) THEN 
    109108 
    110          !Allocate space for tempory variables 
     109         ! allocate space for tempory variables for the bias pressure correction (bpc) 
    111110         ALLOCATE( z_rhd_st(jpi,jpj,jpk), & 
    112111            &      z_gru_st(jpi,jpj),     & 
    113112            &      z_grv_st(jpi,jpj),     & 
    114        &      z_ua(jpi,jpj,jpk),     z_va(jpi,jpj,jpk),     &   
    115        &      z_ua_bpc(jpi,jpj,jpk), z_va_bpc(jpi,jpj,jpk), &  
    116             &      z_ua_bpc_bot(jpi,jpj), z_va_bpc_bot(jpi,jpj)  &  
    117        &            ) 
    118  
    119 ! save the original acceleration trends (z_ua_bpc, z_va_bpc are used as temporary storage) 
     113            &      z_ua(jpi,jpj,jpk),     & 
     114            &      z_va(jpi,jpj,jpk),     &   
     115            &      z_ua_bpc(jpi,jpj,jpk), & 
     116            &      z_va_bpc(jpi,jpj,jpk), &  
     117            &      z_ua_bpc_bot(jpi,jpj), & 
     118            &      z_va_bpc_bot(jpi,jpj)  &  
     119            &    ) 
     120 
     121         ! save the original acceleration trends  
     122         ! (z_ua_bpc, z_va_bpc are used as temporary storage) 
    120123         z_ua_bpc(:,:,:)     = ua(:,:,:) 
    121     z_va_bpc(:,:,:)     = va(:,:,:) 
     124         z_va_bpc(:,:,:)     = va(:,:,:) 
     125          
    122126      END IF  
    123127 
     
    134138      IF ( ln_bias .AND. ln_bias_pc_app ) THEN 
    135139 
    136          z_rhd_st(:,:,:) = rhd(:,:,:)     ! store orig density  
    137          rhd(:,:,:)      = rhd_pc(:,:,:)  ! use pressure corrected density 
     140         ! The aim here is to calculate the contribution of the bpc to the acceleration terms. 
     141         ! This is done so that the effect of the bpc on the hpg at the bottom can be removed. 
     142         ! In order to do that: 
     143         !    1. The hpg calculation is done again, but with the contributions of the bpc included. 
     144         !    2. The difference between the acceleration terms (w and w/o bpc) is then calculated. 
     145         !    3. The effect of the bpc on the bottom hpg is then removed. 
     146         !    4. The total change to the acceleration terms is then calculated. 
     147          
     148         ! The original density fields etc (without the bpc) are stored.           
     149         z_rhd_st(:,:,:) = rhd(:,:,:) 
    138150         z_gru_st(:,:)   = gru(:,:) 
    139          gru(:,:)        = gru_pc(:,:) 
    140151         z_grv_st(:,:)   = grv(:,:) 
    141          grv(:,:)        = grv_pc(:,:) 
    142  
     152 
     153         ! Set the density etc used in the hpc calculations to the value including the effect of the bpc. 
     154         rhd(:,:,:)      = rhd_pc(:,:,:) 
     155         gru(:,:)        = gru_pc(:,:)    
     156         grv(:,:)        = grv_pc(:,:)    
     157             
    143158         ! save the acceleration trends including hpg field but calculated without the bpc fields 
    144159         z_ua(:,:,:)     = ua(:,:,:) 
    145     z_va(:,:,:)     = va(:,:,:) 
    146  
    147          ! reset the acceleration trends to their original values  
     160        z_va(:,:,:)     = va(:,:,:) 
     161 
     162         ! reset the acceleration trends to their original values 
    148163         ua(:,:,:)       = z_ua_bpc(:,:,:)     
    149     va(:,:,:)       = z_va_bpc(:,:,:)   
     164        va(:,:,:)       = z_va_bpc(:,:,:)   
    150165 
    151166         ! re-calculate the horizontal pressure gradients with the bpc fields  
     
    174189 
    175190         ! subtract off the bottom values of bpc contribution to ua and va  
    176     DO jk = 1, jpk - 1 
    177            z_ua_bpc(:,:,jk) = z_ua_bpc(:,:,jk) - z_ua_bpc_bot(:,:) 
    178            z_va_bpc(:,:,jk) = z_va_bpc(:,:,jk) - z_va_bpc_bot(:,:) 
    179     END DO  
    180  
    181          ! calculate ua using the original hpg (z_ua) and the bias hpg with the bottom pressure gradients subtracted off  
     191         DO jk = 1, jpk - 1 
     192            z_ua_bpc(:,:,jk) = z_ua_bpc(:,:,jk) - z_ua_bpc_bot(:,:) 
     193            z_va_bpc(:,:,jk) = z_va_bpc(:,:,jk) - z_va_bpc_bot(:,:) 
     194         END DO  
     195 
     196         ! calculate ua using the original hpg (z_ua) and the bias hpg  
     197         ! with the bottom pressure gradients subtracted off  
    182198         ua(:,:,:) = z_ua(:,:,:) + z_ua_bpc(:,:,:) 
    183199         va(:,:,:) = z_va(:,:,:) + z_va_bpc(:,:,:) 
    184  
    185          IF(lwp) THEN  
    186            WRITE(numout,*) " ! restore original density" 
    187          ENDIF 
    188200 
    189201         ! restore original density, gru and grv fields  
     
    192204         grv(:,:)   = z_grv_st(:,:) 
    193205 
    194          !Deallocate tempory variables 
     206         ! deallocate tempory variables 
    195207         DEALLOCATE( z_rhd_st,   z_gru_st, z_grv_st,   & 
    196208            &        z_ua, z_va, z_ua_bpc, z_va_bpc,   & 
    197        &        z_ua_bpc_bot, z_va_bpc_bot        & 
     209            &        z_ua_bpc_bot, z_va_bpc_bot        & 
    198210            &                                          ) 
    199211        
Note: See TracChangeset for help on using the changeset viewer.