-1

Here is the code in Makefile:

       #=======================================================================
       #  MASTER MAKEFILE FOR ZEUS-2D CODE
       #
       #-------------------  object files  -------------------- ----------------
       OBJ =   bval.o     \
       bvalrad.o  \
       ct.o       \
       dataio.o   \
       derivs.o   \
       emfs.o     \
       empty.o    \
       findno.o   \
       fld.o      \
       ggen.o     \
       giccg.o    \
       gradv.o    \
       gravity.o  \
       hdfall.o   \
       iccgaf.o   \
       intchk.o   \
       lorentz.o  \
       maxmin.o   \
       moment.o   \
       momx1.o    \
       momx2.o    \
       mprops.o   \
       msave.o    \
       mstart.o   \
       newgrid.o  \
       newvg.o    \
       newx1.o    \
       newx2.o    \
       nudt.o     \
       pdv.o      \
       pgas.o     \
       phibv.o    \
       printd.o   \
       restart.o  \
       rhs.o      \
       riccg.o    \
       setup.o    \
       srcstep.o  \
       strtoi.o   \
       stv1.o     \
       stv2.o     \
       stv3b3.o   \
       tav.o      \
       transprt.o \
       tranx1.o   \
       tranx2.o   \
       viscus.o   \
       vtos.o     \
       x1intfc.o  \
       x2intfc.o  \
       x1intzc.o  \
       x2intzc.o  \
       zeus2d.o   \
       bcdflt.o   \
       checkin.o  \
       linpck.o   \
       alpha_old.o
       #-------------------  macro definitions  -------------------------------
       .SUFFIXES:
       .SUFFIXES: .src .c .f .o
        EXEDIR = ../exe/
        SPEC   = alpha_old
        PROB   = torus
        USER   = empty
       # macros for sun or SGI
        FC     = gfortran
        OPTS   =  -c  
        CC     = cc 
        LDR    = gfortran
        #LIB    = -ldf 
        LIB    = -L/home/ianyang/CODE/hdflibs-64 -lmfhdf -ldf -                        
                 ljpeg -lz
        #--------------------  implicit rules  ---------------------------------
        .src.o:
            \cpp -P -traditional $< > $*.f
            \${FC} \${OPTS} $*.f 
        .c.o:
            ${CC} -c -ansi -D_BSD_SOURCE -            
            I/home/fyuan/ZEUS2d/zeus2d_v2.0.3/hdf/4.1r5- 
            linux/include $<
        #---------------------  targets  ---------------------------------------
        help:
            @echo Type 'make compile' to generate ZEUS-2D 
             executable
            @echo Type 'make clean'   to remove *.f and *.o 
             files
            @echo Type 'make listing' to create listing of code
        #-----------------------------------------------------------------------
        clean:
            \rm *.o *.f
        #-----------------------------------------------------------------------
        listing:
            cat Makefile zeus2d.def *.h *.src *.c > listing
        #-----------------------------------------------------------------------
        compile: ${OBJ} ${PROB}.o
        ${LDR} -o ${EXEDIR}zeus2d.exe ${OBJ} ${PROB}.o \
        ${LIB}

I've already download gfortran and tried to change the 'ifort' to 'gfort' or 'gfortran' :

    FC = gfortran
    LDR = gfortran

but it ended up with an error after I 'make compile':

    collect2: error: ld returned 1 exit status
    make: *** [Makefile:95: compile] Error 1

and some warnings:

    Warning: Deleted feature: ASSIGN statement at (1)
             linpck.f:296:20:

              296 |    20    go to next,(30, 50, 70, 110)
                  |                    
    Warning: Deleted feature: Assigned GOTO statement at (1)
             linpck.f:298:72:

              298 |       assign 50 to next
                  |                                                                        
    Warning: Deleted feature: ASSIGN statement at (1)
             linpck.f:307:72:

              307 |       assign 70 to next
                  |                                                                        
    Warning: Deleted feature: ASSIGN statement at (1)
             linpck.f:313:72:

              313 |       assign 110 to next
                  |                                                                        
    Warning: Deleted feature: ASSIGN statement at (1)
             linpck.f:349:72:

              349 |    95    sum = sum + sx(j)**2
    Warning: Fortran 2018 deleted feature: DO termination 
             statement which is not END DO or CONTINUE with 
             label 95 at (1)
   \cpp -P -traditional alpha_old.src > alpha_old.f
   \gfortran \-c   alpha_old.f 
   \cpp -P -traditional torus.src > torus.f
   \gfortran \-c   torus.f 
   torus.f:236:72:

             236 |       do 10 i=is-2,ie+2
                 |                        

and it should've generated some .f files and an executable file, however, there wasn't an exe file. \After add -w in OPTS:

