CMAQV5.3 ISAM Region not found

Hello everyone,
I ran into error when trying to get ISAM running for 9 source regions, which is defined in the CMAQ_MASK file as 9 variables.

The error is:
The Region FA_8
is not found in any of the regions defined
in the Emission Control File.

Emiss control file edit:
! Region | Stream Label |Emission | CMAQ- |Phase/|Scale |Basis |Op
!> CUSTOM MAPPING EXAMPLES <!

! ‘WATER’ , ‘All’ ,‘All’ ,‘All’ ,‘All’ ,0. ,‘MASS’,‘o’,!Zero out all emissions over
‘FA_1’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,2. ,‘UNIT’,‘a’,
‘FA_2’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,3. ,‘UNIT’,‘a’,
‘FA_3’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,4. ,‘UNIT’,‘a’,
‘FA_4’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,5. ,‘UNIT’,‘a’,
‘FA_5’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,6. ,‘UNIT’,‘a’,
‘FA_6’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,7. ,‘UNIT’,‘a’,
‘FA_7’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,8. ,‘UNIT’,‘a’,
‘FA_8’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,9. ,‘UNIT’,‘a’,
‘FA_9’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,10. ,‘UNIT’,‘a’,

&RegionsRegistry
RGN_NML =
! | Region Label | File_Label | Variable on File
‘ALL’ , ‘CMAQ_MASKS’, ‘ALL’

Thank you.

Best regards,
Yukui

1 Like

Hi Yukui,

to help diagnose your problem further, please post the header of your CMAQ_MASKS file (obtained with ncdump -h) and your isam_control.txt file.

The following section of the EmissCtrl file you posted

‘FA_1’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,2. ,‘UNIT’,‘a’,
‘FA_2’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,3. ,‘UNIT’,‘a’,
‘FA_3’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,4. ,‘UNIT’,‘a’,
‘FA_4’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,5. ,‘UNIT’,‘a’,
‘FA_5’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,6. ,‘UNIT’,‘a’,
‘FA_6’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,7. ,‘UNIT’,‘a’,
‘FA_7’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,8. ,‘UNIT’,‘a’,
‘FA_8’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,9. ,‘UNIT’,‘a’,
‘FA_9’ , ‘ALL’ , ‘ALL’ ,‘ALL’ ,‘ALL’ ,10. ,‘UNIT’,‘a’,

does not set up any ISAM definitions. Instead, it scales up all emissions from region ‘FA_1’ by a factor of 2, all emissions from region ‘FA_2’ by a factor of 3, etc., which may not be what you intend to do.

Hello Christian,

My CMAQ_MASK file header:
file global attributes:
IOAPI_VERSION : ioapi-3.1: Id:: init3.F 321 2016-02-26 16:00:20Z coats
EXEC_ID : ???
FTYPE : 1
CDATE : 2016001
CTIME : 134315
WDATE : 2018134
WTIME : 134315
SDATE : 2005001
STIME : 0
TSTEP : 240000
NTHIK : 1
NCOLS : 396
NROWS : 246
NLAYS : 1
NVARS : 7
GDTYP : 2
P_ALP : 33
P_BET : 45
P_GAM : -97
XCENT : -97
YCENT : 40
XORIG : -2412000
YORIG : -1620000
XCELL : 12000
YCELL : 12000
VGTYP : 7
VGTOP : 5000
VGLVLS : ( 0, 0 )
GDNAM : 12US2
UPNAM : M3WNDW
VAR-LIST : FA_1 FA_2 FA_3 FA_4 FA_5 FA_6 FA_7 FA_8 FA_9
FILEDESC : con
HISTORY :
dimensions:
TSTEP = 365
VAR = 2
DATE-TIME = 2
LAY = 1
ROW = 246
COL = 396
variables:
integer TFLAG ( TSTEP, VAR, DATE-TIME )
units : <YYYYDDD,HHMMSS>
long_name : TFLAG
var_desc : Timestep-valid flags: (1) YYYYDDD or (2) HHMMSS

  float FA_1 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

  float FA_2 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

  float FA_3 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

  float FA_4 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

  float FA_5 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

  float FA_6 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

  float FA_7 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

  float FA_8 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

  float FA_9 ( TSTEP, LAY, ROW, COL )
     var_desc :     XY                                                    
     units :
     long_name :    MODIS_FPAR_T

