1 | SUBROUTINE correct (pfild, ksize, pmcoef, kaux, pacoef, pwork, |
---|
2 | $ kunit, cdfic, cdfld) |
---|
3 | C**** |
---|
4 | C ***************************** |
---|
5 | C * OASIS ROUTINE - LEVEL 3 * |
---|
6 | C * ------------- ------- * |
---|
7 | C ***************************** |
---|
8 | C |
---|
9 | C**** *correct* - Flux correction routine |
---|
10 | C |
---|
11 | C Purpose: |
---|
12 | C ------- |
---|
13 | C Use external data to modify coupling fields |
---|
14 | C |
---|
15 | C** Interface: |
---|
16 | C --------- |
---|
17 | C *CALL* *correct (pfild, ksize, pmcoef, kaux, pacoef, pwork, |
---|
18 | C kunit, cdfic, cdfld)* |
---|
19 | C |
---|
20 | C Input: |
---|
21 | C ----- |
---|
22 | C pfild : field on source grid (real 1D) |
---|
23 | C ksize : size of field array (integer) |
---|
24 | C pmcoef : main field coefficient (real) |
---|
25 | C kaux : number of auxilary fields (integer) |
---|
26 | C pacoef : auxilary field coefficients (real 1D) |
---|
27 | C pwork : temporary array to read auxilary fields (real 1D) |
---|
28 | C kunit : logical unit numbers for data files (INTEGER 1D) |
---|
29 | C cdfic : filenames for external data (character 1D) |
---|
30 | C cdfld : auxilary field names (character 1D) |
---|
31 | C |
---|
32 | C Output: |
---|
33 | C ------ |
---|
34 | C pfild : corrected field on source grid (real 1D) |
---|
35 | C |
---|
36 | C Workspace: |
---|
37 | C --------- |
---|
38 | C None |
---|
39 | C |
---|
40 | C Externals: |
---|
41 | C --------- |
---|
42 | C None |
---|
43 | C |
---|
44 | C Reference: |
---|
45 | C --------- |
---|
46 | C See OASIS manual (1995) |
---|
47 | C |
---|
48 | C History: |
---|
49 | C ------- |
---|
50 | C Version Programmer Date Description |
---|
51 | C ------- ---------- ---- ----------- |
---|
52 | C 2.0 L. Terray 95/10/01 created |
---|
53 | C 2.3 S. Valcke 99/04/30 added: printing levels |
---|
54 | C |
---|
55 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
56 | C |
---|
57 | C* ---------------------------- Include files --------------------------- |
---|
58 | C |
---|
59 | USE mod_kinds_oasis |
---|
60 | USE mod_unit |
---|
61 | USE mod_printing |
---|
62 | C |
---|
63 | C* ---------------------------- Argument declarations ------------------- |
---|
64 | C |
---|
65 | REAL (kind=ip_realwp_p) pfild(ksize), pwork(ksize), pacoef(kaux) |
---|
66 | INTEGER (kind=ip_intwp_p) kunit(kaux) |
---|
67 | CHARACTER*8 cdfic(kaux), cdfld(kaux) |
---|
68 | C |
---|
69 | C* ---------------------------- Local declarations ---------------------- |
---|
70 | C |
---|
71 | CHARACTER*8 clfic |
---|
72 | C |
---|
73 | C* ---------------------------- Poema verses ---------------------------- |
---|
74 | C |
---|
75 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
76 | C |
---|
77 | C* 1. Initialization |
---|
78 | C -------------- |
---|
79 | C |
---|
80 | IF (nlogprt .GE. 2) THEN |
---|
81 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
82 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
83 | WRITE (UNIT = nulou,FMT = *) |
---|
84 | $ ' ROUTINE correct - Level 3' |
---|
85 | WRITE (UNIT = nulou,FMT = *) |
---|
86 | $ ' *************** *******' |
---|
87 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
88 | WRITE (UNIT = nulou,FMT = *) |
---|
89 | $ ' Flux correction with external data' |
---|
90 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
91 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
92 | ENDIF |
---|
93 | C |
---|
94 | C* initialize error flag for I/O routine |
---|
95 | C |
---|
96 | iflag = 0 |
---|
97 | C |
---|
98 | C |
---|
99 | C* 2. Multiply main field by its coefficient |
---|
100 | C -------------------------------------- |
---|
101 | C |
---|
102 | DO 210 ji = 1, ksize |
---|
103 | pfild(ji) = pfild(ji) * pmcoef |
---|
104 | 210 CONTINUE |
---|
105 | C |
---|
106 | C |
---|
107 | C* 3. Read external data and add it to main field |
---|
108 | C ------------------------------------------- |
---|
109 | C |
---|
110 | C* Loop on additional fields |
---|
111 | C |
---|
112 | DO 310 ji = 1, kaux |
---|
113 | C |
---|
114 | C* Flush data files |
---|
115 | C |
---|
116 | iunit = kunit(ji) |
---|
117 | clfic = cdfic(ji) |
---|
118 | CLOSE(UNIT = iunit, ERR = 3010, IOSTAT = ios) |
---|
119 | WRITE(UNIT = nulou, FMT = 3100) iunit, clfic |
---|
120 | 3010 CONTINUE |
---|
121 | IF (ios .NE. 0) THEN |
---|
122 | CALL prtout('WARNING: problem in closing unit', |
---|
123 | $ iunit, 1) |
---|
124 | CALL prtout('Error message number is = ', ios, 1) |
---|
125 | CALL HALTE('STOP in correct') |
---|
126 | ENDIF |
---|
127 | OPEN(UNIT=iunit,FILE=clfic,FORM='UNFORMATTED', |
---|
128 | $ STATUS='UNKNOWN',ERR = 3020, IOSTAT = ios) |
---|
129 | WRITE(UNIT = nulou, FMT = 3200) iunit, clfic |
---|
130 | 3020 CONTINUE |
---|
131 | IF (ios .NE. 0) THEN |
---|
132 | CALL prtout('WARNING: problem in connecting unit', |
---|
133 | $ iunit, 1) |
---|
134 | CALL prtout('Error message number is = ', ios, 1) |
---|
135 | CALL HALTE('STOP in correct') |
---|
136 | ENDIF |
---|
137 | C |
---|
138 | C* Reading of the auxilary fields |
---|
139 | C |
---|
140 | CALL locread (cdfld(ji), pwork, ksize, kunit(ji), iflag) |
---|
141 | C |
---|
142 | C* Checking |
---|
143 | C |
---|
144 | IF (iflag .NE. 0) THEN |
---|
145 | CALL prcout |
---|
146 | $ ('WARNING: problem in reading field', |
---|
147 | $ cdfld(ji), 1) |
---|
148 | CALL prtout |
---|
149 | $ ('Error reading logical unit', kunit(ji), 1) |
---|
150 | CALL prcout |
---|
151 | $ ('It is connected to file',cdfic(ji),1) |
---|
152 | WRITE(UNIT = nulou,FMT = *) |
---|
153 | $ ' If very first iteration and parallel simulation ' |
---|
154 | WRITE(UNIT = nulou,FMT = *) |
---|
155 | $ ' or sequential one starting with atmosphere ' |
---|
156 | WRITE(UNIT = nulou,FMT = *) |
---|
157 | $ ' No file present !! It is normal !! ' |
---|
158 | |
---|
159 | ENDIF |
---|
160 | C |
---|
161 | C* Add to original field |
---|
162 | C |
---|
163 | DO 320 jj = 1, ksize |
---|
164 | pfild(jj) = pfild(jj) + pacoef(ji) * pwork(jj) |
---|
165 | 320 CONTINUE |
---|
166 | 310 CONTINUE |
---|
167 | C |
---|
168 | C* Formats |
---|
169 | C |
---|
170 | 3100 FORMAT(/,5X,' Unit ',I2,' has been disconnected from file ',A8) |
---|
171 | 3200 FORMAT(/,5X,' Unit ',I2,' has been reconnected to file ',A8) |
---|
172 | C |
---|
173 | C |
---|
174 | C* 4. End of routine |
---|
175 | C -------------- |
---|
176 | C |
---|
177 | IF (nlogprt .GE. 2) THEN |
---|
178 | WRITE (UNIT = nulou,FMT = *) ' ' |
---|
179 | WRITE (UNIT = nulou,FMT = *) |
---|
180 | $ ' --------- End of routine correct ---------' |
---|
181 | CALL FLUSH (nulou) |
---|
182 | ENDIF |
---|
183 | RETURN |
---|
184 | END |
---|