-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathhimawari_readheader.f90
257 lines (211 loc) · 7.54 KB
/
himawari_readheader.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
!******************************************************************************%
! *
! * Copyright (C) 2016-2019 Simon Proud <[email protected]>
! * License: CC BY-NC-ND 4.0
! *
! ******************************************************************************/
!*******************************************************************************
! Module containing the Fortran interface to himawari_native_util. Please see
! the comments in the C code for descriptions of the various routines including
! their arguments and return values.
!*******************************************************************************
module himawari_readheader
use himawari
use himawari_headerinfo
use iso_c_binding
implicit none
private
public :: AHI_readhdr_IR, &
AHI_readhdr_VIS
contains
integer function AHI_readhdr_IR(filelun,ahi_hdr,verbose)result(status)
type(himawari_t_IR_Header),intent(inout) :: ahi_hdr
integer,intent(in) :: filelun
logical, intent(in) :: verbose
integer :: retval, fpos, i
type(himawari_t_Basic_Info) :: him_basic
type(himawari_t_Data_Info) :: him_data
type(himawari_t_Proj_Info) :: him_proj
type(himawari_t_Navi_Info) :: him_nav
type(himawari_t_Calib_Info) :: him_calib
type(himawari_t_IR_Calib_Info) :: him_chan_calib
type(himawari_t_InterCalib_Info):: him_interCalib
type(himawari_t_Segm_Info) :: him_seg
type(himawari_t_NaviCorr_Info) :: him_navcorr
type(himawari_t_ObsTime_Info) :: him_obstime
type(himawari_t_Error_Info) :: him_error
type(himawari_t_Spare) :: him_spare
type(himawari_t_Correct_Table) :: him_correct_table
fpos = 0
call fseek(filelun,fpos,0,retval)
read(filelun)him_basic
fpos = fpos + him_basic%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_data
fpos = fpos + him_data%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_proj
fpos = fpos + him_proj%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_nav
fpos = fpos + him_nav%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_calib
read(filelun)him_chan_calib
fpos = fpos + him_calib%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_interCalib
fpos = fpos + him_interCalib%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_seg
fpos = fpos + him_seg%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_navcorr%HeaderNum
read(filelun)him_navcorr%BlockLen
read(filelun)him_navcorr%RoCenterColumn
read(filelun)him_navcorr%RoCenterLine
read(filelun)him_navcorr%RoCorrection
read(filelun)him_navcorr%correctNum
allocate(him_navcorr%lineNo(him_navcorr%correctNum))
allocate(him_navcorr%columnShift(him_navcorr%correctNum))
allocate(him_navcorr%lineShift(him_navcorr%correctNum))
do i = 1, him_navcorr%correctNum
read(filelun)him_navcorr%lineNo(i)
read(filelun)him_navcorr%columnShift(i)
read(filelun)him_navcorr%lineShift(i)
end do
fpos = fpos + him_navcorr%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_obstime%HeaderNum
read(filelun)him_obstime%BlockLen
read(filelun)him_obstime%obsNum
allocate(him_obstime%lineNo(him_obstime%obsNum))
allocate(him_obstime%obsMJD(him_obstime%obsNum))
do i = 1, him_obstime%obsNum
read(filelun)him_obstime%lineNo(i)
read(filelun)him_obstime%obsMJD(i)
end do
fpos = fpos + him_obstime%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_error%HeaderNum
read(filelun)him_error%BlockLen
read(filelun)him_error%errorNum
allocate(him_error%lineNo(him_error%errorNum))
allocate(him_error%errPixNum(him_error%errorNum))
do i = 1, him_error%errorNum
read(filelun)him_error%lineNo(i)
read(filelun)him_error%errPixNum(i)
end do
fpos = fpos + him_error%BlockLen
call fseek(filelun,fpos,0,retval)
call fseek(filelun,him_basic%totalHeaderLen,0,retval)
ahi_hdr%him_basic = him_basic
ahi_hdr%him_data = him_data
ahi_hdr%him_proj = him_proj
ahi_hdr%him_nav = him_nav
ahi_hdr%him_calib = him_calib
ahi_hdr%him_chan_calib = him_chan_calib
ahi_hdr%him_interCalib = him_interCalib
ahi_hdr%him_seg = him_seg
ahi_hdr%him_navcorr = him_navcorr
ahi_hdr%him_obstime = him_obstime
ahi_hdr%him_error = him_error
status = HIMAWARI_SUCCESS
return
end function AHI_readhdr_IR
integer function AHI_readhdr_VIS(filelun,ahi_hdr,verbose)result(status)
type(himawari_t_VIS_Header),intent(inout) :: ahi_hdr
integer,intent(in) :: filelun
logical, intent(in) :: verbose
integer :: retval, fpos, i
type(himawari_t_Basic_Info) :: him_basic
type(himawari_t_Data_Info) :: him_data
type(himawari_t_Proj_Info) :: him_proj
type(himawari_t_Navi_Info) :: him_nav
type(himawari_t_Calib_Info) :: him_calib
type(himawari_t_VIS_Calib_Info) :: him_chan_calib
type(himawari_t_InterCalib_Info) :: him_interCalib
type(himawari_t_Segm_Info) :: him_seg
type(himawari_t_NaviCorr_Info) :: him_navcorr
type(himawari_t_ObsTime_Info) :: him_obstime
type(himawari_t_Error_Info) :: him_error
type(himawari_t_Spare) :: him_spare
type(himawari_t_Correct_Table) :: him_correct_table
fpos = 0
call fseek(filelun,0,0,retval)
read(filelun)him_basic
fpos = fpos + him_basic%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_data
fpos = fpos + him_data%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_proj
fpos = fpos + him_proj%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_nav
fpos = fpos + him_nav%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_calib
read(filelun)him_chan_calib
fpos = fpos + him_calib%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_interCalib
fpos = fpos + him_interCalib%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_seg
fpos = fpos + him_seg%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_navcorr%HeaderNum
read(filelun)him_navcorr%BlockLen
read(filelun)him_navcorr%RoCenterColumn
read(filelun)him_navcorr%RoCenterLine
read(filelun)him_navcorr%RoCorrection
read(filelun)him_navcorr%correctNum
allocate(him_navcorr%lineNo(him_navcorr%correctNum))
allocate(him_navcorr%columnShift(him_navcorr%correctNum))
allocate(him_navcorr%lineShift(him_navcorr%correctNum))
do i = 1, him_navcorr%correctNum
read(filelun)him_navcorr%lineNo(i)
read(filelun)him_navcorr%columnShift(i)
read(filelun)him_navcorr%lineShift(i)
end do
fpos = fpos + him_navcorr%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_obstime%HeaderNum
read(filelun)him_obstime%BlockLen
read(filelun)him_obstime%obsNum
allocate(him_obstime%lineNo(him_obstime%obsNum))
allocate(him_obstime%obsMJD(him_obstime%obsNum))
do i = 1, him_obstime%obsNum
read(filelun)him_obstime%lineNo(i)
read(filelun)him_obstime%obsMJD(i)
end do
fpos = fpos + him_obstime%BlockLen
call fseek(filelun,fpos,0,retval)
read(filelun)him_error%HeaderNum
read(filelun)him_error%BlockLen
read(filelun)him_error%errorNum
allocate(him_error%lineNo(him_error%errorNum))
allocate(him_error%errPixNum(him_error%errorNum))
do i = 1, him_error%errorNum
read(filelun)him_error%lineNo(i)
read(filelun)him_error%errPixNum(i)
end do
fpos = fpos + him_error%BlockLen
call fseek(filelun,fpos,0,retval)
call fseek(filelun,him_basic%totalHeaderLen,0,retval)
ahi_hdr%him_basic = him_basic
ahi_hdr%him_data = him_data
ahi_hdr%him_proj = him_proj
ahi_hdr%him_nav = him_nav
ahi_hdr%him_calib = him_calib
ahi_hdr%him_chan_calib = him_chan_calib
ahi_hdr%him_interCalib = him_interCalib
ahi_hdr%him_seg = him_seg
ahi_hdr%him_navcorr = him_navcorr
ahi_hdr%him_obstime = him_obstime
ahi_hdr%him_error = him_error
status = HIMAWARI_SUCCESS
return
end function AHI_readhdr_VIS
end module himawari_readheader