3 |
|
|
4 |
#include "AIM_OPTIONS.h" |
#include "AIM_OPTIONS.h" |
5 |
|
|
6 |
CStartOfInterface |
CBOP |
7 |
SUBROUTINE AIM_DO_CO2( myTime, myIter, myThid) |
C !ROUTINE: AIM_DO_CO2 |
8 |
|
C !INTERFACE: |
9 |
|
SUBROUTINE AIM_DO_CO2( myTime, myIter, myThid ) |
10 |
|
|
11 |
|
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
C *==========================================================* |
13 |
C | S/R AIM_DO_CO2 | |
C | S/R AIM_DO_CO2 |
14 |
C | o CO2 budget of the atmosphere | |
C | o CO2 budget of the atmosphere |
15 |
C *==========================================================* |
C *==========================================================* |
16 |
|
C \ev |
17 |
|
C !USES: |
18 |
IMPLICIT NONE |
IMPLICIT NONE |
19 |
|
|
20 |
C == Global data == |
C == Global data == |
21 |
C-- size for MITgcm & Physics package : |
#include "SIZE.h" |
|
#include "AIM_SIZE.h" |
|
|
|
|
22 |
#include "EEPARAMS.h" |
#include "EEPARAMS.h" |
23 |
#include "PARAMS.h" |
#include "PARAMS.h" |
24 |
#include "GRID.h" |
#include "GRID.h" |
|
#include "SURFACE.h" |
|
25 |
|
|
|
#include "AIM2DYN.h" |
|
26 |
#include "AIM_CO2.h" |
#include "AIM_CO2.h" |
|
|
|
27 |
C-- Coupled to the Ocean : |
C-- Coupled to the Ocean : |
28 |
#ifdef COMPONENT_MODULE |
#ifdef COMPONENT_MODULE |
29 |
#include "CPL_PARAMS.h" |
#include "CPL_PARAMS.h" |
30 |
#include "ATMCPL.h" |
#include "ATMCPL.h" |
31 |
#endif |
#endif |
32 |
|
|
33 |
C == Routine arguments == |
C !INPUT/OUTPUT PARAMETERS: |
34 |
C myTime - Current time of simulation ( s ) |
C myTime :: Current time of simulation ( s ) |
35 |
C myIter - Current iteration number in simulation |
C myIter :: Current iteration number in simulation |
36 |
C myThid - Number of this instance of the routine |
C myThid :: Number of this instance of the routine |
|
INTEGER myIter, myThid |
|
37 |
_RL myTime |
_RL myTime |
38 |
CEndOfInterface |
INTEGER myIter, myThid |
39 |
|
CEOP |
40 |
|
|
41 |
#ifdef ALLOW_AIM |
#ifdef ALLOW_AIM |
42 |
#ifdef ALLOW_AIM_CO2 |
#ifdef ALLOW_AIM_CO2 |
43 |
INTEGER ILNBLNK, IFNBLNK, MDS_RECLEN |
C !FUNCTIONS: |
44 |
EXTERNAL ILNBLNK, IFNBLNK, MDS_RECLEN |
INTEGER ILNBLNK, IFNBLNK |
45 |
|
EXTERNAL ILNBLNK, IFNBLNK |
46 |
|
LOGICAL DIFFERENT_MULTIPLE |
47 |
|
EXTERNAL DIFFERENT_MULTIPLE |
48 |
|
|
49 |
C == Local variables == |
C !LOCAL VARIABLES: |
50 |
C bi,bj - Tile index |
C bi,bj - Tile index |
51 |
C i,j - loop counters |
C i,j - loop counters |
52 |
INTEGER bi, bj, i, j |
INTEGER bi, bj, i, j |
|
INTEGER iUnit, length_of_rec |
|
53 |
_RL total_flux, atpco2_check |
_RL total_flux, atpco2_check |
|
Real*8 tmpco2(2) |
|
54 |
_RL flxCO2tile(nSx,nSy) |
_RL flxCO2tile(nSx,nSy) |
55 |
LOGICAL permCheckPoint |
LOGICAL permCheckPoint |
56 |
LOGICAL DIFFERENT_MULTIPLE |
INTEGER iUnit, iLo, iHi |
57 |
EXTERNAL DIFFERENT_MULTIPLE |
_RS dummyRS(1) |
58 |
CHARACTER*(MAX_LEN_FNAM) fn, msgBuf |
_RL tmpco2(2) |
59 |
INTEGER ilo,ihi |
CHARACTER*(MAX_LEN_FNAM) fn |
60 |
|
CHARACTER*(MAX_LEN_MBUF) msgBuf |
61 |
|
|
62 |
#ifdef COMPONENT_MODULE |
#ifdef COMPONENT_MODULE |
63 |
IF ( useImportFlxCO2 ) THEN |
IF ( useCoupler .AND. useImportFlxCO2 ) THEN |
64 |
DO bj=myByLo(myThid),myByHi(myThid) |
DO bj=myByLo(myThid),myByHi(myThid) |
65 |
DO bi=myBxLo(myThid),myBxHi(myThid) |
DO bi=myBxLo(myThid),myBxHi(myThid) |
66 |
DO j=1,sNy |
DO j=1,sNy |
67 |
DO i=1,sNx |
DO i=1,sNx |
68 |
aimflxCo2(i,j,bi,bj) = flxCO2ocn(i,j,bi,bj) |
aimflxCo2(i,j,bi,bj) = flxCO2ocn(i,j,bi,bj) |
69 |
ENDDO |
ENDDO |
70 |
ENDDO |
ENDDO |
71 |
ENDDO |
ENDDO |
72 |
ENDDO |
ENDDO |
105 |
ELSEIF ( myTime .EQ. startTime ) THEN |
ELSEIF ( myTime .EQ. startTime ) THEN |
106 |
C- If restart, read moles number from pickup |
C- If restart, read moles number from pickup |
107 |
WRITE(fn,'(A,I10.10)') 'pickup_aimCo2.',nIter0 |
WRITE(fn,'(A,I10.10)') 'pickup_aimCo2.',nIter0 |
108 |
ilo = IFNBLNK(fn) |
iUnit = 0 |
109 |
ihi = ILNBLNK(fn) |
CALL MDS_READVEC_LOC( fn, precFloat64, iUnit, 'RL', 2, |
110 |
CALL MDSFINDUNIT( iUnit, myThid ) |
O tmpco2, dummyRS, |
111 |
length_of_rec = MDS_RECLEN( precFloat64, 2, myThid ) |
I 0, 0, 1, myThid ) |
|
OPEN(UNIT=iUnit,FILE=fn(ilo:ihi),STATUS='old', |
|
|
& FORM='UNFORMATTED',ACCESS='DIRECT',RECL=length_of_rec) |
|
|
READ(iUnit,rec=1) tmpco2 |
|
|
CLOSE(iUnit) |
|
|
#ifdef _BYTESWAPIO |
|
|
CALL MDS_BYTESWAPR8( 2, tmpco2 ) |
|
|
#endif |
|
|
|
|
112 |
Atm_CO2_Moles = tmpco2(1) |
Atm_CO2_Moles = tmpco2(1) |
113 |
atpco2_check = tmpco2(2) |
atpco2_check = tmpco2(2) |
114 |
atm_pCO2 = Atm_CO2_Moles / total_atmos_moles |
atm_pCO2 = Atm_CO2_Moles / total_atmos_moles |
115 |
|
|
116 |
iUnit = standardMessageUnit |
iUnit = standardMessageUnit |
117 |
|
iLo = IFNBLNK(fn) |
118 |
|
iHi = ILNBLNK(fn) |
119 |
WRITE(msgBuf,'(A)') ' ' |
WRITE(msgBuf,'(A)') ' ' |
120 |
CALL PRINT_MESSAGE(msgBuf,iUnit,SQUEEZE_RIGHT,myThid) |
CALL PRINT_MESSAGE(msgBuf,iUnit,SQUEEZE_RIGHT,myThid) |
121 |
WRITE(msgBuf,'(A)') '// ===================================' |
WRITE(msgBuf,'(A)') '// ===================================' |
122 |
CALL PRINT_MESSAGE(msgBuf,iUnit,SQUEEZE_RIGHT,myThid) |
CALL PRINT_MESSAGE(msgBuf,iUnit,SQUEEZE_RIGHT,myThid) |
123 |
WRITE(msgBuf,'(2A)') '// AIM_DO_CO2: Read pickup ',fn(ilo:ihi) |
WRITE(msgBuf,'(2A)') '// AIM_DO_CO2: Read pickup ',fn(iLo:iHi) |
124 |
CALL PRINT_MESSAGE(msgBuf,iUnit,SQUEEZE_RIGHT,myThid) |
CALL PRINT_MESSAGE(msgBuf,iUnit,SQUEEZE_RIGHT,myThid) |
125 |
|
|
126 |
CALL WRITE_0D_RL( atpco2_check, INDEX_NONE, 'atpco2_check =', |
CALL WRITE_0D_RL( atpco2_check, INDEX_NONE, 'atpco2_check =', |
139 |
atm_pCO2 = Atm_CO2_Moles / total_atmos_moles |
atm_pCO2 = Atm_CO2_Moles / total_atmos_moles |
140 |
|
|
141 |
C- Write out if time for a new pickup |
C- Write out if time for a new pickup |
142 |
permCheckPoint = .FALSE. |
permCheckPoint = myTime.NE.startTime |
143 |
permCheckPoint = |
permCheckPoint = permCheckPoint .AND. |
144 |
& DIFFERENT_MULTIPLE(pChkptFreq,myTime+deltaTClock,deltaTClock) |
& DIFFERENT_MULTIPLE(pChkptFreq,myTime+deltaTClock,deltaTClock) |
|
& .AND. (myTime .NE. starttime) |
|
145 |
IF (permCheckPoint) THEN |
IF (permCheckPoint) THEN |
|
DO i = 1,MAX_LEN_FNAM |
|
|
fn(i:i) = ' ' |
|
|
ENDDO |
|
146 |
WRITE(fn,'(A,I10.10)') 'pickup_aimCo2.',myIter+1 |
WRITE(fn,'(A,I10.10)') 'pickup_aimCo2.',myIter+1 |
147 |
C- write values to new pickup |
C- write values to new pickup |
|
CALL MDSFINDUNIT( iUnit, myThid ) |
|
|
length_of_rec = MDS_RECLEN( precFloat64, 2, myThid ) |
|
|
OPEN(UNIT=iUnit,FILE=fn,STATUS='unknown', |
|
|
& FORM='UNFORMATTED',ACCESS='DIRECT',RECL=length_of_rec) |
|
148 |
tmpco2(1)= Atm_CO2_Moles |
tmpco2(1)= Atm_CO2_Moles |
149 |
tmpco2(2)= atm_pCO2 |
tmpco2(2)= atm_pCO2 |
150 |
WRITE(iUnit,rec=1) tmpco2 |
iUnit = 0 |
151 |
CLOSE(iUnit) |
CALL MDS_WRITEVEC_LOC( fn, precFloat64, iUnit, 'RL', 2, |
152 |
|
I tmpco2, dummyRS, |
153 |
|
I 0, 0, -1, myIter, myThid ) |
154 |
ENDIF |
ENDIF |
155 |
_END_MASTER(myThid) |
_END_MASTER(myThid) |
156 |
_BARRIER |
_BARRIER |