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 10523 for NEMO/trunk – NEMO

Changeset 10523 for NEMO/trunk


Ignore:
Timestamp:
2019-01-16T10:36:03+01:00 (5 years ago)
Author:
smasson
Message:

trunk: avoid the allocation of potentialy large array in sbcrnf, see #2212

Location:
NEMO/trunk/src/OCE
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • NEMO/trunk/src/OCE/IOM/iom.F90

    r10522 r10523  
    13541354      iom_getszuld = -1 
    13551355      IF( kiomid > 0 ) THEN 
    1356          IF( iom_file(kiomid)%iduld .GE. 0 ) THEN 
    1357             iom_getszuld = iom_file(kiomid)%lenuld 
    1358          ENDIF 
     1356         IF( iom_file(kiomid)%iduld > 0 )   iom_getszuld = iom_file(kiomid)%lenuld 
    13591357      ENDIF 
    13601358   END FUNCTION iom_getszuld 
  • NEMO/trunk/src/OCE/SBC/sbcrnf.F90

    r10522 r10523  
    240240      INTEGER           ::   nbrec         ! temporary integer 
    241241      REAL(wp)          ::   zacoef   
    242       REAL(wp), DIMENSION(:,:,:), ALLOCATABLE :: zrnfcl     
    243       REAL(wp), DIMENSION(:,:  ), ALLOCATABLE :: zrnf 
     242      REAL(wp), DIMENSION(jpi,jpj,2) :: zrnfcl     
    244243      !! 
    245244      NAMELIST/namsbc_rnf/ cn_dir            , ln_rnf_depth, ln_rnf_tem, ln_rnf_sal,   & 
     
    372371         CALL iom_open( TRIM( sn_rnf%clname ), inum )    !  open runoff file 
    373372         nbrec = iom_getszuld( inum ) 
    374          ALLOCATE( zrnfcl(jpi,jpj,nbrec) )     ;      ALLOCATE( zrnf(jpi,jpj) ) 
     373         zrnfcl(:,:,1) = 0._wp                                                          ! init the max to 0. in 1 
    375374         DO jm = 1, nbrec 
    376             CALL iom_get( inum, jpdom_data, TRIM( sn_rnf%clvar ), zrnfcl(:,:,jm), jm ) 
     375            CALL iom_get( inum, jpdom_data, TRIM( sn_rnf%clvar ), zrnfcl(:,:,2), jm )   ! read the value in 2 
     376            zrnfcl(:,:,1) = MAXVAL( zrnfcl(:,:,:), DIM=3 )                              ! store the maximum value in time in 1 
    377377         END DO 
    378378         CALL iom_close( inum ) 
    379          zrnf(:,:) = MAXVAL( zrnfcl(:,:,:), DIM=3 )   !  maximum value in time 
    380          DEALLOCATE( zrnfcl ) 
    381379         ! 
    382380         h_rnf(:,:) = 1. 
     
    384382         zacoef = rn_dep_max / rn_rnf_max            ! coef of linear relation between runoff and its depth (150m for max of runoff) 
    385383         ! 
    386          WHERE( zrnf(:,:) > 0._wp )  h_rnf(:,:) = zacoef * zrnf(:,:)   ! compute depth for all runoffs 
     384         WHERE( zrnfcl(:,:,1) > 0._wp )  h_rnf(:,:) = zacoef * zrnfcl(:,:,1)   ! compute depth for all runoffs 
    387385         ! 
    388386         DO jj = 1, jpj                     ! take in account min depth of ocean rn_hmin 
    389387            DO ji = 1, jpi 
    390                IF( zrnf(ji,jj) > 0._wp ) THEN 
     388               IF( zrnfcl(ji,jj,1) > 0._wp ) THEN 
    391389                  jk = mbkt(ji,jj) 
    392390                  h_rnf(ji,jj) = MIN( h_rnf(ji,jj), gdept_0(ji,jj,jk ) ) 
     
    398396         DO jj = 1, jpj 
    399397            DO ji = 1, jpi 
    400                IF( zrnf(ji,jj) > 0._wp ) THEN 
     398               IF( zrnfcl(ji,jj,1) > 0._wp ) THEN 
    401399                  jk = 2 
    402400                  DO WHILE ( jk /= mbkt(ji,jj) .AND. gdept_0(ji,jj,jk) < h_rnf(ji,jj) ) ;  jk = jk + 1 
     
    408406            END DO 
    409407         END DO 
    410          ! 
    411          DEALLOCATE( zrnf ) 
    412408         ! 
    413409         DO jj = 1, jpj                                ! set the associated depth 
Note: See TracChangeset for help on using the changeset viewer.