Changeset 1659 in lmdz_wrf
- Timestamp:
- Sep 27, 2017, 6:22:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/trajectories_overlap.f90
r1656 r1659 24 24 25 25 ! Local 26 INTEGER :: ncid, rcode 26 INTEGER :: funit, ncunit, rcode 27 INTEGER :: ierr, ios 27 28 INTEGER :: Nvdims 28 29 INTEGER, DIMENSION(1) :: dims1D … … 30 31 INTEGER, DIMENSION(3) :: dims3D 31 32 INTEGER, DIMENSION(:), ALLOCATABLE :: polyN 33 INTEGER, DIMENSION(:,:,:), ALLOCATABLE :: polys 32 34 REAL(r_k) :: resx, resy 33 35 REAL(r_k), DIMENSION(:,:), ALLOCATABLE :: polyas 34 REAL(r_k), DIMENSION(:,:,:), ALLOCATABLE :: poly s, polywctrs, finaltracks36 REAL(r_k), DIMENSION(:,:,:), ALLOCATABLE :: polywctrs, finaltracks 35 37 REAL(r_k), DIMENSION(:,:,:,:), ALLOCATABLE :: polytracks 36 38 LOGICAL :: gotvar … … 39 41 Nmaxtrack 40 42 41 NAMELIST /files/ polyfilename, poly2Dn, pol uyNn, polywctrn, polywarean, varnresx, varnresy, timen43 NAMELIST /files/ polyfilename, poly2Dn, polyNn, polywctrn, polywarean, varnresx, varnresy, timen 42 44 NAMELIST /config/ minarea, projectn, debug 43 45 … … 62 64 63 65 ! Reading namelist 64 funit = Fileunit()66 funit = freeunit() 65 67 OPEN(funit, file='trajectories_overlap.namelist', status='old', form='formatted', iostat=ios) 66 68 msg = "Problems reading nameslit file: 'trajectories_overlap.namelist'" … … 72 74 73 75 ! Opening polygon file 74 rcode = nf90_open(TRIM( filename), NF90_NOWRITE, ncid)76 rcode = nf90_open(TRIM(polyfilename), NF90_NOWRITE, ncunit) 75 77 IF (rcode /= NF90_NOERR) CALL handle_err(rcode) 76 78 … … 79 81 80 82 ! polygons 81 gotvar = isin_ncunit(nc id, poly2Dn)82 IF (.NOT.gotvar) THEN 83 msg = "File '" // TRIM() //"' does not have 2D polygons variable '" // TRIM(poly2Dn) // "'"84 CALL ErrMsg(msg, fname, -1) 85 END IF 86 Nvdims = get_varNdims_ncunit(nc id, poly2Dn)83 gotvar = isin_ncunit(ncunit, poly2Dn) 84 IF (.NOT.gotvar) THEN 85 msg= "File '"//TRIM(polyfilename)//"' does not have 2D polygons variable '" // TRIM(poly2Dn) // "'" 86 CALL ErrMsg(msg, fname, -1) 87 END IF 88 Nvdims = get_varNdims_ncunit(ncunit, poly2Dn) 87 89 IF (Nvdims /= 3) THEN 88 90 WRITE(num3S,'(I3)')Nvdims … … 96 98 msg = "Problems allocating 'polys'" 97 99 CALL ErrMsg(msg, fname, ierr) 98 CALL get_varRK3D_ncunit(ncunit, dims3D(1), dims3D(2), dims3D(3), poly2Dn, polys) 100 CALL get_varI3D_ncunit(ncunit, dims3D(1), dims3D(2), dims3D(3), poly2Dn, polys) 101 IF (debug) PRINT *," Got variable 'polys':", UBOUND(polys) 99 102 100 103 dimx = dims3D(1) … … 103 106 104 107 ! N polygons 105 gotvar = isin_ncunit(ncid, polyNn) 106 IF (.NOT.gotvar) THEN 107 msg = "File '" // TRIM() // "' does not have number of polygons variable '" // TRIM(polyNn) // "'" 108 CALL ErrMsg(msg, fname, -1) 109 END IF 110 Nvdims = get_varNdims_ncunit(ncid, polyNn) 111 IF (Nvdims /= 2) THEN 108 gotvar = isin_ncunit(ncunit, polyNn) 109 IF (.NOT.gotvar) THEN 110 msg="File '"//TRIM(polyfilename)//"' does not have number of polygons variable '" // TRIM(polyNn) & 111 // "'" 112 CALL ErrMsg(msg, fname, -1) 113 END IF 114 Nvdims = get_varNdims_ncunit(ncunit, polyNn) 115 IF (Nvdims /= 1) THEN 112 116 WRITE(num3S,'(I3)')Nvdims 113 117 msg = "Variable with N polygons '" // TRIM(polyNn) // "' has: " // num3S // & 114 " it must have 2dimensions !!"115 CALL ErrMsg(msg, fname, -1) 116 END IF 117 dims 2D = get_var2dims_ncunit(ncunit, polyNn)118 " it must have 1 dimensions !!" 119 CALL ErrMsg(msg, fname, -1) 120 END IF 121 dims1D = get_var1dims_ncunit(ncunit, polyNn) 118 122 IF (ALLOCATED(polyN)) DEALLOCATE(polyN) 119 ALLOCATE(polyN(dims 2D(1), dims2D(2)), STAT=ierr)123 ALLOCATE(polyN(dims1D(1)), STAT=ierr) 120 124 msg = "Problems allocating 'polyN'" 121 125 CALL ErrMsg(msg, fname, ierr) 122 CALL get_varI2D_ncunit(ncunit, dims1D(1), dims1D(2), polyNn, polyN) 126 CALL get_varI1D_ncunit(ncunit, dims1D(1), polyNn, polyN) 127 IF (debug) PRINT *," Got variable 'polyN':", UBOUND(polyN) 123 128 124 129 ! weighted-center of the polygons 125 gotvar = isin_ncunit(nc id, polywctrn)126 IF (.NOT.gotvar) THEN 127 msg = "File '" // TRIM( ) // "' does not have weighted-centerd polygon variable '" //&130 gotvar = isin_ncunit(ncunit, polywctrn) 131 IF (.NOT.gotvar) THEN 132 msg = "File '" // TRIM(polyfilename) // "' does not have weighted-centerd polygon variable '" // & 128 133 TRIM(polywctrn) // "'" 129 134 CALL ErrMsg(msg, fname, -1) 130 135 END IF 131 Nvdims = get_varNdims_ncunit(nc id, polywctrn)136 Nvdims = get_varNdims_ncunit(ncunit, polywctrn) 132 137 IF (Nvdims /= 3) THEN 133 138 WRITE(num3S,'(I3)')Nvdims … … 141 146 msg = "Problems allocating 'polywctrs'" 142 147 CALL ErrMsg(msg, fname, ierr) 143 CALL get_varRK3D_ncunit(ncunit, dims3D(1), dims3D(2), dims3D(3), poly2Dn, polywctrs) 148 CALL get_varRK3D_ncunit(ncunit, dims3D(1), dims3D(2), dims3D(3), polywctrn, polywctrs) 149 IF (debug) PRINT *," Got variable 'polyectrs':", UBOUND(polywctrs) 144 150 Nmaxpoly = dims3D(2) 145 151 Ncoord = dims3D(3) 146 152 147 153 ! area of polygons 148 gotvar = isin_ncunit(nc id, polywarean)149 IF (.NOT.gotvar) THEN 150 msg = "File '" // TRIM( ) // "' does not have variable '" // TRIM(polywarean) // "'"151 CALL ErrMsg(msg, fname, -1) 152 END IF 153 Nvdims = get_varNdims_ncunit(nc id, polywarean)154 IF (Nvdims /= 3) THEN154 gotvar = isin_ncunit(ncunit, polywarean) 155 IF (.NOT.gotvar) THEN 156 msg = "File '" // TRIM(polyfilename) // "' does not have variable '" // TRIM(polywarean) // "'" 157 CALL ErrMsg(msg, fname, -1) 158 END IF 159 Nvdims = get_varNdims_ncunit(ncunit, polywarean) 160 IF (Nvdims /= 2) THEN 155 161 WRITE(num3S,'(I3)')Nvdims 156 162 msg = "Variable with area polygons '" // TRIM(polywarean) // "' has: " // num3S // & … … 163 169 msg = "Problems allocating 'polyas'" 164 170 CALL ErrMsg(msg, fname, ierr) 165 CALL get_varRK2D_ncunit(ncunit, dims2D(1), dims2D(2), poly2Dn, polyas) 171 CALL get_varRK2D_ncunit(ncunit, dims2D(1), dims2D(2), polywarean, polyas) 172 IF (debug) PRINT *," Got variable 'polyas':", UBOUND(polyas) 166 173 167 174 ! Resolution along x/y axis 168 gotvar = isin_ncunit(ncid, varnresx) 169 IF (.NOT.gotvar) THEN 170 msg = "File '" // TRIM() // "' does not have variable '" // TRIM(varnresx) // "'" 171 CALL ErrMsg(msg, fname, -1) 172 END IF 173 CALL get_varRK0dims_ncunit(ncunit, varnresx, resx) 174 gotvar = isin_ncunit(ncid, varnresy) 175 IF (.NOT.gotvar) THEN 176 msg = "File '" // TRIM() // "' does not have variable '" // TRIM(varnresy) // "'" 177 CALL ErrMsg(msg, fname, -1) 178 END IF 179 CALL get_varRK0dims_ncunit(ncunit, varnresy, resy) 180 181 rcode = nf90_close(ncid) 175 gotvar = isin_ncunit(ncunit, varnresx) 176 IF (.NOT.gotvar) THEN 177 msg = "File '" // TRIM(polyfilename) // "' does not have variable '" // TRIM(varnresx) // "'" 178 CALL ErrMsg(msg, fname, -1) 179 END IF 180 CALL get_varRK0D_ncunit(ncunit, varnresx, resx) 181 IF (debug) PRINT *," Got variable 'resx':", resx 182 183 gotvar = isin_ncunit(ncunit, varnresy) 184 IF (.NOT.gotvar) THEN 185 msg = "File '" // TRIM(polyfilename) // "' does not have variable '" // TRIM(varnresy) // "'" 186 CALL ErrMsg(msg, fname, -1) 187 END IF 188 CALL get_varRK0D_ncunit(ncunit, varnresy, resy) 189 IF (debug) PRINT *," Got variable 'resy':", resy 190 191 rcode = nf90_close(ncunit) 182 192 IF (rcode /= NF90_NOERR) CALL handle_err(rcode) 183 193 … … 205 215 ! Computing trajectories 206 216 CALL poly_overlap_tracks_area(debug, dimx, dimy, dimt, minarea, polyN, polys, polywctrs, polyas, & 207 Nmaxpoly, Nmaxtrack s, polytracks, finaltracks)217 Nmaxpoly, Nmaxtrack, polytracks, finaltracks) 208 218 209 219 ! Writting trajectory files 210 220 211 221 DEALLOCATE(polys) 212 DEALLOCATE(polyN s)222 DEALLOCATE(polyN) 213 223 DEALLOCATE(polywctrs) 214 224 DEALLOCATE(polyas)
Note: See TracChangeset
for help on using the changeset viewer.