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

Ignore:
Timestamp:
2015-06-11T21:13:22+02:00 (9 years ago)
Author:
smasson
Message:

merge dev_r5218_CNRS17_coupling into the trunk

File:
1 edited

Legend:

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

    r5385 r5407  
    3232 
    3333   PUBLIC   sbc_rnf       ! routine call in sbcmod module 
    34    PUBLIC   sbc_rnf_div   ! routine called in sshwzv module 
     34   PUBLIC   sbc_rnf_div   ! routine called in divcurl module 
    3535   PUBLIC   sbc_rnf_alloc ! routine call in sbcmod module 
    3636   PUBLIC   sbc_rnf_init  ! (PUBLIC for TAM) 
     
    4444   LOGICAL           , PUBLIC ::   ln_rnf_tem      !: temperature river runoffs attribute specified in a file 
    4545   LOGICAL           , PUBLIC ::   ln_rnf_sal      !: salinity    river runoffs attribute specified in a file 
    46    LOGICAL           , PUBLIC ::   ln_rnf_emp      !: runoffs into a file to be read or already into precipitation 
    4746   TYPE(FLD_N)       , PUBLIC ::   sn_rnf          !: information about the runoff file to be read 
    4847   TYPE(FLD_N)       , PUBLIC ::   sn_cnf          !: information about the runoff mouth file to be read 
     
    5453   REAL(wp)          , PUBLIC ::   rn_avt_rnf      !: runoffs, value of the additional vertical mixing coef. [m2/s] 
    5554   REAL(wp)          , PUBLIC ::   rn_rfact        !: multiplicative factor for runoff 
     55 
     56   LOGICAL           , PUBLIC ::   l_rnfcpl = .false.       ! runoffs recieved from oasis 
    5657 
    5758   INTEGER , PUBLIC  ::   nkrnf = 0         !: nb of levels over which Kz is increased at river mouths 
     
    117118      ENDIF 
    118119 
    119       !                                                   !-------------------! 
    120       IF( .NOT. ln_rnf_emp ) THEN                         !   Update runoff   ! 
    121          !                                                !-------------------! 
    122          ! 
    123                              CALL fld_read ( kt, nn_fsbc, sf_rnf   )    ! Read Runoffs data and provide it at kt 
    124          IF( ln_rnf_tem  )   CALL fld_read ( kt, nn_fsbc, sf_t_rnf )    ! idem for runoffs temperature if required 
    125          IF( ln_rnf_sal  )   CALL fld_read ( kt, nn_fsbc, sf_s_rnf )    ! idem for runoffs salinity    if required 
    126          ! 
    127          ! Runoff reduction only associated to the ORCA2_LIM configuration 
    128          ! when reading the NetCDF file runoff_1m_nomask.nc 
    129          IF( cp_cfg == 'orca' .AND. jp_cfg == 2 )   THEN 
    130             WHERE( 40._wp < gphit(:,:) .AND. gphit(:,:) < 65._wp ) 
    131                sf_rnf(1)%fnow(:,:,1) = 0.85 * sf_rnf(1)%fnow(:,:,1) 
     120      !                                            !-------------------! 
     121      !                                            !   Update runoff   ! 
     122      !                                            !-------------------! 
     123      ! 
     124      IF( .NOT. l_rnfcpl )   CALL fld_read ( kt, nn_fsbc, sf_rnf   )    ! Read Runoffs data and provide it at kt 
     125      IF(   ln_rnf_tem   )   CALL fld_read ( kt, nn_fsbc, sf_t_rnf )    ! idem for runoffs temperature if required 
     126      IF(   ln_rnf_sal   )   CALL fld_read ( kt, nn_fsbc, sf_s_rnf )    ! idem for runoffs salinity    if required 
     127      ! 
     128      ! Runoff reduction only associated to the ORCA2_LIM configuration 
     129      ! when reading the NetCDF file runoff_1m_nomask.nc 
     130      IF( cp_cfg == 'orca' .AND. jp_cfg == 2 .AND. .NOT. l_rnfcpl )   THEN 
     131         WHERE( 40._wp < gphit(:,:) .AND. gphit(:,:) < 65._wp ) 
     132            sf_rnf(1)%fnow(:,:,1) = 0.85 * sf_rnf(1)%fnow(:,:,1) 
     133         END WHERE 
     134      ENDIF 
     135      ! 
     136      IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN 
     137         ! 
     138         IF( .NOT. l_rnfcpl )   rnf(:,:) = rn_rfact * ( sf_rnf(1)%fnow(:,:,1) )       ! updated runoff value at time step kt 
     139         ! 
     140         !                                                     ! set temperature & salinity content of runoffs 
     141         IF( ln_rnf_tem ) THEN                                       ! use runoffs temperature data 
     142            rnf_tsc(:,:,jp_tem) = ( sf_t_rnf(1)%fnow(:,:,1) ) * rnf(:,:) * r1_rau0 
     143            WHERE( sf_t_rnf(1)%fnow(:,:,1) == -999._wp )             ! if missing data value use SST as runoffs temperature 
     144               rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0 
    132145            END WHERE 
    133          ENDIF 
    134          ! 
    135          IF( MOD( kt - 1, nn_fsbc ) == 0 ) THEN 
    136             ! 
    137             rnf(:,:) = rn_rfact * ( sf_rnf(1)%fnow(:,:,1) )       ! updated runoff value at time step kt 
    138             ! 
    139             !                                                     ! set temperature & salinity content of runoffs 
    140             IF( ln_rnf_tem ) THEN                                       ! use runoffs temperature data 
    141                rnf_tsc(:,:,jp_tem) = ( sf_t_rnf(1)%fnow(:,:,1) ) * rnf(:,:) * r1_rau0 
    142                WHERE( sf_t_rnf(1)%fnow(:,:,1) == -999._wp )             ! if missing data value use SST as runoffs temperature 
    143                    rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0 
    144                END WHERE 
    145                WHERE( sf_t_rnf(1)%fnow(:,:,1) == -222._wp )             ! where fwf comes from melting of ice shelves or iceberg 
    146                    ztfrz(:,:) = -1.9 !tfreez( sss_m(:,:) ) !PM to be discuss (trouble if sensitivity study) 
    147                    rnf_tsc(:,:,jp_tem) = ztfrz(:,:) * rnf(:,:) * r1_rau0 - rnf(:,:) * lfusisf * r1_rau0_rcp 
    148                END WHERE 
    149             ELSE                                                        ! use SST as runoffs temperature 
    150                rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0 
    151             ENDIF 
    152             !                                                           ! use runoffs salinity data 
    153             IF( ln_rnf_sal )   rnf_tsc(:,:,jp_sal) = ( sf_s_rnf(1)%fnow(:,:,1) ) * rnf(:,:) * r1_rau0 
    154             !                                                           ! else use S=0 for runoffs (done one for all in the init) 
    155             IF ( ANY( rnf(:,:) < 0._wp ) ) z_err=1 
    156             IF(lk_mpp) CALL mpp_sum(z_err) 
    157             IF( z_err > 0 ) CALL ctl_stop( 'sbc_rnf : negative runnoff values exist' ) 
    158             ! 
    159             CALL iom_put( "runoffs", rnf )         ! output runoffs arrays 
    160          ENDIF 
    161          ! 
    162       ENDIF 
    163       ! 
     146            WHERE( sf_t_rnf(1)%fnow(:,:,1) == -222._wp )             ! where fwf comes from melting of ice shelves or iceberg 
     147               ztfrz(:,:) = -1.9 !tfreez( sss_m(:,:) ) !PM to be discuss (trouble if sensitivity study) 
     148               rnf_tsc(:,:,jp_tem) = ztfrz(:,:) * rnf(:,:) * r1_rau0 - rnf(:,:) * lfusisf * r1_rau0_rcp 
     149            END WHERE 
     150         ELSE                                                        ! use SST as runoffs temperature 
     151            rnf_tsc(:,:,jp_tem) = sst_m(:,:) * rnf(:,:) * r1_rau0 
     152         ENDIF 
     153         !                                                           ! use runoffs salinity data 
     154         IF( ln_rnf_sal )   rnf_tsc(:,:,jp_sal) = ( sf_s_rnf(1)%fnow(:,:,1) ) * rnf(:,:) * r1_rau0 
     155         !                                                           ! else use S=0 for runoffs (done one for all in the init) 
     156         CALL iom_put( "runoffs", rnf )         ! output runoffs arrays 
     157      ENDIF 
     158      ! 
     159      !                                                ! ---------------------------------------- ! 
    164160      IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    ! 
    165161         !                                             ! ---------------------------------------- ! 
     
    172168         ELSE                                                   !* no restart: set from nit000 values 
    173169            IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields set to nit000' 
    174              rnf_b    (:,:  ) = rnf    (:,:  ) 
    175              rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:) 
     170            rnf_b    (:,:  ) = rnf    (:,:  ) 
     171            rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:) 
    176172         ENDIF 
    177173      ENDIF 
     
    187183         CALL iom_rstput( kt, nitrst, numrow, 'rnf_sc_b', rnf_tsc(:,:,jp_sal) ) 
    188184      ENDIF 
     185      ! 
    189186      CALL wrk_dealloc( jpi,jpj, ztfrz) 
    190187      ! 
     
    265262      REAL(wp), DIMENSION(:,:  ), ALLOCATABLE :: zrnf 
    266263      ! 
    267       NAMELIST/namsbc_rnf/ cn_dir, ln_rnf_emp, ln_rnf_depth, ln_rnf_tem, ln_rnf_sal,   & 
     264      NAMELIST/namsbc_rnf/ cn_dir            , ln_rnf_depth, ln_rnf_tem, ln_rnf_sal,   & 
    268265         &                 sn_rnf, sn_cnf    , sn_s_rnf    , sn_t_rnf  , sn_dep_rnf,   & 
    269266         &                 ln_rnf_mouth      , rn_hrnf     , rn_avt_rnf, rn_rfact,     & 
     
    290287         WRITE(numout,*) '~~~~~~~ ' 
    291288         WRITE(numout,*) '   Namelist namsbc_rnf' 
    292          WRITE(numout,*) '      runoff in a file to be read                ln_rnf_emp   = ', ln_rnf_emp 
    293289         WRITE(numout,*) '      specific river mouths treatment            ln_rnf_mouth = ', ln_rnf_mouth 
    294290         WRITE(numout,*) '      river mouth additional Kz                  rn_avt_rnf   = ', rn_avt_rnf 
     
    296292         WRITE(numout,*) '      multiplicative factor for runoff           rn_rfact     = ', rn_rfact 
    297293      ENDIF 
    298       ! 
    299294      !                                   ! ================== 
    300295      !                                   !   Type of runoff 
     
    303298      IF( sbc_rnf_alloc() /= 0 )   CALL ctl_stop( 'STOP', 'sbc_rnf_alloc : unable to allocate arrays' ) 
    304299      ! 
    305       IF( ln_rnf_emp ) THEN                     !==  runoffs directly provided in the precipitations  ==! 
    306          IF(lwp) WRITE(numout,*) 
    307          IF(lwp) WRITE(numout,*) '          runoffs directly provided in the precipitations' 
    308          IF( ln_rnf_depth .OR. ln_rnf_tem .OR. ln_rnf_sal .OR. ln_rnf_depth_ini ) THEN 
    309            CALL ctl_warn( 'runoffs already included in precipitations, so runoff (T,S, depth) attributes will not be used' ) 
    310            ln_rnf_depth = .FALSE.   ;   ln_rnf_tem = .FALSE.   ;   ln_rnf_sal = .FALSE.  ;   ln_rnf_depth_ini = .FALSE. 
    311          ENDIF 
    312          ! 
    313       ELSE                                      !==  runoffs read in a file : set sf_rnf structure  ==! 
    314          ! 
     300      IF( .NOT. l_rnfcpl ) THEN                     
    315301         ALLOCATE( sf_rnf(1), STAT=ierror )         ! Create sf_rnf structure (runoff inflow) 
    316302         IF(lwp) WRITE(numout,*) 
     
    321307         ALLOCATE( sf_rnf(1)%fnow(jpi,jpj,1)   ) 
    322308         IF( sn_rnf%ln_tint ) ALLOCATE( sf_rnf(1)%fdta(jpi,jpj,1,2) ) 
    323          !                                          ! fill sf_rnf with the namelist (sn_rnf) and control print 
    324309         CALL fld_fill( sf_rnf, (/ sn_rnf /), cn_dir, 'sbc_rnf_init', 'read runoffs data', 'namsbc_rnf' ) 
    325          ! 
    326          IF( ln_rnf_tem ) THEN                      ! Create (if required) sf_t_rnf structure 
    327             IF(lwp) WRITE(numout,*) 
    328             IF(lwp) WRITE(numout,*) '          runoffs temperatures read in a file' 
    329             ALLOCATE( sf_t_rnf(1), STAT=ierror  ) 
    330             IF( ierror > 0 ) THEN 
    331                CALL ctl_stop( 'sbc_rnf_init: unable to allocate sf_t_rnf structure' )   ;   RETURN 
    332             ENDIF 
    333             ALLOCATE( sf_t_rnf(1)%fnow(jpi,jpj,1)   ) 
    334             IF( sn_t_rnf%ln_tint ) ALLOCATE( sf_t_rnf(1)%fdta(jpi,jpj,1,2) ) 
    335             CALL fld_fill (sf_t_rnf, (/ sn_t_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff temperature data', 'namsbc_rnf' ) 
    336          ENDIF 
    337          ! 
    338          IF( ln_rnf_sal  ) THEN                     ! Create (if required) sf_s_rnf and sf_t_rnf structures 
    339             IF(lwp) WRITE(numout,*) 
    340             IF(lwp) WRITE(numout,*) '          runoffs salinities read in a file' 
    341             ALLOCATE( sf_s_rnf(1), STAT=ierror  ) 
    342             IF( ierror > 0 ) THEN 
    343                CALL ctl_stop( 'sbc_rnf_init: unable to allocate sf_s_rnf structure' )   ;   RETURN 
    344             ENDIF 
    345             ALLOCATE( sf_s_rnf(1)%fnow(jpi,jpj,1)   ) 
    346             IF( sn_s_rnf%ln_tint ) ALLOCATE( sf_s_rnf(1)%fdta(jpi,jpj,1,2) ) 
    347             CALL fld_fill (sf_s_rnf, (/ sn_s_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff salinity data', 'namsbc_rnf' ) 
    348          ENDIF 
    349          ! 
    350          IF( ln_rnf_depth ) THEN                    ! depth of runoffs set from a file 
    351             IF(lwp) WRITE(numout,*) 
    352             IF(lwp) WRITE(numout,*) '          runoffs depth read in a file' 
    353             rn_dep_file = TRIM( cn_dir )//TRIM( sn_dep_rnf%clname ) 
    354             IF( .NOT. sn_dep_rnf%ln_clim ) THEN   ;   WRITE(rn_dep_file, '(a,"_y",i4)' ) TRIM( rn_dep_file ), nyear    ! add year  
    355                IF( sn_dep_rnf%cltype == 'monthly' )   WRITE(rn_dep_file, '(a,"m",i2)'  ) TRIM( rn_dep_file ), nmonth   ! add month  
    356             ENDIF  
    357             CALL iom_open ( rn_dep_file, inum )                           ! open file 
    358             CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, h_rnf )   ! read the river mouth array 
    359             CALL iom_close( inum )                                        ! close file 
    360             ! 
    361             nk_rnf(:,:) = 0                               ! set the number of level over which river runoffs are applied 
    362             DO jj = 1, jpj 
    363                DO ji = 1, jpi 
    364                   IF( h_rnf(ji,jj) > 0._wp ) THEN 
    365                      jk = 2 
    366                      DO WHILE ( jk /= mbkt(ji,jj) .AND. gdept_0(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1 ;  END DO 
    367                      nk_rnf(ji,jj) = jk 
    368                   ELSEIF( h_rnf(ji,jj) == -1._wp   ) THEN   ;  nk_rnf(ji,jj) = 1 
    369                   ELSEIF( h_rnf(ji,jj) == -999._wp ) THEN   ;  nk_rnf(ji,jj) = mbkt(ji,jj) 
    370                   ELSE 
    371                      CALL ctl_stop( 'sbc_rnf_init: runoff depth not positive, and not -999 or -1, rnf value in file fort.999'  ) 
    372                      WRITE(999,*) 'ji, jj, h_rnf(ji,jj) :', ji, jj, h_rnf(ji,jj) 
    373                   ENDIF 
     310      ENDIF 
     311      ! 
     312      IF( ln_rnf_tem ) THEN                      ! Create (if required) sf_t_rnf structure 
     313         IF(lwp) WRITE(numout,*) 
     314         IF(lwp) WRITE(numout,*) '          runoffs temperatures read in a file' 
     315         ALLOCATE( sf_t_rnf(1), STAT=ierror  ) 
     316         IF( ierror > 0 ) THEN 
     317            CALL ctl_stop( 'sbc_rnf_init: unable to allocate sf_t_rnf structure' )   ;   RETURN 
     318         ENDIF 
     319         ALLOCATE( sf_t_rnf(1)%fnow(jpi,jpj,1)   ) 
     320         IF( sn_t_rnf%ln_tint ) ALLOCATE( sf_t_rnf(1)%fdta(jpi,jpj,1,2) ) 
     321         CALL fld_fill (sf_t_rnf, (/ sn_t_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff temperature data', 'namsbc_rnf' ) 
     322      ENDIF 
     323      ! 
     324      IF( ln_rnf_sal  ) THEN                     ! Create (if required) sf_s_rnf and sf_t_rnf structures 
     325         IF(lwp) WRITE(numout,*) 
     326         IF(lwp) WRITE(numout,*) '          runoffs salinities read in a file' 
     327         ALLOCATE( sf_s_rnf(1), STAT=ierror  ) 
     328         IF( ierror > 0 ) THEN 
     329            CALL ctl_stop( 'sbc_rnf_init: unable to allocate sf_s_rnf structure' )   ;   RETURN 
     330         ENDIF 
     331         ALLOCATE( sf_s_rnf(1)%fnow(jpi,jpj,1)   ) 
     332         IF( sn_s_rnf%ln_tint ) ALLOCATE( sf_s_rnf(1)%fdta(jpi,jpj,1,2) ) 
     333         CALL fld_fill (sf_s_rnf, (/ sn_s_rnf /), cn_dir, 'sbc_rnf_init', 'read runoff salinity data', 'namsbc_rnf' ) 
     334      ENDIF 
     335      ! 
     336      IF( ln_rnf_depth ) THEN                    ! depth of runoffs set from a file 
     337         IF(lwp) WRITE(numout,*) 
     338         IF(lwp) WRITE(numout,*) '          runoffs depth read in a file' 
     339         rn_dep_file = TRIM( cn_dir )//TRIM( sn_dep_rnf%clname ) 
     340         IF( .NOT. sn_dep_rnf%ln_clim ) THEN   ;   WRITE(rn_dep_file, '(a,"_y",i4)' ) TRIM( rn_dep_file ), nyear    ! add year  
     341            IF( sn_dep_rnf%cltype == 'monthly' )   WRITE(rn_dep_file, '(a,"m",i2)'  ) TRIM( rn_dep_file ), nmonth   ! add month  
     342         ENDIF 
     343         CALL iom_open ( rn_dep_file, inum )                           ! open file 
     344         CALL iom_get  ( inum, jpdom_data, sn_dep_rnf%clvar, h_rnf )   ! read the river mouth array 
     345         CALL iom_close( inum )                                        ! close file 
     346         ! 
     347         nk_rnf(:,:) = 0                               ! set the number of level over which river runoffs are applied 
     348         DO jj = 1, jpj 
     349            DO ji = 1, jpi 
     350               IF( h_rnf(ji,jj) > 0._wp ) THEN 
     351                  jk = 2 
     352                  DO WHILE ( jk /= mbkt(ji,jj) .AND. gdept_0(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1 
     353                  END DO 
     354                  nk_rnf(ji,jj) = jk 
     355               ELSEIF( h_rnf(ji,jj) == -1._wp   ) THEN   ;  nk_rnf(ji,jj) = 1 
     356               ELSEIF( h_rnf(ji,jj) == -999._wp ) THEN   ;  nk_rnf(ji,jj) = mbkt(ji,jj) 
     357               ELSE 
     358                  CALL ctl_stop( 'sbc_rnf_init: runoff depth not positive, and not -999 or -1, rnf value in file fort.999'  ) 
     359                  WRITE(999,*) 'ji, jj, h_rnf(ji,jj) :', ji, jj, h_rnf(ji,jj) 
     360               ENDIF 
     361            END DO 
     362         END DO 
     363         DO jj = 1, jpj                                ! set the associated depth 
     364            DO ji = 1, jpi 
     365               h_rnf(ji,jj) = 0._wp 
     366               DO jk = 1, nk_rnf(ji,jj) 
     367                  h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk) 
    374368               END DO 
    375369            END DO 
    376             DO jj = 1, jpj                                ! set the associated depth 
    377                DO ji = 1, jpi 
    378                   h_rnf(ji,jj) = 0._wp 
    379                   DO jk = 1, nk_rnf(ji,jj) 
    380                      h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk) 
     370         END DO 
     371         ! 
     372      ELSE IF( ln_rnf_depth_ini ) THEN           ! runoffs applied at the surface 
     373         ! 
     374         IF(lwp) WRITE(numout,*) 
     375         IF(lwp) WRITE(numout,*) '    depth of runoff computed once from max value of runoff' 
     376         IF(lwp) WRITE(numout,*) '    max value of the runoff climatologie (over global domain) rn_rnf_max = ', rn_rnf_max 
     377         IF(lwp) WRITE(numout,*) '    depth over which runoffs is spread                        rn_dep_max = ', rn_dep_max 
     378         IF(lwp) WRITE(numout,*) '     create (=1) a runoff depth file or not (=0)      nn_rnf_depth_file  = ', nn_rnf_depth_file 
     379 
     380         CALL iom_open( TRIM( sn_rnf%clname ), inum )    !  open runoff file 
     381         CALL iom_gettime( inum, zrec, kntime=nbrec) 
     382         ALLOCATE( zrnfcl(jpi,jpj,nbrec) )     ;      ALLOCATE( zrnf(jpi,jpj) ) 
     383         DO jm = 1, nbrec 
     384            CALL iom_get( inum, jpdom_data, TRIM( sn_rnf%clvar ), zrnfcl(:,:,jm), jm ) 
     385         END DO 
     386         CALL iom_close( inum ) 
     387         zrnf(:,:) = MAXVAL( zrnfcl(:,:,:), DIM=3 )   !  maximum value in time 
     388         DEALLOCATE( zrnfcl ) 
     389         ! 
     390         h_rnf(:,:) = 1. 
     391         ! 
     392         zacoef = rn_dep_max / rn_rnf_max            ! coef of linear relation between runoff and its depth (150m for max of runoff) 
     393         ! 
     394         WHERE( zrnf(:,:) > 0._wp )  h_rnf(:,:) = zacoef * zrnf(:,:)   ! compute depth for all runoffs 
     395         ! 
     396         DO jj = 1, jpj                     ! take in account min depth of ocean rn_hmin 
     397            DO ji = 1, jpi 
     398               IF( zrnf(ji,jj) > 0._wp ) THEN 
     399                  jk = mbkt(ji,jj) 
     400                  h_rnf(ji,jj) = MIN( h_rnf(ji,jj), gdept_0(ji,jj,jk ) ) 
     401               ENDIF 
     402            END DO 
     403         END DO 
     404         ! 
     405         nk_rnf(:,:) = 0                       ! number of levels on which runoffs are distributed 
     406         DO jj = 1, jpj 
     407            DO ji = 1, jpi 
     408               IF( zrnf(ji,jj) > 0._wp ) THEN 
     409                  jk = 2 
     410                  DO WHILE ( jk /= mbkt(ji,jj) .AND. gdept_0(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1 
    381411                  END DO 
     412                  nk_rnf(ji,jj) = jk 
     413               ELSE 
     414                  nk_rnf(ji,jj) = 1 
     415               ENDIF 
     416            END DO 
     417         END DO 
     418         ! 
     419         DEALLOCATE( zrnf ) 
     420         ! 
     421         DO jj = 1, jpj                                ! set the associated depth 
     422            DO ji = 1, jpi 
     423               h_rnf(ji,jj) = 0._wp 
     424               DO jk = 1, nk_rnf(ji,jj) 
     425                  h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk) 
    382426               END DO 
    383427            END DO 
    384             ! 
    385          ELSE IF( ln_rnf_depth_ini ) THEN           ! runoffs applied at the surface 
    386             ! 
    387             IF(lwp) WRITE(numout,*) 
    388             IF(lwp) WRITE(numout,*) '    depth of runoff computed once from max value of runoff' 
    389             IF(lwp) WRITE(numout,*) '    max value of the runoff climatologie (over global domain) rn_rnf_max = ', rn_rnf_max 
    390             IF(lwp) WRITE(numout,*) '    depth over which runoffs is spread                        rn_dep_max = ', rn_dep_max 
    391             IF(lwp) WRITE(numout,*) '     create (=1) a runoff depth file or not (=0)      nn_rnf_depth_file  = ', nn_rnf_depth_file 
    392  
    393             CALL iom_open( TRIM( sn_rnf%clname ), inum )    !  open runoff file 
    394             CALL iom_gettime( inum, zrec, kntime=nbrec) 
    395             ALLOCATE( zrnfcl(jpi,jpj,nbrec) )     ;      ALLOCATE( zrnf(jpi,jpj) ) 
    396             DO jm = 1, nbrec 
    397                CALL iom_get( inum, jpdom_data, TRIM( sn_rnf%clvar ), zrnfcl(:,:,jm), jm ) 
    398             END DO 
    399             CALL iom_close( inum ) 
    400             zrnf(:,:) = MAXVAL( zrnfcl(:,:,:), DIM=3 )   !  maximum value in time 
    401             DEALLOCATE( zrnfcl ) 
    402             ! 
    403             h_rnf(:,:) = 1. 
    404             ! 
    405             zacoef = rn_dep_max / rn_rnf_max            ! coef of linear relation between runoff and its depth (150m for max of runoff) 
    406             ! 
    407             WHERE( zrnf(:,:) > 0._wp )  h_rnf(:,:) = zacoef * zrnf(:,:)   ! compute depth for all runoffs 
    408             ! 
    409             DO jj = 1, jpj                     ! take in account min depth of ocean rn_hmin 
    410                DO ji = 1, jpi 
    411                   IF( zrnf(ji,jj) > 0._wp ) THEN 
    412                      jk = mbkt(ji,jj) 
    413                      h_rnf(ji,jj) = MIN( h_rnf(ji,jj), gdept_0(ji,jj,jk ) ) 
    414                   ENDIF 
    415                END DO 
    416             END DO 
    417             ! 
    418             nk_rnf(:,:) = 0                       ! number of levels on which runoffs are distributed 
    419             DO jj = 1, jpj 
    420                DO ji = 1, jpi 
    421                    IF( zrnf(ji,jj) > 0._wp ) THEN 
    422                      jk = 2 
    423                      DO WHILE ( jk /= mbkt(ji,jj) .AND. gdept_0(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1 ;  END DO 
    424                      nk_rnf(ji,jj) = jk 
    425                    ELSE 
    426                      nk_rnf(ji,jj) = 1 
    427                    ENDIF 
    428                 END DO 
    429             END DO 
    430             ! 
    431             DEALLOCATE( zrnf ) 
    432             ! 
    433             DO jj = 1, jpj                                ! set the associated depth 
    434                DO ji = 1, jpi 
    435                   h_rnf(ji,jj) = 0._wp 
    436                   DO jk = 1, nk_rnf(ji,jj) 
    437                      h_rnf(ji,jj) = h_rnf(ji,jj) + fse3t(ji,jj,jk) 
    438                   END DO 
    439                END DO 
    440             END DO 
    441             ! 
    442             IF( nn_rnf_depth_file == 1 ) THEN      !  save  output nb levels for runoff 
    443                IF(lwp) WRITE(numout,*) '              create runoff depht file' 
    444                CALL iom_open  ( TRIM( sn_dep_rnf%clname ), inum, ldwrt = .TRUE., kiolib = jprstlib ) 
    445                CALL iom_rstput( 0, 0, inum, 'rodepth', h_rnf ) 
    446                CALL iom_close ( inum ) 
    447             ENDIF 
    448          ELSE                                       ! runoffs applied at the surface 
    449             nk_rnf(:,:) = 1 
    450             h_rnf (:,:) = fse3t(:,:,1) 
    451          ENDIF 
    452          ! 
     428         END DO 
     429         ! 
     430         IF( nn_rnf_depth_file == 1 ) THEN      !  save  output nb levels for runoff 
     431            IF(lwp) WRITE(numout,*) '              create runoff depht file' 
     432            CALL iom_open  ( TRIM( sn_dep_rnf%clname ), inum, ldwrt = .TRUE., kiolib = jprstlib ) 
     433            CALL iom_rstput( 0, 0, inum, 'rodepth', h_rnf ) 
     434            CALL iom_close ( inum ) 
     435         ENDIF 
     436      ELSE                                       ! runoffs applied at the surface 
     437         nk_rnf(:,:) = 1 
     438         h_rnf (:,:) = fse3t(:,:,1) 
    453439      ENDIF 
    454440      ! 
     
    471457         IF( rn_hrnf > 0._wp ) THEN 
    472458            nkrnf = 2 
    473             DO WHILE( nkrnf /= jpkm1 .AND. gdepw_1d(nkrnf+1) < rn_hrnf )   ;   nkrnf = nkrnf + 1   ;   END DO 
     459            DO WHILE( nkrnf /= jpkm1 .AND. gdepw_1d(nkrnf+1) < rn_hrnf )   ;   nkrnf = nkrnf + 1 
     460            END DO 
    474461            IF( ln_sco )   CALL ctl_warn( 'sbc_rnf: number of levels over which Kz is increased is computed for zco...' ) 
    475462         ENDIF 
Note: See TracChangeset for help on using the changeset viewer.