jharno / cubep3m

cosmological n-body code
https://wiki.cita.utoronto.ca/index.php/CubePM
35 stars 11 forks source link

[Question] Makefile not working #12

Closed wuseyu closed 1 year ago

wuseyu commented 1 year ago

Hello, I have some question when I tried to transplant it for linux.

The gcc version I am using is 9.3.0,
hmpi version is 1.1.1 , 
openblas version is 0.3.18, 
fftw version is 3.3.8, 
hdf5 version is 1.10.1

At the beginning I met FFLAGS question :

  1. fpp: The platform is recommended to be modified to “-cpp”

  2. axN:I found it only work in ifort,so I delete it.

image

Then I met my current problem.

image They seem to be the same kind of problem.

What can I do for deal with them?

jharno commented 1 year ago

Hi,

the -fpp flag stands for "fortran pre-processor flag", which allows us to use the #ifdef statements in the code. gfortran use -cpp to achieve this. You should probably also include "-ffree-line-length-none", depending on your compiler.

The file that seems to crash is part of the MHD module, which is not well tested. Were you hoping to include baryons, or just dark matter?

Sincerely, Joachim


From: wuseyu @.> Sent: 17 October 2022 02:53 To: jharno/cubep3m @.> Cc: Subscribed @.***> Subject: [jharno/cubep3m] [Question] Makefile not working (Issue #12)

⚠ External sender. Take care when opening links or attachments. Do not provide your login details.

Hello, I have some question when I tried to transplant it for linux.

The gcc version I am using is 9.3.0,

hmpi version is 1.1.1 ,

openblas version is 0.3.18,

fftw version is 3.3.8,

hdf5 version is 1.10.1

At the beginning I met FFLAGS question :

  1. fpp: The platform is recommended to be modified to “-cpp”

  2. axN:I found it only work in ifort,so I delete it.

[image]https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F96163054%2F196071883-55ebbbeb-3023-42dd-a276-e5233876e38a.png&data=05%7C01%7CJoachim.Harnois-Deraps%40newcastle.ac.uk%7C64819d02787649a9caa608daafe258ce%7C9c5012c9b61644c2a91766814fbe3e87%7C1%7C0%7C638015683928813588%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=qLogNOw5v1qgzXlvwMek2g8I1d8STd3ThIY%2F%2FaeZtxE%3D&reserved=0

Then I met my current problem.

[image]https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fuser-images.githubusercontent.com%2F96163054%2F196072105-d6ad3eea-be77-4341-a544-35c28189462a.png&data=05%7C01%7CJoachim.Harnois-Deraps%40newcastle.ac.uk%7C64819d02787649a9caa608daafe258ce%7C9c5012c9b61644c2a91766814fbe3e87%7C1%7C0%7C638015683928813588%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XW5MzHOZPZFTzV24U4On1FA4F9suy%2BVWOBvEDyAGjGI%3D&reserved=0 They seem to be the same kind of problem.

What can I do for deal with them?

— Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fjharno%2Fcubep3m%2Fissues%2F12&data=05%7C01%7CJoachim.Harnois-Deraps%40newcastle.ac.uk%7C64819d02787649a9caa608daafe258ce%7C9c5012c9b61644c2a91766814fbe3e87%7C1%7C0%7C638015683928813588%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=wcWBgL3eIPMb3hBHXFojdzyzN61ECN5I0xgbRwcBlGw%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAAISJHK4K5OGWZ27EPDEJX3WDSWQNANCNFSM6AAAAAARGTQWUA&data=05%7C01%7CJoachim.Harnois-Deraps%40newcastle.ac.uk%7C64819d02787649a9caa608daafe258ce%7C9c5012c9b61644c2a91766814fbe3e87%7C1%7C0%7C638015683928813588%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=XE9OGkUY%2BeUU63iWrilBoR97O5eAWKYInWW9mWQWUKI%3D&reserved=0. You are receiving this because you are subscribed to this thread.Message ID: @.***>

martin-g commented 1 year ago

I am also trying to build cubep3m.

Error:

mpif90 -cpp -g -w -O3 -DDIAG -ffree-line-length-none  -c mpi_tvd_mhd.f90
mpi_tvd_mhd.f90:576:33:

  576 |                       comm_cart, ierr)
      |                                 1
