Changeset f155f96 in flexpart.git
- Timestamp:
- Aug 26, 2016, 4:58:46 PM (8 years ago)
- Branches:
- FPv9.3.1, FPv9.3.1b_testing, FPv9.3.2, fp9.3.1-20161214-nc4, grib2nc4_repair
- Children:
- 3372ef9
- Parents:
- 48a5c5c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
flexpart_code/GRIB2FLEXPART.F90
r48a5c5c rf155f96 54 54 character(len=32) :: lsubgridTXT 55 55 integer :: useAvailable = 0 56 integer :: overwritecheck 56 57 57 58 ! Print the GPL License statement … … 115 116 if ( ldirect.eq.1 ) then 116 117 wfname(i-4+1) = inputFileName 118 if ( overwritecheck( dumpPath, wfname(i-4+1), 0) == -1 ) then 119 ! if the output and input directory is the same, exit with error 120 print *, "Input and output paths must be different" 121 print *, "Output: "//trim(dumpPath) 122 print *, "input: "//trim(wfname(i-4+1)) 123 stop 'Error: Incorrect arguments' 124 endif 117 125 else 118 126 wfname(iargc()+1-i) = inputFileName 127 if ( overwritecheck( dumpPath, wfname(iargc()+1-i), 0) == -1 ) then 128 ! if the output and input directory is the same, exit with error 129 print *, "Input and output paths must be different" 130 print *, "Output: "//trim(dumpPath) 131 print *, "Input: "//trim(wfname(iargc()+1-i)) 132 stop 'Error: Incorrect arguments' 133 endif 119 134 endif 120 135 end do … … 128 143 129 144 call readavailable 130 endif 145 do i=1,numbwf 146 if ( overwritecheck( dumpPath, path(3)(1:length(3)) // trim(wfname(i)),0) == -1) then 147 ! if the output and input directory is the same, exit with error 148 print *, "Input and output paths must be different" 149 print *, "Output: "//trim(dumpPath) 150 print *, "Input: "//path(3)(1:length(3)) // trim(wfname(i)) 151 stop 'Error: Incorrect arguments' 152 endif 153 enddo 154 endif 155 131 156 132 157 ! Reset the times of the wind fields that are kept in memory to no time … … 176 201 177 202 end program grib2flexpart 203 204 ! This function checks whether input and output directories differ 205 ! It does so by creating tmp file in output directory and by checking for its presence in input one 206 ! It's does this way to avoid the need for relative 2 absolute path expansion and to avoid handling of links 207 integer function overwritecheck( dump_path, input_path, input_is_path ) 208 character(len=*) :: dump_path, input_path 209 integer :: input_is_path, open_status 210 character(len=512) :: tmp_file_name, tmp_file_path, check_file_path 211 character(len=64) :: pid, current_time 212 logical :: exists 213 214 overwritecheck = 1 215 216 write (pid,*) getpid() 217 write (current_time, *) time() 218 ! generate tmp file name using PID and timestamp 219 tmp_file_name = "overwritecheck_"//trim(adjustl(pid))//"_"//trim(adjustl(current_time))//".tmp" 220 tmp_file_path = trim(dump_path)//"/"//trim(tmp_file_name) 221 222 ! create tmp file in output directory 223 open(10001, file=trim(tmp_file_path), status="new", action="write", iostat=open_status) 224 ! check for tmp file 225 if ( open_status /= 0 ) then 226 print *, "Output directory does not exist or is not writeable" 227 stop 'Error: Incorrect arguments' 228 endif 229 230 ! generate tmp file name in input directory 231 if ( input_is_path == 1) then 232 check_file_path = trim(input_path)//"/"//trim(tmp_file_name) 233 else 234 check_file_path=trim(input_path(:scan(input_path, '/', .TRUE.)))//trim(tmp_file_name) 235 endif 236 !check for file presence 237 inquire(file=TRIM(check_file_path), exist=exists) 238 ! delete tmp file 239 close(10001, status='DELETE') 240 if ( exists ) then 241 overwritecheck = -1 242 endif 243 244 end function
Note: See TracChangeset
for help on using the changeset viewer.