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 1488 for trunk/NEMO/OPA_SRC/IOM/iom_rstdimg.F90 – NEMO

Ignore:
Timestamp:
2009-07-16T11:19:46+02:00 (15 years ago)
Author:
smasson
Message:

Addition of clobber and chunksize when opening NetCDF files, see ticket:374

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NEMO/OPA_SRC/IOM/iom_rstdimg.F90

    r1152 r1488  
    4848      !! ** Purpose :  open an input file read only (return 0 if not found) 
    4949      !!--------------------------------------------------------------------- 
    50       CHARACTER(len=*)       , INTENT(inout)           ::   cdname   ! File name 
    51       INTEGER                , INTENT(  out)           ::   kiomid   ! iom identifier of the opened file 
    52       LOGICAL                , INTENT(in   )           ::   ldwrt    ! read or write the file? 
    53       LOGICAL                , INTENT(in   )           ::   ldok     ! check the existence  
    54       INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar  ! domain parameters:  
     50      CHARACTER(len=*)       , INTENT(inout)           ::   cdname      ! File name 
     51      INTEGER                , INTENT(  out)           ::   kiomid      ! iom identifier of the opened file 
     52      LOGICAL                , INTENT(in   )           ::   ldwrt       ! read or write the file? 
     53      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence  
     54      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters:  
    5555 
    5656      CHARACTER(LEN=100)                      ::   clinfo                     ! info character 
    5757      CHARACTER(LEN=100)                      ::   cltmp                      ! temporary character 
     58      CHARACTER(LEN=10 )                      ::   clstatus                   ! status of opened file (REPLACE or NEW) 
    5859      INTEGER                                 ::   jv                         ! loop counter 
    5960      INTEGER                                 ::   istop                      ! temporary storage of nstop 
     
    7071      INTEGER                                 ::   iiglo, ijglo               ! domain global size  
    7172      INTEGER                                 ::   jl                         ! loop variable 
     73      LOGICAL                                 ::   llclobber                  ! local definition of ln_clobber 
    7274      CHARACTER(LEN=jpvnl), DIMENSION(jpmax_vars) ::   clna0d, clna1d, clna2d, clna3d     ! name of 0/1/2/3D variables 
    73       REAL(wp),         DIMENSION(jpmax_vars) ::   zval0d, zval1d, zval2d, zval3d     ! value of 0d variables or record 
    74       !                                                                               ! position for 1/2/3D variables 
     75      REAL(wp),             DIMENSION(jpmax_vars) ::   zval0d, zval1d, zval2d, zval3d     ! value of 0d variables or record 
     76      !                                                                                   ! position for 1/2/3D variables 
    7577      !--------------------------------------------------------------------- 
    7678      clinfo = '                    iom_rstdimg_open ~~~  ' 
     
    7880      ios = 0            ! default definition 
    7981      kiomid = 0         ! default definition 
     82      llclobber = ldwrt .AND. ln_clobber 
    8083      ! get a free unit 
    8184      idrst = getunit()  ! get a free logical unit for the restart file 
     
    8588      ! Open the file... 
    8689      ! ============= 
    87       IF( ldok ) THEN      ! Open existing file... 
     90      IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file... 
    8891         ! find the record length 
    8992         OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct'   & 
     
    101104               &       , RECL = irecl8, STATUS = 'old', ACTION = 'read'     , IOSTAT = ios, ERR = 987 ) 
    102105         ENDIF 
    103       ELSE                 ! the file does not exist 
     106      ELSE                                       ! the file does not exist (or we overwrite it) 
    104107         iln = INDEX( cdname, '.dimg' ) 
    105108         IF( ldwrt ) THEN  ! the file should be open in readwrite mode so we create it... 
     
    110113            ENDIF 
    111114            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//TRIM(cdname)//' in READWRITE mode' 
     115             
     116            IF( llclobber ) THEN   ;   clstatus = 'REPLACE'  
     117            ELSE                   ;   clstatus = 'NEW' 
     118            ENDIF 
    112119            OPEN( idrst, FILE = TRIM(cdname), FORM = 'UNFORMATTED', ACCESS = 'DIRECT'   & 
    113                &       , RECL = irecl8, STATUS = 'new', ACTION = 'readwrite', IOSTAT = ios, ERR = 987 ) 
     120               &       , RECL = irecl8, STATUS = TRIM(clstatus), ACTION = 'readwrite', IOSTAT = ios, ERR = 987 ) 
    114121         ELSE              ! the file should be open for read mode so it must exist... 
    115122            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' ) 
     
    118125      ! Performs checks on the file 
    119126      ! ============= 
    120       IF( ldok ) THEN      ! old file 
     127      IF( ldok .AND. .NOT. llclobber ) THEN      ! old file 
    121128         READ( idrst, REC = 1   , IOSTAT = ios, ERR = 987 )              & 
    122129              &   irecl8, inx, iny, inz, in0d, in1d, in2d, in3d, irhd,   & 
Note: See TracChangeset for help on using the changeset viewer.