Skip to content

Commit

Permalink
add spectral strm and vpot at 200mb for SFS
Browse files Browse the repository at this point in the history
  • Loading branch information
KarinaAsmar-NOAA committed Oct 21, 2024
1 parent 4e41404 commit 26aaeb0
Show file tree
Hide file tree
Showing 8 changed files with 379 additions and 3 deletions.
16 changes: 16 additions & 0 deletions parm/post_avblflds.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8479,5 +8479,21 @@
<scale>3.0</scale>
</param>

<param>
<post_avblfldidx>1021</post_avblfldidx>
<shortname>VPOT_ON_ISOBARIC_SFC_FROM_WIND_FLD</shortname>
<pname>VPOT</pname>
<fixed_sfc1_type>isobaric_sfc</fixed_sfc1_type>
<scale>3.0</scale>
</param>

<param>
<post_avblfldidx>1022</post_avblfldidx>
<shortname>STRM_ON_ISOBARIC_SFC_FROM_WIND_FLD</shortname>
<pname>STRM</pname>
<fixed_sfc1_type>isobaric_sfc</fixed_sfc1_type>
<scale>3.0</scale>
</param>

</post_avblflds>
</postxml>
12 changes: 12 additions & 0 deletions parm/sfs/postcntrl_sfs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@
<scale>5.0</scale>
</param>

<param>
<shortname>VPOT_ON_ISOBARIC_SFC_FROM_WIND_FLD</shortname>
<level>20000.</level>
<scale>3.0</scale>
</param>

<param>
<shortname>STRM_ON_ISOBARIC_SFC_FROM_WIND_FLD</shortname>
<level>20000.</level>
<scale>3.0</scale>
</param>

<param>
<shortname>MSLET_ON_MEAN_SEA_LVL</shortname>
<scale>6.0</scale>
Expand Down
86 changes: 85 additions & 1 deletion parm/sfs/postxconfig-NT-sfs.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1
114
116
GFSPRS
0
ncep_nco
Expand Down Expand Up @@ -352,6 +352,90 @@ isobaric_sfc
?
?
?
1021
VPOT_ON_ISOBARIC_SFC_FROM_WIND_FLD
?
1
tmpl4_0
VPOT
?
?
isobaric_sfc
0
?
1
20000.
?
0
?
0
?
?
?
?
0
0.0
0
0.0
?
0
0.0
0
0.0
0
0.0
0
0.0
1
3.0
0
0
0
?
?
?
1022
STRM_ON_ISOBARIC_SFC_FROM_WIND_FLD
?
1
tmpl4_0
STRM
?
?
isobaric_sfc
0
?
1
20000.
?
0
?
0
?
?
?
?
0
0.0
0
0.0
?
0
0.0
0
0.0
0
0.0
0
0.0
1
3.0
0
0
0
?
?
?
23
MSLET_ON_MEAN_SEA_LVL
?
Expand Down
176 changes: 176 additions & 0 deletions sorc/ncep_post.fd/CALCHIPSI.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
!> @file
!> @brief Subroutine that computes the velocity potential and
!> streamfunction from isobaric winds.
!>
!><pre>
!> This routine is based on the CFS genpsiandchi program that
!> computes velocity potential and streamfunction from the
!> isobaric wind components. The program was authored and provided
!> by Saha and H. Chuang.
!> Given the U-V wind components at P-points, this routine
!> collects the winds in the full IM,JM,LSM domain,
!> transforms them back to spectrum space and computes divergence,
!> vorticity, streamfunction and potential. The routine returns:
!> PSI: the streamfunction in global domain
!> CHI: the velocity potential in global domain
!></pre>
!>
!> @param[in] UISO real U-wind component (m/s) at all P-points.
!> @param[in] VISO real V-wind component (m/s) at all P-points.
!> @param[out] CHI real velocity potential (m^2/s) in full grid domain at all P-points.
!> @param[out] PSI real streamfunction (m^2/s) in full grid domain at all P-points
!>
!> ### Program history log:
!> Date | Programmer | Comments
!> -----------|--------------|---------
!> 2024-07-17 | Karina Asmar | Initial
!> 2024-07-25 | Jesse Meng | Add MPI scatterv
!>
!> @author Karina Asmar EMC/VPPPG @date 2024-07-17
!-----------------------------------------------------------------------
!> @brief Subroutine that computes velocity potential and streamfunction
!> from isobaric winds.
!>
!> @param[in] UISO real U-wind component (m/s) at all P-points.
!> @param[in] VISO real V-wind component (m/s) at all P-points.
!> @param[out] CHI real velocity potential (m^2/s) in full grid domain at P-points.
!> @param[out] PSI real streamfunction (m^2/s) in full grid domain at P-points
!-----------------------------------------------------------------------
SUBROUTINE CALCHIPSI(UISO,VISO,CHI,PSI)
!
! INCLUDE ETA GRID DIMENSIONS. SET/DERIVE OTHER PARAMETERS.
!
use gridspec_mod, only: IDRT
use ctlblk_mod, only: ISTA, IEND, JSTA, JEND, IM, JM, LSM, ME, SPVAL, MPI_COMM_COMP,&
num_procs, icnt, idsp, isxa, iexa, jsxa, jexa
use rqstfld_mod, only: IGET, LVLS
!
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
implicit none

