How do I add a new 3d variable in tslist?

Moderator: NCAR/MMM

Post Reply
kwerner
Posts: 1635
Joined: Wed Feb 14, 2018 9:21 pm

How do I add a new 3d variable in tslist?

Post by kwerner » Tue Feb 25, 2020 12:36 am

These changes are for a 3D variable. If you are interested in adding a 2D variable, see:
https://forum.mmm.ucar.edu/phpBB3/viewt ... f=74&t=147

It is probably easiest if you use the module share/wrf_timeseries.F as a reference. You can simply fill in one of the existing arrays for time series output (e.g., tslb) with your own information. All model data are available in that routine. If you would like to add one, you will need to modify Registry.EM_COMMON, and then make more changes in wrf_timeseries.F. For example, if you wanted to add base state pressure (PB) to WRFV4.1.3 timeseries output:

(1) Revise share/wrf_timeseries.F:
- Line 36 should be changed from:

Code: Select all

INTEGER, PARAMETER :: TS_FIELDS = 7
to

Code: Select all

INTEGER, PARAMETER :: TS_FIELDS = 8
- Line 38 should be changed from:

Code: Select all

ts_file_endings = (/ 'UU', 'VV', 'PH', 'TH', 'QV', 'WW', 'PR' /)
to something like (you can choose your suffixes:

Code: Select all

ts_file_endings = (/ 'UU', 'VV', 'PH', 'TH', 'QV', 'WW', 'PR', 'PB' /)
-after line 438, add (in the #if EM_CORE block):
grid%ts_pb_profile(n,i,k)=grid%pb(ix,k,iy)

-after new line 471, add (in the #if EM_CORE block):
grid%ts_pb_profile(n,i,k) = 1.E30

-after new line 573, add (in the #if EM_CORE block):
DO k=1,grid%max_ts_level
ts_buf(:,:)=grid%ts_pb_profile(:,:,k)
CALL wrf_dm_min_reals(ts_buf(:,:),grid%ts_pb_profile(:,:,k),grid%ts_buf_size*grid%max_ts_locs)
END DO

-after new line 813, add (in the #if block, write-statement):
!Write pb profile to separate file
iunit = get_unused_unit()
IF ( iunit <= 0 ) THEN
CALL wrf_error_fatal('Error in write_ts: could not find a free Fortran unit.')
END IF
!Recreate filename for base state pressure profiles
k = LEN_TRIM(ts_profile_filename)
WRITE(ts_profile_filename(k-1:k), '(A2)') 'PB'

OPEN(UNIT=iunit, FILE=TRIM(ts_profile_filename), STATUS='unknown', POSITION='append', FORM='formatted')

DO n=1,grid%next_ts_time - 1

WRITE(UNIT=iunit,FMT=profile_format) &
grid%ts_hour(n,i), &
grid%ts_pb_profile(n,i,1:grid%max_ts_level)
END DO
CLOSE(UNIT=iunit)



(2) Revise Registry/Registry.EM_COMMON:

-after line 741, add:
state real ts_pb_profile ?!k misc - - - "TS_PB_PROFILE" "Base State Pressure"


After making these changes, it's mandatory to go back to your WRF directory and issue a "./clean -a," then reconfigure and recompile, in order to see the changes in the output.
NCAR/MMM

Post Reply

Return to “FAQ: Adding New Features in WRF”