/[MITgcm]/MITgcm/pkg/cal/cal_set.F
ViewVC logotype

Contents of /MITgcm/pkg/cal/cal_set.F

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


Revision 1.9 - (show annotations) (download)
Sun Apr 8 19:17:09 2012 UTC (12 years, 2 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint64, checkpoint63p, checkpoint63q, checkpoint63r, checkpoint63s, checkpoint63m, checkpoint63n, checkpoint63o, checkpoint64x, checkpoint64q, checkpoint64p, checkpoint64s, checkpoint64r, checkpoint64u, checkpoint64t, checkpoint64w, checkpoint64v, checkpoint64i, checkpoint64h, checkpoint64k, checkpoint64j, checkpoint64m, checkpoint64l, checkpoint64o, checkpoint64n, checkpoint64a, checkpoint64c, checkpoint64b, checkpoint64e, checkpoint64d, checkpoint64g, checkpoint64f
Changes since 1.8: +65 -67 lines
declare nMonthYear as parameter and use as dimension in array declaration.

1 C $Header: /u/gcmpack/MITgcm/pkg/cal/cal_set.F,v 1.8 2012/04/05 22:00:08 jmc Exp $
2 C $Name: $
3
4 #include "CAL_OPTIONS.h"
5
6 SUBROUTINE CAL_SET(
7 I modstart, modend, modstep,
8 I moditerini, moditerend, modintsteps,
9 I myThid )
10
11 C ==================================================================
12 C SUBROUTINE cal_Set
13 C ==================================================================
14 C
15 C o This routine initialises the calendar according to the user
16 C specifications in "data".
17 C
18 C Purpose: Precalculations for the calendar.
19 C Given the type of calendar that should be used date
20 C arrays and some additional information is returned.
21 C Check for consistency with other specifications such
22 C as modintsteps.
23 C
24 C started: Christian Eckert eckert@mit.edu 30-Jun-1999
25 C changed: Christian Eckert eckert@mit.edu 29-Dec-1999
26 C - restructured the original version in order to have a
27 C better interface to the MITgcmUV.
28 C Christian Eckert eckert@mit.edu 19-Jan-2000
29 C - Changed the role of the routine arguments. Chris Hill
30 C proposed to make the calendar less "invasive". The tool
31 C now assumes that the MITgcmUV already provides an ade-
32 C quate set of time stepping parameters. The calendar
33 C only associates a date with the given starttime of the
34 C numerical model. startdate corresponds to zero start-
35 C time. So, given niter0 or startdate .ne. zero the actual
36 C startdate of the current integration is shifted by the
37 C time interval correponding to niter0, startdate respec-
38 C tively.
39 C Christian Eckert eckert@mit.edu 03-Feb-2000
40 C - Introduced new routine and function names, cal_<NAME>,
41 C for verion 0.1.3.
42 C Christian Eckert eckert@mit.edu 23-Feb-2000
43 C - Corrected the declaration of *modelrundate*
44 C --> integer modelrundate(4)
45 C
46 C ==================================================================
47 C SUBROUTINE cal_Set
48 C ==================================================================
49
50 IMPLICIT NONE
51
52 C == global variables ==
53
54 #include "cal.h"
55
56 C == routine arguments ==
57 C modstart :: start time of the model integration
58 C modend :: end time of the model integration
59 C modstep :: timestep of the numerical model
60 C moditerini :: initial iteration number of the model
61 C moditerend :: last iteration number of the model
62 C modintsteps :: number of timesteps that are to be performed.
63 C myThid :: my Thread Id number
64
65 _RL modstart
66 _RL modend
67 _RL modstep
68 INTEGER moditerini
69 INTEGER moditerend
70 INTEGER modintsteps
71 INTEGER myThid
72
73 C == local variables ==
74 C modelBaseDate :: full date array for startdate_1,startdate_2
75 C (corresponds to model baseTime, iter=0)
76 INTEGER i,j,k
77 INTEGER ierr
78 INTEGER timediff(4)
79 INTEGER iterinitime(4)
80 INTEGER modelBaseDate(4)
81 _RL runtimesecs
82 _RL iterinisecs
83 C == end of interface ==
84
85 _BEGIN_MASTER(myThid)
86
87 C Initialise some variables.
88 usingGregorianCalendar = .FALSE.
89 usingModelCalendar = .FALSE.
90 usingJulianCalendar = .FALSE.
91
92 C The calendar type: Start setting the calendar parameters.
93
94 if ( TheCalendar .eq. 'gregorian') then
95 usingGregorianCalendar = .TRUE.
96 C The reference date for the Gregorian Calendar.
97 C and its format: ( yymmdd , hhmmss , leap year, weekday )
98 C (1/2) (1 - 7)
99 C The Gregorian calendar starts on Friday, 15 Oct. 1582.
100 refDate(1) = 15821015
101 refDate(2) = 0
102 refDate(3) = 1
103 refDate(4) = 1
104
105 C Number of months per year and other useful numbers.
106 nDaysNoLeap = 365
107 nDaysLeap = 366
108 nMaxDayMonth = 31
109 hoursPerDay = 24
110 minutesPerHour = 60
111 minutesPerDay = minutesPerHour*hoursPerDay
112 secondsPerMinute = 60
113 secondsPerHour = secondsPerMinute*minutesPerHour
114 secondsPerDay = secondsPerMinute*minutesPerDay
115
116 C Number of days per month.
117 C The "magic" number 2773 derives from the sequence: 101010110101
118 C read in reverse and interpreted as a dual number. An
119 C alternative would be to take 2741 with the loop being
120 C executed in reverse order. Accidentially, the latter
121 C is a prime number.
122 k=2773
123 do i=1,nMonthYear
124 j = mod(k,2)
125 k = (k-j)/2
126 nDayMonth(i,1) = 30+j
127 nDayMonth(i,2) = 30+j
128 enddo
129 nDayMonth(2,1) = 28
130 nDayMonth(2,2) = 29
131
132 C Week days.
133 dayOfWeek(1) = 'FRI'
134 dayOfWeek(2) = 'SAT'
135 dayOfWeek(3) = 'SUN'
136 dayOfWeek(4) = 'MON'
137 dayOfWeek(5) = 'TUE'
138 dayOfWeek(6) = 'WED'
139 dayOfWeek(7) = 'THU'
140
141 else if ( TheCalendar .eq. 'model') then
142 usingModelCalendar = .TRUE.
143 C Assume a model calendar having 12 months with thirty days each.
144 C Reference date is the first day of year 0 at 0am, and model day 1.
145 refDate(1) = 00000101
146 refDate(2) = 0
147 refDate(3) = 1
148 refDate(4) = 1
149
150 C Some useful numbers.
151 nDaysNoLeap = 360
152 nDaysLeap = 360
153 nMaxDayMonth = 30
154 hoursPerDay = 24
155 minutesPerHour = 60
156 minutesPerDay = minutesPerHour*hoursPerDay
157 secondsPerMinute = 60
158 secondsPerHour = secondsPerMinute*minutesPerHour
159 secondsPerDay = secondsPerMinute*minutesPerDay
160 do i=1,nMonthYear
161 nDayMonth(i,1) = 30
162 nDayMonth(i,2) = 30
163 enddo
164
165 C Week days (Model Day 1 - 7).
166 dayOfWeek(1) = 'MD1'
167 dayOfWeek(2) = 'MD2'
168 dayOfWeek(3) = 'MD3'
169 dayOfWeek(4) = 'MD4'
170 dayOfWeek(5) = 'MD5'
171 dayOfWeek(6) = 'MD6'
172 dayOfWeek(7) = 'MD7'
173
174 c else if ( TheCalendar .eq. 'julian') then
175 c usingJulianCalendar = .TRUE.
176 c stop ' stopped in cal_Set (Julian Calendar).'
177 c else if ( TheCalendar .eq. 'none') then
178 c usingNoCalendar = .TRUE.
179 c stop ' stopped in cal_Set (No Calendar).'
180 else
181 ierr = 101
182 call cal_PrintError( ierr, myThid )
183 stop
184 endif
185
186 C- Record completion of calendar settings: stage 1 = calendar is defined
187 cal_setStatus = 1
188
189 C Map the numerical model parameters. --> common blocks in CALENDAR.h
190 modelStart = modstart
191 modelEnd = modend
192 modelStep = modstep
193 modelIter0 = moditerini
194 modelIterEnd = moditerend
195 modelIntSteps = modintsteps
196
197 C Do first consistency checks
198 C o Time step.
199 if ( modelStep .le. 0. ) then
200 ierr = 102
201 call cal_PrintError( ierr, myThid )
202 stop ' stopped in cal_Set.'
203 endif
204 if ( modelStep .lt. 1. ) then
205 ierr = 103
206 call cal_PrintError( ierr, myThid )
207 stop ' stopped in cal_Set.'
208 endif
209 if ( abs(modelStep - nint(modelStep)) .gt. 0.000001 ) then
210 ierr = 104
211 call cal_PrintError( ierr, myThid )
212 stop ' stopped in cal_Set.'
213 else
214 modelStep = float(nint(modelStep))
215 endif
216
217 C- Record completion of calendar settings: stage 2 = numerical model parms
218 cal_setStatus = 2
219
220 C Complete the start date specification to get a full date array.
221 call cal_FullDate( startdate_1, startdate_2,
222 & modelBaseDate, myThid )
223
224 C From here on, the final calendar settings are determined by the
225 C following variables:
226 C modelStart, modelStep*modelIntSteps & modelBaseDate
227
228 runtimesecs = modelIntSteps*modelStep
229
230 C Determine the startdate of the integration.
231 c iterinisecs = float(modelIter0)*modelStep
232 C-jmc: above does not work if baseTime <> 0 ; fix it below:
233 iterinisecs = modelStart
234 call cal_TimeInterval( iterinisecs, 'secs', iterinitime, myThid )
235 call cal_AddTime( modelBaseDate, iterinitime, modelStartDate,
236 & myThid )
237
238 call cal_TimeInterval( runtimesecs, 'secs', timediff, myThid )
239 call cal_AddTime( modelStartDate, timediff, modelEndDate,
240 & myThid )
241
242 C- Record completion of calendar settings: stage 3 = fully set-up.
243 cal_setStatus = 3
244
245 _END_MASTER(myThid)
246
247 C Everyone else must wait for the parameters to be set
248 _BARRIER
249
250 RETURN
251 END

  ViewVC Help
Powered by ViewVC 1.1.22