Version 2 (modified by acc, 6 years ago) (diff)

svn copy svn+ssh://acc@forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk   \
         svn+ssh://acc@forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/branches/2015/dev_r5087_NOC2_JATTR \
               -m"#1472. Temporary development branch for testing use of file attributes to control starting j-row from input netcdf files"

Committed revision 5088.

svn co svn+ssh://acc@forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/branches/2015/dev_r5087_NOC2_JATTR

Submit first stage changes (introduces option for bathymetry and coordinates only)

 svn status
M       CONFIG/SHARED/namelist_ref
M       NEMO/OFF_SRC/nemogcm.F90
M       NEMO/OOO_SRC/nemogcm.F90
M       NEMO/OPA_SRC/DOM/domhgr.F90
M       NEMO/OPA_SRC/DOM/domzgr.F90
M       NEMO/OPA_SRC/IOM/iom.F90
M       NEMO/OPA_SRC/LBC/mppini_2.h90
M       NEMO/OPA_SRC/nemogcm.F90
M       NEMO/OPA_SRC/par_oce.F90
M       NEMO/SAS_SRC/nemogcm.F90


svn diff
Index: CONFIG/SHARED/namelist_ref
===================================================================
--- CONFIG/SHARED/namelist_ref  (revision 5088)
+++ CONFIG/SHARED/namelist_ref  (working copy)
@@ -75,6 +75,8 @@
                                        !  = 4 cyclic East-West AND North fold T-point pivot
                                        !  = 5 North fold F-point pivot
                                        !  = 6 cyclic East-West AND North fold F-point pivot
+   ln_use_jattr = .false.              !  use (T) the file attribute: open_ocean_jstart, if present 
+                                       !  in netcdf input files, as the start j-row for reading
 /
 !-----------------------------------------------------------------------
 &namzgr        !   vertical coordinate
Index: NEMO/OFF_SRC/nemogcm.F90
===================================================================
--- NEMO/OFF_SRC/nemogcm.F90    (revision 5088)
+++ NEMO/OFF_SRC/nemogcm.F90    (working copy)
@@ -148,7 +148,7 @@
          &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_bench, nn_timing
       NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg, jpidta, jpjdta, jpkdta, jpiglo, jpjglo, &
-         &             jpizoom, jpjzoom, jperio
+         &             jpizoom, jpjzoom, jperio, ln_use_jattr
       !!----------------------------------------------------------------------
       cltxt = ''
       !
@@ -358,6 +358,7 @@
          WRITE(numout,*) '      left bottom i index of the zoom (in data domain) jpizoom = ', jpizoom
          WRITE(numout,*) '      left bottom j index of the zoom (in data domain) jpizoom = ', jpjzoom
          WRITE(numout,*) '      lateral cond. type (between 0 and 6) jperio = ', jperio   
+         WRITE(numout,*) '      use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr
       ENDIF
       !                             ! Parameter control
       !
Index: NEMO/OOO_SRC/nemogcm.F90
===================================================================
--- NEMO/OOO_SRC/nemogcm.F90    (revision 5088)
+++ NEMO/OOO_SRC/nemogcm.F90    (working copy)
@@ -128,7 +128,7 @@
          &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_bench, nn_timing
       NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg, jpidta, jpjdta, jpkdta, jpiglo, jpjglo, &
-         &             jpizoom, jpjzoom, jperio
+         &             jpizoom, jpjzoom, jperio, ln_use_jattr
       !!----------------------------------------------------------------------
       !
       cltxt = ''
Index: NEMO/OPA_SRC/DOM/domhgr.F90
===================================================================
--- NEMO/OPA_SRC/DOM/domhgr.F90 (revision 5088)
+++ NEMO/OPA_SRC/DOM/domhgr.F90 (working copy)
@@ -615,25 +615,25 @@
       
       CALL iom_open( 'coordinates', inum )
       
