Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for automated TEM Diagnostics #76

Merged
merged 3 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added new BCS version v12

### Changed

- Move to use `time_ave_util.x` from MAPL instead of `time_ave.x`

### Fixed

### Removed

- mask from `read_reynolds.F90`

### Deprecated

## [2.1.0] - 2024-06-10

### Added

- Added new BCS version v12
- Updates for TEM diagnostics

### Removed

- Removed mask from `read_reynolds.F90`

## [2.0.8] - 2024-03-29

### Fixed
Expand Down
95 changes: 95 additions & 0 deletions plots/grads_util/Create_TEM_ddf.csh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/csh -fx

setenv ARCH `uname`

setenv SITE NCCS
setenv GEOSDIR /discover/nobackup/ltakacs/TAGS/Jason-4_0_p2/GEOSagcm
setenv GEOSBIN /discover/nobackup/ltakacs/TAGS/Jason-4_0_p2/GEOSagcm/Linux/bin
setenv GEOSUTIL /discover/nobackup/ltakacs/TAGS/Jason-4_0_p2/GEOSagcm/src/GMAO_Shared/GEOS_Util

source $GEOSBIN/g5_modules
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${BASEDIR}/${ARCH}/lib

set EXPID = $1
set TEM_Collection = $2

# Count Number of "Dots" in EXPID
# -------------------------------
set expdots = ''
@ n = 0
@ b = 1
set bit = `echo ${EXPID} | cut -b $b`
while( "${bit}" != '' )
if( "${bit}" == '.' ) then
@ n = $n + 1
endif
@ b = $b + 1
set bit = `echo ${EXPID} | cut -b $b`
end
set expdots = `echo $expdots $n`
@ date_node = $expdots + 4
echo Date_Node: $date_node

/bin/rm -f grads.commands
touch grads.commands
echo \'open residual.$EXPID.ctl\' >> grads.commands
echo \'run writegrads.gs -name $EXPID.${TEM_Collection}.monthly -time one\' >> grads.commands
echo \'quit\' >> grads.commands
grads -b -l -c "run grads.commands"

set files = `/bin/ls -1 $EXPID.${TEM_Collection}.monthly.*.data`
foreach file ($files)
set date = `echo $file | cut -d. -f${date_node}`
$GEOSBIN/flat2hdf.x -flat $file -ctl $EXPID.${TEM_Collection}.monthly.$date.ctl -nymd $date -nhms 0 -ndt 21600
end

stripname data.nc4 nc4
/bin/rm $EXPID.*.data
/bin/rm $EXPID.*.ctl

# Create DDF File
# ---------------
set monthlies = `/bin/ls -1 $EXPID.${TEM_Collection}.monthly.*.nc4`
set num = `/bin/ls -1 $monthlies | wc -l`
echo num = $num

set edate = `echo $monthlies[$num] | cut -d "." -f${date_node}`
set eyear = `echo $edate | cut -c1-4`
set emonth = `echo $edate | cut -c5-6`

set date = `echo $monthlies[1] | cut -d "." -f${date_node}`
set year = `echo $date | cut -c1-4`
set month = `echo $date | cut -c5-6`

echo edate = $edate
echo eyear = $eyear
echo emonth = $emonth

# set expdsc = `grep EXPDSC: $HISTORYRC | cut -d" " -f2`
set timinc = "mo"

if( $month == "01" ) set MON = JAN
if( $month == "02" ) set MON = FEB
if( $month == "03" ) set MON = MAR
if( $month == "04" ) set MON = APR
if( $month == "05" ) set MON = MAY
if( $month == "06" ) set MON = JUN
if( $month == "07" ) set MON = JUL
if( $month == "08" ) set MON = AUG
if( $month == "09" ) set MON = SEP
if( $month == "10" ) set MON = OCT
if( $month == "11" ) set MON = NOV
if( $month == "12" ) set MON = DEC

@ nmonths = ( $eyear - $year ) * 12 + ( $emonth - $month ) + 1

/bin/rm -f $EXPID.${TEM_Collection}.monthly.ddf
echo DSET ^$EXPID.${TEM_Collection}.monthly.%y4%m201.nc4 > $EXPID.${TEM_Collection}.monthly.ddf
echo TITLE Dummy Experiment Description >> $EXPID.${TEM_Collection}.monthly.ddf
echo OPTIONS template >> $EXPID.${TEM_Collection}.monthly.ddf
echo TDEF time $nmonths LINEAR 00:00Z01$MON$year 1$timinc >> $EXPID.${TEM_Collection}.monthly.ddf





