/[MITgcm]/MITgcm/eesupp/src/utils.F
ViewVC logotype

Contents of /MITgcm/eesupp/src/utils.F

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


Revision 1.10 - (show annotations) (download)
Sun Feb 4 14:38:44 2001 UTC (23 years, 3 months ago) by cnh
Branch: MAIN
CVS Tags: checkpoint40pre3, checkpoint40pre1, checkpoint40pre7, checkpoint40pre6, checkpoint40pre9, checkpoint40pre8, checkpoint38, checkpoint40pre2, checkpoint40pre4, pre38tag1, c37_adj, pre38-close, checkpoint39, checkpoint37, checkpoint36, checkpoint35, checkpoint40pre5, checkpoint40
Branch point for: pre38
Changes since 1.9: +2 -1 lines
Made sure each .F and .h file had
the CVS keywords Header and Name at its start.
Most had header but very few currently have Name, so
lots of changes!

1 C $Header: /u/gcmpack/models/MITgcmUV/eesupp/src/utils.F,v 1.9 2000/06/21 20:44:06 heimbach Exp $
2 C $Name: $
3
4 #include "CPP_EEOPTIONS.h"
5
6 C-- File utils.F: General purpose support routines
7 C-- Contents
8 C-- U DATE - Returns date and time.
9 C-- IFNBLNK - Returns index of first non-blank string character.
10 C-- ILNBLNK - Returns index of last non-blank string character.
11 C-- IO_ERRCOUNT - Reads IO error counter.
12 C-- LCASE - Translates to lower case.
13 C--UM MACHINE - Returns character string identifying computer.
14 C-- UCASE - Translates to upper case.
15 C-- Routines marked "M" contain specific machine dependent code.
16 C-- Routines marked "U" contain UNIX OS calls.
17
18 CStartOfInterface
19 SUBROUTINE DATE ( string , myThreadId )
20 C /==========================================================\
21 C | SUBROUTINE DATE |
22 C | o Return current date |
23 C \==========================================================/
24 IMPLICIT NONE
25 #include "SIZE.h"
26 #include "EEPARAMS.h"
27 C
28 CHARACTER*(*) string
29 INTEGER myThreadId
30 CEndOfInterface
31 C
32 INTEGER lDate
33 CHARACTER*(MAX_LEN_MBUF) msgBuffer
34 C
35 lDate = 24
36 IF ( LEN(string) .LT. lDate ) GOTO 901
37 string = ' '
38 #ifndef TARGET_T3E
39 #ifndef TARGET_CRAY_VECTOR
40 CALL FDATE( string )
41 #endif
42 #endif
43 C
44 1000 CONTINUE
45 RETURN
46 901 CONTINUE
47 WRITE(msgBuffer,'(A)')
48 &' '
49 CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit,
50 &SQUEEZE_RIGHT,myThreadId)
51 WRITE(msgBuffer,'(A)')
52 &'*** WARNING WARNING WARNING WARNING WARNING WARNING ***'
53 CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit,
54 &SQUEEZE_RIGHT,myThreadId)
55 WRITE(msgBuffer,'(A)')
56 &'procedure: "DATE".'
57 CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit,
58 &SQUEEZE_RIGHT,myThreadId)
59 WRITE(msgBuffer,'(A)')
60 &'Variable passed to S/R DATE is too small.'
61 CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit,
62 &SQUEEZE_RIGHT,myThreadId)
63 WRITE(msgBuffer,'(A)')
64 &' Argument must be at least',lDate,'characters long.'
65 CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit,
66 &SQUEEZE_RIGHT,myThreadId)
67 WRITE(msgBuffer,'(A)')
68 &'*******************************************************'
69 CALL PRINT_MESSAGE(msgBuffer,standardMessageUnit,
70 &SQUEEZE_RIGHT,myThreadId)
71 GOTO 1000
72 END
73
74 CStartOfInterface
75 INTEGER FUNCTION IFNBLNK( string )
76 C /==========================================================\
77 C | FUNCTION IFNBLNK |
78 C | o Find first non-blank in character string. |
79 C \==========================================================/
80 IMPLICIT NONE
81 C
82 CHARACTER*(*) string
83 CEndOfInterface
84 C
85 INTEGER L, LS
86 C
87 LS = LEN(string)
88 IFNBLNK = 0
89 DO 10 L = 1, LS
90 IF ( string(L:L) .EQ. ' ' ) GOTO 10
91 IFNBLNK = L
92 GOTO 11
93 10 CONTINUE
94 11 CONTINUE
95 C
96 RETURN
97 END
98
99 CStartOfInterface
100 INTEGER FUNCTION ILNBLNK( string )
101 C /==========================================================\
102 C | FUNCTION ILNBLNK |
103 C | o Find last non-blank in character string. |
104 C \==========================================================/
105 IMPLICIT NONE
106 CHARACTER*(*) string
107 CEndOfInterface
108 INTEGER L, LS
109 C
110 LS = LEN(string)
111 ILNBLNK = LS
112 DO 10 L = LS, 1, -1
113 IF ( string(L:L) .EQ. ' ' ) GOTO 10
114 ILNBLNK = L
115 GOTO 11
116 10 CONTINUE
117 11 CONTINUE
118 C
119 RETURN
120 END
121
122 CStartofinterface
123 INTEGER FUNCTION IO_ERRCOUNT(myThid)
124 C /==========================================================\
125 C | FUNCTION IO_ERRCOUNT |
126 C | o Reads IO error counter. |
127 C \==========================================================/
128 IMPLICIT NONE
129 C == Global variables ==
130 #include "SIZE.h"
131 #include "EEPARAMS.h"
132
133 C == Routine arguments ==
134 INTEGER myThid
135 CEndofinterface
136
137 IO_ERRCOUNT = ioErrorCount(myThid)
138
139 RETURN
140 END
141
142 CStartOfInterface
143 SUBROUTINE LCASE ( string )
144 C /==========================================================\
145 C | SUBROUTINE LCASE |
146 C | o Convert character string to all lower case. |
147 C \==========================================================/
148 IMPLICIT NONE
149 CHARACTER*(*) string
150 CEndOfInterface
151 CHARACTER*26 LOWER
152 DATA LOWER /'abcdefghijklmnopqrstuvwxyz'/
153 SAVE LOWER
154 CHARACTER*26 UPPER
155 DATA UPPER /'ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
156 SAVE UPPER
157 INTEGER I, L
158 C
159 DO 10 I = 1, LEN(string)
160 L = INDEX(UPPER,string(I:I))
161 IF ( L .EQ. 0 ) GOTO 10
162 string(I:I) = LOWER(L:L)
163 10 CONTINUE
164 C
165 RETURN
166 END
167
168 CStartOfInterface
169 SUBROUTINE MACHINE ( string )
170 C /==========================================================\
171 C | SUBROUTINE MACHINE |
172 C | o Return computer identifier in string. |
173 C \==========================================================/
174 IMPLICIT NONE
175 #include "SIZE.h"
176 #include "EEPARAMS.h"
177 CHARACTER*(*) string
178 CEndOfInterface
179 C
180 INTEGER IFNBLNK
181 INTEGER ILNBLNK
182 EXTERNAL IFNBLNK
183 EXTERNAL ILNBLNK
184 C
185 INTEGER iFirst
186 INTEGER iLast
187 INTEGER iEnd
188 INTEGER iFree
189 INTEGER idSize
190 CHARACTER*1024 strTmp
191 CHARACTER*1024 idString
192
193 strTmp = 'UNKNOWN'
194 iFree = 1
195 idSize = LEN(string)
196 #if (defined (TARGET_T3E) || defined (TARGET_CRAY_VECTOR))
197 IFirst = 0
198 CALL PXFGETENV('USER',iFirst,strTmp,ILast,Iend )
199 #else
200 CALL GETENV('USER',strTmp )
201 #endif
202 IF ( strTmp .NE. ' ' ) THEN
203 iFirst = IFNBLNK(strTmp)
204 iLast = ILNBLNK(strTmp)
205 iEnd = iLast-iFirst+1
206 IF (iEnd .GE. 0 ) THEN
207 idString(iFree:) = strTmp(iFirst:iFirst+iEnd)
208 ENDIF
209 iFree = iFree+iEnd+1
210 IF ( iFree .LE. idSize ) THEN
211 idString(iFree:iFree) = '@'
212 iFree = iFree+1
213 ENDIF
214 ENDIF
215 strTmp = 'UNKNOWN'
216 #if (defined (TARGET_T3E) || defined (TARGET_CRAY_VECTOR))
217 IFirst = 0
218 CALL PXFGETENV('HOST',iFirst,strTmp,ILast,Iend )
219 #else
220 CALL GETENV('HOST',strTmp )
221 #endif
222 IF ( strTmp .NE. ' ' ) THEN
223 iFirst = IFNBLNK(strTmp)
224 iLast = ILNBLNK(strTmp)
225 iEnd = iLast-iFirst+1
226 iEnd = MIN(iEnd,idSize-iFree)
227 iEnd = iEnd-1
228 IF (iEnd .GE. 0 ) THEN
229 idString(iFree:) = strTmp(iFirst:iFirst+iEnd)
230 ENDIF
231 iFree = iFree+iEnd+1
232 ENDIF
233 C
234 string = idString
235 C
236 1000 CONTINUE
237 RETURN
238 END
239 C***********************************************************************
240 SUBROUTINE UCASE ( string )
241 IMPLICIT NONE
242 C Translate string to upper case.
243 CHARACTER*(*) string
244 CHARACTER*26 LOWER
245 DATA LOWER /'abcdefghijklmnopqrstuvwxyz'/
246 SAVE LOWER
247 CHARACTER*26 UPPER
248 DATA UPPER /'ABCDEFGHIJKLMNOPQRSTUVWXYZ'/
249 SAVE UPPER
250 INTEGER I, L
251 C
252 DO 10 I = 1, LEN(string)
253 L = INDEX(LOWER,string(I:I))
254 IF ( L .EQ. 0 ) GOTO 10
255 string(I:I) = UPPER(L:L)
256 10 CONTINUE
257 C
258 RETURN
259 END
260 C************************************************************************

  ViewVC Help
Powered by ViewVC 1.1.22