AtChem / AtChem2

Atmospheric chemistry box-model for the MCM
MIT License
58 stars 23 forks source link

Truncation of Rate Definitions and Species Outputs #427

Closed AlfredMayhew closed 4 years ago

AlfredMayhew commented 4 years ago

Hi, I have run into some problems with the truncation of lines in AtChem2. The two instances are described below:

I would be grateful if somebody could point me to the code setting these limits so I could increase them for my own purposes, even if it is not deemed necessary for an update (files from the MCM do not run into these issues).

Thanks, Alfie

spco commented 4 years ago

Hi Alfie, nice to meet you.

On the first point, could you provide more detail? What errors do you get, and at what stage? During the python conversion, compilation, or at runtime? I'm not aware of any specific line-length limit (though my memory may fail me here). It may be that you're hitting your Fortran compiler's line-length limit, so if you can provide your compiler version that might be useful.

On the second point, this is controlled by maxSpecLength as defined at https://github.com/AtChem/AtChem2/blob/d01a5d904513aa36c8b023de15d70bdd41033cbb/src/dataStructures.f90#L74 . That value should be OK to lift without incident - please let me know if it does trigger any incorrect behaviour.

Sam

AlfredMayhew commented 4 years ago

Hi Sam, thanks for your response.

I think the error is due to truncation by the fortran compiler. I'm running on Ubuntu with gfortran, GNU Fortran (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0. I've copied the output from the terminal below for reference:

  • facsimile mechanism file: model/test.fac
  • fortran mechanism directory [ default = ./model/configuration/ ]:
  • mcm data files directory [ default = ./mcm/ ]:

call mech_converter.py /home/alfie/AtChem2 (copy)/model Running fix_fac_file on /home/alfie/AtChem2 (copy)/model/test.fac /home/alfie/AtChem2 (copy)/model/test.fac: file read in 82 items 1 corrections made - now removing old Reading input file looping over inputted RO2s adding RO2 to model/configuration/mechanism.ro2

make sharedlib gfortran -c model/configuration/mechanism.f90 -ffree-form -fimplicit-none -Wall -Wpedantic -Wno-unused-dummy-argument -fcheck=all -fPIC -shared -o model/configuration/mechanism.o -Jobj model/configuration/mechanism.f90:24:132:

00000000000000000000000000000000000000000000000000000000000000000000001 !% 1.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 : ABCDEFGHIJKLMNOPQRSTUVWXYZ = B ; 1 Error: Line truncated at (1) [-Werror=line-truncation] f951: some warnings being treated as errors Makefile:145: recipe for target 'sharedlib' failed make: *** [sharedlib] Error 1

With regards to the maxSpecLength, I changed the value to 50, but the output species only has 15 characters. I tried reducing it to 5, and the species outputted with 5 characters, but it doesn't seem to want to go above 15.

Thanks for your help, Alfie

spco commented 4 years ago

Hi Alfie,

Ok, the printing itself is being controlled by the output format - see https://github.com/AtChem/AtChem2/blob/d01a5d904513aa36c8b023de15d70bdd41033cbb/src/outputFunctions.f90#L359 for example - '100A15' means it can print up to 100 columns of 15-character strings. So if you increase that (and look through that file to see other places where that's used) that should fix your issue.

If you also change the 15 in https://github.com/AtChem/AtChem2/blob/d01a5d904513aa36c8b023de15d70bdd41033cbb/src/outputFunctions.f90#L368 to match, then the column values will continue to line up with the column headers, if you want that to continue.

On the compilation, please try adding the -ffree-line-length-none argument to FSHAREDFLAGS on line 70 of the Makefile.

If that fix works for you, I'd certainly appreciate that being raised as a Pull Request 😄

AlfredMayhew commented 4 years ago

Thanks very much, that seems to solve all the issues. I also adjusted to 100 part of the 100A15 phrase as I was running into issues with the grouping of species into sets of 100 in the output file. I will put the pull request through soon.

Thanks again for all your help, it will certainly make my workflow easier and speed up my running time for the models.

Alfie