Topic: Error: Expected a right parenthesis in expression at (1)

Hi, I was trying to compile several source codes written in FORTRAN 90. At one stage I received the following error message.

ee http://www.openwatcom.org/ for details.
    "C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe" -c -o "build\rthsed.o" -g   -Jmodules "..\..\..\..\Users\Mizanur\TestF\SWAT_Compilation\rthsed.f"
..\..\..\..\Users\Mizanur\TestF\SWAT_Compilation\rthsed.f:173.39:

     &               * sig_g ** -0.1606                                 
                                       1
Error: Expected a right parenthesis in expression at (1)


Could you please address the problem?

Thanks.

Mizan

Re: Error: Expected a right parenthesis in expression at (1)

Mizan,

The error you're seeing is a Fortran syntax error.  The compiler is expecting a right parenthesis for some reason.  You'll need to post more code in the future for anyone to diagnose a syntax error, especially since, in this case, the line you've posted is a continuation of a previous line.

In this case, I've downloaded the SWAT model (which appears to be what you're examining), and looked at the line.  The problem appears to be that SWAT is not conforming to the Fortran fixed-format standard especially well.  Line 172, which is the line that the error originates on, is 77 characters long.  Fortran's fixed-format standard will only recognize code up to column 72, though.  Your error is related to these long lines, I'm guessing.

You can override this constraint using the "-ffixed-line-length-n" flag.  From the Project menu, select "Options," and add the following to Fortran Flags:

-ffixed-line-length-132

The above should allow lines to extend to a more reasonable 132 columns.

Jeff Armstrong
Approximatrix, LLC

Re: Error: Expected a right parenthesis in expression at (1)

Mizan,

I just tried adding the flag using SWAT 2009, and, of course, it caused issues on another file that expects the 72 column constraint (addh.f to be exact).  You might have to edit code manually to overcome this issue.  I would suggest updating rthsed.f to properly conform to the 72 column standard.

Jeff Armstrong
Approximatrix, LLC

Re: Error: Expected a right parenthesis in expression at (1)

The code doesn't conform to the Fortran Standard so the error message is reasonable.

It is illegal to folow the exponentiation operator ** with the unary minus operator.

You need to use parentheses like this

sig_g**(-0.1606)
--
David

5 (edited by mizaniwm 2013-11-07 15:56:05)

Re: Error: Expected a right parenthesis in expression at (1)

Dear Jeff and David

Thanks much for your suggestions. Finally, SF has been able to build all files; however, I got the following message.

collect2.exe: error: ld returned 1 exit status
Error(E42): Last command making (Project.exe) returned a bad status
Error(E02): Make execution terminated

* Failed *

Due to the above error, SF couldn't make executable (---.exe ) file , I guess. Do you have any suggestions for me?


Thanks much.

Sincerely
Mizan

Re: Error: Expected a right parenthesis in expression at (1)

Mizan,

Could you post a few lines before this too?  Was there an additional error?  The above suggests that the linker failed, and I'm wondering if there were any undefined symbols.

Jeff Armstrong
Approximatrix, LLC

7 (edited by mizaniwm 2013-11-08 10:14:00)

Re: Error: Expected a right parenthesis in expression at (1)

Hi Jeff

Thanks for response. While compiling the SF shows a Warning message and following error.

1.----------------------Warning message-------------------

"C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe" -c -o "build\sub_subbasin.o" -g  -ffixed-line-length-132 -Jmodules ".\sub_subbasin.f"
.\sub_subbasin.f:143.14:

      hrnopcp(sb,0) = hrnopcp(sb,nstep)                                       
              1
Warning: Legacy Extension: REAL array index at (1)




2. --------------------After building SF shows the following Error ---------------------------

These are first few lines after building (.o ) files

"C:\Program Files (x86)\Simply Fortran 2\mingw-w64\bin\gfortran.exe" -o "SWAT.exe" "build\addh.o" "build\albedo.o"