-      CALL iom_get( inum, jpdom_data, 'glamt', glamt )
-      CALL iom_get( inum, jpdom_data, 'glamu', glamu )
-      CALL iom_get( inum, jpdom_data, 'glamv', glamv )
-      CALL iom_get( inum, jpdom_data, 'glamf', glamf )
+      CALL iom_get( inum, jpdom_data, 'glamt', glamt, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'glamu', glamu, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'glamv', glamv, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'glamf', glamf, lrowattr=ln_use_jattr )
       
-      CALL iom_get( inum, jpdom_data, 'gphit', gphit )
-      CALL iom_get( inum, jpdom_data, 'gphiu', gphiu )
-      CALL iom_get( inum, jpdom_data, 'gphiv', gphiv )
-      CALL iom_get( inum, jpdom_data, 'gphif', gphif )
+      CALL iom_get( inum, jpdom_data, 'gphit', gphit, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'gphiu', gphiu, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'gphiv', gphiv, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'gphif', gphif, lrowattr=ln_use_jattr )
       
-      CALL iom_get( inum, jpdom_data, 'e1t', e1t )
-      CALL iom_get( inum, jpdom_data, 'e1u', e1u )
-      CALL iom_get( inum, jpdom_data, 'e1v', e1v )
-      CALL iom_get( inum, jpdom_data, 'e1f', e1f )
+      CALL iom_get( inum, jpdom_data, 'e1t', e1t, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e1u', e1u, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e1v', e1v, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e1f', e1f, lrowattr=ln_use_jattr )
       
-      CALL iom_get( inum, jpdom_data, 'e2t', e2t )
-      CALL iom_get( inum, jpdom_data, 'e2u', e2u )
-      CALL iom_get( inum, jpdom_data, 'e2v', e2v )
-      CALL iom_get( inum, jpdom_data, 'e2f', e2f )
+      CALL iom_get( inum, jpdom_data, 'e2t', e2t, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e2u', e2u, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e2v', e2v, lrowattr=ln_use_jattr )
+      CALL iom_get( inum, jpdom_data, 'e2f', e2f, lrowattr=ln_use_jattr )
       
       CALL iom_close( inum )
       
Index: NEMO/OPA_SRC/DOM/domzgr.F90
===================================================================
--- NEMO/OPA_SRC/DOM/domzgr.F90 (revision 5088)
+++ NEMO/OPA_SRC/DOM/domzgr.F90 (working copy)
@@ -533,7 +533,11 @@
          ENDIF
          IF( ln_zps .OR. ln_sco )   THEN              ! zps or sco : read meter bathymetry
             CALL iom_open ( 'bathy_meter.nc', inum ) 
-            CALL iom_get  ( inum, jpdom_data, 'Bathymetry', bathy )
+            IF ( ln_isfcav ) THEN
+               CALL iom_get  ( inum, jpdom_data, 'Bathymetry_isf', bathy, lrowattr=.false. )
+            ELSE
+               CALL iom_get  ( inum, jpdom_data, 'Bathymetry'    , bathy, lrowattr=ln_use_jattr  )
+            END IF
             CALL iom_close( inum )
             !  
             risfdep(:,:)=0._wp         
Index: NEMO/OPA_SRC/IOM/iom.F90
===================================================================
--- NEMO/OPA_SRC/IOM/iom.F90    (revision 5088)
+++ NEMO/OPA_SRC/IOM/iom.F90    (working copy)
@@ -542,7 +542,7 @@
       ENDIF
    END SUBROUTINE iom_g1d
 
-   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+   SUBROUTINE iom_g2d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr )
       INTEGER         , INTENT(in   )                           ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                           ::   kdom      ! Type of domain to be read
       CHARACTER(len=*), INTENT(in   )                           ::   cdvar     ! Name of the variable
@@ -550,14 +550,19 @@
       INTEGER         , INTENT(in   )                , OPTIONAL ::   ktime     ! record number
       INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(2)  , OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   )                , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to
+                                                                               ! look for and use a file attribute
+                                                                               ! called open_ocean_jstart to set the start
+                                                                               ! value for the 2nd dimension (netcdf only)
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r2d=pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
+              &                                                     lrowattr=lrowattr )
       ENDIF
    END SUBROUTINE iom_g2d
 
