USAGE
    moded @ moded.ins [:target]

PURPOSE
Maxwell mode file editor.

To list a range of  modes, use
   showmode 
How to use:
  
showmode -h 


FUNCTION
Reads the instruction file for editing directives, optionally after a locating target; imports, edits, and outputs a Maxwell mode file.
A mode file is the result of program maxwell.f and may contain results for many spherical harmonic degrees (max. 1001, incl. n=0)
For editing, a second mode file can be read in or composed from mode files that contain one to a range of sph.harm. degrees.
From the second memory partial mode series and individual degrees can be copied into the primary memory.

INSTRUCTION FILE
Consists of two parts, an open-file block and a series of editing instructions, terminating with a STOP or END directive.
Example:
COP>
21 R prem_l96_um0.5_lm10.n2-100
22 R prem_l96_um0.5_lm10.n101-200
31 B prem_l96_um0.5_lm10.n2-200
   Q
NCOP 101 .. 200
END


Execute with
  moded @ moded.ins :COP

The file on unit 21 (R  meaning ascii read-only) goes into the primary memory, the file on unit 22 into the secondary. Q ends the open-file block;
more details in openf.html
NCOP implies copying from the secondary into the primary memory. Upon END the primary memory is written to file unit 31 (B meaning writing ascii from the file start).

EDITING DIRECTIVES
Abbreviations:
M1, M2, M#    - primary and secondary memory, or specify which one, respectively.
# #n          - a numeric argument, #i .. #n integer, else floating-point.
                              Sometimes only written #  as a placeholder for integers 1 or 2 when designating
                              M1 or M2, like in SHOW#
text          - a character-type argument, e.g. a file name
BOLD          - fixed text and symbols, eventually underlined for clarity (e.g. , )
[optional]
[ε]           - optionally specify  EPS=#e where e is a grace marign)
(s)           - the decadal logarithm of s (the latter usually being the Laplace parameter).
column                - we have three columns, 1, 2, 3 designating Love numbers H, L, K, respectively.


STOP                 - stop without writing
END                  - stop after writing M1 to file unit 31
OUT# #iu             - output to file unit iu, memory 1 or 2. That unit must be connected to a named
                       file in the open-file block (else it gets the Fortran default name fort.iu

OPEN filename        - open a mode file on unit 22, blank out M2 and read the contents of the file into M2.
INSR filename        - insert a mode file, like OPEN except don't blank out M2. 


NCOP #m .. #n        - do i from m to n step 1: copy sph.degree i from M2 to M1
NCOP #i[,#j,#k,...]  - copy these sph.degrees from M2 to M1

INFM# #m .. #n       - do i from m to n step 1: print mode information for sph.degree i in M# 
INFM# #i[,#j,#k,...] - print mode information for these sph.degrees in M#
SHOW# #k #a #b       - show M# for a ≤ lg(s) ≤ b at sph.harm. degree k
MODE# #k #n #m       - show mode numbers n to m in M# at sph.harm. degree k

KSGF #j [#t #c] [+P] - Re-order M1 according to decreasing mode magnitude. Use column j for that.
                       Keep only the significant modes in M1. Significance is decided upon the
                       step response at time t [in kilo-year] to a very concentrated load, how many
                       modes could be dropped while keeping the imprecision below c times the total.
                       If t is not given, the modes will be ordered without cutting off.
                       Option +P requests printed comments of the results at every sph.harm. degree.

KSGS #j #t #c #a #b [+P]      - Like KSGF, within limit for s: asb
KSGL #j #t #c #a #b [+P]                                ... a ≤ log(s) ≤ b.  

KSMS #j #a #b #c [#n #m] [+P] - Keep strong modes in M1. Use column j for determination. Criterion c:
                                Modes with |i
Ak(j)| > c are kept; M1 will be ordered according to decreasing
                                strength. Mode removal will take place in sph.harm. degrees n
k m
                                for modes with s:
as
                               
No default for a and b. Default n, m = all.
KSML
#j #a #b #c [#n #m] [+P] - Same, a ≤ log(s) ≤ b however.
 
DELS# #n [.. #m] #a #b [ε]    - Delete modes at sph.harm. degrees n to m (n < m) within asb
DELL
# #n [.. #m] #a #b [ε]    - ... a ≤ log(s) ≤ b

ADDM
#n    
[ε]               - Take modes at sph.harm. degree n from M2 and add to M1. Do that only for
                                modes that are unique for M1 (no overcoring), based on lg Laplace-s (grace
                                margi
n ε applies).
 
RPMA #n    
[ε]               - Replace all modes in M1 with corresponding modes in M2 based on lg(s).
RPMN #n #m  [ε]               - Replace the mode in M1 that is closest to mode m in M2, based on lg(s).
RPMS #n #s 
[ε]               - Replace the mode in M1 that is closest to the mode in M2 that is near s.
RPML #n #p  [ε]               - like RPMS, p = lg(s).

INPN# #n #m                   - Interpolate mode no. m in M1 at sph.harm. degree n from the neighbour
                                sph.harm. degrees. 
INPS# #n #s                   - like INPN, using the Laplace-parameter s of the mode in question.
INPL# #n #p                   - like INPS, p = lg(s), however.
INP...
[ALFA=#α] [RADIUS=#ρ] [TINY=#τ]
                             
- For the interpolation commands you may change the parameters with which
                                the modes are identified. It's primarily the big modes that need attention,
                                and this directive should only be used as a last resort, if the mode cannot
                                be found by maxwell (or its amplitude does not converge). 
                                The neighbour modes'
jsn+1 is found by determining
                                  max(|jAn+1|/(|
s - jsn+1| + τ)α , |s - jsn+1| < ρ
                               
where A denotes mode strength (determination is carried out separately
                                for columns 1,2 and 3, although this is probably unneccessary.

MGMS MGML                     - Migrate modes from one sph.degree to another, deprecated.

EPS=
#v
ALFA=#v
RADIUS=#v
TINY=#v              - given at the first position on a line, the parameters are valid through all 
                      
commands that follow until a new setting. Specified last on a line, however,
                       the definition is valid only once.
                       Defaults  EPS/1.d-6/, ALFA/1.5d0/, TINY/1.d-8/, RADIUS/0.2d0/

Unrecognized directives are ignored.                            
     
EXAMPLE:
Interpolation of missing modes and reduction to the essential modes on an accuracy level of 0.001:
INT>
21 R prem3.tst
31 B prem4.tst
   Q
EPS= 1.d-3
INPS  69 0.35008
INPS  83 0.467123 ALFA=0 RADIUS=0.3
INPS  90 0.531016
INPS  92 0.549604
INPS 102 0.643244
KSGF   1 10. 0.001
END



.bye