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
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?
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
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?
Hello, I read the answer above and use the m3mask file to generate the region file. But now I am not very clear about the data format preparation of MASKDATA. The file I prepared is attached below. The LLFILE file is the GRIDCRO2D file used. It will report an error when running, can you help me see what the reason is, thank you (664.8 KB)maskdata.csv (664.8 KB)
Hello Lihong, you can only create mask file with single variable with m3mask. If you want to creat multiple variables in a mask file, you need to create the variable seperately in different mask files. Then you can use m3merge to merge those mask files into one mask file. Also be careful about the variable type. The variable created using m3mask is interger but not float, which can make trouble when you run CMAQ ISAM. You would need to convert variable type. The method about convert variable type you can also find in in the history questions I posted and the answer is from hogrefe.christian.
Another way to generate the ISAM regions maks file is to use the Spatial Allocator using the script which was developed to generate the oceanfile (e.g. alloc_surf_zone_to_oceanfile.csh)
You just need your GRIDDESC, a shapefile with the area you want to map and the Spatial allocator.
Here is an example:
#! /bin/csh -f
#******************* Allocate Shapefiles Run Script **************************
# Allocates a polygon shapefile's data to an I/O API gridded file
# Oct. 2006, LR
# Dec. 2007, LR -- projection specification changes
#*****************************************************************************
setenv DEBUG_OUTPUT Y
# Set executable
setenv EXE "$SA_HOME/bin/32bits/allocator.exe"
# Set Input Directory
setenv DATADIR $SA_HOME/data
setenv OUTPUT $SA_HOME/output
# Select method of spatial analysis
setenv MIMS_PROCESSING ALLOCATE
setenv TIME time
#set "data" shapefile parameters
setenv GRIDDESC $DATADIR/GRIDDESC.txt
**These information you can get from in your shapefile projection**
#set parameters for file being allocated
setenv INPUT_FILE_NAME $DATADIR/surfzone/surfzone_NC_SC
setenv INPUT_FILE_TYPE ShapeFile
setenv INPUT_FILE_MAP_PRJN "+proj=lcc,+lat_1=33,+lat_2=45,+lat_0=40,+lon_0=-97"
setenv INPUT_FILE_ELLIPSOID "+a=6370000.0,+b=6370000.0"
setenv ALLOCATE_ATTRS TYPE
setenv ALLOC_MODE_FILE ALL_AREAPERCENT
#Set this to SURF_ZONE to create the variables needed for CMAQ OCEANfile
setenv ALLOC_ATTR_TYPE **NAME_OF_THE_ATTRIBUTE_IN_THE_SHAPEFILE**
**These information you can get from your GRIDDESC**
# Set name and path of resulting shapefile
setenv OUTPUT_FILE_TYPE IoapiFile
setenv OUTPUT_GRID_NAME NC4KM
setenv OUTPUT_FILE_MAP_PRJN "+proj=lcc,+lat_1=33,+lat_2=45,+lat_0=40,+lon_0=-97"
setenv OUTPUT_FILE_ELLIPSOID "+a=6370000.0,+b=6370000.0"
setenv OUTPUT_FILE_NAME /OUTPUT/MAKS_ISAM_${OUTPUT_GRID_NAME}.ncf
#echo "Allocating MAKS data to CMAQ ISAM"
$TIME $EXE
This script can generates one are at a time, so if you have nine areas, you need to run it 9 times (remember to change the attribute name for each area).
After it, you can merge them with m3merge, for example.
Additionally, check the number of variables in the global attributes of the NetCDF file just to make sure it has the correct number of variables.
I have 10 regions and I have generated a region file for each region. I want to merge them all into a single region file for ISAM as suggested by @rpedruzzi. Can you please share with me a sample of m3merge script I can use for this purpose?