# How to Combine CCTM for all layers?

**URL:** <https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699>\
**Category:** Post-processing\
**Tags:** cmaq\
**Created:** [November 10, 2022, 6:13am UTC](https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699 "2022-11-10T06:13:01Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ting](https://avatars.discourse-cdn.com/v4/letter/t/8c91f0/32.png) [@ting](https://forum.cmascenter.org/u/ting)\
**Post date:** [November 10, 2022, 6:13am UTC](https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699/1 "2022-11-10T06:13:01Z")

</div>

Dear all,  
I’m using CMAQ-combine to process CMAQ output files, and I want to combine output all layers. In the Species definition file, I have changed ‘#layer 1’ to ‘!#layer 1’, but I only got 1 layer. How can I solve this problem？  
Look forward to and thank you for your guidance.

Some information of the log file is shown as follows :  
slight\_smile: Missing environment variable EXECUTION\_ID  
API Started  
Value for IOAPI\_ISPH not defined; returning defaultval ': ‘20’  
Value for IOAPI\_ISPH not defined; returning defaultval ': ‘20’  
_WARNING_ IOAPI\_ISPH not set in script, using 20 (WRF-ARW sphere)  
Value for IOAPI\_CHECK\_HEADERS not defined;returning default: FALSE

```
 "INFILE1" opened as OLD:READ-ONLY   
 File name "/home/ltt/CMAQ/CMAQv5.3/data/chq202101-BEM3-03d/cctm/CCTM_DRYDEP_v533_gcc_chongqing_20210102.nc"
 File type GRDDED3 
 Execution ID "CMAQ_CCTMv533_ltt_20221109_150413_305590332"
 Grid name "chq202101-BEM3-0"
 Dimensions: 109 rows, 94 cols, 1 lays, 172 vbles
 NetCDF ID: 65536 opened as READONLY            
 Starting date and time 2021002:010000 (1:00:00 Jan. 2, 2021)
 Timestep 010000 (1:00:00 hh:mm:ss)
 Maximum current record number 24
  
 "INFILE2" opened as OLD:READ-ONLY   
 File name "/home/ltt/CMAQ/CMAQv5.3/data/chq202101-BEM3-03d/cctm/CCTM_WETDEP1_v533_gcc_chongqing_20210102.nc"
 File type GRDDED3 
 Execution ID "CMAQ_CCTMv533_ltt_20221109_150413_305590332"
 Grid name "chq202101-BEM3-0"
 Dimensions: 109 rows, 94 cols, 1 lays, 141 vbles
 NetCDF ID: 131072 opened as READONLY            
 Starting date and time 2021002:010000 (1:00:00 Jan. 2, 2021)
 Timestep 010000 (1:00:00 hh:mm:ss)
 Maximum current record number 24
  
 "INFILE3" opened as OLD:READ-ONLY   
 File name "/home/ltt/CMAQ/CMAQv5.3/data/chq202101-BEM3-03d/mcip/METCRO2D_2021002.nc"
 File type GRDDED3 
 Execution ID "mcip"
 Grid name "chq202101-BEM3_C"
 Dimensions: 109 rows, 94 cols, 1 lays, 35 vbles
 NetCDF ID: 196608 opened as READONLY            
 Starting date and time 2021002:000000 (0:00:00 Jan. 2, 2021)
 Timestep 010000 (1:00:00 hh:mm:ss)
 Maximum current record number 25

```

**WARNING** File does not exist:  
Value for GENSPEC: N returning FALSE  
Value for ALLOW\_BADVALUES not defined;returning default: FALSE

```
 Value for IOAPI_CHECK_HEADERS not defined;returning default: FALSE
 
 >>--->> WARNING in subroutine OPEN3
 File already exists.
 
  
 "OUTFILE" opened as OLD:READ-WRITE  
 File name "/home/ltt/CMAQ/CMAQv5.3/data/chq202101-BEM3-03d/POST/COMBINE_DEP_v532_gcc_chq202101-BEM3-03d_20210102"
 File type GRDDED3 
 Execution ID "????????????????"
 Grid name "chq202101-BEM3-0"
 Dimensions: 109 rows, 94 cols, 1 lays, 102 vbles
 NetCDF ID: 262144 opened as READWRITE           
 Starting date and time 2021002:010000 (1:00:00 Jan. 2, 2021)
 Timestep 010000 (1:00:00 hh:mm:ss)
 Maximum current record number 24

```

Processing starting at: 2021002 10000  
ending at: 2021003 0

---

<div class="post-metadata">

**Author:** ![ting](https://avatars.discourse-cdn.com/v4/letter/t/8c91f0/32.png) [@ting](https://forum.cmascenter.org/u/ting)\
**Post date:** [November 10, 2022, 6:32am UTC](https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699/2 "2022-11-10T06:32:21Z")

</div>

[combine\_log.txt](https://forum.cmascenter.org/uploads/short-url/7pfNwSOS1cha1ojYJwO10uYYJSF.txt) (304.6 KB)  
[run\_combine\_daybyday.csh](https://forum.cmascenter.org/uploads/short-url/yG4vGiiTsRG6uKU9DrWKYykE82E.csh) (6.6 KB)  
[SpecDef\_cb6r3\_ae6\_aq.txt](https://forum.cmascenter.org/uploads/short-url/zzyKdkGsTxgvGprEjQdOboqYVfv.txt) (15.4 KB)  
[SpecDef\_Dep\_cb6r3\_ae6\_aq.txt](https://forum.cmascenter.org/uploads/short-url/6W09hpZMvKkSOI2H6RK4mpcwLQq.txt) (9.4 KB)

---

<div class="post-metadata">

**Author:** ![hogrefe.christian](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@hogrefe.christian](https://forum.cmascenter.org/u/hogrefe.christian)\
**Post date:** [November 10, 2022, 12:16pm UTC](https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699/3 "2022-11-10T12:16:34Z")

</div>

Changing ‘#layer 1’ to ‘!#layer 1’ in the SpecDef file is necessary but not sufficient to obtain 3D output files from combine. The other requirement is for all input files to be 3D files and for the number of layers to match across all input files.

Changing ‘#layer 1’ to ‘!#layer 1’ merely instructs combine to use all layers from the input files (more precisely from the first input file which is used to define the grid structure of the output file, which is why it is important in this case for the number of layers to match across all input files), but if the input files only have 1 layer (as is the case for the example you posted, with DRYDEP, WETDEP1, and METCRO2D defined as inputs), the output will only have 1 layer, too.

As noted in the [older thread](https://forum.cmascenter.org/t/how-to-combine-cctm-for-layer-2-and-other-layers-in-the-conc-file/1714/18) in which you posted a related question, if you want to create a 3D file with concentrations (deposition is by definition a 2D variable, so there is no sense in trying to create a 3D deposition file, at least not using the traditional cartesian definition of 3D), you’ll need to update the run script to only define 3D files as input (i.e. CONC and METCRO3D, assuming your CONC files were created as 3D files with the number of layers matching METCRO3D, and potentially PMDIAG if you wrote it out as 3D file and the layers match, too) and also update the SpecDef file to only reference variables from these input files.

---

<div class="post-metadata">

**Author:** ![ting](https://avatars.discourse-cdn.com/v4/letter/t/8c91f0/32.png) [@ting](https://forum.cmascenter.org/u/ting)\
**Post date:** [November 11, 2022, 3:08am UTC](https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699/4 "2022-11-11T03:08:26Z")

</div>

Dear @hogrefe.christian  
Your suggestion is very useful to me. According to your guidance, the problem has been solved well. Thank you sincerely!  
Ting

---

<div class="post-metadata">

**Author:** ![Jason\_Hu](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@Jason\_Hu](https://forum.cmascenter.org/u/Jason_Hu)\
**Post date:** [March 2, 2025, 10:15am UTC](https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699/5 "2025-03-02T10:15:52Z")

</div>

could you share your run\_cctm setting? I got the same problem after setting 3D output.

---

<div class="post-metadata">

**Author:** ![Jason\_Hu](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@Jason\_Hu](https://forum.cmascenter.org/u/Jason_Hu)\
**Post date:** [March 2, 2025, 10:50am UTC](https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699/6 "2025-03-02T10:50:53Z")

</div>

@hogrefe.christian I have tried to output all layer when running CCTM. However, when using comnbine.exe, I got variables with 34 layers, but the data in first hour of all variables have values and other hours are none.  
[run\_combine.csh.txt](https://forum.cmascenter.org/uploads/short-url/52CpiAIHEQDV2k45ucUMMaJ0MDv.txt) (6.6 KB)  
[SpecDef\_cb6r3\_ae7\_aq.txt](https://forum.cmascenter.org/uploads/short-url/dUCTQIxjfOoBiaGCNuOGjRGEIdw.txt) (16.1 KB)  
[run\_combine.log.txt](https://forum.cmascenter.org/uploads/short-url/9O61Y58gEJtpTLsAMLAk8dbaTtI.txt) (298.1 KB)

---

<div class="post-metadata">

**Author:** ![hogrefe.christian](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@hogrefe.christian](https://forum.cmascenter.org/u/hogrefe.christian)\
**Post date:** [March 2, 2025, 11:08pm UTC](https://forum.cmascenter.org/t/how-to-combine-cctm-for-all-layers/3699/7 "2025-03-02T23:08:17Z")

</div>

If you look at your log file, you’ll see that the expression  
`exp(118.87-24084/TEMP2[4]-6.025*log(TEMP2[4]))` failed.

If you further check your log file, you’ll see that two of your input files (INFILE4 METCRO2D and INFILE5 GRIDCRO2D) have only 1 layer, not 34 layers. Therefore, computations invoking fields from those files will likely fail since values above layer 1 are undefined.

To successfully generate 3D output files, edit your SpecDef file and run script to only reference 3D input files and define equations only based on the variables present in these 3D files.
