1 | ! scale_LUT_io: Contains subroutines to load and save scaling Look Up Tables (LUTs) to a file |
---|
2 | ! |
---|
3 | ! June 2010 Written by Roj Marchand |
---|
4 | |
---|
5 | module scale_LUTs_io |
---|
6 | implicit none |
---|
7 | |
---|
8 | contains |
---|
9 | |
---|
10 | subroutine load_scale_LUTs(hp) |
---|
11 | |
---|
12 | use radar_simulator_types |
---|
13 | |
---|
14 | type(class_param), intent(inout) :: hp |
---|
15 | |
---|
16 | logical :: LUT_file_exists |
---|
17 | integer :: i,j,k,ind |
---|
18 | |
---|
19 | ! |
---|
20 | ! load scale LUT from file |
---|
21 | ! |
---|
22 | inquire(file=trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat', & |
---|
23 | exist=LUT_file_exists) |
---|
24 | |
---|
25 | if(.not.LUT_file_exists) then |
---|
26 | |
---|
27 | write(*,*) '*************************************************' |
---|
28 | write(*,*) 'Warning: Could NOT FIND radar LUT file: ', & |
---|
29 | trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat' |
---|
30 | write(*,*) 'Will calculated LUT values as needed' |
---|
31 | write(*,*) '*************************************************' |
---|
32 | |
---|
33 | return |
---|
34 | else |
---|
35 | |
---|
36 | OPEN(unit=12,file=trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat',& |
---|
37 | form='unformatted', & |
---|
38 | err= 89, & |
---|
39 | access='DIRECT',& |
---|
40 | recl=28) |
---|
41 | |
---|
42 | write(*,*) 'Loading radar LUT file: ', & |
---|
43 | trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat' |
---|
44 | |
---|
45 | do i=1,maxhclass |
---|
46 | do j=1,mt_ntt |
---|
47 | do k=1,nRe_types |
---|
48 | |
---|
49 | ind = i+(j-1)*maxhclass+(k-1)*(nRe_types*mt_ntt) |
---|
50 | |
---|
51 | read(12,rec=ind) hp%Z_scale_flag(i,j,k), & |
---|
52 | hp%Ze_scaled(i,j,k), & |
---|
53 | hp%Zr_scaled(i,j,k), & |
---|
54 | hp%kr_scaled(i,j,k) |
---|
55 | |
---|
56 | ! if(ind==1482329) then |
---|
57 | ! write (*,*) ind, hp%Z_scale_flag(i,j,k), & |
---|
58 | ! hp%Ze_scaled(i,j,k), & |
---|
59 | ! hp%Zr_scaled(i,j,k), & |
---|
60 | ! hp%kr_scaled(i,j,k) |
---|
61 | !endif |
---|
62 | |
---|
63 | enddo |
---|
64 | enddo |
---|
65 | enddo |
---|
66 | |
---|
67 | close(unit=12) |
---|
68 | return |
---|
69 | endif |
---|
70 | |
---|
71 | 89 write(*,*) 'Error: Found but could NOT READ radar LUT file: ', & |
---|
72 | trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat' |
---|
73 | stop |
---|
74 | |
---|
75 | end subroutine load_scale_LUTs |
---|
76 | |
---|
77 | subroutine save_scale_LUTs(hp) |
---|
78 | |
---|
79 | use radar_simulator_types |
---|
80 | |
---|
81 | type(class_param), intent(inout) :: hp |
---|
82 | |
---|
83 | logical :: LUT_file_exists |
---|
84 | integer :: i,j,k,ind |
---|
85 | |
---|
86 | inquire(file=trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat', & |
---|
87 | exist=LUT_file_exists) |
---|
88 | |
---|
89 | OPEN(unit=12,file=trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat',& |
---|
90 | form='unformatted', & |
---|
91 | err= 99, & |
---|
92 | access='DIRECT',& |
---|
93 | recl=28) |
---|
94 | |
---|
95 | write(*,*) 'Creating or Updating radar LUT file: ', & |
---|
96 | trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat' |
---|
97 | |
---|
98 | do i=1,maxhclass |
---|
99 | do j=1,mt_ntt |
---|
100 | do k=1,nRe_types |
---|
101 | |
---|
102 | ind = i+(j-1)*maxhclass+(k-1)*(nRe_types*mt_ntt) |
---|
103 | |
---|
104 | if(.not.LUT_file_exists .or. hp%Z_scale_added_flag(i,j,k)) then |
---|
105 | |
---|
106 | hp%Z_scale_added_flag(i,j,k)=.false. |
---|
107 | |
---|
108 | write(12,rec=ind) hp%Z_scale_flag(i,j,k), & |
---|
109 | hp%Ze_scaled(i,j,k), & |
---|
110 | hp%Zr_scaled(i,j,k), & |
---|
111 | hp%kr_scaled(i,j,k) |
---|
112 | |
---|
113 | ! 1482329 T 0.170626345026495 0.00000000000000 1.827402935860823E-003 |
---|
114 | |
---|
115 | !if(ind==1482329) then |
---|
116 | ! write (*,*) ind, hp%Z_scale_flag(i,j,k), & |
---|
117 | ! hp%Ze_scaled(i,j,k), & |
---|
118 | ! hp%Zr_scaled(i,j,k), & |
---|
119 | ! hp%kr_scaled(i,j,k) |
---|
120 | !endif |
---|
121 | endif |
---|
122 | enddo |
---|
123 | enddo |
---|
124 | enddo |
---|
125 | |
---|
126 | close(unit=12) |
---|
127 | return |
---|
128 | |
---|
129 | 99 write(*,*) 'Error: Unable to create/update radar LUT file: ', & |
---|
130 | trim(hp%scale_LUT_file_name) // '_radar_Z_scale_LUT.dat' |
---|
131 | return |
---|
132 | |
---|
133 | end subroutine save_scale_LUTs |
---|
134 | |
---|
135 | |
---|
136 | end module scale_LUTs_io |
---|
137 | |
---|