112 use nemsio_module
, only: nemsio_getheadvar, nemsio_gfile, nemsio_init, nemsio_open, &
113 nemsio_getfilehead,nemsio_close
114 use ctlblk_mod, only: filenameaer, me, num_procs, num_servers, mpi_comm_comp, datestr, &
115 mpi_comm_inter, filename, ioform, grib, idat, filenameflux, filenamed3d, gdsdegr, &
116 spldef, modelname, ihrst, lsmdef,vtimeunits, tprec, pthresh, datahandle, im, jm, lm, &
117 lp1, lm1, im_jm, isf_surface_physics, nsoil, spl, lsmp1, global, imp_physics, &
118 ista, iend, ista_m, iend_m, ista_2l, iend_2u, &
119 jsta, jend, jsta_m, jend_m, jsta_2l, jend_2u, novegtype, icount_calmict, npset, datapd,&
120 lsm, fld_info, etafld2_tim, eta2p_tim, mdl2sigma_tim, cldrad_tim, miscln_tim, &
121 mdl2agl_tim, mdl2std_tim, mdl2thandpv_tim, calrad_wcloud_tim,nasa_on,gccpp_on, &
122 fixed_tim, time_output, imin, surfce2_tim, komax, ivegsrc, d3d_on, gocart_on,rdaod, &
123 readxml_tim, spval, fullmodelname, submodelname, hyb_sigp, filenameflat, aqf_on,numx, &
124 run_ifi_tim, slrutah_on, d2d_chem
125 use grib2_module, only: gribit2,num_pset,nrecout,first_grbtbl,grib_info_finalize
130 type(nemsio_gfile
) :: nfile,ffile,rfile
139 real(kind=8) :: time_initpost=0.,initpost_tim=0.,btim,bbtim
140 real rinc(5), untcnvt
141 integer :: status=0,iostatusd3d=0,iostatusflux=0
142 integer i,j,iii,l,k,ierr,nrec,ist,lusig,idrt,ncid3d,ncid2d,varid
143 integer :: prntsec,iim,jjm,llm,ioutcount,itmp,iret,iunit, &
144 iunitd3d,iyear,imn,iday,lcntrl,ieof
145 integer :: iostatusaer
148 integer :: kpo,kth,kpv
149 real,
dimension(komax) :: po,th,pv
150 namelist/nampgb/kpo,po,kth,th,kpv,pv,filenameaer,d3d_on,gocart_on,gccpp_on, nasa_on,popascal &
151 ,hyb_sigp,rdaod,d2d_chem, aqf_on,slrutah_on, vtimeunits,numx,write_ifi_debug_files
153 namelist/model_inputs/filename,ioform,grib,datestr,modelname,submodelname &
154 ,filenameflux,filenameflat
156 character startdate*19,sysdepinfo*80,iowrfname*3,post_fname*255
157 character cgar*1,cdum*4,line*10
183 print*,
'ME,NUM_PROCS,NUM_SERVERS=',me,num_procs,num_servers
185 if (me == 0) CALL w3tagb(
'nems ',0000,0000,0000,
'np23 ')
187 if ( me >= num_procs )
then
201 read(5,nml=model_inputs,iostat=itag_ierr,err=888)
203 888
if (itag_ierr /= 0)
then
204 print*,
'Incorrect namelist variable(s) found in the itag file,stopping!'
208 if (me==0) print*,
'fileName= ',filename
209 if (me==0) print*,
'IOFORM= ',ioform
211 if (me==0) print*,
'OUTFORM= ',grib
212 if (me==0) print*,
'DateStr= ',datestr
213 if (me==0) print*,
'MODELNAME= ',modelname
214 if (me==0) print*,
'SUBMODELNAME= ',submodelname
215 if (me==0) print*,
'numx= ',numx
222 303
format(
'MODELNAME="',a,
'" SUBMODELNAME="',a,
'"')
224 write(*,*)
'MODELNAME: ', modelname, submodelname
226 if (me==0) print 303,modelname,submodelname
228 read(datestr,300) iyear,imn,iday,ihrst,imin
229 if (me==0)
write(*,*)
'in WRFPOST iyear,imn,iday,ihrst,imin', &
230 iyear,imn,iday,ihrst,imin
231 300
format(i4,1x,i2,1x,i2,1x,i2,1x,i2)
247 if (me==0) print*,
'MODELNAME= ',modelname,
'grib=',grib
248 if(modelname ==
'GFS' .OR. modelname ==
'FV3R')
then
249 if (me == 0) print*,
'first two file names in GFS or FV3= ' &
250 ,trim(filename),trim(filenameflux)
253 if(grib==
'grib2')
then
256 if (me==0) print *,
'gdsdegr=',gdsdegr
262 th = (/310.,320.,350.,450.,550.,650.,(0.,k=kth+1,komax)/)
264 pv = (/0.5,-0.5,1.0,-1.0,1.5,-1.5,2.0,-2.0,(0.,k=kpv+1,komax)/)
279 filenameflat=
'postxconfig-NT.txt'
280 read(5,nampgb,iostat=iret,end=119)
282 if (me==0) print*,
'in itag, write_ifi_debug_files=', write_ifi_debug_files
283 if (me==0) print*,
'in itag, mod(num_procs,numx)=', mod(num_procs,numx)
284 if(mod(num_procs,numx)/=0)
then
286 print*,
'total proces, num_procs=', num_procs
287 print*,
'number of subdomain in x direction, numx=', numx
288 print*,
'remainder of num_procs/numx = ', mod(num_procs,numx)
289 print*,
'Warning!!! the remainder of num_procs/numx is not 0, reset numx=1 &
290 & in this run or you adjust numx in the itag file to restart'
294 if(me == 0) print*,
'Warning!!! Reset numx as 1, numx=',numx
296 if(numx>num_procs/2)
then
298 print*,
'total proces, num_procs=', num_procs
299 print*,
'number of subdomain in x direction, numx=', numx
300 print*,
'Warning!!! numx cannot exceed num_procs/2, reset numx=1 in this run'
301 print*,
'or you adjust numx in the itag file to restart'
304 if(me == 0) print*,
'Warning!!! Reset numx as 1, numx=',numx
307 print*,
'komax,iret for nampgb= ',komax,iret
308 print*,
'komax,kpo,kth,th,kpv,pv,fileNameAER,nasa_on,popascal= ',komax,kpo &
309 & ,kth,th(1:kth),kpv,pv(1:kpv),trim(filenameaer),nasa_on,popascal
310 print*,
'NUM_PROCS=',num_procs
314 IF(trim(ioform) /=
'netcdfpara' .AND. trim(ioform) /=
'netcdf' )
THEN
316 if(me == 0) print*,
'2D decomposition only supports netcdfpara IO.'
317 if(me == 0) print*,
'Reset numx= ',numx
320 IF(modelname /=
'FV3R' .AND. modelname /=
'GFS')
THEN
322 if(me == 0) print*,
'2D decomposition only supports GFS and FV3R.'
323 if(me == 0) print*,
'Reset numx= ',numx
330 print*,
'using default pressure levels,spldef=',(spldef(l),l=1,lsmdef)
339 print*,
'using pressure levels from POSTGPVARS'
342 if( .not. popascal )
then
347 if(po(lsm) < po(1))
then
349 spl(l) = po(lsm-l+1)*untcnvt
353 spl(l) = po(l)*untcnvt
358 if (me==0) print*,
'LSM, SPL = ',lsm,spl(1:lsm)
363 if(modelname ==
'NMM')
then
369 if(trim(ioform) ==
'netcdf' .OR. trim(ioform) ==
'netcdfpara')
THEN
370 IF(modelname ==
'NCAR' .OR. modelname ==
'RAPR' .OR. modelname ==
'NMM')
THEN
371 call ext_ncd_ioinit(sysdepinfo,status)
372 print*,
'called ioinit', status
373 call ext_ncd_open_for_read( trim(filename), 0, 0,
" ", &
375 print*,
'called open for read', status
376 if ( status /= 0 )
then
377 print*,
'error opening ',filename,
' Status = ', status ; stop
379 call ext_ncd_get_dom_ti_integer(datahandle &
380 ,
'WEST-EAST_GRID_DIMENSION',iim,1,ioutcount, status )
382 call ext_ncd_get_dom_ti_integer(datahandle &
383 ,
'SOUTH-NORTH_GRID_DIMENSION',jjm,1,ioutcount, status )
385 call ext_ncd_get_dom_ti_integer(datahandle &
386 ,
'BOTTOM-TOP_GRID_DIMENSION',llm,1,ioutcount, status )
392 print*,
'im jm lm from wrfout= ',im,jm, lm
395 call ext_ncd_get_dom_ti_integer(datahandle &
396 ,
'SF_SURFACE_PHYSICS',itmp,1,ioutcount, status )
397 isf_surface_physics = itmp
398 print*,
'SF_SURFACE_PHYSICS= ',isf_surface_physics
404 ELSE IF(itmp == 3)
then
406 ELSE IF(itmp == 7)
then
409 print*,
'NSOIL from wrfout= ',nsoil
411 call ext_ncd_ioclose( datahandle, status )
415 status = nf90_open(trim(filename),ior(nf90_nowrite,nf90_mpiio), &
416 ncid3d,comm=mpi_comm_world,info=mpi_info_null)
417 if ( status /= 0 )
then
418 print*,
'error opening ',filename,
' Status = ', status
421 status = nf90_open(trim(filenameflux),ior(nf90_nowrite,nf90_mpiio), &
422 ncid2d,comm=mpi_comm_world,info=mpi_info_null)
423 if ( status /= 0 )
then
424 print*,
'error opening ',filenameflux,
' Status = ', status
428 status=nf90_get_att(ncid2d,nf90_global,
'landsfcmdl', isf_surface_physics)
430 print*,
'landsfcmdl not found; assigning to 2'
431 isf_surface_physics=2
433 if(isf_surface_physics<2)
then
434 isf_surface_physics=2
436 status=nf90_get_att(ncid2d,nf90_global,
'nsoil', nsoil)
438 print*,
'nsoil not found; assigning to 4'
441 if(me==0)print*,
'SF_SURFACE_PHYSICS= ',isf_surface_physics
442 if(me==0)print*,
'NSOIL= ',nsoil
444 status=nf90_get_att(ncid2d,nf90_global,
'imp_physics',imp_physics)
446 print*,
'imp_physics not found; assigning to GFDL 11'
449 if (me == 0) print*,
'MP_PHYSICS= ',imp_physics
451 status = nf90_inq_dimid(ncid3d,
'grid_xt',varid)
452 if ( status /= 0 )
then
456 status = nf90_inquire_dimension(ncid3d,varid,len=im)
457 if ( status /= 0 )
then
461 status = nf90_inq_dimid(ncid3d,
'grid_yt',varid)
462 if ( status /= 0 )
then
466 status = nf90_inquire_dimension(ncid3d,varid,len=jm)
467 if ( status /= 0 )
then
471 status = nf90_inq_dimid(ncid3d,
'pfull',varid)
472 if ( status /= 0 )
then
476 status = nf90_inquire_dimension(ncid3d,varid,len=lm)
477 if ( status /= 0 )
then
488 print*,
'im jm lm nsoil from fv3 output = ',im,jm,lm,nsoil
491 ELSE IF(trim(ioform) ==
'binary' .OR. &
492 trim(ioform) ==
'binarympiio' )
THEN
493 print*,
'WRF Binary format is no longer supported'
496 ELSE IF(trim(ioform) ==
'binarynemsio' .or. &
497 trim(ioform) ==
'binarynemsiompiio' )
THEN
501 call nemsio_init(iret=status)
502 print *,
'nemsio_init, iret=',status
503 call nemsio_open(nfile,trim(filename),
'read',iret=status)
504 if ( status /= 0 )
then
505 print*,
'error opening ',filename,
' Status = ', status ; stop
508 call nemsio_getfilehead(nfile,iret=status,nrec=nrec &
509 ,dimx=im,dimy=jm,dimz=lm,nsoil=nsoil)
510 if ( status /= 0 )
then
511 print*,
'error finding model dimensions '; stop
513 call nemsio_getheadvar(nfile,
'global',global,iret)
515 print*,
"global not found in file-Assigned false"
518 IF(modelname ==
'GFS') global = .true.
520 if(global .and. modelname ==
'NMM') im = im-1
524 CALL mpi_bcast(im, 1,mpi_integer,0, mpi_comm_comp,status)
525 call mpi_bcast(jm, 1,mpi_integer,0, mpi_comm_comp,status)
526 call mpi_bcast(lm, 1,mpi_integer,0, mpi_comm_comp,status)
527 call mpi_bcast(nsoil,1,mpi_integer,0, mpi_comm_comp,status)
529 if (me == 0) print*,
'im jm lm nsoil from NEMS= ',im,jm, lm ,nsoil
530 call mpi_bcast(global,1,mpi_logical,0,mpi_comm_comp,status)
531 if (me == 0) print*,
'Is this a global run ',global
537 IF(modelname ==
'GFS')
THEN
539 call nemsio_open(ffile,trim(filenameflux),
'read',iret=iostatusflux)
540 if ( iostatusflux /= 0 )
then
541 print*,
'error opening ',filenameflux,
' Status = ', iostatusflux
547 call nemsio_open(rfile,trim(filenameaer),
'read',iret=iostatusaer)
548 if ( iostatusaer /= 0 .and. me == 0)
then
549 print*,
'error opening AER ',filenameaer,
' Status = ', iostatusaer
557 print*,
'UNKNOWN MODEL OUTPUT FORMAT, STOPPING'
563 print*,
'jsta,jend,jsta_m,jend_m,jsta_2l,jend_2u,spval=',jsta, &
564 jend,jsta_m,jend_m, jsta_2l,jend_2u,spval
577 if(modelname ==
'GFS')
THEN
580 else if(modelname==
'NMM' .and. trim(ioform)==
'binarynemsio')
then
583 else if(modelname==
'RAPR')
then
593 IF(trim(ioform) ==
'netcdf' .OR. trim(ioform) ==
'netcdfpara')
THEN
594 IF(modelname ==
'NCAR' .OR. modelname ==
'RAPR')
THEN
595 print*,
'CALLING INITPOST TO PROCESS NCAR NETCDF OUTPUT'
597 ELSE IF (modelname ==
'FV3R' .OR. modelname ==
'GFS')
THEN
599 print*,
'CALLING INITPOST_NETCDF'
602 print*,
'POST does not have netcdf option for model,',modelname,
' STOPPING,'
605 ELSE IF(trim(ioform) ==
'binarympiio')
THEN
606 IF(modelname ==
'NCAR' .OR. modelname ==
'RAPR' .OR. modelname ==
'NMM')
THEN
607 print*,
'WRF BINARY IO FORMAT IS NO LONGER SUPPORTED, STOPPING'
609 ELSE IF(modelname ==
'RSM')
THEN
610 print*,
'MPI BINARY IO IS NOT YET INSTALLED FOR RSM, STOPPING'
613 print*,
'POST does not have mpiio option for this model, STOPPING'
616 ELSE IF(trim(ioform) ==
'binarynemsio')
THEN
617 IF(modelname ==
'NMM')
THEN
620 print*,
'POST does not have nemsio option for model,',modelname,
' STOPPING,'
625 ELSE IF(trim(ioform) ==
'binarynemsiompiio')
THEN
626 IF(modelname ==
'GFS')
THEN
628 call nemsio_close(nfile,iret=status)
629 call nemsio_close(ffile,iret=status)
630 call nemsio_close(rfile,iret=status)
633 print*,
'POST does not have nemsio mpi option for model,',modelname, &
640 print*,
'UNKNOWN MODEL OUTPUT FORMAT, STOPPING'
643 initpost_tim = initpost_tim +(mpi_wtime() - btim)
645 WRITE(6,*)
'WRFPOST: INITIALIZED POST COMMON BLOCKS'
650 if(grib ==
"grib2")
then
653 readxml_tim = readxml_tim + (mpi_wtime() - btim)
661 first_grbtbl = .true.
698 if (me==0)
write(*,*)
' in WRFPOST OUTFORM= ',grib
699 if (me==0)
write(*,*)
' GRIB1 IS NOT SUPPORTED ANYMORE'
700 if (grib ==
"grib2")
then
701 do while (npset < num_pset)
703 if (me==0)
write(*,*)
' in WRFPOST npset=',npset,
' num_pset=',num_pset
705 if (me==0)
write(*,*)
' in WRFPOST size datapd',
size(datapd)
706 if(
allocated(datapd))
deallocate(datapd)
709 allocate(datapd(1:iend-ista+1,1:jend-jsta+1,nrecout+100))
720 call get_postfilename(post_fname)
721 if (me==0)
write(*,*)
'post_fname=',trim(post_fname)
722 if (me==0)
write(*,*)
'get_postfilename,post_fname=',trim(post_fname), &
723 'npset=',npset,
'num_pset=',num_pset, &
724 'iSF_SURFACE_PHYSICS=',isf_surface_physics
731 CALL process(kth,kpv,th(1:kth),pv(1:kpv),iostatusd3d)
732 IF(me == 0)
WRITE(6,*)
'WRFPOST: PREPARE TO PROCESS NEXT GRID'
735 call mpi_barrier(mpi_comm_comp,ierr)
739 call gribit2(post_fname)
750 call grib_info_finalize()
754 WRITE(6,*)
'ALL GRIDS PROCESSED.'
765 print*,
'INITPOST_tim = ', initpost_tim
766 print*,
'MDLFLD_tim = ', etafld2_tim
767 print*,
'MDL2P_tim = ',eta2p_tim
768 print*,
'MDL2SIGMA_tim = ',mdl2sigma_tim
769 print*,
'MDL2AGL_tim = ',mdl2agl_tim
770 print*,
'SURFCE_tim = ',surfce2_tim
771 print*,
'CLDRAD_tim = ',cldrad_tim
772 print*,
'MISCLN_tim = ',miscln_tim
773 print*,
'MDL2STD_tim = ',mdl2std_tim
774 print*,
'FIXED_tim = ',fixed_tim
775 print*,
'MDL2THANDPV_tim = ',mdl2thandpv_tim
776 print*,
'CALRAD_WCLOUD_tim = ',calrad_wcloud_tim
777 print*,
'RUN_IFI_tim = ',run_ifi_tim
778 print*,
'Total time = ',(mpi_wtime() - bbtim)
779 print*,
'Time for OUTPUT = ',time_output
780 print*,
'Time for READxml = ',readxml_tim
796 if (me == 0) CALL w3tage(
'UNIFIED_POST')
797 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 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...
subroutine read_xml()
SUBPROGRAM: READCNTRLgrb2_xml READS POST xml CONTROL FILE PRGRMMR: J.
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 initpost_gfs_nems_mpiio(iostatusAER)
This routine initializes constants and variables at the start of GFS model or post processor run...
subroutine server
SUBPROGRAM: SERVER PERFORMS IO TO DISK PRGRMMR: TUCCILLO ORG: IBM.
subroutine initpost_netcdf(ncid2d, ncid3d)
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...