UPP (develop)
Loading...
Searching...
No Matches
get_postfilename.f
1 subroutine get_postfilename(fname)
2!
3! ABSTRACT: THIS SUBROUTINE GENERATE POST FILE NAME FROM THE DATSET IN
4! POST CONTROL FILE
5!
6! Program log:
7! 11-02 Jun Wang generate code from subroutine gribit
8!
9 use ctlblk_mod, only : ifhr, me, modelname, ifmin
10 use rqstfld_mod, only : ritehd, datset, iget
11!
12 implicit none
13!
14 character(*),intent(inout) :: fname
15!
16!local vars
17 integer IHR,KDAT,KENV,KTHR,NDIG
18 CHARACTER*4 RESTHR,BLANK
19 CHARACTER*10 DESCR2,DESCR3
20 character CFHOUR*40,CFORM*40
21 CHARACTER*180 ENVAR
22 CHARACTER*255 PGBOUT,IPVOUT,D3DOUT
23!
24 DATA blank /' '/
25!
26 IF (ritehd) THEN
27!
28! PUT FORECAST HOUR INTO DIR PREFIX FOR GRIB FILE.
29 ihr = ifhr
30!
31! GET FULL PATH FOR OUTPUT FILE FROM ENVIRONMENT VARIABLE
32! COMSP WHICH IS SET IN THE SCRIPT RUNNING THE MODEL.
33!
34! CONSTRUCT FULL PATH-FILENAME FOR OUTPUT FILE
35 envar = ' '
36 resthr = ' '
37 pgbout = ' '
38 ipvout = ' '
39 d3dout = ' '
40 CALL getenv('COMSP',envar)
41 CALL getenv('tmmark',resthr)
42 CALL getenv('PGBOUT',pgbout)
43 CALL getenv('IPVOUT',ipvout)
44 CALL getenv('D3DOUT',d3dout)
45 kdat = index(datset,' ') -1
46 IF (kdat<=0) kdat = len(datset)
47 kenv = index(envar,' ') -1
48 IF (kenv<=0) kenv = len(envar)
49 kthr = index(resthr,' ') -1
50 IF (kthr<=0) kthr = len(resthr)
51!
52! CONSTRUCT FULL PATH-FILENAME FOR OUTPUT FILE
53 IF(modelname=='GFS')THEN
54 IF(d3dout(1:4)/=blank .AND. &
55 ((iget(354)>0).OR.(iget(355)>0).OR. &
56 (iget(356)>0).OR.(iget(357)>0).OR. &
57 (iget(358)>0).OR.(iget(359)>0).OR. &
58 (iget(360)>0).OR.(iget(361)>0).OR. &
59 (iget(362)>0).OR.(iget(363)>0).OR. &
60 (iget(364)>0).OR.(iget(365)>0).OR. &
61 (iget(366)>0).OR.(iget(367)>0).OR. &
62 (iget(368)>0).OR.(iget(369)>0).OR. &
63 (iget(370)>0).OR.(iget(371)>0).OR. &
64 (iget(372)>0).OR.(iget(373)>0).OR. &
65 (iget(374)>0).OR.(iget(375)>0)))THEN
66 fname = d3dout
67 ELSE IF(ipvout(1:4)/=blank .AND. &
68 index(datset(1:kdat),"IPV")>0 .AND. &
69 ((iget(332)>0).OR.(iget(333)>0).OR. &
70 (iget(334)>0).OR.(iget(335)>0).OR. &
71 (iget(351)>0).OR.(iget(352)>0).OR. &
72 (iget(353)>0).OR.(iget(378)>0)))THEN
73 fname = ipvout
74 ELSE IF(pgbout(1:4)/=blank)THEN
75 fname = pgbout
76 ELSE
77 ndig=max(log10(ihr+0.5)+1.,2.)
78! WRITE(CFORM,'("('.GrbF',I",I1,".",I1,")")') NDIG,NDIG
79 WRITE(cform,'("(I",I1,".",I1,")")') ndig,ndig
80 WRITE(cfhour,cform) ihr
81 fname = datset(1:kdat) //'.GrbF'// cfhour
82 END IF
83! IF(MODELNAME=='GFS'.AND.PGBOUT(1:4)/=BLANK)THEN
84! FNAME = PGBOUT
85! PRINT*,' FNAME FROM PGBOUT=',trim(FNAME)
86!
87 ELSEIF (envar(1:4)==blank.AND.resthr(1:4)==blank) THEN
88 IF(ifmin >= 1)THEN
89 WRITE(descr2,1011) ihr
90 WRITE(descr3,1012) ifmin
91 fname = datset(1:kdat) // trim(descr2) //'.'// descr3(1:2)
92 ELSE
93 ndig=max(log10(ihr+0.5)+1.,2.)
94! WRITE(CFORM,'("('.GrbF',I",I1,".",I1,")")') NDIG,NDIG
95 WRITE(cform,'("(I",I1,".",I1,")")') ndig,ndig
96 WRITE(cfhour,cform) ihr
97 fname = datset(1:kdat) //'.GrbF'// cfhour
98!
99! IF(IHR<100)THEN
100! WRITE(DESCR2,1011) IHR
101! ELSE
102! WRITE(DESCR2,1013) IHR
103! END IF
104 1011 FORMAT('.GrbF',i2.2)
105!1013 FORMAT('.GrbF',I3.3)
106! FNAME = DATSET(1:KDAT) // DESCR2
107 END IF
108!
109 ELSEIF(envar(1:4)==blank.AND.resthr(1:4)/=blank) THEN
110 IF(ifmin >= 1)THEN
111 WRITE(descr3,1012) ifmin
112 IF (ihr<100) THEN
113 WRITE(descr2,1012) ihr
114 fname = datset(1:kdat) // descr2(1:2) //'.'// descr3(1:2) &
115 //'.'// resthr
116 ELSE
117 WRITE(descr2,1014) ihr
118 fname = datset(1:kdat) // descr2(1:3) //'.'// descr3(1:2) &
119 //'.'// resthr
120 ENDIF
121 ELSE
122 IF (ihr<100) THEN
123 WRITE(descr2,1012) ihr
124 fname = datset(1:kdat) // descr2(1:2) //'.'// resthr
125 ELSE
126 WRITE(descr2,1014) ihr
127 fname = datset(1:kdat) // descr2(1:3) //'.'// resthr
128 ENDIF
129 end if
130 ELSE
131 IF(ifmin >= 1)THEN
132 WRITE(descr3,1012) ifmin
133 IF (ihr<100) THEN
134 WRITE(descr2,1012) ihr
135 fname = envar(1:kenv) // datset(1:kdat) // descr2(1:2) &
136 //'.'// descr3(1:2) //'.'// resthr
137 ELSE
138 WRITE(descr2,1014) ihr
139 fname = envar(1:kenv) // datset(1:kdat) // descr2(1:3) &
140 //'.'// descr3(1:2) //'.'// resthr
141 ENDIF
142 ELSE
143 IF (ihr<100) THEN
144 WRITE(descr2,1012) ihr
145 fname = envar(1:kenv) // datset(1:kdat) // descr2(1:2) &
146 //'.'// resthr
147 1012 FORMAT(i2.2)
148 1014 FORMAT(i3.3)
149 ELSE
150 WRITE(descr2,1014) ihr
151 fname = envar(1:kenv) // datset(1:kdat) // descr2(1:3) &
152 //'.'// resthr
153 ENDIF
154 end if
155 ENDIF
156!
157 ENDIF
158
159 end subroutine get_postfilename