Writing a new output file with m3diff

I tried to check the difference in the variable ‘SO2’ between two BC files with different number of variables and timestamps using m3diff; I could see the difference was shown on the screen but not written to output file:

Program version:
     $Id:: m3diff.f 117 2019-06-15 14:56:29Z coats                 $

 Value for PROMPTFLAG not defined;returning default:   TRUE
 Do you want the default analysis? (Y/N) [Y] >>
 Returning default value TRUE for query:
 "Do you want the default analysis?"
 Generate an output data file? (Y/N) [N] >>Y
 Returning value TRUE for query:
 "Generate an output data file?"

 Value for PROMPTFLAG not defined;returning default:   TRUE
 Enter logical name for INPUT FILE A [AFILE] >>
 Value for IOAPI_CHECK_HEADERS not defined;returning default:   FALSE

 "AFILE" opened as OLD:READ-ONLY
 File name "m3tshift.bc.12km.2014H1.01.cmaq.cb6r3_ae7.20140101.lst.ncf.18may2020"
 File type BNDARY3
 Execution ID "????????????????"
 Grid name "12US2_CROSS"
 Dimensions: 246 rows, 396 cols, 34 lays, 53 vbles, 1 cells thick
 NetCDF ID:     65536  opened as READONLY
 Starting date and time  2014001:030000 (3:00:00   Jan. 1, 2014)
 Timestep                          060000 (6:00:00 hh:mm:ss)
 Maximum current record number         5
 Enter logical name for INPUT FILE B [BFILE] >>

 "BFILE" opened as OLD:READ-ONLY
 File name "bc_regrid_m3copy_old_very_right_new_just_mytest_26may2020.ncf"
 File type BNDARY3
 Execution ID "????????????????"
 Grid name "WNDW_12US2_398X2"
 Dimensions: 246 rows, 396 cols, 34 lays, 1 vbles, 1 cells thick
 NetCDF ID:    131072  opened as READONLY
 Starting date and time  2014001:030000 (3:00:00   Jan. 1, 2014)
 Timestep                          060000 (6:00:00 hh:mm:ss)
 Maximum current record number      1460
 Value for PROMPTFLAG not defined;returning default:   TRUE
 Enter logical name for  REPORT FILE, or "NONE" [REPORT] >>REPORTFILE

 File "REPORTFILE" opened for output on unit:  99
 check_day1_2014_m3diff_REPO.txt


 The list of variables in file AFILE is:
 NO      (ppmV            ):
 NO
 NO2     (ppmV            ):
 NO2
 O3      (ppmV            ):
 O3
 H2O2    (ppmV            ):
 H2O2
 SO2     (ppmV            ):
 SO2
 
"
"
     Variable SRFCOR           not found in file BFILE
