-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathharmonic_analysis.f90
61 lines (43 loc) · 1.58 KB
/
harmonic_analysis.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
program harmonic_analysis
use netcdf
use param
implicit none
!$OMP PARALLEL DO
do i = 1,nt
time(:,:,i) = (i-1)*2*pi/365.25
end do
!$OMP END PARALLEL DO
counting = (/nx,ny,1,nt/)
retval = nf90_open(file_in, NF90_NOWRITE, ncid)
retval = nf90_inq_varid(ncid, t_NAME, tvarid)
retval = nf90_inq_varid(ncid, x_NAME, xvarid)
retval = nf90_inq_varid(ncid, y_NAME, yvarid)
retval = nf90_inq_varid(ncid, z_NAME, zvarid)
retval = nf90_get_var(ncid, tvarid, T)
retval = nf90_get_var(ncid, xvarid, X)
retval = nf90_get_var(ncid, yvarid, Y)
retval = nf90_get_var(ncid, zvarid, Z)
retval = nf90_close(ncid)
print*,X
!$OMP PARALLEL DO
do k = 1,nz
start = (/1,1,k,1/)
allocate(temp(nx,ny,nt))
retval = nf90_open(file_in, NF90_NOWRITE, ncid)
retval = nf90_inq_varid(ncid, temp_NAME, tempvarid)
retval = nf90_get_var(ncid,tempvarid,temp,start,counting)
retval = nf90_close(ncid)
where(temp.ne.missing_val)
temp = temp*sf_thetao+af_thetao
end where
call harmonic_regression(nx,ny,nt,time,temp,amp_temp(:,:,k,:), &
& pha_temp(:,:,k,:),missing_val)
mean_temp(:,:,k) = sum(temp,3)/nt
deallocate(temp)
end do
!$OMP END PARALLEL DO
where(mean_temp.le.missing_val)
mean_temp = missing_val
end where
call write_harmonic_output(nx,ny,nz,X,Y,Z,missing_val,amp_temp,pha_temp,mean_temp)
end program