[e200b7a] | 1 | !********************************************************************** |
---|
| 2 | ! Copyright 1998,1999,2000,2001,2002,2005,2007,2008,2009,2010 * |
---|
| 3 | ! Andreas Stohl, Petra Seibert, A. Frank, Gerhard Wotawa, * |
---|
| 4 | ! Caroline Forster, Sabine Eckhardt, John Burkhart, Harald Sodemann * |
---|
| 5 | ! * |
---|
| 6 | ! This file is part of FLEXPART. * |
---|
| 7 | ! * |
---|
| 8 | ! FLEXPART is free software: you can redistribute it and/or modify * |
---|
| 9 | ! it under the terms of the GNU General Public License as published by* |
---|
| 10 | ! the Free Software Foundation, either version 3 of the License, or * |
---|
| 11 | ! (at your option) any later version. * |
---|
| 12 | ! * |
---|
| 13 | ! FLEXPART is distributed in the hope that it will be useful, * |
---|
| 14 | ! but WITHOUT ANY WARRANTY; without even the implied warranty of * |
---|
| 15 | ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
---|
| 16 | ! GNU General Public License for more details. * |
---|
| 17 | ! * |
---|
| 18 | ! You should have received a copy of the GNU General Public License * |
---|
| 19 | ! along with FLEXPART. If not, see <http://www.gnu.org/licenses/>. * |
---|
| 20 | !********************************************************************** |
---|
| 21 | |
---|
[4fbe7a5] | 22 | subroutine interpol_rain(yy1,yy2,yy3,nxmax,nymax,nzmax,nx, & |
---|
[c7e771d] | 23 | ny,iwftouse,xt,yt,level,itime1,itime2,itime,yint1,yint2,yint3) |
---|
[4fbe7a5] | 24 | ! i i i i i i i |
---|
| 25 | !i i i i i i i i o o o |
---|
[e200b7a] | 26 | !**************************************************************************** |
---|
| 27 | ! * |
---|
| 28 | ! Interpolation of meteorological fields on 2-d model layers. * |
---|
| 29 | ! In horizontal direction bilinear interpolation interpolation is used. * |
---|
| 30 | ! Temporally a linear interpolation is used. * |
---|
| 31 | ! Three fields are interpolated at the same time. * |
---|
| 32 | ! * |
---|
| 33 | ! This is a special version of levlininterpol to save CPU time. * |
---|
| 34 | ! * |
---|
| 35 | ! 1 first time * |
---|
| 36 | ! 2 second time * |
---|
| 37 | ! * |
---|
| 38 | ! * |
---|
| 39 | ! Author: A. Stohl * |
---|
| 40 | ! * |
---|
| 41 | ! 30 August 1996 * |
---|
[4fbe7a5] | 42 | ! * |
---|
[e200b7a] | 43 | !**************************************************************************** |
---|
| 44 | ! * |
---|
| 45 | ! Variables: * |
---|
| 46 | ! * |
---|
| 47 | ! dt1,dt2 time differences between fields and current position * |
---|
| 48 | ! dz1,dz2 z distance between levels and current position * |
---|
| 49 | ! height(nzmax) heights of the model levels * |
---|
| 50 | ! indexh help variable * |
---|
| 51 | ! indz the level closest to the current trajectory position * |
---|
| 52 | ! indzh help variable * |
---|
| 53 | ! itime current time * |
---|
| 54 | ! itime1 time of the first wind field * |
---|
| 55 | ! itime2 time of the second wind field * |
---|
| 56 | ! ix,jy x,y coordinates of lower left subgrid point * |
---|
| 57 | ! level level at which interpolation shall be done * |
---|
[0ecc1fe] | 58 | ! iwftouse points to the place of the wind field * |
---|
[e200b7a] | 59 | ! nx,ny actual field dimensions in x,y and z direction * |
---|
| 60 | ! nxmax,nymax,nzmax maximum field dimensions in x,y and z direction * |
---|
| 61 | ! xt current x coordinate * |
---|
| 62 | ! yint the final interpolated value * |
---|
| 63 | ! yt current y coordinate * |
---|
| 64 | ! yy(0:nxmax,0:nymax,nzmax,3) meteorological field used for interpolation * |
---|
| 65 | ! zt current z coordinate * |
---|
| 66 | ! * |
---|
| 67 | !**************************************************************************** |
---|
[8a65cb0] | 68 | use par_mod, only: numwfmem |
---|
[e200b7a] | 69 | |
---|
| 70 | implicit none |
---|
| 71 | |
---|
[8a65cb0] | 72 | integer :: nx,ny,nxmax,nymax,nzmax,memind(numwfmem),m,ix,jy,ixp,jyp |
---|
[4fbe7a5] | 73 | integer :: itime,itime1,itime2,level,indexh |
---|
[8a65cb0] | 74 | real :: yy1(0:nxmax-1,0:nymax-1,nzmax,numwfmem) |
---|
| 75 | real :: yy2(0:nxmax-1,0:nymax-1,nzmax,numwfmem) |
---|
| 76 | real :: yy3(0:nxmax-1,0:nymax-1,nzmax,numwfmem) |
---|
[4fbe7a5] | 77 | real :: ddx,ddy,rddx,rddy,dt1,dt2,dt,y1(2),y2(2),y3(2) |
---|
| 78 | real :: xt,yt,yint1,yint2,yint3,p1,p2,p3,p4 |
---|
[c7e771d] | 79 | integer :: iwftouse |
---|
[e200b7a] | 80 | |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | ! If point at border of grid -> small displacement into grid |
---|
| 84 | !*********************************************************** |
---|
| 85 | |
---|
| 86 | if (xt.ge.real(nx-1)) xt=real(nx-1)-0.00001 |
---|
| 87 | if (yt.ge.real(ny-1)) yt=real(ny-1)-0.00001 |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | |
---|
| 91 | !********************************************************************** |
---|
| 92 | ! 1.) Bilinear horizontal interpolation |
---|
| 93 | ! This has to be done separately for 2 fields (Temporal) |
---|
| 94 | !******************************************************* |
---|
| 95 | |
---|
| 96 | ! Determine the lower left corner and its distance to the current position |
---|
| 97 | !************************************************************************* |
---|
| 98 | |
---|
| 99 | ix=int(xt) |
---|
| 100 | jy=int(yt) |
---|
| 101 | ixp=ix+1 |
---|
| 102 | jyp=jy+1 |
---|
| 103 | ddx=xt-real(ix) |
---|
| 104 | ddy=yt-real(jy) |
---|
| 105 | rddx=1.-ddx |
---|
| 106 | rddy=1.-ddy |
---|
| 107 | p1=rddx*rddy |
---|
| 108 | p2=ddx*rddy |
---|
| 109 | p3=rddx*ddy |
---|
| 110 | p4=ddx*ddy |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | ! Loop over 2 time steps |
---|
| 114 | !*********************** |
---|
| 115 | |
---|
[c7e771d] | 116 | ! do m=1,2 |
---|
| 117 | indexh=iwftouse |
---|
[e200b7a] | 118 | |
---|
[c7e771d] | 119 | y1(1)=p1*yy1(ix ,jy ,level,indexh) & |
---|
[e200b7a] | 120 | + p2*yy1(ixp,jy ,level,indexh) & |
---|
| 121 | + p3*yy1(ix ,jyp,level,indexh) & |
---|
| 122 | + p4*yy1(ixp,jyp,level,indexh) |
---|
[c7e771d] | 123 | y2(1)=p1*yy2(ix ,jy ,level,indexh) & |
---|
[e200b7a] | 124 | + p2*yy2(ixp,jy ,level,indexh) & |
---|
| 125 | + p3*yy2(ix ,jyp,level,indexh) & |
---|
| 126 | + p4*yy2(ixp,jyp,level,indexh) |
---|
[c7e771d] | 127 | y3(1)=p1*yy3(ix ,jy ,level,indexh) & |
---|
[e200b7a] | 128 | + p2*yy3(ixp,jy ,level,indexh) & |
---|
| 129 | + p3*yy3(ix ,jyp,level,indexh) & |
---|
| 130 | + p4*yy3(ixp,jyp,level,indexh) |
---|
[c7e771d] | 131 | ! end do |
---|
[e200b7a] | 132 | |
---|
| 133 | |
---|
| 134 | !************************************ |
---|
[c7e771d] | 135 | ! 2.) Temporal interpolation (linear) - skip to be consistent with clouds |
---|
[e200b7a] | 136 | !************************************ |
---|
| 137 | |
---|
[c7e771d] | 138 | ! dt1=real(itime-itime1) |
---|
| 139 | ! dt2=real(itime2-itime) |
---|
| 140 | ! dt=dt1+dt2 |
---|
[e200b7a] | 141 | |
---|
[c7e771d] | 142 | ! yint1=(y1(1)*dt2+y1(2)*dt1)/dt |
---|
| 143 | ! yint2=(y2(1)*dt2+y2(2)*dt1)/dt |
---|
| 144 | ! yint3=(y3(1)*dt2+y3(2)*dt1)/dt |
---|
[e200b7a] | 145 | |
---|
[c7e771d] | 146 | yint1=y1(1) |
---|
| 147 | yint2=y2(1) |
---|
| 148 | yint3=y3(1) |
---|
[e200b7a] | 149 | |
---|
| 150 | end subroutine interpol_rain |
---|