"
"
 The list of variables common to both files is:
 SO2
 Value for PROMPTFLAG not defined;returning default:   TRUE
 Enter OUTPUT FILE starting date [2014001] >>
 Using default   2014001
 Enter OUTPUT FILE starting time [30000] >>
 Using default     30000
 Enter OUTPUT FILE time step [60000] >>
 Using default     60000

 Now select names, units, and descriptions for variables
 to be stored in the output file (one for each paired
 difference calculation to be performed


 Generating variable for "AFILE:SO2 (A - B) BFILE:SO2"
 Value for PROMPTFLAG not defined;returning default:   TRUE
 Enter NAME for this variable ["SO2"] >>SO2_diff_BC
 Using response "SO2_diff_BC"
 Enter UNITS for this variable ["ppmV"] >>
 Using default "ppmV"
 Description "AFILE:SO2 (A - B) BFILE:SO2""
 Enter description for this variable ["AFILE:SO2 (A - B) BFILE:SO2""] >>
 Using default "AFILE:SO2 (A - B) BFILE:SO2""

 Now please enter the output file description
 (up to 60 lines, terminated by a blank line)


  >>
 Enter logical name for OUTPUT FILE [OFILE] >>OUTFILE

 Value for IOAPI_CHECK_HEADERS not defined;returning default:   FALSE
 Value for IOAPI_OFFSET_64 not defined;returning default:   TRUE
 Value for IOAPI_CFMETA not defined;returning default:   FALSE
 Value for IOAPI_CMAQMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_CMAQMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_SMOKEMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_SMOKEMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_TEXTMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_TEXTMETA not defined; returning defaultval ':  'NONE'

 "OUTFILE" opened as UNKNOWN(R-W)
 File name "diff_bcs_mz2camx_n_pyth36.ncf"
 File type BNDARY3
 Execution ID "????????????????"
 Grid name "WNDW_12US2_398X2"
 Dimensions: 246 rows, 396 cols, 34 lays, 1 vbles, 1 cells thick
 NetCDF ID:    196608  opened as READWRITE
 Starting date and time  2014001:030000 (3:00:00   Jan. 1, 2014)
 Timestep                          060000 (6:00:00 hh:mm:ss)
 Maximum current record number         0

 Processing . . .

 Value for IOAPI_LOG_WRITE not defined;returning default:   TRUE

 >>--->> WARNING in subroutine WRITE3
 Variable SO2_diff_BC      not in file:  OUTFILE
 M3WARN:  DTBUF 3:00:00   Jan. 1, 2014  (2014001:030000)
 Could not write "SO2_diff_BC" to "OUTFILE" for 3:00:00   Jan. 1, 2014

 >>--->> WARNING in subroutine WRITE3
 Variable SO2_diff_BC      not in file:  OUTFILE
 M3WARN:  DTBUF 9:00:00   Jan. 1, 2014  (2014001:090000)
 Could not write "SO2_diff_BC" to "OUTFILE" for 9:00:00   Jan. 1, 2014

 >>--->> WARNING in subroutine WRITE3
 Variable SO2_diff_BC      not in file:  OUTFILE
 M3WARN:  DTBUF 15:00:00  Jan. 1, 2014  (2014001:150000)
 Could not write "SO2_diff_BC" to "OUTFILE" for 15:00:00  Jan. 1, 2014

 >>--->> WARNING in subroutine WRITE3
 Variable SO2_diff_BC      not in file:  OUTFILE
 M3WARN:  DTBUF 21:00:00  Jan. 1, 2014  (2014001:210000)
 Could not write "SO2_diff_BC" to "OUTFILE" for 21:00:00  Jan. 1, 2014

 >>--->> WARNING in subroutine WRITE3
 Variable SO2_diff_BC      not in file:  OUTFILE
 M3WARN:  DTBUF 3:00:00   Jan. 2, 2014  (2014002:030000)
 Could not write "SO2_diff_BC" to "OUTFILE" for 3:00:00   Jan. 2, 2014

 --->> Normal Completion of program M3DIFF
 M3DIFF  completed successfully

Not sure what is going on here, but does the outfile already exist? If it has been created, and its VAR-LIST defined, then you can’t write a variable with a different name to it. Delete the old output file, and rerun the program.

I tried deleting the old OUTFILE and running m3diff again, but got the same results - REPORT file created, program completed normally but the OUTFILE was created and empty with variable NO:

 >>--->> WARNING in subroutine WRITE3
 Variable SO2              not in file:  OFILE
 M3WARN:  DTBUF 3:00:00   Jan. 1, 2014  (2014001:030000)
 Could not write "SO2" to "OFILE" for 3:00:00   Jan. 1, 2014
 
 >>--->> WARNING in subroutine WRITE3
 Variable SO2              not in file:  OFILE
 M3WARN:  DTBUF 9:00:00   Jan. 1, 2014  (2014001:090000)
 Could not write "SO2" to "OFILE" for 9:00:00   Jan. 1, 2014
 
 >>--->> WARNING in subroutine WRITE3
 Variable SO2              not in file:  OFILE
 M3WARN:  DTBUF 15:00:00  Jan. 1, 2014  (2014001:150000)
 Could not write "SO2" to "OFILE" for 15:00:00  Jan. 1, 2014
 
 >>--->> WARNING in subroutine WRITE3
 Variable SO2              not in file:  OFILE
 M3WARN:  DTBUF 21:00:00  Jan. 1, 2014  (2014001:210000)
 Could not write "SO2" to "OFILE" for 21:00:00  Jan. 1, 2014
 
 >>--->> WARNING in subroutine WRITE3
 Variable SO2              not in file:  OFILE
 M3WARN:  DTBUF 3:00:00   Jan. 2, 2014  (2014002:030000)
 Could not write "SO2" to "OFILE" for 3:00:00   Jan. 2, 2014
 
 --->> Normal Completion of program M3DIFF
 M3DIFF  completed successfully

Thus, m3diff is picking up the very first variable (NO in this case) in one of the input files and so when I try to name it SO2 or something other than NO, it refuses to write, so I have to call it NO even though it is technically SO2 - the common variable between the two input files:

 Generating variable for "AFILE:SO2 (A - B) BFILE:SO2"
 Value for PROMPTFLAG not defined;returning default:   TRUE
 Enter NAME for this variable ["SO2"] >>NO
 Using response "NO"
 Enter UNITS for this variable ["vmr"] >>
 Using default "vmr"
 Description "AFILE:SO2 (A - B) BFILE:SO2""
 Enter description for this variable ["AFILE:SO2 (A - B) BFILE:SO2""] >>
 Using default "AFILE:SO2 (A - B) BFILE:SO2""
  
 Now please enter the output file description
 (up to 60 lines, terminated by a blank line)
  

  >> check_m3diff

  >> 
 Enter logical name for OUTPUT FILE [OFILE] >>
 
 Value for IOAPI_CHECK_HEADERS not defined;returning default:   FALSE
 Value for IOAPI_OFFSET_64 not defined;returning default:   TRUE
 Value for IOAPI_CFMETA not defined;returning default:   FALSE
 Value for IOAPI_CMAQMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_CMAQMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_SMOKEMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_SMOKEMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_TEXTMETA not defined; returning defaultval ':  'NONE'
 Value for IOAPI_TEXTMETA not defined; returning defaultval ':  'NONE'
  
 "OFILE" opened as UNKNOWN(R-W)    
 File name "diff_bcs_mz2camx_n_pyth36.ncf"
 File type BNDARY3 
 Execution ID "????????????????"
 Grid name "12US2_CROSS"
 Dimensions: 246 rows, 396 cols, 34 lays, 1 vbles, 1 cells thick
 NetCDF ID:    196608  opened as READWRITE           
 Starting date and time  2014001:030000 (3:00:00   Jan. 1, 2014)
 Timestep                          060000 (6:00:00 hh:mm:ss)
 Maximum current record number         0
  
 Processing . . .
  
 Value for IOAPI_LOG_WRITE not defined;returning default:   TRUE
 NO written to OFILE for   2014001:030000
 NO written to OFILE for   2014001:090000
 NO written to OFILE for   2014001:150000
 NO written to OFILE for   2014001:210000
 NO written to OFILE for   2014002:030000
 
 --->> Normal Completion of program M3DIFF
 M3DIFF  completed successfully

I have used many of the m3tools programs, but not m3diff, so I am not sure what is going on…
How did you create the BC files? I see that one of them has “pyth36” in the name; if you used a python script to create the file, then it is possible that is the problem. Once you have an IOAPI file, you ought to use the IOAPI interface if you want to ensure that the resulting output remains a valid IOAPI file.

It is not clear what you are looking for when you say “check the difference” between the two files. Can you visualize them using VERDI or ncview?

I believe it is because the OFILE already exists. Try moving it to a different name, and then running the program again.