/[MITgcm]/MITgcm/pkg/ptracers/ptracers_readparms.F
ViewVC logotype

Diff of /MITgcm/pkg/ptracers/ptracers_readparms.F

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

revision 1.7 by edhill, Fri Sep 10 12:19:31 2004 UTC revision 1.30 by jmc, Sat Apr 5 18:22:16 2008 UTC
# Line 6  C $Name$ Line 6  C $Name$
6  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|  C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----|
7  CBOP  CBOP
8  C     !ROUTINE: PTRACERS_READPARMS  C     !ROUTINE: PTRACERS_READPARMS
9          
10  C     !INTERFACE:  C     !INTERFACE:
11        SUBROUTINE PTRACERS_READPARMS( myThid )        SUBROUTINE PTRACERS_READPARMS( myThid )
12          
13  C     !DESCRIPTION:  C     !DESCRIPTION:
14  C     Initialize PTRACERS parameters, read in data.ptracers  C     Initialize PTRACERS parameters, read in data.ptracers
15    
# Line 18  C     !USES: Line 18  C     !USES:
18  #include "SIZE.h"  #include "SIZE.h"
19  #include "EEPARAMS.h"  #include "EEPARAMS.h"
20  #include "PTRACERS_SIZE.h"  #include "PTRACERS_SIZE.h"
21  #include "PTRACERS.h"  #include "PTRACERS_PARAMS.h"
22  #include "PARAMS.h"  #include "PARAMS.h"
23  #ifdef ALLOW_MNC  #ifdef ALLOW_MNC
24  #include "MNC_PARAMS.h"  #include "MNC_PARAMS.h"
# Line 31  CEOP Line 31  CEOP
31  #ifdef ALLOW_PTRACERS  #ifdef ALLOW_PTRACERS
32    
33  C     !LOCAL VARIABLES:  C     !LOCAL VARIABLES:
34  C     iTracer    :: loop indices  C     k,iTracer  :: loop indices
35  C     iUnit      :: unit number for I/O  C     iUnit      :: unit number for I/O
36  C     msgBuf     :: message buffer  C     msgBuf     :: message buffer
37        INTEGER iTracer        INTEGER k, iTracer
38        INTEGER iUnit        INTEGER iUnit
39        INTEGER ic        INTEGER ic
40        CHARACTER*(MAX_LEN_MBUF) msgBuf        CHARACTER*(MAX_LEN_MBUF) msgBuf
41          _RL PTRACERS_diffKr(PTRACERS_num)
42          _RL tauTr1ClimRelax
43    
44  C     PTRACERS_taveFreq :: Frequency with which time-averaged PTRACERS  C     PTRACERS_taveFreq :: Frequency with which time-averaged PTRACERS
45  C                          are written to post-processing files.  C                          are written to post-processing files.
46    C     tauTr1ClimRelax :: old parameter (will be removed 1 day)
47        NAMELIST /PTRACERS_PARM01/        NAMELIST /PTRACERS_PARM01/
48         &     tauTr1ClimRelax,
49         &     PTRACERS_dumpFreq,
50       &     PTRACERS_taveFreq,       &     PTRACERS_taveFreq,
51         &     PTRACERS_monitorFreq,
52       &     PTRACERS_advScheme,       &     PTRACERS_advScheme,
53         &     PTRACERS_ImplVertAdv,
54       &     PTRACERS_diffKh,       &     PTRACERS_diffKh,
55       &     PTRACERS_diffK4,       &     PTRACERS_diffK4,
56       &     PTRACERS_diffKr,       &     PTRACERS_diffKr,
57         &     PTRACERS_diffKrNr,
58         &     PTRACERS_ref,
59         &     PTRACERS_EvPrRn,
60       &     PTRACERS_useGMRedi,       &     PTRACERS_useGMRedi,
61       &     PTRACERS_useKPP,       &     PTRACERS_useKPP,
62         &     PTRACERS_Iter0,
63       &     PTRACERS_numInUse,       &     PTRACERS_numInUse,
64       &     PTRACERS_initialFile,       &     PTRACERS_initialFile,
65       &     PTRACERS_useRecords,       &     PTRACERS_useRecords,
66       &     PTRACERS_names,       &     PTRACERS_names,
67       &     PTRACERS_long_names,       &     PTRACERS_long_names,
68       &     PTRACERS_units,       &     PTRACERS_units,
69       &     PTRACERS_write_ioinc,       &     PTRACERS_timeave_mnc,
70       &     PTRACERS_read_mnc,       &     PTRACERS_snapshot_mnc,
71       &     PTRACERS_write_mnc       &     PTRACERS_monitor_mnc,
72         &     PTRACERS_pickup_write_mnc,
73         &     PTRACERS_pickup_read_mnc
74    
75          _BEGIN_MASTER(myThid)
76    
77  C     This routine has been called by the main model so we set our  C     This routine has been called by the main model so we set our
78  C     internal flag to indicate we are in business  C     internal flag to indicate we are in business
79        PTRACERSisON=.TRUE.  c     PTRACERSisON=.TRUE.
80    C Note(jmc): remove this flag which is not really usefull (not set properly
81    C            when usePTRACERS=F and always TRUE otherwise);
82    C            much better to use "usePTRACERS" flag instead.
83    
84    C     Set ptracer IO & diagnostics labels (2 characters long)
85          CALL PTRACERS_SET_IOLABEL(
86         O                           PTRACERS_ioLabel,
87         I                           PTRACERS_num, myThid )
88    
89  C     Set defaults values for parameters in PTRACERS.h  C     Set defaults values for parameters in PTRACERS.h
90        PTRACERS_taveFreq=taveFreq        PTRACERS_dumpFreq    = dumpFreq
91          PTRACERS_taveFreq    = taveFreq
92          PTRACERS_monitorFreq = monitorFreq
93          PTRACERS_Iter0   = 0
94        PTRACERS_numInUse=-1        PTRACERS_numInUse=-1
95        DO iTracer=1,PTRACERS_num        DO iTracer=1,PTRACERS_num
96          PTRACERS_advScheme(iTracer)=saltAdvScheme          PTRACERS_advScheme(iTracer)=saltAdvScheme
97            PTRACERS_ImplVertAdv(iTracer) = .FALSE.
98          PTRACERS_diffKh(iTracer)=diffKhS          PTRACERS_diffKh(iTracer)=diffKhS
99          PTRACERS_diffK4(iTracer)=diffK4S          PTRACERS_diffK4(iTracer)=diffK4S
100          PTRACERS_diffKr(iTracer)=diffKrS          PTRACERS_diffKr(iTracer)=UNSET_RL
101            DO k=1,Nr
102              PTRACERS_diffKrNr(k,iTracer)=diffKrNrS(k)
103              PTRACERS_ref     (k,iTracer)=0. _d 0
104            ENDDO
105            PTRACERS_EvPrRn(iTracer)=UNSET_RL
106          PTRACERS_useGMRedi(iTracer)=useGMRedi          PTRACERS_useGMRedi(iTracer)=useGMRedi
107          PTRACERS_useKPP(iTracer)=useKPP          PTRACERS_useKPP(iTracer)=useKPP
108          PTRACERS_initialFile(iTracer)=' '          PTRACERS_initialFile(iTracer)=' '
# Line 80  C     Set defaults values for parameters Line 112  C     Set defaults values for parameters
112            PTRACERS_units(iTracer)(ic:ic) = ' '            PTRACERS_units(iTracer)(ic:ic) = ' '
113          ENDDO          ENDDO
114        ENDDO        ENDDO
115        PTRACERS_useRecords  = .FALSE.        PTRACERS_useRecords       = .FALSE.
116        PTRACERS_read_mdsio  = .TRUE.  #ifdef ALLOW_MNC
117        PTRACERS_read_mnc    = .FALSE.        PTRACERS_timeave_mnc      = useMNC .AND. timeave_mnc
118        PTRACERS_write_mdsio = .TRUE.        PTRACERS_snapshot_mnc     = useMNC .AND. snapshot_mnc
119        PTRACERS_write_mnc   = .FALSE.        PTRACERS_monitor_mnc      = useMNC .AND. monitor_mnc
120        PTRACERS_write_ioinc = .FALSE.        PTRACERS_pickup_write_mnc = useMNC .AND. pickup_write_mnc
121          PTRACERS_pickup_read_mnc  = useMNC .AND. pickup_read_mnc
122    #else
123          PTRACERS_timeave_mnc      = .FALSE.
124          PTRACERS_snapshot_mnc     = .FALSE.
125          PTRACERS_monitor_mnc      = .FALSE.
126          PTRACERS_pickup_write_mnc = .FALSE.
127          PTRACERS_pickup_read_mnc  = .FALSE.
128    #endif
129          tauTr1ClimRelax = 0.
130    
131  C     Open and read the data.ptracers file  C     Open and read the data.ptracers file
       _BEGIN_MASTER(myThid)  
