/[MITgcm]/MITgcm/pkg/dic/dic_atmos.F
ViewVC logotype

Contents of /MITgcm/pkg/dic/dic_atmos.F

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


Revision 1.12 - (show annotations) (download)
Mon Aug 11 17:41:05 2008 UTC (15 years, 10 months ago) by dfer
Branch: MAIN
CVS Tags: checkpoint61f, checkpoint61g, checkpoint61d, checkpoint61e, checkpoint61c, checkpoint61l, checkpoint61j, checkpoint61k, checkpoint61h, checkpoint61i
Changes since 1.11: +13 -15 lines
Small fix.

1 C $Header: /u/gcmpack/MITgcm/pkg/dic/dic_atmos.F,v 1.11 2008/04/24 21:35:53 gforget Exp $
2 C $Name: $
3
4 #include "DIC_OPTIONS.h"
5 #include "PTRACERS_OPTIONS.h"
6
7 CBOP
8 C !ROUTINE: DIC_ATMOS
9
10 C !INTERFACE: ==========================================================
11 SUBROUTINE DIC_ATMOS( istate, myTime, myIter, myThid )
12
13 C !DESCRIPTION:
14 C Calculate the atmospheric pCO2
15 C dic_int1:
16 C 0=use default 278.d-6
17 C 1=use constant value - dic_pCO2, read in from data.dic
18 C 2=read in from file
19 C 3=interact with atmospheric box
20 C !USES: ===============================================================
21 IMPLICIT NONE
22 #include "SIZE.h"
23 #include "DYNVARS.h"
24 #include "EEPARAMS.h"
25 #include "PARAMS.h"
26 #include "GRID.h"
27 #include "FFIELDS.h"
28 #include "DIC_VARS.h"
29 #include "PTRACERS_SIZE.h"
30 #include "PTRACERS_FIELDS.h"
31 #include "DIC_ATMOS.h"
32
33 C !INPUT PARAMETERS: ===================================================
34 C myThid :: thread number
35 C myIter :: current timestep
36 C myTime :: current time
37 C istate :: 0=initial call, 1=subsequent calls
38 INTEGER myIter, myThid, istate
39 _RL myTime
40
41 #ifdef ALLOW_PTRACERS
42 LOGICAL DIFFERENT_MULTIPLE
43 EXTERNAL DIFFERENT_MULTIPLE
44
45 C !LOCAL VARIABLES: ====================================================
46 INTEGER bi, bj, I,J,k
47 INTEGER ntim, iUnit
48 c
49 _RL total_flux
50 _RL total_ocean_carbon_old
51 _RL total_atmos_carbon_old
52 _RL total_atmos_moles
53 _RL atpco2
54 _RL total_carbon_old, total_carbon, carbon_diff
55 _RL tmp
56 _RL year_diff_ocean, year_diff_atmos, year_total
57 _RL start_diff_ocean, start_diff_atmos, start_total
58 C variables for reading CO2 input files
59 _RL aWght, bWght
60 c
61 CHARACTER*(MAX_LEN_FNAM) fn
62 LOGICAL permCheckPoint
63 CEOP
64
65 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
66
67 c if coupled to atmsopheric model, use the
68 c Co2 value passed from the coupler
69 #ifndef USE_ATMOSCO2
70
71 IF ( nThreads .GT. 1 .AND.
72 & ( dic_int1.EQ.2 .OR. dic_int1.EQ.3 ) ) THEN
73 C Problem with I/O and global-sum for multi-threaded execution
74 C Needs to be fixed before using this S/R in multi-threaded run
75 STOP 'S/R DIC_ATMOS: multi-threaded not right'
76 ENDIF
77
78 c default - set only once
79 if (dic_int1.eq.0.and.istate.eq.0) then
80 DO bj=myByLo(myThid),myByHi(myThid)
81 DO bi=myBxLo(myThid),myBxHi(myThid)
82
83 DO j=1-OLy,sNy+OLy
84 DO i=1-OLx,sNx+OLx
85 AtmospCO2(i,j,bi,bj)=278.0 _d -6
86 ENDDO
87 ENDDO
88
89 ENDDO
90 ENDDO
91 endif
92
93 c user specified value - set only once
94 if (dic_int1.eq.1.and.istate.eq.0) then
95 DO bj=myByLo(myThid),myByHi(myThid)
96 DO bi=myBxLo(myThid),myBxHi(myThid)
97
98 DO j=1-OLy,sNy+OLy
99 DO i=1-OLx,sNx+OLx
100 AtmospCO2(i,j,bi,bj)=dic_pCO2
101 ENDDO
102 ENDDO
103
104 ENDDO
105 ENDDO
106 endif
107
108 c read from a file (note:
109 c dic_int2=number entries to read
110 c dic_int3=start timestep,
111 c dic_int4=timestep between file entries)
112 if (dic_int1.eq.2) then
113 c linearly interpolate between file entries
114 ntim=int((myIter-dic_int3)/dic_int4)+1
115 aWght = FLOAT(myIter-dic_int3)
116 bWght = FLOAT(dic_int4)
117 aWght = 0.5 _d 0 + aWght/bWght - FLOAT(ntim-1)
118 if (aWght.gt.1. _d 0) then
119 ntim=ntim+1
120 aWght=aWght-1. _d 0
121 endif
122 bWght = 1. _d 0 - aWght
123 tmp=co2atmos(ntim)*bWght+co2atmos(ntim+1)*aWght
124 c print*,'weights',ntim, aWght, bWght, tmp
125
126 DO bj=myByLo(myThid),myByHi(myThid)
127 DO bi=myBxLo(myThid),myBxHi(myThid)
128
129 DO j=1-OLy,sNy+OLy
130 DO i=1-OLx,sNx+OLx
131 AtmospCO2(i,j,bi,bj)=tmp
132 ENDDO
133 ENDDO
134
135 print*,'AtmospCO2(20,20)',AtmospCO2(20,20,bi,bj)
136
137 ENDDO
138 ENDDO
139
140
141 endif
142
143
144 c interactive atmosphere
145 if (dic_int1.eq.3) then
146
147 c _BEGIN_MASTER(myThid)
148
149 cMass dry atmosphere = (5.1352+/-0.0003)d18 kg (Trenberth & Smith,
150 cJournal of Climate 2005)
151 cand Mean molecular mass air = 28.97 g/mol (NASA earth fact sheet)
152 total_atmos_moles= 1.77 _d 20
153 c for 278ppmv we need total_atmos_carbon=4.9206e+16
154
155 if (istate.gt.0) then
156 total_ocean_carbon_old=total_ocean_carbon
157 total_atmos_carbon_old=total_atmos_carbon
158 else
159 total_ocean_carbon_old=0. _d 0
160 total_atmos_carbon_old=0. _d 0
161 endif
162
163 total_flux= 0. _d 0
164 total_ocean_carbon= 0. _d 0
165
166 DO bj=myByLo(myThid),myByHi(myThid)
167 DO bi=myBxLo(myThid),myBxHi(myThid)
168 DO i=1,sNx
169 DO j=1,sNy
170 if (istate.gt.0) then
171 total_flux=total_flux+FluxCO2(i,j,bi,bj)*rA(i,j,bi,bj)*
172 & maskC(i,j,1,bi,bj)*dTtracerLev(1)
173 endif
174 DO k=1,nR
175 total_ocean_carbon= total_ocean_carbon+
176 & ( Ptracer(i,j,k,bi,bj,1)
177 #ifdef DIC_BIOTIC
178 & +R_cp*Ptracer(i,j,k,bi,bj,4)
179 #endif
180 & ) * rA(i,j,bi,bj)*
181 & drF(k)*hFacC(i,j,k,bi,bj)
182 ENDDO
183 ENDDO
184 ENDDO
185 ENDDO
186 ENDDO
187
188 _GLOBAL_SUM_R8(total_flux,myThid)
189 _GLOBAL_SUM_R8(total_ocean_carbon,myThid)
190
191 if (istate.eq.0) then
192 c use value read in dic_init_fixed
193 total_atmos_carbon=total_atmos_carbon_ini
194 else
195 c calculate new atmos pCO2
196 total_atmos_carbon=total_atmos_carbon - total_flux
197 c write out if time for a new pickup
198 permCheckPoint = .FALSE.
199 permCheckPoint =
200 & DIFFERENT_MULTIPLE(pChkptFreq,myTime,deltaTClock)
201 if (permCheckPoint) then
202 DO i = 1,MAX_LEN_FNAM
203 fn(i:i) = ' '
204 ENDDO
205 WRITE(fn,'(A,I10.10)') 'dic_atmos.',myIter
206 C Going to really do some IO. Make everyone except master thread wait.
207 _BARRIER
208 c write values to new pickup
209
210 CALL MDSFINDUNIT( iUnit, myThid )
211 open(iUnit,file=fn,status='new')
212 write(iUnit,*) total_atmos_carbon, atpco2
213 close(iUnit)
214
215 endif
216 endif
217
218 atpco2=total_atmos_carbon/total_atmos_moles
219
220 c print*,'QQpCO2', total_atmos_carbon, atpco2, total_ocean_carbon,
221 c & total_flux
222
223 DO bj=myByLo(myThid),myByHi(myThid)
224 DO bi=myBxLo(myThid),myBxHi(myThid)
225
226 DO j=1-OLy,sNy+OLy
227 DO i=1-OLx,sNx+OLx
228 AtmospCO2(i,j,bi,bj)=atpco2
229 ENDDO
230 ENDDO
231
232 ENDDO
233 ENDDO
234
235 print*,'QQ atmos C, total, pCo2', total_atmos_carbon, atpco2
236 total_carbon=total_atmos_carbon + total_ocean_carbon
237 total_carbon_old=total_atmos_carbon_old + total_ocean_carbon_old
238 carbon_diff=total_carbon-total_carbon_old
239 print*,'QQ total C, current, old, diff', total_carbon,
240 & total_carbon_old, carbon_diff
241 carbon_diff=total_ocean_carbon-total_ocean_carbon_old
242 tmp=carbon_diff-total_flux
243 print*,'QQ ocean C, current, old, diff',total_ocean_carbon,
244 & total_ocean_carbon_old, carbon_diff
245 print*,'QQ air-sea flux, addition diff', total_flux, tmp
246
247 c if end of forcing cycle, find total change in ocean carbon
248 if (istate.eq.0) then
249 total_ocean_carbon_start=total_ocean_carbon
250 total_ocean_carbon_year=total_ocean_carbon
251 total_atmos_carbon_start=total_atmos_carbon
252 total_atmos_carbon_year=total_atmos_carbon
253 else
254 permCheckPoint = .FALSE.
255 permCheckPoint =
256 & DIFFERENT_MULTIPLE(externForcingCycle,myTime,deltaTClock)
257 if (permCheckPoint) then
258 year_diff_ocean=total_ocean_carbon-total_ocean_carbon_year
259 year_diff_atmos=total_atmos_carbon-total_atmos_carbon_year
260 year_total=(total_ocean_carbon+total_atmos_carbon) -
261 & (total_ocean_carbon_year+total_atmos_carbon_year)
262 start_diff_ocean=total_ocean_carbon-total_ocean_carbon_start
263 start_diff_atmos=total_atmos_carbon-total_atmos_carbon_start
264 start_total=(total_ocean_carbon+total_atmos_carbon) -
265 & (total_ocean_carbon_start+total_atmos_carbon_start)
266 print*,'QQ YEAR END'
267 print*,'year diff: ocean, atmos, total', year_diff_ocean,
268 & year_diff_atmos, year_total
269 print*,'start diff: ocean, atmos, total ', start_diff_ocean,
270 & start_diff_atmos, start_total
271 c
272 total_ocean_carbon_year=total_ocean_carbon
273 total_atmos_carbon_year=total_atmos_carbon
274 endif
275 endif
276
277 c _END_MASTER(myThid)
278
279 endif
280
281 #endif
282 #endif
283
284 RETURN
285 END

  ViewVC Help
Powered by ViewVC 1.1.22