NCEPLIBS-bufr  12.0.0
mtfnam.f
Go to the documentation of this file.
1 C> @file
2 C> @brief Determine filenames and check for the existence of
3 C> corresponding standard and local master table files on the
4 C> filesystem.
5 C> @author Ator @date 2017-10-16
6 
7 C> Based on the input arguments, this subroutine determines
8 c> the names of the corresponding standard and local master table
9 c> files. It then confirms the existence of these files on the
10 c> filesystem, using additional information obtained from the most
11 c> recent call to subroutine mtinfo(), or else as defined within
12 c> subroutine bfrini() if subroutine mtinfo() was never called.
13 C>
14 C> @param[in] IMT - integer: master table number.
15 C> @param[in] IMTV - integer: master table version number.
16 C> @param[in] IOGCE - integer: originating center.
17 C> @param[in] IMTVL - integer: local table version number.
18 C> @param[in] TBLTYP - character*(*): table type:.
19 C> - 'TableB' Table B
20 C> - 'TableD' Table D
21 C> - 'CodeFlag' Code and Flag Tables
22 C> @param[out] STDFIL - character*(*): standard master table path/filename.
23 C> @param[out] LOCFIL - character*(*): local master table path/filename.
24 C>
25 C> @author Ator @date 2017-10-16
26  SUBROUTINE mtfnam ( IMT, IMTV, IOGCE, IMTVL, TBLTYP,
27  . STDFIL, LOCFIL )
28 
29  COMMON /quiet/ iprt
30  COMMON /mstinf/ lun1, lun2, lmtd, mtdir
31 
32  CHARACTER*(*) STDFIL, LOCFIL, TBLTYP
33 
34  CHARACTER*16 TBLTYP2
35  CHARACTER*20 FMTF
36  CHARACTER*100 MTDIR
37  CHARACTER*128 BORT_STR
38  LOGICAL FOUND
39 
40 C-----------------------------------------------------------------------
41 C-----------------------------------------------------------------------
42 
43  CALL strsuc ( tbltyp, tbltyp2, ltbt )
44 
45 C* Determine the standard master table path/filename.
46 
47  IF ( ( imt .EQ. 0 ) .AND. ( imtv .LE. 13 ) ) THEN
48 
49 C* For master table 0, version 13 is a superset of all earlier
50 C* versions.
51 
52  stdfil = mtdir(1:lmtd) // '/bufrtab.' // tbltyp2(1:ltbt) //
53  . '_STD_0_13'
54  ELSE
55  WRITE ( fmtf, '(A,I1,A,I1,A)' )
56  . '(4A,I', isize(imt), ',A,I', isize(imtv), ')'
57  WRITE ( stdfil, fmtf ) mtdir(1:lmtd), '/bufrtab.',
58  . tbltyp2(1:ltbt), '_STD_', imt, '_', imtv
59  ENDIF
60  IF ( iprt .GE. 2 ) THEN
61  CALL errwrt('Standard ' // tbltyp2(1:ltbt) // ':')
62  CALL errwrt(stdfil)
63  ENDIF
64  INQUIRE ( file = stdfil, exist = found )
65  IF ( .NOT. found ) GOTO 900
66 
67 C* Now determine the local master table path/filename.
68 
69 C* Use the local table corresponding to the originating center
70 C* and local table version number, if such a table exists.
71 C* Otherwise use the local table from NCEP.
72 
73  WRITE ( fmtf, '(A,I1,A,I1,A,I1,A)' )
74  . '(4A,I', isize(imt), ',A,I', isize(iogce),
75  . ',A,I', isize(imtvl), ')'
76  WRITE ( locfil, fmtf ) mtdir(1:lmtd), '/bufrtab.',
77  . tbltyp2(1:ltbt), '_LOC_', imt, '_', iogce, '_', imtvl
78  IF ( iprt .GE. 2 ) THEN
79  CALL errwrt('Local ' // tbltyp2(1:ltbt) // ':')
80  CALL errwrt(locfil)
81  ENDIF
82  INQUIRE ( file = locfil, exist = found )
83  IF ( .NOT. found ) THEN
84 
85 C* Use the local table from NCEP.
86 
87  locfil = mtdir(1:lmtd) // '/bufrtab.' // tbltyp2(1:ltbt) //
88  . '_LOC_0_7_1'
89  IF ( iprt .GE. 2 ) THEN
90  CALL errwrt('Local ' // tbltyp2(1:ltbt) //
91  . 'not found, so using:')
92  CALL errwrt(locfil)
93  ENDIF
94  INQUIRE ( file = locfil, exist = found )
95  IF ( .NOT. found ) GOTO 901
96  ENDIF
97 
98  RETURN
99 900 bort_str = 'BUFRLIB: MTFNAM - COULD NOT FIND STANDARD FILE:'
100  CALL bort2(bort_str,stdfil)
101 901 bort_str = 'BUFRLIB: MTFNAM - COULD NOT FIND LOCAL FILE:'
102  CALL bort2(bort_str,locfil)
103  END
subroutine bort2(STR1, STR2)
Log two error messages and abort application program.
Definition: bort2.f:18
subroutine errwrt(STR)
This subroutine allows the user to specify a custom location for the logging of error and diagnostic ...
Definition: errwrt.f:36
integer function isize(NUM)
This function computes and returns the number of characters needed to encode the input integer NUM as...
Definition: isize.f:19
subroutine mtfnam(IMT, IMTV, IOGCE, IMTVL, TBLTYP, STDFIL, LOCFIL)
Based on the input arguments, this subroutine determines the names of the corresponding standard and ...
Definition: mtfnam.f:28
subroutine strsuc(str1, str2, lens)
This subroutine removes leading and trailing blanks from a character string.
Definition: strsuc.F90:16