1 | PROGRAM treat_files_list |
---|
2 | |
---|
3 | USE fonctions_mod |
---|
4 | USE grid_ames_mod |
---|
5 | USE head_ames_mod |
---|
6 | USE struct_ames_mod |
---|
7 | USE lidar_mod |
---|
8 | |
---|
9 | IMPLICIT NONE |
---|
10 | |
---|
11 | CHARACTER(LEN=300) :: temp_string, temp_string2 |
---|
12 | CHARACTER(LEN=80) :: temp_string80 |
---|
13 | CHARACTER(LEN=250) :: filein,list_files,tmp_list |
---|
14 | CHARACTER(LEN=100) :: cmoismin,cmoismax,cheuremin,cheuremax ,temp_string3 |
---|
15 | CHARACTER(LEN=100) :: rep_data,rep_so,chaine,chaine2,rep_lo,file_lo |
---|
16 | CHARACTER(LEN=50) :: link |
---|
17 | CHARACTER(LEN=8) :: tdate |
---|
18 | CHARACTER(LEN=7) :: col1, col2, col5, col6 |
---|
19 | CHARACTER(LEN=3) :: col4,mois,annee |
---|
20 | CHARACTER(LEN=6) :: col3 |
---|
21 | CHARACTER(LEN=10) :: ttime |
---|
22 | CHARACTER(LEN=5) :: tzone |
---|
23 | INTEGER, DIMENSION(8) :: tvalues |
---|
24 | CHARACTER(LEN=200) :: screen,line,line2 |
---|
25 | INTEGER :: i,j,indice,idatemesure,idatemesuremax,idatemesuremin,nblcomment |
---|
26 | INTEGER :: unit,ios,ios2,iosres,debug,nbfile,ios3,lecture,ulog,nbfiles,ifile,temp_int,nbbc |
---|
27 | type(grid_ames) :: sortie_asc,temp_ames |
---|
28 | type(struct_ames) :: sortie_ames |
---|
29 | LOGICAL :: retour |
---|
30 | REAL :: temp_real |
---|
31 | |
---|
32 | COMMON screen,rep_so,debug |
---|
33 | COMMON rep_lo,file_lo,ulog |
---|
34 | |
---|
35 | !lecture du fichier temporaire devant contenir la liste des fichiers de donnees a traiter |
---|
36 | call getarg(1,tmp_list) |
---|
37 | nbfiles=0 |
---|
38 | debug=1 |
---|
39 | ifile=0 |
---|
40 | |
---|
41 | !ouverture liste des fichiers asc a traiter |
---|
42 | OPEN( UNIT=2, & |
---|
43 | FILE=tmp_list, & |
---|
44 | FORM="formatted", & |
---|
45 | ACCESS="sequential", & |
---|
46 | STATUS="old", & |
---|
47 | ACTION="read", & |
---|
48 | POSITION="rewind", & |
---|
49 | IOSTAT=ios3 ) |
---|
50 | |
---|
51 | |
---|
52 | READ(2,IOSTAT=ios3, FMT='(A)') filein |
---|
53 | |
---|
54 | if (ios3 /= 0 ) then |
---|
55 | screen="Impossible d ouvrir le fichier temporaire des fichiers de donnees a traiter : "//adjustl(trim(filein)) |
---|
56 | retour=printl() |
---|
57 | STOP |
---|
58 | endif |
---|
59 | |
---|
60 | rep_data=filein |
---|
61 | screen="DATA DIRECTORY : "//rep_data |
---|
62 | retour=printl() |
---|
63 | |
---|
64 | mois="" |
---|
65 | annee="" |
---|
66 | |
---|
67 | READ(2,IOSTAT=ios3, FMT='(I)') nbfiles |
---|
68 | READ(2,IOSTAT=ios3,FMT='(I)') debug |
---|
69 | READ(2,IOSTAT=ios3,FMT=*) mois |
---|
70 | READ(2,IOSTAT=ios3,FMT=*) annee |
---|
71 | |
---|
72 | !definition de l'entete |
---|
73 | OPEN( UNIT=1, & |
---|
74 | FILE=trim(adjustl(rep_data))//"./conf.txt", & |
---|
75 | FORM="formatted", & |
---|
76 | ACCESS="sequential", & |
---|
77 | STATUS="old", & |
---|
78 | ACTION="read", & |
---|
79 | POSITION="rewind", & |
---|
80 | IOSTAT=ios2 ) |
---|
81 | |
---|
82 | READ(1,IOSTAT=ios, FMT='(A)') line |
---|
83 | |
---|
84 | IF (ios /= 0 ) THEN |
---|
85 | screen="! Impossible d ouvrir le fichier de configuration" |
---|
86 | retour=printl() |
---|
87 | STOP |
---|
88 | ENDIF |
---|
89 | |
---|
90 | DO WHILE ( ios == 0) |
---|
91 | |
---|
92 | IF (index(line,"station")>0) THEN |
---|
93 | sortie_ames%head%station=line(9:) |
---|
94 | ENDIF |
---|
95 | IF (index(line,"instrument=")>0) THEN |
---|
96 | sortie_ames%head%instrument=line(12:) |
---|
97 | ENDIF |
---|
98 | IF (index(line,"instrument2")>0) THEN |
---|
99 | sortie_ames%head%instrument2=line(13:) |
---|
100 | ENDIF |
---|
101 | IF (index(line,"pi=")>0) THEN |
---|
102 | sortie_ames%head%pi=line(4:) |
---|
103 | ENDIF |
---|
104 | IF (index(line,"pi2")>0) THEN |
---|
105 | sortie_ames%head%pi2=line(5:) |
---|
106 | ENDIF |
---|
107 | IF (index(line,"lab")>0) THEN |
---|
108 | sortie_ames%head%lab=line(5:) |
---|
109 | ENDIF |
---|
110 | IF (index(line,"specie")>0) THEN |
---|
111 | sortie_ames%head%specie=line(8:) |
---|
112 | ENDIF |
---|
113 | IF (index(line,"altitude")>0) THEN |
---|
114 | sortie_ames%head%altitude=line(10:) |
---|
115 | ENDIF |
---|
116 | IF (index(line,"latitude")>0) THEN |
---|
117 | sortie_ames%head%latitude=line(10:) |
---|
118 | ENDIF |
---|
119 | IF (index(line,"longitude")>0) THEN |
---|
120 | sortie_ames%head%longitude=line(11:) |
---|
121 | ENDIF |
---|
122 | |
---|
123 | |
---|
124 | READ(1,IOSTAT=ios, FMT='(A)') line |
---|
125 | END DO |
---|
126 | |
---|
127 | CLOSE(unit=1) |
---|
128 | |
---|
129 | |
---|
130 | !creation du fichier de sortie ames |
---|
131 | OPEN( UNIT=14, & |
---|
132 | FILE="rete"//trim(adjustl(annee))//trim(adjustl(mois))//".kel", & |
---|
133 | FORM="formatted", & |
---|
134 | ACCESS="sequential", & |
---|
135 | STATUS="unknown", & |
---|
136 | ACTION="readwrite", & |
---|
137 | POSITION="rewind", & |
---|
138 | IOSTAT=iosres ) |
---|
139 | |
---|
140 | if (iosres /= 0 ) then |
---|
141 | screen="Impossible de creer le fichier des grilles" |
---|
142 | retour=printl() |
---|
143 | STOP |
---|
144 | endif |
---|
145 | |
---|
146 | |
---|
147 | nbbc=0 |
---|
148 | |
---|
149 | READ(2,IOSTAT=ios3, FMT='(A)') filein |
---|
150 | |
---|
151 | ALLOCATE(sortie_ames%grids_ames(nbfiles)) |
---|
152 | |
---|
153 | DO WHILE ( ios3 == 0 ) |
---|
154 | |
---|
155 | filein=trim(adjustl(filein)) |
---|
156 | screen="current file data="//filein |
---|
157 | retour=printl() |
---|
158 | |
---|
159 | OPEN( UNIT=1, & |
---|
160 | FILE=filein, & |
---|
161 | FORM="formatted", & |
---|
162 | ACCESS="sequential", & |
---|
163 | STATUS="old", & |
---|
164 | ACTION="read", & |
---|
165 | POSITION="rewind", & |
---|
166 | IOSTAT=ios ) |
---|
167 | |
---|
168 | if (ios /= 0 ) then |
---|
169 | screen="Impossible d ouvrir le fichier "//trim(adjustl(filein)) |
---|
170 | retour=printl() |
---|
171 | STOP |
---|
172 | endif |
---|
173 | ifile=ifile+1 |
---|
174 | |
---|
175 | screen="-> Reading file : "//adjustl(trim(filein)) |
---|
176 | retour=printl() |
---|
177 | |
---|
178 | !lecture des donnees et formatage des grilles |
---|
179 | sortie_asc=lidar(filein,rep_data) |
---|
180 | indice=size(sortie_asc%tabMesures(:,1)) |
---|
181 | |
---|
182 | ALLOCATE(sortie_ames%grids_ames(ifile)%tabMesures(indice,6)) |
---|
183 | |
---|
184 | DO i=1,indice |
---|
185 | |
---|
186 | temp_int=sortie_asc%tabMesures(i,1) |
---|
187 | sortie_ames%grids_ames(ifile)%tabMesures(i,1)=temp_int |
---|
188 | |
---|
189 | temp_int=sortie_asc%tabMesures(i,2) |
---|
190 | sortie_ames%grids_ames(ifile)%tabMesures(i,2)=temp_int |
---|
191 | |
---|
192 | temp_int=sortie_asc%tabMesures(i,3) |
---|
193 | sortie_ames%grids_ames(ifile)%tabMesures(i,3)=temp_int |
---|
194 | |
---|
195 | END DO |
---|
196 | |
---|
197 | !DEALLOCATE(sortie_ames%grids_ames(ifile)%tabMesures(i,6)) |
---|
198 | |
---|
199 | sortie_ames%grids_ames(ifile)%top(1)=sortie_asc%top(1) |
---|
200 | sortie_ames%grids_ames(ifile)%top(2)=sortie_asc%top(2) |
---|
201 | sortie_ames%grids_ames(ifile)%top(3)=sortie_asc%top(3) |
---|
202 | sortie_ames%grids_ames(ifile)%top(4)=sortie_asc%top(4) |
---|
203 | sortie_ames%grids_ames(ifile)%top(5)=sortie_asc%top(5) |
---|
204 | sortie_ames%grids_ames(ifile)%top(6)=sortie_asc%top(6) |
---|
205 | sortie_ames%grids_ames(ifile)%top(7)=sortie_asc%top(7) |
---|
206 | sortie_ames%grids_ames(ifile)%top(8)=sortie_asc%top(8) |
---|
207 | sortie_ames%grids_ames(ifile)%top(9)=trim(adjustl(sortie_ames%head%latitude)) |
---|
208 | sortie_ames%grids_ames(ifile)%top(10)=trim(adjustl(sortie_ames%head%longitude)) |
---|
209 | sortie_ames%grids_ames(ifile)%top(11)=trim(adjustl(sortie_ames%head%altitude)) |
---|
210 | sortie_ames%grids_ames(ifile)%datemesure=sortie_asc%datemesure |
---|
211 | sortie_ames%grids_ames(ifile)%cmois=sortie_asc%cmois |
---|
212 | sortie_ames%grids_ames(ifile)%cheure=sortie_asc%cheure |
---|
213 | |
---|
214 | DEALLOCATE(sortie_asc%tabMesures) |
---|
215 | |
---|
216 | !lecture des mesures terminees => sortie_ames%grids_ames remplie |
---|
217 | |
---|
218 | nbbc=nbbc+1 |
---|
219 | CLOSE(unit=1) |
---|
220 | READ(2,IOSTAT=ios3, FMT='(A)') filein |
---|
221 | |
---|
222 | |
---|
223 | END DO |
---|
224 | |
---|
225 | CLOSE(unit=2) |
---|
226 | |
---|
227 | ifile=1 |
---|
228 | |
---|
229 | idatemesuremax=0 |
---|
230 | idatemesuremin=99999999 |
---|
231 | nblcomment=0 |
---|
232 | cheuremin="" |
---|
233 | cmoismin="" |
---|
234 | cheuremax="" |
---|
235 | cmoismax="" |
---|
236 | ifile=1 |
---|
237 | |
---|
238 | !calcul date DEBUT et FIN mesures |
---|
239 | DO WHILE ( ifile <= nbfiles) |
---|
240 | temp_string=sortie_ames%grids_ames(ifile)%datemesure |
---|
241 | READ(temp_string, FMT=*) idatemesure |
---|
242 | |
---|
243 | print*,"DATE MES=",idatemesure |
---|
244 | |
---|
245 | IF(idatemesure < idatemesuremin) THEN |
---|
246 | idatemesuremin=idatemesure |
---|
247 | cheuremin=sortie_ames%grids_ames(ifile)%cheure |
---|
248 | cmoismin=sortie_ames%grids_ames(ifile)%cmois |
---|
249 | ENDIF |
---|
250 | |
---|
251 | IF (idatemesure > idatemesuremax) THEN |
---|
252 | idatemesuremax=idatemesure |
---|
253 | cheuremax=sortie_ames%grids_ames(ifile)%cheure |
---|
254 | cmoismax=sortie_ames%grids_ames(ifile)%cmois |
---|
255 | |
---|
256 | ENDIF |
---|
257 | |
---|
258 | !nblcomment=nblcomment+1 |
---|
259 | ifile=ifile+1 |
---|
260 | END DO |
---|
261 | |
---|
262 | |
---|
263 | !DATEMIN |
---|
264 | temp_string="" |
---|
265 | link="" |
---|
266 | retour=concat(temp_string,temp_string3,idatemesuremin,link,7,8) |
---|
267 | sortie_ames%head%datemin=temp_string3 |
---|
268 | |
---|
269 | link="-" |
---|
270 | retour=concat(temp_string,cmoismin,-999,link,-1,-1) |
---|
271 | retour=concat(temp_string,temp_string3,idatemesuremin,link,1,4) |
---|
272 | |
---|
273 | link=" " |
---|
274 | retour=concat(temp_string,cheuremin,-999,link,-1,-1) |
---|
275 | sortie_ames%head%datemin=temp_string |
---|
276 | |
---|
277 | !DATEMAX |
---|
278 | temp_string="" |
---|
279 | link="" |
---|
280 | retour=concat(temp_string,temp_string3,idatemesuremax,link,7,8) |
---|
281 | sortie_ames%head%datemax=temp_string3 |
---|
282 | link="-" |
---|
283 | retour=concat(temp_string,cmoismax,-999,link,-1,-1) |
---|
284 | retour=concat(temp_string,temp_string3,idatemesuremax,link,1,4) |
---|
285 | link=" " |
---|
286 | retour=concat(temp_string,cheuremax,-999,link,-1,-1) |
---|
287 | sortie_ames%head%datemax=temp_string |
---|
288 | |
---|
289 | !ecriture du fichier de sortie ames |
---|
290 | !head |
---|
291 | temp_string="" |
---|
292 | |
---|
293 | temp_string=sortie_ames%head%pi//sortie_ames%head%instrument//sortie_ames%head%station//sortie_ames%head%specie//trim(adjustl(sortie_ames%head%datemin))//trim(adjustl(sortie_ames%head%datemax)) |
---|
294 | WRITE(UNIT=14, FMT='(A)') trim(adjustl(temp_string))//"1205" |
---|
295 | |
---|
296 | |
---|
297 | nblcomment=33+3*nbfiles |
---|
298 | |
---|
299 | temp_string="31" |
---|
300 | |
---|
301 | WRITE(UNIT=14, FMT=*) trim(adjustl(temp_string))//" 2110" |
---|
302 | |
---|
303 | temp_string80=sortie_ames%head%pi2 |
---|
304 | WRITE(UNIT=14, FMT='(A)') adjustl(temp_string80) |
---|
305 | |
---|
306 | temp_string80=sortie_ames%head%lab |
---|
307 | WRITE(UNIT=14, FMT='(A)') adjustl(temp_string80) |
---|
308 | |
---|
309 | temp_string80=sortie_ames%head%instrument2 |
---|
310 | WRITE(UNIT=14, FMT='(A)') adjustl(temp_string80) |
---|
311 | |
---|
312 | WRITE(UNIT=14, FMT='(A)') "NDACC" |
---|
313 | |
---|
314 | WRITE(UNIT=14, FMT='(A)') "1 1" |
---|
315 | |
---|
316 | link="" |
---|
317 | temp_string="" |
---|
318 | WRITE(temp_string2,FMT=*) idatemesuremin |
---|
319 | temp_string2=trim(adjustl(temp_string2)) |
---|
320 | temp_string3=temp_string2(1:4) |
---|
321 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
322 | |
---|
323 | link=" " |
---|
324 | temp_string3=temp_string2(5:6) |
---|
325 | IF (temp_string3(1:1) == "0") THEN |
---|
326 | temp_string3=temp_string2(6:6) |
---|
327 | ENDIF |
---|
328 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
329 | |
---|
330 | link=" " |
---|
331 | temp_string3=temp_string2(7:8) |
---|
332 | IF (temp_string3(1:1) == "0") THEN |
---|
333 | temp_string3=temp_string2(8:8) |
---|
334 | ENDIF |
---|
335 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
336 | |
---|
337 | !DATE CREATION FICHIERS AMES |
---|
338 | call date_and_time (tdate, ttime, tzone, tvalues) |
---|
339 | link="" |
---|
340 | WRITE(temp_string3,FMT=*) tvalues(1:1) |
---|
341 | temp_string3=trim(adjustl(temp_string3)) |
---|
342 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
343 | |
---|
344 | link=" " |
---|
345 | WRITE(temp_string3,FMT=*) tvalues(2:2) |
---|
346 | temp_string3=trim(adjustl(temp_string3)) |
---|
347 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
348 | |
---|
349 | WRITE(temp_string3,FMT=*) tvalues(3:3) |
---|
350 | temp_string3=trim(adjustl(temp_string3)) |
---|
351 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
352 | |
---|
353 | WRITE(UNIT=14, FMT='(A)') trim(adjustl(temp_string)) |
---|
354 | |
---|
355 | WRITE(UNIT=14, FMT='(A)') "1000. 0.00" |
---|
356 | |
---|
357 | !ouverture fichier description format colonnes |
---|
358 | OPEN( UNIT=2, & |
---|
359 | FILE=trim(adjustl(rep_data))//"./data_format.txt", & |
---|
360 | FORM="formatted", & |
---|
361 | ACCESS="sequential", & |
---|
362 | STATUS="old", & |
---|
363 | ACTION="read", & |
---|
364 | POSITION="rewind", & |
---|
365 | IOSTAT=ios3 ) |
---|
366 | |
---|
367 | |
---|
368 | READ(2,IOSTAT=ios3, FMT='(A)') line |
---|
369 | |
---|
370 | if (ios3 /= 0 ) then |
---|
371 | screen="Impossible d ouvrir le fichier de format des colonnes" |
---|
372 | retour=printl() |
---|
373 | STOP |
---|
374 | endif |
---|
375 | |
---|
376 | DO WHILE ( ios3 == 0 ) |
---|
377 | |
---|
378 | WRITE(UNIT=14, FMT='(A)') trim(adjustl(line)) |
---|
379 | READ(2,IOSTAT=ios3, FMT='(A)') line |
---|
380 | |
---|
381 | END DO |
---|
382 | |
---|
383 | WRITE(UNIT=14, FMT='(A)') "0" |
---|
384 | WRITE(UNIT=14,FMT='(A)') "1" |
---|
385 | WRITE(UNIT=14, FMT='(A)') "Data have been processed with the SA TEMPER software version 1.1" |
---|
386 | |
---|
387 | |
---|
388 | !data |
---|
389 | DO ifile=1,nbfiles |
---|
390 | temp_string="" |
---|
391 | temp_string2="" |
---|
392 | temp_string3="" |
---|
393 | link=" " |
---|
394 | |
---|
395 | temp_string3=sortie_ames%grids_ames(ifile)%top(1) |
---|
396 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
397 | |
---|
398 | temp_string3=sortie_ames%grids_ames(ifile)%top(2) |
---|
399 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
400 | |
---|
401 | temp_string3=sortie_ames%grids_ames(ifile)%top(3) |
---|
402 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
403 | |
---|
404 | temp_string3=sortie_ames%grids_ames(ifile)%top(4) |
---|
405 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
406 | |
---|
407 | temp_string3=sortie_ames%grids_ames(ifile)%top(5) |
---|
408 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
409 | |
---|
410 | temp_string3=sortie_ames%grids_ames(ifile)%top(6) |
---|
411 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
412 | |
---|
413 | temp_string3=sortie_ames%grids_ames(ifile)%top(7) |
---|
414 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
415 | |
---|
416 | temp_string3=sortie_ames%grids_ames(ifile)%top(8) |
---|
417 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
418 | |
---|
419 | temp_string3=sortie_ames%grids_ames(ifile)%top(9) |
---|
420 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
421 | |
---|
422 | temp_string3=sortie_ames%grids_ames(ifile)%top(10) |
---|
423 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
424 | |
---|
425 | temp_string3=sortie_ames%grids_ames(ifile)%top(11) |
---|
426 | retour=concat(temp_string,temp_string3,-999,link,-1,-1) |
---|
427 | |
---|
428 | WRITE(UNIT=14, FMT='(A)') trim(adjustl(temp_string)) |
---|
429 | |
---|
430 | DO i=1,size(sortie_ames%grids_ames(ifile)%tabMesures(:,1)) |
---|
431 | temp_string="" |
---|
432 | temp_string2="" |
---|
433 | |
---|
434 | temp_int=sortie_ames%grids_ames(ifile)%tabMesures(i,1) |
---|
435 | WRITE(col1, FMT='(I7)') temp_int |
---|
436 | |
---|
437 | temp_int=sortie_ames%grids_ames(ifile)%tabMesures(i,2) |
---|
438 | WRITE(col2, FMT='(I7)') temp_int |
---|
439 | |
---|
440 | temp_int=sortie_ames%grids_ames(ifile)%tabMesures(i,3) |
---|
441 | WRITE(col3, FMT='(I6)') temp_int |
---|
442 | |
---|
443 | WRITE(UNIT=14, FMT='(A)') trim(adjustl(adjustr(col1)))//" "//trim(adjustr(col2))//" "//trim(adjustr(col3)) |
---|
444 | |
---|
445 | !WRITE(UNIT=14, FMT=*) temp_string |
---|
446 | |
---|
447 | |
---|
448 | END DO |
---|
449 | DEALLOCATE(sortie_ames%grids_ames(ifile)%tabMesures) |
---|
450 | END DO |
---|
451 | |
---|
452 | CLOSE(UNIT=14) |
---|
453 | |
---|
454 | END PROGRAM treat_files_list |
---|
455 | |
---|