Author Topic: Compiling FEAP 8.4 with user subroutine in Fortran 90  (Read 6607 times)

K.Li

  • Full Member
  • ***
  • Posts: 191
Compiling FEAP 8.4 with user subroutine in Fortran 90
« on: September 02, 2015, 05:59:16 AM »
Hi, FEAP users:

Recently, I have been trying to compile FEAP on Ubuntu mainly for debugging some user subroutines I wrote. All the subroutines are stored in a separate folder "AAA". There are also some old subroutines written in Fortran 77 in AAA. New ones are coded in Fortran 90. It seems all the subroutines I wrote in Fortran 90 are not compiled in the first try. So I have added following to the makefile in AAA, 


Code: [Select]
FT90 = f90
SOURCES = $(wildcard $(FSOURCE)*.$(FEXT)) $(wildcard $(FSOURCE)*.$(FT90)) $(wildcard $(CSOURCE)*.$(CEXT))
OBJSF   = $(SOURCES:.f=.o)
OBJSFF   = $(OBJSF:.f90=.o)
OBJS    = $(OBJSFF:.c=.o)
FL      = built_objs

.....................

.f90.a:
@if $(FF) -c -I$(FINCLUDE) $(FFOPTFLAG) $(FOPTIONS) $*.f90 -o $*.o; then echo $*.o >> $(FL); else false; fi;
@echo "Building $*.o"



Of course, I have modified the makefile in the top folder (/...../ver84/makefile) for this new folder AAA I created.
Code: [Select]
archive:   
(cd program; make archive)
(cd AAA; make archive)
        .......................

So the Fortran 77 source files (.f) stored in AAA were compiled successfully as usual.  However, I got errors like

Code: [Select]
/home/test/feap/ver84/Feap8_4.a(newmm.o): In function `newmm_':
newmm.f:(.text+0xbfd): undefined reference to `integgd_'

Note, here function "integgd" is defined in Fortran 90 format with the file name "integgd.f90".
 
I have no experience about the makefile, I really appreciate it if someone could help me out with this error.

BTW: All the subroutines were compiled with Intel Compiler on a Windows 7 machine without any error.

Thanks a lot!

K. Li
« Last Edit: September 02, 2015, 06:40:51 AM by K.Li »

Jfrisch

  • Full Member
  • ***
  • Posts: 65
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #1 on: August 16, 2017, 05:45:24 AM »
Hello everyone,

I have the same issue trying to compile FEAP8.5 with an user elment subroutine coded in Fortran90. I have made the same adjustements that K. Li did (because they worked with FEAPpv3.1), but FEAP8.5 is compiling only .f-files (Fortran77) and ignores every .f90-file in my user-subdirectory. Any suggestions what has changed or how I can solve this problem?

Thanks in advance!

Jan Frischmann

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #2 on: August 16, 2017, 07:22:11 AM »
On my computer, I just name ALL my files with the .f extender and then use the original make system.  It seems to work with Intel and GCC compilers on a Mac.  I don't think it is necessary to use .f90 (even for f90 files, modules et cetera).

Jfrisch

  • Full Member
  • ***
  • Posts: 65
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #3 on: August 16, 2017, 11:53:15 PM »
I tried this as well but when I rename my user element routine to elmt01.f I get an error in every single line because I do not intend the four characters needed in fortran77. E.g. there is also an unexpected end of file with this error-message before:
Code: [Select]
elmt01.f:820:1:

 end subroutine elmt01
 1
Error: Non-numeric character in statement label at (1)
elmt01.f:820:1:

 end subroutine elmt01
 1
Error: Unclassifiable statement at (1)
f951: Error: Unexpected end of file in ‘elmt01.f’
make[2]: *** [/home/jf/Dropbox/FEM/feap/ver85/Feap8_5.a(elmt01.o)] Error 1
make[1]: *** [archive] Error 1
make: *** [archive] Error 2

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2647
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #4 on: August 17, 2017, 05:46:27 AM »
Can you try adding the rule:

%.o: %.f90
        $(FF) -c $(FFOPTFLAG) -I$(FINCLUDE) $*.f90 -o $*.o

to your makefile

Jfrisch

  • Full Member
  • ***
  • Posts: 65
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #5 on: August 17, 2017, 06:04:16 AM »
I added your recommendation to the makefile in my user-subdirectory but still I am getting this error-message:

Code: [Select]
--->/home/jf/Dropbox/FEM/feap/ver85/contact/util objects now up-to-date<---
make[2]: Leaving directory '/home/jf/Dropbox/FEM/feap/ver85/contact/util'
make[1]: Leaving directory '/home/jf/Dropbox/FEM/feap/ver85/contact'
--> Feap Archive updated <--
(cd main; make feap)
make[1]: Entering directory '/home/jf/Dropbox/FEM/feap/ver85/main'
gfortran -c -g -O2 -J/home/jf/Dropbox/FEM/feap/ver85/modules -I/home/jf/Dropbox/FEM/feap/ver85/include -I/home/jf/Dropbox/FEM/feap/ver85/modules -I/home/jf/Dropbox/FEM/feap/ver85/include/integer8  feap85.f -o feap85.o
ranlib /home/jf/Dropbox/FEM/feap/ver85/Feap8_5.a
gfortran -o feap feap85.o \
 \
 \
/home/jf/Dropbox/FEM/feap/ver85/Feap8_5.a -L/usr/X11R6/lib -lX11 -lblas -llapack -ljpeg -lm
/home/jf/Dropbox/FEM/feap/ver85/Feap8_5.a(elmlib.o): In function `elmlib_':
/home/jf/Dropbox/FEM/feap/ver85/program/elmlib.f:60: undefined reference to `elmt01_'
collect2: error: ld returned 1 exit status
makefile:6: recipe for target 'feap' failed
make[1]: *** [feap] Error 1
make[1]: Leaving directory '/home/jf/Dropbox/FEM/feap/ver85/main'
makefile:12: recipe for target 'feap' failed
make: *** [feap] Error 2

The part with the undefined reference shows, that elmt01.f90 isn't compiled so FEAP8.5 doesn't know about the subroutine I coded. If I name my file elmt01.f the above mentioned error-messages for every line (because I do not start at column 5 letting the first four columns of each line to be used for goto-marks) still appear.
« Last Edit: August 17, 2017, 06:12:35 AM by Jfrisch »

Prof. S. Govindjee

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 1160
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #6 on: August 17, 2017, 06:22:11 AM »
annoying as it is, if you do not want to waste time, just place an explicit rule for your elmt01.f90 (compile and archive) in your makefile.  So don't rely on the magic of make.

we'll figure out the issue but it may take a few days/weeks.

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2647
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #7 on: August 17, 2017, 06:25:54 AM »
where do you have the routine for elmt01.f90 -- you should make sure you can compile this routine separately as it looks like you have change many things.  What happens if you build feap without the routine?  It should produce the executable.  Then try adding the routine in the directory 'main' (with the added rule) to see if you can build it and again get the executable.

Then once all works you can put the file where you may really want it and do the build with all the paths defined.

Keep the steps simple

Jfrisch

  • Full Member
  • ***
  • Posts: 65
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #8 on: August 17, 2017, 06:56:05 AM »
where do you have the routine for elmt01.f90
I have edited the routine "elmt01.f" in the user subdirectory and saved it as a .f90-file to tell the compiler that it is coded in Fortran 90

-- you should make sure you can compile this routine separately as it looks like you have change many things.  What happens if you build feap without the routine?  It should produce the executable. 
Do you mean/suggest to comment the section in feap85.f trying to compile the elmt01-subroutine so everything else is compiled? I can try to figure out how the seperately compiling works, never done this yet (first approach to compile it directly ended with the problem of the include-subdirectory of feap that isn't found).

Then try adding the routine in the directory 'main' (with the added rule) to see if you can build it and again get the executable.

Then once all works you can put the file where you may really want it and do the build with all the paths defined.

Keep the steps simple

Keeping the steps simple sounds quite good. But I do not really understand why now feap omits to compile the subroutine, because in the past I have done the same edits in makefile's and it worked (at least it worked after I solved all problems resulting to some failures in my code).

Prof. R.L. Taylor

  • Administrator
  • FEAP Guru
  • *****
  • Posts: 2647
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #9 on: August 17, 2017, 09:08:17 AM »
1. Leave the original elmt01.f in the /user directory and compile feap to get an executable.

2. Put the new elmt01.f90 in ./main and edit the makefile to add the f90 compile command

3. enter 'make' in the ./main directory -- it should replace the elmt01.o in the archive with the build in main

Jfrisch

  • Full Member
  • ***
  • Posts: 65
Re: Compiling FEAP 8.4 with user subroutine in Fortran 90
« Reply #10 on: August 18, 2017, 12:55:16 AM »
Now the compiling works without seperately compiling the user element subroutine (but don't know why exactly it works). Thanks!