Changeset 1808 for IOIPSL


Ignore:
Timestamp:
07/16/12 10:07:18 (12 years ago)
Author:
jpolcher
Message:

This modification of flincom.f90 treats 2 problems :

  • the time axis was only recognized if the dimension was either called time_counter or tstep. The more natural name "time" was added as an option.
  • The other change deals with scalar variables. For the moment flincom.f90 expects the scalar variables to be global attributes of the netCDF files. This was extended in the following way. If the scalar variable requested by the user is not found among the global attributes, then we look for it within the variables. If found we read that scalar variable.

Neither change modifies the default behaviot of flincom.f90 but it just extends its capabilities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • IOIPSL/trunk/src/flincom.f90

    r1660 r1808  
    739739      zid = iv; llm = lll; 
    740740    ELSE IF (    (INDEX(axname,'tstep') == 1) & 
     741             .OR.(INDEX(axname,'time') == 1) & 
    741742             .OR.(INDEX(axname,'time_counter') == 1) ) THEN 
    742743!---- For the time we certainly need to allow for other names 
     
    16781679! LOCAL 
    16791680!- 
    1680   INTEGER :: iret, fid 
     1681  INTEGER :: iret, fid, vid 
     1682  INTEGER :: attlen, attnum 
     1683  INTEGER :: ndims, nb_atts 
     1684  INTEGER,DIMENSION(NF90_MAX_VAR_DIMS) :: dimids 
     1685  LOGICAL :: var_exists 
    16811686!- 
    16821687  LOGICAL :: l_dbg 
     
    16851690 
    16861691  IF (l_dbg) THEN 
    1687     WRITE (*,*) 'flinget_scal in file with id ',fid_in 
     1692    WRITE (ipslout,*) 'flinget_scal in file with id ',fid_in 
    16881693  ENDIF 
    16891694!- 
    16901695  fid = ncids(fid_in) 
     1696  iret = NF90_INQUIRE_ATTRIBUTE(fid, NF90_GLOBAL, varname, len=attlen, attnum=attnum) 
    16911697!- 
    16921698! 1.0 Reading a global attribute 
    16931699!- 
    1694   iret = NF90_GET_ATT (fid, NF90_GLOBAL, varname, var) 
     1700  IF ( iret == nf90_noerr ) THEN 
     1701     ! 
     1702     ! This seems to be a Global attribute 
     1703     ! 
     1704     iret = NF90_GET_ATT (fid, NF90_GLOBAL, varname, var) 
     1705  ELSE 
     1706     ! 
     1707     ! If there was an error on the test for a global attribute it 
     1708     ! is perhaps a scalar variable. 
     1709     ! 
     1710     vid = -1 
     1711     iret = NF90_INQ_VARID (fid, varname, vid) 
     1712     ! 
     1713     IF ( (vid >= 0).AND.(iret == NF90_NOERR) ) THEN 
     1714        iret = NF90_INQUIRE_VARIABLE (fid, vid, & 
     1715             ndims=ndims, dimids=dimids, nAtts=nb_atts) 
     1716        IF ( (ndims == 0) .AND. (nb_atts >= 0) ) THEN 
     1717           iret = NF90_GET_VAR(fid, vid, var) 
     1718        ELSE 
     1719           CALL histerr (3,'flinget_scal', & 
     1720                'The variable has coordinates and thus is probably not a scalar.', & 
     1721                'Check your netCDF file.', " ") 
     1722        ENDIF 
     1723     ENDIF 
     1724     IF (l_dbg) THEN 
     1725        WRITE(ipslout,*) "Reading a Scalar value for varibale ", varname," It has value ", var 
     1726     ENDIF 
     1727  ENDIF 
     1728!- 
    16951729!--------------------------- 
    16961730END  SUBROUTINE flinget_scal 
Note: See TracChangeset for help on using the changeset viewer.