[816] | 1 | program fft |
---|
| 2 | |
---|
| 3 | ! SL 01/2010: |
---|
| 4 | ! This program reads 4D (lon-lat-alt-time) fields recast in log P coordinates |
---|
| 5 | ! |
---|
| 6 | ! it computes fft of temperature, zonal and merid winds from high-frequency outputs: |
---|
| 7 | ! |
---|
| 8 | ! fftaT -- 4D -- FFT in amplitude of temperature field (K) |
---|
| 9 | ! fftau -- 4D -- FFT in amplitude of zonal wind (m s-1) |
---|
| 10 | ! fftav -- 4D -- FFT in amplitude of meridional wind (m s-1) |
---|
| 11 | ! ulf -- 4D -- low freq part of zonal wind perturbation uprim (m s-1) |
---|
| 12 | ! ubf -- 4D -- band freq part of zonal wind perturbation uprim (m s-1) |
---|
| 13 | ! uhf -- 4D -- high freq part of zonal wind perturbation uprim (m s-1) |
---|
| 14 | ! vlf -- 4D -- low freq part of meridional wind perturbation vprim (m s-1) |
---|
| 15 | ! vbf -- 4D -- band freq part of meridional wind perturbation vprim (m s-1) |
---|
| 16 | ! vhf -- 4D -- high freq part of meridional wind perturbation vprim (m s-1) |
---|
| 17 | ! wlf -- 4D -- low freq part of vertical wind perturbation wprim (Pa s-1) |
---|
| 18 | ! wbf -- 4D -- band freq part of vertical wind perturbation wprim (Pa s-1) |
---|
| 19 | ! whf -- 4D -- high freq part of vertical wind perturbation wprim (Pa s-1) |
---|
| 20 | ! Tlf -- 4D -- low freq part of temperature perturbation Tprim (K) |
---|
| 21 | ! Tbf -- 4D -- band freq part of temperature perturbation Tprim (K) |
---|
| 22 | ! Thf -- 4D -- high freq part of temperature perturbation Tprim (K) |
---|
| 23 | ! |
---|
| 24 | ! Minimal requirements and dependencies: |
---|
| 25 | ! The dataset must include the following data: |
---|
| 26 | ! - pressure vertical coordinate |
---|
| 27 | ! - atmospheric temperature |
---|
| 28 | ! - zonal, meridional and vertical winds |
---|
| 29 | ! |
---|
| 30 | ! We use the FFTW library: http://www.fftw.org |
---|
| 31 | ! These routines are in C, but also include Fortran interfaces. |
---|
| 32 | ! |
---|
| 33 | ! Convention: qbar <=> zonal average / qstar = q - qbar |
---|
| 34 | ! qmean <=> temporal average / qprim = q - qmean |
---|
| 35 | ! |
---|
| 36 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 37 | ! FILTRES |
---|
| 38 | !!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 39 | ! low frequencies: qlf= lowfreq(qprim) |
---|
| 40 | ! band frequencies: qbf=bandfreq(qprim) |
---|
| 41 | ! high frequencies: qhf=highfreq(qprim) |
---|
| 42 | ! |
---|
| 43 | ! Les frequences seuils sont ajustables dans filter.h |
---|
| 44 | ! |
---|
| 45 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
---|
| 46 | |
---|
| 47 | implicit none |
---|
| 48 | |
---|
| 49 | include "netcdf.inc" ! NetCDF definitions |
---|
| 50 | |
---|
| 51 | character (len=128) :: infile ! input file name (name_P.nc) |
---|
| 52 | character (len=128) :: outfile1,outfile2,outfile3,outfile4 ! output file names |
---|
| 53 | |
---|
| 54 | character (len=64) :: text ! to store some text |
---|
| 55 | integer infid ! NetCDF input file ID |
---|
| 56 | integer outfid1,outfid2,outfid3,outfid4 ! NetCDF output files ID |
---|
| 57 | integer lon_dimid1,lat_dimid1,alt_dimid1,time_dimid1 ! NetCDF dimension IDs |
---|
| 58 | integer lon_dimid2,lat_dimid2,alt_dimid2,time_dimid2 ! NetCDF dimension IDs |
---|
| 59 | integer lon_dimid3,lat_dimid3,alt_dimid3,time_dimid3 ! NetCDF dimension IDs |
---|
| 60 | integer lon_dimid4,lat_dimid4,alt_dimid4,time_dimid4 ! NetCDF dimension IDs |
---|
| 61 | integer lon_varid,lat_varid,alt_varid,time_varid |
---|
| 62 | integer :: datashape1d ! shape of 1D datasets |
---|
| 63 | integer,dimension(4) :: datashape4d ! shape of 4D datasets |
---|
| 64 | |
---|
| 65 | real :: miss_val=9.99e+33 ! special "missing value" to specify missing data |
---|
| 66 | real,parameter :: miss_val_def=9.99e+33 ! default value for "missing value" |
---|
| 67 | real :: pi |
---|
| 68 | real,dimension(:),allocatable :: lon ! longitude |
---|
| 69 | integer lonlength ! # of grid points along longitude |
---|
| 70 | real,dimension(:),allocatable :: lat ! latitude |
---|
| 71 | real,dimension(:),allocatable :: latrad ! latitude in radian |
---|
| 72 | integer latlength ! # of grid points along latitude |
---|
| 73 | real,dimension(:),allocatable :: plev ! Pressure levels (Pa) |
---|
| 74 | integer altlength ! # of grid point along altitude (of input datasets) |
---|
| 75 | real,dimension(:),allocatable :: time ! time |
---|
| 76 | real,dimension(:),allocatable :: freq ! frequencies of the FFT (only timelength/2+1 values) |
---|
| 77 | integer timelength ! # of points along time |
---|
| 78 | real,dimension(:,:,:,:),allocatable :: temp ! atmospheric temperature |
---|
| 79 | real,dimension(:,:,:,:),allocatable :: vitu ! zonal wind (in m/s) |
---|
| 80 | real,dimension(:,:,:,:),allocatable :: vitv ! meridional wind (in m/s) |
---|
| 81 | real,dimension(:,:,:,:),allocatable :: vitw ! vertical wind (in Pa/s) |
---|
| 82 | |
---|
| 83 | !!! output variables |
---|
| 84 | real,dimension(:,:,:,:),allocatable :: fftaT ! FFT in amplitude of temperature (K) |
---|
| 85 | real,dimension(:,:,:,:),allocatable :: fftau ! FFT in amplitude of zonal wind (m s-1) |
---|
| 86 | real,dimension(:,:,:,:),allocatable :: fftav ! FFT in amplitude of meridional wind (m s-1) |
---|
| 87 | real,dimension(:,:,:,:),allocatable :: fftaw ! FFT in amplitude of vertical wind (Pa s-1) |
---|
| 88 | real,dimension(:,:,:,:),allocatable :: ulf ! low freq part of zonal wind perturbation uprim (m s-1) |
---|
| 89 | real,dimension(:,:,:,:),allocatable :: ubf ! band freq part of zonal wind perturbation uprim (m s-1) |
---|
| 90 | real,dimension(:,:,:,:),allocatable :: uhf ! high freq part of zonal wind perturbation uprim (m s-1) |
---|
| 91 | real,dimension(:,:,:,:),allocatable :: vlf ! low freq part of meridional wind perturbation vprim (m s-1) |
---|
| 92 | real,dimension(:,:,:,:),allocatable :: vbf ! band freq part of meridional wind perturbation vprim (m s-1) |
---|
| 93 | real,dimension(:,:,:,:),allocatable :: vhf ! high freq part of meridional wind perturbation vprim (m s-1) |
---|
| 94 | real,dimension(:,:,:,:),allocatable :: wlf ! low freq part of vertical wind perturbation vprim (Pa s-1) |
---|
| 95 | real,dimension(:,:,:,:),allocatable :: wbf ! band freq part of vertical wind perturbation vprim (Pa s-1) |
---|
| 96 | real,dimension(:,:,:,:),allocatable :: whf ! high freq part of vertical wind perturbation vprim (Pa s-1) |
---|
| 97 | real,dimension(:,:,:,:),allocatable :: Tlf ! low freq part of temperature perturbation Tprim (K) |
---|
| 98 | real,dimension(:,:,:,:),allocatable :: Tbf ! band freq part of temperature perturbation Tprim (K) |
---|
| 99 | real,dimension(:,:,:,:),allocatable :: Thf ! high freq part of temperature perturbation Tprim (K) |
---|
| 100 | |
---|
| 101 | ! local variables |
---|
| 102 | real,dimension(:,:,:,:),allocatable :: uprim |
---|
| 103 | real,dimension(:,:,:,:),allocatable :: vprim |
---|
| 104 | real,dimension(:,:,:,:),allocatable :: wprim |
---|
| 105 | real,dimension(:,:,:,:),allocatable :: Tprim |
---|
| 106 | |
---|
| 107 | ! lon,lat,alt |
---|
| 108 | real,dimension(:,:,:),allocatable :: umean |
---|
| 109 | real,dimension(:,:,:),allocatable :: vmean |
---|
| 110 | real,dimension(:,:,:),allocatable :: wmean |
---|
| 111 | real,dimension(:,:,:),allocatable :: Tmean |
---|
| 112 | |
---|
| 113 | ! for FFTW routines |
---|
| 114 | real,dimension(:),allocatable :: wndow |
---|
| 115 | double precision,dimension(:),allocatable :: var,fltvar |
---|
| 116 | double complex,dimension(:),allocatable :: fftvar,fltfft |
---|
| 117 | double complex,dimension(:),allocatable :: filtrelf,filtrebf,filtrehf |
---|
| 118 | integer :: M_fft |
---|
| 119 | integer*8 :: planf,planb |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | integer ierr,ierr1,ierr2 ! NetCDF routines return codes |
---|
| 123 | integer i,j,ilon,ilat,ilev,itim ! for loops |
---|
| 124 | logical flagfft |
---|
| 125 | logical :: lmdflag |
---|
| 126 | |
---|
| 127 | include "planet.h" |
---|
| 128 | include "filter.h" |
---|
| 129 | |
---|
| 130 | #include <fftw3.f> |
---|
| 131 | |
---|
| 132 | !=============================================================================== |
---|
| 133 | ! 1. Input parameters |
---|
| 134 | !=============================================================================== |
---|
| 135 | |
---|
| 136 | pi = 2.*asin(1.) |
---|
| 137 | |
---|
| 138 | write(*,*) "" |
---|
| 139 | write(*,*) "You are working on the atmosphere of ",planet |
---|
| 140 | |
---|
| 141 | !=============================================================================== |
---|
| 142 | ! 1.1 Input file |
---|
| 143 | !=============================================================================== |
---|
| 144 | |
---|
| 145 | write(*,*) "" |
---|
| 146 | write(*,*) " Program valid for files with pressure axis (*_P.nc)" |
---|
| 147 | write(*,*) "Enter input file name:" |
---|
| 148 | |
---|
| 149 | read(*,'(a128)') infile |
---|
| 150 | write(*,*) "" |
---|
| 151 | |
---|
| 152 | ! open input file |
---|
| 153 | |
---|
| 154 | ierr = NF_OPEN(infile,NF_NOWRITE,infid) |
---|
| 155 | if (ierr.ne.NF_NOERR) then |
---|
| 156 | write(*,*) 'ERROR: Pb opening file ',trim(infile) |
---|
| 157 | stop "" |
---|
| 158 | endif |
---|
| 159 | |
---|
| 160 | !=============================================================================== |
---|
| 161 | ! 1.2 Get grids in lon,lat,alt(pressure),time |
---|
| 162 | !=============================================================================== |
---|
| 163 | |
---|
| 164 | call get_iddim(infid,lat_varid,latlength,lon_varid,lonlength,& |
---|
| 165 | alt_varid,altlength,time_varid,timelength,lmdflag ) |
---|
| 166 | |
---|
| 167 | allocate(lon(lonlength)) |
---|
| 168 | ierr=NF_GET_VAR_REAL(infid,lon_varid,lon) |
---|
| 169 | if (ierr.ne.NF_NOERR) stop "Error: Failed reading longitude" |
---|
| 170 | |
---|
| 171 | allocate(lat(latlength)) |
---|
| 172 | ierr=NF_GET_VAR_REAL(infid,lat_varid,lat) |
---|
| 173 | if (ierr.ne.NF_NOERR) stop "Error: Failed reading lat" |
---|
| 174 | |
---|
| 175 | allocate(latrad(latlength)) |
---|
| 176 | latrad = lat*pi/180. |
---|
| 177 | |
---|
| 178 | allocate(plev(altlength)) |
---|
| 179 | ierr=NF_GET_VAR_REAL(infid,alt_varid,plev) |
---|
| 180 | if (ierr.ne.NF_NOERR) stop "Error: Failed reading altitude (ie pressure levels)" |
---|
| 181 | |
---|
| 182 | allocate(time(timelength)) |
---|
| 183 | ierr=NF_GET_VAR_REAL(infid,time_varid,time) |
---|
| 184 | if (ierr.ne.NF_NOERR) stop "Error: Failed reading time" |
---|
| 185 | |
---|
| 186 | !=============================================================================== |
---|
| 187 | ! 1.3 Get output file name |
---|
| 188 | !=============================================================================== |
---|
| 189 | write(*,*) "" |
---|
| 190 | !write(*,*) "Enter output file name" |
---|
| 191 | !read(*,*) outfile |
---|
| 192 | outfile1=infile(1:len_trim(infile)-3)//"_UFFT.nc" |
---|
| 193 | outfile2=infile(1:len_trim(infile)-3)//"_VFFT.nc" |
---|
| 194 | outfile3=infile(1:len_trim(infile)-3)//"_WFFT.nc" |
---|
| 195 | outfile4=infile(1:len_trim(infile)-3)//"_TFFT.nc" |
---|
| 196 | write(*,*) "Output file names are: " |
---|
| 197 | if (ok_out(1)) write(*,*) trim(outfile1) |
---|
| 198 | if (ok_out(2)) write(*,*) trim(outfile2) |
---|
| 199 | if (ok_out(3)) write(*,*) trim(outfile3) |
---|
| 200 | if (ok_out(4)) write(*,*) trim(outfile4) |
---|
| 201 | |
---|
| 202 | |
---|
| 203 | !=============================================================================== |
---|
| 204 | ! 2.1 Store needed fields |
---|
| 205 | !=============================================================================== |
---|
| 206 | |
---|
| 207 | !=============================================================================== |
---|
| 208 | ! 2.1.1 Atmospheric temperature |
---|
| 209 | !=============================================================================== |
---|
[888] | 210 | if (ok_out(4)) then |
---|
[816] | 211 | allocate(temp(lonlength,latlength,altlength,timelength)) |
---|
| 212 | |
---|
| 213 | text="temp" |
---|
| 214 | call get_var4d(infid,lonlength,latlength,altlength,timelength,text,temp,ierr1,ierr2) |
---|
| 215 | if (ierr1.ne.NF_NOERR) then |
---|
| 216 | write(*,*) " looking for t instead... " |
---|
| 217 | text="t" |
---|
| 218 | call get_var4d(infid,lonlength,latlength,altlength,timelength,text,temp,ierr1,ierr2) |
---|
[888] | 219 | if (ierr1.ne.NF_NOERR) then |
---|
| 220 | print*,"Error: Failed to get temperature ID" |
---|
| 221 | ok_out(4)=.false. |
---|
| 222 | endif |
---|
[816] | 223 | endif |
---|
[888] | 224 | if (ierr2.ne.NF_NOERR) then |
---|
| 225 | print*,"Error: Failed reading temperature" |
---|
| 226 | ok_out(4)=.false. |
---|
| 227 | endif |
---|
| 228 | endif !ok_out(4) |
---|
[816] | 229 | |
---|
| 230 | !=============================================================================== |
---|
| 231 | ! 2.1.2 Winds |
---|
| 232 | !=============================================================================== |
---|
[888] | 233 | ! zonal wind vitu (in m/s) |
---|
| 234 | if (ok_out(1)) then |
---|
[816] | 235 | allocate(vitu(lonlength,latlength,altlength,timelength)) |
---|
| 236 | |
---|
| 237 | text="vitu" |
---|
| 238 | call get_var4d(infid,lonlength,latlength,altlength,timelength,text,vitu,ierr1,ierr2) |
---|
[888] | 239 | if (ierr1.ne.NF_NOERR) then |
---|
| 240 | print*,"Error: Failed to get vitu ID" |
---|
| 241 | ok_out(1)=.false. |
---|
| 242 | endif |
---|
| 243 | if (ierr2.ne.NF_NOERR) then |
---|
| 244 | print*,"Error: Failed reading zonal wind" |
---|
| 245 | ok_out(1)=.false. |
---|
| 246 | endif |
---|
| 247 | endif !ok_out(1) |
---|
[816] | 248 | |
---|
| 249 | ! meridional wind vitv (in m/s) |
---|
[888] | 250 | if (ok_out(2)) then |
---|
| 251 | allocate(vitv(lonlength,latlength,altlength,timelength)) |
---|
| 252 | |
---|
[816] | 253 | text="vitv" |
---|
| 254 | call get_var4d(infid,lonlength,latlength,altlength,timelength,text,vitv,ierr1,ierr2) |
---|
[888] | 255 | if (ierr1.ne.NF_NOERR) then |
---|
| 256 | print*,"Error: Failed to get vitv ID" |
---|
| 257 | ok_out(2)=.false. |
---|
| 258 | endif |
---|
| 259 | if (ierr2.ne.NF_NOERR) then |
---|
| 260 | print*,"Error: Failed reading meridional wind" |
---|
| 261 | ok_out(2)=.false. |
---|
| 262 | endif |
---|
| 263 | endif !ok_out(2) |
---|
[816] | 264 | |
---|
| 265 | ! vertical wind vitw (in Pa/s) |
---|
[888] | 266 | if (ok_out(3)) then |
---|
| 267 | allocate(vitw(lonlength,latlength,altlength,timelength)) |
---|
| 268 | |
---|
[816] | 269 | text="vitw" |
---|
| 270 | call get_var4d(infid,lonlength,latlength,altlength,timelength,text,vitw,ierr1,ierr2) |
---|
[888] | 271 | if (ierr1.ne.NF_NOERR) then |
---|
| 272 | print*,"Error: Failed to get vitw ID" |
---|
| 273 | ok_out(3)=.false. |
---|
| 274 | endif |
---|
| 275 | if (ierr2.ne.NF_NOERR) then |
---|
| 276 | print*,"Error: Failed reading vertical wind" |
---|
| 277 | ok_out(3)=.false. |
---|
| 278 | endif |
---|
| 279 | endif !ok_out(3) |
---|
[816] | 280 | |
---|
| 281 | !=============================================================================== |
---|
| 282 | ! 2.2 Computations |
---|
| 283 | !=============================================================================== |
---|
| 284 | |
---|
| 285 | print*,"debut calcul" |
---|
| 286 | |
---|
| 287 | !=============================================================================== |
---|
| 288 | ! 2.2.1 FFT and filtering |
---|
| 289 | !=============================================================================== |
---|
| 290 | ! allocations |
---|
| 291 | !------------- |
---|
[888] | 292 | if (ok_out(1)) then |
---|
[816] | 293 | allocate(fftau(lonlength,latlength,altlength,timelength)) |
---|
[888] | 294 | allocate(uprim(lonlength,latlength,altlength,timelength)) |
---|
| 295 | allocate(ulf(lonlength,latlength,altlength,timelength)) |
---|
| 296 | allocate(ubf(lonlength,latlength,altlength,timelength)) |
---|
| 297 | allocate(uhf(lonlength,latlength,altlength,timelength)) |
---|
| 298 | endif !ok_out(1) |
---|
| 299 | if (ok_out(2)) then |
---|
[816] | 300 | allocate(fftav(lonlength,latlength,altlength,timelength)) |
---|
[888] | 301 | allocate(vprim(lonlength,latlength,altlength,timelength)) |
---|
| 302 | allocate(vlf(lonlength,latlength,altlength,timelength)) |
---|
| 303 | allocate(vbf(lonlength,latlength,altlength,timelength)) |
---|
| 304 | allocate(vhf(lonlength,latlength,altlength,timelength)) |
---|
| 305 | endif !ok_out(2) |
---|
| 306 | if (ok_out(3)) then |
---|
[816] | 307 | allocate(fftaw(lonlength,latlength,altlength,timelength)) |
---|
[888] | 308 | allocate(wprim(lonlength,latlength,altlength,timelength)) |
---|
| 309 | allocate(wlf(lonlength,latlength,altlength,timelength)) |
---|
| 310 | allocate(wbf(lonlength,latlength,altlength,timelength)) |
---|
| 311 | allocate(whf(lonlength,latlength,altlength,timelength)) |
---|
| 312 | endif !ok_out(3) |
---|
| 313 | if (ok_out(4)) then |
---|
[816] | 314 | allocate(fftaT(lonlength,latlength,altlength,timelength)) |
---|
| 315 | allocate(Tprim(lonlength,latlength,altlength,timelength)) |
---|
| 316 | allocate(Tlf(lonlength,latlength,altlength,timelength)) |
---|
| 317 | allocate(Tbf(lonlength,latlength,altlength,timelength)) |
---|
| 318 | allocate(Thf(lonlength,latlength,altlength,timelength)) |
---|
[888] | 319 | endif !ok_out(4) |
---|
[816] | 320 | |
---|
| 321 | ! lon,lat,alt |
---|
[888] | 322 | if (ok_out(1)) allocate(umean(lonlength,latlength,altlength)) |
---|
| 323 | if (ok_out(2)) allocate(vmean(lonlength,latlength,altlength)) |
---|
| 324 | if (ok_out(3)) allocate(wmean(lonlength,latlength,altlength)) |
---|
| 325 | if (ok_out(4)) allocate(Tmean(lonlength,latlength,altlength)) |
---|
[816] | 326 | |
---|
| 327 | ! time / frequencies |
---|
| 328 | allocate(freq(timelength)) |
---|
| 329 | allocate(wndow(timelength)) |
---|
| 330 | allocate(var(timelength)) |
---|
| 331 | allocate(fltvar(timelength)) |
---|
| 332 | M_fft = timelength/2 |
---|
| 333 | allocate(fftvar(M_fft+1)) |
---|
| 334 | allocate(fltfft(M_fft+1)) |
---|
| 335 | allocate(filtrelf(M_fft+1)) |
---|
| 336 | allocate(filtrebf(M_fft+1)) |
---|
| 337 | allocate(filtrehf(M_fft+1)) |
---|
| 338 | |
---|
| 339 | ! intermediates |
---|
| 340 | !----------------- |
---|
| 341 | |
---|
[888] | 342 | if (ok_out(1)) call moytim(lonlength,latlength,altlength,timelength,miss_val,vitu,umean) |
---|
| 343 | if (ok_out(2)) call moytim(lonlength,latlength,altlength,timelength,miss_val,vitv,vmean) |
---|
| 344 | if (ok_out(3)) call moytim(lonlength,latlength,altlength,timelength,miss_val,vitw,wmean) |
---|
| 345 | if (ok_out(4)) call moytim(lonlength,latlength,altlength,timelength,miss_val,temp,Tmean) |
---|
[816] | 346 | |
---|
| 347 | do ilon=1,lonlength |
---|
| 348 | do ilat=1,latlength |
---|
| 349 | do ilev=1,altlength |
---|
| 350 | do itim=1,timelength |
---|
[888] | 351 | if (ok_out(1)) then |
---|
[816] | 352 | if ((vitu(ilon,ilat,ilev,itim).ne.miss_val).and. & |
---|
| 353 | (umean(ilon,ilat,ilev) .ne.miss_val)) then |
---|
| 354 | uprim(ilon,ilat,ilev,itim) = vitu(ilon,ilat,ilev,itim)-umean(ilon,ilat,ilev) |
---|
| 355 | else |
---|
| 356 | uprim(ilon,ilat,ilev,itim) = miss_val |
---|
| 357 | endif |
---|
[888] | 358 | endif !ok_out(1) |
---|
| 359 | if (ok_out(2)) then |
---|
[816] | 360 | if ((vitv(ilon,ilat,ilev,itim).ne.miss_val).and. & |
---|
| 361 | (vmean(ilon,ilat,ilev) .ne.miss_val)) then |
---|
| 362 | vprim(ilon,ilat,ilev,itim) = vitv(ilon,ilat,ilev,itim)-vmean(ilon,ilat,ilev) |
---|
| 363 | else |
---|
| 364 | vprim(ilon,ilat,ilev,itim) = miss_val |
---|
| 365 | endif |
---|
[888] | 366 | endif !ok_out(2) |
---|
| 367 | if (ok_out(3)) then |
---|
[816] | 368 | if ((vitw(ilon,ilat,ilev,itim).ne.miss_val).and. & |
---|
| 369 | (wmean(ilon,ilat,ilev) .ne.miss_val)) then |
---|
| 370 | wprim(ilon,ilat,ilev,itim) = vitw(ilon,ilat,ilev,itim)-wmean(ilon,ilat,ilev) |
---|
| 371 | else |
---|
| 372 | wprim(ilon,ilat,ilev,itim) = miss_val |
---|
| 373 | endif |
---|
[888] | 374 | endif !ok_out(3) |
---|
| 375 | if (ok_out(4)) then |
---|
[816] | 376 | if ((temp(ilon,ilat,ilev,itim).ne.miss_val).and. & |
---|
| 377 | (Tmean(ilon,ilat,ilev) .ne.miss_val)) then |
---|
| 378 | Tprim(ilon,ilat,ilev,itim) = temp(ilon,ilat,ilev,itim)-Tmean(ilon,ilat,ilev) |
---|
| 379 | else |
---|
| 380 | Tprim(ilon,ilat,ilev,itim) = miss_val |
---|
| 381 | endif |
---|
[888] | 382 | endif !ok_out(4) |
---|
[816] | 383 | enddo |
---|
| 384 | enddo |
---|
| 385 | enddo |
---|
| 386 | enddo ! lonlength |
---|
| 387 | |
---|
| 388 | ! fft intermediates |
---|
| 389 | !------------- |
---|
| 390 | |
---|
| 391 | ! Define the frequencies |
---|
| 392 | do itim=1,M_fft+1 |
---|
| 393 | freq(itim) = (itim-1)/(timelength*(time(2)-time(1))) |
---|
| 394 | enddo |
---|
| 395 | do itim=M_fft+2,timelength |
---|
| 396 | freq(itim) = 0. |
---|
| 397 | enddo |
---|
| 398 | |
---|
| 399 | ! Define the window (triangle) |
---|
| 400 | do itim=1,timelength |
---|
| 401 | ! N window: |
---|
| 402 | ! wndow(itim)= 1. |
---|
| 403 | ! triangulaire de moyenne = 1 |
---|
| 404 | wndow(itim)= 2.*(1. - abs(real(itim-0.5-M_fft)/real(M_fft))) |
---|
| 405 | enddo |
---|
| 406 | |
---|
| 407 | ! Define the filters |
---|
| 408 | |
---|
| 409 | ! IN filter.h : |
---|
| 410 | ! Low cutting frequency, in Hz : fcoup1 |
---|
| 411 | ! High cutting frequency, in Hz : fcoup2 |
---|
| 412 | ! Half-width of the filters, in Hz : width |
---|
| 413 | |
---|
| 414 | !print*,"Low cutting frequency, in Hz ?" |
---|
| 415 | !read(*,*) fcoup1 |
---|
| 416 | !print*,"High cutting frequency, in Hz ?" |
---|
| 417 | !read(*,*) fcoup2 |
---|
| 418 | !print*,"Half-width of the filters, in Hz ?" |
---|
| 419 | !read(*,*) width |
---|
| 420 | !width = 3./time(timelength) |
---|
| 421 | |
---|
| 422 | do itim=1,M_fft+1 |
---|
| 423 | if (freq(itim).lt.(fcoup1-width)) then |
---|
| 424 | filtrelf(itim) = 1. |
---|
| 425 | elseif (freq(itim).gt.(fcoup1+width)) then |
---|
| 426 | filtrelf(itim) = 0. |
---|
| 427 | else |
---|
| 428 | filtrelf(itim) = (1.+sin(pi*(fcoup1-freq(itim))/(2.*width)))/2. |
---|
| 429 | endif |
---|
| 430 | if (freq(itim).lt.(fcoup2-width)) then |
---|
| 431 | filtrehf(itim) = 0. |
---|
| 432 | elseif (freq(itim).gt.(fcoup2+width)) then |
---|
| 433 | filtrehf(itim) = 1. |
---|
| 434 | else |
---|
| 435 | filtrehf(itim) = (1.-sin(pi*(fcoup2-freq(itim))/(2.*width)))/2. |
---|
| 436 | endif |
---|
| 437 | filtrebf(itim) = (1.-filtrelf(itim))*(1.-filtrehf(itim)) |
---|
| 438 | enddo |
---|
| 439 | |
---|
| 440 | |
---|
| 441 | ! fft and filtering |
---|
| 442 | !------------- |
---|
| 443 | |
---|
| 444 | !---FFTW routines |
---|
| 445 | call dfftw_plan_dft_r2c_1d(planf,timelength,var,fftvar,FFTW_MEASURE) |
---|
| 446 | call dfftw_plan_dft_c2r_1d(planb,timelength,fltfft,fltvar,FFTW_MEASURE) |
---|
| 447 | !--- |
---|
| 448 | |
---|
| 449 | do ilon=1,lonlength |
---|
| 450 | do ilat=1,latlength |
---|
| 451 | do ilev=1,altlength |
---|
| 452 | |
---|
| 453 | ! For zonal wind field |
---|
| 454 | if (ok_out(1)) then |
---|
| 455 | |
---|
| 456 | flagfft=.true. |
---|
| 457 | do itim=1,timelength |
---|
| 458 | if (uprim(ilon,ilat,ilev,itim).eq.miss_val) flagfft=.false. |
---|
| 459 | enddo |
---|
| 460 | |
---|
| 461 | if (flagfft) then |
---|
| 462 | |
---|
| 463 | ! 1/ windowing to improve spectral analysis |
---|
| 464 | var(:)=uprim(ilon,ilat,ilev,:)*wndow(:) |
---|
| 465 | ! 2/ FFT computation |
---|
| 466 | !---FFTW routines |
---|
| 467 | call dfftw_execute_dft_r2c(planf,var,fftvar) |
---|
| 468 | !--- |
---|
| 469 | ! 3/ Amplitude of the FFT, for spectral analysis |
---|
| 470 | fftau(ilon,ilat,ilev,1)=abs(fftvar(1))/M_fft |
---|
| 471 | do itim=2,M_fft |
---|
| 472 | fftau(ilon,ilat,ilev,itim) = abs(fftvar(itim))/M_fft |
---|
| 473 | enddo |
---|
| 474 | fftau(ilon,ilat,ilev,M_fft+1)=abs(fftvar(M_fft+1))/M_fft |
---|
| 475 | do itim=M_fft+2,timelength |
---|
| 476 | fftau(ilon,ilat,ilev,itim) = 0. |
---|
| 477 | enddo |
---|
| 478 | |
---|
| 479 | ! 4/ filtering the FFT in three regions |
---|
| 480 | ! filtering + normalisation (low freq) |
---|
| 481 | fltfft(:) = fftvar(:)*filtrelf(:)/timelength |
---|
| 482 | ! 5/ backward FFT for each region |
---|
| 483 | !---FFTW routines |
---|
| 484 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 485 | !--- |
---|
| 486 | ! 6/ reverse the windowing |
---|
| 487 | ulf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 488 | |
---|
| 489 | ! filtering + normalisation (band freq) |
---|
| 490 | fltfft(:) = fftvar(:)*filtrebf(:)/timelength |
---|
| 491 | !---FFTW routines |
---|
| 492 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 493 | !--- |
---|
| 494 | ubf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 495 | |
---|
| 496 | ! filtering + normalisation (high freq) |
---|
| 497 | fltfft(:) = fftvar(:)*filtrehf(:)/timelength |
---|
| 498 | !---FFTW routines |
---|
| 499 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 500 | !--- |
---|
| 501 | uhf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 502 | |
---|
| 503 | else |
---|
| 504 | fftau(ilon,ilat,ilev,itim) = miss_val |
---|
| 505 | ulf(ilon,ilat,ilev,itim) = miss_val |
---|
| 506 | ubf(ilon,ilat,ilev,itim) = miss_val |
---|
| 507 | uhf(ilon,ilat,ilev,itim) = miss_val |
---|
| 508 | endif ! flagfft |
---|
| 509 | |
---|
| 510 | endif !ok_out(1) |
---|
| 511 | |
---|
| 512 | ! For meridional wind wind field |
---|
| 513 | if (ok_out(2)) then |
---|
| 514 | |
---|
| 515 | flagfft=.true. |
---|
| 516 | do itim=1,timelength |
---|
| 517 | if (vprim(ilon,ilat,ilev,itim).eq.miss_val) flagfft=.false. |
---|
| 518 | enddo |
---|
| 519 | |
---|
| 520 | if (flagfft) then |
---|
| 521 | |
---|
| 522 | ! 1/ windowing to improve spectral analysis |
---|
| 523 | var(:)=vprim(ilon,ilat,ilev,:)*wndow(:) |
---|
| 524 | ! 2/ FFT computation |
---|
| 525 | !---FFTW routines |
---|
| 526 | call dfftw_execute_dft_r2c(planf,var,fftvar) |
---|
| 527 | !--- |
---|
| 528 | ! 3/ Amplitude of the FFT, for spectral analysis |
---|
| 529 | fftav(ilon,ilat,ilev,1)=abs(fftvar(1))/M_fft |
---|
| 530 | do itim=2,M_fft |
---|
| 531 | fftav(ilon,ilat,ilev,itim) = abs(fftvar(itim))/M_fft |
---|
| 532 | enddo |
---|
| 533 | fftav(ilon,ilat,ilev,M_fft+1)=abs(fftvar(M_fft+1))/M_fft |
---|
| 534 | do itim=M_fft+2,timelength |
---|
| 535 | fftav(ilon,ilat,ilev,itim) = 0. |
---|
| 536 | enddo |
---|
| 537 | |
---|
| 538 | ! 4/ filtering the FFT in three regions |
---|
| 539 | ! filtering + normalisation (low freq) |
---|
| 540 | fltfft(:) = fftvar(:)*filtrelf(:)/timelength |
---|
| 541 | ! 5/ backward FFT for each region |
---|
| 542 | !---FFTW routines |
---|
| 543 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 544 | !--- |
---|
| 545 | ! 6/ reverse the windowing |
---|
| 546 | vlf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 547 | |
---|
| 548 | ! filtering + normalisation (band freq) |
---|
| 549 | fltfft(:) = fftvar(:)*filtrebf(:)/timelength |
---|
| 550 | !---FFTW routines |
---|
| 551 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 552 | !--- |
---|
| 553 | vbf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 554 | |
---|
| 555 | ! filtering + normalisation (high freq) |
---|
| 556 | fltfft(:) = fftvar(:)*filtrehf(:)/timelength |
---|
| 557 | !---FFTW routines |
---|
| 558 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 559 | !--- |
---|
| 560 | vhf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 561 | |
---|
| 562 | else |
---|
| 563 | fftav(ilon,ilat,ilev,itim) = miss_val |
---|
| 564 | vlf(ilon,ilat,ilev,itim) = miss_val |
---|
| 565 | vbf(ilon,ilat,ilev,itim) = miss_val |
---|
| 566 | vhf(ilon,ilat,ilev,itim) = miss_val |
---|
| 567 | endif ! flagfft |
---|
| 568 | |
---|
| 569 | endif !ok_out(2) |
---|
| 570 | |
---|
| 571 | ! For vertical wind wind field |
---|
| 572 | if (ok_out(3)) then |
---|
| 573 | |
---|
| 574 | flagfft=.true. |
---|
| 575 | do itim=1,timelength |
---|
| 576 | if (wprim(ilon,ilat,ilev,itim).eq.miss_val) flagfft=.false. |
---|
| 577 | enddo |
---|
| 578 | |
---|
| 579 | if (flagfft) then |
---|
| 580 | |
---|
| 581 | ! 1/ windowing to improve spectral analysis |
---|
| 582 | var(:)=wprim(ilon,ilat,ilev,:)*wndow(:) |
---|
| 583 | ! 2/ FFT computation |
---|
| 584 | !---FFTW routines |
---|
| 585 | call dfftw_execute_dft_r2c(planf,var,fftvar) |
---|
| 586 | !--- |
---|
| 587 | ! 3/ Amplitude of the FFT, for spectral analysis |
---|
| 588 | fftaw(ilon,ilat,ilev,1)=abs(fftvar(1))/M_fft |
---|
| 589 | do itim=2,M_fft |
---|
| 590 | fftaw(ilon,ilat,ilev,itim) = abs(fftvar(itim))/M_fft |
---|
| 591 | enddo |
---|
| 592 | fftaw(ilon,ilat,ilev,M_fft+1)=abs(fftvar(M_fft+1))/M_fft |
---|
| 593 | do itim=M_fft+2,timelength |
---|
| 594 | fftaw(ilon,ilat,ilev,itim) = 0. |
---|
| 595 | enddo |
---|
| 596 | |
---|
| 597 | ! 4/ filtering the FFT in three regions |
---|
| 598 | ! filtering + normalisation (low freq) |
---|
| 599 | fltfft(:) = fftvar(:)*filtrelf(:)/timelength |
---|
| 600 | ! 5/ backward FFT for each region |
---|
| 601 | !---FFTW routines |
---|
| 602 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 603 | !--- |
---|
| 604 | ! 6/ reverse the windowing |
---|
| 605 | wlf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 606 | |
---|
| 607 | ! filtering + normalisation (band freq) |
---|
| 608 | fltfft(:) = fftvar(:)*filtrebf(:)/timelength |
---|
| 609 | !---FFTW routines |
---|
| 610 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 611 | !--- |
---|
| 612 | wbf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 613 | |
---|
| 614 | ! filtering + normalisation (high freq) |
---|
| 615 | fltfft(:) = fftvar(:)*filtrehf(:)/timelength |
---|
| 616 | !---FFTW routines |
---|
| 617 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 618 | !--- |
---|
| 619 | whf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 620 | |
---|
| 621 | else |
---|
| 622 | fftaw(ilon,ilat,ilev,itim) = miss_val |
---|
| 623 | wlf(ilon,ilat,ilev,itim) = miss_val |
---|
| 624 | wbf(ilon,ilat,ilev,itim) = miss_val |
---|
| 625 | whf(ilon,ilat,ilev,itim) = miss_val |
---|
| 626 | endif ! flagfft |
---|
| 627 | |
---|
| 628 | endif !ok_out(3) |
---|
| 629 | |
---|
| 630 | ! For temperature field |
---|
| 631 | if (ok_out(4)) then |
---|
| 632 | |
---|
| 633 | flagfft=.true. |
---|
| 634 | do itim=1,timelength |
---|
| 635 | if (Tprim(ilon,ilat,ilev,itim).eq.miss_val) flagfft=.false. |
---|
| 636 | enddo |
---|
| 637 | |
---|
| 638 | if (flagfft) then |
---|
| 639 | |
---|
| 640 | ! 1/ windowing to improve spectral analysis |
---|
| 641 | var(:)=Tprim(ilon,ilat,ilev,:)*wndow(:) |
---|
| 642 | ! 2/ FFT computation |
---|
| 643 | !---FFTW routines |
---|
| 644 | call dfftw_execute_dft_r2c(planf,var,fftvar) |
---|
| 645 | !--- |
---|
| 646 | ! 3/ Amplitude of the FFT, for spectral analysis |
---|
| 647 | fftaT(ilon,ilat,ilev,1)=abs(fftvar(1))/M_fft |
---|
| 648 | do itim=2,M_fft |
---|
| 649 | fftaT(ilon,ilat,ilev,itim) = abs(fftvar(itim))/M_fft |
---|
| 650 | enddo |
---|
| 651 | fftaT(ilon,ilat,ilev,M_fft+1)=abs(fftvar(M_fft+1))/M_fft |
---|
| 652 | do itim=M_fft+2,timelength |
---|
| 653 | fftaT(ilon,ilat,ilev,itim) = 0. |
---|
| 654 | enddo |
---|
| 655 | |
---|
| 656 | ! 4/ filtering the FFT in three regions |
---|
| 657 | ! filtering + normalisation (low freq) |
---|
| 658 | fltfft(:) = fftvar(:)*filtrelf(:)/timelength |
---|
| 659 | ! 5/ backward FFT for each region |
---|
| 660 | !---FFTW routines |
---|
| 661 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 662 | !--- |
---|
| 663 | ! 6/ reverse the windowing |
---|
| 664 | Tlf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 665 | |
---|
| 666 | ! filtering + normalisation (band freq) |
---|
| 667 | fltfft(:) = fftvar(:)*filtrebf(:)/timelength |
---|
| 668 | !---FFTW routines |
---|
| 669 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 670 | !--- |
---|
| 671 | Tbf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 672 | |
---|
| 673 | ! filtering + normalisation (high freq) |
---|
| 674 | fltfft(:) = fftvar(:)*filtrehf(:)/timelength |
---|
| 675 | !---FFTW routines |
---|
| 676 | call dfftw_execute_dft_c2r(planb,fltfft,fltvar) |
---|
| 677 | !--- |
---|
| 678 | Thf(ilon,ilat,ilev,:) = fltvar(:)/wndow(:) |
---|
| 679 | |
---|
| 680 | else |
---|
| 681 | fftaT(ilon,ilat,ilev,itim) = miss_val |
---|
| 682 | Tlf(ilon,ilat,ilev,itim) = miss_val |
---|
| 683 | Tbf(ilon,ilat,ilev,itim) = miss_val |
---|
| 684 | Thf(ilon,ilat,ilev,itim) = miss_val |
---|
| 685 | endif ! flagfft |
---|
| 686 | |
---|
| 687 | endif !ok_out(4) |
---|
| 688 | |
---|
| 689 | enddo |
---|
| 690 | enddo |
---|
| 691 | enddo ! lonlength |
---|
| 692 | |
---|
| 693 | !---FFTW routines |
---|
| 694 | call dfftw_destroy_plan(planf) |
---|
| 695 | call dfftw_destroy_plan(planb) |
---|
| 696 | !--- |
---|
| 697 | |
---|
| 698 | print*,"End of computations" |
---|
| 699 | |
---|
| 700 | !=============================================================================== |
---|
| 701 | ! 3. Create output files |
---|
| 702 | !=============================================================================== |
---|
| 703 | |
---|
| 704 | ! Create output files |
---|
| 705 | if (ok_out(1)) then |
---|
| 706 | ierr=NF_CREATE(outfile1,NF_CLOBBER,outfid1) |
---|
| 707 | if (ierr.ne.NF_NOERR) then |
---|
| 708 | write(*,*)"Error: could not create file ",outfile1 |
---|
| 709 | stop |
---|
| 710 | endif |
---|
| 711 | endif !ok_out(1) |
---|
| 712 | |
---|
| 713 | if (ok_out(2)) then |
---|
| 714 | ierr=NF_CREATE(outfile2,NF_CLOBBER,outfid2) |
---|
| 715 | if (ierr.ne.NF_NOERR) then |
---|
| 716 | write(*,*)"Error: could not create file ",outfile2 |
---|
| 717 | stop |
---|
| 718 | endif |
---|
| 719 | endif !ok_out(2) |
---|
| 720 | |
---|
| 721 | if (ok_out(3)) then |
---|
| 722 | ierr=NF_CREATE(outfile3,NF_CLOBBER,outfid3) |
---|
| 723 | if (ierr.ne.NF_NOERR) then |
---|
| 724 | write(*,*)"Error: could not create file ",outfile3 |
---|
| 725 | stop |
---|
| 726 | endif |
---|
| 727 | endif !ok_out(3) |
---|
| 728 | |
---|
| 729 | if (ok_out(4)) then |
---|
| 730 | ierr=NF_CREATE(outfile4,NF_CLOBBER,outfid4) |
---|
| 731 | if (ierr.ne.NF_NOERR) then |
---|
| 732 | write(*,*)"Error: could not create file ",outfile4 |
---|
| 733 | stop |
---|
| 734 | endif |
---|
| 735 | endif !ok_out(4) |
---|
| 736 | |
---|
| 737 | !=============================================================================== |
---|
| 738 | ! 3.1. Define and write dimensions |
---|
| 739 | !=============================================================================== |
---|
| 740 | |
---|
| 741 | if (ok_out(1)) & |
---|
| 742 | call write_dim(outfid1,lonlength,latlength,altlength,timelength, & |
---|
| 743 | lon,lat,plev,time,lon_dimid1,lat_dimid1,alt_dimid1,time_dimid1) |
---|
| 744 | if (ok_out(2)) & |
---|
| 745 | call write_dim(outfid2,lonlength,latlength,altlength,timelength, & |
---|
| 746 | lon,lat,plev,time,lon_dimid2,lat_dimid2,alt_dimid2,time_dimid2) |
---|
| 747 | if (ok_out(3)) & |
---|
| 748 | call write_dim(outfid3,lonlength,latlength,altlength,timelength, & |
---|
| 749 | lon,lat,plev,time,lon_dimid3,lat_dimid3,alt_dimid3,time_dimid3) |
---|
| 750 | if (ok_out(4)) & |
---|
| 751 | call write_dim(outfid4,lonlength,latlength,altlength,timelength, & |
---|
| 752 | lon,lat,plev,time,lon_dimid4,lat_dimid4,alt_dimid4,time_dimid4) |
---|
| 753 | |
---|
| 754 | !=============================================================================== |
---|
| 755 | ! 3.2. Define and write variables |
---|
| 756 | !=============================================================================== |
---|
| 757 | |
---|
| 758 | if (ok_out(1)) then |
---|
| 759 | |
---|
| 760 | datashape4d(1)=lon_dimid1 |
---|
| 761 | datashape4d(2)=lat_dimid1 |
---|
| 762 | datashape4d(3)=alt_dimid1 |
---|
| 763 | datashape4d(4)=time_dimid1 |
---|
| 764 | datashape1d =time_dimid1 |
---|
| 765 | |
---|
| 766 | call write_var1d(outfid1,datashape1d,timelength,& |
---|
| 767 | "freq ", "FFT frequencies ","s-1 ",miss_val,& |
---|
| 768 | freq ) |
---|
| 769 | |
---|
| 770 | call write_var4d(outfid1,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 771 | "fftau ", "FFT ampl of vitu ","m s-1 ",miss_val,& |
---|
| 772 | fftau ) |
---|
| 773 | |
---|
| 774 | call write_var4d(outfid1,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 775 | "ulf ", "low freq part vitu ","m s-1 ",miss_val,& |
---|
| 776 | ulf ) |
---|
| 777 | |
---|
| 778 | call write_var4d(outfid1,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 779 | "ubf ", "band freq part vitu ","m s-1 ",miss_val,& |
---|
| 780 | ubf ) |
---|
| 781 | |
---|
| 782 | call write_var4d(outfid1,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 783 | "uhf ", "high freq part vitu ","m s-1 ",miss_val,& |
---|
| 784 | uhf ) |
---|
| 785 | endif !ok_out(1) |
---|
| 786 | |
---|
| 787 | if (ok_out(2)) then |
---|
| 788 | |
---|
| 789 | datashape4d(1)=lon_dimid2 |
---|
| 790 | datashape4d(2)=lat_dimid2 |
---|
| 791 | datashape4d(3)=alt_dimid2 |
---|
| 792 | datashape4d(4)=time_dimid2 |
---|
| 793 | datashape1d =time_dimid2 |
---|
| 794 | |
---|
[888] | 795 | call write_var1d(outfid2,datashape1d,timelength,& |
---|
| 796 | "freq ", "FFT frequencies ","s-1 ",miss_val,& |
---|
| 797 | freq ) |
---|
| 798 | |
---|
[816] | 799 | call write_var4d(outfid2,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 800 | "fftav ", "FFT ampl of vitv ","m s-1 ",miss_val,& |
---|
| 801 | fftav ) |
---|
| 802 | |
---|
| 803 | call write_var4d(outfid2,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 804 | "vlf ", "low freq part vitv ","m s-1 ",miss_val,& |
---|
| 805 | vlf ) |
---|
| 806 | |
---|
| 807 | call write_var4d(outfid2,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 808 | "vbf ", "band freq part vitv ","m s-1 ",miss_val,& |
---|
| 809 | vbf ) |
---|
| 810 | |
---|
| 811 | call write_var4d(outfid2,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 812 | "vhf ", "high freq part vitv ","m s-1 ",miss_val,& |
---|
| 813 | vhf ) |
---|
| 814 | endif !ok_out(2) |
---|
| 815 | |
---|
| 816 | if (ok_out(3)) then |
---|
| 817 | |
---|
| 818 | datashape4d(1)=lon_dimid3 |
---|
| 819 | datashape4d(2)=lat_dimid3 |
---|
| 820 | datashape4d(3)=alt_dimid3 |
---|
| 821 | datashape4d(4)=time_dimid3 |
---|
| 822 | datashape1d =time_dimid3 |
---|
| 823 | |
---|
[888] | 824 | call write_var1d(outfid3,datashape1d,timelength,& |
---|
| 825 | "freq ", "FFT frequencies ","s-1 ",miss_val,& |
---|
| 826 | freq ) |
---|
| 827 | |
---|
[816] | 828 | call write_var4d(outfid3,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 829 | "fftaw ", "FFT ampl of vitw ","Pa s-1 ",miss_val,& |
---|
| 830 | fftaw ) |
---|
| 831 | |
---|
| 832 | call write_var4d(outfid3,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 833 | "wlf ", "low freq part vitw ","Pa s-1 ",miss_val,& |
---|
| 834 | wlf ) |
---|
| 835 | |
---|
| 836 | call write_var4d(outfid3,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 837 | "wbf ", "band freq part vitw ","Pa s-1 ",miss_val,& |
---|
| 838 | wbf ) |
---|
| 839 | |
---|
| 840 | call write_var4d(outfid3,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 841 | "whf ", "high freq part vitw ","Pa s-1 ",miss_val,& |
---|
| 842 | whf ) |
---|
| 843 | endif !ok_out(3) |
---|
| 844 | |
---|
| 845 | if (ok_out(4)) then |
---|
| 846 | |
---|
| 847 | datashape4d(1)=lon_dimid4 |
---|
| 848 | datashape4d(2)=lat_dimid4 |
---|
| 849 | datashape4d(3)=alt_dimid4 |
---|
| 850 | datashape4d(4)=time_dimid4 |
---|
| 851 | datashape1d =time_dimid4 |
---|
| 852 | |
---|
[888] | 853 | call write_var1d(outfid4,datashape1d,timelength,& |
---|
| 854 | "freq ", "FFT frequencies ","s-1 ",miss_val,& |
---|
| 855 | freq ) |
---|
| 856 | |
---|
[816] | 857 | call write_var4d(outfid4,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 858 | "fftaT ", "FFT ampl of temp ","K ",miss_val,& |
---|
| 859 | fftaT ) |
---|
| 860 | |
---|
| 861 | call write_var4d(outfid4,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 862 | "tlf ", "low freq part temp ","K ",miss_val,& |
---|
| 863 | Tlf ) |
---|
| 864 | |
---|
| 865 | call write_var4d(outfid4,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 866 | "tbf ", "band freq part temp ","K ",miss_val,& |
---|
| 867 | Tbf ) |
---|
| 868 | |
---|
| 869 | call write_var4d(outfid4,datashape4d,lonlength,latlength,altlength,timelength,& |
---|
| 870 | "thf ", "high freq part temp ","K ",miss_val,& |
---|
| 871 | Thf ) |
---|
| 872 | endif !ok_out(4) |
---|
| 873 | |
---|
| 874 | !!!! Close output files |
---|
| 875 | if (ok_out(1)) then |
---|
| 876 | ierr=NF_CLOSE(outfid1) |
---|
| 877 | if (ierr.ne.NF_NOERR) write(*,*) 'Error, failed to close output file ',outfile1 |
---|
| 878 | endif !ok_out(1) |
---|
| 879 | |
---|
| 880 | if (ok_out(2)) then |
---|
| 881 | ierr=NF_CLOSE(outfid2) |
---|
| 882 | if (ierr.ne.NF_NOERR) write(*,*) 'Error, failed to close output file ',outfile2 |
---|
| 883 | endif !ok_out(2) |
---|
| 884 | |
---|
| 885 | if (ok_out(3)) then |
---|
| 886 | ierr=NF_CLOSE(outfid3) |
---|
| 887 | if (ierr.ne.NF_NOERR) write(*,*) 'Error, failed to close output file ',outfile3 |
---|
| 888 | endif !ok_out(3) |
---|
| 889 | |
---|
| 890 | if (ok_out(4)) then |
---|
| 891 | ierr=NF_CLOSE(outfid4) |
---|
| 892 | if (ierr.ne.NF_NOERR) write(*,*) 'Error, failed to close output file ',outfile4 |
---|
| 893 | endif !ok_out(4) |
---|
| 894 | |
---|
| 895 | |
---|
| 896 | end program |
---|