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 2715 for trunk/NEMOGCM/NEMO/OPA_SRC/SBC/sbcfwb.F90 – NEMO

Ignore:
Timestamp:
2011-03-30T17:58:35+02:00 (13 years ago)
Author:
rblod
Message:

First attempt to put dynamic allocation on the trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/OPA_SRC/SBC/sbcfwb.F90

    r2528 r2715  
    2828   PRIVATE 
    2929 
    30    PUBLIC   sbc_fwb      ! routine called by step 
    31  
    32    REAL(wp) ::   a_fwb_b            ! annual domain averaged freshwater budget 
    33    REAL(wp) ::   a_fwb              ! for 2 year before (_b) and before year. 
    34    REAL(wp) ::   fwfold             ! fwfold to be suppressed 
    35    REAL(wp) ::   area               ! global mean ocean surface (interior domain) 
    36  
    37    REAL(wp), DIMENSION(jpi,jpj) ::   e1e2    ! area of the interior domain (e1t*e2t) 
     30   PUBLIC   sbc_fwb    ! routine called by step 
     31 
     32   REAL(wp) ::   a_fwb_b   ! annual domain averaged freshwater budget 
     33   REAL(wp) ::   a_fwb     ! for 2 year before (_b) and before year. 
     34   REAL(wp) ::   fwfold    ! fwfold to be suppressed 
     35   REAL(wp) ::   area      ! global mean ocean surface (interior domain) 
    3836 
    3937   !! * Substitutions 
     
    6058      !!                   & spread out over erp area depending its sign 
    6159      !!---------------------------------------------------------------------- 
     60      USE wrk_nemo, ONLY:   wrk_in_use, wrk_not_released 
     61      USE wrk_nemo, ONLY:   ztmsk_neg      => wrk_2d_1 , ztmsk_pos => wrk_2d_2 
     62      USE wrk_nemo, ONLY:   ztmsk_tospread => wrk_2d_3 
     63      USE wrk_nemo, ONLY:   z_wgt          => wrk_2d_4 , zerp_cor  => wrk_2d_5 
     64      ! 
    6265      INTEGER, INTENT( in ) ::   kt       ! ocean time-step index 
    6366      INTEGER, INTENT( in ) ::   kn_fsbc  !  
    6467      INTEGER, INTENT( in ) ::   kn_fwb   ! ocean time-step index 
    65       !! 
    66       INTEGER  ::   inum                  ! temporary logical unit 
    67       INTEGER  ::   ikty, iyear           !  
    68       REAL(wp) ::   z_fwf, z_fwf_nsrf, zsum_fwf, zsum_erp       ! temporary scalars 
    69       REAL(wp) ::   zsurf_neg, zsurf_pos, zsurf_tospread 
    70       REAL(wp), DIMENSION(jpi,jpj) ::   ztmsk_neg, ztmsk_pos, ztmsk_tospread 
    71       REAL(wp), DIMENSION(jpi,jpj) ::   z_wgt, zerp_cor 
     68      ! 
     69      INTEGER  ::   inum, ikty, iyear   ! local integers 
     70      REAL(wp) ::   z_fwf, z_fwf_nsrf, zsum_fwf, zsum_erp   ! local scalars 
     71      REAL(wp) ::   zsurf_neg, zsurf_pos, zsurf_tospread    !   -      - 
    7272      !!---------------------------------------------------------------------- 
     73      ! 
     74      IF( wrk_in_use(2, 1,2,3,4,5) ) THEN 
     75         CALL ctl_stop('sbc_fwb: requested workspace arrays are unavailable')   ;   RETURN 
     76      ENDIF 
    7377      ! 
    7478      IF( kt == nit000 ) THEN 
     
    8488         IF( kn_fwb == 3 .AND. nn_sssr /= 2 )   CALL ctl_stop( 'sbc_fwb: nn_fwb = 3 requires nn_sssr = 2, we stop ' ) 
    8589         ! 
    86          e1e2(:,:) = e1t(:,:) * e2t(:,:)  
    87          area = glob_sum( e1e2(:,:) )           ! interior global domain surface 
     90         area = glob_sum( e1e2t(:,:) )           ! interior global domain surface 
    8891      ENDIF 
    8992       
     
    9497         ! 
    9598         IF( MOD( kt-1, kn_fsbc ) == 0 ) THEN 
    96             z_fwf = glob_sum( e1e2(:,:) * ( emp(:,:) - rnf(:,:) ) ) / area   ! sum over the global domain 
     99            z_fwf = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) ) ) / area   ! sum over the global domain 
    97100            emp (:,:) = emp (:,:) - z_fwf  
    98101            emps(:,:) = emps(:,:) - z_fwf  
     
    117120         IF( MOD( kt, ikty ) == 0 ) THEN 
    118121            a_fwb_b = a_fwb 
    119             a_fwb   = glob_sum( e1e2(:,:) * sshn(:,:) )   ! sum over the global domain 
     122            a_fwb   = glob_sum( e1e2t(:,:) * sshn(:,:) )   ! sum over the global domain 
    120123            a_fwb   = a_fwb * 1.e+3 / ( area * 86400. * 365. )     ! convert in Kg/m3/s = mm/s 
    121124!!gm        !                                                      !!bug 365d year  
     
    142145            ztmsk_neg(:,:) = tmask_i(:,:) - ztmsk_pos(:,:) 
    143146            ! 
    144             zsurf_neg = glob_sum( e1e2(:,:)*ztmsk_neg(:,:) )   ! Area filled by <0 and >0 erp  
    145             zsurf_pos = glob_sum( e1e2(:,:)*ztmsk_pos(:,:) ) 
     147            zsurf_neg = glob_sum( e1e2t(:,:)*ztmsk_neg(:,:) )   ! Area filled by <0 and >0 erp  
     148            zsurf_pos = glob_sum( e1e2t(:,:)*ztmsk_pos(:,:) ) 
    146149            !                                                  ! fwf global mean  
    147             z_fwf = glob_sum( e1e2(:,:) * ( emp(:,:) - rnf(:,:) ) ) / area 
     150            z_fwf = glob_sum( e1e2t(:,:) * ( emp(:,:) - rnf(:,:) ) ) / area 
    148151            !             
    149152            IF( z_fwf < 0._wp ) THEN         ! spread out over >0 erp area to increase evaporation 
     
    155158            ENDIF 
    156159            ! 
    157             zsum_fwf   = glob_sum( e1e2(:,:) * z_fwf )         ! fwf global mean over <0 or >0 erp area 
     160            zsum_fwf   = glob_sum( e1e2t(:,:) * z_fwf )         ! fwf global mean over <0 or >0 erp area 
    158161!!gm :  zsum_fwf   = z_fwf * area   ???  it is right?  I think so.... 
    159162            z_fwf_nsrf =  zsum_fwf / ( zsurf_tospread + rsmall ) 
    160163            !                                                  ! weight to respect erp field 2D structure  
    161             zsum_erp = glob_sum( ztmsk_tospread(:,:) * erp(:,:) * e1e2(:,:) ) 
     164            zsum_erp = glob_sum( ztmsk_tospread(:,:) * erp(:,:) * e1e2t(:,:) ) 
    162165            z_wgt(:,:) = ztmsk_tospread(:,:) * erp(:,:) / ( zsum_erp + rsmall ) 
    163166            !                                                  ! final correction term to apply 
     
    174177               IF( z_fwf < 0._wp ) THEN 
    175178                  WRITE(numout,*)'   z_fwf < 0' 
    176                   WRITE(numout,*)'   SUM(erp+)     = ', SUM( ztmsk_tospread(:,:)*erp(:,:)*e1e2(:,:) )*1.e-9,' Sv' 
     179                  WRITE(numout,*)'   SUM(erp+)     = ', SUM( ztmsk_tospread(:,:)*erp(:,:)*e1e2t(:,:) )*1.e-9,' Sv' 
    177180               ELSE 
    178181                  WRITE(numout,*)'   z_fwf >= 0' 
    179                   WRITE(numout,*)'   SUM(erp-)     = ', SUM( ztmsk_tospread(:,:)*erp(:,:)*e1e2(:,:) )*1.e-9,' Sv' 
     182                  WRITE(numout,*)'   SUM(erp-)     = ', SUM( ztmsk_tospread(:,:)*erp(:,:)*e1e2t(:,:) )*1.e-9,' Sv' 
    180183               ENDIF 
    181                WRITE(numout,*)'   SUM(empG)     = ', SUM( z_fwf*e1e2(:,:) )*1.e-9,' Sv' 
     184               WRITE(numout,*)'   SUM(empG)     = ', SUM( z_fwf*e1e2t(:,:) )*1.e-9,' Sv' 
    182185               WRITE(numout,*)'   z_fwf         = ', z_fwf      ,' Kg/m2/s' 
    183186               WRITE(numout,*)'   z_fwf_nsrf    = ', z_fwf_nsrf ,' Kg/m2/s' 
     
    192195      END SELECT 
    193196      ! 
     197      IF( wrk_not_released(2, 1,2,3,4,5) )   CALL ctl_stop('sbc_fwb: failed to release workspace arrays') 
     198      ! 
    194199   END SUBROUTINE sbc_fwb 
    195200 
Note: See TracChangeset for help on using the changeset viewer.