......
  639 |         call mpi_reduce(amaxl,amax,1,MPI_REAL,MPI_MAX,0,comm_cart, ierr)
      |                                                                   2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/INTEGER(4)).
mpi_tvd_mhd.f90:577:50:

  577 |       call mpi_bcast(cmax,1,MPI_REAL,0,comm_cart, ierr)
      |                                                  1
......
  643 |         call mpi_bcast(amax,1,MPI_REAL,0,comm_cart, ierr)
      |                                                    2
Error: Type mismatch between actual argument at (1) and actual argument at (2) (REAL(4)/INTEGER(4)).
make: *** [Makefile_linux_arm64:25: mpi_tvd_mhd.o] Error 1

Here is the relevant part of the Makefile:

SHELL = /bin/sh

FC=mpif90

#TACC Lonestar  
FFTWLIB=/usr/lib/x86_64-linux-gnu/
FFTWINC=/usr/include/

#Mckenzie   
LDLIBS= -lfftw3_mpi -lfftw3 -lsfftw_mpi -lsfftw -lm -ldl

#Mckenzie
FFLAGS=-cpp -g -w -O3 -DDIAG -ffree-line-length-none # -axN -DNGP -DMHD #-check bounds -DDEBUG #-DDEBUG_LOW #-DDEBUG_VEL -DDEBUG_CCIC -DDEBUG_RHOC -openmp -DDEBUG_LOW

#OPTIONAL FLAGS :: -DMHD -DDEBUG_CCIC -DDEBUG_CRHO -DDEBUG_RHOC -DPOINTSRC ##-DBFTEST

OBJS= mpi_tvd_mhd.o gas_density_buffer.o fine_gas_mass.o checkpoint.o coarse_cic_mass.o coarse_cic_mass_buffer.o coarse_force.o coarse_force_buffer.o coarse_mass.o coarse_max_dt.o coarse_mesh.o coarse_power.o coarse_velocity.o cubepm.o delete_particles.o fftw3ds.o fine_cic_mass.o fine_cic_mass_buffer.o fine_mesh.o fine_ngp_mass.o fine_ngp_mass_halos.o fine_velocity.o halofind.o fftw2.o kernel_initialization.o link_list.o mpi_initialization.o particle_initialization.o particle_mesh.o particle_pass.o projection.o report_pair.o set_pair.o indexedsort.o timers.o timestep.o update_position.o variable_initialization.o 

run: cubep3m

cubep3m: $(OBJS)
    $(FC) $(FFLAGS) $^ -o $@ -L$(FFTWLIB) $(LDLIBS) 

mpi_tvd_mhd.o: mpi_tvd_mhd.f90
    $(FC) $(FFLAGS) -c $<
...
Ubuntu 22.04.1, x86_64
gcc version is 11.3.0,
openblas version is 0.3.20, 
fftw version is 3.3.8, 
hdf5 version is 1.10.7

Any help is very welcome!

jharno commented 1 year ago

Dear Martin,

The module that causes this problem seems to be the mpi_tvd_mhd, which is part of the MHD code that is not supported. Are you trying to compile for dark matter only or baryons?

martin-g commented 1 year ago

Thanks for the quick answer, Joachim! Dark matter only for now.

IZUMI-Zu commented 1 year ago

Hi, I'm also interested in build it, but the makefile seems not work for my computer. Are there any documents or instructions? I'm compile for baryons. Thanks.

wuseyu commented 1 year ago

@jharno Now I am trying to migrate this software to a new operating system,which using gcc and openmpi in x86,also clang and openmpi in arm. Can you give some general solutions? Thanks for your reply.

jharno commented 1 year ago

Unfortunately Cubep3m is not well tested for baryons. The baryons modules exist as magneto-hydrodynamics were included in a previous version of the code (adiabatic only, no sub-gris physics), but support for this has been discontinued. I would recommend trying another hydro-code. Sorry.

