1 |
C $Header: /u/gcmpack/MITgcm/pkg/ptracers/ptracers_check_pickup.F,v 1.3 2012/03/08 17:05:44 jmc Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "PTRACERS_OPTIONS.h" |
5 |
|
6 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
7 |
CBOP |
8 |
C !ROUTINE: PTRACERS_CHECK_PICKUP |
9 |
C !INTERFACE: |
10 |
SUBROUTINE PTRACERS_CHECK_PICKUP( |
11 |
I missFldList, |
12 |
I nMissing, nbFields, |
13 |
I myIter, myThid ) |
14 |
|
15 |
C !DESCRIPTION: |
16 |
C Check that fields that are needed to restart have been read. |
17 |
C In case some fields are missing, stop if pickupStrictlyMatch=T |
18 |
C or try, if possible, to restart without the missing field. |
19 |
|
20 |
C !USES: |
21 |
IMPLICIT NONE |
22 |
#include "SIZE.h" |
23 |
#include "EEPARAMS.h" |
24 |
#include "PARAMS.h" |
25 |
#include "PTRACERS_SIZE.h" |
26 |
#include "PTRACERS_PARAMS.h" |
27 |
#include "PTRACERS_START.h" |
28 |
|
29 |
C !INPUT/OUTPUT PARAMETERS: |
30 |
C missFldList :: List of missing fields (attempted to read but not found) |
31 |
C nMissing :: Number of missing fields (attempted to read but not found) |
32 |
C nbFields :: number of fields in pickup file (read from meta file) |
33 |
C myIter :: Iteration number |
34 |
C myThid :: my Thread Id. number |
35 |
CHARACTER*(8) missFldList(*) |
36 |
INTEGER nMissing |
37 |
INTEGER nbFields |
38 |
INTEGER myIter |
39 |
INTEGER myThid |
40 |
CEOP |
41 |
|
42 |
C !FUNCTIONS |
43 |
INTEGER ILNBLNK |
44 |
EXTERNAL ILNBLNK |
45 |
|
46 |
C !LOCAL VARIABLES: |
47 |
INTEGER i, iTracer |
48 |
INTEGER j |
49 |
INTEGER ioUnit |
50 |
INTEGER warnCnts |
51 |
LOGICAL stopFlag |
52 |
CHARACTER*(8) fldName |
53 |
CHARACTER*(2) ioLabel |
54 |
CHARACTER*(MAX_LEN_MBUF) msgBuf |
55 |
|
56 |
ioUnit = errorMessageUnit |
57 |
|
58 |
_BEGIN_MASTER( myThid ) |
59 |
|
60 |
IF ( nMissing.GE.1 ) THEN |
61 |
stopFlag = .FALSE. |
62 |
warnCnts = nMissing |
63 |
DO j=1,nMissing |
64 |
fldName = missFldList(j) |
65 |
|
66 |
C find the corresponding pTracer: |
67 |
IF ( fldName(1:3).EQ.'pTr' ) THEN |
68 |
ioLabel = fldName(4:5) |
69 |
ELSEIF ( fldName(1:4).EQ.'gPtr' ) THEN |
70 |
ioLabel = fldName(5:6) |
71 |
ELSE |
72 |
ioLabel = ' ' |
73 |
ENDIF |
74 |
iTracer = 0 |
75 |
DO i=1,PTRACERS_numInUse |
76 |
IF ( iTracer.EQ.0 .AND. |
77 |
& ioLabel.EQ.PTRACERS_ioLabel(i) ) iTracer = i |
78 |
ENDDO |
79 |
|
80 |
C- passive tracer field is always needed: |
81 |
IF ( iTracer.GT.0 .AND. |
82 |
& fldName(1:3).EQ.'pTr' .AND. fldName(6:8).EQ.' ' ) THEN |
83 |
stopFlag = .TRUE. |
84 |
WRITE(msgBuf,'(2A,I4,3A)') 'PTRACERS_CHECK_PICKUP: ', |
85 |
& 'cannot restart without tracer ',iTracer, |
86 |
& ' field "',fldName,'"' |
87 |
CALL PRINT_ERROR( msgBuf, myThid ) |
88 |
|
89 |
C- fields with alternative in place to restart without: |
90 |
C- (but get a non-perfect restart) |
91 |
ELSEIF ( iTracer.GT.0 .AND. ( |
92 |
& ( fldName(1:4).EQ.'gPtr' .AND. fldName(7:8).EQ.'m1' ) .OR. |
93 |
& ( fldName(1:3).EQ.'pTr' .AND. fldName(6:8).EQ.'Nm1' ) |
94 |
& ) ) THEN |
95 |
PTRACERS_startAB(iTracer) = 0 |
96 |
IF ( fldName(1:4).EQ.'gPtr' ) WRITE(msgBuf,'(2A,I4)') |
97 |
& '** WARNING ** PTRACERS_CHECK_PICKUP: ', |
98 |
& 'tracer Tendency is missing for pTr# :',iTracer |
99 |
IF ( fldName(1:3).EQ.'pTr' ) WRITE(msgBuf,'(2A,I4)') |
100 |
& '** WARNING ** PTRACERS_CHECK_PICKUP: ', |
101 |
& 'tracer @ iter-1 is missing for pTr# :',iTracer |
102 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
103 |
IF ( .NOT.pickupStrictlyMatch .AND. .NOT.stopFlag ) THEN |
104 |
WRITE(msgBuf,'(3A,I4)') '** WARNING ** ', |
105 |
& '1rst time-step will use simple Euler time-stepping', |
106 |
& ' for pTr# ',iTracer |
107 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
108 |
ENDIF |
109 |
|
110 |
ELSE |
111 |
C- unrecognized field: |
112 |
iTracer = 0 |
113 |
ENDIF |
114 |
|
115 |
C- unrecognized field or tracer: |
116 |
IF ( iTracer.EQ.0 ) THEN |
117 |
stopFlag = .TRUE. |
118 |
WRITE(msgBuf,'(4A)') 'PTRACERS_CHECK_PICKUP: ', |
119 |
& 'missing field "',missFldList(j),'" not recognized' |
120 |
CALL PRINT_ERROR( msgBuf, myThid ) |
121 |
ENDIF |
122 |
ENDDO |
123 |
|
124 |
IF ( stopFlag ) THEN |
125 |
STOP 'ABNORMAL END: S/R PTRACERS_CHECK_PICKUP' |
126 |
ELSEIF ( pickupStrictlyMatch ) THEN |
127 |
WRITE(msgBuf,'(4A)') 'PTRACERS_CHECK_PICKUP: ', |
128 |
& 'try "pickupStrictlyMatch=.FALSE.,"', |
129 |
& ' in file: "data" (NameList PARM03)' |
130 |
CALL PRINT_ERROR( msgBuf, myThid ) |
131 |
STOP 'ABNORMAL END: S/R PTRACERS_CHECK_PICKUP' |
132 |
ELSEIF ( warnCnts .GT. 0 ) THEN |
133 |
WRITE(msgBuf,'(4A)') '** WARNING ** PTRACERS_CHECK_PICKUP: ', |
134 |
& 'Will get only an approximated Restart' |
135 |
CALL PRINT_MESSAGE( msgBuf, ioUnit, SQUEEZE_RIGHT, myThid ) |
136 |
ENDIF |
137 |
|
138 |
ENDIF |
139 |
|
140 |
_END_MASTER( myThid ) |
141 |
|
142 |
RETURN |
143 |
END |