include 'mpif.h'
!
! DECLARE VARIABLES.
!
integer :: JCAP, I, J, L, IERR
REAL, dimension(ISTA:IEND,JSTA:JEND,LSM), intent(in) :: UISO, VISO
REAL, dimension(IM,JM,LSM), intent(out) :: CHI, PSI

integer k, m
real, allocatable :: CHI1(:),CHISUB(:),PSI1(:),PSISUB(:),COL_UWIND(:,:),COL_VWIND(:,:), &
IN_UWIND(:,:),IN_VWIND(:,:),OUT_UWIND(:,:),OUT_VWIND(:,:), &
DIV(:,:),ZO(:,:),CHI_OUT(:,:),PSI_OUT(:,:)

!
!***************************************************************************
! START CALCHIPSI HERE.
!
! SAVE ALL P LEVELS OF U/V WINDS AT GLOBAL GRID

ALLOCATE(COL_UWIND(IM,JM))
ALLOCATE(COL_VWIND(IM,JM))

ALLOCATE(IN_UWIND(IM,JM))
ALLOCATE(IN_VWIND(IM,JM))
ALLOCATE(OUT_UWIND(IM,JM))
ALLOCATE(OUT_VWIND(IM,JM))
ALLOCATE(DIV(IM,JM))
ALLOCATE(ZO(IM,JM))
ALLOCATE(CHI_OUT(IM,JM))
ALLOCATE(PSI_OUT(IM,JM))

ALLOCATE(CHI1(im*jm))
ALLOCATE(CHISUB(icnt(me)))
ALLOCATE(PSI1(im*jm))
ALLOCATE(PSISUB(icnt(me)))

CHI = SPVAL
PSI = SPVAL

DO L=1,LSM
IF(LVLS(L,IGET(1021)) > 0)THEN

CALL COLLECT_ALL(UISO(ISTA:IEND,JSTA:JEND,L),COL_UWIND)
CALL COLLECT_ALL(VISO(ISTA:IEND,JSTA:JEND,L),COL_VWIND)
!$omp parallel do private(i,j)
DO J=1,JM
DO I=1,IM
IN_UWIND(I,J)=COL_UWIND(I,J)
IN_VWIND(I,J)=COL_VWIND(I,J)
ENDDO
ENDDO

IF (ME==0) THEN

! SET MAX WAVELENGTH FOR SPECTRAL TRUNCATION
IF(IDRT == 0)THEN
JCAP = (JM-3)/2
ELSE
JCAP = JM-1
ENDIF

! COMPUTE CHI/PSI FROM WIND VECTORS IN SPECTRAL SPACE
CALL SPTRUNV(0,JCAP,IDRT,IM, &
JM,IDRT,IM,JM,1, &
0,0,0,0, &
0,0,0,0, &
IN_UWIND(1,1),IN_VWIND(1,1), &
.FALSE.,OUT_UWIND(1,1),OUT_VWIND(1,1), &
.FALSE.,DIV,ZO, &
.TRUE.,CHI_OUT(1,1),PSI_OUT(1,1))

ENDIF ! END OF ME=0 BLOCK

CALL MPI_BARRIER(MPI_COMM_COMP, IERR)

IF (ME==0) THEN
k=0
DO m=0,num_procs-1
DO J=jsxa(m),jexa(m)
DO I=isxa(m),iexa(m)
k=k+1
CHI1(k)=CHI_OUT(I,J)
PSI1(k)=PSI_OUT(I,J)
ENDDO
ENDDO
ENDDO
ENDIF

