1 |
C $Header: /u/u3/gcmpack/MITgcm/pkg/mnc/mnc_dim.F,v 1.1 2004/01/06 23:19:27 edhill Exp $ |
2 |
C $Name: $ |
3 |
|
4 |
#include "MNC_OPTIONS.h" |
5 |
|
6 |
C================================================================== |
7 |
|
8 |
SUBROUTINE MNC_DIM_INIT( |
9 |
I myThid, |
10 |
I fname, |
11 |
I dname, |
12 |
I dunits, |
13 |
I dlen ) |
14 |
|
15 |
implicit none |
16 |
#include "mnc_common.h" |
17 |
#include "EEPARAMS.h" |
18 |
|
19 |
C Arguments |
20 |
integer myThid |
21 |
character*(*) fname, dname, dunits |
22 |
integer dlen |
23 |
|
24 |
C Functions |
25 |
integer ILNBLNK |
26 |
|
27 |
C Local Variables |
28 |
integer i,j, indf,indd, n,nf,ndn,ndu |
29 |
character*(MAX_LEN_MBUF) msgbuf |
30 |
|
31 |
nf = ILNBLNK(fname) |
32 |
ndn = ILNBLNK(dname) |
33 |
ndu = ILNBLNK(dunits) |
34 |
|
35 |
C Verify that the file exists |
36 |
CALL MNC_GET_IND(myThid, MNC_MAX_ID, fname, mnc_f_names, indf) |
37 |
IF ( indf .LT. 1 ) THEN |
38 |
write(msgbuf,'(3a)') 'MNC ERROR: file ''', fname(1:nf), |
39 |
& ''' does not exist' |
40 |
CALL print_error( msgbuf, mythid ) |
41 |
stop 'ABNORMAL END: S/R MNC_DIM_INIT' |
42 |
ENDIF |
43 |
|
44 |
C Verify that the dim is not currently defined within the file |
45 |
n = mnc_f_alld(indf,1) |
46 |
DO i = 1,n |
47 |
j = mnc_f_alld(indf,i+1) |
48 |
IF (dname(1:ndn) .EQ. mnc_d_names(j)(1:ndn)) THEN |
49 |
write(msgbuf,'(5a)') 'MNC ERROR: dimension ''', dname(1:ndn), |
50 |
& ''' already exists within file ''', fname(1:nf), |
51 |
& ''' and cannot be re-initalized' |
52 |
CALL print_error( msgbuf, mythid ) |
53 |
stop 'ABNORMAL END: S/R MNC_DIM_INIT' |
54 |
ENDIF |
55 |
ENDDO |
56 |
|
57 |
CALL MNC_GET_NEXT_EMPTY_IND(myThid, MNC_MAX_ID, mnc_d_names, indd) |
58 |
|
59 |
C Check that the dimension name fits in the table |
60 |
IF ( ndn .GT. MNC_MAX_CHAR) THEN |
61 |
ndn = MNC_MAX_CHAR |
62 |
write(msgbuf,'(a)') 'MNC WARNING: dimension name too long' |
63 |
CALL print_error(msgbuf, mythid) |
64 |
ENDIF |
65 |
IF ( ndu .GT. MNC_MAX_CHAR) THEN |
66 |
ndu = MNC_MAX_CHAR |
67 |
write(msgbuf,'(a)') 'MNC WARNING: dimension units too long' |
68 |
CALL print_error(msgbuf, mythid) |
69 |
ENDIF |
70 |
|
71 |
C Add to tables |
72 |
mnc_d_names(indd)(1:ndn) = dname(1:ndn) |
73 |
mnc_d_units(indd)(1:ndu) = dunits(1:ndu) |
74 |
mnc_d_size(indd) = dlen |
75 |
mnc_f_alld(indf,1) = n + 1 |
76 |
mnc_f_alld(indf,n+2) = indd |
77 |
|
78 |
RETURN |
79 |
END |
80 |
|