source: CPL/oasis3/trunk/src/lib/clim/src/CLIM_Parse.F @ 1677

Last change on this file since 1677 was 1677, checked in by aclsce, 12 years ago

Imported oasis3 (tag ipslcm5a) from cvs server to svn server (igcmg project).

File size: 4.6 KB
Line 
1      SUBROUTINE CLIM_Parse (cdarg, cdspawn, kargs, karmax)
2C****
3C               *****************************
4C               * OASIS ROUTINE  -  LEVEL T *
5C               * -------------     ------- *
6C               *****************************
7C
8C**** *parse*  - Parsing routine
9C
10C     Purpose:
11C     -------
12C     parse string cdstr into cdspawn. Blanks are the separators between args.
13C     Each argument is defined as a continuous set of non-blanks characters
14C     the first argument is put into cdspawn(1), the second in cdspawn(2) ...
15C
16C**   Interface:
17C     ---------
18C       *CALL*  *CLIM_Parse (cdarg, cdspawn, kargs, karmax)*
19C
20C     Input:
21C     -----
22C                cdarg   : line to be parsed (char string, including blanks)
23C                karmax  : maximum number of arguments to be found (parameter)
24C
25C     Output:
26C     ------
27C                cdspawn : extracted character strings (possibly blank string)
28C                karg    : number of arguments found (possibly 0)
29C
30C     Workspace:
31C     ---------
32C     None
33C
34C     Externals:
35C     ---------
36C     None
37C
38C     Reference: 
39C     --------- 
40C     See OASIS manual (2000) 
41C 
42C     History:
43C     -------
44C       Version   Programmer     Date      Description
45C       -------   ----------     ----      ----------- 
46C       1.0       J. Latour     00/09/15   created
47C
48C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49C
50C* ---------------------------- Include files ---------------------------
51C
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
56C
57C* ---------------------------- Argument declarations -------------------
58C
59      CHARACTER*80 cdarg
60      INTEGER (kind=ip_intwp_p)      kargs, karmax
61      CHARACTER*24 cdspawn(karmax)
62C
63C* ---------------------------- Local declarations -------------------
64C
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
71C
72C* - Parameter declarations MUST match dimension declarations of cdstr
73C* - and cdspawn
74C
75      CHARACTER (len=1), PARAMETER :: clblank = ' '
76      CHARACTER (len=1), PARAMETER :: clcmt = '#'
77C
78C* ---------------------------- Poema verses ----------------------------
79C
80C %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
81C
82C*    1. Initialize arrays
83C        -----------------
84C
85C* - Transfer cdarg into cdstr
86C
87      DO 100 ji = 1,80
88        cdstr(ji) = cdarg(ji:ji)
89  100 CONTINUE
90C
91C* - Skip line if it is a comment
92C     
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)
102C     
103C* - Fill cdspawn with blanks and kargs with 0
104C
105      DO 210 ji = 1, karmax
106        cdspawn(ji) = clblank
107  210 CONTINUE
108
109      kargs = 0
110      lnewarg = .TRUE.
111C
112C* - 2. Do the extraction work
113C       ----------------------
114C* - Check every character in cdstr, and fill cdspawn with contiguous
115C* - strings of nonblank characters : the arguments.
116C     
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
148C
149C*    3. End of routine
150C        --------------
151C
152#endif
153      RETURN
154      END
Note: See TracBrowser for help on using the repository browser.