From d81d71a40253a60a496b0bba8f66902cd28f5576 Mon Sep 17 00:00:00 2001 From: Luis Manuel Diaz Angulo Date: Thu, 17 Sep 2026 12:05:26 +0200 Subject: [PATCH 1/6] Enhance OpenMP support and update MPI synchronization in solver modules; modify test to include multiple layer configurations. --- external/ngspice | 2 +- src_main_pub/timestepping.F90 | 33 +++++++++++++------------- src_mtln/mtln_solver.F90 | 8 ------- test/pyWrapper/test_full_system_mpi.py | 2 +- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/external/ngspice b/external/ngspice index 730b251e..909c2731 160000 --- a/external/ngspice +++ b/external/ngspice @@ -1 +1 @@ -Subproject commit 730b251ee1975198d680b55c972b271dcd3525cd +Subproject commit 909c2731f3bb67742bdeeeb0c6e7d296ac76fd8b diff --git a/src_main_pub/timestepping.F90 b/src_main_pub/timestepping.F90 index c383be5f..eb1d16d2 100755 --- a/src_main_pub/timestepping.F90 +++ b/src_main_pub/timestepping.F90 @@ -31,6 +31,7 @@ module Solver_m use interpreta_switches_m, only: entrada_t #ifdef CompileWithMPI use MPIcomm_m + use omp_lib, only: omp_set_num_threads #endif #ifdef CompileWithStochastic use MPI_stochastic @@ -271,9 +272,20 @@ subroutine solver_init_control(this, input, maxSourceValue, time_desdelanzamient call this%thereAre%reset() - end subroutine - - + end subroutine + +#ifdef CompileWithMPI + subroutine configure_default_openmp_threads(num_procs) + integer(kind=4), intent(in) :: num_procs + character(len=128) :: omp_num_threads + + if (num_procs <= 1) return + omp_num_threads = "" + call get_environment_variable("OMP_NUM_THREADS", omp_num_threads) + if (len_trim(omp_num_threads) == 0) call omp_set_num_threads(1) + end subroutine configure_default_openmp_threads +#endif + #ifdef CompileWithMTLN subroutine launch_mtln_simulation(this, mtln_parsed, nEntradaRoot, layoutnumber) class(solver_t) :: this @@ -1484,6 +1496,7 @@ end subroutine initializeObservation subroutine initializeMPI() character(len=bufsize) :: dubuf integer(kind=4) :: ierr + call configure_default_openmp_threads(this%control%num_procs) if (this%control%num_procs>1) then call MPI_Barrier(SUBCOMM_MPI,ierr) write(dubuf,*) 'Init MPI MediaMatrix flush...'; call print11(this%control%layoutnumber,dubuf) @@ -1794,8 +1807,6 @@ subroutine solver_run(this) Ex,Ey,Ez,this%everflushed,this%control%nentradaroot,this%control%maxSourceValue,this%control%opcionestotales,this%control%simu_devia,this%control%dontwritevtk,this%control%permitscaling) if (.not.this%parar) then !!! si es por parada se gestiona al final - call request_flush_if_any_observation_is_done() - if (this%perform%flushFIELDS) then call performFlushField() end if @@ -1859,18 +1870,6 @@ subroutine solver_run(this) contains - subroutine request_flush_if_any_observation_is_done() - do i=1,this%sgg%NumberRequest - if (this%sgg%Observation(i)%done.and.(.not.this%sgg%Observation(i)%flushed)) then - this%perform%flushXdmf=.true. - this%perform%flushVTK=.true. - end if - end do -#ifdef CompileWithMPI - call syncroniceFlushFlags(this%perform, ierr) -#endif - end subroutine - #ifdef CompileWithMPI subroutine syncroniceFlushFlags(performFlags, integerError) type(perform_t), intent(inout) :: performFlags diff --git a/src_mtln/mtln_solver.F90 b/src_mtln/mtln_solver.F90 index 0b5526c8..8be5137c 100644 --- a/src_mtln/mtln_solver.F90 +++ b/src_mtln/mtln_solver.F90 @@ -168,10 +168,6 @@ subroutine step_alone(this) subroutine setExternalLongitudinalField(this) class(mtln_t) :: this integer :: i -#ifdef CompileWithMPI - integer :: ierr - call MPI_Barrier(SUBCOMM_MPI,ierr) -#endif do i = 1, this%number_of_bundles if (this%bundles(i)%bundle_in_layer) call this%bundles(i)%setExternalLongitudinalField() end do @@ -230,10 +226,6 @@ subroutine updateOpenNodes(this) subroutine advanceBundlesCurrent(this) class(mtln_t) :: this integer :: i -#ifdef CompileWithMPI - integer :: ierr - call mpi_barrier(subcomm_mpi, ierr) -#endif do i = 1, this%number_of_bundles if (this%bundles(i)%bundle_in_layer) then call this%bundles(i)%advanceCurrent() diff --git a/test/pyWrapper/test_full_system_mpi.py b/test/pyWrapper/test_full_system_mpi.py index 382522a4..d8d5c273 100644 --- a/test/pyWrapper/test_full_system_mpi.py +++ b/test/pyWrapper/test_full_system_mpi.py @@ -167,7 +167,7 @@ def test_towelHanger_mpi(tmp_path): fn = CASES_FOLDER + "towelHanger/towelHanger_mpi.fdtd.json" setNgspice(tmp_path) print(SEMBA_EXE) - for layers in range(1,3): + for layers in [1, 2, 4]: for direction_index, direction in enumerate(["x", "y", "z"]): solver = FDTD( input_filename=fn, From 82593b991ac538a05a68dcb5ec734e0cbea0ec22 Mon Sep 17 00:00:00 2001 From: Luis Manuel Diaz Angulo Date: Fri, 18 Sep 2026 12:30:08 +0200 Subject: [PATCH 2/6] Refactor MPI test for towelHanger: reduce layer configurations from 4 to 2 --- src_main_pub/timestepping.F90 | 270 +++++++++++++------------ test/pyWrapper/test_full_system_mpi.py | 2 +- 2 files changed, 139 insertions(+), 133 deletions(-) diff --git a/src_main_pub/timestepping.F90 b/src_main_pub/timestepping.F90 index eb1d16d2..b8196771 100755 --- a/src_main_pub/timestepping.F90 +++ b/src_main_pub/timestepping.F90 @@ -29,11 +29,13 @@ module Solver_m use Lumped_m use PMLbodies_m use interpreta_switches_m, only: entrada_t -#ifdef CompileWithMPI - use MPIcomm_m - use omp_lib, only: omp_set_num_threads -#endif -#ifdef CompileWithStochastic +#ifdef CompileWithMPI + use MPIcomm_m +#ifdef CompileWithOpenMP + use omp_lib, only: omp_set_num_threads +#endif +#endif +#ifdef CompileWithStochastic use MPI_stochastic #endif #ifdef CompileWithNIBC @@ -98,12 +100,12 @@ module Solver_m type(bounds_t) :: bounds type(EpsMuTimeScale_input_parameters_t) :: EpsMuTimeScale_input_parameters - logical :: parar, everflushed = .false., still_planewave_time -#ifdef CompileWithMTLN - logical :: mtlnObservationInitialized = .false. -#endif - - ! semba variables + logical :: parar, everflushed = .false., still_planewave_time +#ifdef CompileWithMTLN + logical :: mtlnObservationInitialized = .false. +#endif + + ! semba variables type(SGGFDTDINFO_t) :: sgg type(media_matrices_t) :: media type(taglist_t) :: tag_numbers @@ -272,30 +274,34 @@ subroutine solver_init_control(this, input, maxSourceValue, time_desdelanzamient call this%thereAre%reset() - end subroutine - -#ifdef CompileWithMPI - subroutine configure_default_openmp_threads(num_procs) - integer(kind=4), intent(in) :: num_procs - character(len=128) :: omp_num_threads - - if (num_procs <= 1) return - omp_num_threads = "" - call get_environment_variable("OMP_NUM_THREADS", omp_num_threads) - if (len_trim(omp_num_threads) == 0) call omp_set_num_threads(1) - end subroutine configure_default_openmp_threads -#endif - + end subroutine + +#ifdef CompileWithMPI + subroutine configure_default_openmp_threads(num_procs) + integer(kind=4), intent(in) :: num_procs +#ifdef CompileWithOpenMP + character(len=128) :: omp_num_threads +#endif + + if (num_procs <= 1) return +#ifdef CompileWithOpenMP + omp_num_threads = "" + call get_environment_variable("OMP_NUM_THREADS", omp_num_threads) + if (len_trim(omp_num_threads) == 0) call omp_set_num_threads(1) +#endif + end subroutine configure_default_openmp_threads +#endif + #ifdef CompileWithMTLN subroutine launch_mtln_simulation(this, mtln_parsed, nEntradaRoot, layoutnumber) class(solver_t) :: this type(mtln_t) :: mtln_parsed character(len=*), intent(in) :: nEntradaRoot - integer(kind=4), intent(in) :: layoutnumber - - call initializeMTLNProblem(mtln_parsed, nEntradaRoot) - call runMTLNProblem() - call reportSimulationEnd(layoutnumber) + integer(kind=4), intent(in) :: layoutnumber + + call initializeMTLNProblem(mtln_parsed, nEntradaRoot) + call runMTLNProblem() + call reportSimulationEnd(layoutnumber) end subroutine #endif @@ -588,16 +594,16 @@ subroutine solver_init(this) call MPI_Barrier(SUBCOMM_MPI,ierr) #endif - call initializeBorders() - call initializeLumped() - call initializeWires() -#ifdef CompileWithMTLN - if (this%thereAre%MTLNbundles) then - call InitMTLNObservation(this%control%nEntradaRoot) - this%mtlnObservationInitialized = .true. - end if -#endif - call initializeAnisotropic() + call initializeBorders() + call initializeLumped() + call initializeWires() +#ifdef CompileWithMTLN + if (this%thereAre%MTLNbundles) then + call InitMTLNObservation(this%control%nEntradaRoot) + this%mtlnObservationInitialized = .true. + end if +#endif + call initializeAnisotropic() call initializeSGBC() call initializeMultiports() @@ -1151,19 +1157,19 @@ subroutine initializeWires() logical :: l_auxinput, l_auxoutput #ifdef CompileWithMPI integer(kind=4) :: ierr -#endif - dtcritico=this%sgg%dt -#ifdef CompileWithMTLN -#ifdef CompileWithMPI - call MPI_Barrier(SUBCOMM_MPI,ierr) -#endif - write(dubuf,*) 'Init MTLN Wires...'; call print11(this%control%layoutnumber,dubuf) - call InitWires_mtln(this%sgg,Ex,Ey,Ez,& - this%media%sggMiEx,this%media%sggMiEy,this%media%sggMiEz,& - this%media%sggMiHx,this%media%sggMiHy,this%media%sggMiHz,& - this%eps0, this%mu0, this%mtln_parsed,this%thereAre%MTLNbundles, dtcritico) -#else - if ((trim(adjustl(this%control%wiresflavor))=='holland') .or. & +#endif + dtcritico=this%sgg%dt +#ifdef CompileWithMTLN +#ifdef CompileWithMPI + call MPI_Barrier(SUBCOMM_MPI,ierr) +#endif + write(dubuf,*) 'Init MTLN Wires...'; call print11(this%control%layoutnumber,dubuf) + call InitWires_mtln(this%sgg,Ex,Ey,Ez,& + this%media%sggMiEx,this%media%sggMiEy,this%media%sggMiEz,& + this%media%sggMiHx,this%media%sggMiHy,this%media%sggMiHz,& + this%eps0, this%mu0, this%mtln_parsed,this%thereAre%MTLNbundles, dtcritico) +#else + if ((trim(adjustl(this%control%wiresflavor))=='holland') .or. & (trim(adjustl(this%control%wiresflavor))=='transition')) then #ifdef CompileWithMPI call MPI_Barrier(SUBCOMM_MPI,ierr) @@ -1180,10 +1186,10 @@ subroutine initializeWires() #endif if (l_auxoutput ) then write (dubuf,*) '----> there are Holland/transition wires'; call print11(this%control%layoutnumber,dubuf) - else - write(dubuf,*) '----> no Holland/transition wires found'; call print11(this%control%layoutnumber,dubuf) - end if - end if + else + write(dubuf,*) '----> no Holland/transition wires found'; call print11(this%control%layoutnumber,dubuf) + end if + end if #ifdef CompileWithBerengerWires if (trim(adjustl(this%control%wiresflavor))=='berenger') then @@ -1233,27 +1239,27 @@ subroutine initializeWires() this%control%mindistwires, this%control%groundwires,this%control%noSlantedcrecepelo , & this%control%inductance_model, this%control%inductance_order, & this%g%g2, this%sinPML_fullsize, dtcritico,this%eps0,this%mu0,this%control%verbose) - l_auxinput=this%thereAre%Wires - l_auxoutput=l_auxinput - !check for MUR1 nodes sgg 230124 - call init_murABC_slanted(this%sgg,this%sinPML_fullsize,this%eps0,this%mu0) - !!!!!! -#ifdef CompileWithMPI - call MPI_Barrier(SUBCOMM_MPI,ierr) - call MPI_AllReduce( l_auxinput, l_auxoutput, 1_4, MPI_LOGICAL, MPI_LOR, MPI_COMM_WORLD, ierr) -#endif + l_auxinput=this%thereAre%Wires + l_auxoutput=l_auxinput + !check for MUR1 nodes sgg 230124 + call init_murABC_slanted(this%sgg,this%sinPML_fullsize,this%eps0,this%mu0) + !!!!!! +#ifdef CompileWithMPI + call MPI_Barrier(SUBCOMM_MPI,ierr) + call MPI_AllReduce( l_auxinput, l_auxoutput, 1_4, MPI_LOGICAL, MPI_LOR, MPI_COMM_WORLD, ierr) +#endif if (l_auxoutput ) then write (dubuf,*) '----> there are Slanted wires'; call print11(this%control%layoutnumber,dubuf) else write(dubuf,*) '----> no Slanted wires found'; call print11(this%control%layoutnumber,dubuf) - end if - end if -#endif -#endif -#ifdef CompileWithMPI - !!!sincroniza el dtcritico - newdtcritico = 0.0_RKIND_tiempo + end if + end if +#endif +#endif +#ifdef CompileWithMPI + !!!sincroniza el dtcritico + newdtcritico = 0.0_RKIND_tiempo call MPI_AllReduce( dtcritico, newdtcritico, 1_4, REALSIZE_tiempo, MPI_MIN, SUBCOMM_MPI, ierr) dtcritico=newdtcritico #endif @@ -1473,12 +1479,12 @@ subroutine initializeObservation() #ifdef CompileWithMPI call MPI_Barrier(SUBCOMM_MPI,ierr) -#endif - write(dubuf,*) 'Init Observation...'; call print11(this%control%layoutnumber,dubuf) - call init_outputs(this%sgg, this%media, this%sinPML_fullsize, this%tag_numbers, this%bounds, & - this%control, this%thereAre%Observation, this%thereAre%wires, & - eps0_input=this%eps0, mu0_input=this%mu0) - l_auxinput=this%thereAre%Observation.or.this%thereAre%FarFields +#endif + write(dubuf,*) 'Init Observation...'; call print11(this%control%layoutnumber,dubuf) + call init_outputs(this%sgg, this%media, this%sinPML_fullsize, this%tag_numbers, this%bounds, & + this%control, this%thereAre%Observation, this%thereAre%wires, & + eps0_input=this%eps0, mu0_input=this%mu0) + l_auxinput=this%thereAre%Observation.or.this%thereAre%FarFields l_auxoutput=l_auxinput #ifdef CompileWithMPI @@ -1496,7 +1502,7 @@ end subroutine initializeObservation subroutine initializeMPI() character(len=bufsize) :: dubuf integer(kind=4) :: ierr - call configure_default_openmp_threads(this%control%num_procs) + call configure_default_openmp_threads(this%control%num_procs) if (this%control%num_procs>1) then call MPI_Barrier(SUBCOMM_MPI,ierr) write(dubuf,*) 'Init MPI MediaMatrix flush...'; call print11(this%control%layoutnumber,dubuf) @@ -1745,10 +1751,10 @@ subroutine solver_run(this) type(fields_reference_t) :: fieldReference - logical :: call_timing, l_aux, flushFF - integer :: i - real(kind=rkind) :: pscale_alpha - character(len=bufsize) :: dubuf + logical :: call_timing, l_aux, flushFF + integer :: i + real(kind=rkind) :: pscale_alpha + character(len=bufsize) :: dubuf #ifdef CompileWithMPI integer(kind=4) :: ierr #endif @@ -1757,19 +1763,19 @@ subroutine solver_run(this) #endif this%still_planewave_time=.true. !inicializacion de la variable - flushFF = .false. - pscale_alpha=1.0 !se le entra con 1.0 - - Ex => this%Ex; Ey => this%Ey; Ez => this%Ez - Hx => this%Hx; Hy => this%Hy; Hz => this%Hz - - Idxe => this%Idxe; Idye => this%Idye; Idze => this%Idze - Idxh => this%Idxh; Idyh => this%Idyh; Idzh => this%Idzh - - dxe => this%dxe; dye => this%dye; dze => this%dze - dxh => this%dxh; dyh => this%dyh; dzh => this%dzh - - fieldReference%E%x => this%Ex + flushFF = .false. + pscale_alpha=1.0 !se le entra con 1.0 + + Ex => this%Ex; Ey => this%Ey; Ez => this%Ez + Hx => this%Hx; Hy => this%Hy; Hz => this%Hz + + Idxe => this%Idxe; Idye => this%Idye; Idze => this%Idze + Idxh => this%Idxh; Idyh => this%Idyh; Idzh => this%Idzh + + dxe => this%dxe; dye => this%dye; dze => this%dze + dxh => this%dxh; dyh => this%dyh; dzh => this%dzh + + fieldReference%E%x => this%Ex fieldReference%E%y => this%Ey fieldReference%E%z => this%Ez @@ -1820,8 +1826,8 @@ subroutine solver_run(this) write(dubuf,'(a,i9)') ' INIT OBSERVATION DATA FLUSHING n= ',this%n end if call printMessageWithSeparator(this%control%layoutnumber,dubuf) - if (this%thereAre%Observation) call flush_outputs(this%sgg%tiempo, this%n, this%control, fieldReference, this%bounds, flushFF) - end if !del if (this%performflushDATA.or.... + if (this%thereAre%Observation) call flush_outputs(this%sgg%tiempo, this%n, this%control, fieldReference, this%bounds, flushFF) + end if !del if (this%performflushDATA.or.... if (this%control%singlefilewrite.and.this%perform%Unpack) call singleUnpack() if ((this%control%singlefilewrite.and.this%perform%Unpack).or.this%perform%isFlush()) then write(dubuf,'(a,i9)') ' Continuing simulation at n= ',this%n @@ -1902,22 +1908,22 @@ subroutine performFlushField() write(dubuf,*) 'DONE FLUSHING OF RESTARTING FIELDS n=',this%n call printMessageWithSeparator(this%control%layoutnumber, dubuf) - end subroutine performFlushField - - subroutine updateAndFlush() - integer(kind=4) :: mindum - if (this%thereAre%Observation) then - if (this%n > 0 .and. mod(this%n, OUTPUT_TIME_BUFFER_SIZE) == 0) then - call flush_outputs(this%sgg%tiempo, this%n, this%control, fieldReference, this%bounds, .FALSE.) - end if - call update_outputs(this%control, this%sgg%tiempo(this%n), this%n, fieldReference, this%sgg) - end if - end subroutine - - subroutine singleUnpack() - character(len=BUFSIZE) :: dubuf - logical :: somethingdone, newsomethingdone - real(kind=rkind_tiempo) :: at + end subroutine performFlushField + + subroutine updateAndFlush() + integer(kind=4) :: mindum + if (this%thereAre%Observation) then + if (this%n > 0 .and. mod(this%n, OUTPUT_TIME_BUFFER_SIZE) == 0) then + call flush_outputs(this%sgg%tiempo, this%n, this%control, fieldReference, this%bounds, .FALSE.) + end if + call update_outputs(this%control, this%sgg%tiempo(this%n), this%n, fieldReference, this%sgg) + end if + end subroutine + + subroutine singleUnpack() + character(len=BUFSIZE) :: dubuf + logical :: somethingdone, newsomethingdone + real(kind=rkind_tiempo) :: at #ifdef CompileWithMPI integer(kind=4) :: ierr #endif @@ -1955,12 +1961,12 @@ subroutine step(this) call flushPlanewaveOff(planewave_switched_off, this%still_planewave_time, thereareplanewave) call this%AdvanceAnisotropicE() call this%advanceE() - - call this%advanceWiresE() -#ifdef CompileWithMTLN - if (this%mtlnObservationInitialized) call UpdateMTLNObservation(this%n) -#endif - call this%advancePMLE() + + call this%advanceWiresE() +#ifdef CompileWithMTLN + if (this%mtlnObservationInitialized) call UpdateMTLNObservation(this%n) +#endif + call this%advancePMLE() #ifdef CompileWithNIBC if (this%thereAre%Multiports.and.(this%control%mibc)) call AdvanceMultiportE(this%sgg%alloc, this%Ex, this%Ey, this%Ez) #endif @@ -2588,8 +2594,8 @@ subroutine solver_end(this) real(kind=rkind), pointer, dimension(:,:,:) :: Ex, Ey, Ez, Hx, Hy, Hz real(kind=rkind), pointer, dimension(:) :: dxe, dye, dze, dxh, dyh, dzh - integer(kind=4) :: ndummy - logical :: dummylog + integer(kind=4) :: ndummy + logical :: dummylog character(len=bufsize) :: dubuf type(fields_reference_t) :: fieldReference @@ -2656,14 +2662,14 @@ subroutine solver_end(this) end if call print11(this%control%layoutnumber,SEPARADOR//separador//separador) call print11(this%control%layoutnumber,dubuf) - call print11(this%control%layoutnumber,SEPARADOR//separador//separador) - if (this%thereAre%Observation) then - call flush_outputs(this%sgg%tiempo, this%n, this%control, fieldReference, this%bounds, .TRUE.) - end if -#ifdef CompileWithMTLN - if (this%mtlnObservationInitialized) call CloseMTLNObservation() -#endif - if (this%thereAre%Observation) call close_outputs() + call print11(this%control%layoutnumber,SEPARADOR//separador//separador) + if (this%thereAre%Observation) then + call flush_outputs(this%sgg%tiempo, this%n, this%control, fieldReference, this%bounds, .TRUE.) + end if +#ifdef CompileWithMTLN + if (this%mtlnObservationInitialized) call CloseMTLNObservation() +#endif + if (this%thereAre%Observation) call close_outputs() if (this%thereAre%FarFields) then write(dubuf,'(a,i9)') ' DONE FINAL OBSERVATION DATA FLUSHED and Near-to-Far field n= ',this%n else @@ -2677,7 +2683,7 @@ subroutine solver_end(this) call MPI_Barrier(SUBCOMM_MPI,ierr) #endif - call Timing(this%sgg,this%bounds,this%n,ndummy,this%control%layoutnumber, & + call Timing(this%sgg,this%bounds,this%n,ndummy,this%control%layoutnumber, & this%control%num_procs, this%control%maxCPUtime,this%control%flushsecondsFields, & this%control%flushsecondsData,this%initialtimestep, & this%control%finaltimestep,this%perform,this%parar,.FALSE., & diff --git a/test/pyWrapper/test_full_system_mpi.py b/test/pyWrapper/test_full_system_mpi.py index d8d5c273..e5e90733 100644 --- a/test/pyWrapper/test_full_system_mpi.py +++ b/test/pyWrapper/test_full_system_mpi.py @@ -167,7 +167,7 @@ def test_towelHanger_mpi(tmp_path): fn = CASES_FOLDER + "towelHanger/towelHanger_mpi.fdtd.json" setNgspice(tmp_path) print(SEMBA_EXE) - for layers in [1, 2, 4]: + for layers in [1, 2]: for direction_index, direction in enumerate(["x", "y", "z"]): solver = FDTD( input_filename=fn, From 10758e252454c9ec91d5c968c51add9b151d71ca Mon Sep 17 00:00:00 2001 From: Alberto-o Date: Fri, 18 Sep 2026 13:50:58 +0200 Subject: [PATCH 3/6] * MPI communication between layers was giving wrong value to segment orientation * Fixes kind of integers --- src_main_pub/nfde_rotate.F90 | 2 +- src_mtln/mtl.F90 | 84 ++++++++++++------------ src_mtln/mtl_bundle.F90 | 57 +++++++++-------- src_mtln/mtln_solver.F90 | 50 +++++++-------- src_mtln/mtln_types.F90 | 120 +++++++++++++++++------------------ src_mtln/network.F90 | 12 ++-- src_mtln/network_manager.F90 | 12 ++-- src_mtln/preprocess.F90 | 115 +++++++++++++++++---------------- src_mtln/probes.F90 | 2 +- src_wires_pub/wires_mtln.F90 | 7 ++ 10 files changed, 235 insertions(+), 226 deletions(-) diff --git a/src_main_pub/nfde_rotate.F90 b/src_main_pub/nfde_rotate.F90 index 006125f7..06210c8b 100644 --- a/src_main_pub/nfde_rotate.F90 +++ b/src_main_pub/nfde_rotate.F90 @@ -68,7 +68,7 @@ subroutine rotate_mtln(this, mpidir) this%mtln%cables(i)%ptr%segments(j)%x = y this%mtln%cables(i)%ptr%segments(j)%y = z this%mtln%cables(i)%ptr%segments(j)%z = x - select case(abs(old_mtln%cables(i)%ptr%segments(j)%orientation)) + select case(abs(or)) case(1) this%mtln%cables(i)%ptr%segments(j)%orientation = sign(3, or) case(2) diff --git a/src_mtln/mtl.F90 b/src_mtln/mtl.F90 index daf889ea..34c1f7aa 100644 --- a/src_mtln/mtl.F90 +++ b/src_mtln/mtl.F90 @@ -12,22 +12,24 @@ module mtl_m implicit none #ifdef CompileWithMPI - integer, parameter :: COMM_SEND = 1 - integer, parameter :: COMM_RECV = -1 - integer, parameter :: COMM_NONE = 0 - integer, parameter :: COMM_FIELD = 1 - integer, parameter :: COMM_V = 2 - integer, parameter :: COMM_BOTH = 3 + integer(kind=4), parameter :: COMM_SEND = 1 + integer(kind=4), parameter :: COMM_RECV = -1 + integer(kind=4), parameter :: COMM_NONE = 0 + integer(kind=4), parameter :: COMM_FIELD = 1 + integer(kind=4), parameter :: COMM_V = 2 + integer(kind=4), parameter :: COMM_BOTH = 3 + + integer(kind=4), parameter :: SEGMENT_GAP_ORIENTATION = -99 type, public :: communicator_t - integer :: field_index = -1, v_index = -1 - integer :: comm_task = COMM_NONE - integer :: comm_type = COMM_NONE - integer :: delta_rank = 0 + integer(kind=4) :: field_index = -1, v_index = -1 + integer(kind=4) :: comm_task = COMM_NONE + integer(kind=4) :: comm_type = COMM_NONE + integer(kind=4) :: delta_rank = 0 end type type, public :: comm_t type(communicator_t), dimension(:), allocatable :: comms - integer :: rank + integer(kind=4) :: rank end type #endif @@ -41,7 +43,7 @@ module mtl_m real(kind=RKIND_TIEMPO) :: time = 0.0, dt = 0.0 character(len=:), allocatable :: parent_name - integer :: conductor_in_parent + integer(kind=4) :: conductor_in_parent type(transfer_impedance_per_meter_t) :: transfer_impedance type(transfer_impedance_per_meter_t), dimension(:), allocatable :: initial_connector_transfer_impedances, end_connector_transfer_impedances type(segment_t), dimension(:), allocatable :: segments @@ -95,7 +97,7 @@ module mtl_m subroutine initLC(this, lpul, cpul) class(mtl_t) :: this real(kind=rkind), intent(in), dimension(:,:) :: lpul, cpul - integer :: i + integer(kind=4) :: i do i = 1, size(this%lpul, 1) this%lpul(i,:,:) = lpul(:,:) end do @@ -115,7 +117,7 @@ function mtl_shielded(lpul, cpul, rpul, gpul, & type(segment_t), dimension(:), allocatable, intent(in) :: segments real(kind=RKIND_TIEMPO), intent(in) :: dt character(len=*), intent(in) :: parent_name - integer, intent(in) :: conductor_in_parent + integer(kind=4), intent(in) :: conductor_in_parent type(transfer_impedance_per_meter_t), intent(in) :: transfer_impedance integer(kind=4), allocatable, dimension(:,:), intent(in), optional :: layer_indices @@ -250,7 +252,7 @@ subroutine checkTimeStep(this, getMax, dt) subroutine allocatePULMatrices(this) class(mtl_t) :: this - integer :: n + integer(kind=4) :: n n = this%number_of_conductors allocate(this%lpul(size(this%step_size, 1), n, n), source = 0.0_rkind) allocate(this%cpul(size(this%step_size, 1) + 1, n, n), source = 0.0_rkind) @@ -261,7 +263,7 @@ subroutine allocatePULMatrices(this) subroutine computeLCParameters(this, multipolar_expansion) class(mtl_t) :: this type(multipolar_expansion_t), intent(in) :: multipolar_expansion - integer :: i, j, k, n + integer(kind=4) :: i, j, k, n real(kind=rkind), dimension(:,:), allocatable :: ppul allocate(ppul(size(this%cpul,2),size(this%cpul,3))) do i = 1, size(this%segments) @@ -277,7 +279,7 @@ subroutine computeLCParametersFromRadius(this, rad) class(mtl_t) :: this real(kind=rkind), intent(in) :: rad real(kind=RKIND_wires) :: invMu - integer :: i + integer(kind=4) :: i real(kind=rkind) :: d1, d2 invMu = 1.0/mu_vacuum do i = 1, size(this%segments) @@ -305,7 +307,7 @@ subroutine computeLCParametersFromRadius(this, rad) subroutine initDirections(this) class(mtl_t) :: this - integer :: j + integer(kind=4) :: j this%du = reshape(source = [(this%step_size(j)*eye(this%number_of_conductors) , j = 1, size(this%step_size))], & shape = [size(this%step_size), this%number_of_conductors, this%number_of_conductors], & @@ -335,7 +337,7 @@ function getPhaseVelocities(this) result(res) class(mtl_t) :: this real(kind=rkind), dimension(size(this%step_size,1), this%number_of_conductors) :: res real(kind=rkind), dimension(2*this%number_of_conductors) :: ev - integer :: k + integer(kind=4) :: k do k = 1, size(this%step_size, 1) ev = getEigenValues(dble(matmul(this%lpul(k,:,:), this%cpul(k+1,:,:)))) @@ -353,7 +355,7 @@ function getMaxTimeStep(this) result(res) subroutine initRG(this, rpul, gpul) class(mtl_t) :: this real(kind=rkind), intent(in), dimension(:,:) :: rpul, gpul - integer :: i + integer(kind=4) :: i do i = 1, size(this%rpul, 1) this%rpul(i,:,:) = rpul(:,:) end do @@ -365,7 +367,7 @@ subroutine initRG(this, rpul, gpul) subroutine setTimeStep(this, numberOfSteps, finalTime) class(mtl_t) :: this - integer, intent(in) :: numberOfSteps + integer(kind=4), intent(in) :: numberOfSteps real(kind=rkind), intent(in) ::finalTime this%dt = finalTime/numberOfSteps end subroutine @@ -378,7 +380,7 @@ subroutine initStepSizeAndFieldSegments(this, step_size, segments, layer_indices real(kind=rkind), intent(in), dimension(:) :: step_size type(segment_t), intent(in), dimension(:) :: segments integer(kind=4), allocatable, dimension(:,:), intent(in) :: layer_indices - integer :: n, j + integer(kind=4) :: n, j n = 0 do j = 1, size(layer_indices, 1) n = n + layer_indices(j,2) - layer_indices(j,1) + 1 @@ -396,7 +398,7 @@ subroutine initStepSizeAndFieldSegments(this, step_size, segments, layer_indices if (j /= size(layer_indices,1)) then this%step_size(n + layer_indices(j,2) - layer_indices(j,1) + 1) = this%step_size(n + layer_indices(j,2) - layer_indices(j,1)) this%segments(n + layer_indices(j,2) - layer_indices(j,1) + 1) = this%segments(n + layer_indices(j,2) - layer_indices(j,1)) - this%segments(n + layer_indices(j,2) - layer_indices(j,1) + 1)%orientation = -1 + this%segments(n + layer_indices(j,2) - layer_indices(j,1) + 1)%orientation = SEGMENT_GAP_ORIENTATION n = n + 1 end if n = n + layer_indices(j,2) - layer_indices(j,1) + 1 @@ -408,8 +410,8 @@ subroutine initStepSizeAndFieldSegments(this, step_size, segments, layer_indices subroutine initCommunicators(this, alloc_z) class(mtl_t) :: this integer(kind =4), dimension(2) :: alloc_z - integer :: j, n, z - integer :: rank, ierr + integer(kind=4) :: j, n, z + integer(kind=4) :: rank, ierr integer(kind =4) :: z_init, z_end type(communicator_t), dimension(:), allocatable :: aux_comm @@ -421,7 +423,7 @@ subroutine initCommunicators(this, alloc_z) z_end = alloc_z(2) do j = 1, size(this%segments) - if (this%segments(j)%orientation == -1) cycle + if (this%segments(j)%orientation == SEGMENT_GAP_ORIENTATION) cycle z = this%segments(j)%z if (.not. isSegmentZOriented(j) .and. ((z == z_end) .or. (z == z_init + 1))) then @@ -506,58 +508,58 @@ subroutine initCommunicators(this, alloc_z) contains logical function isSegmentZOriented(j) - integer, intent(in) :: j + integer(kind=4), intent(in) :: j isSegmentZOriented = (abs(this%segments(j)%orientation) == 3) end function logical function isSegmentZPositive(j) - integer, intent(in) :: j + integer(kind=4), intent(in) :: j isSegmentZPositive = (this%segments(j)%orientation == 3) end function logical function isSegmentZNegative(j) - integer, intent(in) :: j + integer(kind=4), intent(in) :: j isSegmentZNegative = (this%segments(j)%orientation == -3) end function logical function isSegmentBeforeLayerEnd(j, z_end) - integer, intent(in) :: j, z_end - integer :: z + integer(kind=4), intent(in) :: j, z_end + integer(kind=4) :: z z = this%segments(j)%z isSegmentBeforeLayerEnd = (z==z_end-1) end function logical function isSegmentAfterLayerEnd(j, z_end) - integer, intent(in) :: j, z_end - integer :: z + integer(kind=4), intent(in) :: j, z_end + integer(kind=4) :: z z = this%segments(j)%z isSegmentAfterLayerEnd = (z==z_end) end function logical function isSegmentBeforeLayerInit(j, z_init) - integer, intent(in) :: j, z_init - integer :: z + integer(kind=4), intent(in) :: j, z_init + integer(kind=4) :: z z = this%segments(j)%z isSegmentBeforeLayerInit = (z==z_init) end function logical function isSegmentAfterLayerInit(j, z_init) - integer, intent(in) :: j, z_init - integer :: z + integer(kind=4), intent(in) :: j, z_init + integer(kind=4) :: z z = this%segments(j)%z isSegmentAfterLayerInit = (z==z_init+1) end function logical function isSegmentNextToLayerEnd(j, z_end) - integer, intent(in) :: j, z_end - integer :: z + integer(kind=4), intent(in) :: j, z_end + integer(kind=4) :: z z = this%segments(j)%z isSegmentNextToLayerEnd = (z==z_end) .or. (z==z_end-1) end function logical function isSegmentNextToLayerInit(j, z_init) - integer, intent(in) :: j, z_init - integer :: z + integer(kind=4), intent(in) :: j, z_init + integer(kind=4) :: z z = this%segments(j)%z isSegmentNextToLayerInit = (z==z_init) .or. (z==z_init+1) end function diff --git a/src_mtln/mtl_bundle.F90 b/src_mtln/mtl_bundle.F90 index d830ae9c..05a6a882 100644 --- a/src_mtln/mtl_bundle.F90 +++ b/src_mtln/mtl_bundle.F90 @@ -27,7 +27,7 @@ module mtl_bundle_m type(probe_t), allocatable, dimension(:) :: probes type(transfer_impedance_t) :: transfer_impedance - integer, dimension(:), allocatable :: conductors_in_level + integer(kind=4), dimension(:), allocatable :: conductors_in_level real(kind=rkind), dimension(:,:,:), allocatable :: v_term, i_term real(kind=rkind), dimension(:,:,:), allocatable :: v_diff, i_diff @@ -67,8 +67,8 @@ module mtl_bundle_m end interface type :: external_field_segment_t - integer, dimension(3) ::position - integer :: direction = 0 + integer(kind=4), dimension(3) ::position + integer(kind=4) :: direction = 0 real(kind=rkind) , pointer :: field => null() end type @@ -131,7 +131,7 @@ subroutine initialAllocation(this) function countNumberOfConductors(levels) result(res) type(transmission_line_level_t), dimension(:), intent(in) :: levels - integer :: i,j, res + integer(kind=4) :: i,j, res res = 0 do i = 1, size(levels) do j = 1, size(levels(i)%lines) @@ -143,7 +143,7 @@ function countNumberOfConductors(levels) result(res) subroutine mergePULMatrices(this, levels) class(mtl_bundle_t) :: this type(transmission_line_level_t), dimension(:), intent(in) :: levels - integer :: i, j, n, n_sum + integer(kind=4) :: i, j, n, n_sum n_sum = 0 do i = 1, size(levels) do j = 1, size(levels(i)%lines) @@ -161,7 +161,7 @@ subroutine mergePULMatrices(this, levels) subroutine mergeDispersiveMatrices(this, levels) class(mtl_bundle_t) :: this type(transmission_line_level_t), dimension(:), intent(in) :: levels - integer :: i, j, n, n_sum, number_of_poles + integer(kind=4) :: i, j, n, n_sum, number_of_poles n_sum = 0 number_of_poles = 0 do i = 1, size(levels) @@ -212,7 +212,7 @@ function buildExternalFieldSegments(levels) result(res) type(transmission_line_level_t), dimension(:), intent(in) :: levels type(external_field_segment_t), dimension(:), allocatable :: res type(segment_t), dimension(:), allocatable :: segments - integer :: i + integer(kind=4) :: i segments = levels(1)%lines(1)%segments allocate(res(size(segments))) do i = 1, size(segments) @@ -225,8 +225,8 @@ function buildExternalFieldSegments(levels) result(res) subroutine addProbe(this, index, probe_type, name, position, layer_indices) class(mtl_bundle_t) :: this - integer, intent(in) :: index - integer, intent(in) :: probe_type + integer(kind=4), intent(in) :: index + integer(kind=4), intent(in) :: probe_type real(kind=rkind), dimension(3) :: position character(len=:), allocatable :: name integer(kind=4), dimension(:,:), intent(in), optional :: layer_indices @@ -248,7 +248,7 @@ subroutine addProbe(this, index, probe_type, name, position, layer_indices) subroutine addGenerator(this, index, conductor, gen_type, resistance, path, layer_indices) class(mtl_bundle_t) :: this - integer, intent(in) :: index, conductor, gen_type + integer(kind=4), intent(in) :: index, conductor, gen_type real(kind=rkind) :: resistance character(*), intent(in) :: path integer(kind=4), dimension(:,:), intent(in), optional :: layer_indices @@ -284,9 +284,9 @@ subroutine addGenerator(this, index, conductor, gen_type, resistance, path, laye subroutine bundle_setConnectorTransferImpedance(this, index, conductor_out, range_in, transfer_impedance) class(mtl_bundle_t) :: this - integer, intent(in) :: index - integer, intent(in) :: conductor_out - integer, dimension(:), intent(in) :: range_in + integer(kind=4), intent(in) :: index + integer(kind=4), intent(in) :: conductor_out + integer(kind=4), dimension(:), intent(in) :: range_in type(transfer_impedance_per_meter_t) :: transfer_impedance call this%transfer_impedance%setTransferImpedance(index, conductor_out, range_in, transfer_impedance) @@ -295,8 +295,8 @@ subroutine bundle_setConnectorTransferImpedance(this, index, conductor_out, rang subroutine bundle_addTransferImpedance(this, conductor_out, range_in, transfer_impedance) class(mtl_bundle_t) :: this - integer, intent(in) :: conductor_out - integer, dimension(:), intent(in) :: range_in + integer(kind=4), intent(in) :: conductor_out + integer(kind=4), dimension(:), intent(in) :: range_in type(transfer_impedance_per_meter_t) :: transfer_impedance call this%transfer_impedance%addTransferImpedance(conductor_out, range_in, transfer_impedance) @@ -306,7 +306,7 @@ subroutine bundle_addTransferImpedance(this, conductor_out, range_in, transfer_i subroutine updateLRTerms(this) class(mtl_bundle_t) ::this real(kind=rkind), dimension(this%number_of_divisions,this%number_of_conductors,this%number_of_conductors) :: F1, F2, IF1 - integer :: i + integer(kind=4) :: i F1 = reshape(source=[(matmul( & this%du(i,:,:), & @@ -347,7 +347,7 @@ subroutine updateCGTerms(this) class(mtl_bundle_t) ::this real(kind=rkind), dimension(this%number_of_divisions + 1,this%number_of_conductors,this%number_of_conductors) :: F1, F2, IF1 real(kind=rkind), dimension(this%number_of_divisions + 1, this%number_of_conductors,this%number_of_conductors) :: extended_du - integer :: i + integer(kind=4) :: i extended_du(1,:,:) = this%du(1,:,:) do i = 2, this%number_of_divisions @@ -384,7 +384,7 @@ subroutine bundle_updateGenerators(this, time, dt) class(mtl_bundle_t) ::this real(kind=RKIND_TIEMPO), intent(in) :: time, dt real(kind=rkind) :: val - integer :: i + integer(kind=4) :: i do i = 1, size(this%generators) if (this%generators(i)%in_layer) then if (this%generators(i)%source_type == SOURCE_TYPE_VOLTAGE) then @@ -403,7 +403,7 @@ subroutine bundle_updateGenerators(this, time, dt) subroutine bundle_advanceVoltage(this) class(mtl_bundle_t) ::this - integer :: i + integer(kind=4) :: i do i = 2,this%number_of_divisions this%v(:, i) = matmul(this%v_term(i,:,:), this%v(:,i)) - & matmul(this%i_diff(i,:,:), (this%i(:,i) - this%i(:,i-1)) + matmul(this%du(i,:,:), this%i_source(:,i))) @@ -414,7 +414,7 @@ subroutine bundle_advanceVoltage(this) subroutine bundle_advanceCurrent(this) class(mtl_bundle_t) ::this - integer :: i + integer(kind=4) :: i real(kind=rkind) :: eps_r #ifdef CompileWithMPI integer(kind=4) :: sizeof, ierr @@ -439,9 +439,9 @@ subroutine bundle_advanceCurrent(this) subroutine bundle_setExternalLongitudinalField(this) class(mtl_bundle_t) :: this - integer :: i, j + integer(kind=4) :: i, j #ifdef CompileWithMPI - integer :: sizeof, ierr + integer(kind=4) :: sizeof, ierr call MPI_COMM_SIZE(SUBCOMM_MPI, sizeof, ierr) if (sizeof > 1) call this%Comm_MPI_Fields() @@ -449,9 +449,10 @@ subroutine bundle_setExternalLongitudinalField(this) do j = 1, this%conductors_in_level(1) do i = 1, size(this%e_L,2) - this%e_L(j,i) = this%external_field_segments(i)%field * & - this%external_field_segments(i)%direction/abs(this%external_field_segments(i)%direction) - + if (abs(this%external_field_segments(i)%direction) <= 3) then + this%e_L(j,i) = this%external_field_segments(i)%field * & + this%external_field_segments(i)%direction/abs(this%external_field_segments(i)%direction) + end if end do end do @@ -460,8 +461,8 @@ subroutine bundle_setExternalLongitudinalField(this) #ifdef CompileWithMPI subroutine Comm_MPI_V(this) class(mtl_bundle_t) :: this - integer :: number_of_conductors, i, c - integer :: ierr, rank, status(MPI_STATUS_SIZE) + integer(kind=4) :: number_of_conductors, i, c + integer(kind=4) :: ierr, rank, status(MPI_STATUS_SIZE) call MPI_COMM_RANK(SUBCOMM_MPI, rank, ierr) number_of_conductors = size(this%v,1) do i = 1, size(this%mpi_comm%comms) @@ -490,7 +491,7 @@ subroutine Comm_MPI_V(this) subroutine Comm_MPI_Fields(this) class(mtl_bundle_t) :: this - integer :: i, ierr, rank, status(MPI_STATUS_SIZE) + integer(kind=4) :: i, ierr, rank, status(MPI_STATUS_SIZE) call MPI_COMM_RANK(SUBCOMM_MPI, rank, ierr) do i = 1, size(this%mpi_comm%comms) if (this%mpi_comm%comms(i)%comm_type == COMM_FIELD .or. this%mpi_comm%comms(i)%comm_type == COMM_BOTH) then diff --git a/src_mtln/mtln_solver.F90 b/src_mtln/mtln_solver.F90 index 8be5137c..e5ebc8f0 100644 --- a/src_mtln/mtln_solver.F90 +++ b/src_mtln/mtln_solver.F90 @@ -22,9 +22,9 @@ module mtln_solver_m type(mtl_bundle_t), allocatable, dimension(:) :: bundles type(network_manager_t) :: network_manager ! type(probe_t), allocatable, dimension(:) :: probes - integer :: number_of_bundles + integer(kind=4) :: number_of_bundles logical :: has_active_bundles - integer :: number_of_steps + integer(kind=4) :: number_of_steps real(kind=rkind) :: null_field contains @@ -63,7 +63,7 @@ function mtlnCtor(parsed, alloc) result(res) type(parsed_mtln_t) :: parsed type(XYZlimit_t), dimension(1:6), intent(in), optional :: alloc type(mtln_t) :: res - integer :: i + integer(kind=4) :: i type(preprocess_t) :: pre #ifdef CompileWithMPI @@ -101,9 +101,9 @@ function mtlnCtor(parsed, alloc) result(res) subroutine initNodes(this) class(mtln_t) :: this - integer :: i,j - integer ::b, c, v_idx, i_idx - integer :: n + integer(kind=4) :: i,j + integer(kind=4) ::b, c, v_idx, i_idx + integer(kind=4) :: n if (this%number_of_bundles == 0) return if (size(this%network_manager%networks) == 0) return do i = 1, size(this%network_manager%networks) @@ -143,7 +143,7 @@ subroutine mtln_step(this) logical function hasActiveBundles(this) class(mtln_t) :: this - integer :: i + integer(kind=4) :: i this%has_active_bundles = .false. do i = 1, this%number_of_bundles if (this%bundles(i)%bundle_in_layer) then @@ -154,7 +154,7 @@ logical function hasActiveBundles(this) subroutine step_alone(this) class(mtln_t) :: this - integer :: i + integer(kind=4) :: i call this%advanceBundlesVoltage() call this%advanceNWVoltage() @@ -167,7 +167,7 @@ subroutine step_alone(this) subroutine setExternalLongitudinalField(this) class(mtln_t) :: this - integer :: i + integer(kind=4) :: i do i = 1, this%number_of_bundles if (this%bundles(i)%bundle_in_layer) call this%bundles(i)%setExternalLongitudinalField() end do @@ -176,7 +176,7 @@ subroutine setExternalLongitudinalField(this) subroutine advanceBundlesVoltage(this) class(mtln_t) :: this - integer :: i + integer(kind=4) :: i do i = 1, this%number_of_bundles if (this%bundles(i)%bundle_in_layer) then @@ -189,9 +189,9 @@ subroutine advanceBundlesVoltage(this) subroutine advanceNWVoltage(this) class(mtln_t) :: this - integer :: i,j - integer ::b, c, v_idx, i_idx - integer :: n + integer(kind=4) :: i,j + integer(kind=4) ::b, c, v_idx, i_idx + integer(kind=4) :: n ! #ifdef CompileWithMPI ! integer(kind=4) :: ierr ! call mpi_barrier(subcomm_mpi, ierr) @@ -206,7 +206,7 @@ subroutine advanceNWVoltage(this) subroutine updateOpenNodes(this) class(mtln_t) :: this - integer :: i, b, c, n + integer(kind=4) :: i, b, c, n do i = 1, size(this%network_manager%open_nodes) b = this%network_manager%open_nodes(i)%bundle_number if (this%bundles(b)%bundle_in_layer) then @@ -225,7 +225,7 @@ subroutine updateOpenNodes(this) subroutine advanceBundlesCurrent(this) class(mtln_t) :: this - integer :: i + integer(kind=4) :: i do i = 1, this%number_of_bundles if (this%bundles(i)%bundle_in_layer) then call this%bundles(i)%advanceCurrent() @@ -240,7 +240,7 @@ subroutine advanceTime(this) subroutine updateProbes(this) class(mtln_t) :: this - integer :: i, j + integer(kind=4) :: i, j do i = 1, this%number_of_bundles if (size(this%bundles(i)%probes) /= 0 .and. this%bundles(i)%bundle_in_layer) then do j = 1, size(this%bundles(i)%probes) @@ -255,7 +255,7 @@ subroutine updateProbes(this) function getTimeRange(this, time) result(res) class(mtln_t) :: this real(kind=RKIND_TIEMPO), intent(in), optional :: time - integer :: res + integer(kind=4) :: res if (present(time)) then res = floor(time / this%dt) else @@ -266,7 +266,7 @@ function getTimeRange(this, time) result(res) subroutine updateBundlesTimeStep(this, dt) class(mtln_t) :: this real(kind=RKIND_TIEMPO) :: dt - integer :: i + integer(kind=4) :: i do i = 1, this%number_of_bundles this%bundles(i)%dt = dt end do @@ -274,7 +274,7 @@ subroutine updateBundlesTimeStep(this, dt) subroutine updatePULTerms(this) class(mtln_t) :: this - integer :: i, j + integer(kind=4) :: i, j do i = 1, this%number_of_bundles if (this%bundles(i)%bundle_in_layer) then call this%bundles(i)%updateLRTerms() @@ -293,7 +293,7 @@ subroutine runUntil(this, final_time) class(mtln_t) :: this real(kind=RKIND_TIEMPO), intent(in):: final_time real(kind=RKIND_TIEMPO) :: time - integer :: i + integer(kind=4) :: i do i = 0, this%getTimeRange(final_time) call this%advanceBundlesVoltage() @@ -309,7 +309,7 @@ subroutine runUntil(this, final_time) subroutine mtln_run(this) class(mtln_t) :: this real(kind=RKIND_TIEMPO) :: time - integer :: i + integer(kind=4) :: i do i = 0, this%getTimeRange(this%final_time) call this%advanceBundlesVoltage() @@ -325,12 +325,12 @@ subroutine mtln_run(this) subroutine mtln_initObservation(this, nEntradaRoot) class(mtln_t) :: this character(len=*), intent(in) :: nEntradaRoot - integer :: close_ios, i, ios, j, k, unit + integer(kind=4) :: close_ios, i, ios, j, k, unit character(len=bufsize) :: path character(len=bufsize) :: temp character(len=:), allocatable :: buffer #ifdef CompileWithMPI - integer :: candidate_rank, ierr, rank, writer_rank + integer(kind=4) :: candidate_rank, ierr, rank, writer_rank #endif if (.not. allocated(this%bundles)) return @@ -397,7 +397,7 @@ subroutine mtln_initObservation(this, nEntradaRoot) subroutine mtln_updateObservation(this, step) class(mtln_t) :: this integer, intent(in) :: step - integer :: i, ios, j, n + integer(kind=4) :: i, ios, j, n character(len=bufsize) :: temp character(len=:), allocatable :: buffer #ifdef CompileWithMPI @@ -429,7 +429,7 @@ subroutine mtln_updateObservation(this, step) subroutine mtln_closeObservation(this) class(mtln_t) :: this - integer :: i, ios, j + integer(kind=4) :: i, ios, j if (.not. allocated(this%bundles)) return do i = 1, size(this%bundles) do j = 1, size(this%bundles(i)%probes) diff --git a/src_mtln/mtln_types.F90 b/src_mtln/mtln_types.F90 index ec392986..cc44a38e 100644 --- a/src_mtln/mtln_types.F90 +++ b/src_mtln/mtln_types.F90 @@ -2,51 +2,51 @@ module mtln_types_m use FDETYPES_m, ONLY: direction_t, BUFSIZE, RKIND, RKIND_TIEMPO implicit none - integer, parameter :: TERMINATION_UNDEFINED = -1 - integer, parameter :: TERMINATION_SHORT = 1 - integer, parameter :: TERMINATION_OPEN = 2 - integer, parameter :: TERMINATION_SERIES = 3 - integer, parameter :: TERMINATION_PARALLEL = 4 - integer, parameter :: TERMINATION_RsLCp = 5 - integer, parameter :: TERMINATION_RLsCp = 6 - integer, parameter :: TERMINATION_LsRCp = 7 - integer, parameter :: TERMINATION_CsLRp = 8 - integer, parameter :: TERMINATION_RCsLp = 9 - integer, parameter :: TERMINATION_LCsRp = 10 - integer, parameter :: TERMINATION_CIRCUIT = 11 - integer, parameter :: TERMINATION_NETWORK = 12 - - integer, parameter :: TERMINAL_NODE_SIDE_UNDEFINED = -1 - integer, parameter :: TERMINAL_NODE_SIDE_INI = 1 - integer, parameter :: TERMINAL_NODE_SIDE_END = 2 - - integer, parameter :: TRANSFER_IMPEDANCE_DIRECTION_UNDEFINED = -1 - integer, parameter :: TRANSFER_IMPEDANCE_DIRECTION_INWARDS = 1 - integer, parameter :: TRANSFER_IMPEDANCE_DIRECTION_OUTWARDS = 2 - integer, parameter :: TRANSFER_IMPEDANCE_DIRECTION_BOTH = 3 - - integer, parameter :: PROBE_TYPE_UNDEFINED = -1 - integer, parameter :: PROBE_TYPE_VOLTAGE = 1 - integer, parameter :: PROBE_TYPE_CURRENT = 2 - - integer, parameter :: SOURCE_TYPE_UNDEFINED = -1 - integer, parameter :: SOURCE_TYPE_VOLTAGE = 1 - integer, parameter :: SOURCE_TYPE_CURRENT = 2 - - integer, parameter :: DIRECTION_X_POS = 1 - integer, parameter :: DIRECTION_X_NEG = -1 - integer, parameter :: DIRECTION_Y_POS = 2 - integer, parameter :: DIRECTION_Y_NEG = -2 - integer, parameter :: DIRECTION_Z_POS = 3 - integer, parameter :: DIRECTION_Z_NEG = -3 + integer(kind=4), parameter :: TERMINATION_UNDEFINED = -1 + integer(kind=4), parameter :: TERMINATION_SHORT = 1 + integer(kind=4), parameter :: TERMINATION_OPEN = 2 + integer(kind=4), parameter :: TERMINATION_SERIES = 3 + integer(kind=4), parameter :: TERMINATION_PARALLEL = 4 + integer(kind=4), parameter :: TERMINATION_RsLCp = 5 + integer(kind=4), parameter :: TERMINATION_RLsCp = 6 + integer(kind=4), parameter :: TERMINATION_LsRCp = 7 + integer(kind=4), parameter :: TERMINATION_CsLRp = 8 + integer(kind=4), parameter :: TERMINATION_RCsLp = 9 + integer(kind=4), parameter :: TERMINATION_LCsRp = 10 + integer(kind=4), parameter :: TERMINATION_CIRCUIT = 11 + integer(kind=4), parameter :: TERMINATION_NETWORK = 12 + + integer(kind=4), parameter :: TERMINAL_NODE_SIDE_UNDEFINED = -1 + integer(kind=4), parameter :: TERMINAL_NODE_SIDE_INI = 1 + integer(kind=4), parameter :: TERMINAL_NODE_SIDE_END = 2 + + integer(kind=4), parameter :: TRANSFER_IMPEDANCE_DIRECTION_UNDEFINED = -1 + integer(kind=4), parameter :: TRANSFER_IMPEDANCE_DIRECTION_INWARDS = 1 + integer(kind=4), parameter :: TRANSFER_IMPEDANCE_DIRECTION_OUTWARDS = 2 + integer(kind=4), parameter :: TRANSFER_IMPEDANCE_DIRECTION_BOTH = 3 + + integer(kind=4), parameter :: PROBE_TYPE_UNDEFINED = -1 + integer(kind=4), parameter :: PROBE_TYPE_VOLTAGE = 1 + integer(kind=4), parameter :: PROBE_TYPE_CURRENT = 2 + + integer(kind=4), parameter :: SOURCE_TYPE_UNDEFINED = -1 + integer(kind=4), parameter :: SOURCE_TYPE_VOLTAGE = 1 + integer(kind=4), parameter :: SOURCE_TYPE_CURRENT = 2 + + integer(kind=4), parameter :: DIRECTION_X_POS = 1 + integer(kind=4), parameter :: DIRECTION_X_NEG = -1 + integer(kind=4), parameter :: DIRECTION_Y_POS = 2 + integer(kind=4), parameter :: DIRECTION_Y_NEG = -2 + integer(kind=4), parameter :: DIRECTION_Z_POS = 3 + integer(kind=4), parameter :: DIRECTION_Z_NEG = -3 type parsed_generator_t character(len=256) :: path_to_excitation = "" - integer :: generator_type = SOURCE_TYPE_UNDEFINED + integer(kind=4) :: generator_type = SOURCE_TYPE_UNDEFINED type(cable_t), pointer :: attached_to_cable => null() real(kind=rkind) :: resistance = 0.0 - integer :: index = -1, conductor = -1 + integer(kind=4) :: index = -1, conductor = -1 contains private procedure :: wire_source_eq @@ -55,7 +55,7 @@ module mtln_types_m type node_source_t character(len=256) :: path_to_excitation = "" - integer :: source_type = SOURCE_TYPE_UNDEFINED + integer(kind=4) :: source_type = SOURCE_TYPE_UNDEFINED real(kind=rkind) :: resistance end type @@ -65,13 +65,13 @@ module mtln_types_m end type type, public :: termination_t - integer :: termination_type = TERMINATION_UNDEFINED + integer(kind=4) :: termination_type = TERMINATION_UNDEFINED real(kind=rkind) :: resistance = 0.0_rkind real(kind=rkind) :: inductance = 0.0_rkind real(kind=rkind) :: capacitance = 1e22_rkind type(node_source_t) :: source type(terminal_circuit_t) :: model - integer :: networkCircuitNode = -1 + integer(kind=4) :: networkCircuitNode = -1 contains private procedure :: termination_eq @@ -80,8 +80,8 @@ module mtln_types_m type :: terminal_node_t class(cable_t), pointer :: belongs_to_cable => null() - integer :: conductor_in_cable - integer :: side = TERMINAL_NODE_SIDE_UNDEFINED + integer(kind=4) :: conductor_in_cable + integer(kind=4) :: side = TERMINAL_NODE_SIDE_UNDEFINED type(termination_t) :: termination contains private @@ -94,8 +94,8 @@ module mtln_types_m character(len=256) :: model_file = "" character(len=256) :: model_name = "" character(len=256) :: circuit_name = "" - integer :: number_of_nodes = -1 - integer :: nodeId = -1 + integer(kind=4) :: number_of_nodes = -1 + integer(kind=4) :: nodeId = -1 end type type :: terminal_connection_t @@ -121,7 +121,7 @@ module mtln_types_m real(kind=rkind) :: inductive_term = 0.0_rkind real(kind=rkind) :: resistive_term = 0.0_rkind complex, dimension(:), allocatable :: poles, residues ! poles and residues - integer :: direction = TRANSFER_IMPEDANCE_DIRECTION_UNDEFINED + integer(kind=4) :: direction = TRANSFER_IMPEDANCE_DIRECTION_UNDEFINED contains private procedure :: transfer_impedance_per_meter_eq @@ -130,7 +130,7 @@ module mtln_types_m end type type :: connector_t - integer :: id + integer(kind=4) :: id real(kind=rkind), dimension(:), allocatable :: resistances type(transfer_impedance_per_meter_t), dimension(:), allocatable :: transfer_impedances_per_meter contains @@ -203,7 +203,7 @@ module mtln_types_m type(connector_t), pointer :: initial_connector => null() type(connector_t), pointer :: end_connector => null() character(len=bufsize) :: tag - integer :: n_segments + integer(kind=4) :: n_segments contains private procedure :: cable_eq @@ -228,13 +228,13 @@ module mtln_types_m real(kind=rkind), allocatable, dimension(:,:) :: capacitance_per_meter type(transfer_impedance_per_meter_t) :: transfer_impedance class(cable_t), pointer :: parent_cable => null() - integer :: conductor_in_parent = -1 + integer(kind=4) :: conductor_in_parent = -1 end type type :: probe_t class(cable_t), pointer :: attached_to_cable => null() - integer :: index - integer :: probe_type = PROBE_TYPE_UNDEFINED + integer(kind=4) :: index + integer(kind=4) :: probe_type = PROBE_TYPE_UNDEFINED character(len=:), allocatable :: probe_name real(kind=rkind), dimension(3) :: probe_position contains @@ -254,8 +254,8 @@ module mtln_types_m type(parsed_generator_t), dimension(:), allocatable :: wireGenerators type(connector_t), dimension(:), pointer :: connectors real(kind=RKIND_TIEMPO) :: time_step = 0.0 - integer :: number_of_steps = 0 - integer :: n_sh = 0, n_unsh = 0 + integer(kind=4) :: number_of_steps = 0 + integer(kind=4) :: n_sh = 0, n_unsh = 0 contains private procedure :: mtln_eq @@ -267,7 +267,7 @@ module mtln_types_m logical function mtln_eq(a,b) class(mtln_t), intent(in) :: a,b - integer :: i + integer(kind=4) :: i if (a%time_step /= b%time_step) then mtln_eq = .false. @@ -368,7 +368,7 @@ elemental function multipolar_expansion_eq(a, b) result(res) recursive logical function cable_eq(a,b) class(cable_t), intent(in) :: a, b - integer :: i + integer(kind=4) :: i cable_eq = .true. cable_eq = cable_eq .and. (a%name == b%name) cable_eq = cable_eq .and. all(a%step_size == b%step_size) @@ -503,7 +503,7 @@ logical function terminal_node_eq(a, b) logical function terminal_connection_eq(a,b) class(terminal_connection_t), intent(in) :: a,b - integer :: i + integer(kind=4) :: i if (size(a%nodes) /= size(b%nodes)) then terminal_connection_eq = .false. return @@ -519,7 +519,7 @@ logical function terminal_connection_eq(a,b) logical function terminal_network_eq(a,b) class(terminal_network_t), intent(in) :: a,b - integer :: i + integer(kind=4) :: i if (size(a%connections) /= size(b%connections)) then terminal_network_eq = .false. return @@ -538,7 +538,7 @@ subroutine terminal_connection_add_node(this, node) class(terminal_connection_t) :: this type(terminal_node_t) :: node type(terminal_node_t), dimension(:), allocatable :: newNodes - integer :: newNodesSize + integer(kind=4) :: newNodesSize if (.not. allocated(this%nodes)) allocate(this%nodes(0)) @@ -561,7 +561,7 @@ subroutine terminal_network_add_connection(this, connection) class(terminal_network_t) :: this type(terminal_connection_t) :: connection type(terminal_connection_t), dimension(:), allocatable :: newConnections - integer :: newConnectionsSize + integer(kind=4) :: newConnectionsSize if (.not. allocated(this%connections)) allocate(this%connections(0)) diff --git a/src_mtln/network.F90 b/src_mtln/network.F90 index c6721682..dcfdffb8 100644 --- a/src_mtln/network.F90 +++ b/src_mtln/network.F90 @@ -9,19 +9,19 @@ module network_m type nw_node_t character(len=:), allocatable :: name type(node_source_t) :: source - integer :: source_type + integer(kind=4) :: source_type real(kind=rkind) :: line_c_per_meter, line_g_per_meter real(kind=rkind) :: step real(kind=rkind), pointer :: v real(kind=rkind), pointer :: i - integer :: bundle_number, conductor_number, v_index, i_index - integer :: side + integer(kind=4) :: bundle_number, conductor_number, v_index, i_index + integer(kind=4) :: side logical :: open = .false. end type type, public :: network_t - integer :: number_of_nodes = 0 + integer(kind=4) :: number_of_nodes = 0 type(nw_node_t), dimension(:), allocatable :: nodes character(256), dimension(:), allocatable :: description contains @@ -37,7 +37,7 @@ module network_m integer function countNodes(connections) type(terminal_connection_t), dimension(:), allocatable :: connections - integer :: i + integer(kind=4) :: i countNodes = 0 do i = 1, size(connections) countNodes = countNodes + size(connections(i)%nodes) @@ -48,7 +48,7 @@ function networkCtor(nodes, description) result(res) type(nw_node_t), dimension(:), intent(in) :: nodes character(*), dimension(:), intent(in) :: description type(string_t), dimension(:), allocatable :: names - integer :: i + integer(kind=4) :: i type(network_t) :: res res%nodes = nodes diff --git a/src_mtln/network_manager.F90 b/src_mtln/network_manager.F90 index 6aa02b02..d7ea1984 100644 --- a/src_mtln/network_manager.F90 +++ b/src_mtln/network_manager.F90 @@ -13,7 +13,7 @@ module network_manager_m type(nw_node_t), allocatable :: open_nodes(:) real(kind=rkind) :: time, dt logical :: has_active_node = .false. - integer :: counter = 0 + integer(kind=4) :: counter = 0 contains procedure :: advanceVoltage => network_advanceVoltage @@ -46,7 +46,7 @@ subroutine appendToString_tArray(arr, str) function copy_node_names(networks) result(res) type(network_t), dimension(:), intent(in) :: networks type(string_t), dimension(:), allocatable :: res - integer :: i,j + integer(kind=4) :: i,j type(string_t) :: temp allocate(res(0)) do i = 1, size(networks) @@ -83,7 +83,7 @@ function network_managerCtor(networks, description, final_time, dt) result(res) function collectOpenNodes(nws) result(res) type(network_t), dimension(:), intent(in) :: nws - integer :: i, j, n + integer(kind=4) :: i, j, n type(nw_node_t), allocatable :: res(:) n = 0 do i = 1, size(nws) @@ -110,7 +110,7 @@ function collectOpenNodes(nws) result(res) subroutine updateNetworkVoltages(this) class(network_manager_t) :: this - integer :: i, j + integer(kind=4) :: i, j do i = 1, size(this%networks) do j = 1, this%networks(i)%number_of_nodes this%networks(i)%nodes(j)%v = this%circuit%getNodeVoltage(this%networks(i)%nodes(j)%name) @@ -121,7 +121,7 @@ subroutine updateNetworkVoltages(this) subroutine updateCircuitCurrentsFromNetwork(this) class(network_manager_t) :: this - integer :: i, j + integer(kind=4) :: i, j character(len=:), allocatable :: batch batch = '' do i = 1, size(this%networks) @@ -145,7 +145,7 @@ subroutine network_advanceVoltage(this) subroutine updateNetworkVoltagesFromCircuit(this) class(network_manager_t) :: this - integer :: i, j, idx + integer(kind=4) :: i, j, idx type(vectorInfo_t), pointer :: info type(c_ptr) :: info_ptr real(kind=c_double), pointer :: values(:) diff --git a/src_mtln/preprocess.F90 b/src_mtln/preprocess.F90 index 00c85cf5..acaaae83 100644 --- a/src_mtln/preprocess.F90 +++ b/src_mtln/preprocess.F90 @@ -10,12 +10,12 @@ module mtln_preprocess_m use json_string_utilities, only: lowercase_string implicit none - integer, parameter :: XPOS = 1 - integer, parameter :: XNEG = -1 - integer, parameter :: YPOS = 2 - integer, parameter :: YNEG = -2 - integer, parameter :: ZPOS = 3 - integer, parameter :: ZNEG = -3 + integer(kind=4), parameter :: XPOS = 1 + integer(kind=4), parameter :: XNEG = -1 + integer(kind=4), parameter :: YPOS = 2 + integer(kind=4), parameter :: YNEG = -2 + integer(kind=4), parameter :: ZPOS = 3 + integer(kind=4), parameter :: ZNEG = -3 type, public :: preprocess_t type(mtl_bundle_t), dimension(:), allocatable :: bundles @@ -119,8 +119,8 @@ function preprocess(parsed, alloc) result(res) function conductorsInLevel(line) result(res) type(transmission_line_bundle_t), intent(in) :: line - integer, dimension(:), allocatable :: res - integer :: i,j + integer(kind=4), dimension(:), allocatable :: res + integer(kind=4) :: i,j allocate(res(size(line%levels)), source = 0) do i = 1, size(line%levels) @@ -133,8 +133,8 @@ function conductorsInLevel(line) result(res) function findConductorsBeforeCable(name, level) result(res) character(len=*), intent(in) :: name type(transmission_line_level_t), intent(in) :: level - integer :: res - integer :: i + integer(kind=4) :: res + integer(kind=4) :: i res = 0 do i = 1, size(level%lines) if (level%lines(i)%name /= name) then @@ -148,8 +148,8 @@ function findConductorsBeforeCable(name, level) result(res) function findOuterConductorNumber(line, level, conductors_in_level) result(res) type(mtl_t), intent(in) :: line type(transmission_line_level_t), intent(in) :: level - integer, intent(in) :: conductors_in_level - integer :: res + integer(kind=4), intent(in) :: conductors_in_level + integer(kind=4) :: res res = findConductorsBeforeCable(line%parent_name, level) + & conductors_in_level + & line%conductor_in_parent @@ -158,9 +158,9 @@ function findOuterConductorNumber(line, level, conductors_in_level) result(res) function findInnerConductorRange(line, level, conductors_in_level) result(res) type(mtl_t), intent(in) :: line type(transmission_line_level_t), intent(in) :: level - integer, intent(in) :: conductors_in_level - integer, dimension(:), allocatable :: res - integer :: k + integer(kind=4), intent(in) :: conductors_in_level + integer(kind=4), dimension(:), allocatable :: res + integer(kind=4) :: k res = findConductorsBeforeCable(line%name, level) + & conductors_in_level + & [(k, k = 1, line%number_of_conductors)] @@ -170,12 +170,12 @@ function findInnerConductorRange(line, level, conductors_in_level) result(res) subroutine setBundleTransferImpedance(bundle, line) type(mtl_bundle_t), intent(inout) :: bundle type(transmission_line_bundle_t), intent(in) :: line - integer :: i,j,k, conductor_in_parent - integer, dimension(:), allocatable :: range_in - integer :: conductor_out + integer(kind=4) :: i,j,k, conductor_in_parent + integer(kind=4), dimension(:), allocatable :: range_in + integer(kind=4) :: conductor_out type(transfer_impedance_per_meter_t) :: zt - integer, dimension(:), allocatable :: conductors_in_level + integer(kind=4), dimension(:), allocatable :: conductors_in_level conductors_in_level = conductorsInLevel(line) bundle%conductors_in_level = conductors_in_level @@ -213,9 +213,9 @@ subroutine setBundleTransferImpedance(bundle, line) subroutine mapConductorsBeforeCable(conductors_before_cable, line) type(fhash_tbl_t), intent(inout) :: conductors_before_cable type(transmission_line_bundle_t), intent(in) :: line - integer, dimension(:), allocatable :: range_in - integer, dimension(:), allocatable :: conductors_in_level - integer :: i,j + integer(kind=4), dimension(:), allocatable :: range_in + integer(kind=4), dimension(:), allocatable :: conductors_in_level + integer(kind=4) :: i,j conductors_in_level = conductorsInLevel(line) call conductors_before_cable%set(key(line%levels(1)%lines(1)%name), 0) do i = 2, size(line%levels) @@ -236,7 +236,7 @@ function buildMTLBundles(this, lines) result(res) type(transmission_line_bundle_t), dimension(:), intent(in) :: lines type(mtl_bundle_t), dimension(:), allocatable :: res type(fhash_tbl_t) :: conductors_before_cable - integer :: i + integer(kind=4) :: i #ifdef CompileWithMPI integer(kind=4) :: ierr #endif @@ -266,7 +266,7 @@ function buildLineFromCable(cable, dt, layer_indices, bundle_in_layer, alloc_z) integer(kind=4), dimension(2), intent(in), optional :: alloc_z type(mtl_t) :: res - integer :: conductor_in_parent = 0 + integer(kind=4) :: conductor_in_parent = 0 character(len=:), allocatable :: parent_name select type(cable) @@ -314,7 +314,7 @@ function buildLineFromCable(cable, dt, layer_indices, bundle_in_layer, alloc_z) subroutine addInitialConnector(line, connector) type(mtl_t), intent(inout) :: line type(connector_t) :: connector - integer :: i + integer(kind=4) :: i do i = 1, line%number_of_conductors line%rpul(1, i, i) = connector%resistances(i)/line%du(1, i, i) end do @@ -325,7 +325,7 @@ subroutine addInitialConnector(line, connector) subroutine addEndConnector(line, connector) type(mtl_t), intent(inout) :: line type(connector_t) :: connector - integer :: i + integer(kind=4) :: i do i = 1, line%number_of_conductors line%rpul(size(line%du,1), i, i) = connector%resistances(i)/line%du(size(line%du,1), i, i) end do @@ -340,8 +340,8 @@ function buildLineBundles(cable_bundles, dt, alloc) result(res) type(transmission_line_bundle_t), dimension(:), allocatable :: res real(kind=RKIND_TIEMPO), intent(in) :: dt type(XYZlimit_t), dimension(1:6), intent(in), optional :: alloc - integer :: i, j, k - integer :: nb, nl, nc + integer(kind=4) :: i, j, k + integer(kind=4) :: nb, nl, nc integer(kind=4), allocatable, dimension(:,:) :: layer_indices logical :: bundle_in_layer = .false. integer(kind=4), dimension(2) :: alloc_z @@ -360,7 +360,6 @@ function buildLineBundles(cable_bundles, dt, alloc) result(res) else allocate(layer_indices(0,2), source = 0) end if - ! if (layer_indices(1,1) == layer_indices(1,2) ) bundle_in_layer = .false. end if nl = size(cable_bundles(i)%levels) allocate(res(i)%levels(nl)) @@ -381,7 +380,7 @@ function buildLineBundles(cable_bundles, dt, alloc) result(res) logical function isBundleInLayer(cable, alloc_z) integer(kind=4), dimension(2), intent(in) :: alloc_z class (cable_t), pointer, intent(in) :: cable - integer :: n, i + integer(kind=4) :: n, i logical :: in_layer in_layer = .false. n = 0 @@ -405,7 +404,7 @@ function findIndicesInLayer(cable, alloc_z) result(res) integer(kind=4), dimension(2), intent(in) :: alloc_z class (cable_t), pointer, intent(in) :: cable integer(kind=4), allocatable, dimension(:,:) :: res - integer :: n, i, direction, position(1:3) + integer(kind=4) :: n, i, direction, position(1:3) logical :: in_layer in_layer = .false. ! precount @@ -449,7 +448,7 @@ function findIndicesInLayer(cable, alloc_z) result(res) logical function isSegmentWithinAllocBox(segs, i, z) type(segment_t), intent(in), dimension(:), allocatable :: segs type(segment_t) :: prev - integer :: i + integer(kind=4) :: i integer(kind=4), dimension(2), intent(in) :: z isSegmentWithinAllocBox = (segs(i)%z >= z(1)) .and. (segs(i)%z <= z(2)) end function @@ -493,8 +492,8 @@ integer function findNextLevel(curr_level, cs) type(cable_abstract_t), dimension(:), intent(in) :: cs type(cable_level_t) :: next_level class(cable_t), pointer :: ptr - integer :: i,j, next_level_size - integer :: n + integer(kind=4) :: i,j, next_level_size + integer(kind=4) :: n next_level_size = 0 do i = 1, size(curr_level%cables) do j = 1, size(cs) @@ -532,8 +531,8 @@ function findParentCables(cables) result(res) type(cable_abstract_t), dimension(:), intent(in) :: cables type(cable_abstract_t), dimension(:), allocatable :: res class(cable_t), pointer :: ptr - integer :: i - integer, dimension(:), allocatable :: parent_ids + integer(kind=4) :: i + integer(kind=4), dimension(:), allocatable :: parent_ids #ifdef CompileWithMPI integer(kind=4) :: ierr #endif @@ -565,7 +564,7 @@ function buildCableBundles(cables) result(cable_bundles) type(cable_abstract_t), dimension(:), intent(in) :: cables type(cable_abstract_t), dimension(:), allocatable :: parents type(cable_bundle_t), dimension(:), allocatable :: cable_bundles - integer :: i + integer(kind=4) :: i parents = findParentCables(cables) allocate(cable_bundles(size(parents))) @@ -579,7 +578,7 @@ function mapCablesToBundlesId(lines, bundles) result(res) type(transmission_line_bundle_t), dimension(:), allocatable :: lines type(mtl_bundle_t), dimension(:), allocatable :: bundles type(fhash_tbl_t) :: res - integer :: i, j, k + integer(kind=4) :: i, j, k do i = 1, size(lines) do j = 1, size(lines(i)%levels) @@ -595,7 +594,7 @@ function mapCablesToBundles(lines, bundles) result(res) type(transmission_line_bundle_t), dimension(:), allocatable :: lines type(mtl_bundle_t), dimension(:), allocatable :: bundles type(fhash_tbl_t) :: res - integer :: i, j, k + integer(kind=4) :: i, j, k do i = 1, size(lines) do j = 1, size(lines(i)%levels) @@ -1131,11 +1130,11 @@ function writeXsYZpnode(node, termination, end_node, XYZ) result(res) function addNodeWithId(this, node) result(res) class(preprocess_t) :: this type(terminal_node_t) :: node - integer :: stat - integer :: d + integer(kind=4) :: stat + integer(kind=4) :: d type(nw_node_t) :: res character(len=4) :: sConductor - integer :: conductor_number + integer(kind=4) :: conductor_number call this%conductors_before_cable%get(key(node%belongs_to_cable%name), conductor_number) conductor_number = conductor_number + node%conductor_in_cable @@ -1151,7 +1150,7 @@ function addNodeWithId(this, node) result(res) res%conductor_number = conductor_number block - integer :: v_index, i_index + integer(kind=4) :: v_index, i_index real(kind=rkind) :: line_c_per_meter, line_g_per_meter, step if (node%side == TERMINAL_NODE_SIDE_INI) then v_index = lbound(this%bundles(d)%v,2) @@ -1182,7 +1181,7 @@ function addNodeWithId(this, node) result(res) contains function nodeSideToString(side) result(cSide) character(len=:), allocatable :: cSide - integer, intent(in) :: side + integer(kind=4), intent(in) :: side select case (side) case (TERMINAL_NODE_SIDE_INI) cSide = "initial" @@ -1229,7 +1228,7 @@ subroutine connectNodesToNetworkCircuit(this, terminal_connection, nodes, descri character(len=256) :: network_circuit_node, str_term type(nw_node_t) :: new_node - integer :: i + integer(kind=4) :: i aux_nodes = nodes deallocate(nodes) @@ -1269,7 +1268,7 @@ subroutine connectNodes(this, terminal_connection, nodes, description) character(256), dimension(:), allocatable :: node_description, old_description type(nw_node_t) :: new_node - integer :: i + integer(kind=4) :: i character(len=256) :: interior_node character(len=256) :: buff @@ -1308,7 +1307,7 @@ function buildNetwork(this,terminal_network) result(res) character(256), dimension(:), allocatable :: description character(256), dimension(:), allocatable :: listOfModels type(network_t) :: res - integer :: i + integer(kind=4) :: i type(terminal_connection_t), dimension(:), allocatable :: network_circuit_connections, node2node_connections call filterConnections(terminal_network%connections, network_circuit_connections, node2node_connections) @@ -1342,7 +1341,7 @@ function isModelIncluded(model, listOfModels) result (res) character(256), dimension(:), intent(in) :: listOfModels character(*) :: model logical :: res - integer :: i + integer(kind=4) :: i if (size(listOfModels) == 0) then res = .false. return @@ -1363,7 +1362,7 @@ subroutine addCircuitInstance(description, network_circuit) character(:), allocatable :: ports character(10) :: str_term - integer :: i + integer(kind=4) :: i ports = " " do i = 1, network_circuit%number_of_nodes @@ -1384,7 +1383,7 @@ subroutine addCircuitModel(description, network_circuit, listOfModels) character(:), allocatable :: ports character(10) :: str_term - integer :: i + integer(kind=4) :: i buff = trim(network_circuit%model_file) if (isModelIncluded(buff, listOfModels)) return @@ -1399,7 +1398,7 @@ subroutine addCircuitModel(description, network_circuit, listOfModels) subroutine filterConnections(all_conn, subckt_conn, node_conn) type(terminal_connection_t), dimension(:), intent(in) :: all_conn type(terminal_connection_t), dimension(:), allocatable, intent(inout) :: subckt_conn, node_conn - integer :: i, j, subckt_size, node_size, numberOfNodes, numberOfCktNodes + integer(kind=4) :: i, j, subckt_size, node_size, numberOfNodes, numberOfCktNodes logical :: is_ckt subckt_size = 0 @@ -1447,7 +1446,7 @@ subroutine endDescription(description) subroutine addNetworksDescription(description, networks) character(256), dimension(:), allocatable, intent(inout) :: description type(network_t), dimension(:), intent(in) :: networks - integer :: i,j + integer(kind=4) :: i,j character(256) :: buff do i = 1, size(networks) do j = 1, size(networks(i)%description) @@ -1462,7 +1461,7 @@ subroutine addAnalysis(description, final_time, dt, print_step) character(256) :: buff real(kind=RKIND_TIEMPO), intent(in) :: final_time, dt character(30) :: sTime, sdt, sDelta, sPrint - integer, intent(in) :: print_step + integer(kind=4), intent(in) :: print_step write(sTime, '(E10.2)') final_time write(sdt, '(E10.2)') dt @@ -1480,7 +1479,7 @@ subroutine addSavedNodes(description, networks) character(256) :: buff type(network_t), dimension(:), intent(in) :: networks character(len=:), allocatable :: saved_nodes - integer :: i,j + integer(kind=4) :: i,j do j = 1, size(networks) do i = 1, size(networks(j)%nodes) saved_nodes = ".save V1"//trim(networks(j)%nodes(i)%name)//"#branch " @@ -1501,11 +1500,11 @@ function buildNetworkManager(this, terminal_networks) result(res) type(network_manager_t) :: res character(256), dimension(:), allocatable :: description character(256) :: buff - integer :: i, n + integer(kind=4) :: i, n logical, dimension(:), allocatable :: network_in_MPIslice #ifdef CompileWithMPI - integer :: j,k,d, stat + integer(kind=4) :: j,k,d, stat #endif allocate(network_in_MPIslice(size(terminal_networks)), source = .true.) n = size(terminal_networks) @@ -1554,7 +1553,7 @@ function buildNetworkManager(this, terminal_networks) result(res) subroutine addGenerators(this, parsed_generators) class(preprocess_t) :: this type(parsed_generator_t), dimension(:), allocatable :: parsed_generators - integer :: i, d, stat, n + integer(kind=4) :: i, d, stat, n do i = 1, size(parsed_generators) call this%cable_name_to_bundle_id%get(key = key(parsed_generators(i)%attached_to_cable%name), & @@ -1579,7 +1578,7 @@ subroutine addGenerators(this, parsed_generators) subroutine addProbesWithId(this, parsed_probes) class(preprocess_t) :: this type(parsed_probe_t), dimension(:), allocatable :: parsed_probes - integer :: i, d, stat + integer(kind=4) :: i, d, stat type(mtl_bundle_t), target :: tbundle character(len=:), allocatable :: probe_name diff --git a/src_mtln/probes.F90 b/src_mtln/probes.F90 index 3776ec6d..b28b0839 100644 --- a/src_mtln/probes.F90 +++ b/src_mtln/probes.F90 @@ -80,7 +80,7 @@ function probeCtor(index, probe_type, dt, name, position, layer_indices) result( do i = 1, slice - 1 layer_index = layer_index + layer_indices(i,2) + 1 - (layer_indices(i,1) - 1) end do - layer_index = layer_index + res%index - layer_indices(i,1) + 1 + layer_index = layer_index + res%index - layer_indices(slice,1) + 1 end if res%index = layer_index end if diff --git a/src_wires_pub/wires_mtln.F90 b/src_wires_pub/wires_mtln.F90 index 6988fe7c..e54ddd28 100644 --- a/src_wires_pub/wires_mtln.F90 +++ b/src_wires_pub/wires_mtln.F90 @@ -87,6 +87,10 @@ subroutine pointSegmentsToFields() do m = 1, mtln_solver%number_of_bundles if (mtln_solver%bundles(m)%bundle_in_layer) then do n = 1, ubound(mtln_solver%bundles(m)%external_field_segments,1) + ! Synthetic layer-junction "gap" segments carry an out-of-range + ! direction (see SEGMENT_GAP_ORIENTATION in mtl_m) and do not + ! correspond to a real field point; they must be skipped here. + if (abs(mtln_solver%bundles(m)%external_field_segments(n)%direction) > 3) cycle call readGridIndices(i, j, k, mtln_solver%bundles(m)%external_field_segments(n)) select case (abs(mtln_solver%bundles(m)%external_field_segments(n)%direction)) case(DIRECTION_X_POS) @@ -136,6 +140,9 @@ subroutine AdvanceWiresE_mtln(sgg,Idxh, Idyh, Idzh, eps00,mu00) do m = 1, mtln_solver%number_of_bundles if (mtln_solver%bundles(m)%bundle_in_layer) then do n = 1, ubound(mtln_solver%bundles(m)%external_field_segments,1) + ! Skip synthetic layer-junction "gap" segments: their field + ! pointer is never associated (see pointSegmentsToFields above). + if (abs(mtln_solver%bundles(m)%external_field_segments(n)%direction) > 3) cycle punt => mtln_solver%bundles(m)%external_field_segments(n)%field punt = real(punt, kind=rkind_wires) - computeFieldFromCurrent(m,n) end do From e1c618e210922c982da34d299d84b84efbd313d6 Mon Sep 17 00:00:00 2001 From: Alberto-o Date: Mon, 21 Sep 2026 11:36:34 +0200 Subject: [PATCH 4/6] Adds function to check whether arrays can be compared --- test/pyWrapper/test_full_system.py | 23 ++++++++++++++++++++++- test/utils/utils.py | 8 ++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/test/pyWrapper/test_full_system.py b/test/pyWrapper/test_full_system.py index c9f15b8c..62d4b648 100644 --- a/test/pyWrapper/test_full_system.py +++ b/test/pyWrapper/test_full_system.py @@ -101,6 +101,9 @@ def generate_debug_data(): if is_debugging(): generate_debug_data() + check_values_are_comparable(solved_value) + check_values_are_comparable(expected_value) + assert np.allclose( solved_value, expected_value, @@ -144,18 +147,21 @@ def test_shieldedPair(tmp_path): p_solved[i]["time"].to_numpy(), p_solved[i]["voltage_0"].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected[i]["voltage_0"])[0, 1] > 0.999 solved = np.interp( p_expected[i]["time"].to_numpy(), p_solved[i]["time"].to_numpy(), p_solved[i]["voltage_1"].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected[i]["voltage_1"])[0, 1] > 0.999 solved = np.interp( p_expected[i]["time"].to_numpy(), p_solved[i]["time"].to_numpy(), p_solved[i]["voltage_2"].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected[i]["voltage_2"])[0, 1] > 0.999 for i in [1, 2]: solved = np.interp( @@ -163,18 +169,21 @@ def test_shieldedPair(tmp_path): p_solved[i]["time"].to_numpy(), p_solved[i]["current_0"].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected[i]["current_0"])[0, 1] > 0.999 solved = np.interp( p_expected[i]["time"].to_numpy(), p_solved[i]["time"].to_numpy(), p_solved[i]["current_1"].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected[i]["current_1"])[0, 1] > 0.999 solved = np.interp( p_expected[i]["time"].to_numpy(), p_solved[i]["time"].to_numpy(), p_solved[i]["current_2"].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected[i]["current_2"])[0, 1] > 0.999 @@ -218,6 +227,7 @@ def test_coated_antenna(tmp_path): p_solved["time"].to_numpy(), p_solved["current_0"].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected["current_0"])[0, 1] > 0.999 @@ -241,6 +251,7 @@ def test_holland(tmp_path): expected_i = np.append(expected_i, float(data["value"][1])) expected_i_interp = np.interp(p["time"] - 3.05 * 1e-9, expected_t, expected_i) + check_values_are_comparable(expected_i_interp) assert np.allclose(expected_i_interp, p["current"], rtol=1e-4, atol=5e-5) @@ -273,6 +284,9 @@ def test_holland_short_terminals_match_open_terminals(tmp_path): probe_short = Probe(_get_solved_probe_folder(solver_short, "mid_point")) + check_values_are_comparable(probe_open["current"].to_numpy()) + check_values_are_comparable(probe_short["current"].to_numpy()) + assert np.allclose( probe_open["time"].to_numpy(), probe_short["time"].to_numpy(), @@ -311,6 +325,7 @@ def test_unshielded_multiwires(tmp_path): p_solved["time"].to_numpy(), p_solved[current].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected[current])[0, 1] > 0.999 @@ -341,6 +356,7 @@ def test_towelHanger(tmp_path): p_solved[i]["time"].to_numpy(), p_solved[i]["current_0"].to_numpy(), ) + check_values_are_comparable(solved) assert np.corrcoef(solved, p_expected[i]["current_0"])[0, 1] > 0.999 @@ -365,7 +381,7 @@ def generate_debug_data(): CASES_FOLDER + "towel_rack_with_shorting_plane/towel_rack_with_shorting_plane.fdtd.json" ) - setNgspice(tmp_path) + # setNgspice(tmp_path) # --- excitation --- dt = 1e-12 @@ -381,6 +397,7 @@ def generate_debug_data(): # --- with shorting plane --- folder_with = os.path.join(tmp_path, "with_shorting_plane") os.makedirs(folder_with) + setNgspice(folder_with) solver_w = FDTD(input_filename=fn, path_to_exe=SEMBA_EXE, run_in_folder=folder_with) solver_w.run() @@ -393,6 +410,7 @@ def generate_debug_data(): # --- without shorting plane --- folder_without = os.path.join(tmp_path, "without_shorting_plane") os.makedirs(folder_without) + setNgspice(folder_without) solver_wo = FDTD( input_filename=fn, path_to_exe=SEMBA_EXE, run_in_folder=folder_without ) @@ -408,6 +426,9 @@ def generate_debug_data(): if is_debugging(): generate_debug_data() + check_values_are_comparable(Z_in_w[freqs < 1e6]) + check_values_are_comparable(Z_in_wo[freqs < 1e6]) + # Expect the shorting plane not changing the impedance at low frequencies. assert np.allclose( np.abs(Z_in_w[freqs < 1e6]), np.abs(Z_in_wo[freqs < 1e6]), rtol=0.1 diff --git a/test/utils/utils.py b/test/utils/utils.py index f6efa799..a3165b57 100644 --- a/test/utils/utils.py +++ b/test/utils/utils.py @@ -208,3 +208,11 @@ def corrcoef_on_common_time(t_ref, y_ref, t_cmp, y_cmp): y_ref_common = y_ref[mask] y_cmp_interp = np.interp(t_common, t_cmp, y_cmp) return np.corrcoef(y_ref_common, y_cmp_interp)[0, 1] + +def check_values_are_comparable(arr): + if (np.any(np.isnan(arr)) == True or + np.any(np.isinf(arr)) == True or + np.all(arr == 0.0) == True): + assert False + else: + assert True From 96a8c36bf001e5e6fb2457855d4187ae91ca8a03 Mon Sep 17 00:00:00 2001 From: Alberto-o Date: Mon, 21 Sep 2026 14:18:50 +0200 Subject: [PATCH 5/6] Tests using codemodels are currently not run in windows. Tests using spice now use codemodels for sources. Tagging them so they will be skipped --- test/pyWrapper/test_full_system.py | 10 +++++++++- test/pyWrapper/test_full_system_mpi.py | 2 ++ test/pyWrapper/test_mtln_standalone.py | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/test/pyWrapper/test_full_system.py b/test/pyWrapper/test_full_system.py index 62d4b648..f205c836 100644 --- a/test/pyWrapper/test_full_system.py +++ b/test/pyWrapper/test_full_system.py @@ -192,6 +192,7 @@ def test_shieldedPair(tmp_path): @pytest.mark.wires @pytest.mark.dielectric @pytest.mark.probes +@pytest.mark.codemodel def test_coated_antenna(tmp_path): """Test for a coated antenna with MTLN wires reproducing Fig. 2 in: A. Rubio Bretones, R. Gomez Martin, A. Salinas and I. Sanchez, @@ -331,6 +332,8 @@ def test_unshielded_multiwires(tmp_path): @pytest.mark.wires @pytest.mark.probes +@pytest.mark.codemodel +@pytest.mark.codemodel def test_towelHanger(tmp_path): """Verify towel-hanger wire currents match the stored reference probes.""" setNgspice(tmp_path) @@ -381,7 +384,6 @@ def generate_debug_data(): CASES_FOLDER + "towel_rack_with_shorting_plane/towel_rack_with_shorting_plane.fdtd.json" ) - # setNgspice(tmp_path) # --- excitation --- dt = 1e-12 @@ -893,6 +895,7 @@ def test_current_orientation(tmp_path): @pytest.mark.sgbc @pytest.mark.wires @pytest.mark.probes +@pytest.mark.codemodel def test_sgbc_structured_resistance_single_wire(tmp_path): """Verify structured SGBC resistance produces the expected wire current.""" fn = CASES_FOLDER + "sgbcResistance/sgbcResistance.fdtd.json" @@ -911,6 +914,7 @@ def test_sgbc_structured_resistance_single_wire(tmp_path): # compiled with mtln, wire is treated as an unshielded multiwire @pytest.mark.sgbc @pytest.mark.probes +@pytest.mark.codemodel def test_pec_overlapping_sgbcs(tmp_path): """Test that PEC surfaces overlapping SGBC surfaces prioritize PEC.""" def generate_debug_data(): @@ -950,6 +954,7 @@ def generate_debug_data(): # compiled with mtln, wire is treated as an unshielded multiwire @pytest.mark.sgbc @pytest.mark.probes +@pytest.mark.codemodel def test_sgbc_overlapping_sgbc(tmp_path): """Test that SGBC surfaces overlapping SGBC surfaces prioritize first in MatAss.""" def generate_debug_data(): @@ -1921,6 +1926,7 @@ def test_bulk_current_four_probes_Z_oriented(tmp_path): @pytest.mark.conformal @pytest.mark.wires @pytest.mark.probes +@pytest.mark.codemodel def test_conformal_impedance_cylinder_unshielded(tmp_path): """Verify conformal-cylinder impedance matches the reference spectrum.""" setNgspice(tmp_path) @@ -2003,6 +2009,7 @@ def test_conformal_sphere_rcs(tmp_path): @pytest.mark.conformal @pytest.mark.probes +@pytest.mark.codemodel def test_conformal_delay(tmp_path): """Verify conformal geometry produces the expected propagation delay.""" setNgspice(tmp_path) @@ -2078,6 +2085,7 @@ def test_current_generators_with_resistance(tmp_path): @pytest.mark.wires @pytest.mark.nodal_source @pytest.mark.probes +@pytest.mark.codemodel def test_current_generators_without_resistance(tmp_path): """Verify ideal-wire current-source sign and magnitude at each position.""" # Checks current probes at the extremes of a wire diff --git a/test/pyWrapper/test_full_system_mpi.py b/test/pyWrapper/test_full_system_mpi.py index e5e90733..52caf544 100644 --- a/test/pyWrapper/test_full_system_mpi.py +++ b/test/pyWrapper/test_full_system_mpi.py @@ -163,6 +163,8 @@ def test_holland_mtln_mpi(tmp_path): @pytest.mark.mpi @pytest.mark.wires @pytest.mark.probes +@pytest.mark.codemodel +@pytest.mark.codemodel def test_towelHanger_mpi(tmp_path): fn = CASES_FOLDER + "towelHanger/towelHanger_mpi.fdtd.json" setNgspice(tmp_path) diff --git a/test/pyWrapper/test_mtln_standalone.py b/test/pyWrapper/test_mtln_standalone.py index 37c3e910..ff71309d 100644 --- a/test/pyWrapper/test_mtln_standalone.py +++ b/test/pyWrapper/test_mtln_standalone.py @@ -9,6 +9,7 @@ @pytest.mark.wires @pytest.mark.multiwire @pytest.mark.probes +@pytest.mark.codemodel def test_paul_8_6_square(tmp_path): fn = CASES_FOLDER + "paul/paul_8_6_square.fdtd.json" setNgspice(tmp_path) @@ -40,6 +41,7 @@ def test_paul_8_6_square(tmp_path): @pytest.mark.wires @pytest.mark.multiwire @pytest.mark.probes +@pytest.mark.codemodel def test_paul_8_6_triangle(tmp_path): fn = CASES_FOLDER + "paul/paul_8_6_triangle.fdtd.json" setNgspice(tmp_path) @@ -69,6 +71,7 @@ def test_paul_8_6_triangle(tmp_path): @pytest.mark.wires @pytest.mark.multiwire @pytest.mark.probes +@pytest.mark.codemodel def test_paul_9_6(tmp_path): fn = CASES_FOLDER + "paul/paul_9_6.fdtd.json" setNgspice(tmp_path) @@ -108,6 +111,7 @@ def test_paul_9_6(tmp_path): @pytest.mark.wires @pytest.mark.multiwire @pytest.mark.probes +@pytest.mark.codemodel def test_spice_multilines_opamp(tmp_path): fn = CASES_FOLDER + "multilines_opamp/multilines_opamp.fdtd.json" setNgspice(tmp_path) @@ -136,6 +140,7 @@ def test_spice_multilines_opamp(tmp_path): @pytest.mark.spice @pytest.mark.wires @pytest.mark.probes +@pytest.mark.codemodel def test_spice_connectors_diode(tmp_path): fn = CASES_FOLDER + "spice_connectors/spice_connectors.fdtd.json" setNgspice(tmp_path) @@ -168,6 +173,7 @@ def test_spice_connectors_diode(tmp_path): @pytest.mark.wires @pytest.mark.multiwire @pytest.mark.probes +@pytest.mark.codemodel def test_line_multiline_junction(tmp_path): fn = CASES_FOLDER + "line_multiline_junction/line_multiline_junction.fdtd.json" setNgspice(tmp_path) @@ -226,6 +232,7 @@ def test_spice_opamp_saturation(tmp_path): @pytest.mark.spice @pytest.mark.wires @pytest.mark.probes +@pytest.mark.codemodel def test_spice_zener(tmp_path): fn = CASES_FOLDER + "zener/zener.fdtd.json" setNgspice(tmp_path) From fce0a12d270b68f6106a5ca1ad22a1c3f9a162d1 Mon Sep 17 00:00:00 2001 From: Alberto-o Date: Mon, 21 Sep 2026 15:50:46 +0200 Subject: [PATCH 6/6] Adds missing codemodel tag --- test/pyWrapper/test_full_system.py | 1 + 1 file changed, 1 insertion(+) diff --git a/test/pyWrapper/test_full_system.py b/test/pyWrapper/test_full_system.py index f205c836..42bbbbd5 100644 --- a/test/pyWrapper/test_full_system.py +++ b/test/pyWrapper/test_full_system.py @@ -366,6 +366,7 @@ def test_towelHanger(tmp_path): @pytest.mark.wires @pytest.mark.termination @pytest.mark.probes +@pytest.mark.codemodel def test_towel_rack_with_and_without_shorting_plane(tmp_path): """Verify a shorting plane leaves low-frequency input impedance unchanged.""" def generate_debug_data():