Changeset 1488 for trunk/NEMO/OPA_SRC/IOM/iom_rstdimg.F90
- Timestamp:
- 2009-07-16T11:19:46+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEMO/OPA_SRC/IOM/iom_rstdimg.F90
r1152 r1488 48 48 !! ** Purpose : open an input file read only (return 0 if not found) 49 49 !!--------------------------------------------------------------------- 50 CHARACTER(len=*) , INTENT(inout) :: cdname ! File name51 INTEGER , INTENT( out) :: kiomid ! iom identifier of the opened file52 LOGICAL , INTENT(in ) :: ldwrt ! read or write the file?53 LOGICAL , INTENT(in ) :: ldok ! check the existence54 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: 55 55 56 56 CHARACTER(LEN=100) :: clinfo ! info character 57 57 CHARACTER(LEN=100) :: cltmp ! temporary character 58 CHARACTER(LEN=10 ) :: clstatus ! status of opened file (REPLACE or NEW) 58 59 INTEGER :: jv ! loop counter 59 60 INTEGER :: istop ! temporary storage of nstop … … 70 71 INTEGER :: iiglo, ijglo ! domain global size 71 72 INTEGER :: jl ! loop variable 73 LOGICAL :: llclobber ! local definition of ln_clobber 72 74 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 record74 ! ! position for 1/2/3D variables75 REAL(wp), DIMENSION(jpmax_vars) :: zval0d, zval1d, zval2d, zval3d ! value of 0d variables or record 76 ! ! position for 1/2/3D variables 75 77 !--------------------------------------------------------------------- 76 78 clinfo = ' iom_rstdimg_open ~~~ ' … … 78 80 ios = 0 ! default definition 79 81 kiomid = 0 ! default definition 82 llclobber = ldwrt .AND. ln_clobber 80 83 ! get a free unit 81 84 idrst = getunit() ! get a free logical unit for the restart file … … 85 88 ! Open the file... 86 89 ! ============= 87 IF( ldok ) THEN ! Open existing file...90 IF( ldok .AND. .NOT. llclobber ) THEN ! Open existing file... 88 91 ! find the record length 89 92 OPEN( idrst, FILE = TRIM(cdname), FORM = 'unformatted', ACCESS = 'direct' & … … 101 104 & , RECL = irecl8, STATUS = 'old', ACTION = 'read' , IOSTAT = ios, ERR = 987 ) 102 105 ENDIF 103 ELSE ! the file does not exist106 ELSE ! the file does not exist (or we overwrite it) 104 107 iln = INDEX( cdname, '.dimg' ) 105 108 IF( ldwrt ) THEN ! the file should be open in readwrite mode so we create it... … … 110 113 ENDIF 111 114 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 112 119 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 ) 114 121 ELSE ! the file should be open for read mode so it must exist... 115 122 CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' ) … … 118 125 ! Performs checks on the file 119 126 ! ============= 120 IF( ldok ) THEN ! old file127 IF( ldok .AND. .NOT. llclobber ) THEN ! old file 121 128 READ( idrst, REC = 1 , IOSTAT = ios, ERR = 987 ) & 122 129 & irecl8, inx, iny, inz, in0d, in1d, in2d, in3d, irhd, &
Note: See TracChangeset
for help on using the changeset viewer.