-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadAtmosphere.f90
More file actions
71 lines (48 loc) · 1.76 KB
/
readAtmosphere.f90
File metadata and controls
71 lines (48 loc) · 1.76 KB
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
62
63
64
65
66
67
68
69
70
71
! --------------------------------- read ocean T S RHO etc ------------
subroutine readAtmosphere
use ptmModule
use netcdf
use utilities
implicit none
character*255 :: filename
real, allocatable :: tmpu(:,:,:),tmpv(:,:,:)
! integer :: nlon, nlat, nLevels
integer :: file_id,u_id,v_id ! variable dimensions
integer :: i,j,t, hour
real :: missValnum
integer :: status, hour_t
character*10 ::missVal
allocate(air%U(ncgrid%nLon,ncgrid%nLat,setup%numHoursOfTracking))
allocate(air%V(ncgrid%nLon,ncgrid%nLat,setup%numHoursOfTracking))
allocate(tmpu(ncgrid%nLon,ncgrid%nLat,setup%modelRuntimeInHours))
allocate(tmpv(ncgrid%nLon,ncgrid%nLat,setup%modelRuntimeInHours))
! set correct indexes for reading variables
hour_t = 0
do i = 1,setup%numOfExistingFiles
filename=setup%existingAtmFiles(i)
print *,"READING ATMOSPHERE STATE FROM: ",trim(adjustl(filename))
call handle_err(NF90_OPEN(trim(adjustl(filename)), NF90_NOWRITE, file_id))
call handle_err(NF90_INQ_VARID(file_id, 'uair', u_id))
call handle_err(NF90_INQ_VARID(file_id, 'vair', v_id))
! reading winds:
call handle_err(NF90_GET_VAR(file_id, u_id, tmpu))
call handle_err(NF90_GET_VAR(file_id, v_id, tmpv))
call handle_err(NF90_GET_ATT(file_id, u_id, "missing_value", missVal))
call rstr2num(missVal,missValnum)
if (.not. setup%performBacktracking) then
do t = setup%hourReadStart(i),setup%hourReadEnd(i)
hour_t=hour_t+1
air%U(:,:,hour_t)=tmpu(:,:,t)
air%V(:,:,hour_t)=tmpv(:,:,t)
enddo
else
do t = setup%hourReadEnd(i),setup%hourReadStart(i),-1
hour_t=hour_t+1
air%U(:,:,hour_t)=tmpu(:,:,t)
air%V(:,:,hour_t)=tmpv(:,:,t)
enddo
endif
! close file
call handle_err(NF90_CLOSE(file_id))
enddo
end subroutine readAtmosphere