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 5409 for branches/2014/dev_r5134_UKMO4_CF_compliance – NEMO

Ignore:
Timestamp:
2015-06-12T17:40:01+02:00 (9 years ago)
Author:
hadcv
Message:
  • Add new domain definition for global scalars and restore old generic scalar domain removed in [4689]
    • Global scalars now reference the new domain, the rest reference the generic domain
  • Rewrite set_grid_bounds a bit to avoid allocating 4 2D arrays
Location:
branches/2014/dev_r5134_UKMO4_CF_compliance/NEMOGCM
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r5134_UKMO4_CF_compliance/NEMOGCM/CONFIG/SHARED/domain_def.xml

    r5350 r5409  
    55    <!--   My zoom: example of hand defined zoom   --> 
    66         <domain id="myzoom" zoom_ibegin="10" zoom_jbegin="10" zoom_ni="5" zoom_nj="5" /> 
    7          <domain id="1point" zoom_ibegin="10" zoom_jbegin="10" zoom_ni="1" zoom_nj="1" /> 
    87         <domain id="ptr" zoom_ibegin="0000"  zoom_jbegin="1" zoom_ni="1" zoom_nj="0000" /> 
    98         <!--   Eq section   --> 
     
    170169      </domain_group> 
    171170 
    172       <domain_group id="scalarpoint"> 
    173          <domain id="scalarpoint" long_name="scalar"/> 
    174          <!-- 
    175          <domain id="1point" zoom_ibegin="1" zoom_jbegin="1" zoom_ni="1" zoom_nj="1" /> 
    176          --> 
     171      <domain_group id="scalarpoint" long_name="scalar" zoom_ibegin="1" zoom_jbegin="1" zoom_ni="1" zoom_nj="1"> 
     172         <domain id="1point"/> 
     173         <domain id="globalscalar" /> 
    177174      </domain_group> 
    178175 
  • branches/2014/dev_r5134_UKMO4_CF_compliance/NEMOGCM/CONFIG/SHARED/field_def.xml

    r5350 r5409  
    451451      <!-- scalar variables available with key_diaar5 --> 
    452452 
    453       <field_group id="scalar"  domain_ref="1point" > 
     453      <field_group id="scalar"  domain_ref="globalscalar" > 
    454454         <field id="voltot"     long_name="global total volume"                          standard_name="sea_water_volume"                               unit="m3"   /> 
    455455         <field id="sshtot"     long_name="global mean ssh"                              standard_name="global_average_sea_level_change"                unit="m"    /> 
     
    459459         <field id="temptot"    long_name="global mean temperature"                      standard_name="sea_water_potential_temperature"                unit="degC" /> 
    460460         <field id="saltot"     long_name="global mean salinity"                         standard_name="sea_water_salinity"                             unit="1e-3" /> 
    461          <field id="fram_trans" long_name="Sea Ice Mass Transport Through Fram Strait"   standard_name="sea_ice_transport_across_line"                  unit="kg/s" /> 
     461         <field id="fram_trans" long_name="Sea Ice Mass Transport Through Fram Strait"   standard_name="sea_ice_transport_across_line"                  unit="kg/s"   domain_ref="1point" /> 
    462462 
    463463          <!-- available with ln_diahsb --> 
     
    480480      <!-- LIM3 scalar variables --> 
    481481 
    482       <field_group id="SBC_scalar"  domain_ref="1point" > 
     482      <field_group id="SBC_scalar"  domain_ref="globalscalar" > 
    483483         <!-- available with ln_limdiaout --> 
    484484         <field id="ibgvoltot"    long_name="global mean ice volume"                                 unit="km3"        /> 
     
    881881     </field_group> 
    882882 
    883      <field_group id="PISCES_scalar"  domain_ref="1point" > 
     883     <field_group id="PISCES_scalar"  domain_ref="globalscalar" > 
    884884       <field id="pno3tot"         long_name="global mean nitrate concentration"                  unit="mol/m3"   /> 
    885885       <field id="psiltot"         long_name="global mean silicate concentration"                 unit="mol/m3"   /> 
  • branches/2014/dev_r5134_UKMO4_CF_compliance/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90

    r5406 r5409  
    127127         CALL set_grid( "W", glamt, gphit ) 
    128128         ! 
    129          IF( ln_cfmeta ) THEN   ! Add cell areas 
     129         IF( ln_cfmeta ) THEN   ! Add additional grid metadata 
    130130            CALL iom_set_domain_attr("grid_T", area = e12t(nldi:nlei, nldj:nlej)) 
    131131            CALL iom_set_domain_attr("grid_U", area = e12u(nldi:nlei, nldj:nlej)) 
    132132            CALL iom_set_domain_attr("grid_V", area = e12v(nldi:nlei, nldj:nlej)) 
    133133            CALL iom_set_domain_attr("grid_W", area = e12t(nldi:nlei, nldj:nlej)) 
     134            CALL set_grid_bounds( "T", glamf, gphif, glamt, gphit )  
     135            CALL set_grid_bounds( "U", glamv, gphiv, glamu, gphiu ) 
     136            CALL set_grid_bounds( "V", glamu, gphiu, glamv, gphiv ) 
     137            CALL set_grid_bounds( "W", glamf, gphif, glamt, gphit ) 
    134138         ENDIF 
    135139      ENDIF 
     
    145149         CALL dom_grid_glo   ! Return to parent grid domain 
    146150         ! 
    147          IF( ln_cfmeta ) THEN   ! Add cell areas 
     151         IF( ln_cfmeta ) THEN   ! Add additional grid metadata 
    148152            CALL iom_set_domain_attr("grid_T", area = e1e2t_crs(nldi:nlei, nldj:nlej)) 
    149153            CALL iom_set_domain_attr("grid_U", area = e1u_crs(nldi:nlei, nldj:nlej) * e2u_crs(nldi:nlei, nldj:nlej)) 
    150154            CALL iom_set_domain_attr("grid_V", area = e1v_crs(nldi:nlei, nldj:nlej) * e2v_crs(nldi:nlei, nldj:nlej)) 
    151155            CALL iom_set_domain_attr("grid_W", area = e1e2t_crs(nldi:nlei, nldj:nlej)) 
    152          ENDIF 
    153       ENDIF 
    154  
    155       IF ( ln_cfmeta ) THEN   ! Add horizontal grid bounds 
    156          CALL set_grid_bounds( "T", cdname )  
    157          CALL set_grid_bounds( "U", cdname ) 
    158          CALL set_grid_bounds( "V", cdname ) 
    159          CALL set_grid_bounds( "W", cdname ) 
     156            CALL set_grid_bounds( "T", glamf_crs, gphif_crs, glamt_crs, gphit_crs )  
     157            CALL set_grid_bounds( "U", glamv_crs, gphiv_crs, glamu_crs, gphiu_crs ) 
     158            CALL set_grid_bounds( "V", glamu_crs, gphiu_crs, glamv_crs, gphiv_crs ) 
     159            CALL set_grid_bounds( "W", glamf_crs, gphif_crs, glamt_crs, gphit_crs ) 
     160         ENDIF 
    160161      ENDIF 
    161162 
     
    11011102      CHARACTER(LEN=*), INTENT(in) ::   cdname 
    11021103      REAL(wp)        , INTENT(in) ::   pfield0d 
    1103       REAL(wp)        , DIMENSION(jpi,jpj) ::   zz     ! masson 
    11041104#if defined key_iomput 
    1105       zz(:,:)=pfield0d 
    1106       CALL xios_send_field(cdname, zz) 
    1107       !CALL xios_send_field(cdname, (/pfield0d/))  
     1105      CALL xios_send_field(cdname, (/pfield0d/))  
    11081106#else 
    11091107      IF( .FALSE. )   WRITE(numout,*) cdname, pfield0d   ! useless test to avoid compilation warnings 
     
    13001298 
    13011299 
    1302    SUBROUTINE set_grid_bounds( cdgrd, cdname ) 
     1300   SUBROUTINE set_grid_bounds( cdgrd, plon_cnr, plat_cnr, plon_pnt, plat_pnt ) 
    13031301      !!---------------------------------------------------------------------- 
    13041302      !!                   ***  ROUTINE set_grid_bounds  *** 
     
    13081306      !!---------------------------------------------------------------------- 
    13091307      CHARACTER(LEN=1) , INTENT(in) :: cdgrd 
    1310       CHARACTER(LEN=*) , INTENT(in) :: cdname 
     1308      ! 
     1309      REAL(wp), DIMENSION(jpi,jpj), INTENT(in)           :: plon_cnr, plat_cnr  ! Lat/lon coordinates of a contiguous vertex of cell (i,j) 
     1310      REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt  ! Lat/lon coordinates of the point of cell (i,j) 
    13111311      ! 
    13121312      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:)   :: z_bnds      ! Lat/lon coordinates of the vertices of cell (i,j) 
    1313       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)     :: z_cnr       ! Lat/lon coordinates of a contiguous vertex of cell (i,j) 
    1314       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:)     :: z_pnt       ! Lat/lon coordinates of the point of cell (i,j) 
    13151313      REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_fld       ! Working array to determine where to rotate cells 
    13161314      REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_rot       ! Lat/lon working array for rotation of cells 
     
    13201318      INTEGER :: ji, jj, jn, ni, nj 
    13211319 
    1322       ALLOCATE( z_bnds(4,jpi,jpj,2), z_cnr(jpi,jpj,2), z_pnt(jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2)  ) 
    1323  
    1324       ! Grid information 
     1320      ALLOCATE( z_bnds(4,jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2)  ) 
     1321 
     1322      ! Offset of coordinate representing bottom-left corner 
    13251323      SELECT CASE ( TRIM(cdgrd) ) 
    13261324         CASE ('T', 'W') 
    13271325            icnr = -1 ; jcnr = -1 
    1328             IF( TRIM(cdname) == "nemo_crs" ) THEN 
    1329                z_cnr(:,:,1) = gphif_crs ; z_cnr(:,:,2) = glamf_crs 
    1330                z_pnt(:,:,1) = gphit_crs ; z_pnt(:,:,2) = glamt_crs 
    1331             ELSE 
    1332                z_cnr(:,:,1) = gphif ; z_cnr(:,:,2) = glamf 
    1333                z_pnt(:,:,1) = gphit ; z_pnt(:,:,2) = glamt 
    1334             ENDIF 
    13351326         CASE ('U') 
    13361327            icnr =  0 ; jcnr = -1 
    1337             IF( TRIM(cdname) == "nemo_crs" ) THEN 
    1338                z_cnr(:,:,1) = gphiv_crs ; z_cnr(:,:,2) = glamv_crs 
    1339                z_pnt(:,:,1) = gphiu_crs ; z_pnt(:,:,2) = glamu_crs 
    1340             ELSE 
    1341                z_cnr(:,:,1) = gphiv ; z_cnr(:,:,2) = glamv 
    1342                z_pnt(:,:,1) = gphiu ; z_pnt(:,:,2) = glamu 
    1343             ENDIF 
    13441328         CASE ('V') 
    13451329            icnr = -1 ; jcnr =  0 
    1346             IF( TRIM(cdname) == "nemo_crs" ) THEN 
    1347                z_cnr(:,:,1) = gphiu_crs ; z_cnr(:,:,2) = glamu_crs 
    1348                z_pnt(:,:,1) = gphiv_crs ; z_pnt(:,:,2) = glamv_crs 
    1349             ELSE 
    1350                z_cnr(:,:,1) = gphiu ; z_cnr(:,:,2) = glamu 
    1351                z_pnt(:,:,1) = gphiv ; z_pnt(:,:,2) = glamv 
    1352             ENDIF 
    13531330      END SELECT 
    13541331 
     
    13611338      DO jj = 2, jpjm1 
    13621339         DO ji = 2, jpim1 
    1363             z_bnds(1,ji,jj,:) = z_cnr(ji+icnr,  jj+jcnr  ,:) ! Bottom-left 
    1364             z_bnds(2,ji,jj,:) = z_cnr(ji+icnr+1,jj+jcnr  ,:) ! Bottom-right 
    1365             z_bnds(3,ji,jj,:) = z_cnr(ji+icnr+1,jj+jcnr+1,:) ! Top-right 
    1366             z_bnds(4,ji,jj,:) = z_cnr(ji+icnr,  jj+jcnr+1,:) ! Top-left 
     1340            z_bnds(1,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left 
     1341            z_bnds(2,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right 
     1342            z_bnds(3,ji,jj,1) = plat_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right 
     1343            z_bnds(4,ji,jj,1) = plat_cnr(ji+icnr,  jj+jcnr+1) ! Top-left 
     1344            z_bnds(1,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr  ) ! Bottom-left 
     1345            z_bnds(2,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr  ) ! Bottom-right 
     1346            z_bnds(3,ji,jj,2) = plon_cnr(ji+icnr+1,jj+jcnr+1) ! Top-right 
     1347            z_bnds(4,ji,jj,2) = plon_cnr(ji+icnr,  jj+jcnr+1) ! Top-left 
    13671348         END DO 
    13681349      END DO 
     
    13741355      END DO 
    13751356 
    1376       ! Zero-size cells at closed boundaries 
    1377       IF( (nbondi == -1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN 
    1378          DO jn = 1, 4  ;  z_bnds(jn,1,:,:) = z_pnt(1,:,:)        ;  END DO      ! (West or jpni = 1), closed E-W 
    1379       ENDIF 
    1380       IF( (nbondi == 1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN 
    1381          DO jn = 1, 4  ;  z_bnds(jn,nlci,:,:) = z_pnt(nlci,:,:)  ;  END DO      ! (East or jpni = 1), closed E-W 
    1382       ENDIF 
    1383       IF( nbondj == -1 .OR. (nbondj == 2 .AND. jperio /= 2) ) THEN 
    1384          DO jn = 1, 4  ;  z_bnds(jn,:,1,:) = z_pnt(:,1,:)        ;  END DO      ! South or (jpnj = 1, not symmetric) 
    1385       ENDIF 
    1386       IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio  < 3 ) THEN 
    1387          DO jn = 1, 4  ;  z_bnds(jn,:,nlcj,:) = z_pnt(:,nlcj,:)  ;  END DO      ! (North or jpnj = 1), no north fold 
     1357      ! Zero-size cells at closed boundaries if cell points provided, 
     1358      ! otherwise they are closed cells with unrealistic bounds 
     1359      IF( PRESENT(plon_pnt) .AND. PRESENT(plat_pnt) ) THEN 
     1360         IF( (nbondi == -1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN 
     1361            DO jn = 1, 4        ! (West or jpni = 1), closed E-W 
     1362               z_bnds(jn,1,:,1) = plat_pnt(1,:)  ;  z_bnds(jn,1,:,2) = plon_pnt(1,:) 
     1363            END DO 
     1364         ENDIF 
     1365         IF( (nbondi == 1 .OR. nbondi == 2) .AND. .NOT. (jperio == 1 .OR. jperio == 4 .OR. jperio == 6) ) THEN 
     1366            DO jn = 1, 4        ! (East or jpni = 1), closed E-W 
     1367               z_bnds(jn,nlci,:,1) = plat_pnt(nlci,:)  ;  z_bnds(jn,nlci,:,2) = plon_pnt(nlci,:) 
     1368            END DO 
     1369         ENDIF 
     1370         IF( nbondj == -1 .OR. (nbondj == 2 .AND. jperio /= 2) ) THEN 
     1371            DO jn = 1, 4        ! South or (jpnj = 1, not symmetric) 
     1372               z_bnds(jn,:,1,1) = plat_pnt(:,1)  ;  z_bnds(jn,:,1,2) = plon_pnt(:,1) 
     1373            END DO 
     1374         ENDIF 
     1375         IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio  < 3 ) THEN 
     1376            DO jn = 1, 4        ! (North or jpnj = 1), no north fold 
     1377               z_bnds(jn,:,nlcj,1) = plat_pnt(:,nlcj)  ;  z_bnds(jn,:,nlcj,2) = plon_pnt(:,nlcj) 
     1378            END DO 
     1379         ENDIF 
    13881380      ENDIF 
    13891381 
     
    14121404                                               bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 ) 
    14131405 
    1414       DEALLOCATE( z_bnds, z_cnr, z_pnt, z_fld, z_rot )  
     1406      DEALLOCATE( z_bnds, z_fld, z_rot )  
    14151407 
    14161408   END SUBROUTINE set_grid_bounds 
     
    14241416      !! 
    14251417      !!---------------------------------------------------------------------- 
    1426       REAL(wp), DIMENSION(1) ::   zz = 1. 
     1418      REAL(wp), DIMENSION(1)   ::   zz = 0. 
     1419      REAL(wp), DIMENSION(4,1) ::   z_lat, z_lon 
    14271420      !!---------------------------------------------------------------------- 
    14281421      CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea, jbegin=1, ni=1, nj=1) 
    14291422      CALL iom_set_domain_attr('scalarpoint', data_dim=2, data_ibegin = 1, data_ni = 1, data_jbegin = 1, data_nj = 1) 
     1423       
     1424      z_lon(1,:) = MINVAL(glamt) ; z_lon(2,:) = MAXVAL(glamt) ; z_lon(3,:) = MAXVAL(glamt) ; z_lon(4,:) = MINVAL(glamt) 
     1425      z_lat(1,:) = MINVAL(gphit) ; z_lat(2,:) = MINVAL(gphit) ; z_lat(3,:) = MAXVAL(gphit) ; z_lat(4,:) = MAXVAL(gphit) 
     1426 
     1427      IF( lk_mpp ) THEN 
     1428         CALL mpp_min( z_lon(1,1) ) ; CALL mpp_min( z_lon(4,1) ) ; CALL mpp_max( z_lon(2,1) ) ; CALL mpp_max( z_lon(3,1) ) 
     1429         CALL mpp_min( z_lat(1,1) ) ; CALL mpp_min( z_lat(2,1) ) ; CALL mpp_max( z_lat(3,1) ) ; CALL mpp_max( z_lat(4,1) ) 
     1430      ENDIF 
     1431 
     1432      CALL iom_set_domain_attr('globalscalar', lonvalue=zz, latvalue=zz, bounds_lon=z_lon, bounds_lat=z_lat, nvertex=4) 
     1433 
    14301434      zz=REAL(narea,wp) 
    1431       CALL iom_set_domain_attr('scalarpoint', lonvalue=zz, latvalue=zz) 
     1435      CALL iom_set_domain_attr('1point', lonvalue=zz, latvalue=zz) 
    14321436 
    14331437   END SUBROUTINE set_scalar 
Note: See TracChangeset for help on using the changeset viewer.