Compiling MEGAN3.2: ERROR: IF clause requires a scaler LOGICAL expression

Hi everyone,
I try to compile MEGAN3.2 using gfortran compiler. After execution of the makefile, I get this error:

These are the related lines of readmcip.f file:

And this is the makefile of MET2MGN:

Could anyone help me to solve the problem?
Thank you for any help in advance.

Reza,

Hi Reza,
Again, MEGAN 3.2 Error While Running and Compiling - #5 by f.garcia this has helped me solve the problem that you have mentioned.

One of the posts says " 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:

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

Hope it works for you too.
Amir

@amirdudu
Dear Amir,
Thank you for your reply. I will test it.

No. LFIRST is never declared in readmcip.f – but it should have been. And gfortran is much more insistent upon Standard-compliant code than PGI Fortran…
Edit line 20 in this file so that it declares it properly:

  `logical MCIP_rad,SAT_par,ENVYN,INITIAL_HOUR,ifsoil,lfirst`

Likewise, readpar.f uses illegal PARAMETER statements: lines 15-16 should be

INTEGER, parameter   ::  mx=350
INTEGER, parameter   ::  my=410
INTEGER, parameter   ::  mz=30
INTEGER, parameter   ::  nlat=61
INTEGER, parameter   ::  nlon=121

Aside: MEGAN is a code that is badly in violation of the coding standards that should be in place, and is seriously in need of review by a scientific-programming software engineer. In particular, a code that does not use IMPLICIT NONE throughout is seriously not to be trusted. And FWIW, I/O API routine M3ERR (used throughout this code) was declared obsolete; do not use back in late 1992.

2 Likes

@cjcoats
I appreciate your response. This resolved the problem. readwrfcamx.f file requires the same change as well.

Best regards,