Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Commit

Permalink
No point developing completely from scratch - this is the work on mix…
Browse files Browse the repository at this point in the history
…ing layer
  • Loading branch information
pbartholomew08 committed Oct 5, 2017
1 parent 7c4a3e5 commit 971c3ad
Show file tree
Hide file tree
Showing 34 changed files with 18,991 additions and 137 deletions.
2,904 changes: 2,904 additions & 0 deletions FreeIPC.f90

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions FreeIPC_create.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
! FreeIPC - A library to allow Fortran programs that use MPI
! to easily access shared memory within multicore nodes
! Date - 23rd Oct Version 0.0
! Copyright(C) 2009 Ian Bush
!
! This library is free software; you can redistribute it and/or
! modify it under the terms of the GNU Lesser General Public
! License as published by the Free Software Foundation; either
! version 3.0 of the License, or (at your option) any later version.
!
! This library is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! Lesser General Public License for more details.
!
! You should have received a copy of the GNU Lesser General Public
! License along with this library; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
!
!
! This library is released under LGPL. The full text of LGPL may be found
! at http://www.gnu.org/licenses/lgpl-3.0.txt
!
! In particular, the terms of the GNU LGPL imply that you CAN use this library with
! proprietary code with some restrictions (you can link, but not use the code directly).
! Please consult the above URL for exact details.

Type( c_ptr ) :: shmaddr

! Check things are initialized
If( .Not. Associated( FIPC_ctxt_world%initialized ) ) Then
error = FIPC_not_initialized
Return
End If

If( Size( n ) < rank ) Then
error = FIPC_insufficient_dims
End If

Call segment_create( type, rank, Int( n( 1:rank ), c_long ), ctxt, shmaddr, error )
If( error /= 0 ) Then
Return
End If

Call c_f_pointer( shmaddr, a, Int( n( 1:rank ), c_long ) )

error = FIPC_success

82 changes: 82 additions & 0 deletions FreeIPC_free.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
! FreeIPC - A library to allow Fortran programs that use MPI
! to easily access shared memory within multicore nodes
! Date - 23rd Oct Version 0.0
! Copyright(C) 2009 Ian Bush
!
! This library is free software; you can redistribute it and/or
! modify it under the terms of the GNU Lesser General Public
! License as published by the Free Software Foundation; either
! version 3.0 of the License, or (at your option) any later version.
!
! This library is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
! Lesser General Public License for more details.
!
! You should have received a copy of the GNU Lesser General Public
! License along with this library; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
!
!
! This library is released under LGPL. The full text of LGPL may be found
! at http://www.gnu.org/licenses/lgpl-3.0.txt
!
! In particular, the terms of the GNU LGPL imply that you CAN use this library with
! proprietary code with some restrictions (you can link, but not use the code directly).
! Please consult the above URL for exact details.

Type( FIPC_ctxt ) :: ctxt

Type( segment_list_type ), Pointer :: p

! Check things are initialized
If( .Not. Associated( FIPC_ctxt_world%initialized ) ) Then
error = FIPC_not_initialized
Return
End If

If( .Not. Associated( a ) ) Then
error = FIPC_free_null_pointer
Return
End If

! First find the segment
! Be careful to only look at segments that could possible be associated
! with this pointer
p => seg_list
Do While( Associated( p ) )
If( p%data%type == type ) Then
If( Size( p%data%sizes ) == Size( Shape( a ) ) ) Then
If( All( p%data%sizes == Shape( a ) ) ) Then
Call c_f_pointer( p%data%shmaddr, fp, p%data%sizes )
If( Associated( a, fp ) ) Then
Exit
End If
End If
End If
End If
p => p%next
End Do

If( .Not. Associated( p ) ) Then
error = FIPC_seg_not_found
Return
End If

If( debug ) Then
ctxt = p%data%ctxt
End If

Call segment_free( p%data%shmid, error )
If( error /= FIPC_success ) Then
Return
End If