\cpp -P -traditional bval.src > bval.f
\gfortran \-w -c bval.f 
\cpp -P -traditional bvalrad.src > bvalrad.f
\gfortran \-w -c bvalrad.f 
\cpp -P -traditional ct.src > ct.f
\gfortran \-w -c ct.f 
\cpp -P -traditional dataio.src > dataio.f
\gfortran \-w -c dataio.f 
\cpp -P -traditional derivs.src > derivs.f
\gfortran \-w -c derivs.f 
\cpp -P -traditional emfs.src > emfs.f
\gfortran \-w -c emfs.f 
\cpp -P -traditional empty.src > empty.f
\gfortran \-w -c empty.f 
\cpp -P -traditional findno.src > findno.f
\gfortran \-w -c findno.f 
\cpp -P -traditional fld.src > fld.f
\gfortran \-w -c fld.f 
\cpp -P -traditional ggen.src > ggen.f
\gfortran \-w -c ggen.f 
\cpp -P -traditional giccg.src > giccg.f
\gfortran \-w -c giccg.f 
\cpp -P -traditional gradv.src > gradv.f
\gfortran \-w -c gradv.f 
\cpp -P -traditional gravity.src > gravity.f
\gfortran \-w -c gravity.f 
\cpp -P -traditional hdfall.src > hdfall.f
\gfortran \-w -c hdfall.f 
\cpp -P -traditional iccgaf.src > iccgaf.f
\gfortran \-w -c iccgaf.f 
\cpp -P -traditional intchk.src > intchk.f
\gfortran \-w -c intchk.f 
\cpp -P -traditional lorentz.src > lorentz.f
\gfortran \-w -c lorentz.f 
\cpp -P -traditional maxmin.src > maxmin.f
\gfortran \-w -c maxmin.f 
\cpp -P -traditional moment.src > moment.f
\gfortran \-w -c moment.f 
\cpp -P -traditional momx1.src > momx1.f
\gfortran \-w -c momx1.f 
\cpp -P -traditional momx2.src > momx2.f
\gfortran \-w -c momx2.f 
\cpp -P -traditional mprops.src > mprops.f
\gfortran \-w -c mprops.f 
\cpp -P -traditional msave.src > msave.f
\gfortran \-w -c msave.f 
\cpp -P -traditional mstart.src > mstart.f
\gfortran \-w -c mstart.f 
\cpp -P -traditional newgrid.src > newgrid.f
\gfortran \-w -c newgrid.f 
\cpp -P -traditional newvg.src > newvg.f
\gfortran \-w -c newvg.f 
\cpp -P -traditional newx1.src > newx1.f
\gfortran \-w -c newx1.f 
\cpp -P -traditional newx2.src > newx2.f
\gfortran \-w -c newx2.f 
\cpp -P -traditional nudt.src > nudt.f
\gfortran \-w -c nudt.f 
\cpp -P -traditional pdv.src > pdv.f
\gfortran \-w -c pdv.f 
\cpp -P -traditional pgas.src > pgas.f
\gfortran \-w -c pgas.f 
\cpp -P -traditional phibv.src > phibv.f
\gfortran \-w -c phibv.f 
\cpp -P -traditional printd.src > printd.f
\gfortran \-w -c printd.f 
\cpp -P -traditional restart.src > restart.f
\gfortran \-w -c restart.f 
\cpp -P -traditional rhs.src > rhs.f
\gfortran \-w -c rhs.f 
\cpp -P -traditional riccg.src > riccg.f
\gfortran \-w -c riccg.f 
\cpp -P -traditional setup.src > setup.f
\gfortran \-w -c setup.f 
\cpp -P -traditional srcstep.src > srcstep.f
\gfortran \-w -c srcstep.f 
\cpp -P -traditional strtoi.src > strtoi.f
\gfortran \-w -c strtoi.f 
\cpp -P -traditional stv1.src > stv1.f
\gfortran \-w -c stv1.f 
\cpp -P -traditional stv2.src > stv2.f
\gfortran \-w -c stv2.f 
\cpp -P -traditional stv3b3.src > stv3b3.f
\gfortran \-w -c stv3b3.f 
\cpp -P -traditional tav.src > tav.f
\gfortran \-w -c tav.f 
\cpp -P -traditional transprt.src > transprt.f
\gfortran \-w -c transprt.f 
\cpp -P -traditional tranx1.src > tranx1.f
\gfortran \-w -c tranx1.f 
\cpp -P -traditional tranx2.src > tranx2.f
\gfortran \-w -c tranx2.f 
\cpp -P -traditional viscus.src > viscus.f
\gfortran \-w -c viscus.f 
\cpp -P -traditional vtos.src > vtos.f
\gfortran \-w -c vtos.f 
\cpp -P -traditional x1intfc.src > x1intfc.f
\gfortran \-w -c x1intfc.f 
\cpp -P -traditional x2intfc.src > x2intfc.f
\gfortran \-w -c x2intfc.f 
\cpp -P -traditional x1intzc.src > x1intzc.f
\gfortran \-w -c x1intzc.f 
\cpp -P -traditional x2intzc.src > x2intzc.f
\gfortran \-w -c x2intzc.f 
\cpp -P -traditional zeus2d.src > zeus2d.f
\gfortran \-w -c zeus2d.f 
cc  -c -ansi -D_BSD_SOURCE -I/home/fyuan/ZEUS2d/zeus2d_v2.0.3/hdf/4.1r5-linux/include bcdflt.c
bcdflt.c: In function \u2018bcdflt_\u2019:
bcdflt.c:33:3: warning: incompatible implicit declaration of built-in function \u2018strncpy\u2019 [-Wbuiltin-declaration-mismatch]
   33 |   strncpy(buf,(char *)in + *ioff,*n);
      |   ^~~~~~~
