1 |
C $Header: /u/gcmpack/MITgcm/pkg/cfc/cfc_atmos.F,v 1.4 2006/08/02 22:51:24 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "GCHEM_OPTIONS.h" |
5 |
|
6 |
CBOP |
7 |
C !ROUTINE: CFC_ATMOS |
8 |
C !INTERFACE: |
9 |
SUBROUTINE CFC_ATMOS( myThid ) |
10 |
|
11 |
C !DESCRIPTION: \bv |
12 |
C *==========================================================* |
13 |
C | SUBROUTINE CFC_ATMOS |
14 |
C | o read in time-series of atmoshperic CFC |
15 |
C *==========================================================* |
16 |
|
17 |
C !USES: |
18 |
IMPLICIT NONE |
19 |
|
20 |
C === Global variables === |
21 |
#include "SIZE.h" |
22 |
#include "EEPARAMS.h" |
23 |
#include "PARAMS.h" |
24 |
#include "CFC.h" |
25 |
#include "CFC_ATMOS.h" |
26 |
|
27 |
C !INPUT/OUTPUT PARAMETERS: |
28 |
C === Routine arguments === |
29 |
C myThid :: My Thread Id. number |
30 |
INTEGER myThid |
31 |
CEOP |
32 |
|
33 |
#ifdef ALLOW_CFC |
34 |
C !FUNCTIONS: |
35 |
INTEGER ILNBLNK |
36 |
EXTERNAL ILNBLNK |
37 |
|
38 |
C !LOCAL VARIABLES: |
39 |
C msgBuf :: message buffer |
40 |
INTEGER iUnit, i, it, iL |
41 |
LOGICAL exst |
42 |
_RL tmpVar(5) |
43 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
44 |
|
45 |
_BEGIN_MASTER( myThid ) |
46 |
|
47 |
C read in CFC atmospheric timeseries data |
48 |
iL = ILNBLNK(atmCFC_inpFile) |
49 |
IF ( iL.EQ.0 ) THEN |
50 |
WRITE(msgBuf,'(A)') |
51 |
& 'CFC_ATMOS: File-name missing for atmos CFC time-series' |
52 |
CALL PRINT_ERROR( msgBuf, myThid ) |
53 |
STOP 'ABNORMAL END: S/R CFC_ATMOS' |
54 |
ENDIF |
55 |
INQUIRE( FILE=atmCFC_inpFile(1:iL), EXIST=exst ) |
56 |
IF (exst) THEN |
57 |
WRITE(msgBuf,'(3A)') |
58 |
& 'CFC_ATMOS: opening file "', atmCFC_inpFile(1:iL), '"' |
59 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
60 |
& SQUEEZE_RIGHT, myThid ) |
61 |
ELSE |
62 |
WRITE(msgBuf,'(3A)') |
63 |
& 'CFC_ATMOS: File "', atmCFC_inpFile(1:iL),'" does not exist!' |
64 |
CALL PRINT_ERROR( msgBuf, myThid ) |
65 |
STOP 'ABNORMAL END: S/R CFC_ATMOS' |
66 |
ENDIF |
67 |
|
68 |
C assign a free unit number as the I/O channel for this subroutine |
69 |
CALL MDSFINDUNIT( iUnit, myThid ) |
70 |
OPEN(iUnit,FILE=atmCFC_inpFile(1:iL),STATUS='old') |
71 |
C skip 6 descriptor lines |
72 |
DO i =1,6 |
73 |
READ(iUnit,*) |
74 |
ENDDO |
75 |
C Read in CFC11 and CFC12, N and S Hemisphere time histories |
76 |
it = 0 |
77 |
DO WHILE ( it.LE.ACFCrecSize ) |
78 |
READ(iUnit,*,END=1001) (tmpVar(i),i=1,5) |
79 |
it = it + 1 |
80 |
IF ( it .LE. ACFCrecSize ) THEN |
81 |
ACFCyear(it) = tmpVar(1) |
82 |
ACFC11(it,1) = tmpVar(2) |
83 |
ACFC12(it,1) = tmpVar(3) |
84 |
ACFC11(it,2) = tmpVar(4) |
85 |
ACFC12(it,2) = tmpVar(5) |
86 |
ENDIF |
87 |
ENDDO |
88 |
IF ( it.GT.ACFCrecSize ) THEN |
89 |
CLOSE(iUnit) |
90 |
WRITE(msgBuf,'(3A)') |
91 |
& 'CFC_ATMOS: length of file "',atmCFC_inpFile(1:iL),'"' |
92 |
CALL PRINT_ERROR( msgBuf, myThid ) |
93 |
WRITE(msgBuf,'(2A,I9)') 'CFC_ATMOS: exceeds max num', |
94 |
& ' of records: ACFCrecSize=', ACFCrecSize |
95 |
CALL PRINT_ERROR( msgBuf, myThid ) |
96 |
STOP 'ABNORMAL END: S/R CFC_ATMOS' |
97 |
ENDIF |
98 |
1001 CONTINUE |
99 |
CLOSE(iUnit) |
100 |
ACFCnRec = it |
101 |
|
102 |
C-- Print values to check: |
103 |
WRITE(msgBuf,'(A,I8,A)') |
104 |
& 'CFC_ATMOS: read', ACFCnRec, ' (=ACFCnRec) time records :' |
105 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
106 |
& SQUEEZE_RIGHT, myThid ) |
107 |
WRITE(msgBuf,'(A)') |
108 |
& ' year , cfc11_N, cfc12_N, cfc11_S, cfc12_S' |
109 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
110 |
& SQUEEZE_RIGHT, myThid ) |
111 |
DO it = 1,ACFCnRec |
112 |
WRITE(msgBuf,'(F7.1,4F9.2)') |
113 |
& ACFCyear(it), ACFC11(it,1),ACFC12(it,1), |
114 |
& ACFC11(it,2),ACFC12(it,2) |
115 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
116 |
& SQUEEZE_RIGHT, myThid ) |
117 |
ENDDO |
118 |
|
119 |
WRITE(msgBuf,'(A)') |
120 |
& 'CFC_ATMOS: Setting atmos CFC time series: done' |
121 |
CALL PRINT_MESSAGE( msgBuf, standardMessageUnit, |
122 |
& SQUEEZE_RIGHT, myThid ) |
123 |
|
124 |
_END_MASTER(myThid) |
125 |
|
126 |
C-- Everyone else must wait for the parameters to be loaded |
127 |
_BARRIER |
128 |
|
129 |
#endif /* ALLOW_CFC */ |
130 |
|
131 |
RETURN |
132 |
END |