And my isam_control.txt setting:
TAG CLASSES |OZONE

TAG NAME |GR1
REGION(S) |EVERYWHERE
EMIS STREAM(S) |GRIDDED_EMIS

I want to do isam running for 9 source regions, which are defined in the CMAQ_MASK file.

Thank you.

Thank you for posting this information. A few thoughts:

Do you want to track the combined contribution of the emissions from all nine regions on ozone, or do you want to track the contribution of the emissions from each region separately?

In the first case, you would want to list all regions for a single tag by setting the following in isam_control.txt:

TAG CLASSES |OZONE

TAG NAME |GR1
REGION(S) |FA_1, FA_2, FA_3, FA_4, FA_5, FA_6, FA_7, FA_8, FA_9
EMIS STREAM(S) |GRIDDED_EMIS

(I am assuming that the nine regions are a subset of your entire modeling domain. If their sum is equal to the entire modeling domain, you could keep the ‘EVERYWHERE’ keyword and you wouldn’t need any CMAQ_MASK file)

In the second case, you would want to define nine separate tags, each tracking the contribution from a single region:

TAG CLASSES |OZONE

TAG NAME |GR1
REGION(S) |FA_1
EMIS STREAM(S) |GRIDDED_EMIS

TAG NAME |GR2
REGION(S) |FA_2
EMIS STREAM(S) |GRIDDED_EMIS

TAG NAME |GR3
REGION(S) |FA_3
EMIS STREAM(S) |GRIDDED_EMIS

etc.

Second, looking at the header of the CMAQ_MASK file you posted, it does not appear to have been created with I/O API library tools and as a result may not be fully compliant with I/O API standards. For example, the VAR-LIST attribute should have a string length of 16 characters times the number of variables while you appear to be separating variable names by a single blank. This may cause problem reading variables from your CMAQ_MASK file. I also noticed that your CMAQ_MASK file has 365 TSTEPS which is unusual given that it should not vary in time.

Third, as mentioned in my first post, unless you want to scale up all emissions from region ‘FA_1’ by a factor of 2, all emissions from region ‘FA_2’ by a factor of 3, etc., you should remove that section from your EmissCtrl file.

Finally, we want to make sure you are aware of this Known Issue with CMAQ-ISAMv5.3.1 predictions of secondary gas species. A bugfix release (v5.3.2) is planned for later this spring that will address this issue. It’s fine to proceed with setting up and testing CMAQ-ISAM for your application, but you would want to switch to the updated version of the code before moving to the stage of analyzing/interpreting your simulation results.

Regarding my second point above, please also see this simple test suggested by @cjcoats to verify that the CMAQ_MASK file you generated can successfully be opened and read I/O API library functions. If this test fails, your CMAQ_MASK file wouldn’t work with CMAQ, either.

Thanks for the information. You are right, my CMAQ_MASK file is not fit. I use ncl to make my CMAQ_MASK file. I should try to figure out how to make my CMAQ_MASK using I/O API library tools. I am a new user of CMAQ, so there are a lot of things to learn. Thank you so much.

Hello Christain,

I use ncl to make my CMAQ_MASK file. So is that means I can not use ncl to make any input files for CMAQ? Is that means I can only use ioapi-3.2 to make CMAQ input files including CMAQ_MASK, emissions files?

Hello Yukui,

in theory you can use ncl to generate a file that complies with I/O API standards and is readable by I/O API library functions, but it is not at all trivial and requires an in-depth understanding of the I/O API standards. While there may be some initial learning curve, you probably will find it easier to generate the file by creating Fortran code that utilizes I/O API library functions or by possibly working with existing I/O API M3tools programs that are part of I/O API. You may also find this following discussion thread of interest and might want to reach out to the user to see how they solved their problem.

