Commit f8e4ca8c authored by Tove Svendby's avatar Tove Svendby
Browse files

Upload New File

parent 51e6698b
Program find_sites
Implicit none
Integer I,J,ILINE,IO,II, INDEX1, INDEX2
real :: mm,dd,avg1, avg2
real :: dx, dy,sensX, sensY, min_err, GridresX, GridresY, rlon,rlat
character*50 :: path
character FILE1*20,FILE2*20,FILE3*20,FILE4*20
character FILEgrid*17,yyt*4, mmt*2, ddt*2, time*11
real:: lat(100000),lon(100000),comp1(100000), comp2(100000)
real:: res_lat(8000),res_lon(8000),res_err(8000),res_comp1(8000)
real:: res_comp2(8000)
integer :: ilat, ilon, qa, qa_lim
integer :: nx, ny
real :: latmin,latmax,lonmin,lonmax
character(len=10) :: fmt ! format descriptor
!ncks -s "%e\n" -C -H -v lat Combined_IASI_20191128_1800-2400.nc > lat.txt
!ncks -s "%e\n" -C -H -v lon Combined_IASI_20191128_1800-2400.nc > lon.txt
!ncks -s "%e\n" -C -H -v dBT Combined_IASI_20191128_1800-2400.nc > dBT.txt
FILEgrid='YYYYMMDD_grid.out'
open(11,File='fortran_info_res.txt', status='old')
IO=0
read(11,*,END=50) GridresX
read(11,*,END=50) GridresY
read(11,*,END=50) sensX
read(11,*,END=50) sensY
read(11,*,END=50) latmin
read(11,*,END=50) latmax
read(11,*,END=50) lonmin
read(11,*,END=50) lonmax
read(11,'(a4)',END=50) yyt
read(11,'(a2)',END=50) mmt
read(11,'(a2)',END=50) ddt
read(11,'(a11)',END=50) time
read(11,*,END=50) IO,I,I,FILE1
read(11,*,END=50) FILE2
read(11,*,END=50) FILE3
read(11,*,END=50) FILE4
!iline=IO/3 - 2
iline=IO -2
sensX=sensX/2.0
sensY=sensY/2.0
50 continue
close(11)
IO=1
!satfile=trim(path)//trim(FILE1)
write(*,*) FILE1
write(*,*) FILE2
write(*,*) FILE3
write(*,*) FILE4
write(*,*) 'iline: ',iline
lat(:)=0.0
lon(:)=0.0
comp1(:)=0.0
open(11,File=trim(FILE1), status='old')
do j=1,iline
read(11,*) lat(j)
end do
close(11)
open(11,File=trim(FILE2), status='old')
do j=1,iline
read(11,*) lon(j)
if (lon(j).ge.180.0) lon(j)=lon(j)-360.0
end do
close(11)
open(11,File=trim(FILE3), status='old')
do j=1,iline
read(11,*) comp1(j)
end do
close(11)
open(11,File=trim(FILE4), status='old')
do j=1,iline
read(11,*) comp2(j)
end do
close(11)
open(12,File=FILEgrid, status='unknown')
write(12,'(a4,a1,a2,a1,a2,1x,a11)')yyt,'-',mmt,'-',ddt,time
!############################
nx = nint((lonmax - lonmin)/GridresX)
ny = nint((latmax - latmin)/GridresY)
do ilon=0,nx
do ilat=0,ny
rlon = lonmin + ilon*gridresX
rlat = latmin + ilat*gridresY
II=0
res_lat(:)=0.0
res_lon(:)=0.0
res_err(:)=999.0
res_comp1(:)=0.0
INDEX1=0
INDEX2=0
avg1=0.0
avg2=0.0
do j=1,iline
if (lat(J).ge.(rlat-sensY) .and. lat(J).le.(rlat+sensY) .and. &
lon(J).ge.(rlon-sensX) .and. lon(J).le.(rlon+sensx)) then
dx=(lat(J)-rlat)*(lat(J)-rlat)
dy=(lon(J)-rlon)*(lon(J)-rlon)
II=II+1
res_lat(II)=lat(J)
res_lon(II)=lon(J)
res_err(II)=sqrt(dx+dy)
res_comp1(II)=comp1(J)
res_comp2(II)=comp2(J)
end if
end do
if (II.gt.0) then
avg1=SUM(res_comp1(1:II))/II
avg2=SUM(res_comp2(1:II))/II
min_err=minval(res_err) !Closest grid
INDEX1=MINLOC(res_err,DIM=1) !Index to corresponding minumum
!INDEX2=MINLOC(res_err,DIM=1,MASK=res_comp1.GT.0) !Index to grid with comp1 > 0
write(12,'(4f12.2,I6)') rlat,rlon, res_comp1(INDEX1),res_comp2(INDEX1), II
else
!write(12,'(3f12.2,I6)') rlat,rlon, -99.9, 0
write(12,'(2f12.2,2E13.6,I6)') rlat,rlon, 9.96921e36, 9.96921e36,0
end if
end do !lat
end do !lon
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment