ERROR when running met2mgn.v210.csh

Hi teachers, I am a new guy to CMAQ and MEGAN, unfortunately there’s something wrong when met2mgn.csh was running and I had no idea what happened. I thought its the mcip_out files problems but seems not after I examine them one by one.I come here to look for help, hope someone who may know the solution could kindly give me the ideas to tackle out this issue.

Here is the error info and I attach the my csh file for your reference(so sorry for new user it is not allowed to attach files so I tried to copy all of them and put at the end of this page ~ thanks for your patience :slight_smile: ):

 This program uses the EPA-AREAL/MCNC-EnvPgms/BAMS Models-3      
 I/O Applications Programming Interface, [I/O API] which is      
 built on top of the netCDF I/O library (Copyright 1993, 1996    
 University Corporation for Atmospheric Research/Unidata         
 Program) and the PVM parallel-programming library (from         
 Oak Ridge National Laboratory).  Copyright (C) 1992-2002 MCNC   
 and Carlie J. Coats, Jr., and 2003-2006 Baron Advanced          
 Meteorological Systems, LLC and released under the GNU LGPL     
 License, version 2.1.  See URL                                  
                                                                 
     http://www.baronams.com/products/ioapi/LGPL.txt             
                                                                 
 for conditions of use.                                          
                                                                 
 Library release tag: $JDate: 2010068 $                          
                                                                 
 $Id: @(#) ioapi library version 3.1 $
 Version with PARMS3.EXT/PARAMETER::MXVARS3= 2048
 netCDF version "3.6.3" of Oct  7 2010 10:15:03 $
  
  
 Missing environment variable EXECUTION_ID
 Value for GDNAM3D:  'case1'

 File "GRIDDESC" opened for input on unit:  99
 /data1/jiabh/YZD/data/mcip_out/chengdu/GRIDDESC

 Value for MCIPMET:  Y returning TRUE
 Value for MM5MET:  N returning FALSE
 Value for SATPAR:  N returning FALSE
 Value for MCIPRAD:  Y returning TRUE
 Value for MM5RAD:  N returning FALSE
 Value for STDATE:  1718300
 Value for ENDATE:  1718324
 Value for EPISODE_SDATE:  2017183
 Value for GDNAM3D:  'case1'
 Value for MCIPRAD:  Y returning TRUE
 Value for SATPAR:  N returning FALSE
 Value for EPISODE_SDATE:  2017183
 Value for IOAPI_CHECK_HEADERS not defined;returning default:   FALSE
  
 "METCRO2Dfile1" opened as OLD:READ-ONLY   
 File name "/data1/jiabh/YZD/data/mcip_out/chengdu/chengdu_1h/METCRO2D_case1_old.nc"
 File type GRDDED3 
 Execution ID "mcip"
 Grid name "case1_CROSS"
 Dimensions: 117 rows, 177 cols, 1 lays, 35 vbles
 NetCDF ID:         3  opened as READONLY            
 Starting date and time  2017183:010000 (1:00:00   July 2, 2017)
 Timestep                          010000 (1:00:00 hh:mm:ss)
 Maximum current record number         1
  
 "METCRO3Dfile" opened as OLD:READ-ONLY   
 File name "/data1/jiabh/YZD/data/mcip_out/chengdu/chengdu_1h/METCRO3D_case1.nc"
 File type GRDDED3 
 Execution ID "mcip"
 Grid name "case1_CROSS"
 Dimensions: 117 rows, 177 cols, 34 lays, 16 vbles
 NetCDF ID:         4  opened as READONLY            
 Starting date and time  2017183:010000 (1:00:00   July 2, 2017)
 Timestep                          010000 (1:00:00 hh:mm:ss)
 Maximum current record number         1
  
 "METDOT3Dfile" opened as OLD:READ-ONLY   
 File name "/data1/jiabh/YZD/data/mcip_out/chengdu/chengdu_1h/METDOT3D_case1.nc"
 File type GRDDED3 
 Execution ID "mcip"
 Grid name "case1_DOT"
 Dimensions: 118 rows, 178 cols, 34 lays, 6 vbles
 NetCDF ID:         5  opened as READONLY            
 Starting date and time  2017183:010000 (1:00:00   July 2, 2017)
 Timestep                          010000 (1:00:00 hh:mm:ss)
 Maximum current record number         1
 Requested date & time:      2017183:000000
 File starting date & time:  2017183:010000
 File time step:           010000
 
 >>--->> WARNING in subroutine RDTFLAG
 Time step error for file:  METCRO2Dfile1
 M3WARN:  DTBUF 0:00:00   July 2, 2017
 
 *** ERROR ABORT in subroutine readmcip
 Could not read RC from METCRO2Dfile1    file
 Date and time  0:00:00   July 2, 2017    (2017183:000000)

------------------------------------------end ---------------------------------------------------

------------------------------------run.met2mgn.v210.d01.csh------------------------------

Episodes

############################################################
set dom = case1

set start_date = 20170702 #$STDATE_MAIN
set end_date = 20170702 #20170715 #$EDDATE_MAIN

set STJD = date -d "$start_date" +%Y%j
set EDJD = date -d "$end_date" +%Y%j

setenv EPISODE_SDATE $STJD
setenv EPISODE_STIME 000000

############################################################
#set for grid
############################################################
source ${MEGAN_HOME}/setcase.csh

############################################################

Setting up directories and common environment variable

############################################################
#source $MEGAN_HOME/setcase.csh

setenv PROG met2mgn
setenv EXE $MGNEXE/$PROG

set logdir = $LOGDIR_MAIN/MEGAN/$PROG
if ( ! -e $logdir) mkdir -p $logdir

set INPPATH = /data1/jiabh/YZD/data/mcip_out/chengdu
set OUTPATH = /data1/jiabh/YZD/data/mcip_out/chengdu/chengdu_1h/met2MGN_out

setenv GRIDDESC INPPATH/GRIDDESC setenv GDNAM3D {dom} #ZJ_FC_${dom}

if (! -e $OUTPATH) mkdir $OUTPATH

setenv PFILE OUTPATH/PFILE_{dom}
rm -fv $PFILE

############################################################

Looping

############################################################
set today = $start_date
set JDATE = date -d "$today" +%Y%j
set Y4 = date -d "$today" +%Y
set Y2 = date -d "$today" +%y
set MM = date -d "$today" +%m
set DD = date -d "$today" +%d
set DDm1 = date -d "$today - 1 day" +%d
while ($JDATE <= $EDJD)

#if ($JDATE == 2008367) set JDATE = 2009001
@ jdy = $JDATE - 2000000
#set Y4 = j2g $JDATE | awk '{print $1}'
#set Y2 = echo $Y4 | cut -c 3-4
#set MM = j2g $JDATE | awk '{print $2}'
#set DD = j2g $JDATE | awk '{print $3}'

set Y4 = date -d "$today" +%Y
set Y2 = date -d "$today" +%y
set MM = date -d "$today" +%m
set DD = date -d "$today" +%d

set JDATEm1 = date -d "$today - 1 day" +%Y%j
#if ($JDATEm1 == 2008000) set JDATEm1 = 2007365
@ jdym1 = $JDATEm1 - 2000000
#set Y4m1 = j2g $JDATEm1 | awk '{print $1}'
#set Y2m1 = echo $Y4m1 | cut -c 3-4
#set MMm1 = j2g $JDATEm1 | awk '{print $2}'
#set DDm1 = j2g $JDATEm1 | awk '{print $3}'
set Y4m1 = date -d "$today - 1 day" +%Y
set Y2m1 = date -d "$today - 1 day" +%y
set MMm1 = date -d "$today - 1 day" +%m
set DDm1 = date -d "$today - 1 day" +%d

#set start/end dates
setenv STDATE {jdy}00 setenv ENDATE {jdy}24

#TEMP/PAR input choices

#set if using MM5 output files
setenv MM5MET N
setenv MM5RAD N
#setenv numMM5 2
#setenv MM5file1 /pete/pete5/fcorner/met/links/MMOUT_DOMAIN1_G$Y4$MM$DD
#setenv MM5file2 /pete/pete5/fcorner/met/links/MMOUT_DOMAIN1_G$Y4$MM$DD

#set if using UMD satellite PAR data
set PARDIR = $MGNINP/PAR
setenv SATPAR N
set satpar1 = “$PARDIR/Y2m1{MMm1}par.h”
set satpar2 = “$PARDIR/Y2{MM}par.h”

if ($satpar1 == $satpar2) then
setenv numSATPAR 1
setenv SATPARFILE1 $satpar2
else
setenv numSATPAR 2
setenv SATPARFILE1 $satpar1
setenv SATPARFILE2 $satpar2
endif

#set if using MCIP output files
setenv MCIPMET Y
setenv TMCIP TEMP2 MCIP v3.3 or newer

setenv MCIPRAD Y
if ($JDATE == $EPISODE_SDATE) then
setenv METCRO2Dfile1 $INPPATH/chengdu_1h/METCRO2D_case1_old.nc
else
setenv METCRO2Dfile1 $INPPATH/chengdu_1h/METCRO2D_case1_old.nc
setenv METCRO2Dfile2 $INPPATH/chengdu_1h/METCRO2D_case1_old.nc
endif
setenv METCRO3Dfile $INPPATH/chengdu_1h/METCRO3D_case1.nc
setenv METDOT3Dfile $INPPATH/chengdu_1h/METDOT3D_case1.nc

setenv OUTFILE $OUTPATH/MET.MEGAN.$GDNAM3D.$JDATE.ncf
rm -rf $OUTFILE

$EXE |tee $logdir/log.$PROG.$GDNAM3D.$JDATE.txt

set today = date -d "$today + 1 day" +%Y%m%d
set JDATE = date -d "$today" +%Y%j
end # End while JDATE

First of all, this is built with a badly out-of-date I/O API (3.1 of March 9, 2010); the current version is 3.2 of March 22, 2023).

The real problem is that the call to read your METCRO2D file is for a bad (date=0, time=0) date&time. Don’t know why (I’m not a Megan expert), but that is what’s happening.

1 Like

Your log file shows that the program is trying to read “Date and time 0:00:00 July 2, 2017”, but that your MCIP files start at 1:00:00 on that day, one hour later than the requested time step:

"METCRO2Dfile1" opened as OLD:READ-ONLY   
 File name "/data1/jiabh/YZD/data/mcip_out/chengdu/chengdu_1h/METCRO2D_case1_old.nc"
 File type GRDDED3 
Execution ID "mcip"
Grid name "case1_CROSS"
Dimensions: 117 rows, 177 cols, 1 lays, 35 vbles
NetCDF ID:         3  opened as READONLY            
Starting date and time  2017183:010000 (1:00:00   July 2, 2017)
Timestep                          010000 (1:00:00 hh:mm:ss)
Maximum current record number         1

This causes the program to fail.

You will need to regenerate your MCIP files to cover the period you are trying to process. Not only do your MCIP files start one hour later than requested by the program, they also contain data for only a single hour which is unusual.

1 Like

The meteorology for MEGAN comes from the MCIP files when running CMAQ, so there’s no reason to run met2mgn. Assuming the MCIP files are correct to begin with.