a => Null()

If( debug ) Then
Call print_seg_list( ctxt )
End If

error = FIPC_success

67 changes: 10 additions & 57 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=======================================================================
# Makefile for Imcompact3D-LMN
# Makefile for Imcompact3D
#=======================================================================

# Choose pre-processing options
Expand Down Expand Up @@ -42,9 +42,9 @@ FFTW3_LIB = -L$(FFTW3_PATH)/lib -lfftw3 -lfftw3f
# GNU
FC = mpif90
OPTFC = -O3 -funroll-loops -ftree-vectorize -fcray-pointer -cpp
#OPTFC = -g3 -fcray-pointer -cpp
CC = mpicc
CFLAGS = -O3
#OPTIONS += -Wall -Werror

# Cray
#FC = ftn
Expand All @@ -70,7 +70,7 @@ else ifeq ($(FFT),fftw3)
endif

# List of source files
SRC = decomp_2d.f90 incompact3dlmn.f90
SRC = decomp_2d.f90 glassman.f90 fft_$(FFT).f90 module_param.f90 io.f90 variables.f90 poisson.f90 schemes.f90 convdiff.f90 incompact3d.f90 navier.f90 filter.f90 derive.f90 parameters.f90 tools.f90 visu.f90 test_min_max.f90

#-----------------------------------------------------------------------
# Normally no need to change anything below
Expand All @@ -91,62 +91,15 @@ FreeIPC_c.o: FreeIPC_c.c
$(CC) $(CFLAGS) -c $<

incompact3d : $(OBJ)
$(FC) $(OPTIONS) -o $@ $(OBJ) $(LIBFFT)
$(FC) -O3 -o $@ $(OBJ) $(LIBFFT)

%.o : %.f90
$(FC) $(OPTFC) $(OPTIONS) $(INC) -c $<

run:
./incompact3dlmn
.PHONY: clean
clean:
rm -f *.o *.mod incompact3d

# #-----------------------------------------------------------------------
# # Normally no need to change anything below

# # include PATH
# ifeq ($(FFT),generic)
# INC=
# else ifeq ($(FFT),fftw3)
# INC=$(FFTW3_INCLUDE)
# endif

# # library path
# ifeq ($(FFT),generic)
# LIBFFT=
# else ifeq ($(FFT),fftw3)
# LIBFFT=$(FFTW3_LIB)
# endif

# # List of source files
# SRC = decomp_2d.f90 glassman.f90 fft_$(FFT).f90 module_param.f90 io.f90 variables.f90 poisson.f90 schemes.f90 convdiff.f90 incompact3d.f90 navier.f90 filter.f90 derive.f90 parameters.f90 tools.f90 visu.f90 test_min_max.f90

# #-----------------------------------------------------------------------
# # Normally no need to change anything below

# ifneq (,$(findstring DSHM,$(OPTIONS)))
# SRC := FreeIPC.f90 $(SRC)
# OBJ = $(SRC:.f90=.o) alloc_shm.o FreeIPC_c.o
# else
# OBJ = $(SRC:.f90=.o)
# endif

# all: incompact3d

# alloc_shm.o: alloc_shm.c
# $(CC) $(CFLAGS) -c $<

# FreeIPC_c.o: FreeIPC_c.c
# $(CC) $(CFLAGS) -c $<

# incompact3d : $(OBJ)
# $(FC) -O3 -o $@ $(OBJ) $(LIBFFT)

# %.o : %.f90
# $(FC) $(OPTFC) $(OPTIONS) $(INC) -c $<

# .PHONY: clean
# clean:
# rm -f *.o *.mod incompact3d

# .PHONY: realclean
# realclean: clean
# rm -f *~ \#*\#
.PHONY: realclean
realclean: clean
rm -f *~ \#*\#
Loading

0 comments on commit 971c3ad

Please sign in to comment.