0

I am trying to compile someone else's code but am not use to fortran. When trying to compile I get the error

ForceToForce.f90:119.34:

     99 FORMAT(3(F15.10),X,3I)
                              1
Error: Nonnegative width required in format string at (1)
ForceToForce.f90:120.37:

     111 FORMAT(4(F15.10),X,2(3I))
                                 1
Error: Nonnegative width required in format string at (1)
ForceToForce.f90:153.60:

                       WRITE(399999,FMT=111)QPCOM(i,1),QPCOM(i
                                                        1
Error: FORMAT label 111 at (1) not defined

I did a bit of research and I understand that you need to put an integer after the I to gin the number of positions used. So I changed the line to

111 FORMAT(4(F15.10),X,2(I3))

and the code complies but gives me a segmentation fault. As this is the only thing I changed in I assume I must have misunderstood how FORMAT is suppose to be used. Is there something else I should try?

sbramsey
  • 3
  • 1
  • The format string you end up with looks fine. Would you mind posting the full `WRITE` line where you use 111? Perhaps what you are giving the `WRITE` statement is not matching the format 111. – PaSTE Jul 17 '17 at 16:02
  • Is this the right line? `WRITE(399999,FMT=111)QPCOM(i,1),QPCOM(i,2),QPCOM(i,3),& &real(-(1.0d0/sqrt(1.0d0*NSUB))*(cdotp(antalmod,W,F)/DBLE(QAMP(FOUM(i,l),j)))*(const2/(2.0d0*pi))**2),i,j` – sbramsey Jul 17 '17 at 16:11
  • Pleas always use tag [tag:fortran] for all Fortran questions. I would have closed the question as a duplicate. I must write an answer now. – Vladimir F Героям слава Jul 17 '17 at 16:24

1 Answers1

0

No, that is wrong. 2(3I) specifies six integers. 2(I3) is two integers, each of them with a width of 3 characters.

The Fortran standard requires that a non-negative width is specified for the I edit descriptor as clearly stated in the error message. See Error: Nonnegative width required in format string at (1) The code used to be probably compiled by Intel Fortran, which does not strictly enforce this restriction.

So, your solution is wrong. You can use 3I0 and you should be fine and the behaviour will likely remain exactly the same.