1 |
C $Header: /u/gcmpack/MITgcm/pkg/ecco/cost_gencal.F,v 1.3 2015/07/28 18:54:27 gforget Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "ECCO_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP |
8 |
C !ROUTINE: cost_gencal |
9 |
C !INTERFACE: |
10 |
subroutine cost_gencal( |
11 |
I localbarfile, localobsfile, |
12 |
I irec, localstartdate, localperiod, |
13 |
O fname1, fname2, localrec, obsrec, exst, |
14 |
I mythid ) |
15 |
|
16 |
|
17 |
C !DESCRIPTION: \bv |
18 |
C ================================================================== |
19 |
C SUBROUTINE cost_gencal |
20 |
C ================================================================== |
21 |
C reads and pre-processes bar file records |
22 |
C ================================================================== |
23 |
C SUBROUTINE cost_gencal |
24 |
C ================================================================== |
25 |
C \ev |
26 |
|
27 |
C !USES: |
28 |
IMPLICIT NONE |
29 |
|
30 |
C == global variables == |
31 |
#include "EEPARAMS.h" |
32 |
#include "SIZE.h" |
33 |
#include "PARAMS.h" |
34 |
#ifdef ALLOW_CAL |
35 |
# include "cal.h" |
36 |
#endif |
37 |
#ifdef ALLOW_ECCO |
38 |
# include "ecco.h" |
39 |
#endif |
40 |
|
41 |
c == routine arguments == |
42 |
|
43 |
integer mythid, irec, localstartdate(4) |
44 |
_RL localperiod |
45 |
character*(MAX_LEN_FNAM) localbarfile |
46 |
character*(MAX_LEN_FNAM) localobsfile |
47 |
character*(128) fname1, fname2 |
48 |
integer localrec, obsrec |
49 |
|
50 |
|
51 |
#ifdef ALLOW_ECCO |
52 |
|
53 |
c == local variables == |
54 |
|
55 |
c CHARACTER*(MAX_LEN_MBUF) msgBuf |
56 |
|
57 |
integer k, il |
58 |
_RL daytime |
59 |
_RL diffsecs |
60 |
integer dayiter |
61 |
integer daydate(4) |
62 |
integer difftime(4) |
63 |
integer tempDate_1 |
64 |
integer middate(4) |
65 |
integer yday, ymod |
66 |
integer md, dd, sd, ld, wd |
67 |
integer mody, modm |
68 |
integer beginmodel, beginlocal |
69 |
logical exst |
70 |
|
71 |
c == external functions == |
72 |
|
73 |
integer ilnblnk |
74 |
external ilnblnk |
75 |
|
76 |
c == end of interface == |
77 |
|
78 |
CEOP |
79 |
|
80 |
write(fname1(1:128),'(80a)') ' ' |
81 |
il=ilnblnk( localbarfile ) |
82 |
write(fname1(1:128),'(2a,i10.10)') |
83 |
& localbarfile(1:il),'.',eccoiter |
84 |
|
85 |
if ( localperiod.EQ.dTtracerLev(1) ) then |
86 |
localrec = irec |
87 |
obsrec = irec |
88 |
yday = 0 |
89 |
elseif ( localperiod .EQ. 86400. ) then |
90 |
c-- assume daily fields |
91 |
obsrec = irec |
92 |
daytime = FLOAT(secondsperday*(irec-1)) + modelstart |
93 |
dayiter = hoursperday*(irec-1) + modeliter0 |
94 |
call cal_getdate( dayiter, daytime, daydate, mythid ) |
95 |
call cal_convdate( daydate,yday,md,dd,sd,ld,wd,mythid ) |
96 |
ymod = modelstartdate(1)/10000 |
97 |
do k=1,4 |
98 |
middate(k)=0 |
99 |
enddo |
100 |
tempDate_1 = yday*10000+100+1 |
101 |
if ( ymod .GE. yday ) then |
102 |
call cal_FullDate( modelstartdate(1), 0, middate, mythid) |
103 |
else |
104 |
call cal_FullDate( tempDate_1, 0, middate, mythid) |
105 |
endif |
106 |
call cal_TimePassed( middate, daydate, difftime, mythid ) |
107 |
call cal_ToSeconds( difftime, diffsecs, mythid ) |
108 |
c localrec = floor(diffsecs/localperiod) + 1 |
109 |
localrec = int(diffsecs/localperiod) + 1 |
110 |
else |
111 |
c-- assume monthly fields |
112 |
obsrec = irec |
113 |
mody = modelstartdate(1)/10000 |
114 |
modm = modelstartdate(1)/100 - mody*100 |
115 |
yday = mody + INT((modm-1+irec-1)/12) |
116 |
localrec = 1 + MOD(modm-1+irec-1,12) |
117 |
endif |
118 |
|
119 |
il=ilnblnk(localobsfile) |
120 |
write(fname2(1:128),'(2a,i4)') |
121 |
& localobsfile(1:il), '_', yday |
122 |
inquire( file=fname2, exist=exst ) |
123 |
if (.NOT. exst) then |
124 |
c assume that the data set is cyclic |
125 |
write(fname2(1:128),'(a)') localobsfile(1:il) |
126 |
inquire( file=fname2, exist=exst ) |
127 |
endif |
128 |
|
129 |
#endif /* ALLOW_ECCO */ |
130 |
|
131 |
RETURN |
132 |
END |
133 |
|