The makefile for dm-only are Make_PP_THREADS and Makefile_p3dfft_nested

IZUMI-Zu commented 1 year ago

I'll try it, thanks.

jharno commented 1 year ago

Can you try with: Makefile_fftw3?

wuseyu commented 1 year ago

@jharno Hello, I used "Make_PP_THREADS" according to your suggestion under the x86, in this file, flag "-shared-intel", "-fpp", and "-xhost" can't work ,so I deleted "-shared-intel" and "-xhost",and replaced "-fpp" to "-cpp".(I don't know what the consequences of deleting them will be, but their existence hinders the operation of the program) But after that I ran into some problems, luckily I solved them by adding some flags,which includes " -fallow-argument-mismatch -Wno-error -ffree-form -ffixed-line-length-none -ffree-form". And now I met the last error message. image It seems like some Grammatical errors, but I have no experience to solve the gfortran problem.So can you give me some suggestions?
Thanks again for your reply,hope it doesn't bother you.

wuseyu commented 1 year ago

Can you try with: Makefile_fftw3?

I used to use this file too, but the results were not ideal. It doesn't work for me.

martin-g commented 1 year ago

@wuseyu You may want to check https://github.com/jharno/cubep3m/pull/13. It is a draft PR that adds Makefile based on gfortran and fftw3

wuseyu commented 1 year ago

@martin-g OK, I will check it.

jharno commented 1 year ago

I am also worried about the message that says "-Wline-truncation". That should not happen with the -ffixed-line-lenght-none flag.

wuseyu commented 1 year ago

image This is my current configuration about Make_PP_THREADS. Now when it compiles it will focus on three problems. image image image They should be solved by " -ffixed-line-lenght-none" but not. ps: Maybe my gcc version is too old? It's 10.3.0.

jharno commented 1 year ago

Note that you have twice the -ffree-form flag

jharno commented 1 year ago

Could you try -ffree-line-length-none?

wuseyu commented 1 year ago

image Thanks for your suggestion! This fflag seems to be working fine, but some files cannot be generated properly.

martin-g commented 1 year ago

You have to remove the -openmp flag for those files.

wuseyu commented 1 year ago

OK, I will try it.

jharno commented 1 year ago

Thanks for your help, Martin, your response time is faster than mine! Out of curiosity, I'd be interested to know what science you are trying to achieve with your runs. Feel free to contact me privately if interested in chatting.

wuseyu commented 1 year ago

@jharno I'm afraid I still need your help. Thanks for your previous guidance, I had quite a few problems linking the library after that, but I solved it all using fftw2's library and generated the executable, but now the service seems to be starting It crashed before, what is the reason for the problem,I found some similar error questions, but none of them gave an exact solution (maybe I'm looking in the wrong direction). looking forward to your reply. image

jharno commented 1 year ago

OK, That's good progress, we're nearly there.

The code now compiled, and is looking for a file named checkpoints_high, which specifies at which redshifts you want the particle dumped.

If, instead, you bash source the README file (and read it as well, it is very short, but contains a few key info), it should now work.

wuseyu commented 1 year ago

Thanks for your reply, it really helped me a lot. I will try it after my class, hope everything is fine.

martin-g commented 1 year ago

@wuseyu Could you please attach your Makefile here ? Thanks!

jharno commented 1 year ago

All my makefiles are included in the source_threads/ directory.

I recently used Makefile_fftw3.

martin-g commented 1 year ago

@jharno I guess you used it with Intel compiler ? As I shared at https://github.com/jharno/cubep3m/pull/13 I cannot make it work with GNU Fortran and FFTW3. I will add Github Actions workflow to my draft PR that will show the compilation errors!

jharno commented 1 year ago

OK

wuseyu commented 1 year ago

@martin-g There are modifications I made,hope it can help you.

14

jharno commented 1 year ago

I've merged the work to the main branch, thanks for your help in compiling cubep3m with gfort!

jharno commented 1 year ago

Closing this issue now