bcdflt.c:2:1: note: include \u2018<string.h>\u2019 or provide a declaration of \u2018strncpy\u2019
    1 | #include "zeus2d.def"
  +++ |+#include <string.h>
    2 | #ifdef UNICOS
cc  -c -ansi -D_BSD_SOURCE -I/home/fyuan/ZEUS2d/zeus2d_v2.0.3/hdf/4.1r5-linux/include checkin.c
In file included from /usr/include/aarch64-linux-gnu/sys/time.h:21,
                 from checkin.c:74:
/usr/include/features.h:194:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
  194 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
      |   ^~~~~~~
checkin.c: In function \u2018checkin_\u2019:
checkin.c:88:30: warning: passing argument 2 of \u2018select\u2019 from incompatible pointer type [-Wincompatible-pointer-types]
   88 |   if(*wait)nfound = select(1,&mask,0,0,&timeout);
      |                              ^~~~~
      |                              |
      |                              int *
In file included from /usr/include/aarch64-linux-gnu/sys/time.h:32,
                 from checkin.c:74:
/usr/include/aarch64-linux-gnu/sys/select.h:102:51: note: expected \u2018fd_set * __restrict__\u2019 but argument is of type \u2018int *\u2019
  102 | extern int select (int __nfds, fd_set *__restrict __readfds,
      |                                ~~~~~~~~~~~~~~~~~~~^~~~~~~~~
\cpp -P -traditional linpck.src > linpck.f
\gfortran \-w -c linpck.f 
\cpp -P -traditional alpha_old.src > alpha_old.f
\gfortran \-w -c alpha_old.f 
\cpp -P -traditional torus.src > torus.f
\gfortran \-w -c torus.f 
gfortran -o ../exe/zeus2d.exe bval.o bvalrad.o ct.o dataio.o derivs.o emfs.o empty.o findno.o fld.o ggen.o giccg.o gradv.o gravity.o hdfall.o iccgaf.o intchk.o lorentz.o maxmin.o moment.o momx1.o momx2.o mprops.o msave.o mstart.o newgrid.o newvg.o newx1.o newx2.o nudt.o pdv.o pgas.o phibv.o printd.o restart.o rhs.o riccg.o setup.o srcstep.o strtoi.o stv1.o stv2.o stv3b3.o tav.o transprt.o tranx1.o tranx2.o viscus.o vtos.o x1intfc.o x2intfc.o x1intzc.o x2intzc.o zeus2d.o bcdflt.o checkin.o linpck.o alpha_old.o torus.o \
 -L/home/ianyang/CODE/hdflibs-64 -lmfhdf -ldf -ljpeg -lz
/usr/bin/ld: skipping incompatible /home/ianyang/CODE/hdflibs-64/libmfhdf.a when searching for -lmfhdf
/usr/bin/ld: cannot find -lmfhdf: No such file or directory
/usr/bin/ld: skipping incompatible /home/ianyang/CODE/hdflibs-64/libdf.a when searching for -ldf
/usr/bin/ld: cannot find -ldf: No such file or directory
/usr/bin/ld: skipping incompatible /home/ianyang/CODE/hdflibs-64/libjpeg.a when searching for -ljpeg
/usr/bin/ld: cannot find -ljpeg: No such file or directory
/usr/bin/ld: skipping incompatible /home/ianyang/CODE/hdflibs-64/libz.a when searching for -lz
/usr/bin/ld: cannot find -lz: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:95: compile] Error 1

Files in home/CODE/hdflibs-64 are:

hello.c
libdf.a
libjpeg.a
libmfhdf.a
libz.a

