UPP (develop)
Loading...
Searching...
No Matches
SET_OUTFLDS.f
Go to the documentation of this file.
1
16!---------------------------------------------------------------------------
23 SUBROUTINE set_outflds(kth,th,kpv,pv)
24!
25
26!
27!
28! INCLUDE ETA GRID DIMENSIONS. SET/DERIVE PARAMETERS.
29!
30 use xml_perl_data, only: paramset,post_avblflds
31 use grib2_module, only: num_pset,pset,nrecout,first_grbtbl,grib_info_init
32 use lookup_mod, only: itb,jtb,itbq,jtbq
33 use ctlblk_mod, only: npset, me, fld_info
34 use rqstfld_mod, only: mxfld, iget, ritehd, lvlsxml, datset, ident, &
35 iavblfld, nfld, lvls
36!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
37 implicit none
38!
39! DECLARE VARIABLES.
40!
41 integer, intent(in) :: KTH,KPV
42 real, intent(in) :: th(kth),pv(kpv)
43!
44 integer L,IFLD,MFLD,IAVBL,IREC,I,J
45 CHARACTER*50 AVBLGRB_NAME
46 logical :: FOUND_FLD
47!
48!******************************************************************************
49! START READCNTRL_XML HERE.
50!
51! IF(ME==0)THEN
52! WRITE(6,*)'READCNTRL_XML: POSTING FCST HR ',IFHR,' FROM ', &
53! IHRST,'UTC ',SDAT(1),'-',SDAT(2),'-',SDAT(3),' RUN'
54! ENDIF
55!
56! INITIALIZE VARIABLES.
57! ARRAY IGET IS THE "GET FIELD" FLAG ARRAY.
58!
59 DO ifld=1,mxfld
60 iget(ifld) = -1
61 enddo
62!
63! SET FLAG TO OPEN NEW OUTPUT FILE
64!
65 lvls = 0
66 ritehd = .true.
67
68! allocate(lvlsxml(MXLVL,num_post_afld))
69
70!$omp parallel do private(i,j)
71 DO j=1,size(lvlsxml,2)
72 DO i=1,size(lvlsxml,1)
73 lvlsxml(i,j) = 0
74 ENDDO
75 ENDDO
76!
77 pset = paramset(npset)
78 datset = pset%datset
79!
80! NOW READ WHICH FIELDS ON
81! WHICH LEVELS TO INTERPOLATE TO THE OUTPUT GRID. THE
82! CHARACTER STRING "DONE" MARKS THE END OF THE OUTPUT
83! FIELD SPECIFICATIONS.
84!
85 call grib_info_init()
86 mfld = size(pset%param)
87
88! LinGan set post_avblflds to current working paramset
89! This is required for flat file solution to work for nmm
90
91 post_avblflds%param =>paramset(npset)%param
92 if(size(post_avblflds%param) <= 0) then
93 write(0,*)'WRONG: post available fields not ready!!!'
94 return
95 endif
96!
97 ifld = 0
98 irec = 0
99 DO i=1, mfld
100
101! SEE IF REQUESTED FIELD IS AVAILABLE. IF NOT,
102! WRITE MESSAGE TO 6 AND DECREMENT FIELD
103! COUNTER BY ONE. THEN READ NEXT REQUESTED FIELD.
104!
105! GET POST AVAILBLE FIELD INDEX NUMBER FOR EACH OUTPUT FIELDS IN PSET
106!
107
108 found_fld = .false.
109
110! write(*,*)'cntfile,i=',i,'fld shortname=',trim(pset%param(i)%shortname)
111! write(*,*)'size(post_avblflds%param)=',size(post_avblflds%param)
112
113 ifld = ifld + 1
114
115! segmentation fault occurred on nmm i=112
116
117 iavbl = post_avblflds%param(i)%post_avblfldidx
118 iget(iavbl) = ifld
119 ident(ifld) = iavbl
120 iavblfld(ifld) = i
121 found_fld = .true.
122 call set_lvlsxml(pset%param(i),ifld,irec,kpv,pv,kth,th)
123
124 ENDDO
125
126!
127! ALL DONE FINDING REQUESTED FIELDS FOR current OUTPUT GRID.
128! SET NFLD TO TOTAL NUMBER OF REQUESTED OUTPUT FIELDS THAT
129! ARE AVAILABLE. SET NRECOUT to total number of OUTPUT records
130! NOTE: here NFLD is total number of fields found in post_avblfld_table,
131! while nrecout is the total number of grib messages that go
132! into the output file. One field may contain many different levels,
133! which each different level will be counted as one record
134!
135 nfld = ifld
136 nrecout = irec
137! Meng 04/19/18, add three fields for continous bucket
138! NRECOUT = IREC + 3
139 allocate(fld_info(nrecout+100))
140 do i=1,nrecout
141 fld_info(i)%ifld = 0
142 fld_info(i)%lvl = 0
143 fld_info(i)%lvl1 = 0
144 fld_info(i)%lvl2 = 0
145 fld_info(i)%ntrange = 0
146 fld_info(i)%tinvstat = 0
147 enddo
148!
149! skip creating ipv files if kth=0 and no isobaric fields are requested in ctl file
150! if(kth == 0 .and. iget(013) <= 0) go to 999
151!
152! ECHO OUTPUT FIELDS/LEVELS TO 6.
153!
154! IF(ME==0)THEN
155! WRITE(6,*)'BELOW ARE FIELD/LEVEL/SMOOTHING ', &
156! 'SPECIFICATIONS.,NFLD=',NFLD,'MXLVL=',MXLVL,'nrecout=',nrecout
157! ENDIF
158! DO 50 IFLD = 1,NFLD
159! IF(ME==0)THEN
160! i=IAVBLFLD(IFLD)
161! write(*,*)'readxml,ifld=',ifld,'iget(',IDENT(ifld),')=',iget(ident(ifld)),'iavbl=',IAVBLFLD(iget(ident(ifld))),'postvar=',trim(pset%param(i)%pname), &
162! trim(pset%param(i)%fixed_sfc1_type),'lvls=',LVLS(:,ifld)
163! if(size(pset%param(i)%level)>0) then
164! WRITE(*,*) pset%param(i)%level
165! endif
166! ENDIF
167! 50 CONTINUE
168!
169! END OF ROUTINE.
170!
171 999 CONTINUE
172
173 RETURN
174 END
subroutine set_lvlsxml(param, ifld, irec, kpv, pv, kth, th)
Sets field levels (LVLS and LVLSXML) from POST xml CONTROL FILE requested fields.
Definition SET_LVLSXML.f:25
subroutine set_outflds(kth, th, kpv, pv)
Reads post XML control file.
Definition SET_OUTFLDS.f:24
type(post_avblfld_t), save post_avblflds
Parameters that are used to read in Perl XML processed flat file and handle parameter marshalling for...
type(paramset_t), dimension(:), pointer paramset
Parameters that are used to read in Perl XML processed flat file and handle parameter marshalling for...