CALL MPI_SCATTERV(CHI1,icnt,idsp,MPI_REAL, &
CHISUB,icnt(me),MPI_REAL,0,MPI_COMM_WORLD,IERR)
CALL MPI_SCATTERV(PSI1,icnt,idsp,MPI_REAL, &
PSISUB,icnt(me),MPI_REAL,0,MPI_COMM_WORLD,IERR)

k=0
DO J=JSTA,JEND
DO I=ISTA,IEND
k=k+1
CHI(I,J,L)=CHISUB(k)
PSI(I,J,L)=PSISUB(k)
ENDDO
ENDDO

ENDIF
ENDDO

DEALLOCATE(CHI1)
DEALLOCATE(CHISUB)
DEALLOCATE(PSI1)
DEALLOCATE(PSISUB)

DEALLOCATE(IN_UWIND)
DEALLOCATE(IN_VWIND)
DEALLOCATE(OUT_UWIND)
DEALLOCATE(OUT_VWIND)
DEALLOCATE(DIV)
DEALLOCATE(ZO)
DEALLOCATE(CHI_OUT)
DEALLOCATE(PSI_OUT)

DEALLOCATE(COL_UWIND)
DEALLOCATE(COL_VWIND)
!
!
! END OF ROUTINE.
RETURN
END
1 change: 1 addition & 0 deletions sorc/ncep_post.fd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ list(APPEND LIB_SRC
AVIATION.f
BNDLYR.f
BOUND.f
CALCHIPSI.f
CALDRG.f
CALDWP.f
CALGUST.f
Expand Down
1 change: 1 addition & 0 deletions sorc/ncep_post.fd/GRIDSPEC.f
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ module GRIDSPEC_mod
integer cenlonv !< center longitude of grid
integer latlastv !< latitude of last grid point (upper right corner latitude)
integer lonlastv !< longitude of last grid point (upper right corner longitude)
integer idrt !< grid identifier
real PSMAPF !< map scale factor
character(len=1) gridtype !< type of grid staggering as in Arakawa grids (Arakawa-A through Arakawa-E)
!
Expand Down
5 changes: 3 additions & 2 deletions sorc/ncep_post.fd/INITPOST_NETCDF.f
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
!> 2024-06-25 | Wen Meng | Add capability to read fhzero as either an integer or float
!> 2024-08-26 | Karina Asmar | Add temporal u/v, speed max wind components at 10m agl
!> 2024-10-11 | Sam Trahan | Fixed an incorrect array length in read_netcdf_3d_para
!> 2024-10-21 | Karina Asmar | Read in and store idrt in gridspec_mod
!>
!> @author Hui-Ya Chuang @date 2016-03-04
!----------------------------------------------------------------------
Expand Down Expand Up @@ -127,7 +128,7 @@ SUBROUTINE INITPOST_NETCDF(ncid2d,ncid3d)
use gridspec_mod, only: maptype, gridtype, latstart, latlast, lonstart, lonlast, cenlon, &
dxval, dyval, truelat2, truelat1, psmapf, cenlat,lonstartv, lonlastv, cenlonv, &
latstartv, latlastv,cenlatv,latstart_r,latlast_r,lonstart_r,lonlast_r, STANDLON, &
latse,lonse,latnw,lonnw
latse,lonse,latnw,lonnw,idrt
use upp_physics, only: fpvsnew
!- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
implicit none
Expand Down Expand Up @@ -195,7 +196,7 @@ SUBROUTINE INITPOST_NETCDF(ncid2d,ncid3d)
!jw
integer ii,jj,js,je,iyear,imn,iday,itmp,ioutcount,istatus, &
I,J,L,ll,k,k1,kf,irtn,igdout,n,Index,nframe, &
nframed2,iunitd3d,ierr,idum,iret,nrec,idrt
nframed2,iunitd3d,ierr,idum,iret,nrec
integer ncid3d,ncid2d,varid,nhcas,varid_bl,iret_bl
real TSTART,TLMH,TSPH,ES,FACT,soilayert,soilayerb,zhour,dum, &
tvll,pmll,tv, tx1, tx2, zpbltop
Expand Down
Loading

0 comments on commit 26aaeb0

Please sign in to comment.