C********************************************************************** C rtc_main.f nstx power supply real time control program C C REVISONS: C -------- C 04/28/04 t.gibney Eliminate CHI-specific code. C 07/28/03 t.gibney Change from double-precision to single-precision. C 05/25/00 t.gibney Remove structure refs, compatible with gnu fortran. C 02/18/99 t.gibney Create separate, much smaller main program in C separate file rtc_main.f. C C********************************************************************** IMPLICIT NONE !Include and common: !------------------ include 'rtcdef.inc' include 'nstx_savedata.inc' include 'pcs_common.inc' include 'iboc_override.inc' !External defs !------------- integer clearPcsCommon integer clearRtcConfig integer connecttohost integer nonblanklen !Local variables: !--------------- REAL*4 t !!! volatile t common /force_alignment/ t integer n,nidx character*20 arg character*20 argIbocStby,argIbocPulse !Format statements !----------------- 101 format(/'*EXIT* illegal parameter ',A,/) 102 format(/'*EXIT* usage is -iboc [standbyVal] [pulseValue]',/) 103 format(/' ibocStbyOverride=',F6.3,' ibocPulseOverride=',F6.3) 104 format(/'Options: ',A,/) !Executable code !--------------- !Process command-line arguments !..0th arg is program name - always present !..1st "real" arg is optional '-pcs' flag !----------------------------------------------- call getarg(0,arg) ! 0th arg call set_pgmname(arg) n = connecttohost() n = clearPcsCommon() !Map and clear pcs_common n = clearRtcConfig() !Map and clear rtcConfig structure npcsTest = .FALSE. nidx = 0 do while(.TRUE.) nidx = nidx+1 call getarg(nidx,arg) ! "nidx"th arg (optional) n = nonblanklen(arg) if (n .eq. 0) then goto 200 else if (arg(1:n) .eq. '-nct') then !NCSX coil test write(6,104) arg(1:n) nctFlag = .TRUE. else if (arg(1:n) .eq. '-pcs') then !Get request voltages from pcs_common write(6,104) arg(1:n) npcsFlag = .TRUE. else if (arg(1:n) .eq. '-pcstest') then !Write to pcs_common even though we don't ! take input from the pcs write(6,104) arg(1:n) npcsFlag = .FALSE. npcsTest = .TRUE. call plasmacontrol_init else if (arg(1:n) .eq. '-iboc') then call getarg(nidx+1,argIbocStby) !iboc: standby call getarg(nidx+2,argIbocPulse) !iboc: pulse if (argIbocPulse(1:1) .eq. ' ') then write(6,102) call pscExit(0, & '*ERR* usage is -iboc [standbyVal] [pulseValue]') endif read(argIbocStby,*) ibocStbyOverride read(argIbocPulse,*) ibocPulseOverride niboc = 1 write(6,103) ibocStbyOverride,ibocPulseOverride nidx = nidx+2 else write(6,101) arg call pscExit(0,'*ERR* illegal parameter') endif enddo 200 continue !..out of "arg" loop !Initialize Fortran COMMON from input files !---------------------------------------------- call profile_clear !in case we're doing timing tests call rtc_init if (npcsFlag .OR. npcsTest) then call newCycle_init !1st-time mapping of shared memory endif !!! call chiarc_init !Init for chi arc test ... C C store initial antiparallel blocking data C call reset_standby !reset values, start outdat C C time step loop ////////////////////////////////////////////// C newCycle = .TRUE. !set to FALSE at end of main loop nstep = 0 !nstx_savedata: count of data timesteps nfcount=0 !fault counter do while (.TRUE.) IF (nsubmode.EQ.1) THEN !.. simulation sub mode if (t.ge.15.0) then newCycle = .TRUE. nstep = 0 !nstx_savedata: initialize endif ENDIF if (npulse.eq.1) > call profile_update(1,'main: before indat') CALL indat(t) !reads either real or simulated data if (npulse.eq.1) > call profile_update(9,'main: after indat') if (newCycle) then call newCycle_init endif call rtc_timestep(t) newCycle = .FALSE. enddo END *********************************************************************** SUBROUTINE newCycle_init *********************************************************************** IMPLICIT NONE !Include and common: !------------------ include 'rtcdef.inc' include 'pcs_common.inc' npulse = 0 nerracq = 0 if (npcsFlag) then call plasmacontrol_init if (nmode.eq.0) npcon = 1 write(6,106) npcon 106 format(' npcon =',I2) endif return END *********************************************************************** SUBROUTINE fortran_string(text) *********************************************************************** implicit none character*(*) text write(6,101) text 101 format(A) return end