-   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
+   SUBROUTINE iom_g3d( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, lrowattr )
       INTEGER         , INTENT(in   )                             ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                             ::   kdom      ! Type of domain to be read
       CHARACTER(len=*), INTENT(in   )                             ::   cdvar     ! Name of the variable
@@ -565,17 +570,23 @@
       INTEGER         , INTENT(in   )                  , OPTIONAL ::   ktime     ! record number
       INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(3)    , OPTIONAL ::   kcount    ! number of points in each axis
+      LOGICAL         , INTENT(in   )                  , OPTIONAL ::   lrowattr  ! logical flag telling iom_get to
+                                                                                 ! look for and use a file attribute
+                                                                                 ! called open_ocean_jstart to set the start
+                                                                                 ! value for the 2nd dimension (netcdf only)
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r3d=pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
+              &                                                     lrowattr=lrowattr )
       ENDIF
    END SUBROUTINE iom_g3d
    !!----------------------------------------------------------------------
 
    SUBROUTINE iom_get_123d( kiomid, kdom  , cdvar ,   &
          &                  pv_r1d, pv_r2d, pv_r3d,   &
-         &                  ktime , kstart, kcount  )
+         &                  ktime , kstart, kcount,   &
+         &                  lrowattr                )
       !!-----------------------------------------------------------------------
       !!                  ***  ROUTINE  iom_get_123d  ***
       !!
@@ -592,8 +603,14 @@
       INTEGER                    , INTENT(in   ), OPTIONAL ::   ktime      ! record number
       INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart     ! start position of the reading in each axis 
       INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis
+      LOGICAL                    , INTENT(in   ), OPTIONAL ::   lrowattr   ! logical flag telling iom_get to
+                                                                           ! look for and use a file attribute
+                                                                           ! called open_ocean_jstart to set the start
+                                                                           ! value for the 2nd dimension (netcdf only)
       !
       LOGICAL                        ::   llnoov      ! local definition to read overlap
+      LOGICAL                        ::   luse_jattr  ! local definition to read open_ocean_jstart file attribute
+      INTEGER                        ::   jstartrow   ! start point for 2nd dimension optionally set by file attribute
       INTEGER                        ::   jl          ! loop on number of dimension 
       INTEGER                        ::   idom        ! type of domain
       INTEGER                        ::   idvar       ! id of the variable
@@ -603,7 +620,7 @@
       INTEGER                        ::   istop       ! temporary value of nstop
       INTEGER                        ::   ix1, ix2, iy1, iy2   ! subdomain indexes
       INTEGER                        ::   ji, jj      ! loop counters
-      INTEGER                        ::   irankpv       ! 
+      INTEGER                        ::   irankpv     ! 
       INTEGER                        ::   ind1, ind2  ! substring index
       INTEGER, DIMENSION(jpmax_dims) ::   istart      ! starting point to read for each axis
       INTEGER, DIMENSION(jpmax_dims) ::   icnt        ! number of value to read along each axis 
@@ -628,6 +645,23 @@
       IF( PRESENT(kstart) .AND. (.NOT. PRESENT(kcount)) ) CALL ctl_stop(trim(clinfo), 'kstart present needs kcount present')
       IF( PRESENT(kstart) .AND. idom /= jpdom_unknown   ) CALL ctl_stop(trim(clinfo), 'kstart present needs kdom = jpdom_unknown')
 
