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/sbc_oce.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/sbc_oce.F90

    r2528 r2715  
    1010   !!            3.3  ! 2010-10  (J. Chanut, C. Bricaud)  add the surface pressure forcing 
    1111   !!---------------------------------------------------------------------- 
    12    USE par_oce          ! ocean parameters 
     12 
     13   !!---------------------------------------------------------------------- 
     14   !!   sbc_oce_alloc : allocation of sbc arrays 
     15   !!   sbc_tau2wnd   : wind speed estimated from wind stress 
     16   !!---------------------------------------------------------------------- 
     17   USE par_oce        ! ocean parameters 
     18   USE in_out_manager ! I/O manager 
     19   USE lib_mpp        ! MPP library 
    1320 
    1421   IMPLICIT NONE 
    1522   PRIVATE 
     23 
     24   PUBLIC   sbc_oce_alloc   ! routine called in sbcmod.F90 
     25   PUBLIC   sbc_tau2wnd     ! routine called in several sbc modules 
    1626    
    1727   !!---------------------------------------------------------------------- 
    1828   !!           Namelist for the Ocean Surface Boundary Condition 
    1929   !!---------------------------------------------------------------------- 
    20    !                                             !! * namsbc namelist * 
     30   !                                            !!* namsbc namelist * 
    2131   LOGICAL , PUBLIC ::   ln_ana      = .FALSE.   !: analytical boundary condition flag 
    2232   LOGICAL , PUBLIC ::   ln_flx      = .FALSE.   !: flux      formulation 
     
    3949   LOGICAL , PUBLIC ::   lhftau = .FALSE.        !: HF tau used in TKE: mean(stress module) - module(mean stress) 
    4050   !!                                   !!   now    ! before   !! 
    41    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   utau   , utau_b   !: sea surface i-stress (ocean referential)     [N/m2] 
    42    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   vtau   , vtau_b   !: sea surface j-stress (ocean referential)     [N/m2] 
    43    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   taum              !: module of sea surface stress (at T-point)    [N/m2]  
    44    !! wndm is used only in PISCES to compute surface gases exchanges in ice-free ocean or leads 
    45    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   wndm              !: wind speed module at T-point (=|U10m-Uoce|)  [m/s] 
    46    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qsr               !: sea heat flux:     solar                     [W/m2] 
    47    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qns    , qns_b    !: sea heat flux: non solar                     [W/m2] 
    48    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qsr_tot           !: total     solar heat flux (over sea and ice) [W/m2] 
    49    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   qns_tot           !: total non solar heat flux (over sea and ice) [W/m2] 
    50    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emp    , emp_b    !: freshwater budget: volume flux               [Kg/m2/s] 
    51    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emps   , emps_b   !: freshwater budget: concentration/dillution   [Kg/m2/s] 
    52    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   emp_tot           !: total E-P over ocean and ice                 [Kg/m2/s] 
    53    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   rnf    , rnf_b    !: river runoff   [Kg/m2/s]   
     51   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   utau   , utau_b   !: sea surface i-stress (ocean referential)     [N/m2] 
     52   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   vtau   , vtau_b   !: sea surface j-stress (ocean referential)     [N/m2] 
     53   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   taum              !: module of sea surface stress (at T-point)    [N/m2]  
     54   !! wndm is used onmpute surface gases exchanges in ice-free ocean or leads 
     55   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   wndm              !: wind speed module at T-point (=|U10m-Uoce|)  [m/s] 
     56   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   qsr               !: sea heat flux:     solar                     [W/m2] 
     57   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   qns    , qns_b    !: sea heat flux: non solar                     [W/m2] 
     58   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   qsr_tot           !: total     solar heat flux (over sea and ice) [W/m2] 
     59   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   qns_tot           !: total non solar heat flux (over sea and ice) [W/m2] 
     60   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   emp    , emp_b    !: freshwater budget: volume flux               [Kg/m2/s] 
     61   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   emps   , emps_b   !: freshwater budget: concentration/dillution   [Kg/m2/s] 
     62   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   emp_tot           !: total E-P over ocean and ice                 [Kg/m2/s] 
     63   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   rnf    , rnf_b    !: river runoff   [Kg/m2/s]   
    5464   !! 
    55    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpts) ::  sbc_tsc, sbc_tsc_b  !: sbc content trend                      [K.m/s] 
    56    REAL(wp), PUBLIC, DIMENSION(jpi,jpj,jpk) ::   qsr_hc , qsr_hc_b   !: heat content trend due to qsr flux     [K.m/s] 
     65   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  sbc_tsc, sbc_tsc_b  !: sbc content trend                      [K.m/s] jpi,jpj,jpts 
     66   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:,:) ::  qsr_hc , qsr_hc_b   !: heat content trend due to qsr flux     [K.m/s] jpi,jpj,jpk 
    5767   !! 
    58    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   tprecip           !: total precipitation                          [Kg/m2/s] 
    59    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sprecip           !: solid precipitation                          [Kg/m2/s] 
    60    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   fr_i              !: ice fraction = 1 - lead fraction      (between 0 to 1) 
     68   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   tprecip           !: total precipitation                          [Kg/m2/s] 
     69   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sprecip           !: solid precipitation                          [Kg/m2/s] 
     70   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   fr_i              !: ice fraction = 1 - lead fraction      (between 0 to 1) 
    6171#if defined key_cpl_carbon_cycle 
    62    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   atm_co2           !: atmospheric pCO2                             [ppm] 
     72   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   atm_co2           !: atmospheric pCO2                             [ppm] 
    6373#endif 
    6474 
     
    6777   !!---------------------------------------------------------------------- 
    6878   INTEGER , PUBLIC                     ::   nn_fsbc   !: frequency of sbc computation (as well as sea-ice model) 
    69    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ssu_m     !: mean (nn_fsbc time-step) surface sea i-current (U-point) [m/s] 
    70    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ssv_m     !: mean (nn_fsbc time-step) surface sea j-current (V-point) [m/s] 
    71    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sst_m     !: mean (nn_fsbc time-step) surface sea temperature     [Celsius] 
    72    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   sss_m     !: mean (nn_fsbc time-step) surface sea salinity            [psu] 
    73    REAL(wp), PUBLIC, DIMENSION(jpi,jpj) ::   ssh_m     !: mean (nn_fsbc time-step) sea surface height                [m] 
     79   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ssu_m     !: mean (nn_fsbc time-step) surface sea i-current (U-point) [m/s] 
     80   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ssv_m     !: mean (nn_fsbc time-step) surface sea j-current (V-point) [m/s] 
     81   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sst_m     !: mean (nn_fsbc time-step) surface sea temperature     [Celsius] 
     82   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   sss_m     !: mean (nn_fsbc time-step) surface sea salinity            [psu] 
     83   REAL(wp), PUBLIC, ALLOCATABLE, SAVE, DIMENSION(:,:) ::   ssh_m     !: mean (nn_fsbc time-step) sea surface height                [m] 
    7484 
     85   !! * Substitutions 
     86#  include "vectopt_loop_substitute.h90" 
    7587   !!---------------------------------------------------------------------- 
    76    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     88   !! NEMO/OPA 4.0 , NEMO Consortium (2011) 
    7789   !! $Id$ 
    7890   !! Software governed by the CeCILL licence     (NEMOGCM/NEMO_CeCILL.txt) 
     91   !!---------------------------------------------------------------------- 
     92CONTAINS 
     93 
     94   INTEGER FUNCTION sbc_oce_alloc() 
     95      !!--------------------------------------------------------------------- 
     96      !!                  ***  FUNCTION sbc_oce_alloc  *** 
     97      !!--------------------------------------------------------------------- 
     98      INTEGER :: ierr(4) 
     99      !!--------------------------------------------------------------------- 
     100      ierr(:) = 0 
     101      ! 
     102      ALLOCATE( utau(jpi,jpj) , utau_b(jpi,jpj) , taum(jpi,jpj) ,     & 
     103         &      vtau(jpi,jpj) , vtau_b(jpi,jpj) , wndm(jpi,jpj) , STAT=ierr(1) )  
     104         ! 
     105      ALLOCATE( qns_tot(jpi,jpj) , qns   (jpi,jpj) , qns_b(jpi,jpj),        & 
     106         &      qsr_tot(jpi,jpj) , qsr   (jpi,jpj) ,                        & 
     107         &      emp    (jpi,jpj) , emp_b (jpi,jpj) ,                        & 
     108         &      emps   (jpi,jpj) , emps_b(jpi,jpj) , emp_tot(jpi,jpj) , STAT=ierr(2) ) 
     109         ! 
     110      ALLOCATE( rnf  (jpi,jpj) , sbc_tsc  (jpi,jpj,jpts) , qsr_hc  (jpi,jpj,jpk) ,     & 
     111         &      rnf_b(jpi,jpj) , sbc_tsc_b(jpi,jpj,jpts) , qsr_hc_b(jpi,jpj,jpk) , STAT=ierr(3) ) 
     112         ! 
     113      ALLOCATE( tprecip(jpi,jpj) , sprecip(jpi,jpj) , fr_i(jpi,jpj) ,     & 
     114#if defined key_cpl_carbon_cycle 
     115         &      atm_co2(jpi,jpj) ,                                        & 
     116#endif 
     117         &      ssu_m  (jpi,jpj) , sst_m(jpi,jpj) ,                       & 
     118         &      ssv_m  (jpi,jpj) , sss_m  (jpi,jpj), ssh_m(jpi,jpj) , STAT=ierr(4) ) 
     119         ! 
     120      sbc_oce_alloc = MAXVAL( ierr ) 
     121      IF( lk_mpp            )   CALL mpp_sum ( sbc_oce_alloc ) 
     122      IF( sbc_oce_alloc > 0 )   CALL ctl_warn('sbc_oce_alloc: allocation of arrays failed') 
     123      ! 
     124   END FUNCTION sbc_oce_alloc 
     125 
     126 
     127   SUBROUTINE sbc_tau2wnd 
     128      !!--------------------------------------------------------------------- 
     129      !!                    ***  ROUTINE sbc_tau2wnd  *** 
     130      !!                    
     131      !! ** Purpose : Estimation of wind speed as a function of wind stress    
     132      !! 
     133      !! ** Method  : |tau|=rhoa*Cd*|U|^2 
     134      !!--------------------------------------------------------------------- 
     135      USE dom_oce         ! ocean space and time domain 
     136      USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
     137      REAL(wp) ::   zrhoa  = 1.22         ! Air density kg/m3 
     138      REAL(wp) ::   zcdrag = 1.5e-3       ! drag coefficient 
     139      REAL(wp) ::   ztx, zty, ztau, zcoef ! temporary variables 
     140      INTEGER  ::   ji, jj                ! dummy indices 
     141      !!--------------------------------------------------------------------- 
     142      zcoef = 0.5 / ( zrhoa * zcdrag )  
     143!CDIR NOVERRCHK 
     144      DO jj = 2, jpjm1 
     145!CDIR NOVERRCHK 
     146         DO ji = fs_2, fs_jpim1   ! vect. opt. 
     147            ztx = utau(ji-1,jj  ) + utau(ji,jj)  
     148            zty = vtau(ji  ,jj-1) + vtau(ji,jj)  
     149            ztau = SQRT( ztx * ztx + zty * zty ) 
     150            wndm(ji,jj) = SQRT ( ztau * zcoef ) * tmask(ji,jj,1) 
     151         END DO 
     152      END DO 
     153      CALL lbc_lnk( wndm(:,:) , 'T', 1. ) 
     154      ! 
     155   END SUBROUTINE sbc_tau2wnd 
     156 
    79157   !!====================================================================== 
    80158END MODULE sbc_oce 
Note: See TracChangeset for help on using the changeset viewer.