# ERROR when running met2mgn.v210.csh

**URL:** <https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420>\
**Category:** MEGAN\
**Created:** [December 7, 2024, 3:26pm UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420 "2024-12-07T15:26:05Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![yan2024](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@yan2024](https://forum.cmascenter.org/u/yan2024)\
**Post date:** [December 7, 2024, 3:26pm UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/1 "2024-12-07T15:26:05Z")

</div>

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 🙂 ):

```
 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

---

<div class="post-metadata">

**Author:** ![cjcoats](https://avatars.discourse-cdn.com/v4/letter/c/ac8455/32.png) [@cjcoats](https://forum.cmascenter.org/u/cjcoats)\
**Post date:** [December 7, 2024, 4:40pm UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/2 "2024-12-07T16:40:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hogrefe.christian](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@hogrefe.christian](https://forum.cmascenter.org/u/hogrefe.christian)\
**Post date:** [December 7, 2024, 5:11pm UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/3 "2024-12-07T17:11:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![willison.jeff](https://avatars.discourse-cdn.com/v4/letter/w/c89c15/32.png) [@willison.jeff](https://forum.cmascenter.org/u/willison.jeff)\
**Post date:** [December 7, 2024, 7:17pm UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/4 "2024-12-07T19:17:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yan2024](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@yan2024](https://forum.cmascenter.org/u/yan2024)\
**Post date:** [December 8, 2024, 6:47am UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/5 "2024-12-08T06:47:42Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![yan2024](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@yan2024](https://forum.cmascenter.org/u/yan2024)\
**Post date:** [December 8, 2024, 6:55am UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/7 "2024-12-08T06:55:02Z")

</div>

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?

 ![image](https://canada1.discourse-cdn.com/flex027/uploads/cmas/original/2X/4/473de790decda591b11aae9eb4bbc695230c981f.png)

---

<div class="post-metadata">

**Author:** ![yan2024](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@yan2024](https://forum.cmascenter.org/u/yan2024)\
**Post date:** [December 8, 2024, 8:51am UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/8 "2024-12-08T08:51:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![hogrefe.christian](https://avatars.discourse-cdn.com/v4/letter/h/74df32/32.png) [@hogrefe.christian](https://forum.cmascenter.org/u/hogrefe.christian)\
**Post date:** [December 8, 2024, 4:49pm UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/9 "2024-12-08T16:49:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![willison.jeff](https://avatars.discourse-cdn.com/v4/letter/w/c89c15/32.png) [@willison.jeff](https://forum.cmascenter.org/u/willison.jeff)\
**Post date:** [December 9, 2024, 1:55am UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/10 "2024-12-09T01:55:01Z")

</div>

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:

> [@Megan 3.2 preprocessor input files missing from website](https://forum.cmascenter.org/t/megan-3-2-preprocessor-input-files-missing-from-website/4604/3):
>
> Here is rough flow chart showing what files need to be preprocessed for use with CMAQ. The files in green are optional unless you want a specific LAI input or want to use BDSNP for soil NO. Inputs to the python tool are in yellow boxes.

---

<div class="post-metadata">

**Author:** ![yan2024](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@yan2024](https://forum.cmascenter.org/u/yan2024)\
**Post date:** [December 9, 2024, 2:53am UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/11 "2024-12-09T02:53:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ryan](https://avatars.discourse-cdn.com/v4/letter/r/a8b319/32.png) [@Ryan](https://forum.cmascenter.org/u/Ryan)\
**Post date:** [December 12, 2024, 8:19am UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/12 "2024-12-12T08:19:02Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![yan2024](https://avatars.discourse-cdn.com/v4/letter/y/59ef9b/32.png) [@yan2024](https://forum.cmascenter.org/u/yan2024)\
**Post date:** [December 13, 2024, 2:11pm UTC](https://forum.cmascenter.org/t/error-when-running-met2mgn-v210-csh/5420/13 "2024-12-13T14:11:25Z")

</div>

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
