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 7646 for trunk/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90 – NEMO

Ignore:
Timestamp:
2017-02-06T10:25:03+01:00 (7 years ago)
Author:
timgraham
Message:

Merge of dev_merge_2016 into trunk. UPDATE TO ARCHFILES NEEDED for XIOS2.
LIM_SRC_s/limrhg.F90 to follow in next commit due to change of kind (I'm unable to do it in this commit).
Merged using the following steps:

1) svn merge --reintegrate svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk .
2) Resolve minor conflicts in sette.sh and namelist_cfg for ORCA2LIM3 (due to a change in trunk after branch was created)
3) svn commit
4) svn switch svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/trunk
5) svn merge svn+ssh://forge.ipsl.jussieu.fr/ipsl/forge/projets/nemo/svn/branches/2016/dev_merge_2016 .
6) At this stage I checked out a clean copy of the branch to compare against what is about to be committed to the trunk.
6) svn commit #Commit code to the trunk

In this commit I have also reverted a change to Fcheck_archfile.sh which was causing problems on the Paris machine.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90

    r6140 r7646  
    77   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO 
    88   !!             "   ! 07 07  (D. Storkey) Changes to iom_nf90_gettime 
     9   !!            3.6  ! 2015-15  (J. Harle) Added procedure to read REAL attributes 
    910   !!-------------------------------------------------------------------- 
    1011   !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes 
     
    2930 
    3031   PUBLIC iom_nf90_open, iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput 
    31    PUBLIC iom_nf90_getatt 
     32   PUBLIC iom_nf90_getatt, iom_nf90_putatt 
    3233 
    3334   INTERFACE iom_nf90_get 
     
    3536   END INTERFACE 
    3637   INTERFACE iom_nf90_getatt 
    37       MODULE PROCEDURE iom_nf90_intatt 
     38      MODULE PROCEDURE iom_nf90_giatt, iom_nf90_gratt, iom_nf90_gcatt 
     39   END INTERFACE 
     40   INTERFACE iom_nf90_putatt 
     41      MODULE PROCEDURE iom_nf90_piatt, iom_nf90_pratt, iom_nf90_pcatt 
    3842   END INTERFACE 
    3943   INTERFACE iom_nf90_rstput 
     
    252256   END FUNCTION iom_nf90_varid 
    253257 
     258   !!---------------------------------------------------------------------- 
     259   !!                   INTERFACE iom_nf90_get 
     260   !!---------------------------------------------------------------------- 
    254261 
    255262   SUBROUTINE iom_nf90_g0d( kiomid, kvid, pvar, kstart ) 
     
    312319   END SUBROUTINE iom_nf90_g123d 
    313320 
    314  
    315    SUBROUTINE iom_nf90_intatt( kiomid, cdatt, pvar ) 
    316       !!----------------------------------------------------------------------- 
    317       !!                  ***  ROUTINE  iom_nf90_intatt  *** 
     321   !!---------------------------------------------------------------------- 
     322   !!                   INTERFACE iom_nf90_getatt 
     323   !!---------------------------------------------------------------------- 
     324 
     325   SUBROUTINE iom_nf90_giatt( kiomid, cdatt, pv_i0d, cdvar) 
     326      !!----------------------------------------------------------------------- 
     327      !!                  ***  ROUTINE  iom_nf90_giatt  *** 
    318328      !! 
    319329      !! ** Purpose : read an integer attribute with NF90 
     330      !!              (either a global attribute (default) or a variable 
     331      !!               attribute if optional variable name is supplied (cdvar)) 
    320332      !!----------------------------------------------------------------------- 
    321333      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    322334      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
    323       INTEGER         , INTENT(  out) ::   pvar     ! read field 
     335      INTEGER         , INTENT(  out) ::   pv_i0d   ! read field 
     336      CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
     337                      &               ::   cdvar    ! name of the variable 
    324338      ! 
    325339      INTEGER                         ::   if90id   ! temporary integer 
     340      INTEGER                         ::   ivarid   ! NetCDF variable Id 
    326341      LOGICAL                         ::   llok     ! temporary logical 
    327342      CHARACTER(LEN=100)              ::   clinfo   ! info character 
    328343      !--------------------------------------------------------------------- 
    329       !  
     344      ! 
    330345      if90id = iom_file(kiomid)%nfid 
    331       llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 
     346      IF( PRESENT(cdvar) ) THEN 
     347         ! check the variable exists in the file 
     348         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
     349         IF( llok ) THEN 
     350            ! check the variable has the attribute required 
     351            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 
     352         ELSE 
     353            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 
     354         ENDIF 
     355      ELSE 
     356         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 
     357         ivarid = NF90_GLOBAL 
     358      ENDIF 
     359! 
    332360      IF( llok) THEN 
    333          clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt) 
    334          CALL iom_nf90_check(NF90_GET_ATT(if90id, NF90_GLOBAL, cdatt, values=pvar), clinfo) 
     361         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', giatt: '//TRIM(cdatt) 
     362         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo) 
    335363      ELSE 
    336364         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 
    337          pvar = -999 
    338       ENDIF 
    339       !  
    340    END SUBROUTINE iom_nf90_intatt 
     365         pv_i0d = -999 
     366      ENDIF 
     367      ! 
     368   END SUBROUTINE iom_nf90_giatt 
     369 
     370   SUBROUTINE iom_nf90_gratt( kiomid, cdatt, pv_r0d, cdvar) 
     371      !!----------------------------------------------------------------------- 
     372      !!                  ***  ROUTINE  iom_nf90_gratt  *** 
     373      !! 
     374      !! ** Purpose : read a real attribute with NF90 
     375      !!              (either a global attribute (default) or a variable 
     376      !!               attribute if optional variable name is supplied (cdvar)) 
     377      !!----------------------------------------------------------------------- 
     378      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     379      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
     380      REAL(wp)        , INTENT(  out) ::   pv_r0d   ! read field 
     381      CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
     382                      &               ::   cdvar    ! name of the variable 
     383      ! 
     384      INTEGER                         ::   if90id   ! temporary integer 
     385      INTEGER                         ::   ivarid   ! NetCDF variable Id 
     386      LOGICAL                         ::   llok     ! temporary logical 
     387      CHARACTER(LEN=100)              ::   clinfo   ! info character 
     388      !--------------------------------------------------------------------- 
     389      ! 
     390      if90id = iom_file(kiomid)%nfid 
     391      IF( PRESENT(cdvar) ) THEN 
     392         ! check the variable exists in the file 
     393         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
     394         IF( llok ) THEN 
     395            ! check the variable has the attribute required 
     396            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 
     397         ELSE 
     398            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 
     399         ENDIF 
     400      ELSE 
     401         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 
     402         ivarid = NF90_GLOBAL 
     403      ENDIF 
     404! 
     405      IF( llok) THEN 
     406         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gratt: '//TRIM(cdatt) 
     407         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo) 
     408      ELSE 
     409         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 
     410         pv_r0d = -999._wp 
     411      ENDIF 
     412      ! 
     413   END SUBROUTINE iom_nf90_gratt 
     414 
     415   SUBROUTINE iom_nf90_gcatt( kiomid, cdatt, pv_c0d, cdvar) 
     416      !!----------------------------------------------------------------------- 
     417      !!                  ***  ROUTINE  iom_nf90_gcatt  *** 
     418      !! 
     419      !! ** Purpose : read a character attribute with NF90 
     420      !!              (either a global attribute (default) or a variable 
     421      !!               attribute if optional variable name is supplied (cdvar)) 
     422      !!----------------------------------------------------------------------- 
     423      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     424      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
     425      CHARACTER(len=*), INTENT(  out) ::   pv_c0d   ! read field 
     426      CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
     427                      &               ::   cdvar    ! name of the variable 
     428      ! 
     429      INTEGER                         ::   if90id   ! temporary integer 
     430      INTEGER                         ::   ivarid   ! NetCDF variable Id 
     431      LOGICAL                         ::   llok     ! temporary logical 
     432      CHARACTER(LEN=100)              ::   clinfo   ! info character 
     433      !--------------------------------------------------------------------- 
     434      ! 
     435      if90id = iom_file(kiomid)%nfid 
     436      IF( PRESENT(cdvar) ) THEN 
     437         ! check the variable exists in the file 
     438         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
     439         IF( llok ) THEN 
     440            ! check the variable has the attribute required 
     441            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 
     442         ELSE 
     443            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 
     444         ENDIF 
     445      ELSE 
     446         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 
     447         ivarid = NF90_GLOBAL 
     448      ENDIF 
     449! 
     450      IF( llok) THEN 
     451         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gcatt: '//TRIM(cdatt) 
     452         CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo) 
     453      ELSE 
     454         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 
     455         pv_c0d = '!' 
     456      ENDIF 
     457      ! 
     458   END SUBROUTINE iom_nf90_gcatt 
     459 
     460   !!---------------------------------------------------------------------- 
     461   !!                   INTERFACE iom_nf90_putatt 
     462   !!---------------------------------------------------------------------- 
     463 
     464   SUBROUTINE iom_nf90_piatt( kiomid, cdatt, pv_i0d, cdvar) 
     465      !!----------------------------------------------------------------------- 
     466      !!                  ***  ROUTINE  iom_nf90_piatt  *** 
     467      !! 
     468      !! ** Purpose : write an integer attribute with NF90 
     469      !!              (either a global attribute (default) or a variable 
     470      !!               attribute if optional variable name is supplied (cdvar)) 
     471      !!----------------------------------------------------------------------- 
     472      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     473      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
     474      INTEGER         , INTENT(in   ) ::   pv_i0d   ! write field 
     475      CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
     476                      &               ::   cdvar    ! name of the variable 
     477      ! 
     478      INTEGER                         ::   if90id   ! temporary integer 
     479      INTEGER                         ::   ivarid   ! NetCDF variable Id 
     480      LOGICAL                         ::   llok     ! temporary logical 
     481      LOGICAL                         ::   lenddef  ! temporary logical 
     482      CHARACTER(LEN=100)              ::   clinfo   ! info character 
     483      !--------------------------------------------------------------------- 
     484      ! 
     485      if90id = iom_file(kiomid)%nfid 
     486      lenddef = .false. 
     487      IF( PRESENT(cdvar) ) THEN 
     488         ! check the variable exists in the file 
     489         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
     490         IF( .NOT. llok ) THEN 
     491            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 
     492         ENDIF 
     493      ELSE 
     494         llok = .true. 
     495         ivarid = NF90_GLOBAL 
     496      ENDIF 
     497! 
     498      IF( llok) THEN 
     499         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', piatt: '//TRIM(cdatt) 
     500         IF( iom_file(kiomid)%irec /= -1 ) THEN    
     501            ! trick: irec used to know if the file is in define mode or not 
     502            ! if it is not then temporarily put it into define mode 
     503            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 
     504            lenddef = .true. 
     505         ENDIF 
     506         ! 
     507         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo) 
     508         ! 
     509         IF( lenddef ) THEN    
     510            ! file was in data mode on entry; put it back in that mode 
     511            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 
     512         ENDIF 
     513      ELSE 
     514         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 
     515      ENDIF 
     516      ! 
     517   END SUBROUTINE iom_nf90_piatt 
     518 
     519   SUBROUTINE iom_nf90_pratt( kiomid, cdatt, pv_r0d, cdvar) 
     520      !!----------------------------------------------------------------------- 
     521      !!                  ***  ROUTINE  iom_nf90_pratt  *** 
     522      !! 
     523      !! ** Purpose : write a real attribute with NF90 
     524      !!              (either a global attribute (default) or a variable 
     525      !!               attribute if optional variable name is supplied (cdvar)) 
     526      !!----------------------------------------------------------------------- 
     527      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     528      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
     529      REAL(wp)        , INTENT(in   ) ::   pv_r0d   ! write field 
     530      CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
     531                      &               ::   cdvar    ! name of the variable 
     532      ! 
     533      INTEGER                         ::   if90id   ! temporary integer 
     534      INTEGER                         ::   ivarid   ! NetCDF variable Id 
     535      LOGICAL                         ::   llok     ! temporary logical 
     536      LOGICAL                         ::   lenddef  ! temporary logical 
     537      CHARACTER(LEN=100)              ::   clinfo   ! info character 
     538      !--------------------------------------------------------------------- 
     539      ! 
     540      if90id = iom_file(kiomid)%nfid 
     541      lenddef = .false. 
     542      IF( PRESENT(cdvar) ) THEN 
     543         ! check the variable exists in the file 
     544         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
     545         IF( .NOT. llok ) THEN 
     546            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 
     547         ENDIF 
     548      ELSE 
     549         llok = .true. 
     550         ivarid = NF90_GLOBAL 
     551      ENDIF 
     552! 
     553      IF( llok) THEN 
     554         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pratt: '//TRIM(cdatt) 
     555         IF( iom_file(kiomid)%irec /= -1 ) THEN    
     556            ! trick: irec used to know if the file is in define mode or not 
     557            ! if it is not then temporarily put it into define mode 
     558            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 
     559            lenddef = .true. 
     560         ENDIF 
     561         ! 
     562         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo) 
     563         ! 
     564         IF( lenddef ) THEN    
     565            ! file was in data mode on entry; put it back in that mode 
     566            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 
     567         ENDIF 
     568      ELSE 
     569         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 
     570      ENDIF 
     571      ! 
     572   END SUBROUTINE iom_nf90_pratt 
     573 
     574   SUBROUTINE iom_nf90_pcatt( kiomid, cdatt, pv_c0d, cdvar) 
     575      !!----------------------------------------------------------------------- 
     576      !!                  ***  ROUTINE  iom_nf90_pcatt  *** 
     577      !! 
     578      !! ** Purpose : write a character attribute with NF90 
     579      !!              (either a global attribute (default) or a variable 
     580      !!               attribute if optional variable name is supplied (cdvar)) 
     581      !!----------------------------------------------------------------------- 
     582      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     583      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
     584      CHARACTER(len=*), INTENT(in   ) ::   pv_c0d   ! write field 
     585      CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
     586                      &               ::   cdvar    ! name of the variable 
     587      ! 
     588      INTEGER                         ::   if90id   ! temporary integer 
     589      INTEGER                         ::   ivarid   ! NetCDF variable Id 
     590      LOGICAL                         ::   llok     ! temporary logical 
     591      LOGICAL                         ::   lenddef  ! temporary logical 
     592      CHARACTER(LEN=100)              ::   clinfo   ! info character 
     593      !--------------------------------------------------------------------- 
     594      ! 
     595      if90id = iom_file(kiomid)%nfid 
     596      lenddef = .false. 
     597      IF( PRESENT(cdvar) ) THEN 
     598         ! check the variable exists in the file 
     599         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr 
     600         IF( .NOT. llok ) THEN 
     601            CALL ctl_warn('iom_nf90_putatt: no variable '//cdvar//' found') 
     602         ENDIF 
     603      ELSE 
     604         llok = .true. 
     605         ivarid = NF90_GLOBAL 
     606      ENDIF 
     607! 
     608      IF( llok) THEN 
     609         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pcatt: '//TRIM(cdatt) 
     610         IF( iom_file(kiomid)%irec /= -1 ) THEN    
     611            ! trick: irec used to know if the file is in define mode or not 
     612            ! if it is not then temporarily put it into define mode 
     613            CALL iom_nf90_check(NF90_REDEF( if90id ), clinfo) 
     614            lenddef = .true. 
     615         ENDIF 
     616         ! 
     617         CALL iom_nf90_check(NF90_PUT_ATT(if90id, ivarid, cdatt, values=pv_c0d), clinfo) 
     618         ! 
     619         IF( lenddef ) THEN    
     620            ! file was in data mode on entry; put it back in that mode 
     621            CALL iom_nf90_check(NF90_ENDDEF( if90id ), clinfo) 
     622         ENDIF 
     623      ELSE 
     624         CALL ctl_warn('iom_nf90_putatt: no attribute '//cdatt//' written') 
     625      ENDIF 
     626      ! 
     627   END SUBROUTINE iom_nf90_pcatt 
    341628 
    342629 
Note: See TracChangeset for help on using the changeset viewer.