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

Format of photolysisConstant #372

Open
spco opened this issue Jan 9, 2019 · 12 comments
Open

Format of photolysisConstant #372

spco opened this issue Jan 9, 2019 · 12 comments

Comments

@spco
Copy link
Collaborator

spco commented Jan 9, 2019

From #371: Rather than the format

1   1e-3   J1

photolysisConstant.config should use the format

J1   1e-3

and recreate the photo number from the name (removing the J). TODO: see whether similar can be done for photolysisConstrained.config.

@rs028
Copy link
Collaborator

rs028 commented Jan 9, 2019

Doesn't photolysisConstrained.config already works like that?

@spco
Copy link
Collaborator Author

spco commented Jan 9, 2019

Yes, looks like it's just a list of the rate names.

@xcy12
Copy link

xcy12 commented Jul 8, 2020

I may also have confusion about J values. J61 actually does not occur in the mechanism.fac file. But the PhotolysisOutput gives J61. I wonder what is J61 used for. Thank you in advance and best regards.

@rs028
Copy link
Collaborator

rs028 commented Jul 9, 2020

@xcy12 This has to do with the MCM. I think that either there was a reaction in the MCM using J61 which was then removed or changed, or it is a placeholder for future work. You can ignore it.

@xcy12
Copy link

xcy12 commented Jul 9, 2020

@xcy12 This has to do with the MCM. I think that either there was a reaction in the MCM using J61 which was then removed or changed, or it is a placeholder for future work. You can ignore it.

Got it! Thank you for your kind explanation.

@AlfredMayhew
Copy link
Collaborator

Hi,
I'm having issues trying to use the photolysisConstant.config file. I've looked at some of the other issues around this (including this one and #371 ) and I'm just wondering if this was ever resolved. I've noted what I've tried below.

  • Initially, I tried formatting as is listed in the manual:
    1 1E-5 J1
    but this raised the error:
    Finished reading photolysis numbers. Number of photolysis numbers: 35 Looking for photolysis constants file... Checking that photolysis constants exist in file... Reading photolysis constants from file... STOP readPhotolysisConstants(): error reading file
    -Then I saw this issue and changed the config file to read:
    J1 1E-5
    but got the same error.
  • Then I noticed the point about the ignoring of the first line in Don't expect a header in photolysisConstant.config. #376 so tried adding a blank line at the start of the file. This made no difference when using the J1 1E-5 format but when I used the 1 1E-5 J1 format I got a different error:
Finished reading photolysis numbers.
 Number of photolysis numbers: 35
 Looking for photolysis constants file...
 Checking that photolysis constants exist in file...
 Reading photolysis constants from file...
At line 357 of file src/inputFunctions.f90 (unit = 6, file = 'stdout')
Fortran runtime error: Expected REAL for item 3 in formatted transfer, got CHARACTER
(I7, 1P e15.3, 1P e15.3)
                  ^

Error termination. Backtrace:
#0  0x7f4fa90f2d5a
#1  0x7f4fa90f3869
#2  0x7f4fa90f454f
#3  0x7f4fa932a061
#4  0x7f4fa9336b82
#5  0x7f4fa933a2e5
#6  0x7f4fa933a9d3
#7  0x55cfef4a2177
#8  0x55cfef4900fa
#9  0x55cfef4c9365
#10  0x55cfef4cd086
#11  0x7f4fa8f050b2
#12  0x55cfef47497d
#13  0xffffffffffffffff

Do you remember if this issue was ever resolved, and if so, what is the correct format to get photolysisConstant.config to read correctly?

Thanks,
Alfie

@rs028
Copy link
Collaborator

rs028 commented Jan 31, 2022

@AlfredMayhew I think the format at the moment is still 1 1E-5 J1. From the error message it looks like the program is trying to read a file which should not be the case for a constant. Can you check if you have conflicting settings, such as photolysis rates constrained?

@AlfredMayhew
Copy link
Collaborator

@rs028 JFAC is set to NOTUSED in the environmentVariables.config file and the photolysisConstrained.config file is empty. So I don't think there are any photolysis constraints active.

I've also just noticed that in line 341 of src/inputFunctions.f90 there is a comment reading ! Ignore first line under the readPhotolysisConstants subroutine. I don't know FORTRAN so can't really read the code, but does this mean that the header issue mentioned in #371 was never actually resolved?

@spco
Copy link
Collaborator Author

spco commented Feb 1, 2022

Just reacquainting myself with the code, I think there is a bug in the formatting in src/inputFunctions.f90

if ( numConstantPhotoRates > 3 ) then
write (*, '(I7, 1P e15.3, 1P e15.3)') constantPhotoNumbers(1), constantPhotoValues(1), constantPhotoNames(1)
write (*, '(A)') ' ...'
write (*, '(I7, 1P e15.3, 1P e15.3)') constantPhotoNumbers(numConstantPhotoRates), &
constantPhotoValues(numConstantPhotoRates), constantPhotoNames(numConstantPhotoRates)
else
do i = 1, numConstantPhotoRates
write (*, '(I7, 1P e15.3, 1P e15.3)') constantPhotoNumbers(i), constantPhotoValues(i), constantPhotoNames(i)

The third entry of each output line is from constantPhotoNames which is a character array, but the formatting string has as its third entry 1P e15.3 which is for decimal display. This looks to be a bug.

@AlfredMayhew any chance you could raise a PR which corrects the second occurrence of 1P e15.3 on each of the three lines to instead be A ? So each should be '(I7, 1P e15.3, A)'. Of course try that fix out in your code as well to check it fixes the problem :)

@AlfredMayhew
Copy link
Collaborator

Of course, I'll give it a go and see if it helps. Thanks.

@rs028
Copy link
Collaborator

rs028 commented Feb 1, 2022

I think #371 was solved by #376.

Question: since we are touching the code here how easy would it be to change the format to J1 1e-3 ?

@spco
Copy link
Collaborator Author

spco commented Feb 1, 2022

The place I'm suggested be edited is purely the output to screen or file during the processing - it is not related directly to the format of the photolysisConstant.config file. That is read in on line 343. You can reorder the variables in 343 to change the expected order of the columns in the file, but I don't think we can remove entirely the 1 in the first column (or whichever column you want it to be) as that sets constantPhotoNumbers for use in

j(constantPhotoNumbers(i)) = constantPhotoValues(i)

I'm not sure whether that first column can be removed and automatically calculated without further understanding it, which I can't do at the moment.

So you can change 343 to

      read (10,*, iostat=ierr) constantPhotoNumbers(i), constantPhotoNames(i), constantPhotoValues(i)

if you want the expected file format to be
1 J1 1e-3
(plus updating the docs if this is documented).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Photolysis Rates
Development

No branches or pull requests

4 participants