Author Topic: Problem with iofile.h and fmt_long in feappv-5.1.2e  (Read 3002 times)

BjornG

  • New Member
  • *
  • Posts: 8
Problem with iofile.h and fmt_long in feappv-5.1.2e
« on: February 12, 2025, 02:41:56 PM »
First of all, many thanks for providing Feappv for free.
I have used it since its predecessor in the 3rd edition of Zienkiewicz text book when we typed it from the chapter 26.

I am trying to install feappv-5.1.2e on a computer using Linux Mint 21.3 and gfortran
(GNU Fortran (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0)
The installation halts when compiling program/pmacr1.f with the following message:

pmacr1.f:430:16:

 430 |         fmt_long = .true.
     |                1
Error: Symbol  at (1) has no IMPLICIT type

pmacr1.f contains the line
include 'iofile.h'
where fmt_long is declared as logical and placed in the common block file iofile.
iofile.h contains two equally named but different common statements and I am not sure how the compiler handles this:

     integer         or,ow
     common /iofile/ or,ow

     logical         keepfl,fmt_long
     common /iofile/ keepfl,fmt_long

I commented out the first of these common statements but the error persists.

The same compilation error occurs in two other files:
program/prosodist
program/probationer

So I have declared fmt_long as logical in these three files and it compiles cleanly (except for warnings).
But this "fix" bypasses the role of the common block to transfer the value of fmt_long between subroutines.

I would appreciate a fix of this problem.

Kind regards
Björn Gustafsson

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #1 on: February 12, 2025, 05:27:33 PM »
This is a pretty strange error.  The common block as written looks just fine and pmacr1.f also looks fine (plus it compiles on at least three different computers that I have).  The other two files that you identify as having problems are not part of FEAPpv.  Thus I am guessing that you have a modified set of source files and they may be corrupted in some strange fashion.

Can you please retry using a clean version of the source code: 
Code: [Select]
git clone https://github.com/sanjayg0/feappv.git feappvclean

BjornG

  • New Member
  • *
  • Posts: 8
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #2 on: February 13, 2025, 03:35:26 AM »
I downloaded feappv-master.zip from git and compared with the previously downloaded feappv-5.1.2e.zip  and the only difference was in the vem/main/makefile which in the former had advice for a patch:
11,15d10
< # UBUNTU and other GCC loader type machines (unchecked)
< # Replace $(ARVFEAPPV) \ by:
< #    -L$(FEAPPVHOME5_1)/vem \
< #    -Wl,-whole-archive -lfeappvvem_g -Wl,-no-whole-archive \
<

But I have not tried to install the VEM version so I assume that it is not any help for me.

And if I declare fmt_long only in pmacr1.f  the installation halts  in pnewprob.f :
pnewprob.f:117:14:

  117 |       fmt_long = .false.
      |              1
Error: Symbol ‘fmt_long’ at (1) has no IMPLICIT type; did you mean ‘flog’?

I see now an error in my previous post, I don't know how that happened.
The two other files that halt the compilation are
program/prtdis.f
program/pnewprob.f
When all three gets a logical declaration of fmt_long the compilation succeds.







Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #3 on: February 13, 2025, 03:31:47 PM »
This is a very strange error.  iofile.h is used in tons of places in the code.  I can not understand why you are only seeing a problem in 3 files.  I will see if I can re-create your environment.

BjornG

  • New Member
  • *
  • Posts: 8
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #4 on: February 14, 2025, 12:52:09 AM »
'iofile.h' is indeed included in many files but fmt_long appears only in three:   
find ./ -name "*.f" -exec grep -l fmt_long {} \;
./program/pmacr1.f
./program/prtdis.f
./program/pnewprob.f

Since I am a bit suspicious about having two different common blocks with the same name I tried to split iofile.h into two:
iofile.h

      integer         ior,iow
      common /iofile/ ior,iow

iofile2.h

      logical         keepfl,fmt_long
      common /iofile2/ keepfl,fmt_long

I changed the three files above using fmt_long to include 'iofile2.h' instead of 'iofile.h'
However, this did not work:
pmacr1.f:45: Error: Can't open included file 'iofile2.h'
although they have the same file permissions.
There is obviously something more that must be altered but I don't know what.

By the way:
In my first post I said that  compilation error occurs in two other files:
program/prosodist (instead of program/prtdis.f)
program/probationer (instead of program/pnewprob.f)
This was caused by the spell checker of LibreOffice Writer and i did not observe the change.
I can not remember that Writer asked me to confirm the change.

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #5 on: February 15, 2025, 10:53:36 AM »
Please try this.

Change the declaration in iofile.h so that fmt_long is fmtlong; i.e. remove the underscore.
Then in the three files where it is used, change fmt_long to fmtlong also.  Then recompile everything, archive, all files, executable.

I am thinking that the problem has to do with the fact that fmt_long may be a reserved word for your OS/compiler system.

BjornG

  • New Member
  • *
  • Posts: 8
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #6 on: February 20, 2025, 03:06:39 PM »
I tried with removing the underscore in fmt_long without success, see attempt 1 below.

The first thing I tried when I got the compile error was to declare fmt_long to be logical in the three files that uses it.
This is of course not a solution to the problem but the compilation finished without errors.
The compiler did not complain about keepfl which is also in iofile.h and used in pnewprob.f
So keepflg and fmt_long (and fmtlong) are treated differentlly for some reason.

pnewprob.f:          if(keepfl) then
pnewprob.f:            keepfl = .true.

pnewprob.f:      fmtlong = .false.

Below is a brief summary of my three attempts and how they fail.
I have no more ideas how to find a solution.

There is a fmt_long on the web
https://linux.die.net/man/3/fmt_long
but I can't see that it has anything to do with my problem.

Yours sincerely

Björn Gustafsson
--------------------------- attempt 1: remove underscore in fmt_long
cat iofile.h

      integer         ior,iow
      common /iofile/ ior,iow

      logical         keepfl,fmtlong
      common /iofile/ keepfl,fmtlong

pmacr1.f:430:15:

  430 |         fmtlong = .true.
      |               1
Error: Symbol ‘fmtlong’ at (1) has no IMPLICIT type
---------------------------  attempt 2: putting all four variables in iofilo.h
cat iofile.h

      integer         ior,iow
*      common /iofile/ ior,iow

      logical         keepfl,fmtlong
   common /iofile/ keepfl,fmtlong,ior,iow

pmacr1.f:430:15:

  430 |         fmtlong = .true.
      |               1
Error: Symbol ‘fmtlong’ at (1) has no IMPLICIT type
--------------------------- splitting iofile.h into two files
cat iofile.h
      integer         ior,iow
      common /iofile/ ior,iow

cat iofile2.h
      logical         keepfl,fmtlong
      common /iofile2/ keepfl,fmtlong
     
grep iofile2 *.f
pmacr1.f:      include   'iofile2.h'
pnewprob.f:      include   'iofile2.h'
prtdis.f:      include  'iofile2.h'

pmacr1.f:45: Error: Can't open included file 'iofile2.h'
(iofile2.h and iofile.h  have he same file permissions:
-rwxr-xr-x 1 bjorn bjorn 76 Feb 20 22:40 iofile2.h
-rwxr-xr-x 1 bjorn bjorn 61 Feb 20 22:40 iofile.h
)
----------------------------


Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #7 on: February 20, 2025, 11:27:26 PM »
Where did you place iofile2.h? In what folder?

BjornG

  • New Member
  • *
  • Posts: 8
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #8 on: February 21, 2025, 03:11:06 PM »
I placed it  in the include directory:
bjorn@bjorn-ThinkCentre-M82:~/Feappv/feappv-5.1.2e/include$ ls -l  iofile.h iofile2.h
-rwxr-xr-x 1 bjorn bjorn 76 Feb 20 22:40 iofile2.h
-rwxr-xr-x 1 bjorn bjorn 61 Feb 20 22:40 iofile.h


bjorn@bjorn-ThinkCentre-M82:~/Feappv/feappv-5.1.2e/include$ cat  iofile.h iofile2.h

      integer         ior,iow
      common /iofile/ ior,iow

      logical         keepfl,fmtlong
      common /iofile2/ keepfl,fmtlong

So I can't understand why iofile2.h can not be opened.

I was skeptical to having two different common blocks with the same name (I have never seen it before).
So I wrote a tiny program test.f  which made include of the original iofile.h,
compiled and run it all it worked fine:
bjorn@bjorn-ThinkCentre-M82:~/Feappv/iofile$ cat iofile.h test.f

      integer         ior,iow
      common /iofile/ ior,iow

      logical         keepfl,fmt_long
      common /iofile/ keepfl,fmt_long

      include "iofile.h"
      iow = 6
      ior = 5
      keepfl = .true.
      fmt_long = .false.
      write(6,*)'ior,iow ',ior,iow
      write(6,*)'keepfl,fmt_long ',keepfl,fmt_long
      end
     
bjorn@bjorn-ThinkCentre-M82:~/Feappv/iofile$ gfortran -o test test.f

bjorn@bjorn-ThinkCentre-M82:~/Feappv/iofile$ ./test
 ior,iow            5           6
 keepfl,fmt_long  T F





FEAP_Admin

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 993
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #9 on: February 21, 2025, 08:33:34 PM »
Something seems to be deeply scrambled with your system.  If iofile2.h is in the include directory, then you should never have received the message that it could not be found.  I will have to think more about how you can debug this issue.

BjornG

  • New Member
  • *
  • Posts: 8
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #10 on: February 24, 2025, 01:24:08 PM »
I have now installed the latest version of Linux Mint,  Cinnamon 22.2, on a spare computer.
After installing libx11-dev, the compilation of feappv-5.1.2e was successful, no errors but a lot of warnings,
It created an executable feappv.

I will upgrade my Mint 21.3 to 22.2 to see if the problem disappears but I have not had any problems with Mint 21.3 except this with fmt_long. And upgrading is a bit risky so I am not in a hurry to do that.

Thanks for your efforts!

Yours sincerely
Björn Gustafsson


BjornG

  • New Member
  • *
  • Posts: 8
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #11 on: February 28, 2025, 11:16:53 AM »
I have now upgraded Linux Mint 21.3 Cinnamon to version 22 after which it compiles feappv-5.1.2e without errors to an executable feappv. I leave the problem with that.

Björn Gustafsson

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Problem with iofile.h and fmt_long in feappv-5.1.2e
« Reply #12 on: February 28, 2025, 02:36:27 PM »
Thanks for the update.