Jason's Blog

December 13, 2024Last Updated: December 15, 2024

Conceptual Learning - Weno

Learning3.0 min to read

Conceptual Learning

Fortran

Fortran(全称 Formula Translation,意为公式翻译)是一种用于数值计算和科学计算的编程语言。它于 1957 年首次发布,是世界上第一种广泛使用的高级编程语言。

主要特点:

Fortran 广泛应用于需要高性能计算的领域,例如:

ifort

ifort 是 Intel Fortran 编译器,用于编译和链接标准 Fortran 程序。它是 Intel 编译器套件(Intel oneAPI 或 Intel Parallel Studio)中的一部分。适用于没有并行通信需求的 Fortran 应用程序。

功能和特点:

mpifort

mpifort 是 MPI(Message Passing Interface)环境中用于 Fortran 程序的编译器包装器。它可以调用系统中默认的 Fortran 编译器(可能是 GNU Fortran,也可能是 Intel Fortran,如 ifort),并添加必要的 MPI 库和头文件。

功能和特点:

##mpiifort mpiifort 是 Intel MPI 库与 Intel Fortran 编译器(ifort)的结合版本,类似于 mpifort,但明确使用 Intel 的 Fortran 编译器和 MPI 实现。

功能和特点:

名称功能用途特点
ifortIntel Fortran 编译器编译标准 Fortran 程序高性能优化,适用于单机应用
mpifort通用 MPI 编译器包装器编译支持 MPI 的 Fortran 程序调用系统默认 Fortran 编译器
mpiifortIntel Fortran + Intel MPI编译支持 MPI 的高性能 Fortran 程序专用于 Intel 环境的 MPI 应用

代码解读

##### User configurable options #####
#Makefile used for Trip2.0 serial program

#set main program name for calculation(not include extended name):
MAIN_NAME = weno3d

#for set variable:
SHELL     = /bin/sh

#for library and module path:
INCDIR  = /home/XiYang/MAML_KiloNet/source/data/weno3dnew/include

LIBDIR  = /home/XiYang/MAML_KiloNet/source/data/weno3dnew/lib
LIBNAME = xbfuc

F90 = mpiifort
F77 = mpiifort
CC  = mpicc

#F90 = ifort
#F77 = ifort
#CC  = icc

CFLAG   =
#FFLAG   = -static -r8 -I $(INCDIR)

# FFLAG:Fortran 编译器的选项,-r8 表示将所有实数变量提升为双精度(real(8)),-I $(INCDIR) 指定头文件目录。
FFLAG   = -r8 -I $(INCDIR)
LDFLAGS =
#LKFLAGS = -static -L $(LIBDIR)

# LKFLAGS:指定链接库路径,-L $(LIBDIR) 表示链接库位于 LIBDIR 路径下。
LKFLAGS = -L $(LIBDIR)

#for Calculational program:
EXEC   =  main
OBJS   =  weno3d_mod.o weno3d_boundary.o weno3d_memory.o   \
          weno3d_sdrv.o $(MAIN_NAME).o

.SUFFIXES : .o .c .f .for .f90

### End User configurable options ###

all: $(EXEC)

#default: all

clean:
        -rm -f *.o $(EXEC) *.mod

$(EXEC): $(OBJS)
         $(F90) $(LKFLAGS) -o $@ $(OBJS) $(LDFLAGS) -l$(LIBNAME)

.c.o:
        $(CC)   $(CFLAG) -c $<

.f.o:
        $(F90)   $(FFLAG) -c $<

.for.o:
        $(F90)   $(FFLAG) -c $<

.f90.o:
        $(F90)   $(FFLAG) -c $<

目标 $(EXEC):

.nml

(base) [XiYang@localhost src]$ cat wctrol.nml
&ctrol
  md = 3
  mn = 5
  mt = 3

  nxNo = 80
  nyNo = 80
  nzNo = 80

  XBLKNO = 1
  YBLKNO = 1
  ZBLKNO = 1

  irest  = 0
  tend   = 2.0
  cfl    = 0.5
  ntot   = 20000
  cpumax = 1000000.
  itype  = 1
  rkap   = 7.
/

run_tvc_vorts.sh