16 changes: 16 additions & 0 deletions plots/grads_util/getinfo
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ grav = 9.80665

* -----------------

* Get Grads Config and Version
* ----------------------------
if (name="config")
'query config'
config = sublin(result,1)
endif

if (name="version")
'query config'
config = sublin(result,1)
version = subwrd(config,2)
endif

if( file = "" )
'query file'
file = sublin(result,1)
Expand Down Expand Up @@ -318,6 +331,9 @@ pagey = subwrd(pagey ,6)

* Return Options
* --------------
if (name="config" ) ; return config ; endif
if (name="version" ) ; return version ; endif

if (name="dset" ) ; return dset ; endif
if (name="file" ) ; return file ; endif
if (name="desc" ) ; return desc ; endif
Expand Down
1 change: 1 addition & 0 deletions plots/grads_util/getobs.gs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ endif
if( file = "NULL" )
if( ftype = "BIN" ) ; ' open 'fname ; endif
if( ftype = "HDF" ) ; 'xdfopen 'fname ; endif
if( ftype = "CFIO" ) ; 'xdfopen 'fname ; endif
if( ftype = "SDF" ) ; 'sdfopen 'fname ; endif


Expand Down
4 changes: 2 additions & 2 deletions plots/grads_util/makezdif.gs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ minval = 1e15
endwhile
*say ' '

*'close 'newfile
'!remove ZDIFILE.txt'
'run setenv "ZDIFILE" 'newfile
say 'run setenv "ZDIFILE" 'newfile
'run setenv "ZDIFILE" 'newfile

* Reset Initial Environment Settings
* ----------------------------------
Expand Down
9 changes: 9 additions & 0 deletions plots/grads_util/rgbset.gs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@
'set rgb 93 234 234 234'
'set rgb 94 252 252 252'

* RGB Parameters for STATS Package using Latest Grads Version
* -----------------------------------------------------------
'getinfo version'
version = result

if( version != 'v2.0.1.oga.1' )

* black dots
'set tile 200 2 10 10 2 0'
'set rgb 200 tile 200'
Expand Down Expand Up @@ -181,3 +188,5 @@
'set tile 229 2 15 15 1 29'
'set rgb 229 tile 229'

endif

105 changes: 76 additions & 29 deletions plots/grads_util/writegrads.gs
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
function writegrads(args)

*****************************************************************************************
* Note: To Write Data in Reverse Order
* run setenv ZFLIP ON
*
* args: -vars list of variables to write (Default: all variables)
* -levs list of levels to write (Default: all levels)
* -time all (all times to single file, Default)
* one (one time per file)
* -name name of binary name.data and name.ctl file (Default: name = grads)
*
* Note: To Write Data in Reverse Order
* run setenv ZFLIP ON
*
*****************************************************************************************

'numargs 'args
Expand Down Expand Up @@ -36,13 +41,15 @@ if( xdim = 1 ) ; dlon = 1 ; endif

VARS = 'ALL'
LEVS = 'ALL'
TIME = 'ALL'
NAME = 'grads'

n = 0
num = 0
while ( num < numargs )
num = num + 1
if( subwrd(args,num) = '-name' ) ; NAME = subwrd(args,num+1) ; endif
if( subwrd(args,num) = '-time' ) ; TIME = subwrd(args,num+1) ; endif

* Read VARS
* ---------
Expand Down Expand Up @@ -121,6 +128,9 @@ endif
'numargs 'VARS
numvars = result

'run uppercase 'TIME
TIME = result

*******************************************

'q gxout'
Expand All @@ -139,14 +149,6 @@ endif
lonbeg = result
'getinfo lat'
latbeg = result
'setx'
'sety'

* --------------------------------

'set t 1'
'getinfo date'
begdate = result
'getinfo tinc'
tinc = result
'getinfo tunit'
Expand All @@ -159,29 +161,53 @@ if( tunit = 'month' ) ; tunit = mo ; endif
if( tunit = 'day' ) ; tunit = dy ; endif
if( tunit = 'hour' ) ; tunit = hr ; endif

'setx'
'sety'

* --------------------------------

* --------------------------------------------------------------------

t=1
while(t<=tdim)

'set t 't

'getinfo date'
date = result
year = substr( date,9,4 )
day = substr( date,4,2 )
month = get_month()
yyyymmdd = year''month''day

if( t = 1 | TIME = 'ONE' )

