forked from luflarois/extract_prec
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_out.f90
More file actions
94 lines (78 loc) · 3.66 KB
/
Copy pathmod_out.f90
File metadata and controls
94 lines (78 loc) · 3.66 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
module mod_out
implicit none
private
public :: write_csv, write_script
contains
subroutine write_csv(csv_file,totprec_data,totprec_mask_data,points_inside,mapa,dataini,datafin)
character(len=*), intent(in) :: csv_file
character(len=*), intent(in) :: dataini,datafin
real, intent(in) :: totprec_data(:,:,:)
real, intent(in) :: points_inside(:,:)
character(len=*), intent(in) :: mapa
!
real, intent(out) :: totprec_mask_data(:,:,:)
real :: sum_tot,sum_prec
integer :: t,i,j
sum_tot = 0.0
open(unit=22,file=trim(csv_file),status="replace",action="write")
write(22,fmt='(A4,",",A15,",",A30)') "Time","Tot_area","Tot_Accum_Area"
do t = 1, size(totprec_data,3)
sum_prec = 0.0
do i = 1, size(totprec_data,1)
do j = 1, size(totprec_data,2)
if (points_inside(i,j) .ne. 0.0) then
sum_prec = sum_prec + totprec_data(i,j,t)
!print *,"inside: ",points_inside(i,j),i,j,lon_data(i),lat_data(j)
if (trim(mapa)=="1") then
totprec_mask_data(i,j,t) = points_inside(i,j)
else
totprec_mask_data(i,j,t) = totprec_data(i,j,t)
end if
else
if (trim(mapa)=="1") then
totprec_mask_data(i,j,t) = 0.0
else
totprec_mask_data(i,j,t) = 0.0
end if
end if
end do
end do
sum_tot = sum_tot + sum_prec
write(22,fmt='(I4.4,",",F15.4,",",F30.4)') t,sum_prec,sum_tot
end do
close(unit=22)
write(*,*) 'Arquivo CSV criado: ', csv_file
end subroutine write_csv
subroutine write_script(csv_file, png_file, dataini, datafin, filecontour)
character(len=*), intent(in) :: csv_file
character(len=*), intent(in) :: png_file
character(len=*), intent(in) :: dataini,datafin
character(len=*), intent(in) :: filecontour
character(len=256) :: filename
character(len=256) :: mensagem
integer :: status
filename = trim(csv_file)//".gnu"
open(unit=22,file=trim(filename),status="replace",action="write")
write(22,*) "set terminal pngcairo enhanced font 'Arial,12' size 800,600"
write(22,*) "set output '"//trim(png_file)//"'"
write(22,*) "set y2tics"
write(22,*) "set ytics nomirror"
write(22,*) "set xtics 24"
write(22,*) "set ylabel 'mm'"
write(22,*) "set xlabel 'Horas desde "//dataini
write(22,*) "set y2label 'mm Acum'"
write(22,*) "set xrange[1:360]"
write(22,*) "set title 'Precipitacao - Area de Contribuicao - "//trim(filecontour)//" - "//dataini//datafin
write(22,*) "set grid"
write(22,*) "plot '"//trim(csv_file)//"' using 1:2 axis x1y1 with boxes title 'Prec mm/h' , '"//trim(csv_file)//"' using 1:3 axis x1y2 with lines title 'Prec. acum. mm'"
close(unit=22)
write(*,*) 'Script gnuplot criado: ', trim(filename)
call execute_command_line('gnuplot "'//trim(csv_file)//'.gnu"', exitstat=status, cmdmsg=mensagem)
if (status == 0) then
write(*,*) 'Arquivo de imagem criado: ', trim(png_file)
else
write(*,*) "***** Erro ao executar o gnuplot. Código: ", status
write(*,*) "***** Verifique o erro ou se ele está presente!"
end if
end subroutine write_script
end module mod_out