"build\allocate_parms.o" "build\alph.o" "build\anfert.o" "build\apex_day.o" "build\apply.o" "build\ascrv.o" "build\atri.o" "build\aunif.o" "build\autoirr.o" "build\aveval.o" "build\bacteria.o" "build\biofilm.o" "build\biozone.o" "build\bmp_det_pond.o" "build\bmp_ri_pond.o" "build\bmp_sand_filter.o" "build\bmp_sed_pond.o" "build\bmp_wet_pond.o" "build\bmpfixed.o" "build\bmpinit.o" "build\buffer.o" "build\burnop.o" "build\canopyint.o" "build\caps.o" "build\carbon_new.o" "build\chkcst.o" "build\clgen.o" "build\clicon.o" "build\command.o" "build\conapply.o" "build\confert.o" "build\crackflow.o" "build\crackvol.o" "build\curno.o" "build\dailycn.o" "build\decay.o" "build\depstor.o" "build\distrib_bmps.o" "build\dormant.o" "build\drains.o" "build\dstn1.o" "build\ee.o" "build\eiusle.o" "build\enrsb.o" "build\erfc.o" "build\estimate_ksat.o" "build\etact.o" "build\etpot.o" "build\expo.o" "build\fert.o" "build\filter.o" "build\filtw.o" "build\finalbal.o" "build\gcycl.o" "build\getallo.o" "build\getallo2.o" "build\grass_wway.o" "build\graze.o" "build\grow.o" "build\gw_no3.o" "build\gwmod.o" "build\gwnutr.o" "build\h2omgt_init.o" "build\harvestop.o" "build\harvgrainop.o" "build\harvkillop.o" "build\header.o" "build\headout.o" "build\hhnoqual.o" "build\hhwatqual.o" "build\hmeas.o" "build\hruaa.o" "build\hruallo.o" "build\hruday.o" "build\hrumon.o" "build\hrupond.o" "build\hrupondhr.o" "build\hruyr.o" "build\hydroinit.o" "build\icl.o" "build\impnd_init.o" "build\impndaa.o" "build\impndday.o" "build\impndmon.o" "build\impndyr.o" "build\irr_rch.o" "build\irr_res.o" "build\irrigate.o" "build\irrsub.o" "build\jdt.o" "build\killop.o" "build\lakeq.o" "build\latsed.o" "build\layersplit.o" "build\lwqdef.o" "build\main.o" "build\modparm.o" "build\ndenit.o" "build\newtillmix.o" "build\nfix.o" "build\nitvol.o" "build\nlch.o" "build\nminrl.o" "build\noqual.o" "build\npup.o" "build\nrain.o" "build\nup.o" "build\nuts.o" "build\openwth.o" "build\operatn.o" "build\orgn.o" "build\orgncswat.o" "build\origtile.o" "build\ovr_sed.o" "build\percmacro.o" "build\percmain.o" "build\percmicro.o" "build\pestlch.o" "build\pestw.o" "build\pesty.o" "build\pgen.o" "build\pgenhr.o" "build\pkq.o" "build\plantmod.o" "build\plantop.o" "build\pmeas.o" "build\pminrl.o" "build\pminrl2.o" "build\pond.o" "build\pondhr.o" "build\pothole.o" "build\potholehr.o" "build\print_hyd.o" "build\psed.o" "build\qman.o" "build\ran1.o" "build\rchaa.o" "build\rchday.o" "build\rchinit.o" "build\rchmon.o" "build\rchuse.o" "build\rchyr.o" "build\reachout.o" "build\readatmodep.o" "build\readbsn.o" "build\readchm.o" "build\readcnst.o" "build\readfcst.o" "build\readfert.o" "build\readfig.o" "build\readfile.o" "build\readgw.o" "build\readhru.o" "build\readinpt.o" "build\readlup.o" "build\readlwq.o" "build\readmgt.o" "build\readmon.o" "build\readops.o" "build\readparmfile.o" "build\readpest.o" "build\readplant.o" "build\readpnd.o" "build\readres.o" "build\readrte.o" "build\readru.o" "build\readsdr.o" "build\readsepticbz.o" "build\readseptwq.o" "build\readsno.o" "build\readsol.o" "build\readsub.o" "build\readswq.o" "build\readtill.o" "build\readurban.o" "build\readwgn.o" "build\readwus.o" "build\readwwq.o" "build\readyr.o" "build\reccnst.o" "build\recday.o" "build\rechour.o" "build\recmon.o" "build\recyear.o" "build\regres.o" "build\res.o" "build\resbact.o" "build\resetlu.o" "build\reshr.o" "build\resinit.o" "build\resnut.o" "build\rewind_init.o" "build\rhgen.o" "build\rootfr.o" "build\route.o" "build\routels.o" "build\routeunit.o" "build\routres.o" "build\rsedaa.o" "build\rseday.o" "build\rsedmon.o" "build\rsedyr.o" "build\rtbact.o" "build\rtday.o" "build\rteinit.o" "build\rthmusk.o" "build\rthpest.o" "build\rthr.o" "build\rthsed.o" "build\rtmusk.o" "build\rtout.o" "build\rtpest.o" "build\rtsed.o" "build\rtsed_bagnold.o" "build\rtsed_kodatie.o" "build\rtsed_Molinas_Wu.o" "build\rtsed_yangsand.o" "build\ruallo.o" "build\sat_excess.o" "build\save.o" "build\saveconc.o" "build\sched_mgt.o" "build\schedule_ops.o" "build\sim_initday.o" "build\sim_inityr.o" "build\simulate.o" "build\slrgen.o" "build\smeas.o" "build\snom.o" "build\soil_chem.o" "build\soil_par.o" "build\soil_phys.o" "build\soil_write.o" "build\solp.o" "build\solt.o" "build\std1.o" "build\std2.o" "build\std3.o" "build\stdaa.o" "build\storeinitial.o" "build\structure.o" "build\sub_subbasin.o" "build\subaa.o" "build\subbasin.o" "build\subday.o" "build\submon.o" "build\substor.o" "build\subwq.o" "build\subyr.o" "build\sumhyd.o" "build\sumv.o" "build\surface.o" "build\surfst_h2o.o" "build\surfstor.o" "build\surq_daycn.o" "build\surq_greenampt.o" "build\swbl.o" "build\sweep.o" "build\swu.o" "build\tair.o" "build\tgen.o" "build\theta.o" "build\tillfactor.o" "build\tillmix.o" "build\tmeas.o" "build\tran.o" "build\transfer.o" "build\tstr.o" "build\ttcoef.o" "build\ttcoef_wway.o" "build\urb_bmp.o" "build\urban.o" "build\urbanhr.o" "build\varinit.o" "build\vbl.o" "build\virtual.o" "build\volq.o" "build\washp.o" "build\watbal.o" "build\water_hru.o" "build\watqual.o" "build\watqual2.o" "build\wattable.o" "build\watuse.o" "build\weatgn.o" "build\wetlan.o" "build\wmeas.o" "build\wndgen.o" "build\writea.o" "build\writeaa.o" "build\writed.o" "build\writem.o" "build\xmon.o" "build\ysed.o" "build\zero0.o" "build\zero1.o" "build\zero2.o"


