/[MITgcm]/MITgcm/pkg/exf/exf_getffieldrec.F
ViewVC logotype

Annotation of /MITgcm/pkg/exf/exf_getffieldrec.F

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


Revision 1.8 - (hide annotations) (download)
Tue Sep 23 04:34:25 2003 UTC (20 years, 8 months ago) by dimitri
Branch: MAIN
CVS Tags: checkpoint51f_post, checkpoint51j_post, checkpoint51h_pre, branchpoint-genmake2, checkpoint51i_pre, checkpoint51g_post
Branch point for: branch-genmake2
Changes since 1.7: +54 -47 lines
o Mods and bug fixes to pkg/cal and pkg/exf needed for computation
  of tracer Green's fucntions for ocean inversion project.

1 dimitri 1.8 c $Header: /u/gcmpack/MITgcm/pkg/exf/exf_getffieldrec.F,v 1.7 2003/06/24 16:07:32 heimbach Exp $
2 heimbach 1.1
3     #include "CPP_OPTIONS.h"
4    
5    
6     subroutine exf_GetFFieldRec(
7     I fldstartdate, fldperiod,
8     O fac,
9     O first,
10     O changed,
11     O count0,
12     O count1,
13     I mytime,
14     I myiter,
15     I mythid
16     & )
17    
18     c ==================================================================
19     c SUBROUTINE exf_GetFFieldRec
20     c ==================================================================
21     c
22     c o Get flags, counters, and the linear interpolation factor for a
23     c given field.
24     c
25     c started: Christian Eckert eckert@mit.edu 30-Jun-1999
26     c
27     c changed: Christian Eckert eckert@mit.edu 14-Jan-2000
28     c - Restructured the code in order to create a package
29     c for the MITgcmUV.
30     c
31     c Christian Eckert eckert@mit.edu 12-Feb-2000
32 dimitri 1.3 c - Changed Routine names (package prefix: exf_)
33     c
34     c Curtis Heisey cheisey@mit.edu 19-Dec-2002
35     c - added "repeatPeriod" for cycling of forcing datasets
36 heimbach 1.1 c
37 dimitri 1.3 c Dimitris Menemenlis menemenlis@jpl.nasa.gov 27-Dec-2002
38     c - bug fix for verification/global_with_exf
39 heimbach 1.1 c
40     c ==================================================================
41     c SUBROUTINE exf_GetFFieldRec
42     c ==================================================================
43    
44     implicit none
45    
46     c == global variables ==
47    
48     c cal: modelstart, modelstep
49     #include "EEPARAMS.h"
50     #include "cal.h"
51 cheisey 1.2 #include "exf_param.h"
52 heimbach 1.1
53     c == routine arguments ==
54    
55     integer fldstartdate(4)
56     _RL fldperiod
57     _RL fac
58     logical first
59     logical changed
60     integer count0
61     integer count1
62     _RL mytime
63     integer myiter
64     integer mythid
65    
66     c == local variables ==
67    
68     integer mydate(4)
69     integer previousdate(4)
70     integer difftime(4)
71    
72     _RL fldsecs
73 cheisey 1.2 _RL fldsecs0
74     _RL fldsecs1
75 heimbach 1.1 integer prevfldcount
76     _RL prevfldsecs
77 dimitri 1.3
78 heimbach 1.1 #ifdef EXF_VERBOSE
79     character*(max_len_mbuf) msgbuf
80     #endif
81    
82     c == end of interface ==
83    
84 dimitri 1.8 c Determine offset in seconds from beginning of input data
85     c to current date.
86 heimbach 1.1 call cal_GetDate( myiter, mytime, mydate, mythid )
87     call cal_TimePassed( fldstartdate, mydate, difftime, mythid )
88     call cal_ToSeconds( difftime, fldsecs, mythid )
89 dimitri 1.3
90 dimitri 1.8 c Variables needed to set switches for reading new records.
91     first = ((mytime - modelstart) .lt. 0.5*modelstep)
92     if ( .not. first ) then
93     call cal_GetDate(myiter-1,mytime-modelstep,previousdate,mythid)
94     call cal_TimePassed(fldstartdate,previousdate,difftime,mythid )
95     call cal_ToSeconds( difftime, prevfldsecs, mythid )
96     else
97     prevfldsecs = 0
98 cheisey 1.2 endif
99 heimbach 1.1
100 dimitri 1.8 c Determine the flux records just before and after mycurrentdate.
101     if (repeatPeriod.eq.0.) then
102    
103     if ( fldsecs .lt. 0 ) then
104     print*,'flux data not available for this date'
105     stop 'ABNORMAL END: S/R EXF_GETFFIELDREC'
106     endif
107     count0 = int((fldsecs+0.5)/fldperiod) + 1
108     count1 = count0 + 1
109     prevfldcount= int((prevfldsecs+0.5)/fldperiod) + 1
110     fldsecs = fldsecs - int((fldsecs+0.5)/fldperiod)*fldperiod
111    
112     elseif (repeatPeriod.gt.0.) then
113    
114     c If using repeating data (e.g. monthly means) then make
115     c fldsecs cycle around.
116     do while ( fldsecs .lt. 0 )
117     fldsecs = fldsecs + repeatPeriod
118     enddo
119     fldsecs0 = mod(fldsecs,repeatPeriod)
120     count0 = int((fldsecs0+0.5)/fldperiod) + 1
121     fldsecs1 = mod(fldsecs+fldperiod,repeatPeriod)
122     count1 = int((fldsecs1+0.5)/fldperiod) + 1
123     do while ( prevfldsecs .lt. 0 )
124     prevfldsecs = prevfldsecs + repeatPeriod
125     enddo
126     prevfldsecs = mod(prevfldsecs,repeatPeriod)
127     prevfldcount= int((prevfldsecs+0.5)/fldperiod) + 1
128     fldsecs = fldsecs0-int((fldsecs0+0.5)/fldperiod)*fldperiod
129 heimbach 1.1
130     else
131    
132 dimitri 1.8 print*,'repeatPeriod must be positive'
133     stop 'ABNORMAL END: S/R EXF_GETFFIELDREC'
134    
135 dimitri 1.3 endif
136    
137 dimitri 1.8 c Set switches for reading new records.
138     if ( first) then
139     changed = .false.
140     else
141     if (count0 .ne. prevfldcount) then
142     changed = .true.
143     else
144     changed = .false.
145     endif
146 heimbach 1.1 endif
147    
148     c Weight belonging to irec for linear interpolation purposes.
149 dimitri 1.8 c Note: The weight as chosen here is 1. - fac of the "old"
150     c MITgcm's estimation program.
151 heimbach 1.1 fac = 1. - fldsecs/fldperiod
152    
153     #ifdef EXF_VERBOSE
154     c Do some printing for the protocol.
155     _BEGIN_MASTER( mythid )
156     write(msgbuf,'(a)') ' '
157     call print_message( msgbuf, standardmessageunit,
158     & SQUEEZE_RIGHT , mythid)
159     write(msgbuf,'(a,2x,l2,2x,l2,2x,D15.8)')
160     & ' exf_GetFFieldsRec: first, changed, fac:',
161     & first, changed, fac
162     call print_message( msgbuf, standardmessageunit,
163     & SQUEEZE_RIGHT , mythid)
164     write(msgbuf,'(a,i4,i4)')
165     & ' exf_GetFFieldsRec: count0, count1:',
166     & count0, count1
167     call print_message( msgbuf, standardmessageunit,
168     & SQUEEZE_RIGHT , mythid)
169     write(msgbuf,'(a)') ' '
170     call print_message( msgbuf, standardmessageunit,
171     & SQUEEZE_RIGHT , mythid)
172     _END_MASTER( mythid )
173     #endif
174    
175     end

  ViewVC Help
Powered by ViewVC 1.1.22