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 8427 for branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/trcrst.F90 – NEMO

Ignore:
Timestamp:
2017-08-09T12:13:16+02:00 (7 years ago)
Author:
timgraham
Message:

GMED ticket 341. Fixes found through use of preset NaNs? to make the code more robust.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/dev_r5518_GO6_package/NEMOGCM/NEMO/TOP_SRC/trcrst.F90

    r8280 r8427  
    745745      !!--------------------------------------------------------------------- 
    746746      INTEGER  :: jk, jn 
     747      CHARACTER (LEN=18) :: text_zmean 
    747748      REAL(wp) :: ztraf, zmin, zmax, zmean, areasf 
    748749      REAL(wp), DIMENSION(jpi,jpj) :: zvol 
     
    750751 
    751752      IF( lwp )  WRITE(numout,*) 'STAT- ', names 
    752       ! 
     753       
     754      ! fse3t_a will be undefined at the start of a run, but this routine 
     755      ! may be called at any stage! Hence we MUST make sure it is  
     756      ! initialised to zero when allocated to enable us to test for  
     757      ! zero content here and avoid potentially dangerous and non-portable  
     758      ! operations (e.g. divide by zero, global sums of junk values etc.)    
    753759      zvol(:,:) = e1e2t(:,:) * fse3t_a(:,:,1) * tmask(:,:,1) 
    754760      ztraf = glob_sum( dgtr(:,:) * zvol(:,:) ) 
     
    761767         CALL mpp_max( zmax )      ! max over the global domain 
    762768      END IF 
    763       zmean  = ztraf / areasf 
    764       IF(lwp) WRITE(numout,9002) TRIM( names ), zmean, zmin, zmax 
    765       ! 
    766       IF(lwp) WRITE(numout,*) 
    767 9002  FORMAT(' tracer name :',a10,'    mean :',e18.10,'    min :',e18.10, & 
     769 
     770      text_zmean = "N/A" 
     771      ! Avoid divide by zero. areasf must be positive. 
     772      IF  (areasf > 0.0) THEN  
     773         zmean = ztraf / areasf 
     774         WRITE(text_zmean,'(e18.10)') zmean 
     775      ENDIF 
     776 
     777      IF(lwp) WRITE(numout,9002) TRIM( names ), text_zmean, zmin, zmax 
     778 
     779  9002  FORMAT(' tracer name :',A,'    mean :',A,'    min :',e18.10, & 
    768780      &      '    max :',e18.10 ) 
    769781      ! 
Note: See TracChangeset for help on using the changeset viewer.