Error creating GRIDMASK

Hi all~

I am trying to generate my own GRIDMASK since I use other emission inventory instead of EDGAR. I wrote a f90 file to generate a GRIDMASK file. But when SMOKE was reading the GRIDMASK, the error shows up:

Value for PROMPTFLAG: N returning FALSE
Error reading IDs for variable TZONES
netCDF error number -49 processing file “GRIDMASK”
NetCDF: Variable not found
Could not open file “GRIDMASK”.

I guess the error is caused by the global attribute I wrote into GRIDMASK, which is

VAR-LIST      = 'GEOCODE          TZONES'

The attribute in EDGAR GRIDMASK is

VAR-LIST      = 'GEOCODE         TZONES          '

There are some space behind ‘TZONES’. However I did put space behind ‘TZONES’ in the f90 file

character (len=34), parameter :: VAR_name = 'GEOCODE          TZONES          '

But it doesn’t work with the netcdf libraries. It seems that netcdf function will subtract the tail space. How can I solve it? Thank you in advance!

Best,
Feng

GRIDMASK is a I/O API file. I/O API is an acronym for Input/Output Applications Programming Interface. As the documentation says, it is not a data format (and so far, every attempt that I have seen to treat it as a data format has failed in at least some way). [And, by the way, netCDF’s Fortran-C interface is a bit of a hack, especially insofar as character strings are concerned; you really don’t want to have to worry about all the troubles involved with that!]

If you want to create a GRIDMASK file from scratch, you need to treat it as a programming problem that uses the I/O API. A good place to start would be to modify one of the I/O API’s M3Tools programs to do the job you want. m3mask might be a good place to start.

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

Hi, to expand on what Carlie is saying, you cannot create an
I/O API file using only netCDF functions – you need to use the I/O API libraries as an interface. The approach you are taking is causing string formatting issues in the I/O API variable list that prevents the GRIDMASK netCDF variables
from being read by SMOKE. Instead, try generating the GRIDMASK using the FORTRAN I/O API library.

Thank you @cjcoats @eyth.alison! The problem is solved.

hi all,

Since I received several messages asking how I generated GRIDMASK, I would like to answer it here. I used m3fake. The method is similar with generating dummy ocean file.