1 Like

thanks for your reply, but shouldn’t this the one of key steps of MEGANs that transfers IO/API files to format that MEGAN can read?

thanks to your reply ! I change time sets to agree with each other and this time seems better but still something wrong occur.I’m wondering if its the problem of my input files cuz I found that in mcip_out files GRIDDESC projection info is wrong(I dont know why this is not right, I follow every single step according to some teaching on the Internet), i worry that other files like METCRO2D and METCRO3D went wrong also and is this the reason that run still goes wrong?

thanks for your reply! I am wondering what does mean a badly out-of-date I/O API? is that mean input file goes wrong or something else?

I am not familiar with the met2mgn.v210.csh script, but the error message above is clear enough: METCRO2Dfile1 is defined properly in your run script and is openend, but METCRO2Dfile2 is not defined and therefore cannot be opened.

The relevant section of your run script from your first post shows this:

if ($JDATE == $EPISODE_SDATE) then
setenv METCRO2Dfile1 $INPPATH/chengdu_1h/METCRO2D_case1_old.nc
else
setenv METCRO2Dfile1 $INPPATH/chengdu_1h/METCRO2D_case1_old.nc
setenv METCRO2Dfile2 $INPPATH/chengdu_1h/METCRO2D_case1_old.nc
endif

So, when JDATE equals EPISODE_SDATE, METCRO32Dfile2 isn’t defined which then causes met2mgn to crash. The solution would seem to be to always define both METCRO2Dfile1 and METCRO2Dfile2. That said, I don’t know what distinguishes these two files from met2mgn’s perspective and whether or not it is appropriate to set both variables to the same file as is done in the second section of the if ... then block.

The only program you need to run that directory is TXT2IOAPI, not met2mgn, not daymet, or megvea, or megsea, etc.

This comment might be useful:

thank you so much for your support!!I’ll check this flow chart and run CAMQ again

It means that the IOAPI version you are using is outdated, rather than anything wrong with IOAPI.

It seems that you lack fundamental knowledge about running MEGAN, especially the timeshift and time settings. Actually, the original script in the tarfile provides a very good example to start with. Make sure you read that script and modify based on the script.
BTW, case1_old is definitely wrong. Please carefully check the settings in the sample script to see how it works (it should correspond to each day with the format of $YYYYMMDD or $YYYYJJJ for your MCIP outfiles).

Thanks so much! problem is solved!mcip_out files is indeed wrong and I run wps , wrf again fortunately it is correct this time.And I also change the numbers (hour) following {jdy} to agree with mcip_out file timespan so this time works successfully:
#set start/end dates
setenv STDATE {jdy}12 setenv ENDATE {jdy}12

1 Like