From 6c4aa305e908e207c337ed393409b8e6b1ce338e Mon Sep 17 00:00:00 2001 From: Matthew Pharr Date: Mon, 16 Jun 2025 16:01:39 -0400 Subject: [PATCH 1/5] DOCS - MINOR - unified DIIID example coil inputs --- docs/examples/DIIID_ideal_example/coil.in | 28 ++++++++++++++----- docs/examples/DIIID_kinetic_example/coil.in | 2 ++ docs/examples/DIIID_resistive_example/coil.in | 2 ++ 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/docs/examples/DIIID_ideal_example/coil.in b/docs/examples/DIIID_ideal_example/coil.in index 5875bc84..946e00dc 100644 --- a/docs/examples/DIIID_ideal_example/coil.in +++ b/docs/examples/DIIID_ideal_example/coil.in @@ -5,7 +5,7 @@ machine="d3d" ! Choose from: nstx, d3d, kstar, iter ip_direction="positive" ! Set positive for CCW or negative for CW from a top down view bt_direction="negative" ! Set positive for CCW or negative for CW from a top down view - coil_num=1 ! Total number of coil sets activated + coil_num=3 ! Total number of coil sets activated cmpsi=64 ! ?? Why do we need this is only care about psi_lim?? cmtheta=480 ! Number of poloidal gridpoints (uses DCON jac_type??) @@ -23,12 +23,26 @@ ! bl2l(9), avvu(9), avvm(9), avvl(9) coil_name(1)="c" ! External correction coil set - coil_cur(1,1)= 1e3 ! 1kA, 19 degree phase n=1 field - coil_cur(1,2)= 5e2 - coil_cur(1,3)=-5e2 - coil_cur(1,4)=-1e3 - coil_cur(1,5)=-5e2 - coil_cur(1,6)= 5e2 + coil_cur(1,1)= 982 ! 1kA, 30 degree phase n=1 field + coil_cur(1,2)= 656 + coil_cur(1,3)=-326 + coil_cur(1,4)=-982 + coil_cur(1,5)=-656 + coil_cur(1,6)= 326 + coil_name(2)="il" ! External correction coil set + coil_cur(2,1)= 1e3 ! 1kA, 30 degree phase n=1 field + coil_cur(2,2)= 5e2 + coil_cur(2,3)=-5e2 + coil_cur(2,4)=-1e3 + coil_cur(2,5)=-5e2 + coil_cur(2,6)= 5e2 + coil_name(3)="iu" ! External correction coil set + coil_cur(3,1)= 1e3 ! 1kA, 30 degree phase n=1 field + coil_cur(3,2)= 5e2 + coil_cur(3,3)=-5e2 + coil_cur(3,4)=-1e3 + coil_cur(3,5)=-5e2 + coil_cur(3,6)= 5e2 / &COIL_OUTPUT diff --git a/docs/examples/DIIID_kinetic_example/coil.in b/docs/examples/DIIID_kinetic_example/coil.in index b3ae7abf..946e00dc 100644 --- a/docs/examples/DIIID_kinetic_example/coil.in +++ b/docs/examples/DIIID_kinetic_example/coil.in @@ -10,6 +10,8 @@ cmpsi=64 ! ?? Why do we need this is only care about psi_lim?? cmtheta=480 ! Number of poloidal gridpoints (uses DCON jac_type??) cmzeta=40 ! Number of toroidal gridpoints (uses DCON jac_type??) + coil_threads=0 ! Number of parallel threads used when computing fields from coils (no reason to go beyond 4 for coils with less than 1000 points). Setting to <= 0 uses OMP_NUM_THREADS env variable. + ! Array values should be specified for each of the coil arrays to be activated. ! The supported coil sets (number of coils) include... diff --git a/docs/examples/DIIID_resistive_example/coil.in b/docs/examples/DIIID_resistive_example/coil.in index b3ae7abf..946e00dc 100644 --- a/docs/examples/DIIID_resistive_example/coil.in +++ b/docs/examples/DIIID_resistive_example/coil.in @@ -10,6 +10,8 @@ cmpsi=64 ! ?? Why do we need this is only care about psi_lim?? cmtheta=480 ! Number of poloidal gridpoints (uses DCON jac_type??) cmzeta=40 ! Number of toroidal gridpoints (uses DCON jac_type??) + coil_threads=0 ! Number of parallel threads used when computing fields from coils (no reason to go beyond 4 for coils with less than 1000 points). Setting to <= 0 uses OMP_NUM_THREADS env variable. + ! Array values should be specified for each of the coil arrays to be activated. ! The supported coil sets (number of coils) include... From 1f290f2344b95b906591cf39b50ace79f5f87d54 Mon Sep 17 00:00:00 2001 From: Matthew Pharr Date: Mon, 16 Jun 2025 16:03:15 -0400 Subject: [PATCH 2/5] INSTALL - MINOR - Moved compiler-based flags like recursive, zero, and legacy to DEFAULTS.inc to clean up makefiles --- coil/makefile | 11 ----------- dcon/makefile | 12 +----------- equil/makefile | 11 +---------- gpec/makefile | 12 +----------- install/DEFAULTS.inc | 19 ++++++++++++++++++- install/makefile | 4 ++-- lsode/makefile | 10 +--------- match/makefile | 10 ---------- orbit/makefile | 11 ----------- pentrc/makefile | 15 --------------- rmatch/makefile | 10 ---------- stride/makefile | 14 -------------- vacuum/makefile | 11 ++--------- zlange/makefile | 13 ------------- zvode/makefile | 13 +------------ 15 files changed, 27 insertions(+), 149 deletions(-) diff --git a/coil/makefile b/coil/makefile index 0dc51c7d..2816829e 100644 --- a/coil/makefile +++ b/coil/makefile @@ -1,16 +1,5 @@ # This is the makefile for COIL -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive -else - RECURSFLAG=-frecursive -endif - include ../install/DEFAULTS.inc IFLAGS = -I../equil -I$(MATHINC) -I$(NETCDFINC) diff --git a/dcon/makefile b/dcon/makefile index e30706ef..b1744238 100644 --- a/dcon/makefile +++ b/dcon/makefile @@ -1,18 +1,8 @@ -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive -else - RECURSFLAG=-frecursive -endif include ../install/DEFAULTS.inc IFLAGS = -I../equil -I../harvest -I../pentrc -I../vacuum -I$(MATHINC) -I$(NETCDFINC) -F90 = $(FC) $(FFLAGS) $(OMPFLAG) $(IFLAGS) $(RECURSFLAG) +F90 = $(FC) $(FFLAGS) $(OMPFLAG) $(IFLAGS) $(RECURSFLAG) $(LEGACYFLAG) export FFLAGS # for sub-makes .f.o: diff --git a/equil/makefile b/equil/makefile index 859c4b53..802c4199 100644 --- a/equil/makefile +++ b/equil/makefile @@ -1,13 +1,4 @@ -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive -else - RECURSFLAG=-frecursive -endif +include ../install/DEFAULTS.inc F90 = $(FC) $(FFLAGS) $(RECURSFLAG) diff --git a/gpec/makefile b/gpec/makefile index 1dd80116..db554906 100644 --- a/gpec/makefile +++ b/gpec/makefile @@ -1,18 +1,8 @@ -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive -else - RECURSFLAG=-frecursive -endif include ../install/DEFAULTS.inc IFLAGS = -I../equil -I../vacuum -I../harvest -I../pentrc -I../coil -I../slayer -I$(MATHINC) -I$(NETCDFINC) -F90 = $(FC) $(FFLAGS) $(OMPFLAG) $(IFLAGS) $(RECURSFLAG) +F90 = $(FC) $(FFLAGS) $(OMPFLAG) $(IFLAGS) $(RECURSFLAG) $(LEGACYFLAG) export FFLAGS # for sub-makes .f.o: diff --git a/install/DEFAULTS.inc b/install/DEFAULTS.inc index 0c561400..fde1ea62 100644 --- a/install/DEFAULTS.inc +++ b/install/DEFAULTS.inc @@ -466,10 +466,27 @@ endif #Common compiler flags for OpenMP ifeq ($(findstring ifort,$(FC)),ifort) OMPFLAG ?= -qopenmp + ZEROFLAG ?= -zero + RECURSFLAG ?= -recursive + LEGACYFLAG ?= +else ifeq ($(findstring ifort,$(FC)),ifx) + OMPFLAG ?= -qopenmp + ZEROFLAG ?= -zero + RECURSFLAG ?= -recursive + LEGACYFLAG ?= else ifeq ($(findstring gfortran,$(FC)),gfortran) OMPFLAG ?= -fopenmp + ZEROFLAG ?= -finit-local-zero + RECURSFLAG ?= -frecursive + LEGACYFLAG ?= -std=legacy else ifeq ($(findstring pgfortran,$(FC)),pgfortran) OMPFLAG ?= -mp + ZEROFLAG ?= -zeroinit + RECURSFLAG ?= -Mrecursive + LEGACYFLAG ?= -std=legacy else + ZEROFLAG ?= -zero OMPFLAG ?= -openmp -endif + RECURSFLAG ?= -recursive + LEGACYFLAG ?= -std=legacy +endif \ No newline at end of file diff --git a/install/makefile b/install/makefile index 4d180f66..3048ff7d 100644 --- a/install/makefile +++ b/install/makefile @@ -14,11 +14,11 @@ export LDFLAGS .IGNORE: -all: v harvest equil lsode zlange zvode orbit vacuum pentrc dcon match rdcon rmatch \ +all: v harvest equil lsode zlange zvode orbit vacuum pentrc dcon match rdcon rmatch \ multi sum xdraw slayer coil gpec stride mkbin # fortran only -allf: v harvest equil lsode zlange zvode orbit vacuum pentrc dcon match rdcon rmatch \ +allf: v harvest equil lsode zlange zvode orbit vacuum pentrc dcon match rdcon rmatch \ multi sum slayer coil gpec stride mkbin diff --git a/lsode/makefile b/lsode/makefile index 0f647a36..15795159 100644 --- a/lsode/makefile +++ b/lsode/makefile @@ -1,15 +1,7 @@ -ifneq (,$(findstring ifort,$(FC))) - EXTRAFLAGS=-recursive -else ifneq (,$(findstring ifx,$(FC))) - EXTRAFLAGS=-recursive -else - EXTRAFLAGS=-frecursive -std=legacy -endif - include ../install/DEFAULTS.inc -F90 = $(FC) $(FFLAGS) $(EXTRAFLAGS) $(OMPFLAG) -I../equil +F90 = $(FC) $(FFLAGS) $(RECURSFLAG) $(LEGACYFLAG) $(OMPFLAG) -I../equil LIBDIR = ../lib LIBS = \ diff --git a/match/makefile b/match/makefile index 3aac76bf..ccca698e 100644 --- a/match/makefile +++ b/match/makefile @@ -1,13 +1,3 @@ -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive -else - RECURSFLAG=-frecursive -endif include ../install/DEFAULTS.inc diff --git a/orbit/makefile b/orbit/makefile index 8f134663..b61d42f2 100644 --- a/orbit/makefile +++ b/orbit/makefile @@ -1,17 +1,6 @@ include ../install/DEFAULTS.inc -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive -else - RECURSFLAG=-frecursive -endif - IFLAGS = -I../equil -I$(MATHINC) F90 = $(FC) $(FFLAGS) $(OMPFLAG) $(IFLAGS) $(RECURSFLAG) export FFLAGS diff --git a/pentrc/makefile b/pentrc/makefile index 09450e01..93756e6b 100644 --- a/pentrc/makefile +++ b/pentrc/makefile @@ -1,18 +1,3 @@ -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive - LEGACYFLAG= -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive - LEGACYFLAG= -else - RECURSFLAG=-frecursive - LEGACYFLAG=-std=legacy -endif - - include ../install/DEFAULTS.inc diff --git a/rmatch/makefile b/rmatch/makefile index 66371e90..59fb9616 100755 --- a/rmatch/makefile +++ b/rmatch/makefile @@ -1,13 +1,3 @@ -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive - LEGACYFLAG= -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive - LEGACYFLAG= -else - RECURSFLAG=-frecursive - LEGACYFLAG=-std=legacy -endif include ../install/DEFAULTS.inc diff --git a/stride/makefile b/stride/makefile index 3c0a9e68..e96e8e0f 100755 --- a/stride/makefile +++ b/stride/makefile @@ -1,19 +1,5 @@ # This is the makefile for STRIDE. -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive - LEGACYFLAG= -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive - LEGACYFLAG= -else - RECURSFLAG=-frecursive - LEGACYFLAG=-std=legacy -endif - include ../install/DEFAULTS.inc # flags unique to stride (not to be clobbered by top level install/makefile options) diff --git a/vacuum/makefile b/vacuum/makefile index 0dbfc72d..d12179a5 100644 --- a/vacuum/makefile +++ b/vacuum/makefile @@ -1,15 +1,8 @@ # This is the makefile for VACUUM. -# If using gfortran, the proper syntax is -finit-local-zero. -# If using ifort, the proper syntax is -zero. +include ../install/DEFAULTS.inc -ifneq (,$(findstring ifort,$(FC))) - ZEROFLAG=-zero -else - ZEROFLAG=-finit-local-zero -endif - -F90 = $(FC) $(FFLAGS) $(ZEROFLAG) -I../equil +F90 = $(FC) $(FFLAGS) $(ZEROFLAG) $(RECURSFLAG) $(LEGACYFLAG) -I../equil .f.o: $(F90) -c $*.f diff --git a/zlange/makefile b/zlange/makefile index 74045a7e..a49e0546 100755 --- a/zlange/makefile +++ b/zlange/makefile @@ -1,17 +1,4 @@ # This is the makefile for ZLANGE. -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - RECURSFLAG=-recursive - LEGACYFLAG= -else ifneq (,$(findstring ifx,$(FC))) - RECURSFLAG=-recursive - LEGACYFLAG= -else - RECURSFLAG=-frecursive - LEGACYFLAG=-std=legacy -endif include ../install/DEFAULTS.inc diff --git a/zvode/makefile b/zvode/makefile index 1dd395c4..bdcb6390 100755 --- a/zvode/makefile +++ b/zvode/makefile @@ -1,19 +1,8 @@ # This is the makefile for ZVODE. -# If using gfortran, the proper syntax is -frecursive. -# If using ifort, the proper syntax is -recursive. - -ifneq (,$(findstring ifort,$(FC))) - EXTRAFLAGS=-recursive -else ifneq (,$(findstring ifx,$(FC))) - EXTRAFLAGS=-recursive -else - EXTRAFLAGS=-frecursive -std=legacy -endif - include ../install/DEFAULTS.inc -F90 = $(FC) $(FFLAGS) $(EXTRAFLAGS) -I../equil +F90 = $(FC) $(FFLAGS) $(RECURSFLAG) $(LEGACYFLAG) -I../equil .f.o: $(F90) -c $*.f From 84a0b38f7d767c2a3607fa74478eb2feb995b280 Mon Sep 17 00:00:00 2001 From: Matthew Pharr Date: Mon, 16 Jun 2025 16:04:48 -0400 Subject: [PATCH 3/5] ALL - MINOR - Replaced straggling instances of REAL*8 -> REAL(r8) --- coil/field.F | 4 ++-- dcon/fourfit.F | 8 +++++--- rmatch/deltac.f | 4 ++-- stride/free.f | 4 ++-- stride/ode.F | 26 +++++++++++++------------- stride/sing.F | 4 ++-- stride/stride.F | 22 +++++++++++++--------- vacuum/vacuum_io.f | 2 +- vacuum/vacuum_vac.f | 6 +++--- 9 files changed, 43 insertions(+), 37 deletions(-) diff --git a/coil/field.F b/coil/field.F index e3b5bb99..5bb333bf 100644 --- a/coil/field.F +++ b/coil/field.F @@ -383,7 +383,7 @@ SUBROUTINE field_bs_rzphi(nr,nz,np,gdr,gdz,cbr,cbz,cbp,op_verbose) DO iz=0,nz DO ip=0,np - phi=ip/REAL(np,8) + phi=ip/REAL(np,r8) xobs(ir,iz,ip)=gdr(ir,iz)*COS(twopi*phi) yobs(ir,iz,ip)=gdr(ir,iz)*SIN(twopi*phi) zobs(ir,iz,ip)=gdz(ir,iz) @@ -433,7 +433,7 @@ SUBROUTINE field_bs_rzphi(nr,nz,np,gdr,gdz,cbr,cbz,cbp,op_verbose) DO iz=0,nz CALL cspline_alloc(bspl,np,3) DO ip=0,np - phi=ip/REAL(np,8) + phi=ip/REAL(np,r8) bspl%xs(ip)=phi bspl%fs(ip,1)=br(ir,iz,ip)*EXP(twopi*ifac*cnn*phi) bspl%fs(ip,2)=bz(ir,iz,ip)*EXP(twopi*ifac*cnn*phi) diff --git a/dcon/fourfit.F b/dcon/fourfit.F index 9c261257..eed29648 100644 --- a/dcon/fourfit.F +++ b/dcon/fourfit.F @@ -968,6 +968,8 @@ SUBROUTINE fourfit_kinetic_matrix(methodin,writein) ENDIF ALLOCATE(kwmatls(mpert,mpert,6,0:mpsi,-nl:nl), $ ktmatls(mpert,mpert,6,0:mpsi,-nl:nl)) + kwmatls=0 + ktmatls=0 c----------------------------------------------------------------------- c Original approach using eqgrid loop to calculate kinetic matrices c----------------------------------------------------------------------- @@ -1089,7 +1091,7 @@ SUBROUTINE fourfit_kinetic_matrix(methodin,writein) !$OMP END CRITICAL IF(debug_omp)THEN CALL SYSTEM_CLOCK(COUNT=t_end) - t_sec = REAL(t_end-t_start,8)/REAL(cr,8) + t_sec = REAL(t_end-t_start,r8)/REAL(cr,r8) WRITE(*,'(1x,a5,i3,a6,es16.8,a8)') $ "ipsi=",ipsi," took ",t_sec," seconds" ENDIF @@ -1301,8 +1303,8 @@ SUBROUTINE fourfit_kinetic_matrix(methodin,writein) ktmats(i)%xs=rzphi%xs ENDDO DO ipsi=0,mpsi - iindex = FLOOR(REAL(ipsi+1,8)/FLOOR((mpsi+1)/10.0))*10 - ileft = REAL(ipsi+1,8)/FLOOR((mpsi+1)/10.0)*10-iindex + iindex = FLOOR(REAL(ipsi+1,r8)/FLOOR((mpsi+1)/10.0))*10 + ileft = REAL(ipsi+1,r8)/FLOOR((mpsi+1)/10.0)*10-iindex IF ((ipsi /= 0) .AND. (ileft == 0) .AND. verbose) $ WRITE(*,*)" ...",iindex,"% of kinetic computations" kwmat = 0 diff --git a/rmatch/deltac.f b/rmatch/deltac.f index 287fc69d..33659513 100644 --- a/rmatch/deltac.f +++ b/rmatch/deltac.f @@ -1492,10 +1492,10 @@ SUBROUTINE deltac_lsode_int(u_res,u_h1,u_h2) CALL deltac_lsode_der(neq,x0,u,u) u=u*deltac_tol DO ip=1,neq/2 -c tmp=MAX( DABS(REAL(u(ip),8)),DABS(IMAG(u(ip),8)) ) +c tmp=MAX( DABS(REAL(u(ip),r8)),DABS(IMAG(u(ip),r8)) ) tmp=CDABS(u(ip)) IF (tmp