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

SMOKE-AERMOD grid cell lat-lon coordinates are incorrect #40

Closed
cseppan opened this issue Aug 5, 2021 · 3 comments
Closed

SMOKE-AERMOD grid cell lat-lon coordinates are incorrect #40

cseppan opened this issue Aug 5, 2021 · 3 comments
Assignees
Labels

Comments

@cseppan
Copy link
Member

cseppan commented Aug 5, 2021

When running Smkreport with the AERMOD NONPOINT instruction, Smkreport will output the grid cell coordinates in lat-lon. These coordinates aren't matching what would be expected based on the Lambert coordinates and spheroid.

James Beidler will provide examples of correct inputs and outputs.

Here's the section of code that does the coordinate conversions:

SMOKE/src/emqa/wrrepout.f

Lines 815 to 849 in ffa9e3c

C............. Include grid cell corner coordinates
IF( RPT_%GRDPNT ) THEN
DXORIG = XORIG + XCELL * ( BINX( I ) - 1 ) ! SW corner
DYORIG = YORIG + YCELL * ( BINY( I ) - 1 )
CALL XY2XY( LATGRD3, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0,
& GDTYP , P_ALP, P_BET, P_GAM, XCENT, YCENT,
& DXORIG, DYORIG, SWLON, SWLAT )
DYORIG = DYORIG + YCELL ! NW corner
CALL XY2XY( LATGRD3, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0,
& GDTYP , P_ALP, P_BET, P_GAM, XCENT, YCENT,
& DXORIG, DYORIG, NWLON, NWLAT )
DXORIG = DXORIG + XCELL ! NE corner
CALL XY2XY( LATGRD3, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0,
& GDTYP , P_ALP, P_BET, P_GAM, XCENT, YCENT,
& DXORIG, DYORIG, NELON, NELAT )
DYORIG = DYORIG - YCELL ! SE corner
CALL XY2XY( LATGRD3, 0.0D0, 0.0D0, 0.0D0, 0.0D0, 0.0D0,
& GDTYP , P_ALP, P_BET, P_GAM, XCENT, YCENT,
& DXORIG, DYORIG, SELON, SELAT )
BUFFER = ' '
WRITE( BUFFER, LLGRDFMT ) SWLAT, SWLON, NWLAT, NWLON, NELAT, NELON, SELAT, SELON
STRING = STRING( 1:LE ) // BUFFER
MXLE = MXLE + LLGRDWIDTH
LE = MIN( MXLE, STRLEN )
END IF

According to the IOAPI documentation, the XY2XY method should take the environment variable IOAPI_ISPH into account: https://www.cmascenter.org/ioapi/documentation/all_versions/html/XY2XY.html

I suggest creating a simple Fortran program that calls XY2XY to see what the output values are, using James' example data.

@christos-e christos-e self-assigned this Aug 12, 2021
@christos-e
Copy link
Contributor

Coded with alternative options found here but results remain the same:

https://www.cmascenter.org/ioapi/documentation/all_versions/html/SETSPHERE.html

@cseppan
Copy link
Member Author

cseppan commented Nov 8, 2021

It looks like you need to explicitly call the function INITSPHERES() before using XY2XY(). This should read the environment variable and then XY2XY will automatically use the value. I'd suggest adding the call to smkreport.f, right after the existing initialization functions:

SMOKE/src/emqa/smkreport.f

Lines 143 to 151 in f371a0f

C***********************************************************************
C begin body of program SMKREPORT
LDEV = INIT3()
C......... Write out copyright, version, web address, header info, and prompt
C to continue running the program.
CALL INITEM( LDEV, CVSW, PROGNAME )

@christos-e
Copy link
Contributor

christos-e commented Nov 8, 2021

I added an IF THEN statement from /src/emmod/modgrdlib.f that seems to be doing that in wrrepout.f and fixes the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants