USEPA/CMAQ

possible bugs in RUNTIME_VARS by calling get_env function

Closed this issue · 4 comments

btang1 commented

Description
A clear and concise description of the issue.
The input sequence used for get_env is wrong in RUNTIME_VARS
Scope and Impact
A description of how other users might be impacted by this issue.
RUNTIME_VARS.F code
Solution
Is there a known solution for the issue? If so, how/when will it be shared with other users.
yes, switch the 1st two input sequence for get_env function in RANTIME_VARS code
Additional context
Add any other context about the problem here.
In the RUNTIME_VAR.F code, it calls 'get_env' function. The original get_env function has a character inputs as it 2nd inputs (it takes 4 inputs in total). But in 'get desired wavelengths for diagnostic output' code. it shows 'CALL GET_ENV('NWAVE_PHOTDIAG',NWAVE,WAVE_ENV,VARDEV). I think we need to switch the first two input sequence, making 'NWAVE_PHOTDIAG' the 2nd input.

btang1 commented

Add any other context about the problem here.
In the RUNTIME_VAR.F code, it calls 'get_env' function. The original get_env function has a character inputs as it 2nd inputs (it takes 4 inputs in total). But in 'get desired wavelengths for diagnostic output' code. it shows 'CALL GET_ENV('NWAVE_PHOTDIAG',NWAVE,WAVE_ENV,VARDEV). I think we need to switch the first two input sequence, making 'NWAVE_PHOTDIAG' the 2nd input.

In get_env_mod.f90, get_env is defined as a module procedure.
The compiler determines which of those module procedures to call based on the argument types.
When GET_ENV is called with arguments ('NWAVE_PHOTDIAG', NWAVE, WAVE_ENV, VARDEV), the specific routine that is selected is get_envlist. That routine's arguments are (character, integer, character array, integer), which match the arguments used in the call vector.

If the code is not compiling for you, one alternative is to edit get_env_mod.f90 to remove get_envlist from the get_env module procedure. Then edit RUNTIME_VARS.F to explicitly call get_envlist for all of these cases:
'NPCOL_NPROW'
'AVG_CONC_SPCS'
'CONC_SPCS'
'ACONC_BLEV_ELEV'
'CONC_BLEV_ELEV'
'AISAM_BLEV_ELEV'
'ISAM_BLEV_ELEV'
'NWAVE_PHOTDIAG'
'PA_BCOL_ECOL'
'PA_BROW_EROW'
'PA_BLEV_ELEV'

fisidi commented

@btang1 thanks for your inquiry. @cgnolte's explanation is consistent with my findings. Additionally, I did a test compiling CMAQv5.4 with the GNU compiler suite disabling optimizations and enabling "debug" flags (e.g., -g -ftraceback -fcheck=all -ffpe-trap...) while toggling the PHOTDIAG file on and providing various combinations of "setenv NWAVE_PHOTDIAG".

All simulations compiled and ran successfully as intended.

So at this time we are going to close this issue. However, may we also ask that you please post additional questions and issues about CMAQ on our Users' Forum: https://forum.cmascenter.org/.

We use this forum for CMAQ questions because it has search and tagging features that make it easier for users to find answers to their questions and get connected to the appropriate developer.