andizuend / AIOMFAC

Aerosol Inorganic-Organic Mixtures Functional groups Activity Coefficients (AIOMFAC) model code (used within the online model AIOMFAC-web)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question about ammonium bisulfate

tcbbcc opened this issue · comments

Hi, I am trying to compute the activity coefficient for the mixture with organic and ammonium bisulfate. However, I received the error message said "Program received signal SIGSEGV: Segmentation fault - invalid memory reference". When I switched to ammonium sulfate, no such error appeared. Is there any limitation for the calculation of ammonium bisulfate system?

input_0404.txt

I use the same input downloaded from the website. With the same input, I have the results from the web-online but error message from the offline code.

Hi,
There is no limitation to using ammonium bisulfate instead of ammonium sulfate for your system. The difference is merely that ammonium bisulfate leads to partial dissociation and therefore more ion species in the system, which will therefore require a bit more memory during calculations (and may require a slightly larger stack size).
The encountered issue could be related to the specific commands / compiler you may have used. Please have a look at the suggested commands in the 'maketemplate.txt' file. I cannot reproduce the issue you mentioned. Using your input file works without problems on my machine, both with the Intel Fortran compiler (on Windows) as well as with a recent version of gfortran in a Linux environment. If using the stated compiler and linking options does not help, please show the command line you used to compile the code.

Hi, thank you very much for the comments. I am using gfortran-7.4 in the WSL system.

After debugging, I found that at the line 455 of ModCalcActCoeff.f90, the function “fHSO4dissoc” can not be passed into the subroutine "zerobracket_inwards". When I changed the subroutines&functions which were contained within the subroutine "HSO4DissociationCheck" to be under the module ModCalcActCoeff, the function "fHSO4dissoc" can be then passed into "zerobracket_inwards". I am not sure if it is the compiler problem. But now I can have the same results with the online calculation.

However, the file ModCalcActCoeff.f90 is little messy now because some parameters that were originally calculated in the subroutine "HSO4DissociationCheck" can not be used in the subroutine "DiffKsulfuricDissoc". Then I redefine the parameters and recalculate some parameters in the subroutine "DiffKsulfuricDissoc".

ModCalcActCoeff.f90.txt

Hi, thanks for clarifying the issue and showing your workaround.
I have not seen a problem with passing the contained function in any version of gfortran and ifort I tested (with my command line options). It may be an issue with the command line options you used or that gfortran version(?), which may then cause issues when passing arguments in the fHSO4dissoc interface. I don't think that this is a bug in the actual code and I do not suggest that you change the source code of that module. Instead, I suggest that you (1) update all source files to the latest version (currently v2.32) and (2) use command line options that are similar to those listed in maketemplate.txt file (from FortranCode folder), including the flags -ffree-line-length-none -fdefault-real-8 for gfortran. Also, updating gfortran to a more recent version may be useful (I currently run v9.3.0 in WSL).

Hope that helps, otherwise let me know.

Hi,
I tried reinstall the WSL (ubuntu-20.04) and gfortran-9.30. I downloaded the newest version of source code. The strange error still exist in the new system. I use the exactly same compilation flag in the maketemplate.txt. It can successfully pass the compilation, so I don't think the code itself has problem.

I think both the subroutine zerobracket_inwards and the function brentzero can cause error in my end when I passed the function fHSO4dissoc to subroutines. Since zerobracket_inwards and brentzero were not used elsewhere, I tried to move these two subroutine/functions to be within the subroutine HSO4DissociationCheck. Then I call the subroutine DiffKsulfuricDissoc instead of using function fHSO4dissoc in the zerobracket_inwards and brentzero. With that, I am able to avoid the strange error without significantly changing the major structure of source code.

ModCalcActCoeff.f90.txt

Hi,
This sounds odd and the described issue cannot be reproduced on my system -- nor have I learned from other users running into this problem.
To double check, I downloaded the zip-file of the latest release, unzipped to a local directory, then manually created the "Inputfiles" and "Outputfiles" folders (in Windows Explorer), added your input file and ran the makefile generation, make, and lastly the generated executable (all under WSL, Ubuntu 20.04 LTS, as you have installed as well). The program runs without any issues and correctly generates the output files; --> see the attached screenshot (not showing the output files).

Since you seem to have done it the same way, I don't know what causes this problem on your system, but I am glad that you found a way to get it to run without major changes.

WSL_screenshot_AIOMFAC-web_2 32_gfortran9 3

It is so weird that I never had this kind of issue with other Fortran program. I even tested in a newly installed virtual windows 10 system. I still don't know why it can cause error to pass function. I think I will just compromise with the current solution.
And I really appreciate your time and help :)

Untitled picture