Is there a tool that can take the value of a variable in netcdf all × 2 in a certain period of time ?

For example, I want to multiply the PAR in the inventory of a certain day by 2 times during the time period of 12:00-15:00.

M3Tools program m3combo can do general linear combinations of variables. Multiplying a single variable by a constant such as 2 is a special case of that. See

Sorry I don’t know much about this, I tried to use this program, but I don’t know what to write in COMBO_FILES COMBO_VBLES _VBLES _FILES
_COEFS _OFFSET . Can you give me some guidance or hints?

setenv  <infile>  /data4/sunzhixu/outdata/emis/finn/cn12/
setenv  <outfile> /data4/sunzhixu/outdata/emis/finn/cn12/
setenv COMBO_FILES       <Comma-delimited list of logical names for the input files>
setenv COMBO_VBLES       <Comma-delimited list of names for the output variables>
For each output variable <name>,
    setenv  <name>_VBLES  <list of input variable names>
    setenv  <name>_FILES  <matching list of input file names>
    setenv  <name>_COEFS  <matching list of REAL coefficients>
    setenv  <name>_OFFSET <matching list of REAL constant terms>

m3combo <and respond to the prompts>

Let’s back up a bit: what is it that you really want to do? Your original request was by no means clear…

Do you understand that

PAR = 2.0*PAR

is a special case of the general concept of a linear combination, where n=1 and c1=2.0:

Y = c1*X1 + c2*X2 + ... + cn*Xn


What variables do you want in your output? …for what time period? Do you want to do an in-place substitution? …for only a part of the output time step sequence?

Quite possibly, the right solution would be to look at the m3combo code as a reference example and write your own Fortran for your specific needs.

I want a variable in this file to be multiplied by 2 during a certain period of time ( eg 12:00 to 15:00). Nothing else changes. I understand PAR = PAR *2, and the linear combination. But I don’t know what to write for some variables (like COMBO_FILEs).

You need COMBO_VBLES to be the comma-list of all the variables in the file, and COMBO_UNITS to be the matching list of units from FDESC3. For each of those variables (say FOO), you need

setenv FOO_OFFSET 0

You need two runs: one for the duration of the input file, with

setenv FOO_COEFS 1.0

for all the variables FOO, and another run for the time period of 12:00-15:00, similarly but with all coefficients 1.0 except PAR

setenv PAR_COEFS 2.0

The first run will copy all the data from the input file to the output file; the second will specifically replace PAR by 2.0*PAR for the specific period you request.

1 Like