! module init_module implicit none ! ! Initialize and store model non-input variables and constants: ! ! istep: the current time step index. istep is initialized ! to 0, then incremented before each time step (see advance.f). ! integer :: istep ! time step index ! ! iter (iteration number): the number of timesteps (at the current ! step length) from model time 0,0,0 to current model time (day,hour,min). ! integer :: iter ! ! iyear and iday represent the current model calendar date ! (iyear is 4-digit). Uthr is current decimal hours. These ! are updated per timestep in advnce. ! integer :: iyear ! Current model calendar 4-digit year integer :: iday ! Current model calendar day real :: uthr ! Current ut (decimal hours) ! ! getgpi flag must go here rather than in gpi_mod to avoid circular ! module dependency with nchist_mod and init_mod. ! integer :: igetgpi ! 0/1 flag to get GPI data (see gpi_ncfile ! in input_mod.f. Set in init_mod.f) ! character(len=16) :: | host, ! host machine | system, ! operating system of host (from pre-proc macros) | logname ! user login name character(len=8) :: | rundate, ! current local date of run | runtime ! current local time of run ! ! Secs is updated in advnce, and is referenced in opflux, settei, ! sun, and chapmn. real :: | secs, ! current ut in seconds | p0, ! standard pressure | sfeps ! solar output change due to orbital eccentricity ! | alfalp,efluxlp ! low-energy protons in aurora ! contains !----------------------------------------------------------------------- subroutine init ! ! Initialize (this is called by tgcm.F after input): ! Some init also takes place in inp_model (input_mod.f) ! See also con.f and cons.h. ! use input_module,only: start,step,secflds,secfmag,date,calday, | gpi_ncfile,mxhist_prim,mxhist_sech,output,secout,mkhvols use hist_module,only: hist_init,isechist,nsecfmag,nsecfgeo, | nstep,nhist_total,nsech_total,nsource,nseries,nseries_sech, | nfiles_prim,nfiles_sech use fields_module,only: set_fprog,set_fsech,set_fsechmag, | fsech,fsechmag include "params.h" include "fgcom.h" ! ixtimep,c ! ! External: integer,external :: mtime_to_nstep ! ! Local: real :: pi,theta0 integer :: i,nfsech ! pi = 4.*atan(1.) ! ! Get login name: logname = ' ' call getenv('LOGNAME',logname) if (len_trim(logname)==0) then write(6,"(/,'>>> init: Cannot get LOGNAME environment ', | 'variable.',/)") stop 'LOGNAME' endif ! ! Get host name: call gethostsname(host) ! ! Operating system (based on pre-proc macro): call setosys(system) ! ! Get run date (current date and time): call datetime(rundate,runtime) ! ! Iter is the number of time steps from 0,0,0 to the curent model ! time, using the current step length. Iter is incremented once per ! timestep in advnce. ! iter = mtime_to_nstep(start(:,1),step) ! ! iyear and iday are current calendar year and day. ! If calday > 0, the model is advanced in calendar time, starting ! at day calday. If calday==0, model is NOT advanced in calendar ! time and the calendar day is date(2) throughout the run. ! iyear and iday are incremented in advnce if the model is ! advancing in calendar time. ! iyear = date(1) iday = date(2) sfeps = 1. ! ! Model is being advanced in calendar time: if (calday > 0) then iday = calday theta0 = 2.*pi*float(iday)/365. sfeps = 1.000110+0.034221*cos(theta0)+0.001280*sin(theta0)+ | 0.000719*cos(2.*theta0)+0.000077*sin(2.*theta0) endif ! ! 2/00: these were in modsrc.snoe (tgcm13mt), but were unused. ! Low-energy protons: ! alfalp = 10. ! efluxlp = 1.e-20 ! ! Set GPI flag: igetgpi = 0 if (len_trim(gpi_ncfile) > 0) igetgpi = 1 if (igetgpi > 0) | write(6,"(' gpi_ncfile = ',a)") trim(gpi_ncfile) ! ! ixtimep is 4th dimension index to fg-array for previous time step ! ixtimec is 4th dimension index to fg-array for current time step ! (see fogcm.f) ! ixtimep = 1 ixtimec = 1 ! ! Initialize amie, and get amie file if necessary: call init_amie ! ! Initialize non-input history variables for beginning of run: call hist_init ! ! Initialize prognostic fields type: ! (sub set_fprog is in flds_mod.f) call set_fprog ! ! Initialize secondary history fields type: ! Sub set_fsech (flds_mod.f) for fields on geographic grid. ! Sub set_fsechmag (flds_mod.f) for fields on magnetic grid. ! nsecfmag (hist_mod.f), is number of requested magnetic fields, ! and was set by hist_init, called above. ! if (isechist > 0) then call set_fsech(secflds,nfsech) call set_fsechmag(secfmag) endif ! ! Report to stdout: write(6,"(/,'Model run initialization:')") write(6,"(' nstep = ',i6,4x, | '(Number of time steps this run)')") nstep write(6,"(' iter = ',i6,4x, | '(Initial iteration number)')") iter write(6,"(' iyear = ',i6,4x, | '(Beginning calendar year)')") iyear write(6,"(' iday = ',i6,4x, | '(Beginning calendar day)')") iday write(6,"(' igetgpi = ',i6,4x, | '(Geophysical indices will be used if > 0)')") igetgpi ! ! Report re primary histories to stdout: write(6,"(/,'Primary Histories:')") write(6,"(' nsource = ',i5,2x, | '(If > 0, a primary source history was provided)')") nsource write(6,"(' nseries = ',i5,2x, | '(Number of primary time series)')") nseries write(6,"(' nhist_total = ',i5,2x, | '(Number of primary histories to be written)')") nhist_total write(6,"(' nfiles_prim = ',i5,2x, | '(Number of primary output files to be written)')") nfiles_prim write(6,"(' mxhist_prim = ',i5,2x, | '(Maximum number of primary histories per file)')") mxhist_prim ! ! Report re secondary histories to stdout: if (isechist > 0) then write(6,"(/,'Secondary Histories:')") write(6,"(' nseries_sech = ',i5,2x, | '(Number of secondary time series)')") nseries_sech write(6,"(' nsech_total = ',i5,2x, | '(Number of secondary histories to be written)')") nsech_total write(6,"(' nfiles_prim = ',i5,2x, | '(Number of secondary output files to be written)')") | nfiles_sech write(6,"(' nsecfmag = ',i5,2x, | '(Number of secondary history fields on magnetic grid)')") | nsecfmag write(6,"(' mxhist_sech = ',i5,2x, | '(Maximum number of secondary histories per file)')") | mxhist_sech ! ! Report secondary history fields: write(6,"(/,'Secondary history fields on geographic grid ', | ' (number of fields =',i3,'):')") nsecfgeo do i=1,nsecfgeo if (fsech(i)%prognostic) then write(6,"(' Field ',a,' (',a,')')") fsech(i)%name(1:8), | trim(fsech(i)%long_name) else write(6,"(' Field ',a,' (diagnostic)')") fsech(i)%name endif enddo write(6,"(/,'Secondary history fields on magnetic ', | 'grid (number of fields =',i3,'):')") nsecfmag do i=1,nsecfmag write(6,"(' Mag field ',a,' (diagnostic)')") fsechmag(i)%name enddo endif end subroutine init end module init_module