132        WRITE(msgBuf,'(A)') ' PTRACERS_READPARMS: opening data.ptracers'        WRITE(msgBuf,'(A)') ' PTRACERS_READPARMS: opening data.ptracers'
133        CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,        CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
134       &                   SQUEEZE_RIGHT , 1)       &                    SQUEEZE_RIGHT , myThid )
135        CALL OPEN_COPY_DATA_FILE(        CALL OPEN_COPY_DATA_FILE(
136       I                   'data.ptracers', 'PTRACERS_READPARMS',       I                   'data.ptracers', 'PTRACERS_READPARMS',
137       O                   iUnit,       O                   iUnit,
# Line 99  C     Open and read the data.ptracers fi Line 139  C     Open and read the data.ptracers fi
139        READ(UNIT=iUnit,NML=PTRACERS_PARM01)        READ(UNIT=iUnit,NML=PTRACERS_PARM01)
140        WRITE(msgBuf,'(A)')        WRITE(msgBuf,'(A)')
141       &  ' PTRACERS_READPARMS: finished reading data.ptracers'       &  ' PTRACERS_READPARMS: finished reading data.ptracers'
142        CALL PRINT_MESSAGE(msgBuf, standardMessageUnit,        CALL PRINT_MESSAGE( msgBuf, standardMessageUnit,
143       &                   SQUEEZE_RIGHT , 1)       &                    SQUEEZE_RIGHT , myThid )
144    
145  C     Close the open data file  C     Close the open data file
146        CLOSE(iUnit)        CLOSE(iUnit)
       _END_MASTER(myThid)  
   
 C     Everyone else must wait for the parameters to be loaded  
       _BARRIER  
147    
148  C     Now set-up any remaining parameters that result from the input  C     Now set-up any remaining parameters that result from the input
149  C     parameters  C     parameters
150    
151    C     Tracer 1 climatology relaxation time scale (<- but the code is gone !)
152          IF ( tauTr1ClimRelax .EQ. 0. ) THEN
153           lambdaTr1ClimRelax = 0.
154          ELSE
155           lambdaTr1ClimRelax = 1./tauTr1ClimRelax
156          ENDIF
157    
158  C     If PTRACERS_numInUse was not set in data.ptracers then we can  C     If PTRACERS_numInUse was not set in data.ptracers then we can
159  C     assume that all PTRACERS fields will be in use  C     assume that all PTRACERS fields will be in use
160        IF (PTRACERS_numInUse.LT.0) THEN        IF (PTRACERS_numInUse.LT.0) THEN
# Line 119  C     assume that all PTRACERS fields wi Line 162  C     assume that all PTRACERS fields wi
162        ENDIF        ENDIF
163  C     Check we are not trying to use more tracers than allowed  C     Check we are not trying to use more tracers than allowed
164        IF (PTRACERS_numInUse.GT.PTRACERS_num) THEN        IF (PTRACERS_numInUse.GT.PTRACERS_num) THEN
165          WRITE(msgBuf,'(A,I2,A,I2,A)')          WRITE(msgBuf,'(A,I4,A,I4,A)')
166       &       ' PTRACERS_READPARMS: You requested ',PTRACERS_numInUse,       &       ' PTRACERS_READPARMS: You requested',PTRACERS_numInUse,
167       &       ' tracers at run time when only ',PTRACERS_num,       &       ' tracers at run time when only',PTRACERS_num,
168       &       ' were specified at compile time. Naughty! '       &       ' were specified at compile time. Naughty! '
169          CALL PRINT_ERROR(msgBuf, 1)          CALL PRINT_ERROR( msgBuf, myThid )
170          STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'          STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
171        ENDIF        ENDIF
172  C     Check that enough parameters were specified  C     Check that enough parameters were specified
173        DO iTracer=1,PTRACERS_numInUse        DO iTracer=1,PTRACERS_numInUse
174          IF (PTRACERS_advScheme(iTracer).EQ.0) THEN          IF (PTRACERS_advScheme(iTracer).EQ.0) THEN
175            WRITE(msgBuf,'(A,A,I2)')            WRITE(msgBuf,'(A,A,I3)')
176       &         ' PTRACERS_READPARMS: ',       &         ' PTRACERS_READPARMS: ',
177       &         'No advect. scheme specified for tracer #',       &         'No advect. scheme specified for tracer #',
178       &         iTracer       &         iTracer
179            CALL PRINT_ERROR(msgBuf, 1)            CALL PRINT_ERROR( msgBuf, myThid )
180            STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'            STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
181          ENDIF          ENDIF
182        ENDDO        ENDDO
183    #ifndef INCLUDE_IMPLVERTADV_CODE
184          DO iTracer=1,PTRACERS_numInUse
185           IF ( PTRACERS_ImplVertAdv(iTracer) ) THEN
186            WRITE(msgBuf,'(A)')
187         &   'PTRACERS_READPARMS: #undef INCLUDE_IMPLVERTADV_CODE'
188            CALL PRINT_ERROR( msgBuf, myThid )
189            WRITE(msgBuf,'(2A,I3,A)') 'PTRACERS_READPARMS:',
190         &   ' but pTracers_ImplVertAdv(',iTracer,' ) is TRUE'
191            CALL PRINT_ERROR( msgBuf, myThid )
192            STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
193           ENDIF
194          ENDDO
195    #endif
196          DO iTracer=1,PTRACERS_numInUse
197            IF ( PTRACERS_useGMRedi(iTracer) .AND. .NOT.useGMRedi ) THEN
198              WRITE(msgBuf,'(2A,I3,A)') 'PTRACERS_READPARMS:',
199         &     ' pTracers_useGMRedi(',iTracer,' ) is TRUE'
200              CALL PRINT_ERROR( msgBuf, myThid )
201              WRITE(msgBuf,'(A,L5,A)')
202         &     'PTRACERS_READPARMS: But not useGMRedi (=',useGMRedi,')'
203              CALL PRINT_ERROR( msgBuf, myThid )
204              STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
205            ENDIF
206            IF ( PTRACERS_useKPP(iTracer) .AND. .NOT.useKPP ) THEN
207              WRITE(msgBuf,'(2A,I3,A)') 'PTRACERS_READPARMS:',
208         &     ' pTracers_useKPP(',iTracer,' ) is TRUE'
209              CALL PRINT_ERROR( msgBuf, myThid )
210              WRITE(msgBuf,'(A,L5,A)')
211         &     'PTRACERS_READPARMS: But not useKPP (=',useKPP,')'
212              CALL PRINT_ERROR( msgBuf, myThid )
213              STOP 'ABNORMAL END: S/R PTRACERS_READPARMS'
214            ENDIF
215            IF ( PTRACERS_diffKr(iTracer).NE.UNSET_RL ) THEN
216             DO k=1,Nr
217              PTRACERS_diffKrNr(k,iTracer)=PTRACERS_diffKr(iTracer)
218             ENDDO
219            ENDIF
220          ENDDO
221    
222  #ifdef ALLOW_MNC  #ifdef ALLOW_MNC
223        IF (useMNC) THEN        PTRACERS_timeave_mnc      = useMNC .AND. PTRACERS_timeave_mnc
224  C       Set the default I/O Types        PTRACERS_snapshot_mnc     = useMNC .AND. PTRACERS_snapshot_mnc
225          IF (PTRACERS_read_mnc) PTRACERS_read_mdsio = .FALSE.        PTRACERS_monitor_mnc      = useMNC .AND. PTRACERS_monitor_mnc
226          IF ( (.NOT. PTRACERS_write_ioinc)        PTRACERS_pickup_write_mnc = useMNC .AND. PTRACERS_pickup_write_mnc
227       &       .AND. PTRACERS_write_mnc ) pickup_write_mdsio = .FALSE.        PTRACERS_pickup_read_mnc  = useMNC .AND. PTRACERS_pickup_read_mnc
228            
229  C       Initialize the MNC variable types for PTRACERS        PTRACERS_timeave_mdsio      = (.NOT. PTRACERS_timeave_mnc)
230          CALL PTRACERS_MNC_INIT( myThid )       &     .OR. outputTypesInclusive
231        ENDIF        PTRACERS_snapshot_mdsio     = (.NOT. PTRACERS_snapshot_mnc)
232  #endif /*  ALLOW_MNC  */       &     .OR. outputTypesInclusive
233                PTRACERS_monitor_stdio      = (.NOT. PTRACERS_monitor_mnc)
234         &     .OR. outputTypesInclusive
235          PTRACERS_pickup_write_mdsio = (.NOT. PTRACERS_pickup_write_mnc)
236         &     .OR. outputTypesInclusive
237          PTRACERS_pickup_read_mdsio  = (.NOT. PTRACERS_pickup_read_mnc)
238         &     .OR. outputTypesInclusive
239    #else
240          PTRACERS_timeave_mnc        = .FALSE.
241          PTRACERS_snapshot_mnc       = .FALSE.
242          PTRACERS_monitor_mnc        = .FALSE.
243          PTRACERS_pickup_write_mnc   = .FALSE.
244          PTRACERS_pickup_read_mnc    = .FALSE.
245          PTRACERS_timeave_mdsio      = .TRUE.
246          PTRACERS_snapshot_mdsio     = .TRUE.
247          PTRACERS_monitor_stdio      = .TRUE.
248          PTRACERS_pickup_write_mdsio = .TRUE.
249          PTRACERS_pickup_read_mdsio  = .TRUE.
250    #endif
251    
252    C--   Print a summary of pTracer parameter values:
253          iUnit = standardMessageUnit
254          WRITE(msgBuf,'(A)') '// ==================================='
255          CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT , myThid )
256          WRITE(msgBuf,'(A)') '// PTRACERS parameters '
257          CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT , myThid )
258          WRITE(msgBuf,'(A)') '// ==================================='
259          CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT , myThid )
260          CALL WRITE_0D_I( PTRACERS_numInUse, INDEX_NONE,
261         &   'PTRACERS_numInUse =',
262         &   ' /* number of tracers */')
263          CALL WRITE_0D_I( PTRACERS_Iter0, INDEX_NONE,
264         &   'PTRACERS_Iter0 =',
265         &   ' /* timestep number when tracers are initialized */')
266          CALL WRITE_0D_R8(PTRACERS_dumpFreq, INDEX_NONE,
267         &   'PTRACERS_dumpFreq =',
268         &   ' /* Frequency^-1 for snapshot output (s) */')
269          CALL WRITE_0D_R8(PTRACERS_taveFreq, INDEX_NONE,
270         &   'PTRACERS_taveFreq =',
271         &   ' /* Frequency^-1 for time-Aver. output (s) */')
272          CALL WRITE_0D_L( PTRACERS_useRecords, INDEX_NONE,
273         &   'PTRACERS_useRecords =', ' /* all tracers in 1 file */')
274    
275          CALL WRITE_0D_L( PTRACERS_timeave_mnc, INDEX_NONE,
276         &     'PTRACERS_timeave_mnc =',
277         &     ' /* use MNC for Tave output */')
278          CALL WRITE_0D_L( PTRACERS_snapshot_mnc, INDEX_NONE,
279         &     'PTRACERS_snapshot_mnc =',
280         &     ' /* use MNC for snapshot output */')
281          CALL WRITE_0D_L( PTRACERS_pickup_write_mnc, INDEX_NONE,
282         &     'PTRACERS_pickup_write_mnc =',
283         &     ' /* use MNC for writing pickups */')
284          CALL WRITE_0D_L( PTRACERS_pickup_read_mnc, INDEX_NONE,
285         &     'PTRACERS_pickup_read_mnc =',
286         &     ' /* use MNC for reading pickups */')
287    
288          DO iTracer=1,PTRACERS_numInUse
289            WRITE(msgBuf,'(A)') ' -----------------------------------'
290            CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT, myThid )
291            WRITE(msgBuf,'(A,I4)') ' tracer number : ',iTracer
292            CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT, myThid )
293            CALL WRITE_0D_C( PTRACERS_ioLabel(iTracer), 0, INDEX_NONE,
294         &     'PTRACERS_ioLabel =', ' /* tracer IO Label */')
295            CALL WRITE_0D_I( PTRACERS_advScheme(iTracer), INDEX_NONE,
296         &     'PTRACERS_advScheme =', ' /* Advection Scheme */')
297            CALL WRITE_0D_L( PTRACERS_ImplVertAdv(iTracer), INDEX_NONE,
298         &     'PTRACERS_ImplVertAdv =',
299         &     ' /* implicit vert. advection flag */')
300            CALL WRITE_0D_R8( PTRACERS_diffKh(iTracer), INDEX_NONE,
301         &     'PTRACERS_diffKh =', ' /* Laplacian Diffusivity */')
302            CALL WRITE_0D_R8( PTRACERS_diffK4(iTracer), INDEX_NONE,
303         &     'PTRACERS_diffK4 =', ' /* Biharmonic Diffusivity */')
304            CALL WRITE_1D_R8( PTRACERS_diffKrNr(1,iTracer), Nr, INDEX_K,
305         &     'PTRACERS_diffKrNr =', ' /* Vertical Diffusivity */')
306            CALL WRITE_0D_L( PTRACERS_useGMRedi(iTracer), INDEX_NONE,
307         &     'PTRACERS_useGMRedi =', ' /* apply GM-Redi */')
308            CALL WRITE_0D_L( PTRACERS_useKPP(iTracer), INDEX_NONE,
309         &     'PTRACERS_useKPP =', ' /* apply KPP scheme */')
310            CALL WRITE_1D_R8( PTRACERS_ref(1,iTracer), Nr, INDEX_K,
311         &     'PTRACERS_ref =', ' /* Reference vertical profile */')
312            CALL WRITE_0D_R8( PTRACERS_EvPrRn(iTracer), INDEX_NONE,
313         &     'PTRACERS_EvPrRn =', '/* tracer conc. in Evap. & Rain */')
314    
315          ENDDO
316            WRITE(msgBuf,'(A)') ' -----------------------------------'
317            CALL PRINT_MESSAGE( msgBuf, iUnit, SQUEEZE_RIGHT, myThid )
318    
319          _END_MASTER(myThid)
320    C     Everyone else must wait for the parameters to be loaded
321          _BARRIER
322    
323  #endif /* ALLOW_PTRACERS */  #endif /* ALLOW_PTRACERS */
324    
325        RETURN        RETURN

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.22