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 4792 for branches/2014/dev_r4621_NOC4_BDY_VERT_INTERP/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90 – NEMO

Ignore:
Timestamp:
2014-09-26T13:04:47+02:00 (10 years ago)
Author:
jamesharle
Message:

Updates to code after first successful test + merge with HEAD of trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2014/dev_r4621_NOC4_BDY_VERT_INTERP/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90

    r4292 r4792  
    3535   END INTERFACE 
    3636   INTERFACE iom_nf90_getatt 
    37       MODULE PROCEDURE iom_nf90_intatt 
     37      MODULE PROCEDURE iom_nf90_att 
    3838   END INTERFACE 
    3939   INTERFACE iom_nf90_rstput 
     
    217217         CALL iom_nf90_check(NF90_Inquire_Variable(if90id, ivarid, dimids = idimid(1:i_nvd)), clinfo)   ! dimensions ids 
    218218         iom_file(kiomid)%luld(kiv) = .FALSE.   ! default value 
    219          iom_file(kiomid)%dimsz(:,kiv) = 0   ! reset dimsz in case previously used 
     219         iom_file(kiomid)%dimsz(:,kiv) = 0      ! reset dimsz in case previously used 
    220220         DO ji = 1, i_nvd                       ! dimensions size 
    221221            CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, idimid(ji), len = iom_file(kiomid)%dimsz(ji,kiv)), clinfo)    
     
    312312 
    313313 
    314    SUBROUTINE iom_nf90_intatt( kiomid, cdatt, pvar ) 
    315       !!----------------------------------------------------------------------- 
    316       !!                  ***  ROUTINE  iom_nf90_intatt  *** 
     314   SUBROUTINE iom_nf90_att( kiomid, cdatt, pv_i0d, pv_r0d, cdvar) 
     315      !!----------------------------------------------------------------------- 
     316      !!                  ***  ROUTINE  iom_nf90_att  *** 
    317317      !! 
    318318      !! ** Purpose : read an integer attribute with NF90 
     
    320320      INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    321321      CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
    322       INTEGER         , INTENT(  out) ::   pvar     ! read field 
     322      INTEGER         , INTENT(  out), OPTIONAL       ::   pv_i0d    ! read field 
     323      REAL(wp),         INTENT(  out), OPTIONAL       ::   pv_r0d    ! read field  
     324      CHARACTER(len=*), INTENT(in   ), OPTIONAL       ::   cdvar     ! name of the variable 
    323325      ! 
    324326      INTEGER                         ::   if90id   ! temporary integer 
     327      INTEGER                         ::   ivarid           ! NetCDF  variable Id 
    325328      LOGICAL                         ::   llok     ! temporary logical 
    326329      CHARACTER(LEN=100)              ::   clinfo   ! info character 
     
    328331      !  
    329332      if90id = iom_file(kiomid)%nfid 
    330       llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 
     333      IF( PRESENT(cdvar) ) THEN 
     334         llok = NF90_INQ_VARID( if90id, TRIM(cdvar), ivarid ) == nf90_noerr   ! does the variable exist in the file 
     335         IF( llok ) THEN 
     336            llok = NF90_Inquire_attribute(if90id, ivarid, cdatt) == nf90_noerr 
     337         ELSE 
     338            CALL ctl_warn('iom_nf90_getatt: no variable '//cdvar//' found') 
     339         ENDIF 
     340      ELSE 
     341         llok = NF90_Inquire_attribute(if90id, NF90_GLOBAL, cdatt) == nf90_noerr 
     342      ENDIF  
     343! 
    331344      IF( llok) THEN 
    332345         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', att: '//TRIM(cdatt) 
    333          CALL iom_nf90_check(NF90_GET_ATT(if90id, NF90_GLOBAL, cdatt, values=pvar), clinfo) 
     346         IF(     PRESENT(pv_r0d) ) THEN 
     347            IF( PRESENT(cdvar) ) THEN 
     348               CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_r0d), clinfo) 
     349            ELSE 
     350               CALL iom_nf90_check(NF90_GET_ATT(if90id, NF90_GLOBAL, cdatt, values=pv_r0d), clinfo) 
     351            ENDIF 
     352         ELSE 
     353            IF( PRESENT(cdvar) ) THEN 
     354               CALL iom_nf90_check(NF90_GET_ATT(if90id, ivarid, cdatt, values=pv_i0d), clinfo) 
     355            ELSE 
     356               CALL iom_nf90_check(NF90_GET_ATT(if90id, NF90_GLOBAL, cdatt, values=pv_i0d), clinfo) 
     357            ENDIF 
     358         ENDIF 
    334359      ELSE 
    335360         CALL ctl_warn('iom_nf90_getatt: no attribute '//cdatt//' found') 
    336          pvar = -999 
     361         IF(     PRESENT(pv_r0d) ) THEN 
     362            pv_r0d = -999._wp 
     363         ELSE 
     364            pv_i0d = -999 
     365         ENDIF 
    337366      ENDIF 
    338367      !  
    339    END SUBROUTINE iom_nf90_intatt 
     368   END SUBROUTINE iom_nf90_att 
    340369 
    341370 
Note: See TracChangeset for help on using the changeset viewer.