* Write 'NAME'.ctl
* ----------------
'!remove 'NAME'.ctl'
'!touch 'NAME'.ctl'
'!echo dset ^'NAME'.data >> 'NAME'.ctl'
'!echo title 'label' >> 'NAME'.ctl'
'!echo undef 1e15 >> 'NAME'.ctl'
'!echo xdef 'xdim' linear 'lonbeg' 'dlon' >> 'NAME'.ctl'
'!echo ydef 'ydim' linear 'latbeg' 'dlat' >> 'NAME'.ctl'
'!echo zdef 'zdim' levels 'LEVS' >> 'NAME'.ctl'
'!echo tdef 'tdim' linear 'begdate' 'tinc''tunit' >> 'NAME'.ctl'
'!echo vars 'numvars' >> 'NAME'.ctl'
'!remove 'NAME'.'yyyymmdd'.ctl'
'!touch 'NAME'.'yyyymmdd'.ctl'
'!echo dset ^'NAME'.'yyyymmdd'.data >> 'NAME'.'yyyymmdd'.ctl'
'!echo title 'label' >> 'NAME'.'yyyymmdd'.ctl'
'!echo undef 1e15 >> 'NAME'.'yyyymmdd'.ctl'
'!echo xdef 'xdim' linear 'lonbeg' 'dlon' >> 'NAME'.'yyyymmdd'.ctl'
'!echo ydef 'ydim' linear 'latbeg' 'dlat' >> 'NAME'.'yyyymmdd'.ctl'
'!echo zdef 'zdim' levels 'LEVS' >> 'NAME'.'yyyymmdd'.ctl'
if( TIME = 'ALL' )
'!echo tdef 'tdim' linear 'date' 'tinc''tunit' >> 'NAME'.'yyyymmdd'.ctl'
else
'!echo tdef 1 linear 'date' 'tinc''tunit' >> 'NAME'.'yyyymmdd'.ctl'
endif
'!echo vars 'numvars' >> 'NAME'.'yyyymmdd'.ctl'

* --------------------------------------------------------------------

'set gxout fwrite'
'set fwrite 'NAME'.data'
'set fwrite 'NAME'.'yyyymmdd'.data'

'set undef 1e15'
endif

t=1
while(t<=tdim)
'set t 't

'set undef 1e15'

n=1
while(n<=nvars)
Expand Down Expand Up @@ -232,7 +258,7 @@ while(n<=nvars)
if( name = slp ) ; zref = 0 ; endif

if( zref = 0 )
if( t=1 ) ; '!echo "'desc'" >> 'NAME'.ctl' ; endif
if( ( t=1 & TIME = 'ALL' ) | TIME = 'ONE' ) ; '!echo "'desc'" >> 'NAME'.'yyyymmdd'.ctl' ; endif
* say 'Writing Variable: 'name
'set z 1'
e = 1
Expand All @@ -242,7 +268,7 @@ while(n<=nvars)
e = e + 1
endwhile
else
if( t=1 ) ; '!echo "'desc'" >> 'NAME'.ctl' ; endif
if( ( t=1 & TIME = 'ALL' ) | TIME = 'ONE' ) ; '!echo "'desc'" >> 'NAME'.'yyyymmdd'.ctl' ; endif

if(zflip != 'ON' )
z=1
Expand Down Expand Up @@ -286,11 +312,32 @@ while(n<=nvars)

n=n+1
endwhile
if( t=1 ) ; '!echo endvars >> 'NAME'.ctl' ; endif

if( ( t=1 & TIME = 'ALL' ) | TIME = 'ONE' ) ; '!echo endvars >> 'NAME'.'yyyymmdd'.ctl' ; endif
if( TIME = 'ONE' ) ; 'disable fwrite' ; 'set gxout 'gxout ; endif

say ' '
t=t+1
endwhile

'disable fwrite'
if( TIME = 'ALL' ) ; 'disable fwrite' ; endif
'set gxout 'gxout
return

function get_month(args)
'getinfo month'
month = result
if(month="JAN") ; monthnum = 01 ; endif
if(month="FEB") ; monthnum = 02 ; endif
if(month="MAR") ; monthnum = 03 ; endif
if(month="APR") ; monthnum = 04 ; endif
if(month="MAY") ; monthnum = 05 ; endif
if(month="JUN") ; monthnum = 06 ; endif
if(month="JUL") ; monthnum = 07 ; endif
if(month="AUG") ; monthnum = 08 ; endif
if(month="SEP") ; monthnum = 09 ; endif
if(month="OCT") ; monthnum = 10 ; endif
if(month="NOV") ; monthnum = 11 ; endif
if(month="DEC") ; monthnum = 12 ; endif
return monthnum

Loading
Loading