/[MITgcm]/MITgcm/pkg/ctrl/ctrl_get_gen_rec.F
ViewVC logotype

Contents of /MITgcm/pkg/ctrl/ctrl_get_gen_rec.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Tue Jun 24 16:07:06 2003 UTC (20 years, 10 months ago) by heimbach
Branch: MAIN
CVS Tags: checkpoint51e_post, checkpoint51k_post, checkpoint51o_pre, checkpoint51n_pre, checkpoint51l_post, checkpoint51q_post, checkpoint51j_post, checkpoint51r_post, checkpoint51a_post, checkpoint51c_post, checkpoint51f_pre, checkpoint51, checkpoint51o_post, checkpoint51p_post, checkpoint51i_post, checkpoint51f_post, checkpoint51b_post, checkpoint51b_pre, branchpoint-genmake2, checkpoint51h_pre, checkpoint51l_pre, checkpoint51g_post, checkpoint51d_post, checkpoint51t_post, checkpoint51n_post, checkpoint51i_pre, checkpoint51m_post, checkpoint51s_post
Branch point for: branch-nonh, branch-genmake2, tg2-branch, checkpoint51n_branch
Changes since 1.1: +177 -0 lines
Merging for c51 vs. e34

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

  ViewVC Help
Powered by ViewVC 1.1.22