113 use nemsio_module,
only: nemsio_getheadvar, nemsio_gfile, nemsio_init, nemsio_open, &
114 nemsio_getfilehead,nemsio_close
115 use ctlblk_mod,
only: filenameaer, me, num_procs, num_servers, mpi_comm_comp, datestr, &
116 mpi_comm_inter, filename, ioform, grib, idat, filenameflux, filenamed3d, gdsdegr, &
117 spldef, modelname, ihrst, lsmdef,vtimeunits, tprec, pthresh, datahandle, im, jm, lm, &
118 lp1, lm1, im_jm, isf_surface_physics, nsoil, spl, lsmp1, global, imp_physics, &
119 ista, iend, ista_m, iend_m, ista_2l, iend_2u, &
120 jsta, jend, jsta_m, jend_m, jsta_2l, jend_2u, novegtype, icount_calmict, npset, datapd,&
121 lsm, fld_info, etafld2_tim, eta2p_tim, mdl2sigma_tim, cldrad_tim, miscln_tim, &
122 mdl2agl_tim, mdl2std_tim, mdl2thandpv_tim, calrad_wcloud_tim,nasa_on,gccpp_on, &
123 fixed_tim, time_output, imin, surfce2_tim, komax, ivegsrc, d3d_on, gocart_on,rdaod, &
124 readxml_tim, spval, fullmodelname, submodelname, hyb_sigp, filenameflat, aqf_on,numx, &
125 run_ifi_tim, slrutah_on, d2d_chem
126 use grib2_module,
only: gribit2,num_pset,nrecout,first_grbtbl,grib_info_finalize
127 use upp_ifi_mod,
only: write_ifi_debug_files
131 type(nemsio_gfile) :: nfile,ffile,rfile
140 real(kind=8) :: time_initpost=0.,initpost_tim=0.,btim,bbtim
141 real rinc(5), untcnvt
142 integer :: status=0,iostatusd3d=0,iostatusflux=0
143 integer i,j,iii,l,k,ierr,nrec,ist,lusig,idrt,ncid3d,ncid2d,varid
144 integer :: prntsec,iim,jjm,llm,ioutcount,itmp,iret,iunit, &
145 iunitd3d,iyear,imn,iday,lcntrl,ieof
146 integer :: iostatusaer
149 integer :: kpo,kth,kpv
150 real,
dimension(komax) :: po,th,pv
151 namelist/nampgb/kpo,po,kth,th,kpv,pv,filenameaer,d3d_on,gocart_on,gccpp_on, nasa_on,popascal &
152 ,hyb_sigp,rdaod,d2d_chem, aqf_on,slrutah_on, vtimeunits,numx,write_ifi_debug_files
154 namelist/model_inputs/filename,ioform,grib,datestr,modelname,submodelname &
155 ,filenameflux,filenameflat
157 character startdate*19,sysdepinfo*80,iowrfname*3,post_fname*255
158 character cgar*1,cdum*4,line*10
184 if (me == 0)
CALL w3tagb(
'nems ',0000,0000,0000,
'np23 ')
186 if ( me >= num_procs )
then
198 filenameflat=
'postxconfig-NT.txt'
202 read(5,nml=model_inputs,iostat=itag_ierr,err=888)
203888
if (itag_ierr /= 0)
then
204 print*,
'Incorrect namelist variable(s) found in the itag file,stopping!'
207 if (me == 0)
write(6, model_inputs)
215 303
format(
'MODELNAME="',a,
'" SUBMODELNAME="',a,
'"')
217 if(me==0)
write(*,*)
'MODELNAME: ', modelname, submodelname
220 read(datestr,300) iyear,imn,iday,ihrst,imin
221 if (me==0)
write(*,*)
'in WRFPOST iyear,imn,iday,ihrst,imin', &
222 iyear,imn,iday,ihrst,imin
223 300
format(i4,1x,i2,1x,i2,1x,i2,1x,i2)
239 if(grib==
'grib2')
then
247 th = (/310.,320.,350.,450.,550.,650.,(0.,k=kth+1,komax)/)
249 pv = (/0.5,-0.5,1.0,-1.0,1.5,-1.5,2.0,-2.0,(0.,k=kpv+1,komax)/)
264 read(5,nampgb,iostat=iret,
end=119)
266 if (me == 0)
write(6, nampgb)
267 if(mod(num_procs,numx)/=0)
then
269 print*,
'total proces, num_procs=', num_procs
270 print*,
'number of subdomain in x direction, numx=', numx
271 print*,
'remainder of num_procs/numx = ', mod(num_procs,numx)
272 print*,
'Warning!!! the remainder of num_procs/numx is not 0, reset numx=1 &
273 & in this run or you adjust numx in the itag file to restart'
277 if(me == 0) print*,
'Warning!!! Reset numx as 1, numx=',numx
279 if(numx>num_procs/2)
then
281 print*,
'total proces, num_procs=', num_procs
282 print*,
'number of subdomain in x direction, numx=', numx
283 print*,
'Warning!!! numx cannot exceed num_procs/2, reset numx=1 in this run'
284 print*,
'or you adjust numx in the itag file to restart'
287 if(me == 0) print*,
'Warning!!! Reset numx as 1, numx=',numx
290 print*,
'komax,iret for nampgb= ',komax,iret
291 print*,
'komax,kpo,kth,th,kpv,pv,fileNameAER,nasa_on,popascal= ',komax,kpo &
292 & ,kth,th(1:kth),kpv,pv(1:kpv),trim(filenameaer),nasa_on,popascal
293 print*,
'NUM_PROCS=',num_procs
297 IF(trim(ioform) /=
'netcdfpara' .AND. trim(ioform) /=
'netcdf' )
THEN
299 if(me == 0) print*,
'2D decomposition only supports netcdfpara IO.'
300 if(me == 0) print*,
'Reset numx= ',numx
303 IF(modelname /=
'FV3R' .AND. modelname /=
'GFS')
THEN
305 if(me == 0) print*,
'2D decomposition only supports GFS and FV3R.'
306 if(me == 0) print*,
'Reset numx= ',numx
313 print*,
'using default pressure levels,spldef=',(spldef(l),l=1,lsmdef)
322 print*,
'using pressure levels from POSTGPVARS'
325 if( .not. popascal )
then
330 if(po(lsm) < po(1))
then
332 spl(l) = po(lsm-l+1)*untcnvt
336 spl(l) = po(l)*untcnvt
345 if(modelname ==
'NMM')
then
351 if(trim(ioform) ==
'netcdf' .OR. trim(ioform) ==
'netcdfpara')
THEN
352 IF(modelname ==
'NCAR' .OR. modelname ==
'RAPR' .OR. modelname ==
'NMM')
THEN
353 call ext_ncd_ioinit(sysdepinfo,status)
354 call ext_ncd_open_for_read( trim(filename), 0, 0,
" ", &
356 if ( status /= 0 )
then
357 print*,
'error opening ',filename,
' Status = ', status ; stop
359 call ext_ncd_get_dom_ti_integer(datahandle &
360 ,
'WEST-EAST_GRID_DIMENSION',iim,1,ioutcount, status )
362 call ext_ncd_get_dom_ti_integer(datahandle &
363 ,
'SOUTH-NORTH_GRID_DIMENSION',jjm,1,ioutcount, status )
365 call ext_ncd_get_dom_ti_integer(datahandle &
366 ,
'BOTTOM-TOP_GRID_DIMENSION',llm,1,ioutcount, status )
373 call ext_ncd_get_dom_ti_integer(datahandle &
374 ,
'SF_SURFACE_PHYSICS',itmp,1,ioutcount, status )
375 isf_surface_physics = itmp
381 ELSE IF(itmp == 3)
then
383 ELSE IF(itmp == 7)
then
387 call ext_ncd_ioclose ( datahandle, status )
391 status = nf90_open(trim(filename),ior(nf90_nowrite,nf90_mpiio), &
392 ncid3d,comm=mpi_comm_world,info=mpi_info_null)
393 if ( status /= 0 )
then
394 print*,
'error opening ',filename,
' Status = ', status
397 status = nf90_open(trim(filenameflux),ior(nf90_nowrite,nf90_mpiio), &
398 ncid2d,comm=mpi_comm_world,info=mpi_info_null)
399 if ( status /= 0 )
then
400 print*,
'error opening ',filenameflux,
' Status = ', status
404 status=nf90_get_att(ncid2d,nf90_global,
'landsfcmdl', isf_surface_physics)
406 print*,
'landsfcmdl not found; assigning to 2'
407 isf_surface_physics=2
409 if(isf_surface_physics<2)
then
410 isf_surface_physics=2
412 status=nf90_get_att(ncid2d,nf90_global,
'nsoil', nsoil)
414 print*,
'nsoil not found; assigning to 4'
418 status=nf90_get_att(ncid2d,nf90_global,
'imp_physics',imp_physics)
420 print*,
'imp_physics not found; assigning to GFDL 11'
424 status = nf90_inq_dimid(ncid3d,
'grid_xt',varid)
425 if ( status /= 0 )
then
429 status = nf90_inquire_dimension(ncid3d,varid,len=im)
430 if ( status /= 0 )
then
434 status = nf90_inq_dimid(ncid3d,
'grid_yt',varid)
435 if ( status /= 0 )
then
439 status = nf90_inquire_dimension(ncid3d,varid,len=jm)
440 if ( status /= 0 )
then
444 status = nf90_inq_dimid(ncid3d,
'pfull',varid)
445 if ( status /= 0 )
then
449 status = nf90_inquire_dimension(ncid3d,varid,len=lm)
450 if ( status /= 0 )
then
462 ELSE IF(trim(ioform) ==
'binary' .OR. &
463 trim(ioform) ==
'binarympiio' )
THEN
464 print*,
'WRF Binary format is no longer supported'
467 ELSE IF(trim(ioform) ==
'binarynemsio' .or. &
468 trim(ioform) ==
'binarynemsiompiio' )
THEN
472 call nemsio_init(iret=status)
473 call nemsio_open(nfile,trim(filename),
'read',iret=status)
474 if ( status /= 0 )
then
475 print*,
'error opening ',filename,
' Status = ', status ; stop
478 call nemsio_getfilehead(nfile,iret=status,nrec=nrec &
479 ,dimx=im,dimy=jm,dimz=lm,nsoil=nsoil)
480 if ( status /= 0 )
then
481 print*,
'error finding model dimensions '; stop
483 call nemsio_getheadvar(nfile,
'global',global,iret)
485 print*,
"global not found in file-Assigned false"
488 IF(modelname ==
'GFS') global = .true.
490 if(global .and. modelname ==
'NMM') im = im-1
494 CALL mpi_bcast(im, 1,mpi_integer,0, mpi_comm_comp,status)
495 call mpi_bcast(jm, 1,mpi_integer,0, mpi_comm_comp,status)
496 call mpi_bcast(lm, 1,mpi_integer,0, mpi_comm_comp,status)
497 call mpi_bcast(nsoil,1,mpi_integer,0, mpi_comm_comp,status)
499 call mpi_bcast(global,1,mpi_logical,0,mpi_comm_comp,status)
505 IF(modelname ==
'GFS')
THEN
507 call nemsio_open(ffile,trim(filenameflux),
'read',iret=iostatusflux)
508 if ( iostatusflux /= 0 )
then
509 print*,
'error opening ',filenameflux,
' Status = ', iostatusflux
515 call nemsio_open(rfile,trim(filenameaer),
'read',iret=iostatusaer)
516 if ( iostatusaer /= 0 .and. me == 0)
then
517 print*,
'error opening AER ',filenameaer,
' Status = ', iostatusaer
525 print*,
'UNKNOWN MODEL OUTPUT FORMAT, STOPPING'
543 if(modelname ==
'GFS')
THEN
546 else if(modelname==
'NMM' .and. trim(ioform)==
'binarynemsio')
then
549 else if(modelname==
'RAPR')
then
559 IF(trim(ioform) ==
'netcdf' .OR. trim(ioform) ==
'netcdfpara')
THEN
560 IF(modelname ==
'NCAR' .OR. modelname ==
'RAPR')
THEN
562 ELSE IF (modelname ==
'FV3R' .OR. modelname ==
'GFS')
THEN
566 print*,
'POST does not have netcdf option for model,',modelname,
' STOPPING,'
569 ELSE IF(trim(ioform) ==
'binarympiio')
THEN
570 IF(modelname ==
'NCAR' .OR. modelname ==
'RAPR' .OR. modelname ==
'NMM')
THEN
571 print*,
'WRF BINARY IO FORMAT IS NO LONGER SUPPORTED, STOPPING'
573 ELSE IF(modelname ==
'RSM')
THEN
574 print*,
'MPI BINARY IO IS NOT YET INSTALLED FOR RSM, STOPPING'
577 print*,
'POST does not have mpiio option for this model, STOPPING'
580 ELSE IF(trim(ioform) ==
'binarynemsio')
THEN
581 IF(modelname ==
'NMM')
THEN
584 print*,
'POST does not have nemsio option for model,',modelname,
' STOPPING,'
589 ELSE IF(trim(ioform) ==
'binarynemsiompiio')
THEN
590 IF(modelname ==
'GFS')
THEN
592 call nemsio_close(nfile,iret=status)
593 call nemsio_close(ffile,iret=status)
594 call nemsio_close(rfile,iret=status)
597 print*,
'POST does not have nemsio mpi option for model,',modelname, &
604 print*,
'UNKNOWN MODEL OUTPUT FORMAT, STOPPING'
607 initpost_tim = initpost_tim +(mpi_wtime() - btim)
609 WRITE(6,*)
'WRFPOST: INITIALIZED POST COMMON BLOCKS'
614 if(grib ==
"grib2")
then
617 readxml_tim = readxml_tim + (mpi_wtime() - btim)
625 first_grbtbl = .true.
662 if (me==0)
write(*,*)
' in WRFPOST OUTFORM= ',grib
663 if (me==0)
write(*,*)
' GRIB1 IS NOT SUPPORTED ANYMORE'
664 if (grib ==
"grib2")
then
665 do while (npset < num_pset)
667 if (me==0)
write(*,*)
' in WRFPOST npset=',npset,
' num_pset=',num_pset
669 if (me==0)
write(*,*)
' in WRFPOST size datapd',
size(datapd)
670 if(
allocated(datapd))
deallocate(datapd)
673 allocate(datapd(1:iend-ista+1,1:jend-jsta+1,nrecout+100))
684 call get_postfilename(post_fname)
685 if (me==0)
write(*,*)
'post_fname=',trim(post_fname)
686 if (me==0)
write(*,*)
'get_postfilename,post_fname=',trim(post_fname), &
687 'npset=',npset,
'num_pset=',num_pset, &
688 'iSF_SURFACE_PHYSICS=',isf_surface_physics
695 CALL process(kth,kpv,th(1:kth),pv(1:kpv),iostatusd3d)
696 IF(me == 0)
WRITE(6,*)
'WRFPOST: PREPARE TO PROCESS NEXT GRID'
699 call mpi_barrier(mpi_comm_comp,ierr)
703 call gribit2(post_fname)
714 call grib_info_finalize()
718 WRITE(6,*)
'ALL GRIDS PROCESSED.'
729 print*,
'INITPOST_tim = ', initpost_tim
730 print*,
'MDLFLD_tim = ', etafld2_tim
731 print*,
'MDL2P_tim = ',eta2p_tim
732 print*,
'MDL2SIGMA_tim = ',mdl2sigma_tim
733 print*,
'MDL2AGL_tim = ',mdl2agl_tim
734 print*,
'SURFCE_tim = ',surfce2_tim
735 print*,
'CLDRAD_tim = ',cldrad_tim
736 print*,
'MISCLN_tim = ',miscln_tim
737 print*,
'MDL2STD_tim = ',mdl2std_tim
738 print*,
'FIXED_tim = ',fixed_tim
739 print*,
'MDL2THANDPV_tim = ',mdl2thandpv_tim
740 print*,
'CALRAD_WCLOUD_tim = ',calrad_wcloud_tim
741 print*,
'RUN_IFI_tim = ',run_ifi_tim
742 print*,
'Total time = ',(mpi_wtime() - bbtim)
743 print*,
'Time for OUTPUT = ',time_output
744 print*,
'Time for READxml = ',readxml_tim
760 if (me == 0)
CALL w3tage(
'UNIFIED_POST')
761 CALL mpi_finalize(ierr)
subroutine allocate_all()
SET UP MESSGAE PASSING INFO.
subroutine initpost
This routine initializes constants and variables at the start of an ETA model or post processor run.
subroutine initpost_gfs_nems_mpiio(iostatusaer)
This routine initializes constants and variables at the start of GFS model or post processor run.
subroutine initpost_nems(nrec, nfile)
This routine initializes constants and variables at the start of an NEMS model or post processor run.
subroutine initpost_netcdf(ncid2d, ncid3d)
This routine initializes constants and variables at the start of GFS model or post processor run.
subroutine mpi_first()
SUBPROGRAM: MPI_FIRST SET UP MESSGAE PASSING INFO PRGRMMR: TUCCILLO ORG: IBM.
subroutine mpi_last
SUBPROGRAM: MPI_LAST SHUTS DOWN THE IO SERVER PRGRMMR: TUCCILLO ORG: IBM.
subroutine read_xml()
SUBPROGRAM: READCNTRLgrb2_xml READS POST xml CONTROL FILE PRGRMMR: J.
subroutine server
SUBPROGRAM: SERVER PERFORMS IO TO DISK PRGRMMR: TUCCILLO ORG: IBM.
subroutine setup_servers(mype, npes, inumq, mpi_comm_comp, mpi_comm_inter)
This subroutine is to setup I/O servers.
subroutine set_outflds(kth, th, kpv, pv)
This routine reads the control file in xml format specifying field(s) to post, and save all the field...
program wrfpost
2023-05-20 | Rahul Mahajan | Bug fix for fileNameFlat as namelist configurable