| 1 |
C $Header: /u/gcmpack/MITgcm/pkg/mnc/mnc_cwrapper.F,v 1.34 2009/06/28 01:08:25 jmc Exp $ |
| 2 |
C $Name: $ |
| 3 |
|
| 4 |
#include "MNC_OPTIONS.h" |
| 5 |
|
| 6 |
C-- File mnc_cwrapper.F: |
| 7 |
C-- Contents |
| 8 |
C-- o MNC_CW_ADD_GNAME |
| 9 |
C-- o MNC_CW_DEL_GNAME |
| 10 |
C-- o MNC_CW_DUMP |
| 11 |
C-- o MNC_CW_APPEND_VNAME |
| 12 |
C-- o MNC_CW_ADD_VNAME |
| 13 |
C-- o MNC_CW_DEL_VNAME |
| 14 |
C-- o MNC_CW_ADD_VATTR_TEXT |
| 15 |
C-- o MNC_CW_ADD_VATTR_INT |
| 16 |
C-- o MNC_CW_ADD_VATTR_DBL |
| 17 |
C-- o MNC_CW_ADD_VATTR_ANY |
| 18 |
C-- o MNC_CW_GET_TILE_NUM |
| 19 |
C-- o MNC_CW_GET_FACE_NUM |
| 20 |
C-- o MNC_CW_GET_XYFO |
| 21 |
C-- o MNC_CW_FILE_AORC |
| 22 |
|
| 23 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 24 |
CBOP 0 |
| 25 |
C !ROUTINE: MNC_CW_ADD_GNAME |
| 26 |
|
| 27 |
C !INTERFACE: |
| 28 |
SUBROUTINE MNC_CW_ADD_GNAME( |
| 29 |
I name, |
| 30 |
I ndim, |
| 31 |
I dlens, |
| 32 |
I dnames, |
| 33 |
I inds_beg, inds_end, |
| 34 |
I myThid ) |
| 35 |
|
| 36 |
C !DESCRIPTION: |
| 37 |
C Add a grid name to the MNC convenience wrapper layer. |
| 38 |
|
| 39 |
C !USES: |
| 40 |
implicit none |
| 41 |
#include "MNC_COMMON.h" |
| 42 |
#include "EEPARAMS.h" |
| 43 |
|
| 44 |
C !INPUT PARAMETERS: |
| 45 |
integer myThid, ndim |
| 46 |
character*(*) name |
| 47 |
integer dlens(*), inds_beg(*), inds_end(*) |
| 48 |
character*(*) dnames(*) |
| 49 |
CEOP |
| 50 |
|
| 51 |
C !LOCAL VARIABLES: |
| 52 |
integer i, nnf,nnl, indg |
| 53 |
character*(MAX_LEN_MBUF) msgbuf |
| 54 |
|
| 55 |
C Functions |
| 56 |
integer IFNBLNK, ILNBLNK |
| 57 |
|
| 58 |
nnf = IFNBLNK(name) |
| 59 |
nnl = ILNBLNK(name) |
| 60 |
|
| 61 |
C Check that this name is not already defined |
| 62 |
CALL MNC_GET_IND(MNC_MAX_ID, name, mnc_cw_gname, indg, myThid) |
| 63 |
IF (indg .GT. 0) THEN |
| 64 |
write(msgbuf,'(3a)') 'MNC_CW_ADD_GNAME ERROR: ''', name, |
| 65 |
& ''' is already defined' |
| 66 |
CALL print_error(msgbuf, mythid) |
| 67 |
stop 'ABNORMAL END: S/R MNC_CW_ADD_GNAME' |
| 68 |
ENDIF |
| 69 |
CALL MNC_GET_NEXT_EMPTY_IND(MNC_MAX_ID, mnc_cw_gname, |
| 70 |
& 'mnc_cw_gname', indg, myThid) |
| 71 |
|
| 72 |
mnc_cw_gname(indg)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
| 73 |
mnc_cw_gname(indg)(1:(nnl-nnf+1)) = name(nnf:nnl) |
| 74 |
mnc_cw_ndim(indg) = ndim |
| 75 |
|
| 76 |
DO i = 1,ndim |
| 77 |
mnc_cw_dn(i,indg)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
| 78 |
nnf = IFNBLNK(dnames(i)) |
| 79 |
nnl = ILNBLNK(dnames(i)) |
| 80 |
mnc_cw_dn(i,indg)(1:(nnl-nnf+1)) = dnames(i)(nnf:nnl) |
| 81 |
mnc_cw_dims(i,indg) = dlens(i) |
| 82 |
mnc_cw_is(i,indg) = inds_beg(i) |
| 83 |
mnc_cw_ie(i,indg) = inds_end(i) |
| 84 |
ENDDO |
| 85 |
|
| 86 |
RETURN |
| 87 |
END |
| 88 |
|
| 89 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 90 |
CBOP 0 |
| 91 |
C !ROUTINE: MNC_CW_DEL_GNAME |
| 92 |
|
| 93 |
C !INTERFACE: |
| 94 |
SUBROUTINE MNC_CW_DEL_GNAME( |
| 95 |
I name, |
| 96 |
I myThid ) |
| 97 |
|
| 98 |
C !DESCRIPTION: |
| 99 |
C Delete a grid name from the MNC convenience wrapper layer. |
| 100 |
|
| 101 |
C !USES: |
| 102 |
implicit none |
| 103 |
#include "MNC_COMMON.h" |
| 104 |
#include "EEPARAMS.h" |
| 105 |
|
| 106 |
C !INPUT PARAMETERS: |
| 107 |
integer myThid |
| 108 |
character*(*) name |
| 109 |
CEOP |
| 110 |
|
| 111 |
C !LOCAL VARIABLES: |
| 112 |
integer nnf,nnl, indg |
| 113 |
|
| 114 |
C Functions |
| 115 |
integer IFNBLNK, ILNBLNK |
| 116 |
|
| 117 |
nnf = IFNBLNK(name) |
| 118 |
nnl = ILNBLNK(name) |
| 119 |
|
| 120 |
C Check that this name is not already defined |
| 121 |
CALL MNC_GET_IND(MNC_MAX_ID, name, mnc_cw_gname, indg, myThid) |
| 122 |
IF (indg .LT. 1) THEN |
| 123 |
RETURN |
| 124 |
ENDIF |
| 125 |
|
| 126 |
mnc_cw_gname(indg)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
| 127 |
mnc_cw_ndim(indg) = 0 |
| 128 |
|
| 129 |
RETURN |
| 130 |
END |
| 131 |
|
| 132 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 133 |
CBOP 1 |
| 134 |
C !ROUTINE: MNC_CW_DUMP |
| 135 |
|
| 136 |
C !INTERFACE: |
| 137 |
SUBROUTINE MNC_CW_DUMP( myThid ) |
| 138 |
|
| 139 |
C !DESCRIPTION: |
| 140 |
C Write a condensed view of the current state of the MNC look-up |
| 141 |
C tables for the convenience wrapper section. |
| 142 |
|
| 143 |
C !USES: |
| 144 |
implicit none |
| 145 |
#include "MNC_COMMON.h" |
| 146 |
#include "SIZE.h" |
| 147 |
#include "EEPARAMS.h" |
| 148 |
#include "PARAMS.h" |
| 149 |
|
| 150 |
C !INPUT PARAMETERS: |
| 151 |
integer myThid |
| 152 |
CEOP |
| 153 |
|
| 154 |
C !LOCAL VARIABLES: |
| 155 |
integer i,j, ntot |
| 156 |
integer NBLNK |
| 157 |
parameter ( NBLNK = 150 ) |
| 158 |
character s1*(NBLNK), blnk*(NBLNK) |
| 159 |
|
| 160 |
_BEGIN_MASTER(myThid) |
| 161 |
|
| 162 |
DO i = 1,NBLNK |
| 163 |
blnk(i:i) = ' ' |
| 164 |
ENDDO |
| 165 |
|
| 166 |
s1(1:NBLNK) = blnk(1:NBLNK) |
| 167 |
write(s1,'(a5,a)') 'MNC: ', |
| 168 |
& 'The currently defined Grid Types are:' |
| 169 |
CALL PRINT_MESSAGE( |
| 170 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
| 171 |
ntot = 0 |
| 172 |
DO j = 1,MNC_MAX_ID |
| 173 |
IF (mnc_cw_gname(j)(1:MNC_MAX_CHAR) |
| 174 |
& .NE. mnc_blank_name(1:MNC_MAX_CHAR)) THEN |
| 175 |
|
| 176 |
ntot = ntot + 1 |
| 177 |
s1(1:NBLNK) = blnk(1:NBLNK) |
| 178 |
write(s1,'(a5,2i5,a3,a20,i3,a3,5i4,a4,5i4,a4,5i4,6a8)') |
| 179 |
& 'MNC: ', |
| 180 |
& j, ntot, ' : ', mnc_cw_gname(j)(1:20), mnc_cw_ndim(j), |
| 181 |
& ' : ', (mnc_cw_dims(i,j), i=1,5), |
| 182 |
& ' | ', (mnc_cw_is(i,j), i=1,5), |
| 183 |
& ' | ', (mnc_cw_ie(i,j), i=1,5), |
| 184 |
& ' | ', (mnc_cw_dn(i,j)(1:7), i=1,5) |
| 185 |
CALL PRINT_MESSAGE( |
| 186 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
| 187 |
|
| 188 |
ENDIF |
| 189 |
ENDDO |
| 190 |
|
| 191 |
s1(1:NBLNK) = blnk(1:NBLNK) |
| 192 |
write(s1,'(a5,a)') 'MNC: ', |
| 193 |
& 'The currently defined Variable Types are:' |
| 194 |
CALL PRINT_MESSAGE( |
| 195 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
| 196 |
ntot = 0 |
| 197 |
DO j = 1,MNC_MAX_ID |
| 198 |
IF (mnc_cw_vname(j)(1:MNC_MAX_CHAR) |
| 199 |
& .NE. mnc_blank_name(1:MNC_MAX_CHAR)) THEN |
| 200 |
|
| 201 |
ntot = ntot + 1 |
| 202 |
s1(1:NBLNK) = blnk(1:NBLNK) |
| 203 |
write(s1,'(a5,2i5,a3,a25,a3,i4)') 'MNC: ', |
| 204 |
& j, ntot, ' | ', |
| 205 |
& mnc_cw_vname(j)(1:20), ' | ', mnc_cw_vgind(j) |
| 206 |
CALL PRINT_MESSAGE( |
| 207 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
| 208 |
|
| 209 |
DO i = 1,mnc_cw_vnat(1,j) |
| 210 |
s1(1:NBLNK) = blnk(1:NBLNK) |
| 211 |
write(s1,'(a5,a14,i4,a3,a25,a3,a55)') |
| 212 |
& 'MNC: ',' text_at:',i, |
| 213 |
& ' : ', mnc_cw_vtnm(i,j)(1:25), ' : ', |
| 214 |
& mnc_cw_vtat(i,j)(1:MNC_MAX_CHAR) |
| 215 |
CALL PRINT_MESSAGE( |
| 216 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
| 217 |
ENDDO |
| 218 |
DO i = 1,mnc_cw_vnat(2,j) |
| 219 |
s1(1:NBLNK) = blnk(1:NBLNK) |
| 220 |
write(s1,'(a5,a14,i4,a3,a25,a3,i20)') |
| 221 |
& 'MNC: ',' int__at:',i, |
| 222 |
& ' : ', mnc_cw_vinm(i,j)(1:25), ' : ', |
| 223 |
& mnc_cw_viat(i,j) |
| 224 |
CALL PRINT_MESSAGE( |
| 225 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
| 226 |
ENDDO |
| 227 |
DO i = 1,mnc_cw_vnat(3,j) |
| 228 |
s1(1:NBLNK) = blnk(1:NBLNK) |
| 229 |
write(s1,'(a5,a14,i4,a3,a25,a3,f25.10)') |
| 230 |
& 'MNC: ',' dbl__at:',i, |
| 231 |
& ' : ', mnc_cw_vdnm(i,j)(1:25), ' : ', |
| 232 |
& mnc_cw_vdat(i,j) |
| 233 |
CALL PRINT_MESSAGE( |
| 234 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
| 235 |
ENDDO |
| 236 |
|
| 237 |
ENDIF |
| 238 |
ENDDO |
| 239 |
IF (ntot .EQ. 0) THEN |
| 240 |
s1(1:NBLNK) = blnk(1:NBLNK) |
| 241 |
write(s1,'(a)') 'MNC: None defined!' |
| 242 |
CALL PRINT_MESSAGE( |
| 243 |
& s1, standardMessageUnit, SQUEEZE_RIGHT, mythid) |
| 244 |
ENDIF |
| 245 |
|
| 246 |
_END_MASTER(myThid) |
| 247 |
|
| 248 |
RETURN |
| 249 |
END |
| 250 |
|
| 251 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 252 |
CBOP 0 |
| 253 |
C !ROUTINE: MNC_CW_APPEND_VNAME |
| 254 |
|
| 255 |
C !INTERFACE: |
| 256 |
SUBROUTINE MNC_CW_APPEND_VNAME( |
| 257 |
I vname, |
| 258 |
I gname, |
| 259 |
I bi_dim, bj_dim, |
| 260 |
I myThid ) |
| 261 |
|
| 262 |
C !DESCRIPTION: |
| 263 |
C If it is not yet defined within the MNC CW layer, append a |
| 264 |
C variable type. Calls MNC\_CW\_ADD\_VNAME(). |
| 265 |
|
| 266 |
C !USES: |
| 267 |
implicit none |
| 268 |
#include "MNC_COMMON.h" |
| 269 |
|
| 270 |
C !INPUT PARAMETERS: |
| 271 |
integer myThid, bi_dim, bj_dim |
| 272 |
character*(*) vname, gname |
| 273 |
CEOP |
| 274 |
|
| 275 |
C !LOCAL VARIABLES: |
| 276 |
integer indv |
| 277 |
|
| 278 |
C Check whether vname is defined |
| 279 |
CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid) |
| 280 |
IF (indv .LT. 1) THEN |
| 281 |
CALL MNC_CW_ADD_VNAME(vname, gname, bi_dim, bj_dim, myThid) |
| 282 |
ENDIF |
| 283 |
|
| 284 |
|
| 285 |
RETURN |
| 286 |
END |
| 287 |
|
| 288 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 289 |
CBOP 0 |
| 290 |
C !ROUTINE: MNC_CW_ADD_VNAME |
| 291 |
|
| 292 |
C !INTERFACE: |
| 293 |
SUBROUTINE MNC_CW_ADD_VNAME( |
| 294 |
I vname, |
| 295 |
I gname, |
| 296 |
I bi_dim, bj_dim, |
| 297 |
I myThid ) |
| 298 |
|
| 299 |
C !DESCRIPTION: |
| 300 |
C Add a variable type to the MNC CW layer. The variable type is an |
| 301 |
C association between a variable type name and the following items: |
| 302 |
C \begin{center} |
| 303 |
C \begin{tabular}[h]{|ll|}\hline |
| 304 |
C \textbf{Item} & \textbf{Purpose} \\\hline |
| 305 |
C grid type & defines the in-memory arrangement \\ |
| 306 |
C \texttt{bi,bj} dimensions & tiling indices, if present \\\hline |
| 307 |
C \end{tabular} |
| 308 |
C \end{center} |
| 309 |
|
| 310 |
C !USES: |
| 311 |
implicit none |
| 312 |
#include "MNC_COMMON.h" |
| 313 |
#include "EEPARAMS.h" |
| 314 |
|
| 315 |
C !INPUT PARAMETERS: |
| 316 |
integer myThid, bi_dim, bj_dim |
| 317 |
character*(*) vname, gname |
| 318 |
CEOP |
| 319 |
|
| 320 |
C !LOCAL VARIABLES: |
| 321 |
integer i, nvf,nvl, ngf,ngl, indv,indg |
| 322 |
character*(MAX_LEN_MBUF) msgbuf |
| 323 |
|
| 324 |
C Functions |
| 325 |
integer IFNBLNK, ILNBLNK |
| 326 |
|
| 327 |
nvf = IFNBLNK(vname) |
| 328 |
nvl = ILNBLNK(vname) |
| 329 |
ngf = IFNBLNK(gname) |
| 330 |
ngl = ILNBLNK(gname) |
| 331 |
|
| 332 |
C Check that this vname is not already defined |
| 333 |
CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid) |
| 334 |
IF (indv .GT. 0) THEN |
| 335 |
write(msgbuf,'(3a)') 'MNC_CW_ADD_VNAME ERROR: ''', |
| 336 |
& vname(nvf:nvl), ''' is already defined' |
| 337 |
CALL print_error(msgbuf, mythid) |
| 338 |
stop 'ABNORMAL END: S/R MNC_CW_ADD_VNAME' |
| 339 |
ENDIF |
| 340 |
CALL MNC_GET_NEXT_EMPTY_IND(MNC_MAX_ID, mnc_cw_vname, |
| 341 |
& 'mnc_cw_vname', indv, myThid) |
| 342 |
|
| 343 |
C Check that gname exists |
| 344 |
CALL MNC_GET_IND(MNC_MAX_ID, gname, mnc_cw_gname, indg, myThid) |
| 345 |
IF (indg .LT. 1) THEN |
| 346 |
write(msgbuf,'(3a)') 'MNC_CW_ADD_VNAME ERROR: ''', |
| 347 |
& gname(ngf:ngl), ''' is not defined' |
| 348 |
CALL print_error(msgbuf, mythid) |
| 349 |
stop 'ABNORMAL END: S/R MNC_CW_ADD_VNAME' |
| 350 |
ENDIF |
| 351 |
|
| 352 |
mnc_cw_vname(indv)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
| 353 |
mnc_cw_vname(indv)(1:(nvl-nvf+1)) = vname(nvf:nvl) |
| 354 |
mnc_cw_vgind(indv) = indg |
| 355 |
DO i = 1,3 |
| 356 |
mnc_cw_vnat(i,indv) = 0 |
| 357 |
ENDDO |
| 358 |
mnc_cw_vbij(1,indv) = bi_dim |
| 359 |
mnc_cw_vbij(2,indv) = bj_dim |
| 360 |
|
| 361 |
#ifdef MNC_DEBUG_GTYPE |
| 362 |
CALL MNC_CW_ADD_VATTR_TEXT(vname,1,'mitgcm_grid',gname, myThid) |
| 363 |
#endif |
| 364 |
|
| 365 |
RETURN |
| 366 |
END |
| 367 |
|
| 368 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 369 |
CBOP 0 |
| 370 |
C !ROUTINE: MNC_CW_DEL_VNAME |
| 371 |
|
| 372 |
C !INTERFACE: |
| 373 |
SUBROUTINE MNC_CW_DEL_VNAME( |
| 374 |
I vname, |
| 375 |
I myThid ) |
| 376 |
|
| 377 |
C !DESCRIPTION: |
| 378 |
C Delete a variable type from the MNC CW layer. |
| 379 |
|
| 380 |
C !USES: |
| 381 |
implicit none |
| 382 |
#include "MNC_COMMON.h" |
| 383 |
#include "EEPARAMS.h" |
| 384 |
|
| 385 |
C !INPUT PARAMETERS: |
| 386 |
integer myThid |
| 387 |
character*(*) vname |
| 388 |
CEOP |
| 389 |
|
| 390 |
C !LOCAL VARIABLES: |
| 391 |
integer i, indv |
| 392 |
|
| 393 |
C Check that this vname is not already defined |
| 394 |
CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid) |
| 395 |
IF (indv .LT. 1) THEN |
| 396 |
RETURN |
| 397 |
ENDIF |
| 398 |
|
| 399 |
mnc_cw_vname(indv)(1:MNC_MAX_CHAR)=mnc_blank_name(1:MNC_MAX_CHAR) |
| 400 |
mnc_cw_vgind(indv) = 0 |
| 401 |
DO i = 1,3 |
| 402 |
mnc_cw_vnat(i,indv) = 0 |
| 403 |
ENDDO |
| 404 |
|
| 405 |
RETURN |
| 406 |
END |
| 407 |
|
| 408 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 409 |
CBOP |
| 410 |
C !ROUTINE: MNC_CW_ADD_VATTR_TEXT |
| 411 |
C !INTERFACE: |
| 412 |
SUBROUTINE MNC_CW_ADD_VATTR_TEXT( |
| 413 |
I vname, tname, tval, |
| 414 |
I myThid ) |
| 415 |
|
| 416 |
C !DESCRIPTION: |
| 417 |
C Add a text attribute |
| 418 |
|
| 419 |
C !USES: |
| 420 |
implicit none |
| 421 |
|
| 422 |
C !INPUT PARAMETERS: |
| 423 |
integer myThid |
| 424 |
character*(*) vname, tname, tval |
| 425 |
integer ival |
| 426 |
REAL*8 dval |
| 427 |
CEOP |
| 428 |
ival = 0 |
| 429 |
dval = 0.0D0 |
| 430 |
CALL MNC_CW_ADD_VATTR_ANY(vname, 1, |
| 431 |
& tname, ' ', ' ', tval, ival, dval, myThid ) |
| 432 |
RETURN |
| 433 |
END |
| 434 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 435 |
CBOP |
| 436 |
C !ROUTINE: MNC_CW_ADD_VATTR_INT |
| 437 |
C !INTERFACE: |
| 438 |
SUBROUTINE MNC_CW_ADD_VATTR_INT( |
| 439 |
I vname, iname, ival, |
| 440 |
I myThid ) |
| 441 |
|
| 442 |
C !DESCRIPTION: |
| 443 |
C Add integer attribute |
| 444 |
|
| 445 |
C !USES: |
| 446 |
implicit none |
| 447 |
|
| 448 |
C !INPUT PARAMETERS: |
| 449 |
integer myThid |
| 450 |
character*(*) vname, iname |
| 451 |
integer ival |
| 452 |
REAL*8 dval |
| 453 |
CEOP |
| 454 |
dval = 0.0D0 |
| 455 |
CALL MNC_CW_ADD_VATTR_ANY(vname, 2, |
| 456 |
& ' ', iname, ' ', ' ', ival, dval, myThid ) |
| 457 |
RETURN |
| 458 |
END |
| 459 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 460 |
CBOP |
| 461 |
C !ROUTINE: MNC_CW_ADD_VATTR_DBL |
| 462 |
C !INTERFACE: |
| 463 |
SUBROUTINE MNC_CW_ADD_VATTR_DBL( |
| 464 |
I vname, dname, dval, |
| 465 |
I myThid ) |
| 466 |
|
| 467 |
C !DESCRIPTION: |
| 468 |
C Add double-precision real attribute |
| 469 |
|
| 470 |
C !USES: |
| 471 |
implicit none |
| 472 |
|
| 473 |
C !INPUT PARAMETERS: |
| 474 |
integer myThid |
| 475 |
character*(*) vname, dname |
| 476 |
integer ival |
| 477 |
REAL*8 dval |
| 478 |
CEOP |
| 479 |
ival = 0 |
| 480 |
CALL MNC_CW_ADD_VATTR_ANY(vname, 3, |
| 481 |
& ' ', ' ', dname, ' ', ival, dval, myThid ) |
| 482 |
RETURN |
| 483 |
END |
| 484 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 485 |
CBOP 1 |
| 486 |
C !ROUTINE: MNC_CW_ADD_VATTR_ANY |
| 487 |
|
| 488 |
C !INTERFACE: |
| 489 |
SUBROUTINE MNC_CW_ADD_VATTR_ANY( |
| 490 |
I vname, |
| 491 |
I atype, |
| 492 |
I tname, iname, dname, |
| 493 |
I tval, ival, dval, |
| 494 |
I myThid ) |
| 495 |
|
| 496 |
C !DESCRIPTION: |
| 497 |
|
| 498 |
C !USES: |
| 499 |
implicit none |
| 500 |
#include "MNC_COMMON.h" |
| 501 |
#include "EEPARAMS.h" |
| 502 |
|
| 503 |
C !INPUT PARAMETERS: |
| 504 |
integer myThid |
| 505 |
integer atype |
| 506 |
character*(*) vname |
| 507 |
character*(*) tname, iname, dname |
| 508 |
character*(*) tval |
| 509 |
integer ival |
| 510 |
REAL*8 dval |
| 511 |
CEOP |
| 512 |
|
| 513 |
C !LOCAL VARIABLES: |
| 514 |
integer n, nvf,nvl, n1,n2, indv, ic |
| 515 |
character*(MAX_LEN_MBUF) msgbuf |
| 516 |
|
| 517 |
C Functions |
| 518 |
integer IFNBLNK, ILNBLNK |
| 519 |
|
| 520 |
nvf = IFNBLNK(vname) |
| 521 |
nvl = ILNBLNK(vname) |
| 522 |
|
| 523 |
C Check that vname is defined |
| 524 |
CALL MNC_GET_IND(MNC_MAX_ID, vname, mnc_cw_vname, indv, myThid) |
| 525 |
IF (indv .LT. 1) THEN |
| 526 |
write(msgbuf,'(3a)') 'MNC_CW_ADD_VATTR_ANY ERROR: ''', |
| 527 |
& vname(nvf:nvl), ''' is not defined' |
| 528 |
CALL print_error(msgbuf, mythid) |
| 529 |
stop 'ABNORMAL END: S/R MNC_CW_ADD_VATTR_ANY' |
| 530 |
ENDIF |
| 531 |
|
| 532 |
IF (atype .EQ. 1) THEN |
| 533 |
C Text Attribute |
| 534 |
n = mnc_cw_vnat(1,indv) + 1 |
| 535 |
n1 = IFNBLNK(tname) |
| 536 |
n2 = ILNBLNK(tname) |
| 537 |
IF ((n2-n1+1) .GT. MNC_MAX_CHAR) THEN |
| 538 |
write(msgbuf,'(3a,i6,2a)') |
| 539 |
& 'MNC_CW_ADD_VATTR_ANY WARNING: attribute name ''', |
| 540 |
& tname(n1:n2), ''' has more than ', MNC_MAX_CHAR, |
| 541 |
& ' characters and has been truncated to fit--please', |
| 542 |
& 'use a smaller name or increase MNC_MAX_CHAR' |
| 543 |
CALL PRINT_MESSAGE( msgbuf, errorMessageUnit, |
| 544 |
& SQUEEZE_RIGHT , myThid) |
| 545 |
C MNC_MAX_CHAR = n2 - n1 + 1 |
| 546 |
n2 = MNC_MAX_CHAR + n1 - 1 |
| 547 |
ENDIF |
| 548 |
C write(*,*) atype,tname(n1:n2) |
| 549 |
mnc_cw_vtnm(n,indv)(1:MNC_MAX_CHAR) = |
| 550 |
& mnc_blank_name(1:MNC_MAX_CHAR) |
| 551 |
mnc_cw_vtnm(n,indv)(1:(n2-n1+1)) = tname(n1:n2) |
| 552 |
|
| 553 |
n1 = IFNBLNK(tval) |
| 554 |
n2 = ILNBLNK(tval) |
| 555 |
IF ((n2-n1+1) .GT. MNC_MAX_CATT) THEN |
| 556 |
write(msgbuf,'(3a,i6,2a)') |
| 557 |
& 'MNC_CW_ADD_VATTR_ANY WARNING: attribute value ''', |
| 558 |
& tval(n1:n2), ''' has more than ', MNC_MAX_CATT, |
| 559 |
& ' characters and has been truncated to fit--please', |
| 560 |
& 'use a smaller name or increase MNC_MAX_CATT' |
| 561 |
CALL PRINT_MESSAGE( msgbuf, errorMessageUnit, |
| 562 |
& SQUEEZE_RIGHT , myThid) |
| 563 |
n2 = MNC_MAX_CATT + n1 - 1 |
| 564 |
ENDIF |
| 565 |
|
| 566 |
mnc_cw_vnat(1,indv) = n |
| 567 |
DO ic = 1,MNC_MAX_CATT |
| 568 |
mnc_cw_vtat(n,indv)(ic:ic) = ' ' |
| 569 |
ENDDO |
| 570 |
IF ((n1 .NE. 0) .AND. (n2 .NE. 0)) THEN |
| 571 |
mnc_cw_vtat(n,indv)(1:(n2-n1+1)) = tval(n1:n2) |
| 572 |
ENDIF |
| 573 |
ENDIF |
| 574 |
|
| 575 |
IF (atype .EQ. 2) THEN |
| 576 |
C Integer Attribute |
| 577 |
n = mnc_cw_vnat(2,indv) + 1 |
| 578 |
n1 = IFNBLNK(iname) |
| 579 |
n2 = ILNBLNK(iname) |
| 580 |
C write(*,*) atype,iname(n1:n2) |
| 581 |
mnc_cw_vinm(n,indv)(1:(n2-n1+1)) = iname(n1:n2) |
| 582 |
mnc_cw_viat(n,indv) = ival |
| 583 |
mnc_cw_vnat(2,indv) = n |
| 584 |
ENDIF |
| 585 |
|
| 586 |
IF (atype .EQ. 3) THEN |
| 587 |
C Double Attribute |
| 588 |
n = mnc_cw_vnat(3,indv) + 1 |
| 589 |
n1 = IFNBLNK(dname) |
| 590 |
n2 = ILNBLNK(dname) |
| 591 |
C write(*,*) atype,dname(n1:n2) |
| 592 |
mnc_cw_vdnm(n,indv)(1:(n2-n1+1)) = dname(n1:n2) |
| 593 |
mnc_cw_vdat(n,indv) = dval |
| 594 |
mnc_cw_vnat(3,indv) = n |
| 595 |
ENDIF |
| 596 |
|
| 597 |
RETURN |
| 598 |
END |
| 599 |
|
| 600 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 601 |
CBOP 1 |
| 602 |
C !ROUTINE: MNC_CW_GET_TILE_NUM |
| 603 |
|
| 604 |
C !INTERFACE: |
| 605 |
SUBROUTINE MNC_CW_GET_TILE_NUM( |
| 606 |
I bi, bj, |
| 607 |
O uniq_tnum, |
| 608 |
I myThid ) |
| 609 |
|
| 610 |
C !DESCRIPTION: |
| 611 |
|
| 612 |
C !USES: |
| 613 |
implicit none |
| 614 |
#include "EEPARAMS.h" |
| 615 |
#include "SIZE.h" |
| 616 |
#ifdef ALLOW_EXCH2 |
| 617 |
#include "W2_EXCH2_SIZE.h" |
| 618 |
#include "W2_EXCH2_TOPOLOGY.h" |
| 619 |
#endif |
| 620 |
|
| 621 |
C !INPUT PARAMETERS: |
| 622 |
integer myThid, bi,bj, uniq_tnum |
| 623 |
CEOP |
| 624 |
|
| 625 |
C !LOCAL VARIABLES: |
| 626 |
integer iG,jG |
| 627 |
|
| 628 |
iG = 0 |
| 629 |
jG = 0 |
| 630 |
|
| 631 |
#ifdef ALLOW_EXCH2 |
| 632 |
|
| 633 |
uniq_tnum = W2_myTileList(bi,bj) |
| 634 |
|
| 635 |
#else |
| 636 |
|
| 637 |
C Global tile number for simple (non-cube) domains |
| 638 |
iG = bi+(myXGlobalLo-1)/sNx |
| 639 |
jG = bj+(myYGlobalLo-1)/sNy |
| 640 |
|
| 641 |
uniq_tnum = (jG - 1)*(nPx*nSx) + iG |
| 642 |
|
| 643 |
#endif |
| 644 |
|
| 645 |
CEH3 write(*,*) 'iG,jG,uniq_tnum :', iG,jG,uniq_tnum |
| 646 |
|
| 647 |
RETURN |
| 648 |
END |
| 649 |
|
| 650 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 651 |
CBOP 1 |
| 652 |
C !ROUTINE: MNC_CW_GET_FACE_NUM |
| 653 |
|
| 654 |
C !INTERFACE: |
| 655 |
SUBROUTINE MNC_CW_GET_FACE_NUM( |
| 656 |
I bi, bj, |
| 657 |
O uniq_fnum, |
| 658 |
I myThid ) |
| 659 |
|
| 660 |
C !DESCRIPTION: |
| 661 |
|
| 662 |
C !USES: |
| 663 |
implicit none |
| 664 |
#include "EEPARAMS.h" |
| 665 |
#include "SIZE.h" |
| 666 |
#ifdef ALLOW_EXCH2 |
| 667 |
#include "W2_EXCH2_SIZE.h" |
| 668 |
#include "W2_EXCH2_TOPOLOGY.h" |
| 669 |
#endif |
| 670 |
|
| 671 |
C !INPUT PARAMETERS: |
| 672 |
integer myThid, bi,bj, uniq_fnum |
| 673 |
CEOP |
| 674 |
|
| 675 |
#ifdef ALLOW_EXCH2 |
| 676 |
|
| 677 |
uniq_fnum = exch2_myFace( W2_myTileList(bi,bj) ) |
| 678 |
|
| 679 |
#else |
| 680 |
|
| 681 |
C Global face number for simple (EXCH "1") domains |
| 682 |
uniq_fnum = -1 |
| 683 |
|
| 684 |
#endif |
| 685 |
|
| 686 |
RETURN |
| 687 |
END |
| 688 |
|
| 689 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 690 |
CBOP 1 |
| 691 |
C !ROUTINE: MNC_CW_GET_XYFO |
| 692 |
|
| 693 |
C !INTERFACE: |
| 694 |
SUBROUTINE MNC_CW_GET_XYFO( |
| 695 |
I bi, bj, |
| 696 |
O ixoff, iyoff, |
| 697 |
I myThid ) |
| 698 |
|
| 699 |
C !DESCRIPTION: |
| 700 |
|
| 701 |
C !USES: |
| 702 |
implicit none |
| 703 |
#include "EEPARAMS.h" |
| 704 |
#include "SIZE.h" |
| 705 |
#ifdef ALLOW_EXCH2 |
| 706 |
#include "W2_EXCH2_SIZE.h" |
| 707 |
#include "W2_EXCH2_TOPOLOGY.h" |
| 708 |
#endif |
| 709 |
|
| 710 |
C !INPUT PARAMETERS: |
| 711 |
integer myThid, bi,bj, ixoff,iyoff |
| 712 |
CEOP |
| 713 |
|
| 714 |
C !LOCAL VARIABLES: |
| 715 |
#ifdef ALLOW_EXCH2 |
| 716 |
integer uniq_tnum |
| 717 |
#endif |
| 718 |
|
| 719 |
#ifdef ALLOW_EXCH2 |
| 720 |
|
| 721 |
uniq_tnum = W2_myTileList(bi,bj) |
| 722 |
ixoff = exch2_tbasex( uniq_tnum ) |
| 723 |
iyoff = exch2_tbasey( uniq_tnum ) |
| 724 |
|
| 725 |
#else |
| 726 |
|
| 727 |
C Global tile number for simple (non-cube) domains |
| 728 |
C iG = bi+(myXGlobalLo-1)/sNx |
| 729 |
C jG = bj+(myYGlobalLo-1)/sNy |
| 730 |
C uniq_tnum = (jG - 1)*(nPx*nSx) + iG |
| 731 |
ixoff = myXGlobalLo + bi * sNx |
| 732 |
iyoff = myYGlobalLo + bj * sNy |
| 733 |
|
| 734 |
#endif |
| 735 |
|
| 736 |
RETURN |
| 737 |
END |
| 738 |
|
| 739 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |
| 740 |
CBOP 1 |
| 741 |
C !ROUTINE: MNC_CW_FILE_AORC |
| 742 |
|
| 743 |
C !INTERFACE: |
| 744 |
SUBROUTINE MNC_CW_FILE_AORC( |
| 745 |
I fname, |
| 746 |
O indf, |
| 747 |
I lbi, lbj, uniq_tnum, |
| 748 |
I myThid ) |
| 749 |
|
| 750 |
C !DESCRIPTION: |
| 751 |
C Open a NetCDF file, appending to the file if it already exists |
| 752 |
C and, if not, creating a new file. |
| 753 |
|
| 754 |
C !USES: |
| 755 |
implicit none |
| 756 |
#include "MNC_COMMON.h" |
| 757 |
#include "EEPARAMS.h" |
| 758 |
#include "netcdf.inc" |
| 759 |
|
| 760 |
C !INPUT PARAMETERS: |
| 761 |
integer myThid, indf, lbi, lbj, uniq_tnum |
| 762 |
character*(*) fname |
| 763 |
CEOP |
| 764 |
|
| 765 |
C !LOCAL VARIABLES: |
| 766 |
integer ierr |
| 767 |
|
| 768 |
C Check if the file is already open |
| 769 |
CALL MNC_GET_IND(MNC_MAX_FID, fname, mnc_f_names, indf, myThid) |
| 770 |
IF (indf .GT. 0) THEN |
| 771 |
RETURN |
| 772 |
ENDIF |
| 773 |
|
| 774 |
C Try to open an existing file |
| 775 |
CALL MNC_FILE_TRY_READ(fname, ierr, indf, myThid) |
| 776 |
IF (ierr .NE. NF_NOERR) THEN |
| 777 |
C Try to create a new one |
| 778 |
CALL MNC_FILE_OPEN(fname, 0, indf, myThid) |
| 779 |
ENDIF |
| 780 |
|
| 781 |
C Add the global attributes |
| 782 |
CALL MNC_CW_SET_GATTR(fname, lbi,lbj, uniq_tnum, myThid) |
| 783 |
|
| 784 |
RETURN |
| 785 |
END |
| 786 |
|
| 787 |
C---+----1----+----2----+----3----+----4----+----5----+----6----+----7-|--+----| |