+      luse_jattr = .false.
+      IF( PRESENT(lrowattr) ) THEN
+         IF( lrowattr .AND. idom /= jpdom_data   ) CALL ctl_stop(trim(clinfo), 'lrowattr present and true needs kdom = jpdom_data')
+         IF( lrowattr .AND. idom == jpdom_data   ) luse_jattr = .true.
+      ENDIF
+      IF( luse_jattr ) THEN
+         SELECT CASE (iom_file(kiomid)%iolib)
+         CASE (jpioipsl, jprstdimg )
+             CALL ctl_warn(trim(clinfo), 'lrowattr present and true but this only works with netcdf (jpnf90)')
+             luse_jattr = .false.
+         CASE (jpnf90   )   
+             ! Ok
+         CASE DEFAULT    
+            CALL ctl_stop( TRIM(clinfo)//' accepted IO library are only jpioipsl, jpnf90 and jprstdimg' )
+         END SELECT
+      ENDIF
+
       ! Search for the variable in the data base (eventually actualize data)
       istop = nstop
       idvar = iom_varid( kiomid, cdvar )
@@ -700,8 +734,14 @@
             IF(           idom == jpdom_unknown ) THEN                                       ; icnt(1:idmspc) = idimsz(1:idmspc)
             ELSE 
                IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array
-                  IF(     idom == jpdom_data    ) THEN ; istart(1:2) = (/ mig(1), mjg(1) /)  ! icnt(1:2) done bellow
-                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done bellow
+                  IF(     idom == jpdom_data    ) THEN
+                     jstartrow = 1
+                     IF( luse_jattr ) THEN
+                        CALL iom_getatt(kiomid, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found
+                        jstartrow = MAX(1,jstartrow)
+                     ENDIF
+                     istart(1:2) = (/ mig(1), mjg(1) + jstartrow - 1 /)  ! icnt(1:2) done below
+                  ELSEIF( idom == jpdom_global  ) THEN ; istart(1:2) = (/ nimpp , njmpp  /)  ! icnt(1:2) done below
                   ENDIF
                   ! we do not read the overlap                     -> we start to read at nldi, nldj
 ! JMM + SM: ugly patch before getting the new version of lib_mpp)
Index: NEMO/OPA_SRC/LBC/mppini_2.h90
===================================================================
--- NEMO/OPA_SRC/LBC/mppini_2.h90       (revision 5088)
+++ NEMO/OPA_SRC/LBC/mppini_2.h90       (working copy)
@@ -44,6 +44,7 @@
       INTEGER :: ji, jj, jn, jproc, jarea     ! dummy loop indices
       INTEGER ::  inum                        ! temporary logical unit
       INTEGER ::  idir                        ! temporary integers
+      INTEGER ::  jstartrow                   ! temporary integers
       INTEGER ::   ios                        ! Local integer output status for namelist read
       INTEGER ::   &
          ii, ij, ifreq, il1, il2,          &  ! temporary integers
@@ -99,13 +100,26 @@
 
       ! open the file
       ! Remember that at this level in the code, mpp is not yet initialized, so
-      ! the file must be open with jpdom_unknown, and kstart amd kcount forced 
+      ! the file must be open with jpdom_unknown, and kstart and kcount forced 
+      jstartrow = 1
       IF ( ln_zco ) THEN 
          CALL iom_open ( 'bathy_level.nc', inum )   ! Level bathymetry
-         CALL iom_get ( inum, jpdom_unknown, 'Bathy_level', zdta, kstart=(/jpizoom,jpjzoom/), kcount=(/jpiglo,jpjglo/) )
+          ! Optionally use a file attribute (open_ocean_jstart) to set a start row for reading from the global file
+          ! This allows the unextended grid bathymetry to be stored in the same file as the under ice-shelf extended bathymetry
+         CALL iom_getatt(inum, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found
+         jstartrow = MAX(1,jstartrow)
+         CALL iom_get ( inum, jpdom_unknown, 'Bathy_level', zdta, kstart=(/jpizoom,jpjzoom+jstartrow-1/), kcount=(/jpiglo,jpjglo/) )
       ELSE
          CALL iom_open ( 'bathy_meter.nc', inum )   ! Meter bathy in case of partial steps
-         CALL iom_get ( inum, jpdom_unknown, 'Bathymetry' , zdta, kstart=(/jpizoom,jpjzoom/), kcount=(/jpiglo,jpjglo/) )
+         IF ( ln_isfcav ) THEN
+             CALL iom_get ( inum, jpdom_unknown, 'Bathymetry_isf' , zdta, kstart=(/jpizoom,jpjzoom/), kcount=(/jpiglo,jpjglo/) )
+         ELSE
+             ! Optionally use a file attribute (open_ocean_jstart) to set a start row for reading from the global file
+             ! This allows the unextended grid bathymetry to be stored in the same file as the under ice-shelf extended bathymetry
+             CALL iom_getatt(inum, 'open_ocean_jstart', jstartrow ) ! -999 is returned if the attribute is not found
+             jstartrow = MAX(1,jstartrow)
+             CALL iom_get ( inum, jpdom_unknown, 'Bathymetry' , zdta, kstart=(/jpizoom,jpjzoom+jstartrow-1/), kcount=(/jpiglo,jpjglo/) )
+         ENDIF
       ENDIF
       CALL iom_close (inum)
       
Index: NEMO/OPA_SRC/nemogcm.F90
===================================================================
--- NEMO/OPA_SRC/nemogcm.F90    (revision 5088)
+++ NEMO/OPA_SRC/nemogcm.F90    (working copy)
@@ -221,7 +221,7 @@
          &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_bench, nn_timing
       NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg, jpidta, jpjdta, jpkdta, jpiglo, jpjglo, &
-         &             jpizoom, jpjzoom, jperio
+         &             jpizoom, jpjzoom, jperio, ln_use_jattr
       !!----------------------------------------------------------------------
       !
       cltxt = ''
@@ -260,6 +260,7 @@
       jpjzoom = 1
       nperio  = 0
       jperio  = 0
+      ln_use_jattr = .false.
    ENDIF
 #endif
       !
@@ -505,6 +506,7 @@
          WRITE(numout,*) '      left bottom i index of the zoom (in data domain) jpizoom = ', jpizoom
          WRITE(numout,*) '      left bottom j index of the zoom (in data domain) jpizoom = ', jpjzoom
          WRITE(numout,*) '      lateral cond. type (between 0 and 6) jperio = ', jperio   
+         WRITE(numout,*) '      use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr
       ENDIF
       !                             ! Parameter control
       !
Index: NEMO/OPA_SRC/par_oce.F90
===================================================================
--- NEMO/OPA_SRC/par_oce.F90    (revision 5088)
+++ NEMO/OPA_SRC/par_oce.F90    (working copy)
@@ -52,6 +52,13 @@
    !                                       !  = 5 North fold F-point pivot
    !                                       !  = 6 cyclic East-West AND North fold F-point pivot
 
+   ! Input file read offset
+   LOGICAL       ::   ln_use_jattr     !: Use file global attribute: open_ocean_jstart to determine start j-row 
+                                           ! when reading input from those netcdf files that have the 
+                                           ! attribute defined. This is designed to enable input files associated 
+                                           ! with the extended grids used in the under ice shelf configurations to 
+                                           ! be used without redundant rows when the ice shelves are not in use.
+
    !!  Values set to pp_not_used indicates that this parameter is not used in THIS config.
    !!  Values set to pp_to_be_computed  indicates that variables will be computed in domzgr
    REAL(wp)      ::   pp_not_used       = 999999._wp   !: vertical grid parameter
Index: NEMO/SAS_SRC/nemogcm.F90
===================================================================
--- NEMO/SAS_SRC/nemogcm.F90    (revision 5088)
+++ NEMO/SAS_SRC/nemogcm.F90    (working copy)
@@ -160,7 +160,7 @@
          &             nn_isplt, nn_jsplt, nn_jctls, nn_jctle,   &
          &             nn_bench, nn_timing
       NAMELIST/namcfg/ cp_cfg, cp_cfz, jp_cfg, jpidta, jpjdta, jpkdta, jpiglo, jpjglo, &
-         &             jpizoom, jpjzoom, jperio
+         &             jpizoom, jpjzoom, jperio, ln_use_jattr
       !!----------------------------------------------------------------------
       cltxt = ''
       !
@@ -347,6 +347,7 @@
          WRITE(numout,*) '      left bottom i index of the zoom (in data domain) jpizoom = ', jpizoom
          WRITE(numout,*) '      left bottom j index of the zoom (in data domain) jpizoom = ', jpjzoom
          WRITE(numout,*) '      lateral cond. type (between 0 and 6) jperio = ', jperio   
+         WRITE(numout,*) '      use file attribute if exists as i/p j-start ln_use_jattr = ', ln_use_jattr
       ENDIF
       !                             ! Parameter control
       !