1 | SUBROUTINE CLIM_Parse (cdarg, cdspawn, kargs, karmax) |
---|
2 | C**** |
---|
3 | C ***************************** |
---|
4 | C * OASIS ROUTINE - LEVEL T * |
---|
5 | C * ------------- ------- * |
---|
6 | C ***************************** |
---|
7 | C |
---|
8 | C**** *parse* - Parsing routine |
---|
9 | C |
---|
10 | C Purpose: |
---|
11 | C ------- |
---|
12 | C parse string cdstr into cdspawn. Blanks are the separators between args. |
---|
13 | C Each argument is defined as a continuous set of non-blanks characters |
---|
14 | C the first argument is put into cdspawn(1), the second in cdspawn(2) ... |
---|
15 | C |
---|
16 | C** Interface: |
---|
17 | C --------- |
---|
18 | C *CALL* *CLIM_Parse (cdarg, cdspawn, kargs, karmax)* |
---|
19 | C |
---|
20 | C Input: |
---|
21 | C ----- |
---|
22 | C cdarg : line to be parsed (char string, including blanks) |
---|
23 | C karmax : maximum number of arguments to be found (parameter) |
---|
24 | C |
---|
25 | C Output: |
---|
26 | C ------ |
---|
27 | C cdspawn : extracted character strings (possibly blank string) |
---|
28 | C karg : number of arguments found (possibly 0) |
---|
29 | C |
---|
30 | C Workspace: |
---|
31 | C --------- |
---|
32 | C None |
---|
33 | C |
---|
34 | C Externals: |
---|
35 | C --------- |
---|
36 | C None |
---|
37 | C |
---|
38 | C Reference: |
---|
39 | C --------- |
---|
40 | C See OASIS manual (2000) |
---|
41 | C |
---|
42 | C History: |
---|
43 | C ------- |
---|
44 | C Version Programmer Date Description |
---|
45 | C ------- ---------- ---- ----------- |
---|
46 | C 1.0 J. Latour 00/09/15 created |
---|
47 | C |
---|
48 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
49 | C |
---|
50 | C* ---------------------------- Include files --------------------------- |
---|
51 | C |
---|
52 | #if defined use_comm_MPI1 || defined use_comm_MPI2 || !defined use_comm_MPI1 && !defined use_comm_MPI2 && !defined use_comm_SIPC && !defined use_comm_GMEM && !defined use_comm_PIPE && !defined use_comm_NONE |
---|
53 | USE mod_kinds_oasis |
---|
54 | USE mod_clim |
---|
55 | USE mod_comclim |
---|
56 | C |
---|
57 | C* ---------------------------- Argument declarations ------------------- |
---|
58 | C |
---|
59 | CHARACTER*80 cdarg |
---|
60 | INTEGER (kind=ip_intwp_p) kargs, karmax |
---|
61 | CHARACTER*24 cdspawn(karmax) |
---|
62 | C |
---|
63 | C* ---------------------------- Local declarations ------------------- |
---|
64 | C |
---|
65 | CHARACTER*1 cdstr |
---|
66 | DIMENSION cdstr(80) |
---|
67 | LOGICAL lnewarg |
---|
68 | INTEGER (kind=ip_intwp_p), PARAMETER :: maxchar=80 |
---|
69 | INTEGER (kind=ip_intwp_p), PARAMETER :: maxarg=24 |
---|
70 | INTEGER (kind=ip_intwp_p) ii, ji, nulin |
---|
71 | C |
---|
72 | C* - Parameter declarations MUST match dimension declarations of cdstr |
---|
73 | C* - and cdspawn |
---|
74 | C |
---|
75 | CHARACTER (len=1), PARAMETER :: clblank = ' ' |
---|
76 | CHARACTER (len=1), PARAMETER :: clcmt = '#' |
---|
77 | C |
---|
78 | C* ---------------------------- Poema verses ---------------------------- |
---|
79 | C |
---|
80 | C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
81 | C |
---|
82 | C* 1. Initialize arrays |
---|
83 | C ----------------- |
---|
84 | C |
---|
85 | C* - Transfer cdarg into cdstr |
---|
86 | C |
---|
87 | DO 100 ji = 1,80 |
---|
88 | cdstr(ji) = cdarg(ji:ji) |
---|
89 | 100 CONTINUE |
---|
90 | C |
---|
91 | C* - Skip line if it is a comment |
---|
92 | C |
---|
93 | nulin=99 |
---|
94 | 110 IF (cdstr(1) .NE. clcmt) GO TO 130 |
---|
95 | READ (UNIT = nulin, FMT = 1001) cdarg |
---|
96 | DO 120 ji = 1, 80 |
---|
97 | cdstr(ji) = cdarg(ji:ji) |
---|
98 | 120 CONTINUE |
---|
99 | GO TO 110 |
---|
100 | 130 CONTINUE |
---|
101 | 1001 FORMAT(A80) |
---|
102 | C |
---|
103 | C* - Fill cdspawn with blanks and kargs with 0 |
---|
104 | C |
---|
105 | DO 210 ji = 1, karmax |
---|
106 | cdspawn(ji) = clblank |
---|
107 | 210 CONTINUE |
---|
108 | |
---|
109 | kargs = 0 |
---|
110 | lnewarg = .TRUE. |
---|
111 | C |
---|
112 | C* - 2. Do the extraction work |
---|
113 | C ---------------------- |
---|
114 | C* - Check every character in cdstr, and fill cdspawn with contiguous |
---|
115 | C* - strings of nonblank characters : the arguments. |
---|
116 | C |
---|
117 | DO 220 ji = 1, maxchar |
---|
118 | IF ( cdstr(ji) .NE. clblank ) THEN |
---|
119 | IF ( lnewarg ) THEN |
---|
120 | kargs = kargs + 1 |
---|
121 | IF ( kargs .GT. karmax ) THEN |
---|
122 | WRITE (UNIT = nulprt,FMT = *) |
---|
123 | $ ' Too many arguments in list passed to model' |
---|
124 | WRITE (UNIT = nulprt,FMT = *) |
---|
125 | $ ' We STOP!!! Check the file namcouple' |
---|
126 | CALL flush(nulprt) |
---|
127 | CALL halte('STOP in CLIM_Parse.f') |
---|
128 | ENDIF |
---|
129 | ii = 1 |
---|
130 | cdspawn(kargs)(ii:ii) = cdstr(ji) |
---|
131 | lnewarg = .FALSE. |
---|
132 | ELSE |
---|
133 | ii = ii+1 |
---|
134 | IF ( ii .GT. maxarg ) THEN |
---|
135 | WRITE (UNIT = nulprt,FMT = *) |
---|
136 | $ ' Too many characters in argument passed to model' |
---|
137 | WRITE (UNIT = nulprt,FMT = *) |
---|
138 | $ ' We STOP!!! Check the file namcouple' |
---|
139 | CALL flush(nulprt) |
---|
140 | CALL halte('STOP in CLIM_Parse.f') |
---|
141 | ENDIF |
---|
142 | cdspawn(kargs)(ii:ii) = cdstr(ji) |
---|
143 | ENDIF |
---|
144 | ELSE |
---|
145 | lnewarg = .TRUE. |
---|
146 | ENDIF |
---|
147 | 220 CONTINUE |
---|
148 | C |
---|
149 | C* 3. End of routine |
---|
150 | C -------------- |
---|
151 | C |
---|
152 | #endif |
---|
153 | RETURN |
---|
154 | END |
---|