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 11066 for branches/UKMO/AMM15_v3_6_STABLE_package_reanalysis3/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90 – NEMO

Ignore:
Timestamp:
2019-05-28T18:00:55+02:00 (5 years ago)
Author:
rrenshaw
Message:

changes to add regional means output and correction for section transports

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/UKMO/AMM15_v3_6_STABLE_package_reanalysis3/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90

    r8058 r11066  
    5656   PUBLIC iom_getatt, iom_use, iom_context_finalize 
    5757 
     58   INTEGER , PUBLIC ::   n_regions_output 
     59 
    5860   PRIVATE iom_rp0d, iom_rp1d, iom_rp2d, iom_rp3d 
    5961   PRIVATE iom_g0d, iom_g1d, iom_g2d, iom_g3d, iom_get_123d 
     
    106108      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: z_bnds 
    107109      !!---------------------------------------------------------------------- 
     110       
     111       
     112       
     113       
     114       
     115      REAL(wp),  ALLOCATABLE,   DIMENSION(:,:) ::   tmpregion !: temporary region_mask 
     116      INTEGER, DIMENSION(3) ::   zdimsz   ! number of elements in each of the 3 dimensions (i.e., lon, lat, no of masks, 297,  375,  4) for an array 
     117      INTEGER               ::   zndims   ! number of dimensions in an array (i.e. 3, ) 
     118      INTEGER :: inum, nmasks,ierr,maskno,idmaskvar,tmpint 
     119      REAL(wp), ALLOCATABLE,   DIMENSION(:,:,:)  ::   tmp_region_mask_real   ! tempory region_mask of reals 
     120       
     121      LOGICAL ::   ln_diaregmean  ! region mean calculation 
     122    
     123     
     124      INTEGER ::   ios                  ! Local integer output status for namelist read 
     125      LOGICAL :: ln_diaregmean_ascii  ! region mean calculation ascii output 
     126      LOGICAL :: ln_diaregmean_bin  ! region mean calculation binary output 
     127      LOGICAL :: ln_diaregmean_nc  ! region mean calculation netcdf output 
     128      LOGICAL :: ln_diaregmean_karamld  ! region mean calculation including kara mld terms 
     129      LOGICAL :: ln_diaregmean_pea  ! region mean calculation including pea terms 
     130      LOGICAL :: ln_diaregmean_diaar5  ! region mean calculation including AR5 SLR terms 
     131      LOGICAL :: ln_diaregmean_diasbc  ! region mean calculation including Surface BC 
     132     
     133#if defined key_fabm 
     134      LOGICAL :: ln_diaregmean_bgc  ! region mean calculation including BGC 
     135#endif 
     136      ! Read the number region mask to work out how many regions are needed. 
     137       
     138#if defined key_fabm 
     139      NAMELIST/nam_diaregmean/ ln_diaregmean,ln_diaregmean_ascii,ln_diaregmean_bin,ln_diaregmean_nc,& 
     140        & ln_diaregmean_karamld, ln_diaregmean_pea,ln_diaregmean_diaar5,ln_diaregmean_diasbc,ln_diaregmean_bgc 
     141#else 
     142      NAMELIST/nam_diaregmean/ ln_diaregmean,ln_diaregmean_ascii,ln_diaregmean_bin,ln_diaregmean_nc,& 
     143        & ln_diaregmean_karamld, ln_diaregmean_pea,ln_diaregmean_diaar5,ln_diaregmean_diasbc 
     144#endif 
     145       
     146      ! read in Namelist.  
     147      !!---------------------------------------------------------------------- 
     148      ! 
     149      REWIND ( numnam_ref )              ! Read Namelist nam_diatmb in referdiatmbence namelist : TMB diagnostics 
     150      READ   ( numnam_ref, nam_diaregmean, IOSTAT=ios, ERR= 901 ) 
     151901   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diaregmean in reference namelist', lwp ) 
     152 
     153      REWIND( numnam_cfg )              ! Namelist nam_diatmb in configuration namelist  TMB diagnostics 
     154      READ  ( numnam_cfg, nam_diaregmean, IOSTAT = ios, ERR = 902 ) 
     155902   IF( ios /= 0 ) CALL ctl_nam ( ios , 'nam_diaregmean in configuration namelist', lwp ) 
     156      IF(lwm) WRITE ( numond, nam_diaregmean ) 
     157 
     158      IF (ln_diaregmean) THEN 
     159       
     160        ! Open region mask for region means, and retrieve the size of the mask (number of levels)           
     161          CALL iom_open ( 'region_mask.nc', inum ) 
     162          idmaskvar = iom_varid( inum, 'mask', kdimsz=zdimsz, kndims=zndims, ldstop = .FALSE.)           
     163          nmasks = zdimsz(3) 
     164           
     165          ! read in the region mask (which contains floating point numbers) into a temporary array of reals. 
     166          ALLOCATE( tmp_region_mask_real(jpi,jpj,nmasks),  STAT= ierr ) 
     167          IF( ierr /= 0 )   CALL ctl_stop( 'dia_regmean_init: failed to allocate tmp_region_mask_real array' ) 
     168           
     169          ! Use jpdom_unknown to read in a n layer mask. 
     170          tmp_region_mask_real(:,:,:) = 0 
     171          CALL iom_get( inum, jpdom_unknown, 'mask', tmp_region_mask_real(1:nlci,1:nlcj,1:nmasks),   & 
     172              &          kstart = (/ mig(1),mjg(1),1 /), kcount = (/ nlci,nlcj,nmasks /) ) 
     173           
     174          CALL iom_close( inum ) 
     175          !Convert the region mask of reals into one of integers.  
     176           
     177           
     178          n_regions_output = 0 
     179          DO maskno = 1,nmasks 
     180              tmpint = maxval(int(tmp_region_mask_real(:,:,maskno))) 
     181              CALL mpp_max( tmpint ) 
     182              n_regions_output = n_regions_output + (tmpint + 1) 
     183          END DO 
     184       
     185           
     186         
     187      ELSE 
     188        n_regions_output = 1 
     189      ENDIF 
     190       
     191       
     192       
    108193#if ! defined key_xios2 
    109194      ALLOCATE( z_bnds(jpk,2) ) 
     
    227312      CALL iom_set_axis_attr( "iax_20C", (/ REAL(20,wp) /) ) 
    228313      CALL iom_set_axis_attr( "iax_28C", (/ REAL(28,wp) /) ) 
     314       
     315       
     316       
     317      CALL iom_set_axis_attr( "region", (/ (REAL(ji,wp), ji=1,n_regions_output) /) ) 
     318 
     319      CALL iom_set_axis_attr( "noos", (/ (REAL(ji,wp), ji=1,3) /) ) 
     320 
    229321       
    230322      ! automatic definitions of some of the xml attributs 
Note: See TracChangeset for help on using the changeset viewer.