74 logical fexist, opened
75 integer fsize, ncid, error, id_dim, nx, ny
76 character(len=256) :: outgrid =
"none" 77 character(len=256) :: inputorog =
"none" 78 character(len=256) :: merge_file =
"none" 79 logical :: mask_only = .false.
80 integer :: mtnres,im,jm,nm,nr,nf0,nf1,efac,blat,nw
82 READ(5,*) mtnres,im,jm,nm,nr,nf0,nf1,efac,blat
98 print*,
"INPUTOROG=", trim(inputorog)
99 print*,
"IM,JM=", im, jm
100 print*,
"MASK_ONLY", mask_only
101 print*,
"MERGE_FILE", trim(merge_file)
109 print*, mtnres,im,jm,nm,nr,nf0,nf1,efac,blat
110 nw=(nm+1)*((nr+1)*nm+2)
113 print *,
' Starting terr12 mtnlm7_slm30.f IMN,JMN:',imn,jmn
116 if( trim(outgrid) .NE.
"none" )
then 117 inquire(file=trim(outgrid), exist=fexist)
118 if(.not. fexist)
then 119 print*,
"FATAL ERROR: file "//trim(outgrid)
120 print*,
" does not exist." 124 inquire( ncid,opened=opened )
125 if( .NOT.opened )
exit 128 print*,
"outgrid=", trim(outgrid)
129 error=nf__open(trim(outgrid),nf_nowrite,fsize,ncid)
130 call netcdf_err(error,
'Open file '//trim(outgrid) )
131 error=nf_inq_dimid(ncid,
'nx', id_dim)
132 call netcdf_err(error,
'inquire dimension nx from file '//
134 error=nf_inq_dimlen(ncid,id_dim,nx)
135 call netcdf_err(error,
'inquire dimension nx length '//
136 &
'from file '//trim(outgrid) )
138 error=nf_inq_dimid(ncid,
'ny', id_dim)
139 call netcdf_err(error,
'inquire dimension ny from file '//
141 error=nf_inq_dimlen(ncid,id_dim,ny)
142 call netcdf_err(error,
'inquire dimension ny length '//
143 &
'from file '//trim(outgrid) )
145 if(im .ne. nx/2)
then 146 print*,
"IM=",im,
" /= grid file nx/2=",nx/2
147 print*,
"Set IM = ", nx/2
150 if(jm .ne. ny/2)
then 151 print*,
"JM=",jm,
" /= grid file ny/2=",ny/2
152 print*,
"Set JM = ", ny/2
156 call netcdf_err(error,
'close file '//trim(outgrid) )
160 CALL tersub(imn,jmn,im,jm,nm,nr,nf0,nf1,nw,efac,blat,
161 & outgrid,inputorog,mask_only,merge_file)
187 SUBROUTINE tersub(IMN,JMN,IM,JM,NM,NR,NF0,NF1,NW,EFAC,BLAT,
188 & OUTGRID,INPUTOROG,MASK_ONLY,MERGE_FILE)
192 integer :: IMN,JMN,IM,JM,NM,NR,NF0,NF1,NW
193 character(len=*),
intent(in) :: OUTGRID
194 character(len=*),
intent(in) :: INPUTOROG
195 character(len=*),
intent(in) :: MERGE_FILE
197 logical,
intent(in) :: mask_only
199 real,
parameter :: MISSING_VALUE=-9999.
200 real,
PARAMETER :: PI=3.1415926535897931
201 integer,
PARAMETER :: NMT=14
203 integer :: efac,blat,zsave1,zsave2
204 integer :: mskocn,notocn
205 integer :: i,j,nx,ny,ncid,js,jn,iw,ie,k,it,jt,error,id_dim
206 integer :: id_var,nx_in,ny_in,fsize,wgta,IN,INW,INE,IS,ISW,ISE
207 integer :: M,N,IMT,IRET,ios,latg2,istat,itest,jtest
208 integer :: i_south_pole,j_south_pole,i_north_pole,j_north_pole
209 integer :: maxc3,maxc4,maxc5,maxc6,maxc7,maxc8
213 integer,
allocatable :: JST(:),JEN(:),KPDS(:),KGDS(:),numi(:)
214 integer,
allocatable :: lonsperlat(:)
216 integer,
allocatable :: IST(:,:),IEN(:,:),ZSLMX(:,:)
217 integer,
allocatable :: ZAVG(:,:),ZSLM(:,:)
218 integer(1),
allocatable :: UMD(:,:)
219 integer(2),
allocatable :: glob(:,:)
221 integer,
allocatable :: IWORK(:,:,:)
223 real :: DEGRAD,maxlat, minlat,timef,tbeg,tend,tbeg1
224 real :: PHI,DELXN,RS,RN,slma,oroa,vara,var4a,xn,XS,FFF,WWW
225 real :: sumdif,avedif
227 real,
allocatable :: COSCLT(:),WGTCLT(:),RCLT(:),XLAT(:),DIFFX(:)
228 real,
allocatable :: XLON(:),ORS(:),oaa(:),ola(:),GLAT(:)
230 real,
allocatable :: GEOLON(:,:),GEOLON_C(:,:),DX(:,:)
231 real,
allocatable :: GEOLAT(:,:),GEOLAT_C(:,:),DY(:,:)
232 real,
allocatable :: SLM(:,:),ORO(:,:),VAR(:,:),ORF(:,:)
233 real,
allocatable :: land_frac(:,:),lake_frac(:,:)
234 real,
allocatable :: THETA(:,:),GAMMA(:,:),SIGMA(:,:),ELVMAX(:,:)
235 real,
allocatable :: VAR4(:,:),SLMI(:,:)
236 real,
allocatable :: WORK1(:,:),WORK2(:,:),WORK3(:,:),WORK4(:,:)
237 real,
allocatable :: WORK5(:,:),WORK6(:,:)
238 real,
allocatable :: tmpvar(:,:)
239 real,
allocatable :: slm_in(:,:), lon_in(:,:), lat_in(:,:)
240 real(4),
allocatable:: GICE(:,:),OCLSM(:,:)
242 real,
allocatable :: OA(:,:,:),OL(:,:,:),HPRIME(:,:,:)
243 real,
allocatable :: oa_in(:,:,:), ol_in(:,:,:)
246 complex :: ffj(im/2+1)
248 logical :: grid_from_file,output_binary,fexist,opened
249 logical :: SPECTR, REVLAT, FILTER
251 logical :: is_south_pole(IM,JM), is_north_pole(IM,JM)
254 output_binary = .false.
259 allocate (jst(jm),jen(jm),kpds(200),kgds(200),numi(jm))
260 allocate (lonsperlat(jm/2))
261 allocate (ist(im,jm),ien(im,jm),zslmx(2700,1350))
262 allocate (glob(imn,jmn))
265 allocate (cosclt(jm),wgtclt(jm),rclt(jm),xlat(jm),diffx(jm/2))
266 allocate (xlon(im),ors(nw),oaa(4),ola(4),glat(jmn))
268 allocate (zavg(imn,jmn))
269 allocate (zslm(imn,jmn))
270 allocate (umd(imn,jmn))
286 if (mskocn .eq. 1)
then 287 print *,
' Ocean Model LSM Present and ' 288 print *,
' Overrides OCEAN POINTS in LSM: mskocn=',mskocn
289 if (notocn .eq. 1)
then 290 print *,
' Ocean LSM Reversed: NOTOCN=',notocn
294 print *,
' Attempt to open/read UMD 30sec slmsk.' 296 error=nf__open(
"./landcover.umd.30s.nc",nf_nowrite,fsize,ncid)
297 call netcdf_err(error,
'Open file landcover.umd.30s.nc' )
298 error=nf_inq_varid(ncid,
'land_mask', id_var)
299 call netcdf_err(error,
'Inquire varid of land_mask')
300 error=nf_get_var_int1(ncid, id_var, umd)
301 call netcdf_err(error,
'Inquire data of land_mask')
302 error = nf_close(ncid)
304 print *,
' UMD lake, UMD(50,50)=',umd(50,50)
308 print *,
' Call read_g to read global topography' 328 print *,
' After read_g, glob(500,500)=',glob(500,500)
332 print*,
' IM, JM, NM, NR, NF0, NF1, EFAC, BLAT' 333 print*, im,jm,nm,nr,nf0,nf1,efac,blat
334 print *,
' imn,jmn,glob(imn,jmn)=',imn,jmn,glob(imn,jmn)
335 print *,
' UBOUND ZAVG=',ubound(zavg)
336 print *,
' UBOUND glob=',ubound(glob)
337 print *,
' UBOUND ZSLM=',ubound(zslm)
338 print *,
' UBOUND GICE=',imn+1,3601
339 print *,
' UBOUND OCLSM=',im,jm
370 if ( umd(i,j) .eq. 0 ) zslm(i,j) = 0
374 deallocate (zslmx,umd,glob)
389 read(20,*,iostat=ios) latg2,lonsperlat
390 if(ios.ne.0.or.2*latg2.ne.jm)
then 394 print *,ios,latg2,
'COMPUTE TERRAIN ON A FULL GAUSSIAN GRID' 397 numi(j)=lonsperlat(j)
400 numi(j)=lonsperlat(jm+1-j)
402 print *,ios,latg2,
'COMPUTE TERRAIN ON A REDUCED GAUSSIAN GRID',
412 print *,
' SPECTR=',spectr,
' REVLAT=',revlat,
' ** with GICE-07 **' 414 CALL splat(4,jm,cosclt,wgtclt)
416 rclt(j) = acos(cosclt(j))
419 phi = rclt(j) * degrad
421 xlat(jm-j+1) = phi - 90.
424 CALL splat(0,jm,cosclt,wgtclt)
426 rclt(j) = acos(cosclt(j))
427 xlat(j) = 90.0 - rclt(j) * degrad
431 allocate (gice(imn+1,3601))
435 diffx(j) = xlat(j) - xlat(j-1)
436 sumdif = sumdif + diffx(j)
438 avedif=sumdif/(float(jm/2))
442 write (6,106) (xlat(j),j=jm,1,-1)
443 106
format( 10(f7.3,1x))
444 107
format( 10(f9.5,1x))
449 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
452 &
' Before GICE ZAVG(1,2)=',zavg(1,2),zslm(1,2)
454 &
' Before GICE ZAVG(1,12)=',zavg(1,12),zslm(1,12)
456 &
' Before GICE ZAVG(1,52)=',zavg(1,52),zslm(1,52)
458 &
' Before GICE ZAVG(1,112)=',zavg(1,jmn-112),zslm(1,112)
463 error=nf__open(
"./topography.antarctica.ramp.30s.nc",
464 & nf_nowrite,fsize,ncid)
465 call netcdf_err(error,
'Opening RAMP topo file' )
466 error=nf_inq_varid(ncid,
'topo', id_var)
467 call netcdf_err(error,
'Inquire varid of RAMP topo')
468 error=nf_get_var_real(ncid, id_var, gice)
469 call netcdf_err(error,
'Inquire data of RAMP topo')
470 error = nf_close(ncid)
472 print *,
' GICE 30" Antarctica RAMP orog 43201x3601 read OK' 473 print *,
' Processing! ' 474 print *,
' Processing! ' 475 print *,
' Processing! ' 480 if( gice(i,j) .ne. -99. .and. gice(i,j) .ne. -1.0 )
then 481 if ( gice(i,j) .gt. 0.)
then 482 zavg(i,j) = int( gice(i,j) + 0.5 )
488 152
format(1x,
' ZAVG(i=',i4,
' j=',i4,
')=',i5,i3,
489 &
' orig:',i5,i4,
' Lat=',f7.3,f8.2,
'E',
' GICE=',f8.1)
495 allocate (oclsm(im,jm),slmi(im,jm))
502 if (mskocn .eq. 1)
then 506 open(25,form=
'formatted',iostat=istat)
509 print *,
' Ocean lsm file Open failure: mskocn,istat=',mskocn,istat
512 print *,
' Ocean lsm file Opened OK: mskocn,istat=',mskocn,istat
518 read(25,*,iostat=ios)oclsm
523 print *,
' Rd fail: Ocean lsm - continue, mskocn,ios=',mskocn,ios
526 print *,
' Rd OK: ocean lsm: mskocn,ios=',mskocn,ios
530 if ( mskocn .eq. 1 )
then 533 if ( notocn .eq. 0 )
then 534 slmi(i,j) = float(nint(oclsm(i,j)))
536 if ( nint(oclsm(i,j)) .eq. 0)
then 544 print *,
' OCLSM',oclsm(1,1),oclsm(50,50),oclsm(75,75),oclsm(im,jm)
545 print *,
' SLMI:',slmi(1,1),slmi(50,50),slmi(75,75),slmi(im,jm)
553 print *,
' Not using Ocean model land sea mask' 556 if (mskocn .eq. 1)
then 557 print *,
' LSM:',oclsm(1,1),oclsm(50,50),oclsm(75,75),oclsm(im,jm)
560 allocate (geolon(im,jm),geolon_c(im+1,jm+1),dx(im,jm))
561 allocate (geolat(im,jm),geolat_c(im+1,jm+1),dy(im,jm))
562 allocate (slm(im,jm),oro(im,jm),var(im,jm),var4(im,jm))
563 allocate (land_frac(im,jm),lake_frac(im,jm))
566 grid_from_file = .false.
567 is_south_pole = .false.
568 is_north_pole = .false.
573 if( trim(outgrid) .NE.
"none" )
then 574 grid_from_file = .true.
575 inquire(file=trim(outgrid), exist=fexist)
576 if(.not. fexist)
then 577 print*,
"FATAL ERROR: file "//trim(outgrid)
578 print*,
"does not exist." 582 inquire( ncid,opened=opened )
583 if( .NOT.opened )
exit 586 print*,
"outgrid=", trim(outgrid)
587 error=nf__open(trim(outgrid),nf_nowrite,fsize,ncid)
588 call netcdf_err(error,
'Open file '//trim(outgrid) )
589 error=nf_inq_dimid(ncid,
'nx', id_dim)
590 call netcdf_err(error,
'inquire dimension nx from file '//
594 print*,
"Read the grid from file "//trim(outgrid)
596 allocate(tmpvar(nx+1,ny+1))
598 error=nf_inq_varid(ncid,
'x', id_var)
599 call netcdf_err(error,
'inquire varid of x from file ' 601 error=nf_get_var_double(ncid, id_var, tmpvar)
602 call netcdf_err(error,
'inquire data of x from file ' 605 do j = 1,ny+1;
do i = 1,nx+1
606 if(tmpvar(i,j) .NE. missing_value)
then 607 if(tmpvar(i,j) .GT. 360) tmpvar(i,j) = tmpvar(i,j) - 360
608 if(tmpvar(i,j) .LT. 0) tmpvar(i,j) = tmpvar(i,j) + 360
612 geolon(1:im,1:jm) = tmpvar(2:nx:2,2:ny:2)
613 geolon_c(1:im+1,1:jm+1) = tmpvar(1:nx+1:2,1:ny+1:2)
615 error=nf_inq_varid(ncid,
'y', id_var)
616 call netcdf_err(error,
'inquire varid of y from file ' 618 error=nf_get_var_double(ncid, id_var, tmpvar)
619 call netcdf_err(error,
'inquire data of y from file ' 621 geolat(1:im,1:jm) = tmpvar(2:nx:2,2:ny:2)
622 geolat_c(1:im+1,1:jm+1) = tmpvar(1:nx+1:2,1:ny+1:2)
631 do j = 1, ny+1;
do i = 1, nx+1
632 if( tmpvar(i,j) > maxlat )
then 637 if( tmpvar(i,j) < minlat )
then 644 if(maxlat < 89.9 )
then 648 if(minlat > -89.9 )
then 652 print*,
"minlat=", minlat,
"maxlat=", maxlat
653 print*,
"north pole supergrid index is ",
654 & i_north_pole, j_north_pole
655 print*,
"south pole supergrid index is ",
656 & i_south_pole, j_south_pole
659 if(i_south_pole >0 .and. j_south_pole > 0)
then 660 if(mod(i_south_pole,2)==0)
then 661 do j = 1, jm;
do i = 1, im
662 if(i==i_south_pole/2 .and. (j==j_south_pole/2
663 & .or. j==j_south_pole/2+1) )
then 664 is_south_pole(i,j) = .true.
665 print*,
"south pole at i,j=", i, j
669 do j = 1, jm;
do i = 1, im
670 if((i==i_south_pole/2 .or. i==i_south_pole/2+1)
671 & .and. (j==j_south_pole/2 .or.
672 & j==j_south_pole/2+1) )
then 673 is_south_pole(i,j) = .true.
674 print*,
"south pole at i,j=", i, j
679 if(i_north_pole >0 .and. j_north_pole > 0)
then 680 if(mod(i_north_pole,2)==0)
then 681 do j = 1, jm;
do i = 1, im
682 if(i==i_north_pole/2 .and. (j==j_north_pole/2 .or.
683 & j==j_north_pole/2+1) )
then 684 is_north_pole(i,j) = .true.
685 print*,
"north pole at i,j=", i, j
689 do j = 1, jm;
do i = 1, im
690 if((i==i_north_pole/2 .or. i==i_north_pole/2+1)
691 & .and. (j==j_north_pole/2 .or.
692 & j==j_north_pole/2+1) )
then 693 is_north_pole(i,j) = .true.
694 print*,
"north pole at i,j=", i, j
701 allocate(tmpvar(nx,ny))
702 error=nf_inq_varid(ncid,
'area', id_var)
703 call netcdf_err(error,
'inquire varid of area from file ' 705 error=nf_get_var_double(ncid, id_var, tmpvar)
706 call netcdf_err(error,
'inquire data of area from file ' 711 dx(i,j) = sqrt(tmpvar(2*i-1,2*j-1)+tmpvar(2*i,2*j-1)
712 & +tmpvar(2*i-1,2*j )+tmpvar(2*i,2*j ))
738 write(6,*)
' Timer 1 time= ',tend-tbeg
740 if(grid_from_file)
then 743 IF (merge_file ==
'none')
then 745 & im,jm,imn,jmn,geolon_c,geolat_c)
748 print*,
'Read in external mask ',merge_file
753 print*,
'Computing mask only.' 761 CALL makemt2(zavg,zslm,oro,slm,var,var4,glat,
762 & im,jm,imn,jmn,geolon_c,geolat_c,
lake_frac,land_frac)
765 write(6,*)
' MAKEMT2 time= ',tend-tbeg
767 CALL makemt(zavg,zslm,oro,slm,var,var4,glat,
768 & ist,ien,jst,jen,im,jm,imn,jmn,xlat,numi)
771 call minmxj(im,jm,oro,
' ORO')
772 call minmxj(im,jm,slm,
' SLM')
773 call minmxj(im,jm,var,
' VAR')
774 call minmxj(im,jm,var4,
' VAR4')
795 allocate (theta(im,jm),gamma(im,jm),sigma(im,jm),elvmax(im,jm))
796 if(grid_from_file)
then 798 CALL makepc2(zavg,zslm,theta,gamma,sigma,glat,
799 1 im,jm,imn,jmn,geolon_c,geolat_c,slm)
801 write(6,*)
' MAKEPC2 time= ',tend-tbeg
803 CALL makepc(zavg,zslm,theta,gamma,sigma,glat,
804 1 ist,ien,jst,jen,im,jm,imn,jmn,xlat,numi)
807 call minmxj(im,jm,theta,
' THETA')
808 call minmxj(im,jm,gamma,
' GAMMA')
809 call minmxj(im,jm,sigma,
' SIGMA')
818 allocate (iwork(im,jm,4))
819 allocate (oa(im,jm,4),ol(im,jm,4),hprime(im,jm,14))
820 allocate (work1(im,jm),work2(im,jm),work3(im,jm),work4(im,jm))
821 allocate (work5(im,jm),work6(im,jm))
823 call minmxj(im,jm,oro,
' ORO')
824 print*,
"inputorog=", trim(inputorog)
825 if(grid_from_file)
then 826 if(trim(inputorog) ==
"none")
then 827 print*,
"calling MAKEOA2 to compute OA, OL" 829 CALL makeoa2(zavg,zslm,var,glat,oa,ol,iwork,elvmax,oro,
830 1 work1,work2,work3,work4,work5,work6,
831 2 im,jm,imn,jmn,geolon_c,geolat_c,
832 3 geolon,geolat,dx,dy,is_south_pole,is_north_pole)
834 write(6,*)
' MAKEOA2 time= ',tend-tbeg
837 error=nf__open(trim(inputorog),nf_nowrite,fsize,ncid)
838 call netcdf_err(error,
'Open file '//trim(inputorog) )
839 error=nf_inq_dimid(ncid,
'lon', id_dim)
840 call netcdf_err(error,
'inquire dimension lon from file '//
842 error=nf_inq_dimlen(ncid,id_dim,nx_in)
843 call netcdf_err(error,
'inquire dimension lon length '//
844 &
'from file '//trim(inputorog) )
845 error=nf_inq_dimid(ncid,
'lat', id_dim)
846 call netcdf_err(error,
'inquire dimension lat from file '//
848 error=nf_inq_dimlen(ncid,id_dim,ny_in)
849 call netcdf_err(error,
'inquire dimension lat length '//
850 &
'from file '//trim(inputorog) )
852 print*,
"extrapolate OA, OL from Gaussian grid with nx=",
853 & nx_in,
", ny=", ny_in
854 allocate(oa_in(nx_in,ny_in,4), ol_in(nx_in,ny_in,4))
855 allocate(slm_in(nx_in,ny_in) )
856 allocate(lon_in(nx_in,ny_in), lat_in(nx_in,ny_in) )
858 error=nf_inq_varid(ncid,
'oa1', id_var)
859 call netcdf_err(error,
'inquire varid of oa1 from file ' 860 & //trim(inputorog) )
861 error=nf_get_var_double(ncid, id_var, oa_in(:,:,1))
862 call netcdf_err(error,
'inquire data of oa1 from file ' 863 & //trim(inputorog) )
864 error=nf_inq_varid(ncid,
'oa2', id_var)
865 call netcdf_err(error,
'inquire varid of oa2 from file ' 866 & //trim(inputorog) )
867 error=nf_get_var_double(ncid, id_var, oa_in(:,:,2))
868 call netcdf_err(error,
'inquire data of oa2 from file ' 869 & //trim(inputorog) )
870 error=nf_inq_varid(ncid,
'oa3', id_var)
871 call netcdf_err(error,
'inquire varid of oa3 from file ' 872 & //trim(inputorog) )
873 error=nf_get_var_double(ncid, id_var, oa_in(:,:,3))
874 call netcdf_err(error,
'inquire data of oa3 from file ' 875 & //trim(inputorog) )
876 error=nf_inq_varid(ncid,
'oa4', id_var)
877 call netcdf_err(error,
'inquire varid of oa4 from file ' 878 & //trim(inputorog) )
879 error=nf_get_var_double(ncid, id_var, oa_in(:,:,4))
880 call netcdf_err(error,
'inquire data of oa4 from file ' 881 & //trim(inputorog) )
883 error=nf_inq_varid(ncid,
'ol1', id_var)
884 call netcdf_err(error,
'inquire varid of ol1 from file ' 885 & //trim(inputorog) )
886 error=nf_get_var_double(ncid, id_var, ol_in(:,:,1))
887 call netcdf_err(error,
'inquire data of ol1 from file ' 888 & //trim(inputorog) )
889 error=nf_inq_varid(ncid,
'ol2', id_var)
890 call netcdf_err(error,
'inquire varid of ol2 from file ' 891 & //trim(inputorog) )
892 error=nf_get_var_double(ncid, id_var, ol_in(:,:,2))
893 call netcdf_err(error,
'inquire data of ol2 from file ' 894 & //trim(inputorog) )
895 error=nf_inq_varid(ncid,
'ol3', id_var)
896 call netcdf_err(error,
'inquire varid of ol3 from file ' 897 & //trim(inputorog) )
898 error=nf_get_var_double(ncid, id_var, ol_in(:,:,3))
899 call netcdf_err(error,
'inquire data of ol3 from file ' 900 & //trim(inputorog) )
901 error=nf_inq_varid(ncid,
'ol4', id_var)
902 call netcdf_err(error,
'inquire varid of ol4 from file ' 903 & //trim(inputorog) )
904 error=nf_get_var_double(ncid, id_var, ol_in(:,:,4))
905 call netcdf_err(error,
'inquire data of ol4 from file ' 906 & //trim(inputorog) )
908 error=nf_inq_varid(ncid,
'slmsk', id_var)
909 call netcdf_err(error,
'inquire varid of slmsk from file ' 910 & //trim(inputorog) )
911 error=nf_get_var_double(ncid, id_var, slm_in)
912 call netcdf_err(error,
'inquire data of slmsk from file ' 913 & //trim(inputorog) )
915 error=nf_inq_varid(ncid,
'geolon', id_var)
916 call netcdf_err(error,
'inquire varid of geolon from file ' 917 & //trim(inputorog) )
918 error=nf_get_var_double(ncid, id_var, lon_in)
919 call netcdf_err(error,
'inquire data of geolon from file ' 920 & //trim(inputorog) )
922 error=nf_inq_varid(ncid,
'geolat', id_var)
923 call netcdf_err(error,
'inquire varid of geolat from file ' 924 & //trim(inputorog) )
925 error=nf_get_var_double(ncid, id_var, lat_in)
926 call netcdf_err(error,
'inquire data of geolat from file ' 927 & //trim(inputorog) )
930 do j=1,ny_in;
do i=1,nx_in
931 if(slm_in(i,j) == 2) slm_in(i,j) = 0
936 & //trim(inputorog) )
938 print*,
"calling MAKEOA3 to compute OA, OL" 939 CALL makeoa3(zavg,zslm,var,glat,oa,ol,iwork,elvmax,oro,slm,
940 1 work1,work2,work3,work4,work5,work6,
941 2 im,jm,imn,jmn,geolon_c,geolat_c,
942 3 geolon,geolat,is_south_pole,is_north_pole,nx_in,ny_in,
943 4 oa_in,ol_in,slm_in,lon_in,lat_in)
945 deallocate(oa_in,ol_in,slm_in,lon_in,lat_in)
949 CALL makeoa(zavg,var,glat,oa,ol,iwork,elvmax,oro,
950 1 work1,work2,work3,work4,
952 3 ist,ien,jst,jen,im,jm,imn,jmn,xlat,numi)
957 deallocate (zslm,zavg)
959 deallocate (work2,work3,work4,work5,work6)
965 call minmxj(im,jm,oa,
' OA')
966 call minmxj(im,jm,ol,
' OL')
967 call minmxj(im,jm,elvmax,
' ELVMAX')
968 call minmxj(im,jm,oro,
' ORO')
988 if (elvmax(i,j) .gt. 3000.) maxc3 = maxc3 +1
989 if (elvmax(i,j) .gt. 4000.) maxc4 = maxc4 +1
990 if (elvmax(i,j) .gt. 5000.) maxc5 = maxc5 +1
991 if (elvmax(i,j) .gt. 6000.) maxc6 = maxc6 +1
992 if (elvmax(i,j) .gt. 7000.) maxc7 = maxc7 +1
993 if (elvmax(i,j) .gt. 8000.) maxc8 = maxc8 +1
996 print *,
' MAXC3:',maxc3,maxc4,maxc5,maxc6,maxc7,maxc8
1001 print *,
' ===> Replacing ELVMAX with ELVMAX-ORO <=== ' 1002 print *,
' ===> if ELVMAX<=ORO replace with proxy <=== ' 1003 print *,
' ===> the sum of mean orog (ORO) and std dev <=== ' 1006 if (elvmax(i,j) .lt. oro(i,j) )
then 1008 elvmax(i,j) = max( 3. * var(i,j),0.)
1010 elvmax(i,j) = max( elvmax(i,j) - oro(i,j),0.)
1022 if (elvmax(i,j) .gt. 3000.) maxc3 = maxc3 +1
1023 if (elvmax(i,j) .gt. 4000.) maxc4 = maxc4 +1
1024 if (elvmax(i,j) .gt. 5000.) maxc5 = maxc5 +1
1025 if (elvmax(i,j) .gt. 6000.) maxc6 = maxc6 +1
1026 if (elvmax(i,j) .gt. 7000.) maxc7 = maxc7 +1
1027 if (elvmax(i,j) .gt. 8000.) maxc8 = maxc8 +1
1030 print *,
' after MAXC 3-6 km:',maxc3,maxc4,maxc5,maxc6
1032 call mnmxja(im,jm,elvmax,itest,jtest,
' ELVMAX')
1037 print *,
' Testing at point (itest,jtest)=',itest,jtest
1038 print *,
' SLM(itest,jtest)=',slm(itest,jtest),itest,jtest
1039 print *,
' ORO(itest,jtest)=',oro(itest,jtest),itest,jtest
1042 IF(slm(i,j).EQ.0.)
THEN 1072 IF (merge_file ==
'none')
then 1074 msk_ocn :
if ( mskocn .eq. 1 )
then 1078 if (abs(oro(i,j)) .lt. 1. )
then 1079 slm(i,j) = slmi(i,j)
1081 if ( slmi(i,j) .eq. 1. .and. slm(i,j) .eq. 1) slm(i,j) = 1
1082 if ( slmi(i,j) .eq. 0. .and. slm(i,j) .eq. 0) slm(i,j) = 0
1083 if ( slmi(i,j) .eq. 0. .and. slm(i,j) .eq. 1) slm(i,j) = 0
1084 if ( slmi(i,j) .eq. 0. .and. slm(i,j) .eq. 0) slm(i,j) = 0
1090 print *,
' SLM(itest,jtest)=',slm(itest,jtest),itest,jtest
1091 print *,
' ORO(itest,jtest)=',oro(itest,jtest),itest,jtest
1095 IF (merge_file ==
'none')
then 1098 iso_loop :
DO j=2,jm-1
1101 rn=
REAL(NUMI(JN))/
REAL(NUMI(J))
1102 rs=
REAL(NUMI(JS))/
REAL(NUMI(J))
1106 slma=slm(iw,j)+slm(ie,j)
1107 oroa=oro(iw,j)+oro(ie,j)
1108 vara=var(iw,j)+var(ie,j)
1109 var4a=var4(iw,j)+var4(ie,j)
1111 oaa(k)=oa(iw,j,k)+oa(ie,j,k)
1113 ola(k)=ol(iw,j,k)+ol(ie,j,k)
1117 IF(abs(xn-nint(xn)).LT.1.e-2)
THEN 1118 in=mod(nint(xn)-1,numi(jn))+1
1119 inw=mod(in+numi(jn)-2,numi(jn))+1
1120 ine=mod(in,numi(jn))+1
1121 slma=slma+slm(inw,jn)+slm(in,jn)+slm(ine,jn)
1122 oroa=oroa+oro(inw,jn)+oro(in,jn)+oro(ine,jn)
1123 vara=vara+var(inw,jn)+var(in,jn)+var(ine,jn)
1124 var4a=var4a+var4(inw,jn)+var4(in,jn)+var4(ine,jn)
1126 oaa(k)=oaa(k)+oa(inw,jn,k)+oa(in,jn,k)+oa(ine,jn,k)
1127 ola(k)=ola(k)+ol(inw,jn,k)+ol(in,jn,k)+ol(ine,jn,k)
1132 ine=mod(inw,numi(jn))+1
1133 slma=slma+slm(inw,jn)+slm(ine,jn)
1134 oroa=oroa+oro(inw,jn)+oro(ine,jn)
1135 vara=vara+var(inw,jn)+var(ine,jn)
1136 var4a=var4a+var4(inw,jn)+var4(ine,jn)
1138 oaa(k)=oaa(k)+oa(inw,jn,k)+oa(ine,jn,k)
1139 ola(k)=ola(k)+ol(inw,jn,k)+ol(ine,jn,k)
1144 IF(abs(xs-nint(xs)).LT.1.e-2)
THEN 1145 is=mod(nint(xs)-1,numi(js))+1
1146 isw=mod(is+numi(js)-2,numi(js))+1
1147 ise=mod(is,numi(js))+1
1148 slma=slma+slm(isw,js)+slm(is,js)+slm(ise,js)
1149 oroa=oroa+oro(isw,js)+oro(is,js)+oro(ise,js)
1150 vara=vara+var(isw,js)+var(is,js)+var(ise,js)
1151 var4a=var4a+var4(isw,js)+var4(is,js)+var4(ise,js)
1153 oaa(k)=oaa(k)+oa(isw,js,k)+oa(is,js,k)+oa(ise,js,k)
1154 ola(k)=ola(k)+ol(isw,js,k)+ol(is,js,k)+ol(ise,js,k)
1159 ise=mod(isw,numi(js))+1
1160 slma=slma+slm(isw,js)+slm(ise,js)
1161 oroa=oroa+oro(isw,js)+oro(ise,js)
1162 vara=vara+var(isw,js)+var(ise,js)
1163 var4a=var4a+var4(isw,js)+var4(ise,js)
1165 oaa(k)=oaa(k)+oa(isw,js,k)+oa(ise,js,k)
1166 ola(k)=ola(k)+ol(isw,js,k)+ol(ise,js,k)
1177 IF(slm(i,j).EQ.0..AND.slma.EQ.wgta)
THEN 1178 print
'("SEA ",2F8.0," MODIFIED TO LAND",2F8.0," AT ",2I8)',
1179 & oro(i,j),var(i,j),oroa,vara,i,j
1188 ELSEIF(slm(i,j).EQ.1..AND.slma.EQ.0.)
THEN 1189 print
'("LAND",2F8.0," MODIFIED TO SEA ",2F8.0," AT ",2I8)',
1190 & oro(i,j),var(i,j),oroa,vara,i,j
1203 print *,
' after isolated points removed' 1204 call minmxj(im,jm,oro,
' ORO')
1206 print *,
' ORO(itest,jtest)=',oro(itest,jtest)
1207 print *,
' VAR(itest,jtest)=',var(itest,jtest)
1208 print *,
' VAR4(itest,jtest)=',var4(itest,jtest)
1209 print *,
' OA(itest,jtest,1)=',oa(itest,jtest,1)
1210 print *,
' OA(itest,jtest,2)=',oa(itest,jtest,2)
1211 print *,
' OA(itest,jtest,3)=',oa(itest,jtest,3)
1212 print *,
' OA(itest,jtest,4)=',oa(itest,jtest,4)
1213 print *,
' OL(itest,jtest,1)=',ol(itest,jtest,1)
1214 print *,
' OL(itest,jtest,2)=',ol(itest,jtest,2)
1215 print *,
' OL(itest,jtest,3)=',ol(itest,jtest,3)
1216 print *,
' OL(itest,jtest,4)=',ol(itest,jtest,4)
1217 print *,
' Testing at point (itest,jtest)=',itest,jtest
1218 print *,
' THETA(itest,jtest)=',theta(itest,jtest)
1219 print *,
' GAMMA(itest,jtest)=',gamma(itest,jtest)
1220 print *,
' SIGMA(itest,jtest)=',sigma(itest,jtest)
1221 print *,
' ELVMAX(itest,jtest)=',elvmax(itest,jtest)
1222 print *,
' EFAC=',efac
1229 oro(i,j) = oro(i,j) + efac*var(i,j)
1230 hprime(i,j,1) = var(i,j)
1231 hprime(i,j,2) = var4(i,j)
1232 hprime(i,j,3) = oa(i,j,1)
1233 hprime(i,j,4) = oa(i,j,2)
1234 hprime(i,j,5) = oa(i,j,3)
1235 hprime(i,j,6) = oa(i,j,4)
1236 hprime(i,j,7) = ol(i,j,1)
1237 hprime(i,j,8) = ol(i,j,2)
1238 hprime(i,j,9) = ol(i,j,3)
1239 hprime(i,j,10)= ol(i,j,4)
1240 hprime(i,j,11)= theta(i,j)
1241 hprime(i,j,12)= gamma(i,j)
1242 hprime(i,j,13)= sigma(i,j)
1243 hprime(i,j,14)= elvmax(i,j)
1247 call mnmxja(im,jm,elvmax,itest,jtest,
' ELVMAX')
1256 allocate (orf(im,jm))
1257 IF ( nf1 - nf0 .eq. 0 ) filter=.false.
1258 print *,
' NF1, NF0, FILTER=',nf1,nf0,filter
1262 if(numi(j).lt.im)
then 1264 call spfft1(numi(j),im/2+1,numi(j),1,ffj,oro(1,j),-1)
1265 call spfft1(im,im/2+1,im,1,ffj,oro(1,j),+1)
1268 CALL sptez(nr,nm,4,im,jm,ors,oro,-1)
1270 print *,
' about to apply spectral filter ' 1276 www=max(1.-fff*(n-nf0)**2,0.)
1277 ors(i+1)=ors(i+1)*www
1278 ors(i+2)=ors(i+2)*www
1284 CALL sptez(nr,nm,4,im,jm,ors,orf,+1)
1286 if(numi(j).lt.im)
then 1287 call spfft1(im,im/2+1,im,1,ffj,orf(1,j),-1)
1288 call spfft1(numi(j),im/2+1,numi(j),1,ffj,orf(1,j),+1)
1294 CALL revers(im, jm, numi, slm, work1)
1295 CALL revers(im, jm, numi, oro, work1)
1297 CALL revers(im, jm, numi, hprime(1,1,imt), work1)
1306 call mnmxja(im,jm,elvmax,itest,jtest,
' ELVMAX')
1307 print *,
' ELVMAX(',itest,jtest,
')=',elvmax(itest,jtest)
1308 print *,
' after spectral filter is applied' 1309 call minmxj(im,jm,oro,
' ORO')
1310 call minmxj(im,jm,orf,
' ORF')
1313 call rg2gg(im,jm,numi,slm)
1314 call rg2gg(im,jm,numi,oro)
1315 call rg2gg(im,jm,numi,orf)
1318 call rg2gg(im,jm,numi,hprime(1,1,imt))
1321 print *,
' after nearest neighbor interpolation applied ' 1322 call minmxj(im,jm,oro,
' ORO')
1323 call minmxj(im,jm,orf,
' ORF')
1324 call mnmxja(im,jm,elvmax,itest,jtest,
' ELVMAX')
1325 print *,
' ORO,ORF(itest,jtest),itest,jtest:',
1326 & oro(itest,jtest),orf(itest,jtest),itest,jtest
1327 print *,
' ELVMAX(',itest,jtest,
')=',elvmax(itest,jtest)
1333 if ( i .le. 21 .and. i .ge. 1 )
then 1334 if (j .eq. jm )
write(6,153)i,j,oro(i,j),elvmax(i,j),slm(i,j)
1335 153
format(1x,
' ORO,ELVMAX(i=',i4,
' j=',i4,
')=',2e14.5,f5.1)
1340 write(6,*)
' Timer 5 time= ',tend-tbeg
1341 if (output_binary)
then 1344 print *,
' OUTPUT BINARY FIELDS' 1345 WRITE(51)
REAL(SLM,4)
1346 WRITE(52)
REAL(ORF,4)
1347 WRITE(53)
REAL(HPRIME,4)
1348 WRITE(54)
REAL(ORS,4)
1349 WRITE(55)
REAL(ORO,4)
1350 WRITE(66)
REAL(THETA,4)
1351 WRITE(67)
REAL(GAMMA,4)
1352 WRITE(68)
REAL(SIGMA,4)
1354 if ( mskocn .eq. 1 )
then 1356 WRITE(27,iostat=ios) oclsm
1357 print *,
' write OCLSM input:',ios
1361 call minmxj(im,jm,oro,
' ORO')
1362 print *,
' IM=',im,
' JM=',jm,
' SPECTR=',spectr
1364 WRITE(71)
REAL(SLM,4)
1366 WRITE(71)
REAL(HPRIME(:,:,IMT),4)
1367 print *,
' HPRIME(',itest,jtest,imt,
')=',hprime(itest,jtest,imt)
1369 WRITE(71)
REAL(ORO,4)
1371 WRITE(71)
REAL(ORF,4) 1396 kgds(4)=90000-180000/pi*rclt(1)
1398 kgds(7)=180000/pi*rclt(1)-90000
1399 kgds(8)=-nint(360000./im)
1400 kgds(9)=nint(360000./im)
1404 CALL baopen(56,
'fort.56',iret)
1405 if (iret .ne. 0) print *,
' BAOPEN ERROR UNIT 56: IRET=',iret
1406 CALL putgb(56,im*jm,kpds,kgds,lb,slm,iret)
1407 print *,
' SLM: putgb-KPDS(22,5),iret:',kpds(22),kpds(5),iret
1408 if (iret .ne. 0) print *,
' SLM PUTGB ERROR: UNIT 56: IRET=',iret
1409 print *,
' SLM: putgb-KPDS(22,5),iret:',kpds(22),kpds(5),iret
1421 CALL baopen(57,
'fort.57',iret)
1422 CALL putgb(57,im*jm,kpds,kgds,lb,orf,iret)
1423 print *,
' ORF (ORO): putgb-KPDS(22,5),iret:',kpds(22),kpds(5),iret
1430 CALL baopen(58,
'fort.58',iret)
1431 CALL putgb(58,im*jm,kpds,kgds,lb,theta,iret)
1432 print *,
' THETA: putgb-KPDS(22,5),iret:',kpds(22),kpds(5),iret
1439 CALL baopen(60,
'fort.60',iret)
1440 CALL putgb(60,im*jm,kpds,kgds,lb,sigma,iret)
1441 print *,
' SIGMA: putgb-KPDS(22,5),iret:',kpds(22),kpds(5),iret
1448 CALL baopen(59,
'fort.59',iret)
1449 CALL putgb(59,im*jm,kpds,kgds,lb,gamma,iret)
1450 print *,
' GAMMA: putgb-KPDS(22,5),iret:',kpds(22),kpds(5),iret
1454 CALL baopen(61,
'fort.61',iret)
1455 CALL putgb(61,im*jm,kpds,kgds,lb,hprime,iret)
1456 print *,
' HPRIME: putgb-KPDS(22,5),iret:',kpds(22),kpds(5),iret
1461 CALL baopen(62,
'fort.62',iret)
1462 CALL putgb(62,im*jm,kpds,kgds,lb,elvmax,iret)
1463 print *,
' ELVMAX: putgb-KPDS(22,5),iret:',kpds(22),kpds(5),iret
1468 xlon(i) = delxn*(i-1)
1470 IF(trim(outgrid) ==
"none")
THEN 1473 geolon(i,j) = xlon(i)
1474 geolat(i,j) = xlat(j)
1479 xlat(j) = geolat(1,j)
1482 xlon(i) = geolon(i,1)
1486 write(6,*)
' Binary output time= ',tend-tbeg
1488 CALL write_netcdf(im,jm,slm,land_frac,oro,orf,hprime,1,1,
1489 1 geolon(1:im,1:jm),geolat(1:im,1:jm), xlon,xlat)
1491 write(6,*)
' WRITE_NETCDF time= ',tend-tbeg
1492 print *,
' wrote netcdf file out.oro.tile?.nc' 1494 print *,
' ===== Deallocate Arrays and ENDING MTN VAR OROG program' 1497 deallocate(jst,jen,kpds,kgds,numi,lonsperlat)
1498 deallocate(cosclt,wgtclt,rclt,xlat,diffx,xlon,ors,oaa,ola,glat)
1502 deallocate (geolon,geolon_c,geolat,geolat_c)
1503 deallocate (slm,oro,var,orf,land_frac)
1504 deallocate (theta,gamma,sigma,elvmax)
1508 write(6,*)
' Total runtime time= ',tend-tbeg1
1541 SUBROUTINE makemt(ZAVG,ZSLM,ORO,SLM,VAR,VAR4,
1542 1 GLAT,IST,IEN,JST,JEN,IM,JM,IMN,JMN,XLAT,numi)
1543 dimension glat(jmn),xlat(jm)
1545 INTEGER ZAVG(IMN,JMN),ZSLM(IMN,JMN)
1546 DIMENSION ORO(IM,JM),SLM(IM,JM),VAR(IM,JM),VAR4(IM,JM)
1547 dimension ist(im,jm),ien(im,jm),jst(jm),jen(jm),numi(jm)
1553 print *,
' _____ SUBROUTINE MAKEMT ' 1560 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
1570 faclon = delx / delxn
1571 ist(i,j) = faclon * float(i-1) - faclon * 0.5 + 1
1572 ien(i,j) = faclon * float(i) - faclon * 0.5 + 1
1576 IF (ist(i,j) .LE. 0) ist(i,j) = ist(i,j) + imn
1577 IF (ien(i,j) .LT. ist(i,j)) ien(i,j) = ien(i,j) + imn
1586 print *,
' DELX=',delx,
' DELXN=',delxn
1590 xxlat = (xlat(j)+xlat(j+1))/2.
1591 IF(flag.AND.glat(j1).GT.xxlat)
THEN 1599 jst(jm) = max(jst(jm-1) - (jen(jm-1)-jst(jm-1)),1)
1600 jen(1) = min(jen(2) + (jen(2)-jst(2)),jmn)
1618 DO ii1 = 1, ien(i,j) - ist(i,j) + 1
1619 i1 = ist(i,j) + ii1 - 1
1620 IF(i1.LE.0.) i1 = i1 + imn
1621 IF(i1.GT.imn) i1 = i1 - imn
1628 xland = xland + float(zslm(i1,j1))
1629 xwatr = xwatr + float(1-zslm(i1,j1))
1631 height = float(zavg(i1,j1))
1633 IF(height.LT.-990.) height = 0.0
1634 xl1 = xl1 + height * float(zslm(i1,j1))
1635 xs1 = xs1 + height * float(1-zslm(i1,j1))
1637 xw2 = xw2 + height ** 2
1648 IF(xnsum.GT.1.)
THEN 1653 slm(i,j) = float(nint(xland/xnsum))
1654 IF(slm(i,j).NE.0.)
THEN 1655 oro(i,j)= xl1 / xland
1657 oro(i,j)= xs1 / xwatr
1659 var(i,j)=sqrt(max(xw2/xnsum-(xw1/xnsum)**2,0.))
1660 DO ii1 = 1, ien(i,j) - ist(i,j) + 1
1661 i1 = ist(i,j) + ii1 - 1
1662 IF(i1.LE.0.) i1 = i1 + imn
1663 IF(i1.GT.imn) i1 = i1 - imn
1665 height = float(zavg(i1,j1))
1666 IF(height.LT.-990.) height = 0.0
1667 xw4 = xw4 + (height-oro(i,j)) ** 4
1670 IF(var(i,j).GT.1.)
THEN 1674 var4(i,j) = min(xw4/xnsum/var(i,j) **4,10.)
1679 WRITE(6,*)
"! MAKEMT ORO SLM VAR VAR4 DONE" 1704 SUBROUTINE get_index(IMN,JMN,npts,lonO,latO,DELXN,
1705 & jst,jen,ilist,numx)
1707 integer,
intent(in) :: IMN,JMN
1709 real,
intent(in) :: LONO(npts), LATO(npts)
1710 real,
intent(in) :: DELXN
1711 integer,
intent(out) :: jst,jen
1712 integer,
intent(out) :: ilist(IMN)
1713 integer,
intent(out) :: numx
1714 real minlat,maxlat,minlon,maxlon
1715 integer i2, ii, ist, ien
1717 minlat = minval(lato)
1718 maxlat = maxval(lato)
1719 minlon = minval(lono)
1720 maxlon = maxval(lono)
1721 ist = minlon/delxn+1
1722 ien = maxlon/delxn+1
1723 jst = (minlat+90)/delxn+1
1724 jen = (maxlat+90)/delxn
1729 if(jen>jmn) jen = jmn
1732 if((jst == 1 .OR. jen == jmn) .and.
1733 & (ien-ist+1 > imn/2) )
then 1738 else if( ien-ist+1 > imn/2 )
then 1744 ii = lono(i2)/delxn+1
1745 if(ii <0 .or. ii>imn) print*,
"ii=",ii,imn,lono(i2),delxn
1746 if( ii < imn/2 )
then 1748 else if( ii > imn/2 )
then 1752 if(ist<1 .OR. ist>imn)
then 1753 print*, .or.
"FATAL ERROR: ist<1 ist>IMN" 1756 if(ien<1 .OR. ien>imn)
then 1757 print*, .or.
"FATAL ERROR: iend<1 iend>IMN" 1761 numx = imn - ien + 1
1763 ilist(i2) = ien + (i2-1)
1772 ilist(i2) = ist + (i2-1)
1793 SUBROUTINE make_mask(zslm,SLM,land_frac,
1794 1 GLAT,IM,JM,IMN,JMN,lon_c,lat_c)
1796 real,
parameter :: D2R = 3.14159265358979/180.
1797 integer,
parameter :: MAXSUM=20000000
1798 integer im, jm, imn, jmn, jst, jen
1799 real GLAT(JMN), GLON(IMN)
1800 INTEGER ZSLM(IMN,JMN)
1801 real land_frac(IM,JM)
1803 real lon_c(IM+1,JM+1), lat_c(IM+1,JM+1)
1804 real LONO(4),LATO(4),LONI,LATI
1805 integer JM1,i,j,nsum,nsum_all,ii,jj,numx,i2
1807 real DELXN,XNSUM,XLAND,XWATR,XL1,XS1,XW1
1808 real XNSUM_ALL,XLAND_ALL,XWATR_ALL
1809 logical inside_a_polygon
1812 print *,
' _____ SUBROUTINE MAKE_MASK ' 1819 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
1822 glon(i) = 0. + (i-1) * delxn + delxn * 0.5
1825 land_frac(:,:) = 0.0
1847 lono(1) = lon_c(i,j)
1848 lono(2) = lon_c(i+1,j)
1849 lono(3) = lon_c(i+1,j+1)
1850 lono(4) = lon_c(i,j+1)
1851 lato(1) = lat_c(i,j)
1852 lato(2) = lat_c(i+1,j)
1853 lato(3) = lat_c(i+1,j+1)
1854 lato(4) = lat_c(i,j+1)
1855 call get_index(imn,jmn,4,lono,lato,delxn,jst,jen,ilist,numx)
1856 do jj = jst, jen;
do i2 = 1, numx
1859 lati = -90 + jj*delxn
1861 xland_all = xland_all + float(zslm(ii,jj))
1862 xwatr_all = xwatr_all + float(1-zslm(ii,jj))
1863 xnsum_all = xnsum_all + 1.
1864 nsum_all = nsum_all+1
1865 if(nsum_all > maxsum)
then 1866 print*,
"FATAL ERROR: nsum_all is greater than MAXSUM," 1867 print*,
"increase MAXSUM." 1871 if(inside_a_polygon(loni*d2r,lati*d2r,4,
1872 & lono*d2r,lato*d2r))
then 1874 xland = xland + float(zslm(ii,jj))
1875 xwatr = xwatr + float(1-zslm(ii,jj))
1878 if(nsum > maxsum)
then 1879 print*,
"FATAL ERROR: nsum is greater than MAXSUM," 1880 print*,
"increase MAXSUM." 1887 IF(xnsum.GT.1.)
THEN 1891 land_frac(i,j) = xland/xnsum
1892 slm(i,j) = float(nint(xland/xnsum))
1893 ELSEIF(xnsum_all.GT.1.)
THEN 1894 land_frac(i,j) = xland_all/xnsum _all
1895 slm(i,j) = float(nint(xland_all/xnsum_all))
1897 print*,
"FATAL ERROR: no source points in MAKE_MASK." 1903 WRITE(6,*)
"! MAKE_MASK DONE" 1928 SUBROUTINE makemt2(ZAVG,ZSLM,ORO,SLM,VAR,VAR4,
1929 1 GLAT,IM,JM,IMN,JMN,lon_c,lat_c,lake_frac,land_frac)
1931 real,
parameter :: D2R = 3.14159265358979/180.
1932 integer,
parameter :: maxsum=20000000
1933 real,
dimension(:),
allocatable :: hgt_1d, hgt_1d_all
1934 integer IM, JM, IMN, JMN
1935 real GLAT(JMN), GLON(IMN)
1936 INTEGER ZAVG(IMN,JMN),ZSLM(IMN,JMN)
1937 real ORO(IM,JM),VAR(IM,JM),VAR4(IM,JM)
1938 real,
intent(in) :: SLM(IM,JM), lake_frac(im,jm),land_frac(im,jm)
1940 real lon_c(IM+1,JM+1), lat_c(IM+1,JM+1)
1941 real LONO(4),LATO(4),LONI,LATI
1943 integer JM1,i,j,nsum,nsum_all,ii,jj,i1,numx,i2
1945 real DELXN,XNSUM,XLAND,XWATR,XL1,XS1,XW1,XW2,XW4
1946 real XNSUM_ALL,XLAND_ALL,XWATR_ALL,HEIGHT_ALL
1947 real XL1_ALL,XS1_ALL,XW1_ALL,XW2_ALL,XW4_ALL
1948 logical inside_a_polygon
1953 print *,
' _____ SUBROUTINE MAKEMT2 ' 1954 allocate(hgt_1d(maxsum))
1955 allocate(hgt_1d_all(maxsum))
1962 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
1965 glon(i) = 0. + (i-1) * delxn + delxn * 0.5
2005 lono(1) = lon_c(i,j)
2006 lono(2) = lon_c(i+1,j)
2007 lono(3) = lon_c(i+1,j+1)
2008 lono(4) = lon_c(i,j+1)
2009 lato(1) = lat_c(i,j)
2010 lato(2) = lat_c(i+1,j)
2011 lato(3) = lat_c(i+1,j+1)
2012 lato(4) = lat_c(i,j+1)
2013 call get_index(imn,jmn,4,lono,lato,delxn,jst,jen,ilist,numx)
2014 do jj = jst, jen;
do i2 = 1, numx
2017 lati = -90 + jj*delxn
2019 xland_all = xland_all + float(zslm(ii,jj))
2020 xwatr_all = xwatr_all + float(1-zslm(ii,jj))
2021 xnsum_all = xnsum_all + 1.
2022 height_all = float(zavg(ii,jj))
2023 nsum_all = nsum_all+1
2024 if(nsum_all > maxsum)
then 2025 print*,
"FATAL ERROR: nsum_all is greater than MAXSUM," 2026 print*,
"increase MAXSUM." 2029 hgt_1d_all(nsum_all) = height_all
2030 IF(height_all.LT.-990.) height_all = 0.0
2031 xl1_all = xl1_all + height_all * float(zslm(ii,jj))
2032 xs1_all = xs1_all + height_all * float(1-zslm(ii,jj))
2033 xw1_all = xw1_all + height_all
2034 xw2_all = xw2_all + height_all ** 2
2036 if(inside_a_polygon(loni*d2r,lati*d2r,4,
2037 & lono*d2r,lato*d2r))
then 2039 xland = xland + float(zslm(ii,jj))
2040 xwatr = xwatr + float(1-zslm(ii,jj))
2042 height = float(zavg(ii,jj))
2044 if(nsum > maxsum)
then 2045 print*,
"FATAL ERROR: nsum is greater than MAXSUM," 2046 print*,
"increase MAXSUM." 2049 hgt_1d(nsum) = height
2050 IF(height.LT.-990.) height = 0.0
2051 xl1 = xl1 + height * float(zslm(ii,jj))
2052 xs1 = xs1 + height * float(1-zslm(ii,jj))
2054 xw2 = xw2 + height ** 2
2058 IF(xnsum.GT.1.)
THEN 2064 IF(slm(i,j) .NE. 0. .OR. land_frac(i,j) > 0.)
THEN 2066 oro(i,j)= xl1 / xland
2068 oro(i,j)= xs1 / xwatr
2072 oro(i,j)= xs1 / xwatr
2074 oro(i,j)= xl1 / xland
2078 var(i,j)=sqrt(max(xw2/xnsum-(xw1/xnsum)**2,0.))
2080 xw4 = xw4 + (hgt_1d(i1) - oro(i,j)) ** 4
2083 IF(var(i,j).GT.1.)
THEN 2084 var4(i,j) = min(xw4/xnsum/var(i,j) **4,10.)
2087 ELSEIF(xnsum_all.GT.1.)
THEN 2090 IF(slm(i,j) .NE. 0. .OR. land_frac(i,j) > 0.)
THEN 2091 IF (xland_all > 0)
THEN 2092 oro(i,j)= xl1_all / xland_all
2094 oro(i,j)= xs1_all / xwatr_all
2097 IF (xwatr_all > 0)
THEN 2098 oro(i,j)= xs1_all / xwatr_all
2100 oro(i,j)= xl1_all / xland_all
2104 var(i,j)=sqrt(max(xw2_all/xnsum_all-
2105 & (xw1_all/xnsum_all)**2,0.))
2108 & (hgt_1d_all(i1) - oro(i,j)) ** 4
2111 IF(var(i,j).GT.1.)
THEN 2112 var4(i,j) = min(xw4_all/xnsum_all/var(i,j) **4,10.)
2115 print*,
"FATAL ERROR: no source points in MAKEMT2." 2121 IF (lake_frac(i,j) .EQ. 0. .AND. land_frac(i,j) .EQ. 0.)
THEN 2128 WRITE(6,*)
"! MAKEMT2 ORO SLM VAR VAR4 DONE" 2131 deallocate(hgt_1d_all)
2163 SUBROUTINE makepc(ZAVG,ZSLM,THETA,GAMMA,SIGMA,
2164 1 GLAT,IST,IEN,JST,JEN,IM,JM,IMN,JMN,XLAT,numi)
2168 parameter(rearth=6.3712e+6)
2169 dimension glat(jmn),xlat(jm),deltax(jmn)
2170 INTEGER ZAVG(IMN,JMN),ZSLM(IMN,JMN)
2171 DIMENSION ORO(IM,JM),SLM(IM,JM),HL(IM,JM),HK(IM,JM)
2172 DIMENSION HX2(IM,JM),HY2(IM,JM),HXY(IM,JM),HLPRIM(IM,JM)
2173 DIMENSION THETA(IM,JM),GAMMA(IM,JM),SIGMA2(IM,JM),SIGMA(IM,JM)
2174 dimension ist(im,jm),ien(im,jm),jst(jm),jen(jm),numi(jm)
2179 pi = 4.0 * atan(1.0)
2185 deltay = certh / float(jmn)
2186 print *,
'MAKEPC: DELTAY=',deltay
2189 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
2190 deltax(j) = deltay * cos(glat(j)*pi/180.0)
2199 faclon = delx / delxn
2200 ist(i,j) = faclon * float(i-1) - faclon * 0.5
2201 ist(i,j) = ist(i,j) + 1
2202 ien(i,j) = faclon * float(i) - faclon * 0.5
2209 IF (ist(i,j) .LE. 0) ist(i,j) = ist(i,j) + imn
2210 IF (ien(i,j) .LT. ist(i,j)) ien(i,j) = ien(i,j) + imn
2212 if ( i .lt. 10 .and. j .lt. 10 )
2213 1 print*,
' I j IST IEN ',i,j,ist(i,j),ien(i,j)
2215 IF (ien(i,j) .LT. ist(i,j))
2216 1 print *,
' MAKEPC: IEN < IST: I,J,IST(I,J),IEN(I,J)',
2217 2 i,j,ist(i,j),ien(i,j)
2223 xxlat = (xlat(j)+xlat(j+1))/2.
2224 IF(flag.AND.glat(j1).GT.xxlat)
THEN 2231 jst(jm) = max(jst(jm-1) - (jen(jm-1)-jst(jm-1)),1)
2232 jen(1) = min(jen(2) + (jen(2)-jst(2)),jmn)
2234 print*,
' IST,IEN(1,1-numi(1,JM))',ist(1,1),ien(1,1),
2235 1 ist(numi(jm),jm),ien(numi(jm),jm), numi(jm)
2236 print*,
' JST,JEN(1,JM) ',jst(1),jen(1),jst(jm),jen(jm)
2265 DO ii1 = 1, ien(i,j) - ist(i,j) + 1
2266 i1 = ist(i,j) + ii1 - 1
2267 IF(i1.LE.0.) i1 = i1 + imn
2268 IF(i1.GT.imn) i1 = i1 - imn
2273 if (i1 - 1 .le. 0 ) i0 = i0 + imn
2274 if (i1 - 1 .gt. imn) i0 = i0 - imn
2277 if (i1 + 1 .le. 0 ) ip1 = ip1 + imn
2278 if (i1 + 1 .gt. imn) ip1 = ip1 - imn
2282 if ( i1 .eq. ist(i,j) .and. j1 .eq. jst(j) )
2283 1 print*,
' J, J1,IST,JST,DELTAX,GLAT ',
2284 2 j,j1,ist(i,j),jst(j),deltax(j1),glat(j1)
2285 if ( i1 .eq. ien(i,j) .and. j1 .eq. jen(j) )
2286 1 print*,
' J, J1,IEN,JEN,DELTAX,GLAT ',
2287 2 j,j1,ien(i,j),jen(j),deltax(j1),glat(j1)
2289 xland = xland + float(zslm(i1,j1))
2290 xwatr = xwatr + float(1-zslm(i1,j1))
2293 height = float(zavg(i1,j1))
2294 hi0 = float(zavg(i0,j1))
2295 hip1 = float(zavg(ip1,j1))
2297 IF(height.LT.-990.) height = 0.0
2298 if(hi0 .lt. -990.) hi0 = 0.0
2299 if(hip1 .lt. -990.) hip1 = 0.0
2301 xfp = 0.5 * ( hip1 - hi0 ) / deltax(j1)
2302 xfp2 = xfp2 + 0.25 * ( ( hip1 - hi0 )/deltax(j1) )** 2
2306 if ( j1 .ne. jst(jm) .and. j1 .ne. jen(1) )
then 2307 hj0 = float(zavg(i1,j1-1))
2308 hjp1 = float(zavg(i1,j1+1))
2309 if(hj0 .lt. -990.) hj0 = 0.0
2310 if(hjp1 .lt. -990.) hjp1 = 0.0
2312 yfp = 0.5 * ( hjp1 - hj0 ) / deltay
2313 yfp2 = yfp2 + 0.25 * ( ( hjp1 - hj0 )/deltay )**2
2319 elseif ( j1 .eq. jst(jm) )
then 2321 if (ijax .le. 0 ) ijax = ijax + imn
2322 if (ijax .gt. imn) ijax = ijax - imn
2324 hijax = float(zavg(ijax,j1))
2325 hi1j1 = float(zavg(i1,j1))
2326 if(hijax .lt. -990.) hijax = 0.0
2327 if(hi1j1 .lt. -990.) hi1j1 = 0.0
2329 yfp = 0.5 * ( ( 0.5 * ( hijax - hi1j1 ) ) )/deltay
2330 yfp2 = yfp2 + 0.25 * ( ( 0.5 * ( hijax - hi1j1) )
2336 elseif ( j1 .eq. jen(1) )
then 2338 if (ijax .le. 0 ) ijax = ijax + imn
2339 if (ijax .gt. imn) ijax = ijax - imn
2340 hijax = float(zavg(ijax,j1))
2341 hi1j1 = float(zavg(i1,j1))
2342 if(hijax .lt. -990.) hijax = 0.0
2343 if(hi1j1 .lt. -990.) hi1j1 = 0.0
2344 if ( i1 .lt. 5 )print *,
' S.Pole i1,j1 :',i1,j1,hijax,hi1j1
2346 yfp = 0.5 * (0.5 * ( hijax - hi1j1) )/deltay
2347 yfp2 = yfp2 + 0.25 * ( (0.5 * (hijax - hi1j1) )
2354 xfpyfp = xfpyfp + xfp * yfp
2355 xl1 = xl1 + height * float(zslm(i1,j1))
2356 xs1 = xs1 + height * float(1-zslm(i1,j1))
2366 IF(xnsum.GT.1.)
THEN 2367 slm(i,j) = float(nint(xland/xnsum))
2368 IF(slm(i,j).NE.0.)
THEN 2369 oro(i,j)= xl1 / xland
2370 hx2(i,j) = xfp2 / xland
2371 hy2(i,j) = yfp2 / xland
2372 hxy(i,j) = xfpyfp / xland
2374 oro(i,j)= xs1 / xwatr
2378 print *,
" I,J,i1,j1,HEIGHT:", i,j,i1,j1,height,
2380 print *,
" xfpyfp,xfp2,yfp2:",xfpyfp,xfp2,yfp2
2381 print *,
" HX2,HY2,HXY:",hx2(i,j),hy2(i,j),hxy(i,j)
2387 hk(i,j) = 0.5 * ( hx2(i,j) + hy2(i,j) )
2388 hl(i,j) = 0.5 * ( hx2(i,j) - hy2(i,j) )
2389 hlprim(i,j) = sqrt(hl(i,j)*hl(i,j) + hxy(i,j)*hxy(i,j))
2390 IF( hl(i,j).NE. 0. .AND. slm(i,j) .NE. 0. )
THEN 2392 theta(i,j) = 0.5 * atan2(hxy(i,j),hl(i,j)) * 180.0 / pi
2396 sigma2(i,j) = ( hk(i,j) + hlprim(i,j) )
2397 if ( sigma2(i,j) .GE. 0. )
then 2398 sigma(i,j) = sqrt(sigma2(i,j) )
2399 if (sigma2(i,j) .ne. 0. .and.
2400 & hk(i,j) .GE. hlprim(i,j) )
2401 1 gamma(i,j) = sqrt( (hk(i,j) - hlprim(i,j)) / sigma2(i,j) )
2407 print *,
" I,J,THETA,SIGMA,GAMMA,",i,j,theta(i,j),
2408 1 sigma(i,j),gamma(i,j)
2409 print *,
" HK,HL,HLPRIM:",hk(i,j),hl(i,j),hlprim(i,j)
2413 WRITE(6,*)
"! MAKE Principal Coord DONE" 2438 SUBROUTINE makepc2(ZAVG,ZSLM,THETA,GAMMA,SIGMA,
2439 1 GLAT,IM,JM,IMN,JMN,lon_c,lat_c,SLM)
2444 real,
parameter :: REARTH=6.3712e+6
2445 real,
parameter :: D2R = 3.14159265358979/180.
2446 integer :: im,jm,imn,jmn
2447 real :: GLAT(JMN),DELTAX(JMN)
2448 INTEGER ZAVG(IMN,JMN),ZSLM(IMN,JMN)
2449 real lon_c(IM+1,JM+1), lat_c(IM+1,JM+1)
2450 real,
intent(in) :: SLM(IM,JM)
2451 real HL(IM,JM),HK(IM,JM)
2452 real HX2(IM,JM),HY2(IM,JM),HXY(IM,JM),HLPRIM(IM,JM)
2453 real THETA(IM,JM),GAMMA(IM,JM),SIGMA2(IM,JM),SIGMA(IM,JM)
2454 real PI,CERTH,DELXN,DELTAY,XNSUM,XLAND
2455 real xfp,yfp,xfpyfp,xfp2,yfp2
2456 real hi0,hip1,hj0,hjp1,hijax,hi1j1
2457 real LONO(4),LATO(4),LONI,LATI
2458 integer i,j,i1,j1,i2,jst,jen,numx,i0,ip1,ijax
2460 logical inside_a_polygon
2465 pi = 4.0 * atan(1.0)
2470 deltay = certh / float(jmn)
2471 print *,
'MAKEPC2: DELTAY=',deltay
2474 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
2475 deltax(j) = deltay * cos(glat(j)*d2r)
2509 lono(1) = lon_c(i,j)
2510 lono(2) = lon_c(i+1,j)
2511 lono(3) = lon_c(i+1,j+1)
2512 lono(4) = lon_c(i,j+1)
2513 lato(1) = lat_c(i,j)
2514 lato(2) = lat_c(i+1,j)
2515 lato(3) = lat_c(i+1,j+1)
2516 lato(4) = lat_c(i,j+1)
2517 call get_index(imn,jmn,4,lono,lato,delxn,jst,jen,ilist,numx)
2519 do j1 = jst, jen;
do i2 = 1, numx
2522 lati = -90 + j1*delxn
2523 inside :
if(inside_a_polygon(loni*d2r,lati*d2r,4,
2524 & lono*d2r,lato*d2r))
then 2529 if (i1 - 1 .le. 0 ) i0 = i0 + imn
2530 if (i1 - 1 .gt. imn) i0 = i0 - imn
2533 if (i1 + 1 .le. 0 ) ip1 = ip1 + imn
2534 if (i1 + 1 .gt. imn) ip1 = ip1 - imn
2536 xland = xland + float(zslm(i1,j1))
2539 hi0 = float(zavg(i0,j1))
2540 hip1 = float(zavg(ip1,j1))
2542 if(hi0 .lt. -990.) hi0 = 0.0
2543 if(hip1 .lt. -990.) hip1 = 0.0
2545 xfp = 0.5 * ( hip1 - hi0 ) / deltax(j1)
2546 xfp2 = xfp2 + 0.25 * ( ( hip1 - hi0 )/deltax(j1) )** 2
2550 if ( j1 .ne. 1 .and. j1 .ne. jmn )
then 2551 hj0 = float(zavg(i1,j1-1))
2552 hjp1 = float(zavg(i1,j1+1))
2553 if(hj0 .lt. -990.) hj0 = 0.0
2554 if(hjp1 .lt. -990.) hjp1 = 0.0
2556 yfp = 0.5 * ( hjp1 - hj0 ) / deltay
2557 yfp2 = yfp2 + 0.25 * ( ( hjp1 - hj0 )/deltay )**2
2563 elseif ( j1 .eq. 1 )
then 2565 if (ijax .le. 0 ) ijax = ijax + imn
2566 if (ijax .gt. imn) ijax = ijax - imn
2568 hijax = float(zavg(ijax,j1))
2569 hi1j1 = float(zavg(i1,j1))
2570 if(hijax .lt. -990.) hijax = 0.0
2571 if(hi1j1 .lt. -990.) hi1j1 = 0.0
2573 yfp = 0.5 * ( ( 0.5 * ( hijax - hi1j1 ) ) )/deltay
2574 yfp2 = yfp2 + 0.25 * ( ( 0.5 * ( hijax - hi1j1) )
2580 elseif ( j1 .eq. jmn )
then 2582 if (ijax .le. 0 ) ijax = ijax + imn
2583 if (ijax .gt. imn) ijax = ijax - imn
2584 hijax = float(zavg(ijax,j1))
2585 hi1j1 = float(zavg(i1,j1))
2586 if(hijax .lt. -990.) hijax = 0.0
2587 if(hi1j1 .lt. -990.) hi1j1 = 0.0
2588 if ( i1 .lt. 5 )print *,
' S.Pole i1,j1 :',i1,j1,
2591 yfp = 0.5 * (0.5 * ( hijax - hi1j1) )/deltay
2592 yfp2 = yfp2 + 0.25 * ( (0.5 * (hijax - hi1j1) )
2599 xfpyfp = xfpyfp + xfp * yfp
2610 xnsum_gt_1 :
IF(xnsum.GT.1.)
THEN 2611 IF(slm(i,j).NE.0.)
THEN 2613 hx2(i,j) = xfp2 / xland
2614 hy2(i,j) = yfp2 / xland
2615 hxy(i,j) = xfpyfp / xland
2617 hx2(i,j) = xfp2 / xnsum
2618 hy2(i,j) = yfp2 / xnsum
2619 hxy(i,j) = xfpyfp / xnsum
2624 print *,
" I,J,i1,j1:", i,j,i1,j1,
2626 print *,
" xfpyfp,xfp2,yfp2:",xfpyfp,xfp2,yfp2
2627 print *,
" HX2,HY2,HXY:",hx2(i,j),hy2(i,j),hxy(i,j)
2633 hk(i,j) = 0.5 * ( hx2(i,j) + hy2(i,j) )
2634 hl(i,j) = 0.5 * ( hx2(i,j) - hy2(i,j) )
2635 hlprim(i,j) = sqrt(hl(i,j)*hl(i,j) + hxy(i,j)*hxy(i,j))
2636 IF( hl(i,j).NE. 0. .AND. slm(i,j) .NE. 0. )
THEN 2638 theta(i,j) = 0.5 * atan2(hxy(i,j),hl(i,j)) / d2r
2642 sigma2(i,j) = ( hk(i,j) + hlprim(i,j) )
2643 if ( sigma2(i,j) .GE. 0. )
then 2644 sigma(i,j) = sqrt(sigma2(i,j) )
2645 if (sigma2(i,j) .ne. 0. .and.
2646 & hk(i,j) .GE. hlprim(i,j) )
2647 1 gamma(i,j) = sqrt( (hk(i,j) - hlprim(i,j)) / sigma2(i,j) )
2653 print *,
" I,J,THETA,SIGMA,GAMMA,",i,j,theta(i,j),
2654 1 sigma(i,j),gamma(i,j)
2655 print *,
" HK,HL,HLPRIM:",hk(i,j),hl(i,j),hlprim(i,j)
2660 WRITE(6,*)
"! MAKE Principal Coord DONE" 2706 SUBROUTINE makeoa(ZAVG,VAR,GLAT,OA4,OL,IOA4,ELVMAX,
2707 1 ORO,oro1,XNSUM,XNSUM1,XNSUM2,XNSUM3,XNSUM4,
2708 2 IST,IEN,JST,JEN,IM,JM,IMN,JMN,XLAT,numi)
2709 dimension glat(jmn),xlat(jm)
2710 INTEGER ZAVG(IMN,JMN)
2711 DIMENSION ORO(IM,JM),ORO1(IM,JM),ELVMAX(IM,JM),ZMAX(IM,JM)
2712 DIMENSION OA4(IM,JM,4),IOA4(IM,JM,4)
2713 DIMENSION IST(IM,jm),IEN(IM,jm),JST(JM),JEN(JM)
2714 DIMENSION XNSUM(IM,JM),XNSUM1(IM,JM),XNSUM2(IM,JM)
2715 dimension xnsum3(im,jm),xnsum4(im,jm)
2716 dimension var(im,jm),ol(im,jm,4),numi(jm)
2726 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
2728 print *,
' IM=',im,
' JM=',jm,
' IMN=',imn,
' JMN=',jmn
2735 faclon = delx / delxn
2737 ist(i,j) = faclon * float(i-1) - faclon * 0.5
2738 ist(i,j) = ist(i,j) + 1
2739 ien(i,j) = faclon * float(i) - faclon * 0.5
2742 IF (ist(i,j) .LE. 0) ist(i,j) = ist(i,j) + imn
2743 IF (ien(i,j) .LT. ist(i,j)) ien(i,j) = ien(i,j) + imn
2745 if ( i .lt. 3 .and. j .lt. 3 )
2746 1print*,
' MAKEOA: I j IST IEN ',i,j,ist(i,j),ien(i,j)
2747 if ( i .lt. 3 .and. j .ge. jm-1 )
2748 1print*,
' MAKEOA: I j IST IEN ',i,j,ist(i,j),ien(i,j)
2751 print *,
'MAKEOA: DELXN,DELX,FACLON',delxn,delx,faclon
2752 print *,
' ***** ready to start JST JEN section ' 2757 xxlat = (xlat(j)+xlat(j+1))/2.
2758 IF(flag.AND.glat(j1).GT.xxlat)
THEN 2763 1print*,
' MAKEOA: XX j JST JEN ',j,jst(j),jen(j)
2767 1print*,
' MAKEOA: j JST JEN ',j,jst(j),jen(j)
2769 1print*,
' MAKEOA: j JST JEN ',j,jst(j),jen(j)
2778 jst(jm) = max(jst(jm-1) - (jen(jm-1)-jst(jm-1)),1)
2779 jen(1) = min(jen(2) + (jen(2)-jst(2)),jmn)
2780 print *,
' ***** JST(1) JEN(1) ',jst(1),jen(1)
2781 print *,
' ***** JST(JM) JEN(JM) ',jst(jm),jen(jm)
2786 elvmax(i,j) = oro(i,j)
2795 DO ii1 = 1, ien(i,j) - ist(i,j) + 1
2796 i1 = ist(i,j) + ii1 - 1
2798 IF(i1.LE.0.) i1 = i1 + imn
2799 IF (i1 .GT. imn) i1 = i1 - imn
2801 height = float(zavg(i1,j1))
2802 IF(height.LT.-990.) height = 0.0
2803 IF ( height .gt. oro(i,j) )
then 2804 if ( height .gt. zmax(i,j) )zmax(i,j) = height
2805 xnsum(i,j) = xnsum(i,j) + 1
2809 if ( i .lt. 5 .and. j .ge. jm-5 )
then 2810 print *,
' I,J,ORO(I,J),XNSUM(I,J),ZMAX(I,J):',
2811 1 i,j,oro(i,j),xnsum(i,j),zmax(i,j)
2822 oro1(i,j) = oro(i,j)
2823 elvmax(i,j) = zmax(i,j)
2856 hc = 1116.2 - 0.878 * var(i,j)
2858 DO ii1 = 1, ien(i,j) - ist(i,j) + 1
2859 i1 = ist(i,j) + ii1 - 1
2864 IF(i1.GT.imn) i1 = i1 - imn
2866 IF(float(zavg(i1,j1)) .GT. hc)
2867 1 xnsum1(i,j) = xnsum1(i,j) + 1
2868 xnsum2(i,j) = xnsum2(i,j) + 1
2872 inci = nint((ien(i,j)-ist(i,j)) * 0.5)
2873 isttt = min(max(ist(i,j)-inci,1),imn)
2874 ieddd = min(max(ien(i,j)-inci,1),imn)
2876 incj = nint((jen(j)-jst(j)) * 0.5)
2877 jsttt = min(max(jst(j)-incj,1),jmn)
2878 jeddd = min(max(jen(j)-incj,1),jmn)
2888 IF(float(zavg(i1,j1)) .GT. hc)
2889 1 xnsum3(i,j) = xnsum3(i,j) + 1
2890 xnsum4(i,j) = xnsum4(i,j) + 1
2916 IF (ii .GT. numi(j)) ii = ii - numi(j)
2917 xnpu = xnsum(i,j) + xnsum(i,j+1)
2918 xnpd = xnsum(ii,j) + xnsum(ii,j+1)
2919 IF (xnpd .NE. xnpu) oa4(ii,j+1,1) = 1. - xnpd / max(xnpu , 1.)
2920 ol(ii,j+1,1) = (xnsum3(i,j+1)+xnsum3(ii,j+1))/
2921 1 (xnsum4(i,j+1)+xnsum4(ii,j+1))
2936 IF (ii .GT. numi(j)) ii = ii - numi(j)
2937 xnpu = xnsum(i,j+1) + xnsum(ii,j+1)
2938 xnpd = xnsum(i,j) + xnsum(ii,j)
2939 IF (xnpd .NE. xnpu) oa4(ii,j+1,2) = 1. - xnpd / max(xnpu , 1.)
2940 ol(ii,j+1,2) = (xnsum3(ii,j)+xnsum3(ii,j+1))/
2941 1 (xnsum4(ii,j)+xnsum4(ii,j+1))
2947 IF (ii .GT. numi(j)) ii = ii - numi(j)
2948 xnpu = xnsum(i,j+1) + ( xnsum(i,j) + xnsum(ii,j+1) )*0.5
2949 xnpd = xnsum(ii,j) + ( xnsum(i,j) + xnsum(ii,j+1) )*0.5
2950 IF (xnpd .NE. xnpu) oa4(ii,j+1,3) = 1. - xnpd / max(xnpu , 1.)
2951 ol(ii,j+1,3) = (xnsum1(ii,j)+xnsum1(i,j+1))/
2952 1 (xnsum2(ii,j)+xnsum2(i,j+1))
2958 IF (ii .GT. numi(j)) ii = ii - numi(j)
2959 xnpu = xnsum(i,j) + ( xnsum(ii,j) + xnsum(i,j+1) )*0.5
2960 xnpd = xnsum(ii,j+1) + ( xnsum(ii,j) + xnsum(i,j+1) )*0.5
2961 IF (xnpd .NE. xnpu) oa4(ii,j+1,4) = 1. - xnpd / max(xnpu , 1.)
2962 ol(ii,j+1,4) = (xnsum1(i,j)+xnsum1(ii,j+1))/
2963 1 (xnsum2(i,j)+xnsum2(ii,j+1))
2969 ol(i,1,kwd) = ol(i,2,kwd)
2970 ol(i,jm,kwd) = ol(i,jm-1,kwd)
2978 oa4(i,j,kwd) = sign( min( abs(t), 1. ), t )
2993 t = abs( oa4(i,j,kwd) )
2997 ELSE IF(t .GT. 0. .AND. t .LE. 1.)
THEN 3000 ELSE IF(t .GT. 1. .AND. t .LE. 10.)
THEN 3003 ELSE IF(t .GT. 10. .AND. t .LE. 100.)
THEN 3006 ELSE IF(t .GT. 100. .AND. t .LE. 1000.)
THEN 3009 ELSE IF(t .GT. 1000. .AND. t .LE. 10000.)
THEN 3012 ELSE IF(t .GT. 10000.)
THEN 3020 WRITE(6,*)
"! MAKEOA EXIT" 3036 real dx, lat, degrad
3039 real,
parameter :: radius = 6371200
3041 get_lon_angle = 2*asin( sin(dx/radius*0.5)/cos(lat) )*degrad
3058 real,
parameter :: radius = 6371200
3100 SUBROUTINE makeoa2(ZAVG,zslm,VAR,GLAT,OA4,OL,IOA4,ELVMAX,
3101 1 ORO,oro1,XNSUM,XNSUM1,XNSUM2,XNSUM3,XNSUM4,
3102 2 IM,JM,IMN,JMN,lon_c,lat_c,lon_t,lat_t,dx,dy,
3103 3 is_south_pole,is_north_pole )
3105 real,
parameter :: MISSING_VALUE = -9999.
3106 real,
parameter :: d2r = 3.14159265358979/180.
3107 real,
PARAMETER :: R2D=180./3.14159265358979
3108 integer im,jm,imn,jmn
3110 INTEGER ZAVG(IMN,JMN),ZSLM(IMN,JMN)
3111 real ORO(IM,JM),ORO1(IM,JM),ELVMAX(IM,JM),ZMAX(IM,JM)
3113 integer IOA4(IM,JM,4)
3114 real lon_c(IM+1,JM+1), lat_c(IM+1,JM+1)
3115 real lon_t(IM,JM), lat_t(IM,JM)
3116 real dx(IM,JM), dy(IM,JM)
3117 logical is_south_pole(IM,JM), is_north_pole(IM,JM)
3118 real XNSUM(IM,JM),XNSUM1(IM,JM),XNSUM2(IM,JM)
3119 real XNSUM3(IM,JM),XNSUM4(IM,JM)
3120 real VAR(IM,JM),OL(IM,JM,4)
3121 integer i,j,ilist(IMN),numx,i1,j1,ii1
3123 real LONO(4),LATO(4),LONI,LATI
3124 real DELXN,HC,HEIGHT,XNPU,XNPD,T
3125 integer NS0,NS1,NS2,NS3,NS4,NS5,NS6
3126 logical inside_a_polygon
3127 real lon,lat,dlon,dlat,dlat_old
3128 real lon1,lat1,lon2,lat2
3129 real xnsum11,xnsum12,xnsum21,xnsum22
3130 real HC_11, HC_12, HC_21, HC_22
3131 real xnsum1_11,xnsum1_12,xnsum1_21,xnsum1_22
3132 real xnsum2_11,xnsum2_12,xnsum2_21,xnsum2_22
3133 real get_lon_angle, get_lat_angle, get_xnsum
3141 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
3143 print *,
' IM=',im,
' JM=',jm,
' IMN=',imn,
' JMN=',jmn
3151 elvmax(i,j) = oro(i,j)
3159 oro1(i,j) = oro(i,j)
3160 elvmax(i,j) = zmax(i,j)
3172 hc = 1116.2 - 0.878 * var(i,j)
3173 lono(1) = lon_c(i,j)
3174 lono(2) = lon_c(i+1,j)
3175 lono(3) = lon_c(i+1,j+1)
3176 lono(4) = lon_c(i,j+1)
3177 lato(1) = lat_c(i,j)
3178 lato(2) = lat_c(i+1,j)
3179 lato(3) = lat_c(i+1,j+1)
3180 lato(4) = lat_c(i,j+1)
3181 call get_index(imn,jmn,4,lono,lato,delxn,jst,jen,ilist,numx)
3182 do j1 = jst, jen;
do ii1 = 1, numx
3185 lati = -90 + j1*delxn
3186 if(inside_a_polygon(loni*d2r,lati*d2r,4,
3187 & lono*d2r,lato*d2r))
then 3189 height = float(zavg(i1,j1))
3190 IF(height.LT.-990.) height = 0.0
3191 IF ( height .gt. oro(i,j) )
then 3192 if ( height .gt. zmax(i,j) )zmax(i,j) = height
3205 oro1(i,j) = oro(i,j)
3206 elvmax(i,j) = zmax(i,j)
3240 if(is_north_pole(i,j))
then 3241 print*,
"set oa1 = 0 and ol=0 at i,j=", i,j
3246 else if(is_south_pole(i,j))
then 3247 print*,
"set oa1 = 0 and ol=1 at i,j=", i,j
3255 dlon = get_lon_angle(dx(i,j), lat*d2r, r2d )
3256 dlat = get_lat_angle(dy(i,j), r2d)
3258 if( lat-dlat*0.5<-90.)
then 3259 print*,
"at i,j =", i,j, lat, dlat, lat-dlat*0.5
3260 print*,
"FATAL ERROR: lat-dlat*0.5<-90." 3263 if( lat+dlat*2 > 90.)
then 3266 print*,
"at i,j=",i,j,
" adjust dlat from ",
3267 & dlat_old,
" to ", dlat
3275 if(lat1<-90 .or. lat2>90)
then 3276 print*,
"at upper left i=,j=", i, j, lat, dlat,lat1,lat2
3278 xnsum11 = get_xnsum(lon1,lat1,lon2,lat2,imn,jmn,glat,
3286 if(lat1<-90 .or. lat2>90)
then 3287 print*,
"at lower left i=,j=", i, j, lat, dlat,lat1,lat2
3289 xnsum12 = get_xnsum(lon1,lat1,lon2,lat2,imn,jmn,glat,
3297 if(lat1<-90 .or. lat2>90)
then 3298 print*,
"at upper right i=,j=", i, j, lat, dlat,lat1,lat2
3300 xnsum21 = get_xnsum(lon1,lat1,lon2,lat2,imn,jmn,glat,
3308 if(lat1<-90 .or. lat2>90)
then 3309 print*,
"at lower right i=,j=", i, j, lat, dlat,lat1,lat2
3312 xnsum22 = get_xnsum(lon1,lat1,lon2,lat2,imn,jmn,glat,
3315 xnpu = xnsum11 + xnsum12
3316 xnpd = xnsum21 + xnsum22
3317 IF (xnpd .NE. xnpu) oa4(i,j,1) = 1. - xnpd / max(xnpu , 1.)
3319 xnpu = xnsum11 + xnsum21
3320 xnpd = xnsum12 + xnsum22
3321 IF (xnpd .NE. xnpu) oa4(i,j,2) = 1. - xnpd / max(xnpu , 1.)
3323 xnpu = xnsum11 + (xnsum12+xnsum21)*0.5
3324 xnpd = xnsum22 + (xnsum12+xnsum21)*0.5
3325 IF (xnpd .NE. xnpu) oa4(i,j,3) = 1. - xnpd / max(xnpu , 1.)
3327 xnpu = xnsum12 + (xnsum11+xnsum22)*0.5
3328 xnpd = xnsum21 + (xnsum11+xnsum22)*0.5
3329 IF (xnpd .NE. xnpu) oa4(i,j,4) = 1. - xnpd / max(xnpu , 1.)
3338 if(lat1<-90 .or. lat2>90)
then 3339 print*,
"at upper left i=,j=", i, j, lat, dlat,lat1,lat2
3341 call get_xnsum2(lon1,lat1,lon2,lat2,imn,jmn,glat,
3342 & zavg,delxn, xnsum1_11, xnsum2_11, hc_11)
3349 if(lat1<-90 .or. lat2>90)
then 3350 print*,
"at lower left i=,j=", i, j, lat, dlat,lat1,lat2
3352 call get_xnsum2(lon1,lat1,lon2,lat2,imn,jmn,glat,
3353 & zavg,delxn, xnsum1_12, xnsum2_12, hc_12)
3360 if(lat1<-90 .or. lat2>90)
then 3361 print*,
"at upper right i=,j=", i, j, lat, dlat,lat1,lat2
3363 call get_xnsum2(lon1,lat1,lon2,lat2,imn,jmn,glat,
3364 & zavg,delxn, xnsum1_21, xnsum2_21, hc_21)
3371 if(lat1<-90 .or. lat2>90)
then 3372 print*,
"at lower right i=,j=", i, j, lat, dlat,lat1,lat2
3374 call get_xnsum2(lon1,lat1,lon2,lat2,imn,jmn,glat,
3375 & zavg,delxn, xnsum1_22, xnsum2_22, hc_22)
3377 ol(i,j,3) = (xnsum1_22+xnsum1_11)/(xnsum2_22+xnsum2_11)
3378 ol(i,j,4) = (xnsum1_12+xnsum1_21)/(xnsum2_12+xnsum2_21)
3386 if(lat1<-90 .or. lat2>90)
then 3387 print*,
"at upper left i=,j=", i, j, lat, dlat,lat1,lat2
3389 call get_xnsum3(lon1,lat1,lon2,lat2,imn,jmn,glat,
3390 & zavg,delxn, xnsum1_11, xnsum2_11, hc_11)
3397 if(lat1<-90 .or. lat2>90)
then 3398 print*,
"at lower left i=,j=", i, j, lat, dlat,lat1,lat2
3401 call get_xnsum3(lon1,lat1,lon2,lat2,imn,jmn,glat,
3402 & zavg,delxn, xnsum1_12, xnsum2_12, hc_12)
3409 if(lat1<-90 .or. lat2>90)
then 3410 print*,
"at upper right i=,j=", i, j, lat, dlat,lat1,lat2
3412 call get_xnsum3(lon1,lat1,lon2,lat2,imn,jmn,glat,
3413 & zavg,delxn, xnsum1_21, xnsum2_21, hc_21)
3420 if(lat1<-90 .or. lat2>90)
then 3421 print*,
"at lower right i=,j=", i, j, lat, dlat,lat1,lat2
3424 call get_xnsum3(lon1,lat1,lon2,lat2,imn,jmn,glat,
3425 & zavg,delxn, xnsum1_22, xnsum2_22, hc_22)
3427 ol(i,j,1) = (xnsum1_11+xnsum1_21)/(xnsum2_11+xnsum2_21)
3428 ol(i,j,2) = (xnsum1_21+xnsum1_22)/(xnsum2_21+xnsum2_22)
3437 oa4(i,j,kwd) = sign( min( abs(t), 1. ), t )
3452 t = abs( oa4(i,j,kwd) )
3456 ELSE IF(t .GT. 0. .AND. t .LE. 1.)
THEN 3459 ELSE IF(t .GT. 1. .AND. t .LE. 10.)
THEN 3462 ELSE IF(t .GT. 10. .AND. t .LE. 100.)
THEN 3465 ELSE IF(t .GT. 100. .AND. t .LE. 1000.)
THEN 3468 ELSE IF(t .GT. 1000. .AND. t .LE. 10000.)
THEN 3471 ELSE IF(t .GT. 10000.)
THEN 3479 WRITE(6,*)
"! MAKEOA2 EXIT" 3495 real,
intent(in) :: theta1, phi1, theta2, phi2
3498 if(theta1 == theta2 .and. phi1 == phi2)
then 3503 dot = cos(phi1)*cos(phi2)*cos(theta1-theta2) + sin(phi1)*sin(phi2)
3504 if(dot > 1. ) dot = 1.
3505 if(dot < -1.) dot = -1.
3529 & bitmap_in,num_out, lon_out,lat_out, iindx, jindx )
3530 integer,
intent(in) :: im_in, jm_in, num_out
3531 real,
intent(in) :: geolon_in(im_in,jm_in)
3532 real,
intent(in) :: geolat_in(im_in,jm_in)
3533 logical*1,
intent(in) :: bitmap_in(im_in,jm_in)
3534 real,
intent(in) :: lon_out(num_out), lat_out(num_out)
3535 integer,
intent(out):: iindx(num_out), jindx(num_out)
3536 real,
parameter :: MAX_DIST = 1.e+20
3537 integer,
parameter :: NUMNBR = 20
3538 integer :: i_c,j_c,jstart,jend
3541 print*,
"im_in,jm_in = ", im_in, jm_in
3542 print*,
"num_out = ", num_out
3543 print*,
"max and min of lon_in is", minval(geolon_in),
3545 print*,
"max and min of lat_in is", minval(geolat_in),
3547 print*,
"max and min of lon_out is", minval(lon_out),
3549 print*,
"max and min of lat_out is", minval(lat_out),
3551 print*,
"count(bitmap_in)= ", count(bitmap_in), max_dist
3560 if(lat .LE. geolat_in(1,j) .and.
3561 & lat .GE. geolat_in(1,j+1))
then 3565 if(lat > geolat_in(1,1)) j_c = 1
3566 if(lat < geolat_in(1,jm_in)) j_c = jm_in
3569 jstart = max(j_c-numnbr,1)
3570 jend = min(j_c+numnbr,jm_in)
3575 do j = jstart, jend;
do i = 1,im_in
3576 if(bitmap_in(i,j) )
then 3579 & geolon_in(i,j), geolat_in(i,j))
3581 iindx(n) = i; jindx(n) = j
3586 if(iindx(n) ==0)
then 3587 print*,
"lon,lat=", lon,lat
3588 print*,
"jstart, jend=", jstart, jend, dist
3589 print*,
"FATAL ERROR in get mismatch_index: " 3590 print*,
"did not find nearest points." 3611 & num_out, data_out, iindx, jindx)
3612 integer,
intent(in) :: im_in, jm_in, num_out
3613 real,
intent(in) :: data_in(im_in,jm_in)
3614 real,
intent(out):: data_out(num_out)
3615 integer,
intent(in) :: iindx(num_out), jindx(num_out)
3618 data_out(n) = data_in(iindx(n),jindx(n))
3667 SUBROUTINE makeoa3(ZAVG,zslm,VAR,GLAT,OA4,OL,IOA4,ELVMAX,
3668 1 ORO,SLM,oro1,XNSUM,XNSUM1,XNSUM2,XNSUM3,XNSUM4,
3669 2 IM,JM,IMN,JMN,lon_c,lat_c,lon_t,lat_t,
3670 3 is_south_pole,is_north_pole,IMI,JMI,OA_IN,OL_IN,
3671 4 slm_in,lon_in,lat_in)
3679 real,
parameter :: MISSING_VALUE = -9999.
3680 real,
parameter :: d2r = 3.14159265358979/180.
3681 real,
PARAMETER :: R2D=180./3.14159265358979
3682 integer im,jm,imn,jmn,imi,jmi
3684 INTEGER ZAVG(IMN,JMN),ZSLM(IMN,JMN)
3686 real ORO(IM,JM),ORO1(IM,JM),ELVMAX(IM,JM),ZMAX(IM,JM)
3688 integer IOA4(IM,JM,4)
3689 real OA_IN(IMI,JMI,4), OL_IN(IMI,JMI,4)
3690 real slm_in(IMI,JMI)
3691 real lon_in(IMI,JMI), lat_in(IMI,JMI)
3692 real lon_c(IM+1,JM+1), lat_c(IM+1,JM+1)
3693 real lon_t(IM,JM), lat_t(IM,JM)
3694 logical is_south_pole(IM,JM), is_north_pole(IM,JM)
3695 real XNSUM(IM,JM),XNSUM1(IM,JM),XNSUM2(IM,JM)
3696 real XNSUM3(IM,JM),XNSUM4(IM,JM)
3697 real VAR(IM,JM),OL(IM,JM,4)
3699 integer i,j,ilist(IMN),numx,i1,j1,ii1
3701 real LONO(4),LATO(4),LONI,LATI
3702 real DELXN,HC,HEIGHT,XNPU,XNPD,T
3703 integer NS0,NS1,NS2,NS3,NS4,NS5,NS6
3704 logical inside_a_polygon
3705 real lon,lat,dlon,dlat,dlat_old
3706 real lon1,lat1,lon2,lat2
3707 real xnsum11,xnsum12,xnsum21,xnsum22,xnsumx
3708 real HC_11, HC_12, HC_21, HC_22
3709 real xnsum1_11,xnsum1_12,xnsum1_21,xnsum1_22
3710 real xnsum2_11,xnsum2_12,xnsum2_21,xnsum2_22
3711 real get_lon_angle, get_lat_angle, get_xnsum
3712 integer ist, ien, jst, jen
3713 real xland,xwatr,xl1,xs1,oroavg
3714 integer int_opt, ipopt(20), kgds_input(200), kgds_output(200)
3715 integer count_land_output
3716 integer ij, ijmdl_output, iret, num_mismatch_land, num
3717 integer ibo(1), ibi(1)
3718 logical*1,
allocatable :: bitmap_input(:,:)
3719 logical*1,
allocatable :: bitmap_output(:,:)
3720 integer,
allocatable :: ijsav_land_output(:)
3721 real,
allocatable :: lats_land_output(:)
3722 real,
allocatable :: lons_land_output(:)
3723 real,
allocatable :: output_data_land(:,:)
3724 real,
allocatable :: lons_mismatch_output(:)
3725 real,
allocatable :: lats_mismatch_output(:)
3726 real,
allocatable :: data_mismatch_output(:)
3727 integer,
allocatable :: iindx(:), jindx(:)
3733 ijmdl_output = im*jm
3736 glat(j) = -90. + (j-1) * delxn + delxn * 0.5
3738 print *,
' IM=',im,
' JM=',jm,
' IMN=',imn,
' JMN=',jmn
3746 elvmax(i,j) = oro(i,j)
3754 oro1(i,j) = oro(i,j)
3755 elvmax(i,j) = zmax(i,j)
3764 hc = 1116.2 - 0.878 * var(i,j)
3765 lono(1) = lon_c(i,j)
3766 lono(2) = lon_c(i+1,j)
3767 lono(3) = lon_c(i+1,j+1)
3768 lono(4) = lon_c(i,j+1)
3769 lato(1) = lat_c(i,j)
3770 lato(2) = lat_c(i+1,j)
3771 lato(3) = lat_c(i+1,j+1)
3772 lato(4) = lat_c(i,j+1)
3773 call get_index(imn,jmn,4,lono,lato,delxn,jst,jen,ilist,numx)
3774 do j1 = jst, jen;
do ii1 = 1, numx
3777 lati = -90 + j1*delxn
3778 if(inside_a_polygon(loni*d2r,lati*d2r,4,
3779 & lono*d2r,lato*d2r))
then 3781 height = float(zavg(i1,j1))
3782 IF(height.LT.-990.) height = 0.0
3783 IF ( height .gt. oro(i,j) )
then 3784 if ( height .gt. zmax(i,j) )zmax(i,j) = height
3797 oro1(i,j) = oro(i,j)
3798 elvmax(i,j) = zmax(i,j)
3818 kgds_input(4) = 90000
3821 kgds_input(7) = -90000
3822 kgds_input(8) = nint(-360000./imi)
3823 kgds_input(9) = nint((360.0 / float(imi))*1000.0)
3825 kgds_input(10) = jmi /2
3826 kgds_input(12) = 255
3827 kgds_input(20) = 255
3834 kgds_output(4) = 90000
3836 kgds_output(6) = 128
3837 kgds_output(7) = -90000
3838 kgds_output(8) = nint(-360000./im)
3839 kgds_output(9) = nint((360.0 / float(im))*1000.0)
3841 kgds_output(10) = jm /2
3842 kgds_output(12) = 255
3843 kgds_output(20) = 255
3846 print*,
"sum(slm) = ", sum(slm)
3847 do ij = 1, ijmdl_output
3849 i = mod(ij-1,im) + 1
3850 if (slm(i,j) > 0.0)
then 3851 count_land_output=count_land_output+1
3854 allocate(bitmap_input(imi,jmi))
3855 bitmap_input=.false.
3856 print*,
"number of land input=", sum(slm_in)
3857 where(slm_in > 0.0) bitmap_input=.true.
3858 print*,
"count(bitmap_input)", count(bitmap_input)
3860 allocate(bitmap_output(count_land_output,1))
3861 allocate(output_data_land(count_land_output,1))
3862 allocate(ijsav_land_output(count_land_output))
3863 allocate(lats_land_output(count_land_output))
3864 allocate(lons_land_output(count_land_output))
3869 do ij = 1, ijmdl_output
3871 i = mod(ij-1,im) + 1
3872 if (slm(i,j) > 0.0)
then 3873 count_land_output=count_land_output+1
3874 ijsav_land_output(count_land_output)=ij
3875 lats_land_output(count_land_output)=lat_t(i,j)
3876 lons_land_output(count_land_output)=lon_t(i,j)
3885 bitmap_output = .false.
3886 output_data_land = 0.0
3887 call ipolates(int_opt, ipopt, kgds_input, kgds_output,
3888 & (imi*jmi), count_land_output,
3889 & 1, ibi, bitmap_input, oa_in(:,:,kwd),
3890 & count_land_output, lats_land_output,
3891 & lons_land_output, ibo,
3892 & bitmap_output, output_data_land, iret)
3894 print*,
'- FATAL ERROR IN IPOLATES ',iret
3898 num_mismatch_land = 0
3899 do ij = 1, count_land_output
3900 if (bitmap_output(ij,1))
then 3901 j = (ijsav_land_output(ij)-1)/im + 1
3902 i = mod(ijsav_land_output(ij)-1,im) + 1
3903 oa4(i,j,kwd)=output_data_land(ij,1)
3905 num_mismatch_land = num_mismatch_land + 1
3908 print*,
"num_mismatch_land = ", num_mismatch_land
3910 if(.not.
allocated(data_mismatch_output))
then 3911 allocate(lons_mismatch_output(num_mismatch_land))
3912 allocate(lats_mismatch_output(num_mismatch_land))
3913 allocate(data_mismatch_output(num_mismatch_land))
3914 allocate(iindx(num_mismatch_land))
3915 allocate(jindx(num_mismatch_land))
3918 do ij = 1, count_land_output
3919 if (.not. bitmap_output(ij,1))
then 3921 lons_mismatch_output(num) = lons_land_output(ij)
3922 lats_mismatch_output(num) = lats_land_output(ij)
3928 print*,
"before get_mismatch_index", count(bitmap_input)
3930 & lat_in*d2r,bitmap_input,num_mismatch_land,
3931 & lons_mismatch_output*d2r,lats_mismatch_output*d2r,
3935 data_mismatch_output = 0
3937 & num_mismatch_land,data_mismatch_output,iindx,jindx)
3940 do ij = 1, count_land_output
3941 if (.not. bitmap_output(ij,1))
then 3943 j = (ijsav_land_output(ij)-1)/im + 1
3944 i = mod(ijsav_land_output(ij)-1,im) + 1
3945 oa4(i,j,kwd) = data_mismatch_output(num)
3946 if(i==372 .and. j== 611)
then 3947 print*,
"ij=",ij, num, oa4(i,j,kwd),iindx(num),jindx(num)
3957 bitmap_output = .false.
3958 output_data_land = 0.0
3959 call ipolates(int_opt, ipopt, kgds_input, kgds_output,
3960 & (imi*jmi), count_land_output,
3961 & 1, ibi, bitmap_input, ol_in(:,:,kwd),
3962 & count_land_output, lats_land_output,
3963 & lons_land_output, ibo,
3964 & bitmap_output, output_data_land, iret)
3966 print*,
'- FATAL ERROR IN IPOLATES ',iret
3970 num_mismatch_land = 0
3971 do ij = 1, count_land_output
3972 if (bitmap_output(ij,1))
then 3973 j = (ijsav_land_output(ij)-1)/im + 1
3974 i = mod(ijsav_land_output(ij)-1,im) + 1
3975 ol(i,j,kwd)=output_data_land(ij,1)
3977 num_mismatch_land = num_mismatch_land + 1
3980 print*,
"num_mismatch_land = ", num_mismatch_land
3982 data_mismatch_output = 0
3984 & num_mismatch_land,data_mismatch_output,iindx,jindx)
3987 do ij = 1, count_land_output
3988 if (.not. bitmap_output(ij,1))
then 3990 j = (ijsav_land_output(ij)-1)/im + 1
3991 i = mod(ijsav_land_output(ij)-1,im) + 1
3992 ol(i,j,kwd) = data_mismatch_output(num)
3993 if(i==372 .and. j== 611)
then 3994 print*,
"ij=",ij, num, ol(i,j,kwd),iindx(num),jindx(num)
4002 deallocate(lons_mismatch_output,lats_mismatch_output)
4003 deallocate(data_mismatch_output,iindx,jindx)
4004 deallocate(bitmap_output,output_data_land)
4005 deallocate(ijsav_land_output,lats_land_output)
4006 deallocate(lons_land_output)
4012 oa4(i,j,kwd) = sign( min( abs(t), 1. ), t )
4027 t = abs( oa4(i,j,kwd) )
4031 ELSE IF(t .GT. 0. .AND. t .LE. 1.)
THEN 4034 ELSE IF(t .GT. 1. .AND. t .LE. 10.)
THEN 4037 ELSE IF(t .GT. 10. .AND. t .LE. 100.)
THEN 4040 ELSE IF(t .GT. 100. .AND. t .LE. 1000.)
THEN 4043 ELSE IF(t .GT. 1000. .AND. t .LE. 10000.)
THEN 4046 ELSE IF(t .GT. 10000.)
THEN 4054 WRITE(6,*)
"! MAKEOA3 EXIT" 4069 SUBROUTINE revers(IM, JM, numi, F, WRK)
4071 REAL F(IM,JM), WRK(IM,JM)
4081 if (ir .gt. im) ir = ir - im
4106 subroutine rg2gg(im,jm,numi,a)
4108 integer,
intent(in):: im,jm,numi(jm)
4109 real,
intent(inout):: a(im,jm)
4113 r=
real(numi(j))/
real(im)
4115 ir=mod(nint((ig-1)*r),numi(j))+1
4132 subroutine gg2rg(im,jm,numi,a)
4134 integer,
intent(in):: im,jm,numi(jm)
4135 real,
intent(inout):: a(im,jm)
4139 r=
real(numi(j))/
real(im)
4158 SUBROUTINE minmxj(IM,JM,A,title)
4161 real A(IM,JM),rmin,rmax
4172 if(a(i,j).ge.rmax)rmax=a(i,j)
4173 if(a(i,j).le.rmin)rmin=a(i,j)
4176 write(6,150)rmin,rmax,title
4177 150
format(
'rmin=',e13.4,2x,
'rmax=',e13.4,2x,a8,
' ')
4193 SUBROUTINE mnmxja(IM,JM,A,imax,jmax,title)
4196 real A(IM,JM),rmin,rmax
4197 integer i,j,IM,JM,imax,jmax
4207 if(a(i,j).ge.rmax)
then 4212 if(a(i,j).le.rmin)rmin=a(i,j)
4215 write(6,150)rmin,rmax,title
4216 150
format(
'rmin=',e13.4,2x,
'rmax=',e13.4,2x,a8,
' ')
4255 SUBROUTINE spfft1(IMAX,INCW,INCG,KMAX,W,G,IDIR)
4257 INTEGER,
INTENT(IN):: IMAX,INCW,INCG,KMAX,IDIR
4258 COMPLEX,
INTENT(INOUT):: W(INCW,KMAX)
4259 REAL,
INTENT(INOUT):: G(INCG,KMAX)
4260 REAL:: AUX1(25000+INT(0.82*IMAX))
4261 REAL:: AUX2(20000+INT(0.57*IMAX))
4262 INTEGER:: NAUX1,NAUX2
4264 NAUX1=25000+int(0.82*imax)
4265 naux2=20000+int(0.57*imax)
4270 SELECT CASE(digits(1.))
4272 CALL scrft(1,w,incw,g,incg,imax,kmax,-1,1.,
4273 & aux1,naux1,aux2,naux2,0.,0)
4274 CALL scrft(0,w,incw,g,incg,imax,kmax,-1,1.,
4275 & aux1,naux1,aux2,naux2,0.,0)
4277 CALL dcrft(1,w,incw,g,incg,imax,kmax,-1,1.,
4278 & aux1,naux1,aux2,naux2,0.,0)
4279 CALL dcrft(0,w,incw,g,incg,imax,kmax,-1,1.,
4280 & aux1,naux1,aux2,naux2,0.,0)
4285 SELECT CASE(digits(1.))
4287 CALL srcft(1,g,incg,w,incw,imax,kmax,+1,1./imax,
4288 & aux1,naux1,aux2,naux2,0.,0)
4289 CALL srcft(0,g,incg,w,incw,imax,kmax,+1,1./imax,
4290 & aux1,naux1,aux2,naux2,0.,0)
4292 CALL drcft(1,g,incg,w,incw,imax,kmax,+1,1./imax,
4293 & aux1,naux1,aux2,naux2,0.,0)
4294 CALL drcft(0,g,incg,w,incw,imax,kmax,+1,1./imax,
4295 & aux1,naux1,aux2,naux2,0.,0)
4307 include
'netcdf.inc' 4309 integer*2,
intent(out) :: glob(360*120,180*120)
4311 integer :: ncid, error, id_var, fsize
4315 error=nf__open(
"./topography.gmted2010.30s.nc",
4316 & nf_nowrite,fsize,ncid)
4317 call netcdf_err(error,
'Open file topography.gmted2010.30s.nc' )
4318 error=nf_inq_varid(ncid,
'topo', id_var)
4319 call netcdf_err(error,
'Inquire varid of topo')
4320 error=nf_get_var_int2(ncid, id_var, glob)
4322 error = nf_close(ncid)
4325 call maxmin (glob,360*120*180*120,
'global0')
4337 subroutine maxmin(ia,len,tile)
4343 integer iaamax, iaamin, len, j, m, ja, kount
4344 integer(8) sum2,std,mean,isum
4345 integer i_count_notset,kount_9
4360 if ( ja .eq. -9999 )
then 4364 if ( ja .eq. -12345 ) i_count_notset=i_count_notset+1
4366 iaamax = max0( iaamax, ja )
4367 iaamin = min0( iaamin, ja )
4378 std = ifix(sqrt(float((sum2/(kount))-mean**2)))
4379 print*,tile,
' max=',iaamax,
' min=',iaamin,
' sum=',isum,
4380 &
' i_count_notset=',i_count_notset
4381 print*,tile,
' mean=',mean,
' std.dev=',std,
4382 &
' ko9s=',kount,kount_9,kount+kount_9
4395 SUBROUTINE minmaxj(IM,JM,A,title)
4398 real(kind=4) A(IM,JM),rmin,rmax,undef
4399 integer i,j,IM,JM,imax,jmax,imin,jmin,iundef
4400 character*8 title,chara
4416 if(a(i,j).ge.rmax)
then 4421 if(a(i,j).le.rmin)
then 4422 if ( a(i,j) .eq. undef )
then 4432 write(6,150)chara,rmin,imin,jmin,rmax,imax,jmax,iundef
4433 150
format(1x,a8,2x,
'rmin=',e13.4,2i6,2x,
'rmax=',e13.4,3i6)
4449 integer,
intent(in) :: siz
4450 real,
intent(in) :: lon(siz), lat(siz)
4451 real,
intent(out) :: x(siz), y(siz), z(siz)
4456 x(n) = cos(lat(n))*cos(lon(n))
4457 y(n) = cos(lat(n))*sin(lon(n))
4471 real,
parameter :: epsln30 = 1.e-30
4472 real,
parameter :: pi=3.1415926535897931
4473 real v1(3), v2(3), v3(3)
4476 real px, py, pz, qx, qy, qz, ddd;
4479 px = v1(2)*v2(3) - v1(3)*v2(2)
4480 py = v1(3)*v2(1) - v1(1)*v2(3)
4481 pz = v1(1)*v2(2) - v1(2)*v2(1)
4483 qx = v1(2)*v3(3) - v1(3)*v3(2);
4484 qy = v1(3)*v3(1) - v1(1)*v3(3);
4485 qz = v1(1)*v3(2) - v1(2)*v3(1);
4487 ddd = (px*px+py*py+pz*pz)*(qx*qx+qy*qy+qz*qz);
4488 if ( ddd <= 0.0 )
then 4491 ddd = (px*qx+py*qy+pz*qz) / sqrt(ddd);
4492 if( abs(ddd-1) < epsln30 ) ddd = 1;
4493 if( abs(ddd+1) < epsln30 ) ddd = -1;
4494 if ( ddd>1. .or. ddd<-1. )
then 4521 real,
parameter :: epsln10 = 1.e-10
4522 real,
parameter :: epsln8 = 1.e-8
4523 real,
parameter :: pi=3.1415926535897931
4524 real,
parameter :: range_check_criteria=0.05
4529 real lon2(npts), lat2(npts)
4530 real x2(npts), y2(npts), z2(npts)
4531 real lon1_1d(1), lat1_1d(1)
4532 real x1(1), y1(1), z1(1)
4533 real pnt0(3),pnt1(3),pnt2(3)
4535 real max_x2,min_x2,max_y2,min_y2,max_z2,min_z2
4537 call latlon2xyz(npts,lon2, lat2, x2, y2, z2);
4540 call latlon2xyz(1,lon1_1d, lat1_1d, x1, y1, z1);
4543 if( x1(1) > max_x2+range_check_criteria )
return 4545 if( x1(1)+range_check_criteria < min_x2 )
return 4547 if( y1(1) > max_y2+range_check_criteria )
return 4549 if( y1(1)+range_check_criteria < min_y2 )
return 4551 if( z1(1) > max_z2+range_check_criteria )
return 4553 if( z1(1)+range_check_criteria < min_z2 )
return 4561 if(abs(x1(1)-x2(i)) < epsln10 .and.
4562 & abs(y1(1)-y2(i)) < epsln10 .and.
4563 & abs(z1(1)-z2(i)) < epsln10 )
then 4568 if(ip1>npts) ip1 = 1
4578 anglesum = anglesum + angle
4581 if(abs(anglesum-2*pi) < epsln8)
then 4614 function get_xnsum(lon1,lat1,lon2,lat2,IMN,JMN,
4615 & glat,zavg,zslm,delxn)
4620 real,
intent(in) :: lon1,lat1,lon2,lat2,delxn
4621 integer,
intent(in) :: imn,jmn
4622 real,
intent(in) :: glat(jmn)
4623 integer,
intent(in) :: zavg(imn,jmn),zslm(imn,jmn)
4624 integer i, j, ist, ien, jst, jen, i1
4626 real xland,xwatr,xl1,xs1,slm,xnsum
4629 if( glat(j) .GT. lat1 )
then 4635 if( glat(j) .GT. lat2 )
then 4642 ist = lon1/delxn + 1
4644 if(ist .le.0) ist = ist + imn
4645 if(ien < ist) ien = ien + imn
4656 do i1 = 1, ien - ist + 1
4658 if( i .LE. 0) i = i + imn
4659 if( i .GT. imn) i = i - imn
4660 xland = xland + float(zslm(i,j))
4661 xwatr = xwatr + float(1-zslm(i,j))
4663 height = float(zavg(i,j))
4664 IF(height.LT.-990.) height = 0.0
4665 xl1 = xl1 + height * float(zslm(i,j))
4666 xs1 = xs1 + height * float(1-zslm(i,j))
4669 if( xnsum > 1.)
THEN 4670 slm = float(nint(xland/xnsum))
4682 if( i .LE. 0) i = i + imn
4683 if( i .GT. imn) i = i - imn
4684 height = float(zavg(i,j))
4685 IF(height.LT.-990.) height = 0.0
4720 subroutine get_xnsum2(lon1,lat1,lon2,lat2,IMN,JMN,
4721 & glat,zavg,delxn,xnsum1,xnsum2,HC)
4724 real,
intent(out) :: xnsum1,xnsum2,HC
4726 real lon1,lat1,lon2,lat2,oro,delxn
4729 integer zavg(IMN,JMN)
4730 integer i, j, ist, ien, jst, jen, i1
4732 real XW1,XW2,slm,xnsum
4735 if( glat(j) .GT. lat1 )
then 4741 if( glat(j) .GT. lat2 )
then 4748 ist = lon1/delxn + 1
4750 if(ist .le.0) ist = ist + imn
4751 if(ien < ist) ien = ien + imn
4759 do i1 = 1, ien - ist + 1
4761 if( i .LE. 0) i = i + imn
4762 if( i .GT. imn) i = i - imn
4764 height = float(zavg(i,j))
4765 IF(height.LT.-990.) height = 0.0
4767 xw2 = xw2 + height ** 2
4770 var = sqrt(max(xw2/xnsum-(xw1/xnsum)**2,0.))
4771 hc = 1116.2 - 0.878 * var
4777 if( i .LE. 0) i = i + imn
4778 if( i .GT. imn) i = i - imn
4779 height = float(zavg(i,j))
4780 IF ( height .gt. hc ) xnsum1 = xnsum1 + 1
4815 subroutine get_xnsum3(lon1,lat1,lon2,lat2,IMN,JMN,
4816 & glat,zavg,delxn,xnsum1,xnsum2,HC)
4819 real,
intent(out) :: xnsum1,xnsum2
4820 real lon1,lat1,lon2,lat2,oro,delxn
4823 integer zavg(IMN,JMN)
4824 integer i, j, ist, ien, jst, jen, i1
4826 real XW1,XW2,slm,xnsum
4832 if( glat(j) .GT. lat1 )
then 4838 if( glat(j) .GT. lat2 )
then 4845 ist = lon1/delxn + 1
4847 if(ist .le.0) ist = ist + imn
4848 if(ien < ist) ien = ien + imn
4856 if( i .LE. 0) i = i + imn
4857 if( i .GT. imn) i = i - imn
4858 height = float(zavg(i,j))
4859 IF ( height .gt. hc ) xnsum1 = xnsum1 + 1
4879 subroutine nanc(a,l,c)
4880 integer inan1,inan2,inan3,inan4,inaq1,inaq2,inaq3,inaq4
4883 equivalence(itest,word)
4886 data inan1/x
'7F800001'/
4887 data inan2/x
'7FBFFFFF'/
4888 data inan3/x
'FF800001'/
4889 data inan4/x
'FFBFFFFF'/
4893 data inaq1/x
'7FC00000'/
4894 data inaq2/x
'7FFFFFFF'/
4895 data inaq3/x
'FFC00000'/
4896 data inaq4/x
'FFFFFFFF'/
4898 real(kind=8)a(l),rtc,t1,t2
4904 if( (itest .GE. inan1 .AND. itest .LE. inan2) .OR.
4905 * (itest .GE. inan3 .AND. itest .LE. inan4) )
then 4906 print *,
' NaNs detected at word',k,
' ',c
4909 if( (itest .GE. inaq1 .AND. itest .LE. inaq2) .OR.
4910 * (itest .GE. inaq3 .AND. itest .LE. inaq4) )
then 4911 print *,
' NaNq detected at word',k,
' ',c
4919 102
format(
' time to check ',i9,
' words is ',f10.4,
' ',a24)
4927 real function timef()
4928 character(8) :: date
4929 character(10) :: time
4930 character(5) :: zone
4931 integer,
dimension(8) :: values
4934 call date_and_time(date,time,zone,values)
4935 total=(3600*values(5))+(60*values(6))
4937 elapsed=float(total) + (1.0e-3*float(values(8)))
subroutine write_mask_netcdf(im, jm, slm, land_frac, ntiles, tile, geolon, geolat)
Write the land mask file.
subroutine read_mask(merge_file, slm, land_frac, lake_frac, im, jm)
Read the land mask file.
subroutine makemt(ZAVG, ZSLM, ORO, SLM, VAR, VAR4, GLAT, IST, IEN, JST, JEN, IM, JM, IMN, JMN, XLAT, numi)
Create the orography, land-mask, standard deviation of orography and the convexity on a model gaussia...
subroutine get_index(IMN, JMN, npts, lonO, latO, DELXN, jst, jen, ilist, numx)
Determine the location of a cubed-sphere point within the high-resolution orography data...
real function timef()
Get the date/time for the system clock.
subroutine netcdf_err(err, string)
Check NetCDF error code and output the error message.
real function get_lat_angle(dy, DEGRAD)
Convert the 'y' direction distance of a cubed-sphere grid point to the corresponding distance in lati...
subroutine mnmxja(IM, JM, A, imax, jmax, title)
Print out the maximum and minimum values of an array.
subroutine makepc2(ZAVG, ZSLM, THETA, GAMMA, SIGMA, GLAT, IM, JM, IMN, JMN, lon_c, lat_c, SLM)
Make the principle coordinates - slope of orography, anisotropy, angle of mountain range with respect...
real function spherical_angle(v1, v2, v3)
Compute spherical angle.
subroutine minmaxj(IM, JM, A, title)
Print out the maximum and minimum values of an array and their i/j location.
subroutine spfft1(IMAX, INCW, INCG, KMAX, W, G, IDIR)
Perform multiple fast fourier transforms.
program lake_frac
This program computes lake fraction and depth numbers for FV3 cubed sphere grid cells, from a high resolution lat/lon data set.
subroutine rg2gg(im, jm, numi, a)
Convert from a reduced grid to a full grid.
subroutine write_netcdf(im, jm, slm, land_frac, oro, orf, hprime, ntiles, tile, geolon, geolat, lon, lat)
Write out orography file in netcdf format.
subroutine makepc(ZAVG, ZSLM, THETA, GAMMA, SIGMA, GLAT, IST, IEN, JST, JEN, IM, JM, IMN, JMN, XLAT, numi)
Make the principle coordinates - slope of orography, anisotropy, angle of mountain range with respect...
subroutine gg2rg(im, jm, numi, a)
Convert from a full grid to a reduced grid.
subroutine get_xnsum3(lon1, lat1, lon2, lat2, IMN, JMN, glat, zavg, delxn, xnsum1, xnsum2, HC)
Count the number of high-resolution orography points that are higher than a critical value inside a m...
logical function inside_a_polygon(lon1, lat1, npts, lon2, lat2)
Check if a point is inside a polygon.
real function spherical_distance(theta1, phi1, theta2, phi2)
Compute a great circle distance between two points.
subroutine nanc(a, l, c)
Report NaNS and NaNQ within an address range for 8-byte real words.
subroutine makeoa3(ZAVG, zslm, VAR, GLAT, OA4, OL, IOA4, ELVMAX, ORO, SLM, oro1, XNSUM, XNSUM1, XNSUM2, XNSUM3, XNSUM4, IM, JM, IMN, JMN, lon_c, lat_c, lon_t, lat_t, is_south_pole, is_north_pole, IMI, JMI, OA_IN, OL_IN, slm_in, lon_in, lat_in)
Create orographic asymmetry and orographic length scale on the model grid.
subroutine get_mismatch_index(im_in, jm_in, geolon_in, geolat_in, bitmap_in, num_out, lon_out, lat_out, iindx, jindx)
For unmapped land points, find the nearest land point on the input data and pass back its i/j index...
subroutine make_mask(zslm, SLM, land_frac, GLAT, IM, JM, IMN, JMN, lon_c, lat_c)
Create the land-mask, land fraction.
subroutine maxmin(ia, len, tile)
Print the maximum, mininum, mean and standard deviation of an array.
subroutine makemt2(ZAVG, ZSLM, ORO, SLM, VAR, VAR4, GLAT, IM, JM, IMN, JMN, lon_c, lat_c, lake_frac, land_frac)
Create the orography, land-mask, land fraction, standard deviation of orography and the convexity on ...
subroutine interpolate_mismatch(im_in, jm_in, data_in, num_out, data_out, iindx, jindx)
Replace unmapped model land points with the nearest land point on the input grid. ...
real function get_lon_angle(dx, lat, DEGRAD)
Convert the 'x' direction distance of a cubed-sphere grid point to the corresponding distance in long...
subroutine get_xnsum2(lon1, lat1, lon2, lat2, IMN, JMN, glat, zavg, delxn, xnsum1, xnsum2, HC)
Count the number of high-resolution orography points that are higher than a critical value inside a m...
subroutine revers(IM, JM, numi, F, WRK)
Reverse the east-west and north-south axes in a two-dimensional array.
subroutine makeoa2(ZAVG, zslm, VAR, GLAT, OA4, OL, IOA4, ELVMAX, ORO, oro1, XNSUM, XNSUM1, XNSUM2, XNSUM3, XNSUM4, IM, JM, IMN, JMN, lon_c, lat_c, lon_t, lat_t, dx, dy, is_south_pole, is_north_pole)
Create orographic asymmetry and orographic length scale on the model grid.
subroutine latlon2xyz(siz, lon, lat, x, y, z)
Convert from latitude and longitude to x,y,z coordinates.
subroutine minmxj(IM, JM, A, title)
Print out the maximum and minimum values of an array.
subroutine makeoa(ZAVG, VAR, GLAT, OA4, OL, IOA4, ELVMAX, ORO, oro1, XNSUM, XNSUM1, XNSUM2, XNSUM3, XNSUM4, IST, IEN, JST, JEN, IM, JM, IMN, JMN, XLAT, numi)
Create orographic asymmetry and orographic length scale on the model grid.
subroutine tersub(IMN, JMN, IM, JM, NM, NR, NF0, NF1, NW, EFAC, BLAT, OUTGRID, INPUTOROG, MASK_ONLY, MERGE_FILE)
Driver routine to compute terrain.
real function get_xnsum(lon1, lat1, lon2, lat2, IMN, JMN, glat, zavg, zslm, delxn)
Count the number of high-resolution orography points that are higher than the model grid box average ...
subroutine read_g(glob)
Read input global 30-arc second orography data.