"build\zero_urbn.o" "build\zeroini.o" -LC:/PROGRA~2/SIMPLY~1/MINGW-~1/lib/   


build\modparm.o:modparm.f:(.bss+0x0): multiple definition of `__parm_MOD_a_days'
build\main.o:C:\Users\Mizanur\TestF\SWAT_Compilation/./main.f:2: first defined here
build\modparm.o:modparm.f:(.bss+0x60): multiple definition of `__parm_MOD_aairr'
build\main.o:C:\Users\Mizanur\TestF\SWAT_Compilation/./main.f:58: first defined here
build\modparm.o:modparm.f:(.bss+0x90): multiple definition of `__parm_MOD_abstinit'


---------------------------------------- Intermediate lines here -----------------------------------------
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------


The following lines are last few before ending compilation.


build\main.o:main.f:(.bss+0x23ea0): first defined here
build\modparm.o:modparm.f:(.bss+0x23f00): multiple definition of `__parm_MOD_yr_skip'
build\main.o:main.f:(.bss+0x23f00): first defined here
build\modparm.o:modparm.f:(.bss+0x23f40): multiple definition of `__parm_MOD_zdb'
build\main.o:main.f:(.bss+0x23f40): first defined here
build\modparm.o:modparm.f:(.bss+0x23f88): multiple definition of `__parm_MOD_zone'
build\main.o:main.f:(.bss+0x23f88): first defined here

collect2.exe: error: ld returned 1 exit status
Error(E42): Last command making (SWAT.exe) returned a bad status
Error(E02): Make execution terminated

* Failed *



If you require any more information, please let me know.


Sincerely

Mizan

Re: Error: Expected a right parenthesis in expression at (1)

Hi Jeff

Finally I have been able to solve the problems I raised in my last post. Thanks to all for your nice cooperation.

Sincerely

Mizan

Re: Error: Expected a right parenthesis in expression at (1)

Mizan,

That's great to hear!  It looks like you had a duplicated module hiding in your code, but I'm glad to see that you sorted things out.

Jeff Armstrong
Approximatrix, LLC