Skip to content

Commit

Permalink
Change compiling flag for hydrostatic options (#828)
Browse files Browse the repository at this point in the history
* Remove -DUSE_COND and -DMOIST_CAPPA compiling flags for hydrostatic runs; Fix the issue to write out omga and geopotential height for inline post

* Add the conditions to calculate omega in post

* Update CMakeLists.txt

* revise conditions to calculate zint
  • Loading branch information
XiaqiongZhou-NOAA committed May 15, 2024
1 parent 7147dac commit 9534e14
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ set(USE_GFSL63 ON)
if(MOVING_NEST)
set(MOVING_NEST ON)
endif()
if(HYDRO)
set(HYDRO ON)
endif()
add_subdirectory(atmos_cubed_sphere)
target_compile_definitions(fv3 PRIVATE BYPASS_BREED_SLP_INLINE)

Expand All @@ -61,7 +64,11 @@ if(NOT PARALLEL_NETCDF)
endif()

if(MOVING_NEST)
list(APPEND _fv3atm_defs_private MOVING_NEST MOIST_CAPPA USE_COND)
list(APPEND _fv3atm_defs_private MOVING_NEST)
if(NOT HYDRO)
list(APPEND _fv3atm_defs_private MOIST_CAPPA USE_COND)
endif()

if(DEBUG)
list(APPEND _fv3atm_defs_private DEBUG)
endif()
Expand Down
2 changes: 1 addition & 1 deletion atmos_cubed_sphere
6 changes: 4 additions & 2 deletions ccpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,10 @@ endif(CCPP_32BIT)

#------------------------------------------------------------------------------
# Add model-specific flags for C/C++/Fortran preprocessor
add_definitions(-DMOIST_CAPPA -DUSE_COND -DNEMS_GSM)
add_definitions(-DINTERNAL_FILE_NML)
if(NOT HYDRO)
add_definitions(-DMOIST_CAPPA -DUSE_COND -DNEMS_GSM)
endif()
add_definitions(-DINTERNAL_FILE_NML -DNEMS_GSM)

if(MULTI_GASES)
add_definitions(-DMULTI_GASES)
Expand Down
53 changes: 37 additions & 16 deletions io/post_fv3.F90
Original file line number Diff line number Diff line change
Expand Up @@ -3564,6 +3564,19 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
enddo
endif

! model level omga
if(trim(fieldname)=='omga') then
!$omp parallel do default(none) private(i,j,l) shared(lm,jsta,jend,ista,iend,omga,arrayr43d,fillvalue,spval)
do l=1,lm
do j=jsta,jend
do i=ista, iend
omga(i,j,l) = arrayr43d(i,j,l)
if(abs(arrayr43d(i,j,l)-fillvalue)<small) omga(i,j,l) = spval
enddo
enddo
enddo
endif

! soilt
if(trim(fieldname)=='soilt') then
!$omp parallel do default(none) private(i,j,l) shared(nsoil,jsta,jend,ista,iend,stc,arrayr43d,sm,sice,fillvalue,spval)
Expand Down Expand Up @@ -4268,22 +4281,6 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
enddo
enddo

do l=lm,1,-1
!$omp parallel do default(none) private(i,j) shared(l,jsta,jend,omga,wh,dpres,zint,spval,ista,iend)
do j=jsta,jend
do i=ista,iend
if(wh(i,j,l) /= spval) then
omga(i,j,l) = (-1.) * wh(i,j,l) * dpres(i,j,l)/zint(i,j,l)
zint(i,j,l) = zint(i,j,l) + zint(i,j,l+1)
else
omga(i,j,l) = spval
zint(i,j,l) = spval
endif
enddo
enddo
enddo
! print *,'in post_lam,omga 3d=',maxval(omga(ista:iend,jsta:jend,1)),minval(omga(ista:iend,jsta:jend,1)), &
! 'lm=',maxval(omga(ista:iend,jsta:jend,lm)),minval(omga(ista:iend,jsta:jend,lm))

! compute pint from top down
!$omp parallel do default(none) private(i,j) shared(jsta,jend,ak5,pint,ista,iend)
Expand Down Expand Up @@ -4343,6 +4340,29 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
end do
end do

do l=lm,1,-1
!$omp parallel do default(none) private(i,j) shared(l,jsta,jend,omga,wh,dpres,zint,alpint,q,t,spval,ista,iend)
do j=jsta,jend
do i=ista,iend
if(wh(i,j,l) /= spval) then
if(omga(i,j,l) == spval .and. dpres(i,j,l) /= spval .and. zint(i,j,l) /=spval) &
omga(i,j,l) = (-1.) * wh(i,j,l) * dpres(i,j,l)/zint(i,j,l)
if(zint(i,j,l+1) /=spval .and. zint(i,j,l) /=spval) &
zint(i,j,l) = zint(i,j,l) + zint(i,j,l+1)
else
if(zint(i,j,l+1) /=spval .and. t(i,j,l) /= spval .and. alpint(i,j,l+1) /= spval &
.and. alpint(i,j,l) /=spval .and. q(i,j,l) /= spval) then
zint(i,j,l) = zint(i,j,l+1)+(rgas/grav)*t(i,j,l)*(1.+fv*q(i,j,l))*(alpint(i,j,l+1)-alpint(i,j,l))
else
zint(i,j,l) = spval
endif
endif
enddo
enddo
enddo
! print *,'in post_lam,omga 3d=',maxval(omga(ista:iend,jsta:jend,1)),minval(omga(ista:iend,jsta:jend,1)), &
! 'lm=',maxval(omga(ista:iend,jsta:jend,lm)),minval(omga(ista:iend,jsta:jend,lm))

! compute zmid
do l=lm,1,-1
!$omp parallel do default(none) private(i,j) shared(l,jsta,jend,zmid,zint,pmid,alpint,spval,ista,iend)
Expand All @@ -4359,6 +4379,7 @@ subroutine set_postvars_fv3(wrt_int_state,grid_id,mype,mpicomp)
end do
end do


! surface potential T, and potential T at roughness length
!$omp parallel do default(none) private(i,j) shared(jsta,jend,ista,iend,spval,lp1,sm,ths,sst,thz0,sice,pint)
do j=jsta,jend
Expand Down

0 comments on commit 9534e14

Please sign in to comment.