Changeset 740 in lmdz_wrf
- Timestamp:
- May 2, 2016, 9:29:21 PM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/module_ForInterpolate.F90
r735 r740 743 743 END SUBROUTINE CoarseInterpolateExact 744 744 745 SUBROUTINE Interpolate(projlon, projlat, lonvs, latvs, mindiff, ivar, newvar , newvarin, newvarinpt,&746 newvarindiff, dimx, dimy, Ninpts)745 SUBROUTINE Interpolate(projlon, projlat, lonvs, latvs, mindiff, ivar, newvarinpt, & 746 newvarindiff, ilonlat, dimx, dimy, Ninpts) 747 747 ! Subroutine which finds the closest grid point within a projection 748 748 … … 757 757 REAL(r_k), DIMENSION(Ninpts), INTENT(in) :: ivar, lonvs, latvs 758 758 REAL(r_k), INTENT(in) :: mindiff 759 REAL(r_k), DIMENSION(dimx,dimy), INTENT(out) :: newvar760 INTEGER, DIMENSION(dimx,dimy), INTENT(out) :: newvarin761 759 INTEGER, DIMENSION(Ninpts), INTENT(out) :: newvarinpt 762 760 REAL(r_k), DIMENSION(Ninpts), INTENT(out) :: newvarindiff 761 INTEGER, DIMENSION(Ninpts,2), INTENT(out) :: ilonlat 763 762 764 763 ! Local 765 764 INTEGER :: iv,i,j 766 765 INTEGER :: ierr 767 INTEGER, DIMENSION(2) :: ilonlat768 REAL(r_k), DIMENSION(dimx,dimy) :: difflonlat769 766 REAL(r_k) :: mindiffLl 770 767 INTEGER :: Ninpts1 768 REAL(r_k), DIMENSION(dimx,dimy) :: difflonlat 771 769 REAL(r_k), DIMENSION(2) :: extremelon, extremelat 772 770 CHARACTER(LEN=50) :: fname … … 783 781 ! newvarinpt: integer value indicating if the value has been already located (0: no, 1: yes) 784 782 ! newvarindiff: distance of point from the input data to the closest target point 783 ! ilonlat: longitude and latitude of the point 785 784 ! ncid: netCDF output file id 786 785 … … 813 812 difflonlat = SQRT((projlon-lonvs(iv))**2. + (projlat-latvs(iv))**2.) 814 813 mindiffLl = MINVAL(difflonlat) 815 ilonlat = index2DArrayR(difflonlat, dimx, dimy, mindiffLl)814 ilonlat(iv,:) = index2DArrayR(difflonlat, dimx, dimy, mindiffLl) 816 815 817 816 IF (mindiffLl <= mindiff) THEN 818 817 ! percendone(iv,Ninpts,0.5,'done:') 819 818 820 IF (ilonlat(1) >= 0 .AND. ilonlat(1) >= 0) THEN 821 newvar(ilonlat(1),ilonlat(2)) = ivar(iv) 822 newvarin(ilonlat(1),ilonlat(2)) = iv 819 IF (ilonlat(iv,1) >= 0 .AND. ilonlat(iv,2) >= 0) THEN 823 820 newvarinpt(iv) = 1 824 821 newvarindiff(iv) = mindiffLl … … 830 827 PRINT *,' ' // TRIM(fname) // ': point iv:', iv, ' at', lonvs(iv), ' ,', latvs(iv), & 831 828 ' not relocated !!' 832 PRINT *,' mindiffl:', mindiffLl, ' ilon:', ilonlat( 1), ' ilat:', ilonlat(2)829 PRINT *,' mindiffl:', mindiffLl, ' ilon:', ilonlat(iv,1), ' ilat:', ilonlat(iv,2) 833 830 STOP 834 831 END IF -
trunk/tools/nc_var_tools.py
r739 r740 20405 20405 # lonvss, latvss, fracd, mindiff, ovars) 20406 20406 # Slow way 20407 newvar ,newvarin,newvarinpt[pts],newvarindiff[pts] =\20407 newvarinpt[pts],newvarindiff[pts],ilonlatv = \ 20408 20408 fin.module_forinterpolate.interpolate(projlon, projlat, \ 20409 20409 lonvss, latvss, np.float64(mindiff), ovars) 20410 for i in range(fracs): 20411 # print 'Lluis: ilonlatv:', ilonlatv[i,:] 20412 newvar[ilonlatv[i,1],ilonlatv[i,0]] = ovars[i] 20413 newvarin[ilonlatv[i,1],ilonlatv[i,0]] = i 20410 20414 newnc.sync() 20411 print newvar20412 print 'newvar:',type(newvar), newvar.shape, np.min(newvar), np.max(newvar)20413 print 'newvarin:',type(newvarin), newvarin.shape, np.min(newvarin), np.max(newvarin)20414 newnc.close()20415 for i in range(iri,ire,1):20416 print lonvss[i], latvss[i], ovars[i]20417 20418 quit()20419 20415 20420 20416 elif kind == 'lonlat':
Note: See TracChangeset
for help on using the changeset viewer.