Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue parsing en empty line starting with & #399

Open
svalat opened this issue Apr 11, 2023 · 3 comments
Open

Issue parsing en empty line starting with & #399

svalat opened this issue Apr 11, 2023 · 3 comments

Comments

@svalat
Copy link

svalat commented Apr 11, 2023

I observed an issue in the CROCO oceanic simulation while applying fparser on its step3d file.

fparser2 step3d_t_.mpc.f
Traceback (most recent call last):
  File "/home/svalat/Projects/croco-psyclone/bench/rundir/venv/bin/fparser2", line 8, in <module>
    sys.exit(main())
  File "/home/svalat/Projects/croco-psyclone/bench/rundir/venv/lib/python3.10/site-packages/fparser/scripts/fparser2.py", line 122, in main
    runner(parser, options, args)
  File "/home/svalat/Projects/croco-psyclone/bench/rundir/venv/lib/python3.10/site-packages/fparser/scripts/fparser2.py", line 106, in runner
    program = fparser(reader)
  File "/home/svalat/Projects/croco-psyclone/bench/rundir/venv/lib/python3.10/site-packages/fparser/two/Fortran2003.py", line 237, in __new__
    return Base.__new__(cls, string)
  File "/home/svalat/Projects/croco-psyclone/bench/rundir/venv/lib/python3.10/site-packages/fparser/two/utils.py", line 428, in __new__
    raise NoMatchError(errmsg)
fparser.two.utils.NoMatchError: at line 12
>>>      call step3d_t_tile(Istr,Iend,Jstr,Jend

The major issue is that the problem is not reported on the right line. The problem comes from an empty line starting by & in the last nested for loops and not from the call itself.

      subroutine step3d_t (tile)
      implicit none
      integer*4 tile
      integer*4 trd, omp_get_thread_num
      real A2d(100,100,0:100), A3d(100,8,0:100)
      integer Istr, Iend,  Jstr, Jend
      Istr=10
      Iend=10
      Jstr=10
      Jend=10
      trd=1
      call step3d_t_tile(Istr,Iend,Jstr,Jend
     &                    ,A2d(1,1,trd), A2d(1,2,trd), A2d(1,3,trd)
     &                    ,A2d(1,4,trd), A2d(1,5,trd), A2d(1,6,trd)
     &                    ,A2d(1,7,trd), A2d(1,8,trd), A2d(1,9,trd)
     &                                                ,A3d(1,1,trd)
     &   ,A3d(1,2,trd),A3d(1,3,trd),A3d(1,4,trd),A3d(1,5,trd)
     &                            )
      return
      end
      subroutine step3d_t_tile (Istr,Iend,Jstr,Jend,
     &                          FX,FE, WORK, FC,CF,BC,DC,EC,GC, swdk
     &                           ,FX_3D,FE_3D,WORK_3D,WORK2_3D
     &  )
      implicit none
      integer*4  N
      parameter (N=10)
      integer*4 Istr,Iend,Jstr,Jend, itrc, i,j,k, indx, kmld
     &       ,imin,imax,jmin,jmax,iAkt,nadv
      real epsil
      real FX_3D(Istr-2:Iend+2,Jstr-2:Jend+2,0:N),
     &     FE_3D(Istr-2:Iend+2,Jstr-2:Jend+2,0:N),
     &     WORK_3D(Istr-2:Iend+2,Jstr-2:Jend+2,0:N),
     &     WORK2_3D(Istr-2:Iend+2,Jstr-2:Jend+2,0:N)


      DO k=1,N
          do j=Jstr,Jend
            do i=Istr,Iend
              t(i,j,k,nnew,itrc)=Hz_bak(i,j,k)*t(i,j,k,nstp,itrc)
     &                    -dt*pm(i,j)*pn(i,j)*(
     &                                       FX_3D(i+1,j,k)-FX_3D(i,j,k)
     &
     &                                     +FE_3D(i,j+1,k)-FE_3D(i,j,k))
            enddo
          enddo
      ENDDO
      return
      end
@hiker
Copy link
Collaborator

hiker commented Apr 11, 2023

Did you switch to use fixed format? I only get this error when I try to parse it as free (which is the default). I am not sure if you can change this in fparser2. For a simple script I added:

        parser = ParserFactory().create(std="f2003")
        from fparser.common.sourceinfo import FortranFormat
        reader.set_format(FortranFormat(False, False))
        parse_tree = parser(reader)

And then it was happy with the file.

@sergisiso
Copy link
Collaborator

sergisiso commented Apr 11, 2023

Thanks @hiker , Sebastien had this problem in psyclone and I didn't realize it was a Fortran format issue. Can the format for the psyclone cli input file be changed? I can just see a parameter for the FortranReader, but nemo does not use this class yet.

Regardless, the error message seems that could be improved to be more descriptive.

(@svalat The other issue with the C$... comment may be related. Is all CROCO fixed format or just part of it?)

@svalat
Copy link
Author

svalat commented Apr 11, 2023

@hiker & @sergisiso Yes, I got that issue via PSyClone.

Croco has both fixed and free form, but for the file I'm currently considering they are only fixed. (for the other person who had the issue with C$, I'm not sure if he needs to pass on the free form ones).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants