Page 1 of 1

### Complex sulfur chemistry

Posted: October 1st, 2015, 6:06 pm
Hi,

I have been working towards changing the prchem.f code in the model to calculate unique point by point so2-so4 conversion. When I started editing the code I noticed that the existing routine was 1-D in that calculations are done in bulk across the entire domain. I am adjusting accordingly for this but one variable still remains a mystery to me - TOTSO2. The name and description of this variable suggest it is a 3-D variable which wouldn't fit in the rest of the code but I cannot find where this value is calculated in other subroutines so I do not know for sure.

My question is whether this variable is 1-D or 3-D?

Also, where is the variable calculated?

Mahalo!
Andre

### Re: Complex sulfur chemistry

Posted: October 5th, 2015, 4:14 pm
I have kept digging and I see that most multi-dimensional variable are 'packed' into 1-d vectors. This makes sense based on how the code is written but I still can not trace where the TOTSO2 variable is being calculated.

### Re: Complex sulfur chemistry

Posted: October 6th, 2015, 7:00 am
TOTSO2 is the a 1 dimensional concentration snapshot from the last time step (created by saving the current air 3D mass on the particle from the CSUM variable in the hymodelc.f main program) that is used in prchem.f to calculate the SO2 K constant which is dependent on the total SO2.

### Re: Complex sulfur chemistry

Posted: October 6th, 2015, 6:23 pm
Hi Glenn,

Thanks for your response. This is how I understand you explanation - TOTSO2 is a compressed copy of CSUM(:,:,:,1,1) when running ICHEM=4 because SO2 is species 1 and only 1 grid is run at a time. So size(TOTSO2) = size(CSUM(:,:,:,1,1)) for non-zero values in the grid.

-Andre

### Re: Complex sulfur chemistry

Posted: October 7th, 2015, 6:32 am
correct

### Re: Complex sulfur chemistry

Posted: October 7th, 2015, 10:55 pm
Great. The challenge I am having now is that I want to read in temperature, RH, and pressure to prchem.f for my KSO2 calculations at each point corresponding to CNOW/TOTSO2/CSUM. I am seeing only surface variables available in hymodelc.F (TAMB, RELH, PRES). When I look around I see prfcom.f has the variables I want (a,q,p) over the whole domain. How could I pull them into hymodelc.F so that I can create arrays to match CNOW?

-Andre

### Re: Complex sulfur chemistry

Posted: October 9th, 2015, 5:44 pm
I got the code to where it should work if TOTSO2 is of size(nx,ny,kl). Everything compiles without error however when I run hysc_so2 I get a segmentation fault during the computation of the model time step DT. This is where the MESSAGE files terminates:

------------- Start computation messages -------------------
NOTICE metpos: (mtime,ftime) - 60757200 0
NOTICE metpos: (mtime,ftime) - 60757260 0
NOTICE advpnt: (kg,nx,ny,nz) - 1 150 156
26
NOTICE sfcinp: record terminator = CR/LF
NOTICE metgrd: (kg, xyr,xy1) - 1 150 156
1 1
NOTICE metinp: AWRF 1 1 150 156
1 1 60757200 15 7 9
12
NOTICE metinp: AWRF 1 247 150 156
1 1 60757260 15 7 9
13
NOTICE main: Initial t

I have not made any changes that should effect this section of code so I am really confused as to what is going on. Any thoughts?

My CONTROL file and SETUP.CFG files are below if that helps.

15 07 09 12
2
19.38 -155.120 50.0 49583.33 100.0
19.401 -155.280 50.0 250833.33 100.0
15
1
10000.0
2
/share/huina/akp4221/data/fieldproject/2015070912/
wrf01km.2015070912
/share/huina/akp4221/data/fieldproject/2015070912/
wrf01km.2015071012
3
SO2
1.0
15.0
00 00 00 00 00
SO4
0.0001
15.0
00 00 00 00 00
SO4W
0.0
15.0
00 00 00 00 00
1
19.5 -155.5
0.01 0.01
1.5 1.5
./
new_chem_test1
1
100
00 00 00 00 00
00 00 00 00 00
00 01 00
3
0.0 0.0 0.0
0.0042 0.0 0.0 0.0 0.0
1.24 0.0 0.0
0.0
0.0
1.0 1.0 1.0
0.0025 0.0 0.0 0.0 0.0
0.0 3.2E+05 5.0E-05
0.0
0.0
1.0 1.0 1.0
0.0025 0.0 0.0 0.0 0.0
0.0 3.2E+05 5.0E-05
0.0
0.0

&SETUP
tratio = 0.75,
delt = 0.0,
initd = 0,
kpuff = 0,
khmax = 9999,
maxdim = 3,
numpar = 20000,
maxpar = 500000,
qcycle = 0.0,
efile = '',
kdef = 0,
kzmix = 0,
kbls = 1,
kblt = 2,
isot = -99,
vscale = 200.0,
hscale = 10800.0,
tvmix = 1.00,
tkerd = 0.18,
tkern = 0.18,
kmix0 = 250,
kmixd = 0,
ninit = 1,
ndump = 6,
ncycl = 6,
pinpf = 'PARINIT',
poutf = 'PARDUMP',
mgmin = 300,
conage = 48,
kmsl = 0,
ichem = 4,
cpack = 1,
cmass = 0,
kspl = 1,
krnd = 6,
frhmax = 3.00,
splitf = 1.00,
frhs = 1.00,
frvs = 0.01,
frts = 0.10,
dxf = 1.00,
dyf = 1.00,
dzf = 0.01,
/

### Re: Complex sulfur chemistry

Posted: October 13th, 2015, 2:01 pm
You should have a file called PRCHEM.DAT containing the following information:

0.90 CRITICAL RELATIVE HUMIDITY (RHCRIT)
0.015 DAY SO2-SO4/HR (KSO2DY)
0.002 NIGHT SO2-SO4/HR (KSO2NT)
0.65 DRY TO WET SO4 CONVERSION FRACTION (D2WFR)
0.90 HYDROGEN PEROXIDE (PPB) (H2O2)
0.90 LIQUID WATER CONTENT (G/M3) (LWC)

### Re: Complex sulfur chemistry

Posted: October 16th, 2015, 10:49 pm
I don't know if this was the problem but I went back and now have it working properly. I am looking to do some thresholding for each TOTSO2 value based on the grid size (dx,dy,dz). Since this changes for each level of the terrain following sigma coordinates I need to do this uniquely for each point. What subroutine would like be able to pull this information from and what variable names am I looking for?