1 |
C $Header: /u/gcmpack/MITgcm/pkg/ctrl/ctrl_get_gen_rec.F,v 1.2 2003/06/24 16:07:06 heimbach Exp $ |
2 |
|
3 |
#include "PACKAGES_CONFIG.h" |
4 |
#include "CTRL_CPPOPTIONS.h" |
5 |
|
6 |
|
7 |
subroutine ctrl_get_gen_rec( |
8 |
I xx_genstartdate, |
9 |
I xx_genperiod, |
10 |
O fac, |
11 |
O first, |
12 |
O changed, |
13 |
O count0, |
14 |
O count1, |
15 |
I mytime, |
16 |
I myiter, |
17 |
I mythid |
18 |
& ) |
19 |
|
20 |
c ================================================================== |
21 |
c SUBROUTINE ctrl_get_gen_rec |
22 |
c ================================================================== |
23 |
c |
24 |
c o Get flags, counters, and the linear interpolation factor for a |
25 |
c given control vector contribution. |
26 |
c o New, generic, for new routine ctrl_get_gen |
27 |
c |
28 |
c ================================================================== |
29 |
c SUBROUTINE ctrl_get_gen_rec |
30 |
c ================================================================== |
31 |
|
32 |
implicit none |
33 |
|
34 |
c == global variables == |
35 |
|
36 |
#include "EEPARAMS.h" |
37 |
#include "SIZE.h" |
38 |
|
39 |
#include "ctrl.h" |
40 |
#ifdef ALLOW_CAL |
41 |
# include "cal.h" |
42 |
#endif |
43 |
|
44 |
c == routine arguments == |
45 |
|
46 |
integer xx_genstartdate(4) |
47 |
_RL xx_genperiod |
48 |
_RL fac |
49 |
logical first |
50 |
logical changed |
51 |
integer count0 |
52 |
integer count1 |
53 |
_RL mytime |
54 |
integer myiter |
55 |
integer mythid |
56 |
|
57 |
c == local variables == |
58 |
|
59 |
#ifdef ALLOW_CAL |
60 |
|
61 |
integer mydate(4) |
62 |
integer previousdate(4) |
63 |
integer difftime(4) |
64 |
|
65 |
integer fldcount |
66 |
_RL fldsecs |
67 |
integer prevfldcount |
68 |
_RL prevfldsecs |
69 |
integer flddate(4) |
70 |
|
71 |
integer fldstartdate(4) |
72 |
_RL fldperiod |
73 |
|
74 |
logical lArgErr |
75 |
|
76 |
#ifdef ECCO_VERBOSE |
77 |
character*(max_len_mbuf) msgbuf |
78 |
#endif |
79 |
|
80 |
c == end of interface == |
81 |
|
82 |
lArgErr = .true. |
83 |
fldperiod = 0. |
84 |
|
85 |
c Map the field parameters. |
86 |
|
87 |
call cal_CopyDate( |
88 |
I xx_genstartdate, |
89 |
O fldstartdate, |
90 |
I mythid |
91 |
& ) |
92 |
fldperiod = xx_genperiod |
93 |
lArgErr = .false. |
94 |
|
95 |
c-- Check the field argument. |
96 |
if ( lArgErr ) then |
97 |
print*,' The subroutine *ctrl_get_gen_rec* has been called' |
98 |
print*,' with an illegal field specification.' |
99 |
stop ' ... stopped in ctrl_get_gen_rec.' |
100 |
endif |
101 |
|
102 |
c-- Determine the current date. |
103 |
call cal_GetDate( myiter, mytime, mydate, mythid ) |
104 |
|
105 |
c Determine the flux record just before mycurrentdate. |
106 |
call cal_TimePassed( fldstartdate, mydate, difftime, |
107 |
& mythid ) |
108 |
call cal_ToSeconds( difftime, fldsecs, mythid ) |
109 |
fldsecs = int((fldsecs+0.5)/fldperiod)*fldperiod |
110 |
fldcount = int((fldsecs+0.5)/fldperiod) + 1 |
111 |
|
112 |
c Set switches for reading new records. |
113 |
first = ((mytime - modelstart) .lt. 0.5*modelstep) |
114 |
|
115 |
if ( first) then |
116 |
changed = .false. |
117 |
else |
118 |
call cal_GetDate( myiter-1, mytime-modelstep, |
119 |
& previousdate, mythid ) |
120 |
|
121 |
call cal_TimePassed( fldstartdate, previousdate, |
122 |
& difftime, mythid ) |
123 |
call cal_ToSeconds( difftime, prevfldsecs, mythid ) |
124 |
prevfldsecs = int((prevfldsecs+0.5)/fldperiod)*fldperiod |
125 |
prevfldcount = int((prevfldsecs+0.5)/fldperiod) + 1 |
126 |
|
127 |
if (fldcount .ne. prevfldcount) then |
128 |
changed = .true. |
129 |
else |
130 |
changed = .false. |
131 |
endif |
132 |
endif |
133 |
|
134 |
count0 = fldcount |
135 |
count1 = fldcount + 1 |
136 |
|
137 |
call cal_TimeInterval( fldsecs, 'secs', difftime, mythid ) |
138 |
call cal_AddTime( fldstartdate, difftime, flddate, mythid ) |
139 |
call cal_TimePassed( flddate, mydate, difftime, mythid ) |
140 |
call cal_ToSeconds( difftime, fldsecs, mythid ) |
141 |
|
142 |
c Weight belonging to irec for linear interpolation purposes. |
143 |
c Note: The weight as chosen here is 1. - fac of the "old" |
144 |
c MITgcm's estimation program. |
145 |
fac = 1. - fldsecs/fldperiod |
146 |
|
147 |
#ifdef ECCO_VERBOSE |
148 |
c Do some printing for the protocol. |
149 |
_BEGIN_MASTER( mythid ) |
150 |
write(msgbuf,'(a)') ' ' |
151 |
call print_message( msgbuf, standardmessageunit, |
152 |
& SQUEEZE_RIGHT , mythid) |
153 |
write(msgbuf,'(a,a)') |
154 |
& ' ctrl_getrec: thefield: ', |
155 |
& thefield |
156 |
call print_message( msgbuf, standardmessageunit, |
157 |
& SQUEEZE_RIGHT , mythid) |
158 |
write(msgbuf,'(a,2x,l2,2x,l2,2x,D15.8)') |
159 |
& ' first, changed, fac:', |
160 |
& first, changed, fac |
161 |
call print_message( msgbuf, standardmessageunit, |
162 |
& SQUEEZE_RIGHT , mythid) |
163 |
write(msgbuf,'(a,i4,i4)') |
164 |
& ' count0, count1:', |
165 |
& count0, count1 |
166 |
call print_message( msgbuf, standardmessageunit, |
167 |
& SQUEEZE_RIGHT , mythid) |
168 |
write(msgbuf,'(a)') ' ' |
169 |
call print_message( msgbuf, standardmessageunit, |
170 |
& SQUEEZE_RIGHT , mythid) |
171 |
_END_MASTER( mythid ) |
172 |
#endif |
173 |
|
174 |
#endif /* ALLOW_CAL */ |
175 |
|
176 |
return |
177 |
end |
178 |
|