# MEGAN 3.2 Error While Running and Compiling

**URL:** <https://forum.cmascenter.org/t/megan-3-2-error-while-running-and-compiling/2976>\
**Category:** MEGAN\
**Created:** [January 24, 2022, 2:49pm UTC](https://forum.cmascenter.org/t/megan-3-2-error-while-running-and-compiling/2976 "2022-01-24T14:49:20Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![f.garcia](https://avatars.discourse-cdn.com/v4/letter/f/49beb7/32.png) [@f.garcia](https://forum.cmascenter.org/u/f.garcia)\
**Post date:** [January 24, 2022, 8:00pm UTC](https://forum.cmascenter.org/t/megan-3-2-error-while-running-and-compiling/2976/5 "2022-01-24T20:00:43Z")

</div>

Thank you so much @cjcoats for your elaborate instructions.

> [@cjcoats](#):
>
> ```auto
> INTEGER, parameter :: nlat=61
> INTEGER, parameter :: nlon=121
> 
> ```

This existed in the readpar.f file as you have mentioned.  
About the “LFIRST”, I tried implicit none which produced even more errors:

```auto
 -I/home/fernando/Build_CMAQ/src/ioapi/ioapi/fixed_src -I/home/fernando/Build_CMAQ/LIBRARIES/netcdf/include -I/home/fernando/megan32/MEGANv3.2_Dec_2021/src/MET2MGN/INCLDIR readmcip.f
readmcip.f:16:132:

   16 | implicit none
      | 1
Error: IMPLICIT NONE statement at (1) cannot follow COMMON statement at (2)
readmcip.f:243:12:

  243 | do i=1,nx
      | 1
Error: Symbol ‘i’ at (1) has no IMPLICIT type
readmcip.f:78:12:

   78 | ietime = etime/100
      | 1
Error: Symbol ‘ietime’ at (1) has no IMPLICIT type; did you mean ‘etime’?
readmcip.f:77:12:

   77 | istime = stime/100
      | 1
Error: Symbol ‘istime’ at (1) has no IMPLICIT type; did you mean ‘stime’?
readmcip.f:242:12:

  242 | do j=1,ny
      | 1
Error: Symbol ‘j’ at (1) has no IMPLICIT type
readmcip.f:131:17:

  131 | isoilm = INDEX1('SOIM1',NVARS3D,VNAME3D)
      | 1
Error: Function ‘index1’ at (1) has no IMPLICIT type
readmcip.f:132:17:

  132 | isoilt = INDEX1('SOIT1',NVARS3D,VNAME3D)
      | 1
Error: Function ‘index1’ at (1) has no IMPLICIT type
readmcip.f:133:19:

  133 | isoiltyp = INDEX1('SLTYP',NVARS3D,VNAME3D)
      | 1
Error: Function ‘index1’ at (1) has no IMPLICIT type
make: *** [makefile:43: readmcip.o] Error 1

```

I tried this too, and it produced the same error.

> [@cjcoats](#):
>
> `LOGICAL :: LFIRST`

> [@f.garcia](#):
>
> ```auto
> gfortran -c -O3 -ffixed-line-length-132 -fopenmp -ffast-math -funroll-loops -m64 -I/home/fernando/Build_CMAQ/src/ioapi/ioapi/fixed_src -I/home/fernando/Build_CMAQ/LIBRARIES/netcdf/include -I/home/fernando/megan32/MEGANv3.2_Dec_2021/src/MET2MGN/INCLDIR met2mgn.f
> gfortran -c -O3 -ffixed-line-length-132 -fopenmp -ffast-math -funroll-loops -m64 -I/home/fernando/Build_CMAQ/src/ioapi/ioapi/fixed_src -I/home/fernando/Build_CMAQ/LIBRARIES/netcdf/include -I/home/fernando/megan32/MEGANv3.2_Dec_2021/src/MET2MGN/INCLDIR readpar.f
> readpar.f:15:15:
> 
> 15 | parameter nlat=61,nlon=121
> | 1
> Warning: Legacy Extension: PARAMETER without '()' at (1)
> readpar.f:184:132:
> 
> 184 | do 200 i = 1,nx
> | 1
> Warning: Fortran 2018 deleted feature: Shared DO termination label 200 at (1)
> gfortran -c -O3 -ffixed-line-length-132 -fopenmp -ffast-math -funroll-loops -m64 -I/home/fernando/Build_CMAQ/src/ioapi/ioapi/fixed_src -I/home/fernando/Build_CMAQ/LIBRARIES/netcdf/include -I/home/fernando/megan32/MEGANv3.2_Dec_2021/src/MET2MGN/INCLDIR readmcip.f
> readmcip.f:331:19:
> 
> 331 | lfirst = .TRUE.
> | 1
> Warning: Extension: Conversion from LOGICAL(4) to INTEGER(4) at (1)
> readmcip.f:333:19:
> 
> 333 | lfirst = .FALSE.
> | 1
> Warning: Extension: Conversion from LOGICAL(4) to INTEGER(4) at (1)
> readmcip.f:335:12:
> 
> 335 | if (lfirst) then
> | 1
> Error: IF clause at (1) requires a scalar LOGICAL expression
> make: *** [makefile:43: readmcip.o] Error 1
> 
> ```

Then I did something which don’t think is the right approach to these problems, but it worked. I changed “LFIRST” from logical to integer and changed the code to this:

```auto
        if((sdate+2000000).eq.jdate.and.(stime*100).eq.jtime) then
          lfirst = 100
        else
          lfirst = 50
        endif 
        if (lfirst==100) then

```

LFIRST is only used in this part of the code so I don’t think that there will be a problem with this change (I really have no idea whether I am write or wrong here).

I believe that if someone like you tells the MEGAN developers to change their codes to something which isn’t obsolete, they’ll probably listen to your words. I am just a simple user who wants to get his job done, but your experience in this field is something that they should try to listen to.

Again, thank you for your helps

---

_[View the full topic](https://forum.cmascenter.org/t/megan-3-2-error-while-running-and-compiling/2976)._
