Changeset 729 in lmdz_wrf
- Timestamp:
- Apr 26, 2016, 6:52:24 PM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_ForInterpolate.F90
r728 r729 197 197 END SUBROUTINE CoarselonlatFind 198 198 199 SUBROUTINE CoarseInterpolate( projlon, projlat, lonvs, latvs, percen, mindiff, ivar, newvar, newvarin,&200 newvarin pt, newvarindiff, dimx, dimy, Ninpts)199 SUBROUTINE CoarseInterpolate(inpts, projlon, projlat, lonvs, latvs, percen, mindiff, ivar, newvar, & 200 newvarin, newvarinpt, newvarindiff, dimx, dimy, Ninpts) 201 201 ! Subroutine which finds the closest grid point within a projection throughout a first guest 202 202 ! approche from percentages of the whole domain … … 210 210 REAL(r_k), DIMENSION(dimx,dimy), INTENT(in) :: projlon, projlat 211 211 INTEGER, INTENT(in) :: Ninpts 212 INTEGER, DIMENSION(Ninpts), INTENT(in) :: inpts 212 213 REAL(r_k), DIMENSION(Ninpts), INTENT(in) :: ivar, lonvs, latvs 213 214 REAL(r_k) :: mindiff, percen … … 229 230 230 231 !!!!!!! Variables 232 ! inpts: relative position of the values to interpolate 231 233 ! dimx, dimy: dimension length of the target interpolation 232 234 ! proj[lon/lat]: longitudes and latitudes of the target interpolation … … 248 250 extremelat = (/ MINVAL(projlat), MAXVAL(projlat) /) 249 251 250 PRINT *,' ' // TRIM(fname) //' fraction:', dimx, ' ,', dimy, ' %', percen251 252 dfracdx = INT(1./percen )253 dfracdy = INT(1./percen )252 PRINT *,' ' // TRIM(fname) //' total space:', dimx, ', ', dimy, ' %', percen 253 254 dfracdx = INT(1./percen+1) 255 dfracdy = INT(1./percen+1) 254 256 fracdx = INT(dimx*percen) 255 257 fracdy = INT(dimy*percen) 258 PRINT *,' ' // TRIM(fname) //' fraction:', dfracdx, ', ', dfracdy, ' freq:', fracdx,', ',fracdy 256 259 257 260 IF (ALLOCATED(fractionlon)) DEALLOCATE(fractionlon) … … 272 275 DO i=1,dfracdx 273 276 DO j=1,dfracdy 274 fractionlon(i,j) = projlon(fracdx*(i-1),fracdy*(j-1)) 275 fractionlat(i,j) = projlat(fracdx*(i-1),fracdy*(j-1)) 277 fractionlon(i,j) = projlon(fracdx*(i-1)+1,fracdy*(j-1)+1) 278 fractionlat(i,j) = projlat(fracdx*(i-1)+1,fracdy*(j-1)+1) 279 ! PRINT *,'i,j:',i,', ',j,' frac ij:',fracdx*(i-1),', ',fracdy*(j-1),' lonlat:', fractionlon(i,j),& 280 ! ', ',fractionlat(i,j) 276 281 END DO 277 282 END DO 278 283 279 284 PRINT *,' ' // TRIM(fname) // ' fractions of:' 280 PRINT *,' lon _______' 281 PRINT *,fractionlon 285 PRINT *,' lon _______ (',dfracdx,', ',dfracdy,')' 286 DO i=1,dfracdx 287 PRINT *,fractionlon(i,:) 288 END DO 282 289 PRINT *,' lat_______' 283 PRINT *,fractionlat 290 DO i=1,dfracdx 291 PRINT *,fractionlat(i,:) 292 END DO 284 293 285 294 DO iv=1,Ninpts … … 292 301 293 302 IF (ilonlat(1) >= 0 .AND. ilonlat(1) >= 0) THEN 294 newvar(ilonlat(1),ilonlat(2)) = ivar(i v)295 newvarin(ilonlat(1),ilonlat(2)) = i v296 newvarinpt(i v) = 1297 newvarindiff(i v) = mindiffLl303 newvar(ilonlat(1),ilonlat(2)) = ivar(inpts(iv)) 304 newvarin(ilonlat(1),ilonlat(2)) = inpts(iv) 305 newvarinpt(inpts(iv)) = 1 306 newvarindiff(inpts(iv)) = mindiffLl 298 307 ! PRINT *,'Lluis iv:', newvarin(ilonlat(1),ilonlat(2)), ' localized:', newvarinpt(iv), & 299 308 ! ' values:', newvar(ilonlat(1),ilonlat(2)), ' invalues:', ivar(iv), ' mindist:', & -
trunk/tools/nc_var_tools.py
r727 r729 19443 19443 foudre: f2py -m module_ForInterpolate --f90exec=/usr/bin/gfortran-4.7 -c module_ForInterpolate.F90 module_generic.F90 >& run_f2py.log 19444 19444 ciclad: f2py --f90flags="-fPIC" -L/opt/canopy-1.3.0/Canopy_64bit/System/lib/ -L/usr/lib64/ -L/opt/canopy-1.3.0/Canopy_64bit/System/lib/ -m module_ForInterpolate -c module_ForInterpolate.F90 module_generic.F90 19445 values= [lonmame],[latname],[fillVal],[resolution],[kind],[lonlatProjfile],[ fracd],[fracs]19445 values= [lonmame],[latname],[fillVal],[resolution],[kind],[lonlatProjfile],[ipoint],[fracd],[fracs] 19446 19446 [lonname]: name of the longitude variable 19447 19447 [latname]: name of the latitude variable … … 19458 19458 'Goode': Goode projection 19459 19459 [lonlatProjfile]: file with the lon,lat of the desired projection. 'None' to be computed and written on fly 19460 [ipoint]: initial point to use for the interpolation (0, the first) 19460 19461 [fracd]: Percentage of the fractions within perform the first guess search 19461 19462 [fracs]: Number of grid points to perform the syncronization with the file and the computed values … … 19475 19476 19476 19477 arguments = '[lonmame],[latname],[fillVal],[resolution],[kind],' + \ 19477 '[lonlatProjfile],[ fracd],[fracs]'19478 '[lonlatProjfile],[ipoint],[fracd],[fracs]' 19478 19479 check_arguments(fname, values, arguments, ',') 19479 19480 … … 19493 19494 kind = values.split(',')[4] 19494 19495 Projfile = values.split(',')[5] 19495 fracd = np.float(values.split(',')[6]) 19496 fracs = int(values.split(',')[7]) 19496 ipoint = int(values.split(',')[6]) 19497 fracd = np.float(values.split(',')[7]) 19498 fracs = int(values.split(',')[8]) 19497 19499 19498 19500 if Projfile == 'None': … … 19724 19726 # Error at 150024, 150025, 151709, 153421 19725 19727 print ' ' + fname + ': from:', Ninpts,'re-locating:',Nptsf,'points...' 19726 # fracs = 10000019727 19728 if kind == 'Goode': 19728 19729 # newvar,newvarin,newvarinpt,newvarindiff = \ 19729 19730 # fin.module_forinterpolate.coarseinterpolate(projlon, projlat, lonvs, \ 19730 19731 # latvs, percen, mindiff, ivar, dimx, dimy, ninpts) 19731 for ir in range( 0,Ninpts,fracs):19732 for ir in range(ipoint,Ninpts,fracs): 19732 19733 iri = ir 19733 19734 ire = ir + fracs + 1 19734 19735 print iri,',',ire 19735 19736 # percendone(iri,Ninpts,0.5,'done:') 19737 pts = np.arange(iri,ire,1, dtype='int32') 19736 19738 lonvss = lonvs[iri:ire].astype('float64') 19737 19739 latvss = latvs[iri:ire].astype('float64') … … 19739 19741 19740 19742 newvar,newvarin,newvarinpt,newvarindiff = \ 19741 fin.module_forinterpolate.coarseinterpolate(p rojlon, projlat,\19743 fin.module_forinterpolate.coarseinterpolate(pts, projlon, projlat, \ 19742 19744 lonvss, latvss, np.float64(fracd), np.float64(mindiff), ovars) 19743 19745 newnc.sync()
Note: See TracChangeset
for help on using the changeset viewer.