ps: I'm using a M1 macbook so ifort cannot run on my computer.

Thanks so much for solving my problem!

Ian Yang
  • 1
  • 4
  • 2
    " it didn't work" does not say anything useful. What file is this? A Makefile? Show more of it. What exactly happened when you tried it? Any error message? What exactly did it do? – Vladimir F Героям слава Aug 08 '23 at 14:49
  • when I change it to 'gfort', the warning is 'warning: make: gfort: no such file or directory '; change it to 'gfortran', I got various of warnings like 'incompatible implicit declaration of built-in function', 'passing argument 2 of \u2018 select\u2019 from incompatible pointer type', ‘warning: deleted feature’, but eventually, it generated several .f file. – Ian Yang Aug 09 '23 at 02:12
  • And also there was an exe file in the folder before I 'make compile', after I 'make compile', it is gone. – Ian Yang Aug 09 '23 at 02:39
  • Please follow [ask] and [mcve]. You have to ask about those individual problems. Ask about one, then about another, because often the subsequent error nessages depend on the first one. [Edit] your question to show the relevant code and reasonably complete error messages. Do not use comments for important information. Warnings are often ignorable, you now mostly care about errors. – Vladimir F Героям слава Aug 09 '23 at 05:16
  • No, this is not enough at all. The Fortran code is necessary and it must be the Fortran code that is referred to in the error messages that you find among those many warnings that you mentioned. But since the .f files are being created by the Makefile, you also have to show us more inside the Makefile to see how exactly are those .f files being created. The ultimate fixes necessary might be simple or not but currently we have no useful information to be able to say anything. – Vladimir F Героям слава Aug 09 '23 at 06:27
  • I've added the makefile – Ian Yang Aug 09 '23 at 07:05
  • The some warnings shown are not enough, we need the first error that appears there. You can show more of them, but the first one is the most important one. The warnings are mostly just noise. – Vladimir F Героям слава Aug 09 '23 at 07:10
  • The only error is shown :'collect2: error: ld returned 1 exit status make: *** [Makefile:95: compile] Error 1', and I couldn't find where it actually went wrong. – Ian Yang Aug 09 '23 at 07:15
  • That is too late, something happens before that. Temporarily add the `-w` flag to OPTS to hide warnings, do a make clean and then make compile. Try to show the complete output. If still too big, upload it somewhere. It should not be done, but as a preliminary step it is possible. – Vladimir F Героям слава Aug 09 '23 at 07:48
  • OK, I've posted the output. – Ian Yang Aug 09 '23 at 08:07
  • Did you remove the `-c` flag? It has to stay there. – Vladimir F Героям слава Aug 09 '23 at 08:35
  • oh my mistake, now I just add -w to OPTS and the output is posted. Not many differences than before. – Ian Yang Aug 09 '23 at 08:45
  • 1
    Looks like the libraries installed in `/home/ianyang/CODE/hdflibs-64/` cannot be used by gfortran. Where do they come from? – PierU Aug 09 '23 at 12:05
  • 1
    I suspect these libraries are for Intel x86 CPUs, while gfortran here tries generating an ARM64 (Apple Silicon M1) binary code. Hence the incompatibility. – PierU Aug 09 '23 at 13:13
  • So it means that I still cannot use gfortran instead of ifort? – Ian Yang Aug 10 '23 at 01:53
  • No, it means you need M1 versions of those libraries. Ifort would not have been able to use them either. Where did you get them in the first place? – Vladimir F Героям слава Aug 10 '23 at 05:47
  • My tutor gived me. – Ian Yang Aug 10 '23 at 06:32
  • To develop/run on a Mac M1 you need ARM64 librairies/binaries/etc... You have to recompile these librairies on your Mac from the source codes. Another solution is to get a full x86 emulator such as [UTM](https://mac.getutm.app/) : then you can install a classical x86 version of Ubuntu and all x86 tools (including ifort if you need). But the performances are likely to be terrible. – PierU Aug 10 '23 at 07:01
  • OK thank you so much! I've tried UTM for full x86 emulator...it is indeed terrible..so slow. I'll try to find ARM64 libraries. – Ian Yang Aug 10 '23 at 07:06
  • Tryiing to find ARM64 libraries is not the correct way to approach it. If those libraries are available for your ARM64 Ubuntu, by all means install them and use them. Use `apt search` or https://askubuntu.com/questions/160897/how-do-i-search-for-available-packages-from-the-command-line. But otherwise just download the source code, compile it and install it. Most often you will need the `./configure`,`make` and `make install` trii of commands. If you do not know what they do, read some tutorial, you will need it. See also https://stackoverflow.com/a/66860223/721644 – Vladimir F Героям слава Aug 10 '23 at 12:59

0 Answers0