Right.
The EDSS/Models-3 I/O API home page:
The Models-3 I/O API is A programming interface, not a data format !!

I/O API files are not synonymous with “netCDF files” !!

Yukui,

A quick solution is to “borrow” the meta data. This solution assumes your new data is the same shape and consistent with the spatial domain in the borrowed meta data. For now, I assume you are using files with only one variable. This could be modified for multiple variables.

Each step includes code that can be used from the command line.

  1. Make your mask with ncl (hereafter /path/to/nclmask.nc)

  2. Copy an existing IOAPI compliant mask file

    cp /path/to/existing/ioapimask.nc /path/to/new/ioapimask.nc
    
  3. Use ncrename to change the variable name

    ncrename -v OLDNAME,NEWNAME /path/to/new/ioapimask.nc
    
  4. Use ncatted to edit the VAR-LIST global property to be consistent with the new name that must include 16 characters (spaces for unused characters).

    ncatted -a "VAR-LIST,global,o,c,NEWNAME         " /path/to/new/ioapimask.nc`
    
  5. Use python to overwrite the data (requires netCDF4 python library).

    python -ic "from netCDF4 import Dataset
    nclf = Dataset('/path/to/nclmask.nc')
    ioapif = Dataset('/path/to/ioapimask.nc', 'r+s')
    ioapif.variables['NEWNAME'][:] = nclf.variables['NEWNAME']
    ioapi.close()
    "
    

I repeat: treating I/O API data in this way is not supported.

So far, to the best of my knowledge, everyone who has attempted to do this has failed in at least one important regard (and this is true of both VERDI and PAVE, by the way).

Carlie J. Coats, Jr., Ph.D.
I/O API Author/Maintainer

Thank you all for the information. I am trying to use ioapi-3.1 to recreate my CMAQ_MASK file.

Hello Carlie and Christian,

One question, is there anywhere that I can find examples of run code or Fortran code that makes the CMAQ_MASK file? I can not find much information about using Fortran code to make netcdf file. Or can I have a look about the code that makes “GRIDMASK_STATES_12US1.nc” file?

Thank you. Looking forward to hearing from you.

Best regards,
Yukui

There are many thousands of lines of such code as part of the I/O API’s M3Tools (and in fact having a good repository of sample codes is deliberate); a particularly good one to look at would be the “latlon” program, which creates Lat-Lon 2-D files of type GRIDDED and BOUNDARY. “vertintegral” might be another one to look at…

BTW, the current I/O API version is the 3.2; version 3.1 is in maintenance-only, and the netCDF changes made in netCDF-4 break it, so it requires netCDF-3, and its use is discouraged.

Carlie J. Coats, Jr., Ph.D.                    cjcoats@email.unc.edu
Senior Software Engineer                   I/O API Author/Maintainer
Center for Environmental Modeling for Policy Development,
UNC Institute for the Environment                     www.ie.unc.edu
100 Europa Dr., Suite 490 Rm 4051 / Campus Box 1105     919.843.5951
Chapel Hill, NC 27599-1105                          Fax 919.966.9920

Hello all,

I want to run m3mask in ioapi-3.2, is there any example of MASKDATA file?

Thank you.

No. Just use your favorite text editor to create a text file with lines of the form
COL ROW
containing a list of the in-mask (MASK=1) grid-cells.

Thank you. Another question is what LLFILE for m3mask? Is it the REPORT of M3TOTXT? Is the LLFILE a netcdf file or txt file? If it’s a netcdf file, can I use the mcip file GRIDCRO2D file?

2-D gridded file on the same grid as CMAQ, with variables LAT and LON. Could be a GRID_CRO_2D or could be an output of M3Tools program latlon.

Can m3mask ouput file have multiple variables?

no it can’t

[filler so that the posting-nazi software (q.v Friends) will be happy]