text
stringlengths 12
986k
| repo_path
stringlengths 6
121
|
---|---|
SUBROUTINE AF_PTRB ( report, istrb, ietrb, iret )
C************************************************************************
C* AF_PTRB *
C* *
C* This subroutine decodes and stores the turbulence data from within *
C* a PIREP report. *
C* *
C* AF_PTRB ( REPORT, ISTRB, IETRB, IRET ) *
C* *
C* Input parameters: *
C* REPORT CHAR* PIREP report *
C* ISTRB INTEGER Pointer to start of turbulence *
C* data within REPORT *
C* IETRB INTEGER Pointer to end of turbulence *
C* data within REPORT *
C* *
C* Output parameters: *
C* RIVALS (IRNTRB) REAL Number of turbulence levels *
C* RIVALS (IRDGOT) REAL Degree of turbulence *
C* RIVALS (IRHBOT) REAL Base of turbulence in feet *
C* RIVALS (IRHTOT) REAL Top of turbulence in feet *
C* RIVALS (IRFQOT) REAL Frequency of turbulence *
C* RIVALS (IRTPOT) REAL Type of turbulence *
C* IRET INTEGER Return code *
C* 0 = normal return *
C* *
C** *
C* Log: *
C* J. Ator/NP12 09/96 *
C* J. Ator/NP12 08/97 New interface format, style changes *
C* D. Kidwell/NCEP 6/99 Added frequency, type, document turb. *
C* D. Kidwell/NCEP 7/99 Used flight level if heights missing, *
C* changed meters to feet in prologue *
C* S. Jacobs/NCEP 9/12 Set heights to missing if intensity=0 *
C* or is itself missing *
C************************************************************************
INCLUDE 'GEMPRM.PRM'
INCLUDE 'afcmn.cmn'
C*
CHARACTER*(*) report
C*
INTEGER islyr ( MXNLYR ), ielyr ( MXNLYR )
C*
INCLUDE 'ERMISS.FNC'
C-----------------------------------------------------------------------
iret = 0
C
C* Break up the input string into groups of "like-type" in order
C* to facilitate decoding.
C
CALL AF_BKGP ( report ( istrb : ietrb ), ierbgp )
IF ( ierbgp .ne. 0 ) THEN
RETURN
END IF
C
C* There may be multiple layers of turbulence data reported;
C* if so, then each layer is separated from the others by a
C* "like-type" group containing a "/" character.
C* Separate these layers.
C
CALL AF_PLYR ( '/TB', islyr, ielyr, nlyr, ierlyr )
C
C* Decode and store the turbulence data.
C
C* Degree of turbulence values are stored in the interface format
C* as GEMPAK turbulence numbers.
C* NONE = 0
C* LIGHT = 2
C* LIGHT-MODERATE = 3
C* MODERATE = 4
C* MODERATE-SEVERE = 5
C* SEVERE = 6
C* EXTREME = 8
C
ntrb = 0
DO ii = 1, nlyr
CALL AF_PTLR ( islyr (ii), ielyr (ii),
+ dgot, hbot, htot, fqot, tpot, iertlr )
IF ( iertlr .eq. 0 ) THEN
C
C* If heights are missing, use flight level.
C
IF ( dgot .gt. 0 ) THEN
IF ( ERMISS ( hbot ) .and. ERMISS ( htot ) ) THEN
hbot = rivals ( irflvl )
htot = rivals ( irflvl )
END IF
ELSE
hbot = RMISSD
htot = RMISSD
END IF
C
ntrb = ntrb + 1
rivals ( irdgot ( ntrb ) ) = dgot
rivals ( irhbot ( ntrb ) ) = hbot
rivals ( irhtot ( ntrb ) ) = htot
rivals ( irfqot ( ntrb ) ) = fqot
rivals ( irtpot ( ntrb ) ) = tpot
END IF
END DO
rivals ( irntrb ) = ntrb
C*
RETURN
END
| gempak/source/bridge/af/afptrb.f |
use plantfem
implicit none
integer, parameter :: np = 10
type(Soybean_) :: soy(np,np)
real(real64) :: biomass(np,np)
integer(int32) :: i,j,k
!$OMP parallel do private(i,j)
do i=1,np
do j=1,np
call soy(i,j)%init(config="Tutorial/obj/realSoybeanConfig_mini.json")
do k=1,2
call soy(i,j)%grow(dt=1.0d0,simple=.true.)
enddo
biomass(i,j) = soy(i,j)%getBiomass()
call soy(i,j)%move(x=dble(i-1)*0.40,y=dble(j-1)*0.14)
call soy(i,j)%stl(name="soy_"//str(i)//"_"//str(j) )
enddo
enddo
!$OMP end parallel do
!call soil%create(x_num=3,y_num=3,z_num=1)
!call soil%resize(x=3.0d0, y=3.0d0, z=1.0d0)
!call soil%msh(name="soil")
call print(biomass)
!writing soy_2_2_leaf18_000001.stl step>> 1
!1.2474712525392341E-003 1.1998353796776593E-003
!1.2671755205095057E-003 1.2480182046246107E-003
!0.0049625004
call print(sum(biomass))
end | Tutorial/obj/simpleSoybeanPopulationGrowth.f90 |
SUBROUTINE SPROD (X,Y,SCAL,R1,R2)
*+
* - - - - - - - - - - -
* S P R O D
* - - - - - - - - - - -
*
* This routine is part of the International Earth Rotation and
* Reference Systems Service (IERS) Conventions software collection.
*
* This subroutine computes the scalar product of two vectors and
* their norms.
*
* In general, Class 1, 2, and 3 models represent physical effects that
* act on geodetic parameters while canonical models provide lower-level
* representations or basic computations that are used by Class 1, 2, or
* 3 models.
*
* Status: Canonical model
*
* Class 1 models are those recommended to be used a priori in the
* reduction of raw space geodetic data in order to determine
* geodetic parameter estimates.
* Class 2 models are those that eliminate an observational
* singularity and are purely conventional in nature.
* Class 3 models are those that are not required as either Class
* 1 or 2.
* Canonical models are accepted as is and cannot be classified as a
* Class 1, 2, or 3 model.
*
* Given:
* X d(3) components of vector x
* Y d(3) components of vector y
*
* Returned:
* SCAL d scalar product of vector x and vector y
* R1 d length of vector x
* R2 d length of vector y
*
* Called:
* None
*
* Test case:
* given input: X(1) = 2D0 Y(1) = 1D0
* X(2) = 2D0 Y(2) = 3D0
* X(3) = 3D0 Y(3) = 4D0
*
* expected output: SCAL = 20D0
* R1 = 4.123105625617660586D0
* R2 = 5.099019513592784492D0
*
* References:
*
* Mathews, P. M., Dehant, V., and Gipson, J. M., 1997, ''Tidal station
* displacements," J. Geophys. Res., 102(B9), pp. 20,469-20,477
*
* Petit, G. and Luzum, B. (eds.), IERS Conventions (2010),
* IERS Technical Note No. 36, BKG (2010)
*
* Revisions:
* 2009 July 10 B.E.Stetzler Initial standardization of function,
* explicit exponential notation and
* provided a test case
*-----------------------------------------------------------------------
IMPLICIT NONE
DOUBLE PRECISION X(3), Y(3), R1, R2, SCAL
R1=DSQRT(X(1)*X(1)+X(2)*X(2)+X(3)*X(3))
R2=DSQRT(Y(1)*Y(1)+Y(2)*Y(2)+Y(3)*Y(3))
SCAL=X(1)*Y(1)+X(2)*Y(2)+X(3)*Y(3)
RETURN
* Finished.
*+----------------------------------------------------------------------
*
* Copyright (C) 2008
* IERS Conventions Center
*
* ==================================
* IERS Conventions Software License
* ==================================
*
* NOTICE TO USER:
*
* BY USING THIS SOFTWARE YOU ACCEPT THE FOLLOWING TERMS AND CONDITIONS
* WHICH APPLY TO ITS USE.
*
* 1. The Software is provided by the IERS Conventions Center ("the
* Center").
*
* 2. Permission is granted to anyone to use the Software for any
* purpose, including commercial applications, free of charge,
* subject to the conditions and restrictions listed below.
*
* 3. You (the user) may adapt the Software and its algorithms for your
* own purposes and you may distribute the resulting "derived work"
* to others, provided that the derived work complies with the
* following requirements:
*
* a) Your work shall be clearly identified so that it cannot be
* mistaken for IERS Conventions software and that it has been
* neither distributed by nor endorsed by the Center.
*
* b) Your work (including source code) must contain descriptions of
* how the derived work is based upon and/or differs from the
* original Software.
*
* c) The name(s) of all modified routine(s) that you distribute
* shall be changed.
*
* d) The origin of the IERS Conventions components of your derived
* work must not be misrepresented; you must not claim that you
* wrote the original Software.
*
* e) The source code must be included for all routine(s) that you
* distribute. This notice must be reproduced intact in any
* source distribution.
*
* 4. In any published work produced by the user and which includes
* results achieved by using the Software, you shall acknowledge
* that the Software was used in obtaining those results.
*
* 5. The Software is provided to the user "as is" and the Center makes
* no warranty as to its use or performance. The Center does not
* and cannot warrant the performance or results which the user may
* obtain by using the Software. The Center makes no warranties,
* express or implied, as to non-infringement of third party rights,
* merchantability, or fitness for any particular purpose. In no
* event will the Center be liable to the user for any consequential,
* incidental, or special damages, including any lost profits or lost
* savings, even if a Center representative has been advised of such
* damages, or for any claim by any third party.
*
* Correspondence concerning IERS Conventions software should be
* addressed as follows:
*
* Gerard Petit
* Internet email: gpetit[at]bipm.org
* Postal address: IERS Conventions Center
* Time, frequency and gravimetry section, BIPM
* Pavillon de Breteuil
* 92312 Sevres FRANCE
*
* or
*
* Brian Luzum
* Internet email: brian.luzum[at]usno.navy.mil
* Postal address: IERS Conventions Center
* Earth Orientation Department
* 3450 Massachusetts Ave, NW
* Washington, DC 20392
*
*
*-----------------------------------------------------------------------
END
| lib/iers/src/sprod.f |
Driving in Davis is an interesting experience, and it shows when you look at the commentary about Davis Drivers. Its quite a bit different than either SoCal or Bay Area driving. Here are some of the things to consider when driving the streets of the Peoples Republic of Davis:
Customary Order
Law Enforcement
Davis Police Department Traffic Unit consists of four motorcycle officers and an administrative sergeant. The motorcycle officers are used for traffic enforcement because they allow officers easier accessibility to traffic related problems. The traffic unit is responsible for enforcing the California Vehicle Code statutes, enforcement of local traffic ordinances, and investigation of vehicle collisions. The traffic officers provide dedicated enforcement at high collision intersections. If you are concerned about a specific traffic related issue, you are encouraged to http://www.davispd.org contact the Davis P.D. traffic unit by email. Occasionally speed traps are set up, but you are more likely to see a radar sign that just lets you know how fast you were going and what the speed limit is for that street.
Davis Police Department
California Highway Patrol
DMV
TAPS
Traffic Slowing Measures
In its brilliance, the Davis City Council designs streets so that people will have to drive slowly through neighborhoods. Thus we see 4way stops, Traffic Circle traffic circles like the one on Alvarado Ave., speed humps (you have to take them at 15mph or less if you care about the parts in your car) and curved roads. Every city does this but Davis takes it a little further. Presumably this is at the behest of the residents.
3rd & University Poles poles block and direct traffic through neighborhoods.
Slow Speed Limits. Russell Boulevard has a speed limit of 30 mph in the Central Davis Central and Downtown Davis and 35 mph in West Davis. Consequently, this road is always congested.
http://www.ite.org/traffic/table.htm Speed Tables on Oak Avenue to discourage traffic from using Oak Ave. to get to campus.
Too few lanes. This is especially apparent on Russell Boulevard around 5 PM or any time of day on Richards Boulevard under the Train Tracks train tracks near the Bike tunnels bike tunnel.
Purely Davis
Bike Signal Bike Signals. Remember, the bikes get to go first. Theres a little bike symbol in the lights.
The Light Ordinance makes it difficult to see moving objects that dont selfilluminate
Parking in town and campus
Hazards
The Worst Intersection in Davis
10th St. & D St. Intersection
OnRamp of Doom
Traffic Signals
Its hard to explain how badly timed these are. Though most lights have sensors, they tend to ignore people for long periods of time. Conversely, some lights stop a major street any time one car pulls up on the side street. Russell Boulevard is a prime example. During the Night Time, any car or Bicycles bicycle that wishes to cross the street will immediately get a green light. Interestingly, during the morning hours, the bike button doesnt seem to make the light change speed up at all.
The traffic light at Arthur and Russell Boulevard in West Davis is a good example of the latter problem. Sometimes late at night, the light will favor people turning from left from Arthur onto Russell, while people headed either way on Russell are given a red light. This makes no sense since Russell is obviously more trafficked than Arthur. Users/KalenRidenour
Red Light Cameras
The amount of time drivers sit at red lights when not a single car passes through the cross street is ridiculous. Are the timing programs that operate the lights based on observation of traffic flows, or are they just randomly set?
On another note, the Davis Police Department says that they cannot send an officer to direct traffic in the case of power outages because the city would then be liable for car accidents. As per California state law, when traffic signals are off you must treat them as a fourway stop. Just because you dont see red doesnt mean you have a green so it should go without saying, but pay attention as you approach intersections.
Street Signs
Unlike Davis welladministered neighboring cities, the street signs here appear to be printed in small font (specifically, the signs displaying the name of the street). This increases the number of people who slow down at each and every intersection trying to figure out if its the street they want to turn on or not. If you already know the names of the streets where youre driving, its no problem. But the purpose of the signs is to inform people who arent already familiar with the streets, right?
Bicycles
There are a lot of them, and you have to watch out for them. Watch outmost bicyclists, who, presumably, feel like they own the road, do not stop for pedestrians or cars. Be vigilant of bicycling bicyclists riding on the wrong side of the street (against traffic) and in pedestrian crosswalks, especially at night time. Thankfully, the system of Bike Paths in Davis is excellent, and works better than the road system.
Pedestrians
Three points each. Bikes are only two. :) Pedestrians are generally a problem while driving in the neighborhood near Cafe Roma as well as the Downtown area, where people will often step out into the crosswalks without even looking.
Trucks
Delivery trucks will often doublepark downtown, blocking both the bike lane and most of the traffic lane.
Accidents
Please note that it is a CRIME to leave the scene of an accident: http://www.dmv.ca.gov/pubs/vctop/d10/vc20001.htm. This is known as a hit and run. For example, if you hit someone on their bike, you should pull over and make sure they are okay and exchange information/call police if necessary, instead of speeding away.
Random facts about accidents from the State of CA BR
Top 5 locations for vehicle accidents that occur in Davis are as follows:
Mace Blvd./2nd Street Unsafe Speed
D Street/3rd Street Right of Way
L Street/5th Street Unsafe Speed
Pole Line Rd./E 8th Street Right of Way
W Covell Blvd./F Street Unsafe Speed
Citywide Primary Collision Factors prepared for 06/01/05 to 06/30/05 Statistical analysis of the Primary Cause factors citywide equally indicated that Unsafe Speed and Right of Way amounted to the majority of collisions.
Unsafe Speed (Incidents10, 23%)
Other (Incidents8, 20%)
Right of Way (Incidents6, 15%)
Improper Turning (Incidents6, 15%)
Traffic Lights (Incidents4, 10%)
Unsafe starting backing (Incidents4, 10%)
DUI (Incidents3, 7%)
Accidents Daily/Hourly Analysis BR
June 2005
Primary collisions days have been on Tuesday, Wednesday, and Friday with 65.9% of all accidents
Hourly trend of accidents for this month correlate with work/school hours (08:00 AM, lunch break, 5:00 PM – 7:00 PM)
Time percentage of these collisions:
8:00 AM – 11:00 AM : 19.5%
1:00 PM – 5:00 PM : 41.5%
5:00 PM – 8:00 PM : 17.1%
Getting Around
Learn about Navigating Davis.
Transportation types.
Find some shortcuts.
Learn the traffic patterns.
Some say everything in Davis is Walking Distance.
Local Yellow Light Custom: If its going to be yellow for any portion of the time that you were in the intersection, you should go. Everyone else does, as it will likely be a long time before you see green again. Some people do this on the first few seconds of a red light as well. This also means you shouldnt race ahead as soon as the light turns green, as even bikes follow the Yellow Light Custom.
California Vehicle Code section 21452(a) indicates that the significance of a yellow light is merely to warn that a red light will follow. Nowhere does it say that you cannot enter an intersection. Provided that the front of the vehicle has entered the intersection before the light turned red, one has not broken the law at all. There is no reason to speed up, because your only concern (besides safety) should be that you were legally entering the intersection (which you can do on a yellow). This is the same reason that cars turning leftbut unable to, due to oncoming trafficare allowed to remain in the intersection so they can turn even though their light turns red. So feel proud to enter an intersection on a yellow. Users/JaimeRaba jr
While it isnt illegal to enter an intersection on the yellow light, the general rule (ie: a guideline, not law specifically relating to the vehicle code) given by the CA DMV is to proceed through only if you believe you can clear the intersection before the light turns red. They also say this about yellow signal lights: When you see the yellow light, stop if you can do so safely. If you can’t stop safely, enter the intersection cautiously. Users/JevanGray Jevan
Yep, I meant it as a custom. Its changed. Users/BrentLaabs
I changed mine too. But hey, its good to know that its completely legal. Always was a grey point to me until I researched it.
You guys are fools. Do you realize how dangerous that can be? I have seen multiple car accidents happen because ppl enter the light in the yellow, this custom of yours. This is a stupid custom and it isnt even a custom, it is a dangerous habit. Users/GeorgeLewis
Ive probably seen more accidents caused by people slamming on their brakes at yellows than Ive seen caused by people safely proceeding through yellows. Yellow light means proceed with caution. However, whats dangerous is people racing through yellowsbut theres no reason to race. After all, people are already used to people lurking in interscetions due to what happens when someone needs to turn left and cannot. Users/JaimeRaba jr
Clearly I wasnt advocating the stomping on ones breaks every time one sees a yellow light. I think you know exactly what I was saying. Users/GeorgeLewis
20051206 18:12:19 nbsp I see cars without plates all the time in Kali, what is up wit that? Users/DudeNude
20051212 12:07:54 nbsp Driving less is good for everyone. Users/GregoryThrasher
20060516 22:42:34 nbsp I just recently moved to Davis from the East Coast and need to get my car inspected so that it passes the CA smog laws. Any recommendations on where to go? I was hoping the DavisWiki pages re: cars would give me a hint, but no dice. Users/BelvinGong
I havent had my vehicle smogged in Davis but you can go to Speedee Oil Change & Tune Up Speedee or Davis Smog or EZ Smog or just about any place that does an oil change. Check your mail and theres a weekly book that has a bunch of coupons and ads in it. They advertise in that. Users/JoAnnaRich JR
Dont go to the place on 5th near the DMV. They try to rip off new residents. Do some research on the places listed above and find the appropriate price range. Users/ThucNghiNguyen TNN
20120306 21:25:01 nbsp I got into an accident on 1st & B the other day (the T intersection near campus). I fit in the statistics of the right of way being the cause. Just a plea to others: please dont text and drive, and please dont lie if youre the one at fault. I should have called the police just to get a clear report. Oh well, lesson learned. Users/MichelleHV
| lab/davisWiki/Driving_in_Davis.f |
! ###################################################################
! Copyright (c) 2017-2019, Marc De Graef Research Group/Carnegie Mellon University
! All rights reserved.
!
! Redistribution and use in source and binary forms, with or without modification, are
! permitted provided that the following conditions are met:
!
! - Redistributions of source code must retain the above copyright notice, this list
! of conditions and the following disclaimer.
! - Redistributions in binary form must reproduce the above copyright notice, this
! list of conditions and the following disclaimer in the documentation and/or
! other materials provided with the distribution.
! - Neither the names of Marc De Graef, Carnegie Mellon University nor the names
! of its contributors may be used to endorse or promote products derived from
! this software without specific prior written permission.
!
! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
! AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
! IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
! ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
! LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
! DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
! SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
! OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
! USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! ###################################################################
!--------------------------------------------------------------------------
! EMsoft:gvectorsQC.f90
!--------------------------------------------------------------------------
!
! MODULE: gvectorsQC
!
!> @author Saransh Singh, Carnegie Mellon University
!
!> @brief routines to handle g vector sampling for quasi-crystals
!> multibeam computations
!
!> @date 06/26/18 SS 1.0 original
!--------------------------------------------------------------------------
module gvectorsQC
use local
use typedefs
use qcrystal
use diffractionQC
use QCmod
IMPLICIT NONE
public
interface MakeQCRefList
module procedure Make2DQCRefList
module procedure Make3DQCRefList
end interface MakeQCRefList
interface AddQCReflection
module procedure Add2DQCReflection
module procedure Add3DQCReflection
end interface AddQCReflection
interface Delete_QCgvectorlist
module procedure Delete_QCgvectorlist
module procedure Delete_TDQCgvectorlist
end interface Delete_QCgvectorlist
interface QC_Apply_BethePotentials
module procedure TDQC_Apply_BethePotentials
module procedure QC_Apply_BethePotentials
end interface QC_Apply_BethePotentials
interface Initialize_QCReflectionList
module procedure Initialize_TDQCReflectionList
module procedure Initialize_QCReflectionList
end interface Initialize_QCReflectionList
contains
!--------------------------------------------------------------------------
!
! SUBROUTINE: Make2DQCRefList
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief allocate and initialize the linked reflection list for a quasi-crystal
!
!> @param listroot top of linked list
!> @param rltail auxiliary pointer
!> @param nref number of reflections in list
!
!> @date 10/20/98 MDG 1.0 original
!> @date 5/22/01 MDG 2.0 f90
!> @date 11/27/01 MDG 2.1 added kind support
!> @date 03/26/13 MDG 3.0 updated IO
!> @date 01/10/14 MDG 4.0 account for new version of cell type
!> @date 06/09/14 MDG 4.1 added cell and rltail as arguments
!> @date 06/17/14 MDG 4.2 modification for separate reflist pointers; removed cell pointer
!> @date 03/15/17 MDG 4.3 copied from gvectors module for QCmod adaptation
!> @date 03/23/18 SS 4.4 adapted from QCmod.f90
!--------------------------------------------------------------------------
recursive subroutine Make2DQCRefList(listroot, rltail, nref)
!DEC$ ATTRIBUTES DLLEXPORT :: Make2DQCRefList
use error
IMPLICIT NONE
type(TDQCreflisttype),pointer :: listroot
type(TDQCreflisttype),pointer :: rltail
integer(kind=irg),INTENT(INOUT) :: nref
integer(kind=irg) :: istat
! create it if it does not already exist
if (.not.associated(listroot)) then
nref = 0
allocate(listroot,stat=istat)
if (istat.ne.0) call FatalError('MakeQCRefList:',' unable to allocate pointer')
rltail => listroot ! tail points to new value
nullify(rltail%next) ! nullify next in new value
end if
end subroutine Make2DQCRefList
!--------------------------------------------------------------------------
!
! SUBROUTINE: Add2DQCReflection
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief add a reflection to the linked reflection list
!
!> @param rltail QCreflisttype variable
!> @param listroot QCreflisttype variable
!> @param QCcell QC structure pointer
!> @param nref number of reflections
!> @param hkl Miller indices
!
!> @date 10/20/98 MDG 1.0 original
!> @date 5/22/01 MDG 2.0 f90
!> @date 11/27/01 MDG 2.1 added kind support
!> @date 03/26/13 MDG 3.0 updated IO
!> @date 01/10/14 MDG 4.0 account for new version of cell type
!> @date 06/09/14 MDG 4.1 added rltail and cell as arguments
!> @date 06/17/14 MDG 4.2 modification for separate reflist pointers
!> @date 09/08/15 MDG 4.3 added qg entry
!> @date 03/15/17 MDG 4.3 copied from gvectors module for QCmod adaptation
!> @date 03/23/18 SS 4.4 adapted from QCmod.f90
!--------------------------------------------------------------------------
recursive subroutine Add2DQCReflection(rltail,listroot,QCcell,nref,gg)
!DEC$ ATTRIBUTES DLLEXPORT :: Add2DQCReflection
use error
IMPLICIT NONE
type(TDQCreflisttype),pointer :: rltail
type(TDQCreflisttype),pointer :: listroot
type(TDQCStructureType),pointer :: QCcell
integer(kind=irg),INTENT(INOUT) :: nref
integer(kind=irg),INTENT(IN) :: gg(5)
integer(kind=irg) :: istat, QCindex
complex(kind=dbl) :: Ucg, qg
real(kind=dbl) :: Vmod, Vpmod, xig, xgp
! create linked list if it does not already exist
if (.not.associated(rltail)) then
nullify(rltail)
end if
if (.not.associated(listroot)) then
call MakeQCRefList(listroot,rltail,nref)
end if
! create a new entry
allocate(rltail%next,stat=istat) ! allocate new value
if (istat.ne.0) call FatalError('AddQCReflection',' unable to add new reflection')
rltail => rltail%next ! tail points to new value
nullify(rltail%next) ! nullify next in new value
nref = nref + 1 ! update reflection counter
rltail%num = nref ! store reflection number
rltail%hkl = gg ! store Miller indices
QCindex = QC_getindex(QCcell, gg)
rltail%Ucg = QCcell%LUT(QCindex) !QCcell%LUT(gg(1),gg(2),gg(3),gg(4),gg(5))
rltail%qg = QCcell%LUT(QCindex) !QCcell%LUTqg(gg(1),gg(2),gg(3),gg(4),gg(5))
rltail%glen = QC_getvectorLength(QCcell, rltail%hkl, 'P', 'r')
nullify(rltail%nextw)
nullify(rltail%nexts)
end subroutine Add2DQCReflection
!--------------------------------------------------------------------------
!
! SUBROUTINE: Delete_QCgvectorlist
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief delete the entire linked list
!
!> @param top top of the list to be removed
!
!> @date 04/29/13 MDG 1.0 original
!> @date 06/09/14 MDG 1.1 added cell argument
!> @date 06/17/14 MDG 1.2 replaced cell by top
!--------------------------------------------------------------------------
recursive subroutine Delete_QCgvectorlist(top)
!DEC$ ATTRIBUTES DLLEXPORT :: Delete_QCgvectorlist
IMPLICIT NONE
type(QCreflisttype),pointer :: top
type(QCreflisttype),pointer :: rltail, rltmpa
! deallocate the entire linked list before returning, to prevent memory leaks
rltail => top
rltmpa => rltail % next
do
deallocate(rltail)
if (.not. associated(rltmpa)) EXIT
rltail => rltmpa
rltmpa => rltail % next
end do
end subroutine Delete_QCgvectorlist
!--------------------------------------------------------------------------
!
! SUBROUTINE: Delete_TDQCgvectorlist
!
!> @author Saransh Singh, Carnegie Mellon University
!
!> @brief delete the entire linked list
!
!> @param top top of the list to be removed
!
!> @date 05/01/18 SS 1.0 adapted from QCmod.f90
!--------------------------------------------------------------------------
recursive subroutine Delete_TDQCgvectorlist(top)
!DEC$ ATTRIBUTES DLLEXPORT :: Delete_TDQCgvectorlist
IMPLICIT NONE
type(TDQCreflisttype),pointer :: top
type(TDQCreflisttype),pointer :: rltail, rltmpa
! deallocate the entire linked list before returning, to prevent memory leaks
rltail => top
rltmpa => rltail % next
do
deallocate(rltail)
if (.not. associated(rltmpa)) EXIT
rltail => rltmpa
rltmpa => rltail % next
end do
end subroutine Delete_TDQCgvectorlist
!--------------------------------------------------------------------------
!
! SUBROUTINE: Make3DQCRefList
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief allocate and initialize the linked reflection list for a quasi-crystal
!
!> @param listroot top of linked list
!> @param rltail auxiliary pointer
!> @param nref number of reflections in list
!
!> @date 10/20/98 MDG 1.0 original
!> @date 5/22/01 MDG 2.0 f90
!> @date 11/27/01 MDG 2.1 added kind support
!> @date 03/26/13 MDG 3.0 updated IO
!> @date 01/10/14 MDG 4.0 account for new version of cell type
!> @date 06/09/14 MDG 4.1 added cell and rltail as arguments
!> @date 06/17/14 MDG 4.2 modification for separate reflist pointers; removed cell pointer
!> @date 03/15/17 MDG 4.3 copied from gvectors module for QCmod adaptation
!--------------------------------------------------------------------------
recursive subroutine Make3DQCRefList(listroot, rltail, nref)
!DEC$ ATTRIBUTES DLLEXPORT :: Make3DQCRefList
use error
IMPLICIT NONE
type(QCreflisttype),pointer :: listroot
type(QCreflisttype),pointer :: rltail
integer(kind=irg),INTENT(INOUT) :: nref
integer(kind=irg) :: istat
! create it if it does not already exist
if (.not.associated(listroot)) then
nref = 0
allocate(listroot,stat=istat)
if (istat.ne.0) call FatalError('MakeQCRefList:',' unable to allocate pointer')
rltail => listroot ! tail points to new value
nullify(rltail%next) ! nullify next in new value
end if
end subroutine Make3DQCRefList
!--------------------------------------------------------------------------
!
! SUBROUTINE: Add3DQCReflection
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief add a reflection to the linked reflection list
!
!> @param rltail QCreflisttype variable
!> @param listroot QCreflisttype variable
!> @param QCcell QC structure pointer
!> @param nref number of reflections
!> @param hkl Miller indices
!
!> @date 10/20/98 MDG 1.0 original
!> @date 5/22/01 MDG 2.0 f90
!> @date 11/27/01 MDG 2.1 added kind support
!> @date 03/26/13 MDG 3.0 updated IO
!> @date 01/10/14 MDG 4.0 account for new version of cell type
!> @date 06/09/14 MDG 4.1 added rltail and cell as arguments
!> @date 06/17/14 MDG 4.2 modification for separate reflist pointers
!> @date 09/08/15 MDG 4.3 added qg entry
!> @date 03/15/17 MDG 4.3 copied from gvectors module for QCmod adaptation
!--------------------------------------------------------------------------
recursive subroutine Add3DQCReflection(rltail,listroot,QCcell,nref,QCindex,gg)
!DEC$ ATTRIBUTES DLLEXPORT :: Add3DQCReflection
use error
IMPLICIT NONE
type(QCreflisttype),pointer :: rltail
type(QCreflisttype),pointer :: listroot
type(QCStructureType),pointer :: QCcell
integer(kind=irg),INTENT(INOUT) :: nref
integer(kind=irg),INTENT(IN) :: QCindex !< QC Miller indices of reflection to be added to list
integer(kind=irg),INTENT(IN) :: gg(6)
integer(kind=irg) :: istat
complex(kind=dbl) :: Ucg, qg
real(kind=dbl) :: Vmod, Vpmod, xig, xgp
! create linked list if it does not already exist
if (.not.associated(rltail)) then
nullify(rltail)
end if
if (.not.associated(listroot)) then
call MakeQCRefList(listroot,rltail,nref)
end if
! create a new entry
allocate(rltail%next,stat=istat) ! allocate new value
if (istat.ne.0) call FatalError('AddQCReflection',' unable to add new reflection')
rltail => rltail%next ! tail points to new value
nullify(rltail%next) ! nullify next in new value
nref = nref + 1 ! update reflection counter
rltail%num = nref ! store reflection number
rltail%hkl = gg ! store Miller indices
rltail%Ucg = QCcell%LUT(QCindex)
rltail%qg = QCcell%LUTqg(QCindex)
rltail%glen = QC_getvectorLength(QCcell, rltail%hkl, 'P', 'r')
nullify(rltail%nextw)
nullify(rltail%nexts)
end subroutine Add3DQCReflection
!--------------------------------------------------------------------------
!
! SUBROUTINE: Initialize_TDQCReflectionList
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief initialize the potential quasi-crystal reflection list for a given wave vector
!
!> @param QCcell cell pointer
!> @param BetheParameter Bethe potential structure
!> @param FN foil normal
!> @param k zone axis direction cosines in direct Bravais lattice
!> @param listroot pointer to top of list (could be cell%reflist)
!> @param nref number of reflections in main list (used to be DynNbeams)
!> @param verbose (optional) used for debugging purposes mostly
!> @date 03/15/17 MDG 1.0 original, based on regular Initialize_ReflectionList
!> @date 03/23/18 SS 1.1 adapted from QCmod.f90
!--------------------------------------------------------------------------
recursive subroutine Initialize_TDQCReflectionList(QCcell, listroot, BetheParameter, FN, k, nref, verbose)
!DEC$ ATTRIBUTES DLLEXPORT :: Initialize_TDQCReflectionList
use local
use typedefs
use io
use constants
use diffraction
IMPLICIT NONE
type(TDQCStructureType),pointer :: QCcell
type(TDQCreflisttype),pointer :: listroot
type(BetheParameterType),INTENT(INOUT) :: BetheParameter
real(kind=sgl),INTENT(IN) :: FN(3)
real(kind=sgl),INTENT(IN) :: k(3)
integer(kind=irg),INTENT(INOUT) :: nref
logical,INTENT(IN),OPTIONAL :: verbose
integer(kind=irg) :: imh, imhz, gg(5), i, minholz, RHOLZ, im, istat, N, &
ig, numr, ir, irsel, i1, i2, i3, i4, i5, QCindex
integer(kind=irg),allocatable :: orbit(:,:)
real(kind=sgl) :: dhkl, io_real(9), H, g3(3), g3n(3), FNg(3), ddt, s, kr(3), exer, &
rBethe_i, rBethe_d, sgp, r_g, la, dval
integer(kind=irg) :: io_int(3), gshort(3), gp(5), isym, nn
type(TDQCreflisttype),pointer :: rltail
complex(kind=dbl) :: Ucg, qg
real(kind=dbl) :: Vmod, Vpmod, xig, xgp
logical :: isnew
! set the truncation parameters
rBethe_i = BetheParameter%c3 ! if larger than this value, we ignore the reflection completely
rBethe_d = BetheParameter%sgdbdiff ! excitation error cutoff for double diffraction reflections
la = 1.0/sngl(QCcell%mLambda)
! get the size of the lookup table
!gg = shape(QCcell%LUT)
imh = QCcell%imax_qc/2 !(gg(1) - 1)/4
imhz = QCcell%imax_p/2 !(gg(5) - 1)/4
nullify(listroot)
nullify(rltail)
! transmitted beam has excitation error zero
gg = (/ 0,0,0,0,0 /)
!QCindex = QC_get6Dindex(QCcell, gg)
!QCindex = QC_getindex(QCcell, gg)
call AddQCReflection(rltail, listroot, QCcell, nref, gg) ! this guarantees that 000 is always the first reflection
rltail%sg = 0.0
allocate(orbit(5,QCcell%nsym))
orbit = 0
! now compute |sg|/|U_g|/lambda for the other allowed reflections; if this parameter is less than
! the threshhold, rBethe_i, then add the reflection to the list of potential reflections
i1l: do i1=-imh,imh
i2l: do i2=-imh,imh
i3l: do i3=-imh,imh
i4l: do i4=-imh,imh
i5l: do i5=-imhz,imhz
if ((abs(i1)+abs(i2)+abs(i3)+abs(i4)+abs(i5)).ne.0) then ! avoid double counting the origin
gg = (/ i1, i2, i3, i4, i5/)
QCindex = QC_getindex(QCcell, gg)
sgp = QC_Calcsg(QCcell,gg,k,FN)
Ucg = QCcell%LUT(QCindex) !QCcell%LUT(gg(1),gg(2),gg(3),gg(4),gg(5))
r_g = la * abs(sgp)/cdabs(Ucg)
if (r_g.le.rBethe_i) then
call AddQCReflection( rltail, listroot, QCcell, nref, gg )
rltail%sg = sgp
rltail%glen = QC_getvectorLength(QCcell, gg, 'P', 'r')
end if
end if
end do i5l
end do i4l
end do i3l
end do i2l
end do i1l
if (present(verbose)) then
if (verbose) then
io_int(1) = nref
call WriteValue(' Length of the master list of reflections : ', io_int, 1, "(I8)")
end if
end if
end subroutine Initialize_TDQCReflectionList
!--------------------------------------------------------------------------
!
! SUBROUTINE: Initialize_QCReflectionList
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief initialize the potential quasi-crystal reflection list for a given wave vector
!
!> @param QCcell cell pointer
!> @param BetheParameter Bethe potential structure
!> @param FN foil normal
!> @param k zone axis direction cosines in direct Bravais lattice
!> @param listroot pointer to top of list (could be cell%reflist)
!> @param nref number of reflections in main list (used to be DynNbeams)
!> @param verbose (optional) used for debugging purposes mostly
!
!> @date 03/15/17 MDG 1.0 original, based on regular Initialize_ReflectionList
!--------------------------------------------------------------------------
recursive subroutine Initialize_QCReflectionList(QCcell, listroot, BetheParameter, FN, k, nref, verbose)
!DEC$ ATTRIBUTES DLLEXPORT :: Initialize_QCReflectionList
use local
use typedefs
use io
use constants
use diffraction
IMPLICIT NONE
type(QCStructureType),pointer :: QCcell
type(QCreflisttype),pointer :: listroot
type(BetheParameterType),INTENT(INOUT) :: BetheParameter
real(kind=sgl),INTENT(IN) :: FN(3)
real(kind=sgl),INTENT(IN) :: k(3)
integer(kind=irg),INTENT(INOUT) :: nref
logical,INTENT(IN),OPTIONAL :: verbose
integer(kind=irg) :: imh, gg(6), i, minholz, RHOLZ, im, istat, N, &
ig, numr, ir, irsel, i1, i2, i3, i4, i5, i6, QCindex
real(kind=sgl) :: dhkl, io_real(9), H, g3(3), g3n(3), FNg(3), ddt, s, kr(3), exer, &
rBethe_i, rBethe_d, sgp, r_g, la, dval
integer(kind=irg) :: io_int(3), gshort(3), gp(6)
type(QCreflisttype),pointer :: rltail
complex(kind=dbl) :: Ucg, qg
real(kind=dbl) :: Vmod, Vpmod, xig, xgp
! set the truncation parameters
rBethe_i = BetheParameter%c3 ! if larger than this value, we ignore the reflection completely
rBethe_d = BetheParameter%sgdbdiff ! excitation error cutoff for double diffraction reflections
la = 1.0/sngl(QCcell%mLambda)
! get the size of the lookup table
imh = QCcell%imax / 2
nullify(listroot)
nullify(rltail)
! transmitted beam has excitation error zero
gg = (/ 0,0,0,0,0,0 /)
QCindex = QC_getindex(QCcell, gg)
call AddQCReflection(rltail, listroot, QCcell, nref, QCindex, gg) ! this guarantees that 000 is always the first reflection
rltail%sg = 0.0
! now compute |sg|/|U_g|/lambda for the other allowed reflections; if this parameter is less than
! the threshhold, rBethe_i, then add the reflection to the list of potential reflections
i1l: do i1=-imh,imh
i2l: do i2=-imh,imh
i3l: do i3=-imh,imh
i4l: do i4=-imh,imh
i5l: do i5=-imh,imh
i6l: do i6=-imh,imh
if ((abs(i1)+abs(i2)+abs(i3)+abs(i4)+abs(i5)+abs(i6)).ne.0) then ! avoid double counting the origin
gg = (/ i1, i2, i3, i4, i5, i6 /)
QCindex = QC_getindex(QCcell, gg)
sgp = QC_Calcsg(QCcell,gg,k,FN)
Ucg = QCcell%LUT(QCindex)
r_g = la * abs(sgp)/cdabs(Ucg)
if (r_g.le.rBethe_i) then
call AddQCReflection( rltail, listroot, QCcell, nref, QCindex, gg )
rltail%sg = sgp
rltail%glen = QC_getvectorLength(QCcell, gg, 'P', 'r')
end if
end if
end do i6l
end do i5l
end do i4l
end do i3l
end do i2l
end do i1l
if (present(verbose)) then
if (verbose) then
io_int(1) = nref
call WriteValue(' Length of the master list of reflections : ', io_int, 1, "(I8)")
end if
end if
end subroutine Initialize_QCReflectionList
!--------------------------------------------------------------------------
!
! SUBROUTINE: QC_Apply_BethePotentials
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief tag weak and strong reflections in cell%reflist
!
!> @param cell unit cell pointer
!> @param BetheParameter Bethe Potential parameter structure
!> @param listroot top of reflection linked list
!> @param listrootw top of weak reflection linked list
!> @param nref total number of reflections
!> @param nns number of strong reflections
!> @param nnw number of weak reflections
!
!> @details This routine steps through the listroot linked list and
!> determines for each reflection whether it is strong or weak or should be
!> ignored. Strong and weak reflections are then linked in a new list via
!> the nexts and nextw pointers, along with the nns and nnw counters.
!> This routine makes use of the BetheParameter variables.
!
!> @date 01/14/14 MDG 1.0 original version
!> @date 06/09/14 MDG 2.0 added cell and BetheParameter arguments
!> @date 06/17/14 MDG 2.1 added listroot, listrootw, nns, nnw arguments
!--------------------------------------------------------------------------
recursive subroutine QC_Apply_BethePotentials(QCcell, listroot, listrootw, BetheParameter, nref, nns, nnw)
!DEC$ ATTRIBUTES DLLEXPORT :: QC_Apply_BethePotentials
use io
use diffraction
IMPLICIT NONE
type(QCStructureType),pointer :: QCcell
type(QCreflisttype),pointer :: listroot
type(QCreflisttype),pointer :: listrootw
type(BetheParameterType),INTENT(IN) :: BetheParameter
integer(kind=irg),INTENT(IN) :: nref
integer(kind=irg),INTENT(OUT) :: nns
integer(kind=irg),INTENT(OUT) :: nnw
integer(kind=irg),allocatable :: glist(:,:)
real(kind=dbl),allocatable :: rh(:)
type(QCreflisttype),pointer :: rl, lastw, lasts
integer(kind=irg) :: icnt, istat, gmh(6), ir, ih, QCindex
real(kind=dbl) :: sgp, la, m
complex(kind=dbl) :: Ugh, qg
real(kind=dbl) :: Vmod, Vpmod, xig, xgp
nullify(lasts)
nullify(lastw)
nullify(rl)
! first we extract the list of g-vectors from reflist, so that we can compute
! all the g-h difference vectors
allocate(glist(6,nref),rh(nref),stat=istat)
rl => listroot%next
icnt = 0
do
if (.not.associated(rl)) EXIT
icnt = icnt+1
glist(1:6,icnt) = rl%hkl(1:6)
rl => rl%next
end do
! initialize the strong and weak reflection counters
nns = 1
nnw = 0
! the first reflection is always strong
rl => listroot%next
rl%strong = .TRUE.
rl%weak = .FALSE.
lasts => rl
nullify(lasts%nextw)
la = 1.D0/QCcell%mLambda
! next we need to iterate through all reflections in glist and
! determine which category the reflection belongs to: strong, weak, ignore
irloop: do ir = 2,icnt
rl => rl%next
rh = 0.D0
sgp = la * abs(rl%sg)
do ih = 1,icnt
gmh(1:6) = glist(1:6,ir) - glist(1:6,ih)
!QCindex = QC_get6Dindex(QCcell, gmh)
QCindex = QC_getindex(QCcell, gmh)
Ugh = QCcell%LUT(QCindex)
if (cdabs(Ugh).eq.0.D0) then
rh(ih) = 10000.D0
else
rh(ih) = sgp/cdabs(Ugh)
end if
end do
! which category does reflection ir belong to ?
m = minval(rh)
! m > c2 => ignore this reflection
if (m.gt.BetheParameter%c2) then
rl%weak = .FALSE.
rl%strong = .FALSE.
CYCLE irloop
end if
! c1 < m < c2 => weak reflection
if ((BetheParameter%c1.lt.m).and.(m.le.BetheParameter%c2)) then
if (nnw.eq.0) then
listrootw => rl
lastw => rl
else
lastw%nextw => rl
lastw => rl
nullify(lastw%nexts)
end if
rl%weak = .TRUE.
rl%strong = .FALSE.
nnw = nnw + 1
CYCLE irloop
end if
! m < c1 => strong
if (m.le.BetheParameter%c1) then
lasts%nexts => rl
nullify(lasts%nextw)
lasts => rl
rl%weak = .FALSE.
rl%strong = .TRUE.
nns = nns + 1
end if
end do irloop
deallocate(glist, rh)
end subroutine QC_Apply_BethePotentials
!--------------------------------------------------------------------------
!
! SUBROUTINE: TDQC_Apply_BethePotentials
!
!> @author Marc De Graef, Carnegie Mellon University
!
!> @brief tag weak and strong reflections in cell%reflist
!
!> @param cell unit cell pointer
!> @param BetheParameter Bethe Potential parameter structure
!> @param listroot top of reflection linked list
!> @param listrootw top of weak reflection linked list
!> @param nref total number of reflections
!> @param nns number of strong reflections
!> @param nnw number of weak reflections
!
!> @details This routine steps through the listroot linked list and
!> determines for each reflection whether it is strong or weak or should be
!> ignored. Strong and weak reflections are then linked in a new list via
!> the nexts and nextw pointers, along with the nns and nnw counters.
!> This routine makes use of the BetheParameter variables.
!
!> @date 01/14/14 MDG 1.0 original version
!> @date 06/09/14 MDG 2.0 added cell and BetheParameter arguments
!> @date 06/17/14 MDG 2.1 added listroot, listrootw, nns, nnw arguments
!> @date 03/23/18 SS 2.2 adapted from QCmod.f90
!--------------------------------------------------------------------------
recursive subroutine TDQC_Apply_BethePotentials(QCcell, listroot, listrootw, BetheParameter, nref, nns, nnw)
!DEC$ ATTRIBUTES DLLEXPORT :: TDQC_Apply_BethePotentials
use io
use diffraction
IMPLICIT NONE
type(TDQCStructureType),pointer :: QCcell
type(TDQCreflisttype),pointer :: listroot
type(TDQCreflisttype),pointer :: listrootw
type(BetheParameterType),INTENT(IN) :: BetheParameter
integer(kind=irg),INTENT(IN) :: nref
integer(kind=irg),INTENT(OUT) :: nns
integer(kind=irg),INTENT(OUT) :: nnw
integer(kind=irg),allocatable :: glist(:,:)
real(kind=dbl),allocatable :: rh(:)
type(TDQCreflisttype),pointer :: rl, lastw, lasts
integer(kind=irg) :: icnt, istat, gmh(5), ir, ih, QCindex
real(kind=dbl) :: sgp, la, m
complex(kind=dbl) :: Ugh, qg
real(kind=dbl) :: Vmod, Vpmod, xig, xgp, eps
eps = 1.D0-8
nullify(lasts)
nullify(lastw)
nullify(rl)
! first we extract the list of g-vectors from reflist, so that we can compute
! all the g-h difference vectors
allocate(glist(5,nref),rh(nref),stat=istat)
rl => listroot%next
icnt = 0
do
if (.not.associated(rl)) EXIT
icnt = icnt+1
glist(1:5,icnt) = rl%hkl(1:5)
rl => rl%next
end do
! initialize the strong and weak reflection counters
nns = 1
nnw = 0
! the first reflection is always strong
rl => listroot%next
rl%strong = .TRUE.
rl%weak = .FALSE.
lasts => rl
nullify(lasts%nextw)
la = 1.D0/QCcell%mLambda
! next we need to iterate through all reflections in glist and
! determine which category the reflection belongs to: strong, weak, ignore
irloop: do ir = 2,icnt
rl => rl%next
rh = 0.D0
sgp = la * abs(rl%sg)
do ih = 1,icnt
gmh(1:5) = glist(1:5,ir) - glist(1:5,ih)
QCindex = QC_getindex(QCcell, gmh)
Ugh = QCcell%LUT(QCindex) !QCcell%LUT(gmh(1),gmh(2),gmh(3),gmh(4),gmh(5))
if (cdabs(Ugh) .lt. eps) then
rh(ih) = 10000.D0
else
rh(ih) = sgp/cdabs(Ugh)
end if
end do
! which category does reflection ir belong to ?
m = minval(rh)
! m > c2 => ignore this reflection
if (m.gt.BetheParameter%c2) then
rl%weak = .FALSE.
rl%strong = .FALSE.
CYCLE irloop
end if
! c1 < m < c2 => weak reflection
if ((BetheParameter%c1.lt.m).and.(m.le.BetheParameter%c2)) then
if (nnw.eq.0) then
listrootw => rl
lastw => rl
else
lastw%nextw => rl
lastw => rl
nullify(lastw%nexts)
end if
rl%weak = .TRUE.
rl%strong = .FALSE.
nnw = nnw + 1
CYCLE irloop
end if
! m < c1 => strong
if (m.le.BetheParameter%c1) then
lasts%nexts => rl
nullify(lasts%nextw)
lasts => rl
rl%weak = .FALSE.
rl%strong = .TRUE.
nns = nns + 1
end if
end do irloop
deallocate(glist, rh)
end subroutine TDQC_Apply_BethePotentials
end module gvectorsQC
| Source/EMsoftLib/gvectorsQC.f90 |
! { dg-do compile }
! { dg-options "-Wall" }
!
! PR 53655: [F03] "default initializer" warnings
!
! Contributed by Tobias Burnus <burnus@gcc.gnu.org>
type t
end type t
contains
subroutine foo(x) ! { dg-warning "defined but not used" }
type(t), intent(out) :: x
end subroutine
end
| validation_tests/llvm/f18/gfortran.dg/intent_out_8.f90 |
integer,parameter::m=10000
real::a(m), b(m)
real::fact=0.5
do concurrent (i=1:m)
a(i) = a(i) + fact*b(i)
end do
write(*,"(A)") "Done"
end
| tests/fortran/concurrent.f90 |
module hoecH_tbl
!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
!-----------------------------------------------------------------------
!
! !ROUTINE: hoecH_tbl - a F90 module of hoecH input tables
!
! !INTERFACE: (to do)
!
! !DESCRIPTION:
!
! !EXAMPLES:
!
! !BUGS:
!
! !SEE ALSO:
!
! !SYSTEM ROUTINES:
!
! !FILES USED:
!
! !REVISION HISTORY:
! 10Jan96 - J. Guo - programmed and added the prolog
! 19Sep96 - J. Guo - add `save' to all public variables
!_______________________________________________________________________
use config, only : lvmax_hc, MXpar_hc, MX_hoecH
implicit none
public
integer,save :: n_hoecH ! a counter upto MX_hoecH
character*16,save :: name_hoecH(MX_hoecH) ! classes
character*16,save :: type_hoecH(MX_hoecH) ! functional form
character*64,save :: desc_hoecH(MX_hoecH) ! descriptions
integer,save :: nlev_hoecH(MX_hoecH)
integer,save :: npar_hoecH(MX_hoecH)
real,save :: plev_hoecH(lvmax_hc,MX_hoecH)
real,save :: pars_hoecH(MXpar_hc,lvmax_hc,MX_hoecH)
contains
subroutine hoecH_tbl0()
end subroutine hoecH_tbl0
end module hoecH_tbl
| src/Shared/GMAO_Shared/GMAO_psas/hoecH_tbl.f90 |
module tagging_module
use amrex_fort_module, only : rt => amrex_real
implicit none
real(rt) , save :: denerr, dengrad, dengrad_rel
real(rt) , save :: enterr, entgrad, entgrad_rel
real(rt) , save :: velerr, velgrad, velgrad_rel
real(rt) , save :: temperr, tempgrad, tempgrad_rel
real(rt) , save :: presserr, pressgrad, pressgrad_rel
real(rt) , save :: raderr, radgrad, radgrad_rel
integer , save :: max_denerr_lev, max_dengrad_lev, max_dengrad_rel_lev
integer , save :: max_enterr_lev, max_entgrad_lev, max_entgrad_rel_lev
integer , save :: max_velerr_lev, max_velgrad_lev, max_velgrad_rel_lev
integer , save :: max_temperr_lev, max_tempgrad_lev, max_tempgrad_rel_lev
integer , save :: max_presserr_lev, max_pressgrad_lev, max_pressgrad_rel_lev
integer , save :: max_raderr_lev, max_radgrad_lev, max_radgrad_rel_lev
public
contains
! All tagging subroutines in this file must be threadsafe because
! they are called inside OpenMP parallel regions.
! ::: -----------------------------------------------------------
! ::: INPUTS/OUTPUTS:
! :::
! ::: tag <= integer tag array
! ::: lo,hi => index extent of work region
! ::: set => integer value to tag cell for refinement
! ::: clear => integer value to untag cell
! ::: temp => temperature array
! ::: np => number of components in temp array (should be 1)
! ::: domlo,hi => index extent of problem domain
! ::: delta => cell spacing
! ::: xlo => physical location of lower left hand
! ::: corner of work region
! ::: problo => phys loc of lower left corner of prob domain
! ::: time => problem evolution time
! ::: level => refinement level of this array
! ::: -----------------------------------------------------------
! ::: -----------------------------------------------------------
! ::: This routine will tag high error cells based on the Laplacian.
! ::: -----------------------------------------------------------
subroutine ca_laplac_error(tag,taglo,taghi, &
set,clear, &
var,varlo,varhi, &
lo,hi,nd,domlo,domhi, &
delta,xlo,problo,time,level) &
bind(C, name="ca_laplac_error")
use prob_params_module, only: dg, dim
use amrex_fort_module, only : rt => amrex_real
implicit none
integer, intent(in) :: set, clear, nd, level
integer, intent(in) :: taglo(3), taghi(3)
integer, intent(in) :: varlo(3), varhi(3)
integer, intent(in) :: lo(3), hi(3), domlo(3), domhi(3)
integer, intent(inout) :: tag(taglo(1):taghi(1),taglo(2):taghi(2),taglo(3):taghi(3))
real(rt), intent(in) :: var(varlo(1):varhi(1),varlo(2):varhi(2),varlo(3):varhi(3))
real(rt), intent(in) :: delta(3), xlo(3), problo(3), time
integer :: i, j, k
real(rt) :: delu(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,lo(3)-1:hi(3)+1,3)
real(rt) :: delua(lo(1)-1:hi(1)+1,lo(2)-1:hi(2)+1,lo(3)-1:hi(3)+1,3)
real(rt) :: delu2(9), delu3(9), delu4(9)
real(rt) :: num, denom, error
! This value is taken from FLASH
real(rt) , parameter :: ctore=0.8
real(rt) , parameter :: epsil=0.02
! adapted from ref_marking.f90 in FLASH2.5
delu = 0.0
delua = 0.0
! d/dx
do k=lo(3)-1*dg(3),hi(3)+1*dg(3)
do j=lo(2)-1*dg(2),hi(2)+1*dg(2)
do i=lo(1)-1*dg(1),hi(1)+1*dg(1)
delu(i,j,k,1) = var(i+1*dg(1),j,k) - var(i-1*dg(1),j,k)
delua(i,j,k,1) = abs(var(i+1*dg(1),j,k)) + abs(var(i-1*dg(1),j,k))
end do
end do
end do
! d/dy
if (dim .ge. 2) then
do k=lo(3)-1*dg(3),hi(3)+1*dg(3)
do j=lo(2)-1*dg(2),hi(2)+1*dg(2)
do i=lo(1)-1*dg(1),hi(1)+1*dg(1)
delu(i,j,k,2) = var(i,j+1*dg(2),k) - var(i,j-1*dg(2),k)
delua(i,j,k,2) = abs(var(i,j+1*dg(2),k)) + abs(var(i,j-1*dg(2),k))
end do
end do
end do
endif
! d/dz
if (dim .eq. 3) then
do k=lo(3)-1*dg(3),hi(3)+1*dg(3)
do j=lo(2)-1*dg(2),hi(2)+1*dg(2)
do i=lo(1)-1*dg(1),hi(1)+1*dg(1)
delu(i,j,k,3) = var(i,j,k+1*dg(3)) - var(i,j,k-1*dg(3))
delua(i,j,k,3) = abs(var(i,j,k+1*dg(3))) + abs(var(i,j,k-1*dg(3)))
end do
end do
end do
endif
do k = lo(3),hi(3)
do j = lo(2),hi(2)
do i = lo(1),hi(1)
! d/dxdx
delu2(1) = delu(i+1,j,k,1) - delu(i-1,j,k,1)
delu3(1) = abs(delu(i+1,j,k,1)) + abs(delu(i-1,j,k,1))
delu4(1) = delua(i+1,j,k,1) + delua(i-1,j,k,1)
! d/dydx
delu2(2) = delu(i,j+1,k,1) - delu(i,j-1,k,1)
delu3(2) = abs(delu(i,j+1,k,1)) + abs(delu(i,j-1,k,1))
delu4(2) = delua(i,j+1,k,1) + delua(i,j-1,k,1)
! d/dxdy
delu2(3) = delu(i+1,j,k,2) - delu(i-1,j,k,2)
delu3(3) = abs(delu(i+1,j,k,2)) + abs(delu(i-1,j,k,2))
delu4(3) = delua(i+1,j,k,2) + delua(i-1,j,k,2)
! d/dydy
delu2(4) = delu(i,j+1,k,2) - delu(i,j-1,k,2)
delu3(4) = abs(delu(i,j+1,k,2)) + abs(delu(i,j-1,k,2))
delu4(4) = delua(i,j+1,k,2) + delua(i,j-1,k,2)
! d/dzdx
delu2(5) = delu(i,j,k+1,1) - delu(i,j,k-1,1)
delu3(5) = abs(delu(i,j,k+1,1)) + abs(delu(i,j,k-1,1))
delu4(5) = delua(i,j,k+1,1) + delua(i,j,k-1,1)
! d/dzdy
delu2(6) = delu(i,j,k+1,2) - delu(i,j,k-1,2)
delu3(6) = abs(delu(i,j,k+1,2)) + abs(delu(i,j,k-1,2))
delu4(6) = delua(i,j,k+1,2) + delua(i,j,k-1,2)
! d/dxdz
delu2(7) = delu(i+1,j,k,3) - delu(i-1,j,k,3)
delu3(7) = abs(delu(i+1,j,k,3)) + abs(delu(i-1,j,k,3))
delu4(7) = delua(i+1,j,k,3) + delua(i-1,j,k,3)
! d/dydz
delu2(8) = delu(i,j+1,k,3) - delu(i,j-1,k,3)
delu3(8) = abs(delu(i,j+1,k,3)) + abs(delu(i,j-1,k,3))
delu4(8) = delua(i,j+1,k,3) + delua(i,j-1,k,3)
! d/dzdz
delu2(9) = delu(i,j,k+1,3) - delu(i,j,k-1,3)
delu3(9) = abs(delu(i,j,k+1,3)) + abs(delu(i,j,k-1,3))
delu4(9) = delua(i,j,k+1,3) + delua(i,j,k-1,3)
! compute the error
num = sum(delu2**2)
denom = sum((delu3 + (epsil*delu4+1.e-99_rt))**2)
error = sqrt(num/denom)
if (error .gt. ctore) tag(i,j,k) = set
end do
end do
end do
end subroutine ca_laplac_error
! ::: -----------------------------------------------------------
! ::: This routine will tag high error cells based on the density
! ::: -----------------------------------------------------------
subroutine ca_denerror(tag,taglo,taghi, &
set,clear, &
den,denlo,denhi, &
lo,hi,nd,domlo,domhi, &
delta,xlo,problo,time,level) &
bind(C, name="ca_denerror")
use prob_params_module, only: dg
use amrex_fort_module, only : rt => amrex_real
implicit none
integer, intent(in) :: set, clear, nd, level
integer, intent(in) :: taglo(3), taghi(3)
integer, intent(in) :: denlo(3), denhi(3)
integer, intent(in) :: lo(3), hi(3), domlo(3), domhi(3)
integer, intent(inout) :: tag(taglo(1):taghi(1),taglo(2):taghi(2),taglo(3):taghi(3))
real(rt), intent(in) :: den(denlo(1):denhi(1),denlo(2):denhi(2),denlo(3):denhi(3),nd)
real(rt), intent(in) :: delta(3), xlo(3), problo(3), time
real(rt) :: ax, ay, az
integer :: i, j, k
! Tag on regions of high density
if (level .lt. max_denerr_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
if (den(i,j,k,1) .ge. denerr) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
! Tag on regions of high density gradient
if (level .lt. max_dengrad_lev .or. level .lt. max_dengrad_rel_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
ax = ABS(den(i+1*dg(1),j,k,1) - den(i,j,k,1))
ay = ABS(den(i,j+1*dg(2),k,1) - den(i,j,k,1))
az = ABS(den(i,j,k+1*dg(3),1) - den(i,j,k,1))
ax = MAX(ax,ABS(den(i,j,k,1) - den(i-1*dg(1),j,k,1)))
ay = MAX(ay,ABS(den(i,j,k,1) - den(i,j-1*dg(2),k,1)))
az = MAX(az,ABS(den(i,j,k,1) - den(i,j,k-1*dg(3),1)))
if (MAX(ax,ay,az) .ge. dengrad .or. MAX(ax,ay,az) .ge. ABS(dengrad_rel * den(i,j,k,1))) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
end subroutine ca_denerror
! ::: -----------------------------------------------------------
! ::: This routine will tag high error cells based on the temperature
! ::: -----------------------------------------------------------
subroutine ca_temperror(tag,taglo,taghi, &
set,clear, &
temp,templo,temphi, &
lo,hi,np,domlo,domhi, &
delta,xlo,problo,time,level) &
bind(C, name="ca_temperror")
use prob_params_module, only: dg
use amrex_fort_module, only : rt => amrex_real
implicit none
integer, intent(in) :: set, clear, np, level
integer, intent(in) :: taglo(3), taghi(3)
integer, intent(in) :: templo(3), temphi(3)
integer, intent(in) :: lo(3), hi(3), domlo(3), domhi(3)
integer, intent(inout) :: tag(taglo(1):taghi(1),taglo(2):taghi(2),taglo(3):taghi(3))
real(rt), intent(in) :: temp(templo(1):temphi(1),templo(2):temphi(2),templo(3):temphi(3),np)
real(rt), intent(in) :: delta(3), xlo(3), problo(3), time
real(rt) :: ax, ay, az
integer :: i, j, k
! Tag on regions of high temperature
if (level .lt. max_temperr_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
if (temp(i,j,k,1) .ge. temperr) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
! Tag on regions of high temperature gradient
if (level .lt. max_tempgrad_lev .or. level .lt. max_tempgrad_rel_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
ax = ABS(temp(i+1*dg(1),j,k,1) - temp(i,j,k,1))
ay = ABS(temp(i,j+1*dg(2),k,1) - temp(i,j,k,1))
az = ABS(temp(i,j,k+1*dg(3),1) - temp(i,j,k,1))
ax = MAX(ax,ABS(temp(i,j,k,1) - temp(i-1*dg(1),j,k,1)))
ay = MAX(ay,ABS(temp(i,j,k,1) - temp(i,j-1*dg(2),k,1)))
az = MAX(az,ABS(temp(i,j,k,1) - temp(i,j,k-1*dg(3),1)))
if (MAX(ax,ay,az) .ge. tempgrad .or. MAX(ax,ay,az) .ge. ABS(tempgrad_rel * temp(i,j,k,1))) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
end subroutine ca_temperror
! ::: -----------------------------------------------------------
! ::: This routine will tag high error cells based on the pressure
! ::: -----------------------------------------------------------
subroutine ca_presserror(tag,taglo,taghi, &
set,clear, &
press,presslo,presshi, &
lo,hi,np,domlo,domhi, &
delta,xlo,problo,time,level) &
bind(C, name="ca_presserror")
use prob_params_module, only: dg
use amrex_fort_module, only : rt => amrex_real
implicit none
integer, intent(in) :: set, clear, np, level
integer, intent(in) :: taglo(3), taghi(3)
integer, intent(in) :: presslo(3), presshi(3)
integer, intent(in) :: lo(3), hi(3), domlo(3), domhi(3)
integer, intent(inout) :: tag(taglo(1):taghi(1),taglo(2):taghi(2),taglo(3):taghi(3))
real(rt), intent(in) :: press(presslo(1):presshi(1),presslo(2):presshi(2),presslo(3):presshi(3),np)
real(rt), intent(in) :: delta(3), xlo(3), problo(3), time
real(rt) :: ax, ay, az
integer :: i, j, k
! Tag on regions of high pressure
if (level .lt. max_presserr_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
if (press(i,j,k,1) .ge. presserr) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
! Tag on regions of high pressure gradient
if (level .lt. max_pressgrad_lev .or. level .lt. max_pressgrad_rel_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
ax = ABS(press(i+1*dg(1),j,k,1) - press(i,j,k,1))
ay = ABS(press(i,j+1*dg(2),k,1) - press(i,j,k,1))
az = ABS(press(i,j,k+1*dg(3),1) - press(i,j,k,1))
ax = MAX(ax,ABS(press(i,j,k,1) - press(i-1*dg(1),j,k,1)))
ay = MAX(ay,ABS(press(i,j,k,1) - press(i,j-1*dg(2),k,1)))
az = MAX(az,ABS(press(i,j,k,1) - press(i,j,k-1*dg(3),1)))
if (MAX(ax,ay,az) .ge. pressgrad .or. MAX(ax,ay,az) .ge. ABS(pressgrad_rel * press(i,j,k,1))) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
end subroutine ca_presserror
! ::: -----------------------------------------------------------
! ::: This routine will tag high error cells based on the velocity
! ::: -----------------------------------------------------------
subroutine ca_velerror(tag,taglo,taghi, &
set,clear, &
vel,vello,velhi, &
lo,hi,nv,domlo,domhi, &
delta,xlo,problo,time,level) &
bind(C, name="ca_velerror")
use prob_params_module, only: dg
use amrex_fort_module, only : rt => amrex_real
implicit none
integer, intent(in) :: set, clear, nv, level
integer, intent(in) :: taglo(3), taghi(3)
integer, intent(in) :: vello(3), velhi(3)
integer, intent(in) :: lo(3), hi(3), domlo(3), domhi(3)
integer, intent(inout) :: tag(taglo(1):taghi(1),taglo(2):taghi(2),taglo(3):taghi(3))
real(rt), intent(in) :: vel(vello(1):velhi(1),vello(2):velhi(2),vello(3):velhi(3),nv)
real(rt), intent(in) :: delta(3), xlo(3), problo(3), time
real(rt) :: ax, ay, az
integer :: i, j, k
! Tag on regions of high velocity
if (level .lt. max_velerr_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
if (vel(i,j,k,1) .ge. velerr) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
! Tag on regions of high velocity gradient
if (level .lt. max_velgrad_lev .or. level .lt. max_velgrad_rel_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
ax = ABS(vel(i+1*dg(1),j,k,1) - vel(i,j,k,1))
ay = ABS(vel(i,j+1*dg(2),k,1) - vel(i,j,k,1))
az = ABS(vel(i,j,k+1*dg(3),1) - vel(i,j,k,1))
ax = MAX(ax,ABS(vel(i,j,k,1) - vel(i-1*dg(1),j,k,1)))
ay = MAX(ay,ABS(vel(i,j,k,1) - vel(i,j-1*dg(2),k,1)))
az = MAX(az,ABS(vel(i,j,k,1) - vel(i,j,k-1*dg(3),1)))
if (MAX(ax,ay,az) .ge. velgrad .or. MAX(ax,ay,az) .ge. ABS(velgrad_rel * vel(i,j,k,1))) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
end subroutine ca_velerror
! ::: -----------------------------------------------------------
! ::: This routine will tag high error cells based on the radiation
! ::: -----------------------------------------------------------
subroutine ca_raderror(tag,taglo,taghi, &
set,clear, &
rad,radlo,radhi, &
lo,hi,nr,domlo,domhi, &
delta,xlo,problo,time,level) &
bind(C, name="ca_raderror")
use prob_params_module, only: dg
use amrex_fort_module, only : rt => amrex_real
implicit none
integer, intent(in) :: set, clear, nr, level
integer, intent(in) :: taglo(3), taghi(3)
integer, intent(in) :: radlo(3), radhi(3)
integer, intent(in) :: lo(3), hi(3), domlo(3), domhi(3)
integer, intent(inout) :: tag(taglo(1):taghi(1),taglo(2):taghi(2),taglo(3):taghi(3))
real(rt), intent(in) :: rad(radlo(1):radhi(1),radlo(2):radhi(2),radlo(3):radhi(3),nr)
real(rt), intent(in) :: delta(3), xlo(3), problo(3), time
real(rt) :: ax, ay, az
integer :: i, j, k
! Tag on regions of high radiation
if (level .lt. max_raderr_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
if (rad(i,j,k,1) .ge. raderr) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
! Tag on regions of high radiation gradient
if (level .lt. max_radgrad_lev .or. level .lt. max_radgrad_rel_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
ax = ABS(rad(i+1*dg(1),j,k,1) - rad(i,j,k,1))
ay = ABS(rad(i,j+1*dg(2),k,1) - rad(i,j,k,1))
az = ABS(rad(i,j,k+1*dg(3),1) - rad(i,j,k,1))
ax = MAX(ax,ABS(rad(i,j,k,1) - rad(i-1*dg(1),j,k,1)))
ay = MAX(ay,ABS(rad(i,j,k,1) - rad(i,j-1*dg(2),k,1)))
az = MAX(az,ABS(rad(i,j,k,1) - rad(i,j,k-1*dg(3),1)))
if (MAX(ax,ay,az) .ge. radgrad .or. MAX(ax,ay,az) .ge. ABS(radgrad_rel * rad(i,j,k,1))) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
end subroutine ca_raderror
! ::: -----------------------------------------------------------
! ::: This routine will tag high error cells based on the entropy
! ::: -----------------------------------------------------------
subroutine ca_enterror(tag,taglo,taghi, &
set,clear, &
ent,entlo,enthi, &
lo,hi,nr,domlo,domhi, &
delta,xlo,problo,time,level) &
bind(C, name="ca_enterror")
use prob_params_module, only: dg
use amrex_fort_module, only : rt => amrex_real
implicit none
integer, intent(in) :: set, clear, nr, level
integer, intent(in) :: taglo(3), taghi(3)
integer, intent(in) :: entlo(3), enthi(3)
integer, intent(in) :: lo(3), hi(3), domlo(3), domhi(3)
integer, intent(inout) :: tag(taglo(1):taghi(1),taglo(2):taghi(2),taglo(3):taghi(3))
real(rt), intent(in) :: ent(entlo(1):enthi(1),entlo(2):enthi(2),entlo(3):enthi(3),nr)
real(rt), intent(in) :: delta(3), xlo(3), problo(3), time
real(rt) :: ax, ay, az
integer :: i, j, k
! Tag on regions of high radiation
if (level .lt. max_enterr_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
if (ent(i,j,k,1) .ge. enterr) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
! Tag on regions of high radiation gradient
if (level .lt. max_entgrad_lev .or. level .lt. max_entgrad_rel_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
ax = ABS(ent(i+1*dg(1),j,k,1) - ent(i,j,k,1))
ay = ABS(ent(i,j+1*dg(2),k,1) - ent(i,j,k,1))
az = ABS(ent(i,j,k+1*dg(3),1) - ent(i,j,k,1))
ax = MAX(ax,ABS(ent(i,j,k,1) - ent(i-1*dg(1),j,k,1)))
ay = MAX(ay,ABS(ent(i,j,k,1) - ent(i,j-1*dg(2),k,1)))
az = MAX(az,ABS(ent(i,j,k,1) - ent(i,j,k-1*dg(3),1)))
if (MAX(ax,ay,az) .ge. entgrad .or. MAX(ax,ay,az) .ge. ABS(entgrad_rel * ent(i,j,k,1))) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
endif
end subroutine ca_enterror
! ::: -----------------------------------------------------------
! ::: This routine will tag cells based on the sound crossing time
! ::: relative to the nuclear energy injection timescale.
! ::: At present we tag for maximal refinement since this
! ::: criterion is necessary for numerical burning stability.
! ::: -----------------------------------------------------------
subroutine ca_nucerror(tag,taglo,taghi, &
set,clear, &
t,tlo,thi, &
lo,hi,nr,domlo,domhi, &
delta,xlo,problo,time,level) &
bind(C, name="ca_nucerror")
use meth_params_module, only: dxnuc, dxnuc_max, max_dxnuc_lev
use amrex_fort_module, only : rt => amrex_real
implicit none
integer, intent(in) :: set, clear, nr, level
integer, intent(in) :: taglo(3), taghi(3)
integer, intent(in) :: tlo(3), thi(3)
integer, intent(in) :: lo(3), hi(3), domlo(3), domhi(3)
integer, intent(inout) :: tag(taglo(1):taghi(1),taglo(2):taghi(2),taglo(3):taghi(3))
real(rt), intent(in) :: t(tlo(1):thi(1),tlo(2):thi(2),tlo(3):thi(3),nr) ! t_sound / t_e
real(rt), intent(in) :: delta(3), xlo(3), problo(3), time
integer :: i, j, k
! Disable if we're not utilizing this tagging
if (dxnuc > 1.e199_rt) return
if (level .lt. max_dxnuc_lev) then
do k = lo(3), hi(3)
do j = lo(2), hi(2)
do i = lo(1), hi(1)
if (t(i,j,k,1) > dxnuc .and. t(i,j,k,1) < dxnuc_max) then
tag(i,j,k) = set
endif
enddo
enddo
enddo
end if
end subroutine ca_nucerror
! Routines for retrieving the maximum tagging level.
subroutine get_max_denerr_lev(lev) bind(c, name='get_max_denerr_lev')
implicit none
integer, intent(out) :: lev
lev = max_denerr_lev
end subroutine get_max_denerr_lev
subroutine get_max_dengrad_lev(lev) bind(c, name='get_max_dengrad_lev')
implicit none
integer, intent(out) :: lev
lev = max_dengrad_lev
end subroutine get_max_dengrad_lev
subroutine get_max_dengrad_rel_lev(lev) bind(c, name='get_max_dengrad_rel_lev')
implicit none
integer, intent(out) :: lev
lev = max_dengrad_rel_lev
end subroutine get_max_dengrad_rel_lev
subroutine get_max_enterr_lev(lev) bind(c, name='get_max_enterr_lev')
implicit none
integer, intent(out) :: lev
lev = max_enterr_lev
end subroutine get_max_enterr_lev
subroutine get_max_entgrad_lev(lev) bind(c, name='get_max_entgrad_lev')
implicit none
integer, intent(out) :: lev
lev = max_entgrad_lev
end subroutine get_max_entgrad_lev
subroutine get_max_entgrad_rel_lev(lev) bind(c, name='get_max_entgrad_rel_lev')
implicit none
integer, intent(out) :: lev
lev = max_entgrad_rel_lev
end subroutine get_max_entgrad_rel_lev
subroutine get_max_velerr_lev(lev) bind(c, name='get_max_velerr_lev')
implicit none
integer, intent(out) :: lev
lev = max_velerr_lev
end subroutine get_max_velerr_lev
subroutine get_max_velgrad_lev(lev) bind(c, name='get_max_velgrad_lev')
implicit none
integer, intent(out) :: lev
lev = max_velgrad_lev
end subroutine get_max_velgrad_lev
subroutine get_max_velgrad_rel_lev(lev) bind(c, name='get_max_velgrad_rel_lev')
implicit none
integer, intent(out) :: lev
lev = max_velgrad_rel_lev
end subroutine get_max_velgrad_rel_lev
subroutine get_max_temperr_lev(lev) bind(c, name='get_max_temperr_lev')
implicit none
integer, intent(out) :: lev
lev = max_temperr_lev
end subroutine get_max_temperr_lev
subroutine get_max_tempgrad_lev(lev) bind(c, name='get_max_tempgrad_lev')
implicit none
integer, intent(out) :: lev
lev = max_tempgrad_lev
end subroutine get_max_tempgrad_lev
subroutine get_max_tempgrad_rel_lev(lev) bind(c, name='get_max_tempgrad_rel_lev')
implicit none
integer, intent(out) :: lev
lev = max_tempgrad_rel_lev
end subroutine get_max_tempgrad_rel_lev
subroutine get_max_presserr_lev(lev) bind(c, name='get_max_presserr_lev')
implicit none
integer, intent(out) :: lev
lev = max_presserr_lev
end subroutine get_max_presserr_lev
subroutine get_max_pressgrad_lev(lev) bind(c, name='get_max_pressgrad_lev')
implicit none
integer, intent(out) :: lev
lev = max_pressgrad_lev
end subroutine get_max_pressgrad_lev
subroutine get_max_pressgrad_rel_lev(lev) bind(c, name='get_max_pressgrad_rel_lev')
implicit none
integer, intent(out) :: lev
lev = max_pressgrad_rel_lev
end subroutine get_max_pressgrad_rel_lev
subroutine get_max_raderr_lev(lev) bind(c, name='get_max_raderr_lev')
implicit none
integer, intent(out) :: lev
lev = max_raderr_lev
end subroutine get_max_raderr_lev
subroutine get_max_radgrad_lev(lev) bind(c, name='get_max_radgrad_lev')
implicit none
integer, intent(out) :: lev
lev = max_radgrad_lev
end subroutine get_max_radgrad_lev
subroutine get_max_radgrad_rel_lev(lev) bind(c, name='get_max_radgrad_rel_lev')
implicit none
integer, intent(out) :: lev
lev = max_radgrad_rel_lev
end subroutine get_max_radgrad_rel_lev
end module tagging_module
| Source/driver/Tagging_nd.f90 |
! ###############################################################
! # #
! # VLIDORT_2p8p2 #
! # #
! # Vectorized LInearized Discrete Ordinate Radiative Transfer #
! # - -- - - - - #
! # #
! ###############################################################
! ###############################################################
! # #
! # Authors : Robert. J. D. Spurr (1) #
! # Matt Christi #
! # #
! # Address (1) : RT Solutions, inc. #
! # 9 Channing Street #
! # Cambridge, MA 02138, USA #
! # #
! # Tel: (617) 492 1183 #
! # Email : rtsolutions@verizon.net #
! # #
! # This Version : VLIDORT_2p8p2 #
! # Release Date : 15 April 2020 #
! # #
! # Previous VLIDORT Versions under Standard GPL 3.0: #
! # ------------------------------------------------ #
! # #
! # 2.7 F90, released August 2014 #
! # 2.8 F90, released May 2017 #
! # 2.8.1 F90, released August 2019 #
! # #
! # Features Summary of Recent VLIDORT Versions: #
! # ------------------------------------------- #
! # #
! # NEW: TOTAL COLUMN JACOBIANS (2.4) #
! # NEW: BPDF Land-surface KERNELS (2.4R) #
! # NEW: Thermal Emission Treatment (2.4RT) #
! # Consolidated BRDF treatment (2.4RTC) #
! # f77/f90 Release (2.5) #
! # External SS / New I/O Structures (2.6) #
! # #
! # SURFACE-LEAVING / BRDF-SCALING (2.7) #
! # TAYLOR Series / OMP THREADSAFE (2.7) #
! # New Water-Leaving Treatment (2.8) #
! # LBBF & BRDF-Telescoping, enabled (2.8) #
! # Several Performance Enhancements (2.8) #
! # Water-leaving coupled code (2.8.1) #
! # Planetary problem, media properties (2.8.1) #
! # #
! # Features Summary of This VLIDORT Version #
! # ---------------------------------------- #
! # #
! # 2.8.2, released 15 April 2020. #
! # ==> Geometry (FO/MS), check/derive separation #
! # ==> New setup_master for Geometry/Check/Derive #
! # ==> Reduction of zeroing, some dynamic memory #
! # ==> Use of F-matrixes only in FO code #
! # ==> Use I/O type structures directly #
! # ==> Doublet geometry post-processing option #
! # #
! ###############################################################
! ###################################################################
! # #
! # This is Version 2.8.2 of the VLIDORT_2p8 software library. #
! # This library comes with the Standard GNU General Public License,#
! # Version 3.0, 29 June 2007. Please read this license carefully. #
! # #
! # VLIDORT Copyright (c) 2003-2020. #
! # Robert Spurr, RT Solutions, Inc. #
! # 9 Channing Street, Cambridge, MA 02138, USA. #
! # #
! # This file is part of VLIDORT_2p8p2 ( Version 2.8.2 ) #
! # #
! # VLIDORT_2p8p2 is free software: you can redistribute it #
! # and/or modify it under the terms of the Standard GNU GPL #
! # (General Public License) as published by the Free Software #
! # Foundation, either version 3.0 of the License, or any #
! # later version. #
! # #
! # VLIDORT_2p8p2 is distributed in the hope that it will be #
! # useful, but WITHOUT ANY WARRANTY; without even the implied #
! # warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR #
! # PURPOSE. See the Standard GNU General Public License (GPL) #
! # for more details. #
! # #
! # You should have received a copy of the Standard GNU General #
! # Public License (GPL) Version 3.0, along with the VLIDORT_2p8p2 #
! # code package. If not, see <http://www.gnu.org/licenses/>. #
! # #
! ###################################################################
! ###############################################################
! # #
! # Taylor series, small number expansions: #
! # TAYLOR_SERIES_1 #
! # TAYLOR_SERIES_L_1 #
! # #
! ###############################################################
! 4/15/20. Version 2.8.2. No changes
MODULE vlidort_Taylor_m
USE VLIDORT_PARS_m, only : max_Taylor_terms, Taylor_small, zero, one, two
PUBLIC
CONTAINS
subroutine Taylor_series_1 &
( order, eps, delta, udel, sm, mult )
! Good for the particular and homogeneous-solution multipliers.
! Small number expansion to any order up to 4.
! Note: In LIDORT, this subroutine is applied to quantities of the form
! [exp(-b*DELTA) - exp(-a*DELTA)]
! q = -------------------------------
! (a-b)
! where (a-b) has become small to the point of causing instability.
! Note the positions of "a" and "b" in the numerator are swapped
! from their positions in the denominator.
!
! Using the above form for "q", the I/O for the subroutine is as
! follows:
! * EPS = (a-b)
! * DELTA = optical thickness (whole or partial layer)
! * TERM2 = exp(-a*DELTA) (usually UDEL or WDEL)
! * MULT = q
IMPLICIT NONE
! arguments
INTEGER , INTENT(IN) :: order
double precision, INTENT(IN) :: eps, delta, udel, sm
double precision, INTENT(OUT) :: mult
! local declarations
integer :: mterms, m
double precision :: power, d(0:max_Taylor_terms)
! exp(De) expansion coefficients
mterms = order + 1 ; d(0) = one
do m = 1, mterms
d(m) = delta * d(m-1) / dble(m)
enddo
! evaluate multiplier
mult = d(1) ; power = one
do m = 2, mterms
power = power * eps ; mult = mult + power * d(m)
enddo
mult = mult * udel * sm
! Equivalent to the following, for order = 3 (highest power of eps)
! power = delta*eps ; power2 = power*power ; power3 = power2 * power
! mult = udel * sm * delta *(one + half*power + power2/6.0_fpk + power3/24.0_fpk)
! Finish
return
end subroutine Taylor_Series_1
!
subroutine Taylor_series_L_1 ( order, eps, delta, ddot, kdot, Ldot, uterm, sm, L_mult )
! Small number expansion for derivatives of Series 1 quantities
! sm is required, but result is NOT SCALED
! L_HMULT --> sm = user-secant , Ldot = zero
! L_EMULT --> sm = user_secant , Ldot = zero
implicit none
! arguments
INTEGER , INTENT(IN) :: order
double precision, INTENT(IN) :: eps, delta, ddot, kdot, Ldot, uterm, sm
double precision, INTENT(OUT) :: L_mult
! local declarations
integer :: mterms, m, m1, m2
double precision :: power, d(0:max_Taylor_terms), series1, series2, series3
! exp(De) expansion coefficients
mterms = order + 2 ; d(0) = one
do m = 1, mterms
d(m) = delta * d(m-1) / dble(m)
enddo
! Develop series
! Series 3 absent for HMULT/EMULT, only present for GMULT
power = one
series1 = d(0) - d(1)*sm
series2 = d(2) - d(1)*delta
series3 = d(2)
do m = 1, order
m1 = m + 1 ; m2 = m1 + 1
power = power * eps
series1 = series1 + power * (d(m) - d(m1)*sm)
series2 = series2 + power * (d(m2) - d(m1)*delta)
series3 = series3 + power * d(m2)
enddo
! final
L_mult = ( ddot*series1 - Ldot*series3 + kdot*series2 ) * uterm
return
end subroutine Taylor_series_L_1
! Finish module
END MODULE vlidort_Taylor_m
| src/Components/rtms/RTSI/VLIDORT2p8p2/sourcecode_str/regular_modules/vlidort_Taylor.f90 |
! ###############################################################
! # #
! # THE VECTOR LIDORT MODEL #
! # #
! # (Vector LInearized Discrete Ordinate Radiative Transfer) #
! # - -- - - - - #
! # #
! ###############################################################
! ###############################################################
! # #
! # Author : Robert. J. D. Spurr #
! # #
! # Address : RT Solutions, inc. #
! # 9 Channing Street #
! # Cambridge, MA 02138, USA #
! # Tel: (617) 492 1183 #
! # #
! # Email : rtsolutions@verizon.net #
! # #
! # Versions : 2.0, 2.2, 2.3, 2.4, 2.4R, 2.4RT, 2.4RTC, #
! # 2.5, 2.6, 2.7 #
! # Release Date : December 2005 (2.0) #
! # Release Date : March 2007 (2.2) #
! # Release Date : October 2007 (2.3) #
! # Release Date : December 2008 (2.4) #
! # Release Date : April 2009 (2.4R) #
! # Release Date : July 2009 (2.4RT) #
! # Release Date : October 2010 (2.4RTC) #
! # Release Date : March 2011 (2.5) #
! # Release Date : May 2012 (2.6) #
! # Release Date : August 2014 (2.7) #
! # #
! # NEW: TOTAL COLUMN JACOBIANS (2.4) #
! # NEW: BPDF Land-surface KERNELS (2.4R) #
! # NEW: Thermal Emission Treatment (2.4RT) #
! # Consolidated BRDF treatment (2.4RTC) #
! # f77/f90 Release (2.5) #
! # External SS / New I/O Structures (2.6) #
! # #
! # SURFACE-LEAVING / BRDF-SCALING (2.7) #
! # TAYLOR Series / OMP THREADSAFE (2.7) #
! # #
! ###############################################################
! #####################################################
! # #
! # This Version of VLIDORT comes with a GNU-style #
! # license. Please read the license carefully. #
! # #
! #####################################################
! ###########################################################
! # #
! # 2OS History : #
! # #
! # Mark 1: 2007 for OCO-Mk1, publication #
! # Mark 2: 2009, with BRDFs #
! # Mark 3: 2013, Re-engineered Model: #
! # * Including Multiple Geometry #
! # * Merging with Stand-alone FO code #
! # * New linearization for Bulk properties #
! # Mark 4: 2014, integration with VLIDORT #
! # #
! # #
! ###########################################################
! ###########################################################
! # #
! # PUBLIC Subroutines in this Module #
! # #
! # Calculate_SecondOrder_LPSPlus #
! # Calculate_FirstOrder_LPSPlus #
! # Add_Fourier_Component_LPSPlus #
! # Calculate_Multipliers_LPPlus #
! # Set_avsecant_LPPlus #
! # #
! ###########################################################
module vlidort_2OScorr_lps_routines
use VLIDORT_PARS, only : fpk, zero, one, two, three, four, &
six, half, quarter, deg_to_rad, &
BIGEXP, TAYLOR_SMALL, Smallnum6, &
MAXLAYERS, MAXMOMENTS, MAXSTREAMS, &
MAXSTREAMS_P2, MAX_ATMOSWFS, MAX_SURFACEWFS
use vlidort_2OScorr_utilities, only : Exptrans, Exptrans_L, &
Make_Trans23, Make_Trans23_P
implicit none
public :: Calculate_SecondOrder_LPSPlus, &
Calculate_FirstOrder_LPSPlus, &
Add_Fourier_Component_LPSPlus, &
Calculate_Multipliers_LPPlus, &
Set_avsecant_LPPlus
contains
subroutine Calculate_SecondOrder_LPSPlus &
( do_LP_Jacobians,do_LS_Jacobians,m,layer,nstreams,nstokes,nlayers,npars,nspars, & ! Input Control
qweights,omega,xv,xa, LP_omega,LP_xa, & ! Inputs
O2_AVTrans, LP_O2_AVTrans, & ! Input R2 Multiplier
O2_QVMult_d, LP_O2_QVMult_d, & ! Input R2 Multipliers
O2_QAMult_d, LP_O2_QAMult_d, & ! Input R2 Multipliers
O2_QAVMult_du, LP_O2_QAVMult_du, & ! Input R2 Multipliers
O2_QAVMult_dd, LP_O2_QAVMult_dd, & ! Input R2 Multipliers
Ptc,Pts,Prc,Prs, LP_Ptc,LP_Pts,LP_Prc,LP_Prs, & ! Inputs
R1c,R1s,R1cscal,LP_R1c,LP_R1s,LP_R1cscal,LS_R1c,LS_R1s,LS_R1cscal, & ! Input R1 sources
R2c,R2s,R2cscal,LP_R2c,LP_R2s,LP_R2cscal,LS_R2c,LS_R2s,LS_R2cscal ) ! Output R2 reflectances
! Purpose: Update the second-order Reflectance field in Layer n.
! Also updates the Profile Jacobians
implicit none
! 1. Standard
! -----------
! Control (Fourier #, Layer #, NSTREAMS, NSTOKES)
integer , intent(in) :: m, layer, nstreams, nstokes
! General inputs (quadrature weights, ssa, secants)
real(fpk), intent(in) :: qweights(MAXSTREAMS)
real(fpk), intent(in) :: omega, xv, xa
! source phase matrices
real(fpk), intent(in) :: Ptc(2,MAXSTREAMS,4,4),Pts(2,MAXSTREAMS,4,4)
real(fpk), intent(in) :: Prc(2,MAXSTREAMS,4,4),Prs(2,MAXSTREAMS,4,4)
! Second-order Transmittances and multipliers
real(fpk), intent(in) :: O2_AVTrans
real(fpk), intent(in) :: O2_QVMult_d(MAXSTREAMS)
real(fpk), intent(in) :: O2_QAMult_d(MAXSTREAMS)
real(fpk), intent(in) :: O2_QAVMult_dd(MAXSTREAMS)
real(fpk), intent(in) :: O2_QAVMult_du(MAXSTREAMS)
! 2. Linearized
! -------------
! Linearization control
logical , intent(in) :: do_LP_Jacobians, do_LS_Jacobians
integer , intent(in) :: npars(MAXLAYERS), nspars, nlayers
! Linearizated General inputs (secants, ssa)
real(fpk), intent(in) :: LP_omega(MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_xa(MAXLAYERS,MAX_ATMOSWFS)
! Linearized source phase matrices
real(fpk), intent(in) :: LP_Ptc(2,MAXSTREAMS,4,4,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_Pts(2,MAXSTREAMS,4,4,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_Prc(2,MAXSTREAMS,4,4,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_Prs(2,MAXSTREAMS,4,4,MAX_ATMOSWFS)
! Linearized Second-order Transmittances and multipliers
real(fpk), intent(in) :: LP_O2_AVTrans(MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_O2_QVMult_d(MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_O2_QAMult_d(MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_O2_QAVMult_dd(MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_O2_QAVMult_du(MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS)
! Outputs
! =======
! Modified first order inputs (standard & Linearized)
real(fpk), intent(inout) :: R1c(2,MAXSTREAMS,4,4)
real(fpk), intent(inout) :: R1s(2,MAXSTREAMS,4,4)
real(fpk), intent(inout) :: R1cscal(2,MAXSTREAMS)
real(fpk), intent(inout) :: LP_R1c(2,MAXSTREAMS,4,4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LP_R1s(2,MAXSTREAMS,4,4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LP_R1cscal(2,MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LS_R1c(2,MAXSTREAMS,4,4,MAX_SURFACEWFS)
real(fpk), intent(inout) :: LS_R1s(2,MAXSTREAMS,4,4,MAX_SURFACEWFS)
real(fpk), intent(inout) :: LS_R1cscal(2,MAXSTREAMS,MAX_SURFACEWFS)
! Modified second order outputs (standard & Linearized)
real(fpk), intent(inout) :: R2c(4),R2s(4),R2cscal
real(fpk), intent(inout) :: LP_R2c(4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LP_R2s(4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LP_R2cscal(MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LS_R2c(4,MAX_SURFACEWFS),LS_R2s(4,MAX_SURFACEWFS),LS_R2cscal(MAX_SURFACEWFS)
! local variables
! ===============
integer :: i, k, l, n, nd, p
real(fpk) :: dqw, pgv, pha, dglq, dhlq, HW
real(fpk) :: L_dqw(MAX_ATMOSWFS), L_hw(MAX_ATMOSWFS)
real(fpk) :: L_pgv(MAXLAYERS,MAX_ATMOSWFS), L_pha(MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: L_dglq(MAXLAYERS,MAX_ATMOSWFS), L_dhlq(MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: S1(4),S2(4), L_S1(4,MAXLAYERS,MAX_ATMOSWFS), L_S2(4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: S3(4),S4(4), L_S3(4,MAXLAYERS,MAX_ATMOSWFS), L_S4(4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: S1scal,S2scal, L_S1scal(MAXLAYERS,MAX_ATMOSWFS), L_S2scal(MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: V1(4),V2(4,4), L_V1(4,MAXLAYERS,MAX_ATMOSWFS), L_V2(4,4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: V4(4),V6(4,4), L_V4(4,MAXLAYERS,MAX_ATMOSWFS), L_V6(4,4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: V1scal,V2scal, L_V1scal(MAXLAYERS,MAX_ATMOSWFS), L_V2scal(MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: LS_S1(4,MAX_SURFACEWFS), LS_S2(4,MAX_SURFACEWFS)
real(fpk) :: LS_S3(4,MAX_SURFACEWFS), LS_S4(4,MAX_SURFACEWFS)
real(fpk) :: LS_S1scal(MAX_SURFACEWFS), LS_S2scal(MAX_SURFACEWFS)
real(fpk) :: LS_V1(4,MAX_SURFACEWFS), LS_V2(4,4,MAX_SURFACEWFS)
real(fpk) :: LS_V4(4,MAX_SURFACEWFS), LS_V6(4,4,MAX_SURFACEWFS)
real(fpk) :: LS_V1scal(MAX_SURFACEWFS), LS_V2scal(MAX_SURFACEWFS)
! initial section
! ---------------
! Zero the S-matrices
S1 = zero ; S2 = zero
S1scal = zero ; S2scal = zero
S3 = zero ; S4 = zero
L_S1 = zero ; L_S2 = zero
L_S1scal = zero ; L_S2scal = zero
L_S3 = zero ; L_S4 = zero
LS_S1 = zero ; LS_S2 = zero
LS_S1scal = zero ; LS_S2scal = zero
LS_S3 = zero ; LS_S4 = zero
nd = layer ! Dummy variable, debug only
hw = Omega * quarter
if ( do_LP_Jacobians ) L_hw(1:npars(layer)) = LP_omega(1:npars(layer)) * quarter
! Enter the k-loop
! ================
do k = 1, nstreams
! factors in front of Multipliers
dglq = hw * O2_QAVMult_du(k) ; pgv = xv * O2_QVMult_d(k)
dhlq = hw * O2_QAVMult_dd(k) ; pha = xa * O2_QAMult_d(k)
L_dglq = zero ; L_dhlq = zero ; L_pgv = zero ; L_pha = zero
if ( do_LP_Jacobians ) then
do n = 1, nlayers
if ( n.eq.layer ) then
do p = 1, npars(n)
L_dglq(n,p) = L_hw(p) * O2_QAVMult_du(k) + hw * LP_O2_QAVMult_du(k,n,p)
L_dhlq(n,p) = L_hw(p) * O2_QAVMult_dd(k) + hw * LP_O2_QAVMult_dd(k,n,p)
L_pgv(n,p) = xv * LP_O2_QVMult_d(k,n,p)
L_pha(n,p) = xa * LP_O2_QAMult_d(k,n,p) + LP_xa(n,p) * O2_QAMult_d(k)
enddo
else
do p = 1, npars(n)
L_dglq(n,p) = hw * LP_O2_QAVMult_du(k,n,p)
L_dhlq(n,p) = hw * LP_O2_QAVMult_dd(k,n,p)
L_pgv(n,p) = xv * LP_O2_QVMult_d(k,n,p)
L_pha(n,p) = xa * LP_O2_QAMult_d(k,n,p) + LP_xa(n,p) * O2_QAMult_d(k)
enddo
endif
enddo
endif
! V matrices
! ----------
! Part 1: The I and Q components
do l = 1, 2
V1(l) = pgv * R1c(2,k,l,1) + dglq * Prc(2,k,l,1)
V2(1:2,l) = pha * R1c(1,k,1:2,l) + dhlq * Prc(1,k,1:2,l)
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
L_V1(l,n,p) = L_pgv(n,p) * R1c(2,k,l,1) + pgv * LP_R1c(2,k,l,1,n,p) &
+ L_dglq(n,p) * Prc(2,k,l,1)
L_V2(1:2,l,n,p) = L_pha(n,p) * R1c(1,k,1:2,l) + pha * LP_R1c(1,k,1:2,l,n,p) &
+ L_dhlq(n,p) * Prc(1,k,1:2,l)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
L_V1(l,n,p) = L_V1(l,n,p) + dglq * LP_Prc(2,k,l,1,p)
L_V2(1:2,l,n,p) = L_V2(1:2,l,n,p) + dhlq * LP_Prc(1,k,1:2,l,p)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_V1(l,p) = pgv * LS_R1c(2,k,l,1,p)
LS_V2(1:2,l,p) = pha * LS_R1c(1,k,1:2,l,p)
enddo
endif
enddo
if (m .gt. 0) then
do l = 3, 4
V4(l) = pgv * R1s(2,k,l,1) + dglq * Prs(2,k,l,1)
V6(1:2,l) = pha * R1s(1,k,1:2,l) + dhlq * Prs(1,k,1:2,l)
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
L_V4(l,n,p) = L_pgv(n,p) * R1s(2,k,l,1) + pgv * LP_R1s(2,k,l,1,n,p) &
+ L_dglq(n,p) * Prs(2,k,l,1)
L_V6(1:2,l,n,p) = L_pha(n,p) * R1s(1,k,1:2,l) + pha * LP_R1s(1,k,1:2,l,n,p) &
+ L_dhlq(n,p) * Prs(1,k,1:2,l)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
L_V4(l,n,p) = L_V4(l,n,p) + dglq * LP_Prs(2,k,l,1,p)
L_V6(1:2,l,n,p) = L_V6(1:2,l,n,p) + dhlq * LP_Prs(1,k,1:2,l,p)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_V4(l,p) = pgv * LS_R1s(2,k,l,1,p)
LS_V6(1:2,l,p) = pha * LS_R1s(1,k,1:2,l,p)
enddo
endif
enddo
endif
! Part 2: the U component
if (m .gt. 0) then
do i = 3, nstokes
V2(i,3:4) = pha * R1c(1,k,i,3:4) + dhlq * Prc(1,k,i,3:4)
V6(i,1:2) = pha * R1s(1,k,i,1:2) + dhlq * Prs(1,k,i,1:2)
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
L_V2(i,3:4,n,p) = L_pha(n,p) * R1c(1,k,i,3:4) + pha * LP_R1c(1,k,i,3:4,n,p) &
+ L_dhlq(n,p) * Prc(1,k,i,3:4)
L_V6(i,1:2,n,p) = L_pha(n,p) * R1s(1,k,i,1:2) + pha * LP_R1s(1,k,i,1:2,n,p) &
+ L_dhlq(n,p) * Prs(1,k,i,1:2)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
L_V2(i,3:4,n,p) = L_V2(i,3:4,n,p) + dhlq * LP_Prc(1,k,i,3:4,p)
L_V6(i,1:2,n,p) = L_V6(i,1:2,n,p) + dhlq * LP_Prs(1,k,i,1:2,p)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_V2(i,3:4,p) = pha * LS_R1c(1,k,i,3:4,p)
LS_V6(i,1:2,p) = pha * LS_R1s(1,k,i,1:2,p)
enddo
endif
enddo
endif
! Part 3: the scalar calculation
V1scal = pgv * R1cscal(2,k) + dglq * Prc(2,k,1,1)
V2scal = pha * R1cscal(1,k) + dhlq * Prc(1,k,1,1)
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
L_V1scal(n,p) = L_pgv(n,p) * R1cscal(2,k) + pgv * LP_R1cscal(2,k,n,p) &
+ L_dglq(n,p) * Prc(2,k,1,1)
L_V2scal(n,p) = L_pha(n,p) * R1cscal(1,k) + pha * LP_R1cscal(1,k,n,p) &
+ L_dhlq(n,p) * Prc(1,k,1,1)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
L_V1scal(n,p) = L_V1scal(n,p) + dglq * LP_Prc(2,k,1,1,p)
L_V2scal(n,p) = L_V2scal(n,p) + dhlq * LP_Prc(1,k,1,1,p)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_V1scal(p) = pgv * LS_R1cscal(2,k,p)
LS_V2scal(p) = pha * LS_R1cscal(1,k,p)
enddo
endif
! debug
! write(94,'(2i3,1p5e20.12)')m,n,V4(3),V4(4),V6(3,1)
! if (m.eq.3.and.n.eq.60)pause'gronk'
! S Matrices
! ----------
dqw = Omega * qweights(k)
if ( do_LP_Jacobians ) then
L_dqw(1:npars(layer)) = LP_Omega(1:npars(layer)) * qweights(k)
endif
! Part 1: I and Q components
do i = 1, 2
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
do l = 1, 2
L_S1(i,n,p) = L_S1(i,n,p) + dqw * Ptc(1,k,i,l) * L_V1(l,n,p)
L_S2(i,n,p) = L_S2(i,n,p) + dqw * Ptc(2,k,l,1) * L_V2(i,l,n,p)
enddo
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
do l = 1, 2
L_S1(i,n,p) = L_S1(i,n,p) + L_dqw(p) * Ptc(1,k,i,l) * V1(l) + &
dqw * LP_Ptc(1,k,i,l,p) * V1(l)
L_S2(i,n,p) = L_S2(i,n,p) + L_dqw(p) * Ptc(2,k,l,1) * V2(i,l) + &
dqw * LP_Ptc(2,k,l,1,p) * V2(i,l)
enddo
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
do l = 1, 2
LS_S1(i,p) = LS_S1(i,p) + dqw * Ptc(1,k,i,l) * LS_V1(l,p)
LS_S2(i,p) = LS_S2(i,p) + dqw * Ptc(2,k,l,1) * LS_V2(i,l,p)
enddo
enddo
endif
do l = 1, 2
S1(i) = S1(i) + dqw * Ptc(1,k,i,l) * V1(l)
S2(i) = S2(i) + dqw * Ptc(2,k,l,1) * V2(i,l)
enddo
if (m .gt. 0) then
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
do l = 3, 4
L_S3(i,n,p) = L_S3(i,n,p) + dqw * Pts(1,k,i,l) * L_V4(l,n,p)
L_S4(i,n,p) = L_S4(i,n,p) + dqw * Pts(2,k,l,1) * L_V6(i,l,n,p)
enddo
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
do l = 3, 4
L_S3(i,n,p) = L_S3(i,n,p) + L_dqw(p) * Pts(1,k,i,l) * V4(l) + &
dqw * LP_Pts(1,k,i,l,p) * V4(l)
L_S4(i,n,p) = L_S4(i,n,p) + L_dqw(p) * Pts(2,k,l,1) * V6(i,l) + &
dqw * LP_Pts(2,k,l,1,p) * V6(i,l)
enddo
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
do l = 3, 4
LS_S3(i,p) = LS_S3(i,p) + dqw * Pts(1,k,i,l) * LS_V4(l,p)
LS_S4(i,p) = LS_S4(i,p) + dqw * Pts(2,k,l,1) * LS_V6(i,l,p)
enddo
enddo
endif
do l = 3,4
S3(i) = S3(i) + dqw * Pts(1,k,i,l) * V4(l)
S4(i) = S4(i) + dqw * Pts(2,k,l,1) * V6(i,l)
enddo
endif
enddo
! Part 2: U component
do i = 3, nstokes
if (m .gt. 0) then
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
do l = 3, 4
L_S1(i,n,p) = L_S1(i,n,p) + dqw * Ptc(1,k,i,l) * L_V4(l,n,p)
L_S2(i,n,p) = L_S2(i,n,p) + dqw * Pts(2,k,l,1) * L_V2(i,l,n,p)
enddo
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
do l = 3, 4
L_S1(i,n,p) = L_S1(i,n,p) + L_dqw(p) * Ptc(1,k,i,l) * V4(l) + &
dqw * LP_Ptc(1,k,i,l,p) * V4(l)
L_S2(i,n,p) = L_S2(i,n,p) + L_dqw(p) * Pts(2,k,l,1) * V2(i,l) + &
dqw * LP_Pts(2,k,l,1,p) * V2(i,l)
enddo
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
do l = 3, 4
LS_S1(i,p) = LS_S1(i,p) + dqw * Ptc(1,k,i,l) * LS_V4(l,p)
LS_S2(i,p) = LS_S2(i,p) + dqw * Pts(2,k,l,1) * LS_V2(i,l,p)
enddo
enddo
endif
do l = 3, 4
S1(i) = S1(i) + dqw * Ptc(1,k,i,l) * V4(l)
S2(i) = S2(i) + dqw * Pts(2,k,l,1) * V2(i,l)
enddo
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
do l = 1, 2
L_S3(i,n,p) = L_S3(i,n,p) + dqw * Pts(1,k,i,l) * L_V1(l,n,p)
L_S4(i,n,p) = L_S4(i,n,p) + dqw * Ptc(2,k,l,1) * L_V6(i,l,n,p)
enddo
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
do l = 1, 2
L_S3(i,n,p) = L_S3(i,n,p) + L_dqw(p) * Pts(1,k,i,l) * V1(l) + &
dqw * LP_Pts(1,k,i,l,p) * V1(l)
L_S4(i,n,p) = L_S4(i,n,p) + L_dqw(p) * Ptc(2,k,l,1) * V6(i,l) + &
dqw * LP_Ptc(2,k,l,1,p) * V6(i,l)
enddo
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
do l = 1, 2
LS_S3(i,p) = LS_S3(i,p) + dqw * Pts(1,k,i,l) * LS_V1(l,p)
LS_S4(i,p) = LS_S4(i,p) + dqw * Ptc(2,k,l,1) * LS_V6(i,l,p)
enddo
enddo
endif
do l = 1, 2
S3(i) = S3(i) + dqw * Pts(1,k,i,l) * V1(l)
S4(i) = S4(i) + dqw * Ptc(2,k,l,1) * V6(i,l)
enddo
endif
! End k-stream loop
enddo
! Part 3: scalar
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
L_S1scal(n,p) = L_S1scal(n,p) + dqw * Ptc(1,k,1,1) * L_V1scal(n,p)
L_S2scal(n,p) = L_S2scal(n,p) + dqw * Ptc(2,k,1,1) * L_V2scal(n,p)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
L_S1scal(n,p) = L_S1scal(n,p) + L_dqw(p) * Ptc(1,k,1,1) * V1scal + &
dqw * LP_Ptc(1,k,1,1,p) * V1scal
L_S2scal(n,p) = L_S2scal(n,p) + L_dqw(p) * Ptc(2,k,1,1) * V2scal + &
dqw * LP_Ptc(2,k,1,1,p) * V2scal
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_S1scal = LS_S1scal + dqw * Ptc(1,k,1,1) * LS_V1scal(p)
LS_S2scal = LS_S2scal + dqw * Ptc(2,k,1,1) * LS_V2scal(p)
enddo
endif
S1scal = S1scal + dqw * Ptc(1,k,1,1) * V1scal
S2scal = S2scal + dqw * Ptc(2,k,1,1) * V2scal
! end k loop
enddo
! Recursion (Using the solar/LOS transmittance multiplier)
! =========
! Update the R2c/R2s terms, with the transmittance
do i = 1, 2
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R2c(i,n,p) = R2c(i) * LP_O2_AVTRANS(n,p) + LP_R2c(i,n,p)*O2_AVTRANS
enddo
enddo
endif
if ( do_LS_Jacobians ) then
LS_R2c(i,1:nspars) = LS_R2c(i,1:nspars)*O2_AVTRANS
endif
R2c(i) = R2c(i)*O2_AVTRANS
enddo
if (nstokes .eq. 3) then
do i = 3, nstokes
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R2s(i,n,p) = R2s(i) * LP_O2_AVTRANS(n,p) + LP_R2s(i,n,p)*O2_AVTRANS
enddo
enddo
endif
if ( do_LS_Jacobians ) then
LS_R2s(i,1:nspars) = LS_R2s(i,1:nspars)*O2_AVTRANS
endif
R2s(i) = R2s(i)*O2_AVTRANS
enddo
endif
! update the scalar corrections
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R2cscal(n,p) = R2cscal * LP_O2_AVTRANS(n,p) + LP_R2cscal(n,p)*O2_AVTRANS
enddo
enddo
endif
if ( do_LS_Jacobians ) then
LS_R2cscal(1:nspars) = LS_R2cscal(1:nspars)*O2_AVTRANS
endif
R2cscal = R2cscal*O2_AVTRANS
do i = 1, 2
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R2c(i,n,p) = LP_R2c(i,n,p) + half * ( L_S1(i,n,p) + L_S2(i,n,p) )
enddo
enddo
endif
if ( do_LS_Jacobians ) then
LS_R2c(i,1:nspars) = LS_R2c(i,1:nspars) + half * ( LS_S1(i,1:nspars) + LS_S2(i,1:nspars) )
endif
R2c(i) = R2c(i) + half * ( S1(i) + S2(i) )
enddo
R2cscal = R2cscal + half * ( S1scal + S2scal )
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R2cscal(n,p) = LP_R2cscal(n,p) + half * ( L_S1scal(n,p) + L_S2scal(n,p) )
enddo
enddo
endif
if ( do_LS_Jacobians ) then
LS_R2cscal(1:nspars) = LS_R2cscal(1:nspars) + half * ( LS_S1scal(1:nspars) + LS_S2scal(1:nspars) )
endif
if (m .gt. 0) then
do i = 1, 2
R2c(i) = R2c(i) + half * ( S3(i) - S4(i) )
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R2c(i,n,p) = LP_R2c(i,n,p) + half * ( L_S3(i,n,p) - L_S4(i,n,p) )
enddo
enddo
endif
if ( do_LS_Jacobians ) then
LS_R2c(i,1:nspars) = LS_R2c(i,1:nspars) + half * ( LS_S3(i,1:nspars) - LS_S4(i,1:nspars) )
endif
enddo
if (nstokes .eq. 3) then
do i = 3, nstokes
R2s(i) = R2s(i) + half * ( S1(i) + S2(i) - S3(i) + S4(i) )
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R2s(i,n,p) = LP_R2s(i,n,p) + half * &
( L_S1(i,n,p) + L_S2(i,n,p) - L_S3(i,n,p) + L_S4(i,n,p) )
enddo
enddo
endif
if ( do_LS_Jacobians ) then
LS_R2s(i,1:nspars) = LS_R2s(i,1:nspars) + half * &
( LS_S1(i,1:nspars) + LS_S2(i,1:nspars) - LS_S3(i,1:nspars) + LS_S4(i,1:nspars) )
endif
enddo
endif
endif
! write(94,'(2i3,1p5e20.12)')m,n,R2s(1),R2s(2),R2s(3)
! if (m.eq.3.and.n.eq.60)pause'gronk'
! Finish
return
end subroutine Calculate_SecondOrder_LPSPlus
subroutine Calculate_FirstOrder_LPSPlus &
( do_LP_Jacobians, do_LS_Jacobians,m,layer,nstreams,nlayers,npars,nspars, & ! Input Control
Prc,Prs, LP_Prc,LP_Prs, & ! Scattering input
O1_QVTrans, LP_O1_QVTrans, & ! First-order multiplier input
O1_QVMult, LP_O1_QVMult, & ! First-order multiplier input
O1_QATrans, LP_O1_QATrans, & ! First-order multiplier input
O1_QAMult, LP_O1_QAMult, & ! First-order multiplier input
R1c,R1s,R1cscal,LP_R1c,LP_R1s,LP_R1cscal,LS_R1c,LS_R1s,LS_R1cscal ) ! First-order output
! Purpose: Update the First-Order Reflectance for Layer n
! Also updates the Profile Jacobians
implicit none
! Inputs
! ======
! 1. Standard
! -----------
! Control (Fourier #, NSTREAMS, NSTOKES)
integer , intent(in) :: m, layer, nstreams
! source phase matrices
real(fpk), intent(in) :: Prc(2,MAXSTREAMS,4,4),Prs(2,MAXSTREAMS,4,4)
! First-order transmittances/multipliers
real(fpk), intent(in) :: O1_QVTrans(MAXSTREAMS), O1_QATrans(MAXSTREAMS)
real(fpk), intent(in) :: O1_QVMult (MAXSTREAMS), O1_QAMult (MAXSTREAMS)
! 2. Linearized
! -------------
! Linearization control
logical , intent(in) :: do_LP_Jacobians,do_LS_Jacobians
integer , intent(in) :: npars(MAXLAYERS), nspars,nlayers
! source phase matrices
real(fpk), intent(in) :: LP_Prc(2,MAXSTREAMS,4,4,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_Prs(2,MAXSTREAMS,4,4,MAX_ATMOSWFS)
! First-order transmittances/multipliers
! (No Cross-Layer terms for QV)
real(fpk), intent(in) :: LP_O1_QVTrans(MAXSTREAMS,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_O1_QVMult (MAXSTREAMS,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_O1_QATrans(MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(in) :: LP_O1_QAMult (MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS)
! Modified outputs
! ================
real(fpk), intent(inout) :: R1c(2,MAXSTREAMS,4,4)
real(fpk), intent(inout) :: R1s(2,MAXSTREAMS,4,4)
real(fpk), intent(inout) :: R1cscal(2,MAXSTREAMS)
real(fpk), intent(inout) :: LP_R1c(2,MAXSTREAMS,4,4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LP_R1s(2,MAXSTREAMS,4,4,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LP_R1cscal(2,MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(inout) :: LS_R1c(2,MAXSTREAMS,4,4,MAX_SURFACEWFS)
real(fpk), intent(inout) :: LS_R1s(2,MAXSTREAMS,4,4,MAX_SURFACEWFS)
real(fpk), intent(inout) :: LS_R1cscal(2,MAXSTREAMS,MAX_SURFACEWFS)
! local variables
integer :: j,i,k1,k2,n,p
! viewing direction + all j-quadrature directions
! -----------------------------------------------
! update the R1 matrices themselves
do j = 1, nstreams
! R1scal updates.......
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R1cscal(1,j,n,p) = LP_R1cscal(1,j,n,p) * O1_QVTrans(j)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
LP_R1cscal(1,j,n,p) = LP_R1cscal(1,j,n,p) + LP_Prc(1,j,1,1,p) * O1_QVMULT(j) &
+ R1cscal(1,j) * LP_O1_QVTrans(j,p) &
+ Prc(1,j,1,1) * LP_O1_QVMULT(j,p)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_R1cscal(1,j,p) = O1_QVTRANS(j) * LS_R1cscal(1,j,p)
enddo
endif
R1cscal(1,j) = R1cscal(1,j) * O1_QVTrans(j) + Prc(1,j,1,1) * O1_QVMULT(j)
! R1c and R1s...............
do k1 = 1, 4
do k2 = 1, 4
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R1c(1,j,k1,k2,n,p) = LP_R1c(1,j,k1,k2,n,p) * O1_QVTrans(j)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
LP_R1c(1,j,k1,k2,n,p) = LP_R1c(1,j,k1,k2,n,p) + LP_Prc(1,j,k1,k2,p) * O1_QVMULT(j) &
+ R1c(1,j,k1,k2) * LP_O1_QVTrans(j,p) &
+ Prc(1,j,k1,k2) * LP_O1_QVMULT(j,p)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_R1c(1,j,k1,k2,p) = O1_QVTRANS(j) * LS_R1c(1,j,k1,k2,p)
enddo
endif
R1c(1,j,k1,k2) = R1c(1,j,k1,k2) * O1_QVTrans(j) + Prc(1,j,k1,k2) * O1_QVMULT(j)
if (m .gt. 0) then
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R1s(1,j,k1,k2,n,p) = LP_R1s(1,j,k1,k2,n,p) * O1_QVTrans(j)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
LP_R1s(1,j,k1,k2,n,p) = LP_R1s(1,j,k1,k2,n,p) + LP_Prs(1,j,k1,k2,p) * O1_QVMULT(j) &
+ R1s(1,j,k1,k2) * LP_O1_QVTrans(j,p) &
+ Prs(1,j,k1,k2) * LP_O1_QVMULT(j,p)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_R1s(1,j,k1,k2,p) = O1_QVTRANS(j) * LS_R1s(1,j,k1,k2,p)
enddo
endif
R1s(1,j,k1,k2) = R1s(1,j,k1,k2) * O1_QVTrans(j) + Prs(1,j,k1,k2) * O1_QVMULT(j)
endif
enddo
enddo
enddo
! solar direction
! ---------------
do i = 1, nstreams
! R1scal updates.......
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R1cscal(2,i,n,p) = LP_R1cscal(2,i,n,p) * O1_QATRANS(i) &
+ R1cscal(2,i) * LP_O1_QATRANS(i,n,p)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
LP_R1cscal(2,i,n,p) = LP_R1cscal(2,i,n,p) + LP_Prc(2,i,1,1,p) * O1_QAMULT(i) &
+ Prc(2,i,1,1) * LP_O1_QAMULT(i,n,p)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_R1cscal(2,i,p) = O1_QATrans(i) * LS_R1cscal(2,i,p)
enddo
endif
R1cscal(2,i) = R1cscal(2,i) * O1_QATRANS(i) + Prc(2,i,1,1) * O1_QAMULT(i)
! R1c and R1s...............
do k1 = 1, 4
do k2 = 1, 4
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R1c(2,i,k1,k2,n,p) = LP_R1c(2,i,k1,k2,n,p) * O1_QATRANS(i) &
+ R1c(2,i,k1,k2) * LP_O1_QATRANS(i,n,p) &
+ Prc(2,i,k1,k2) * LP_O1_QAMULT(i,n,p)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
LP_R1c(2,i,k1,k2,n,p) = LP_R1c(2,i,k1,k2,n,p) + LP_Prc(2,i,k1,k2,p) * O1_QAMULT(i)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_R1c(2,i,k1,k2,p) = O1_QATrans(i) * LS_R1c(2,i,k1,k2,p)
enddo
endif
R1c(2,i,k1,k2) = R1c(2,i,k1,k2) * O1_QATRANS(i) + Prc(2,i,k1,k2) * O1_QAMULT(i)
if (m .gt. 0) then
if ( do_LP_Jacobians ) then
do n = 1, nlayers
do p = 1, npars(n)
LP_R1s(2,i,k1,k2,n,p) = LP_R1s(2,i,k1,k2,n,p) * O1_QATRANS(i) &
+ R1s(2,i,k1,k2) * LP_O1_QATRANS(i,n,p) &
+ Prs(2,i,k1,k2) * LP_O1_QAMULT(i,n,p)
enddo
if ( n.eq.layer ) then
do p = 1, npars(n)
LP_R1s(2,i,k1,k2,n,p) = LP_R1s(2,i,k1,k2,n,p) + LP_Prs(2,i,k1,k2,p) * O1_QAMULT(i)
enddo
endif
enddo
endif
if ( do_LS_Jacobians ) then
do p = 1, nspars
LS_R1s(2,i,k1,k2,p) = O1_QATrans(i) * LS_R1s(2,i,k1,k2,p)
enddo
endif
R1s(2,i,k1,k2) = R1s(2,i,k1,k2) * O1_QATRANS(i) + Prs(2,i,k1,k2) * O1_QAMULT(i)
endif
enddo
enddo
enddo
! End
return
end subroutine Calculate_firstOrder_LPSPlus
subroutine Calculate_Multipliers_LPPlus &
( MaxGeoms, nstreams, nlayers, ngeoms, npars, do_Jacobians, & ! Inputs
qstreams, avg_secants, geoms, opdeps, omegas, & ! Inputs
LP_avg_secants, L_opdeps, L_omegas, & ! Inputs
O1_QVTrans, O1_QVMult, O1_QATrans, O1_QAMult, & ! First-order output
LP_O1_QVTrans, LP_O1_QVMult, LP_O1_QATrans, LP_O1_QAMult, & ! First-order output
O2_AVTrans, O2_AVMult, O2_QVMult_d, O2_QAMult_d, & ! Second-order output
O2_QAVMult_du, O2_QAVMult_dd, & ! Second-order output
LP_O2_AVTrans, LP_O2_AVMult, LP_O2_QVMult_d, LP_O2_QAMult_d, & ! Second-order output
LP_O2_QAVMult_du, LP_O2_QAVMult_dd ) ! Second-order output
! Purpose : calculate transmittances and integrated multipliers for R1/R2 fields
! Convention for directional output as follows
! Q = quadrature stream direction
! S = solar scattering direction
! A = Solar Average-secant direction
! V = Los viewing direction
implicit none
! Inputs
! ------
! Control integers
integer, intent(in) :: MaxGeoms, nlayers, nstreams, ngeoms
! Jacobian control
logical, intent(in) :: do_Jacobians
integer, intent(in) :: npars(MAXLAYERS)
! Cosines Quadrature
real(fpk), intent(in) :: qstreams(MAXSTREAMS)
! Average secants
real(fpk), intent(in) :: avg_secants (MAXLAYERS,MaxGeoms)
real(fpk), intent(in) :: LP_avg_secants(MAXLAYERS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
! Geometries stored in array Geoms(i,j,*)
! i = 1/2/3 = SZA/VZA/AZM, j = 1/2/3/4 = Degrees/Radians/Cosines/sines
real(fpk), intent(in) :: geoms(3,4,MaxGeoms)
! optical properties (these will be deltam-scaled)
real(fpk), intent(in) :: opdeps(MAXLAYERS)
real(fpk), intent(in) :: omegas(MAXLAYERS)
real(fpk), intent(in) :: L_opdeps(MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(in) :: L_omegas(MAXLAYERS,MAX_ATMOSWFS)
! outputs
! -------
! First-order Transmittances and multipliers. Only defined for Quadrature directions.
real(fpk), intent(out) :: O1_QVTrans(MAXLAYERS,MAXSTREAMS,MaxGeoms)
real(fpk), intent(out) :: O1_QATrans(MAXLAYERS,MAXSTREAMS,MaxGeoms)
real(fpk), intent(out) :: O1_QVMult(MAXLAYERS,MAXSTREAMS,MaxGeoms)
real(fpk), intent(out) :: O1_QAMult(MAXLAYERS,MAXSTREAMS,MaxGeoms)
! Second-order Transmittances and multipliers
real(fpk), intent(out) :: O2_AVTrans(MAXLAYERS,MaxGeoms)
real(fpk), intent(out) :: O2_AVMult (MAXLAYERS,MaxGeoms)
real(fpk), intent(out) :: O2_QVMult_d(MAXLAYERS,MAXSTREAMS,MaxGeoms)
real(fpk), intent(out) :: O2_QAMult_d(MAXLAYERS,MAXSTREAMS,MaxGeoms)
real(fpk), intent(out) :: O2_QAVMult_dd(MAXLAYERS,MAXSTREAMS,MaxGeoms)
real(fpk), intent(out) :: O2_QAVMult_du(MAXLAYERS,MAXSTREAMS,MaxGeoms)
! Linearized First-order Transmittances and multipliers
real(fpk), intent(out) :: LP_O1_QVTrans(MAXLAYERS,MAXSTREAMS,MAX_ATMOSWFS,MaxGeoms)
real(fpk), intent(out) :: LP_O1_QVMult (MAXLAYERS,MAXSTREAMS,MAX_ATMOSWFS,MaxGeoms)
real(fpk), intent(out) :: LP_O1_QATrans(MAXLAYERS,MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
real(fpk), intent(out) :: LP_O1_QAMult (MAXLAYERS,MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
! Linearized Second-order Transmittances and multipliers
real(fpk), intent(out) :: LP_O2_AVTrans(MAXLAYERS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
real(fpk), intent(out) :: LP_O2_AVMult (MAXLAYERS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
real(fpk), intent(out) :: LP_O2_QVMult_d(MAXLAYERS,MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
real(fpk), intent(out) :: LP_O2_QAMult_d(MAXLAYERS,MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
real(fpk), intent(out) :: LP_O2_QAVMult_dd(MAXLAYERS,MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
real(fpk), intent(out) :: LP_O2_QAVMult_du(MAXLAYERS,MAXSTREAMS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
! local variables
! ---------------
integer :: k,n,L,p,m,np,mp
real(fpk) :: xv,xs,xsxv,xa,xk,xvxk,xsxk,deltaus,O2_QAMult_u,Help1
real(fpk) :: sv_plus, kv_plus, kv_minus, ka_plus, ka_minus
real(fpk) :: dxv,dxs,dxa,dxk,atrans,vtrans,ktrans,hw,term1,term2
real(fpk) :: L_xa(MAXLAYERS,MAX_ATMOSWFS),L_hw(MAX_ATMOSWFS),L_deltaus(MAX_ATMOSWFS),L_term1,L_term2
real(fpk) :: L_dxv(MAX_ATMOSWFS),L_dxs(MAX_ATMOSWFS),L_dxa(MAXLAYERS,MAX_ATMOSWFS),L_dxk(MAX_ATMOSWFS)
real(fpk) :: L_atrans(MAXLAYERS,MAX_ATMOSWFS),L_vtrans(MAX_ATMOSWFS),L_ktrans(MAX_ATMOSWFS),LP_O2_QAMult_u
! start of code
! =============
do L = 1, ngeoms
! secants
xv = one / geoms(2,3,L) ! Los secant
xs = one / geoms(1,3,L) ! solar secant for scattering
xsxv = xs * xv
! layer loop
! ----------
do n = 1, nlayers
! Average secant
xa = avg_secants(n,L) ! solar average-secant for transmittance
if ( do_Jacobians ) then
do m = n, nlayers
mp = npars(m) ; L_xa (m,1:mp) = LP_avg_secants(n,m,1:mp,L)
enddo
endif
! Help variables
deltaus = opdeps(n)
dxv = deltaus * xv ; call ExpTrans(BigExp,dxv,vtrans)
dxa = deltaus * xa ; call ExpTrans(BigExp,dxa,atrans)
dxs = deltaus * xs
hw = omegas(n) * quarter
if ( do_Jacobians ) then
np = npars(n) ; L_hw(1:np) = L_omegas(n,1:np) * quarter
L_deltaus(1:np) = L_opdeps(n,1:np)
L_dxv(1:np) = L_deltaus(1:np) * xv
L_dxs(1:np) = L_deltaus(1:np) * xs
do m = 1, nlayers
mp = npars(m) ; L_dxa(m,1:mp) = deltaus * L_xa(m,1:mp)
if ( m.eq.n ) L_dxa(m,1:mp) = L_dxa(m,1:mp) + L_deltaus(1:mp) * xa
enddo
endif
! Solar to viewing (second Order). Tranmsittance/Multiplier
sv_plus = one / ( xv + xa) ; Help1 = xv * sv_plus
O2_AVTrans(n,L) = vtrans * atrans
O2_AVMult (n,L) = Help1 * ( one - O2_AVTrans(n,L) )
if ( do_Jacobians ) then
call ExpTrans_L(BigExp,npars(n),dxv,L_dxv,vtrans,L_vtrans)
do m = 1, nlayers
call ExpTrans_L(BigExp,npars(m),dxa,L_dxa(m,:),atrans,L_atrans(m,:))
do p = 1, npars(m)
LP_O2_AVTrans(n,m,p,L) = L_atrans(m,p) * vtrans
LP_O2_AVMult (n,m,p,L) = - Help1 * LP_O2_AVTrans(n,m,p,L) - L_xa(m,p) * O2_AVMult(n,L) * sv_plus
enddo
if ( m.eq.n ) then
do p = 1, npars(m)
L_Term1 = L_vtrans(p) * atrans
LP_O2_AVTrans(n,m,p,L) = LP_O2_AVTrans(n,m,p,L) + L_Term1
LP_O2_AVMult (n,m,p,L) = LP_O2_AVMult (n,m,p,L) - Help1 * L_Term1
enddo
endif
enddo
endif
! Loop over Nstreams (quadrature)
! -------------------------------
do k = 1, nstreams
! Quadrature secant value
xk = one/qstreams(k)
! Help variables
dxk = deltaus * xk ; call ExpTrans(BigExp,dxk,ktrans)
xvxk = xk * xv ; kv_plus = xk + xv ; kv_minus = xk - xv
xsxk = xk * xs ; ka_plus = xk + xa ; ka_minus = xk - xa
if ( do_Jacobians ) then
L_dxk(1:np) = L_deltaus(1:np) * xk
call ExpTrans_L(BigExp,np,dxk,L_dxk,ktrans,L_ktrans)
endif
! First Order: viewing direction + all quadrature directions
! (Formerly, Facj, Chibj). THIS HAS NO CROSS-LAYER DERIVATIVES !!!!!!!!!!!!!!!!
term1 = xvxk / kv_plus
O1_QVTrans(n,k,L) = ktrans * vtrans ; term2 = one - O1_QVTrans(n,k,L)
O1_QVMult (n,k,L) = term1 * hw * term2
if ( do_Jacobians ) then
do p = 1, npars(n)
LP_O1_QVTrans(n,k,p,L) = L_ktrans(p) * vtrans + L_vtrans(p) * ktrans
LP_O1_QVMult (n,k,p,L) = term1 * ( L_hw(p) * term2 - hw * LP_O1_QVTrans(n,k,p,L) )
enddo
endif
! First Order: Solar (Av-secant) direction + all quadrature directions
! (Formerly, Faci, Chibi). THIS TERM HAS CROSS_LAYER DERIVATIVES
term1 = xsxk * hw / ka_plus
O1_QATrans(n,k,L) = ktrans * atrans ; term2 = one - O1_QATrans(n,k,L)
O1_QAMult (n,k,L) = term1 * term2
if ( do_Jacobians ) then
do m = 1, nlayers
! do m = n, nlayers
do p = 1, npars(m)
L_term1 = - term1 * L_xa(m,p) / ka_plus
LP_O1_QATrans(n,k,m,p,L) = L_atrans(m,p) * ktrans
LP_O1_QAMult (n,k,m,p,L) = - term1 * LP_O1_QATrans(n,k,m,p,L) - L_xa(m,p) * O1_QAMult(n,k,L) / ka_plus
enddo
if ( m.eq.n ) then
do p = 1, npars(m)
L_Term2 = L_ktrans(p) * atrans
L_term1 = xsxk * L_hw(p) / ka_plus
LP_O1_QATrans(n,k,m,p,L) = LP_O1_QATrans(n,k,m,p,L) + L_Term2
LP_O1_QAMult (n,k,m,p,L) = LP_O1_QAMult (n,k,m,p,L) - L_Term2 * Term1 + Term2 * L_Term1
enddo
endif
enddo
endif
! Second Order Multipliers (Formerly PHG, PHH, G, and H )
! General case (No Small-number series)
O2_QVMult_d(n,k,L) = ( O2_AVTrans(n,L) - O1_QATrans(n,k,L) ) / kv_minus
O2_QAMult_d(n,k,L) = ( O2_AVTrans(n,L) - O1_QVTrans(n,k,L) ) / ka_minus
O2_QAMult_u = ( one - O1_QVTrans(n,k,L) ) / kv_plus
O2_QAVMult_du(n,k,L) = xsxk * ( O2_AVMult(n,L) - xv * O2_QVMult_d(n,k,L) ) / ka_plus
O2_QAVMult_dd(n,k,L) = xsxk * ( O2_AVMult(n,L) - xv * O2_QAMult_u ) / ka_minus
if ( do_Jacobians ) then
do m = 1, nlayers
do p = 1, npars(m)
LP_O2_QVMult_d(n,k,m,p,L) = ( LP_O2_AVTrans(n,m,p,L) - LP_O1_QATrans(n,k,m,p,L) ) / kv_minus
LP_O2_QAMult_d(n,k,m,p,L) = ( LP_O2_AVTrans(n,m,p,L) + O2_QAMult_d(n,k,L) * L_xa(m,p) ) / ka_minus
LP_O2_QAVMult_du(n,k,m,p,L) = ( xsxk * ( LP_O2_AVMult(n,m,p,L) - xv * LP_O2_QVMult_d(n,k,m,p,L) ) &
- O2_QAVMult_du(n,k,L) * L_xa(m,p) ) / ka_plus
LP_O2_QAVMult_dd(n,k,m,p,L) = ( xsxk * LP_O2_AVMult(n,m,p,L) &
+ O2_QAVMult_dd(n,k,L) * L_xa(m,p) ) / ka_minus
enddo
if ( m.eq.n ) then
do p = 1, npars(m)
LP_O2_QAMult_d(n,k,m,p,L) = LP_O2_QAMult_d(n,k,m,p,L) - LP_O1_QVTrans(n,k,p,L) / ka_minus
LP_O2_QAMult_u = - LP_O1_QVTrans(n,k,p,L) / kv_plus
LP_O2_QAVMult_dd(n,k,m,p,L) = LP_O2_QAVMult_dd(n,k,m,p,L) - xsxk * xv * LP_O2_QAMult_u / ka_minus
enddo
endif
enddo
endif
! end k loop
enddo
! end layer loop
enddo
! end geometry loop
enddo
! Finish
return
end subroutine Calculate_Multipliers_LPPlus
subroutine Set_avsecant_LPPlus &
( MaxGeoms, do_plane_parallel, do_LP_jacobians, & ! Flag inputs
nlayers, ngeoms, npars, geoms, & ! Control inputs
SunChapman, opdeps, L_opdeps, & ! Geometrical and Optical inputs
avg_secants, LP_avg_secants ) ! Output
! The convention in 2OS is that Layers are counted from BOA--> TOA (upwards)
! The convention in FO/LIDORT is Layers are counted from TOA--> BOA (downwards)
! Thus if using the LIDORT convention for the Chapman factors, one must reverse
! the indexing on opdeps, and L_opdeps to use it properly
! Calculations are done from Top downwards in this routine
implicit none
! inputs and output
integer , intent(in) :: MaxGeoms
logical , intent(in) :: do_plane_parallel, do_LP_jacobians
integer , intent(in) :: nlayers,ngeoms,npars(MAXLAYERS)
real(fpk), intent(in) :: geoms(3,4,MaxGeoms)
real(fpk), intent(in) :: opdeps(MAXLAYERS)
real(fpk), intent(in) :: L_opdeps(MAXLAYERS,MAX_ATMOSWFS)
real(fpk), intent(in) :: SunChapman (MAXLAYERS,MAXLAYERS,MaxGeoms)
real(fpk), intent(out) :: avg_secants(MAXLAYERS,MaxGeoms)
real(fpk), intent(out) :: LP_avg_secants(MAXLAYERS,MAXLAYERS,MAX_ATMOSWFS,MaxGeoms)
! local variables
real(fpk) :: delta(MAXLAYERS), L_delta(MAXLAYERS,MAX_ATMOSWFS)
real(fpk) :: sum, sum1, lambda,xs, fac
integer :: n,n1,m,m1,L,p,nrev(MAXLAYERS)
! Zero output
avg_secants = zero
LP_avg_secants = zero
! Plane parallel
if ( do_plane_parallel ) then
do L = 1, ngeoms
xs = geoms(1,3,L) ; xs = one / xs
do n = 1, nlayers
avg_secants(n,L) = xs
enddo
enddo
return
endif
! Pseudo-spherical approximation
do n = 1, nlayers
n1 = nlayers + 1 - n ; nrev(n) = n1
delta(n1) = opdeps(n)
enddo
do n = 1, nlayers
n1 = nrev(n)
do L = 1, ngeoms
sum1 = zero
do m = 1, n - 1
sum1 = sum1 + SunChapman(n-1,m,L) * delta(m)
enddo
sum = zero
do m = 1, n
sum = sum + SunChapman(n,m,L) * delta(m)
enddo
avg_secants(n1,L) = (sum-sum1)/delta(n)
enddo
enddo
if ( .not. do_LP_jacobians ) return
! Linearized average secants
do n = 1, nlayers
n1 = nrev(n)
do p = 1, npars(n1)
L_delta(n1,p) = L_opdeps(n,p)
enddo
enddo
do n = 1, nlayers
n1 = nrev(n)
do L = 1, ngeoms
lambda = avg_secants(n1,L)
do m = 1, n
m1 = nrev(m)
if ( m.eq.n ) then
fac = (SunChapman(n,n,L)-lambda)/delta(n)
do p = 1, npars(m1)
LP_avg_secants(n1,m1,p,L) = fac*L_delta(n,p)
enddo
else if (m .lt. n) then
fac = (SunChapman(n,m,L)-SunChapman(n-1,m,L))/delta(n)
do p = 1, npars(m1)
LP_avg_secants(n1,m1,p,L) = fac*L_delta(m,p)
enddo
endif
enddo
enddo
enddo
! Finish
return
end subroutine Set_avsecant_LPPlus
subroutine Add_Fourier_Component_LPSPlus &
(m,nstokes,phi,do_lp_jacobians,do_ls_jacobians,nlayers,npars,nspars, & ! Inputs
R2c,R2s,R2cscal,LP_R2c,LP_R2s,LP_R2cscal,LS_R2c,LS_R2s,LS_R2cscal, & ! Inputs
R2,Icorr,LP_R2,LP_Icorr,LS_R2,LS_Icorr) ! Modified Output
implicit none
! inputs
logical , intent(in) :: do_lp_jacobians,do_ls_jacobians
integer , intent(in) :: m,nstokes,nlayers,npars(MAXLAYERS),nspars
real(fpk), intent(in) :: phi,R2c(4),R2s(4),R2cscal
real(fpk), intent(in) :: LP_R2c(4,MAXLAYERS,MAX_ATMOSWFS) ,LS_R2c(4,MAX_SURFACEWFS)
real(fpk), intent(in) :: LP_R2s(4,MAXLAYERS,MAX_ATMOSWFS) ,LS_R2s(4,MAX_SURFACEWFS)
real(fpk), intent(in) :: LP_R2cscal(MAXLAYERS,MAX_ATMOSWFS),LS_R2cscal(MAX_SURFACEWFS)
! outputs
real(fpk), intent(inout) :: R2(4),Icorr
real(fpk), intent(inout) :: LP_R2(4,MAXLAYERS,MAX_ATMOSWFS), LS_R2(4,MAX_SURFACEWFS)
real(fpk), intent(inout) :: LP_Icorr(MAXLAYERS,MAX_ATMOSWFS), LS_Icorr(MAX_SURFACEWFS)
! local variables
integer :: ki, n, nq
real(fpk) :: cosmph,fac,sinmph,rm
! start of code
rm = real(m,fpk) * DEG_TO_RAD ; cosmph = cos(rm*phi)
if (nstokes .eq. 3) sinmph = sin(rm*phi)
fac = two ; if (m .eq. 0) fac = one
! I and Q components
do ki = 1, 2
R2(ki) = R2(ki)+fac*R2c(ki)*cosmph
if (do_LS_Jacobians) then
LS_R2(ki,1:nspars) = LS_R2(ki,1:nspars) + fac * LS_R2c(ki,1:nspars)*cosmph
endif
if (do_LP_Jacobians) then
do n = 1, nlayers
nq = npars(n)
LP_R2(ki,n,1:nq) = LP_R2(ki,n,1:nq) + fac * LP_R2c(ki,n,1:nq)*cosmph
enddo
endif
enddo
! U component
if (nstokes .eq. 3) then
ki = nstokes ; R2(ki) = R2(ki)+ fac*R2s(ki)*sinmph
if (do_LS_Jacobians) then
LS_R2(ki,1:nspars) = LS_R2(ki,1:nspars) + fac * LS_R2s(ki,1:nspars)*sinmph
endif
if (do_LP_Jacobians) then
do n = 1, nlayers
nq = npars(n)
LP_R2(ki,n,1:nq) = LP_R2(ki,n,1:nq) + fac * LP_R2s(ki,n,1:nq)*sinmph
enddo
endif
endif
! scalar correction
Icorr = Icorr+fac*(R2c(1)-R2cscal)*cosmph
if (do_LS_Jacobians) then
LS_Icorr(1:nspars) = LS_Icorr(1:nspars) + &
fac * (LS_R2c(1,1:nspars)-LS_R2cscal(1:nspars)) * cosmph
endif
if (do_LP_Jacobians) then
do n = 1, nlayers
nq = npars(n)
LP_Icorr(n,1:nq) = LP_Icorr(n,1:nq) + &
fac * (LP_R2c(1,n,1:nq)-LP_R2cscal(n,1:nq)) * cosmph
enddo
endif
! Finish
return
end subroutine Add_Fourier_Component_LPSPlus
! End module
end module vlidort_2OScorr_lps_routines
| src/Components/rtms/RTSI/VLIDORT2OS/sourcecode_str/tmp/vlidort_2OScorr_lps_routines.f90 |
MODULE setcsh_I
INTERFACE
!...Generated by Pacific-Sierra Research 77to90 4.3E 10:50:30 2/14/04
!...Modified by Charlotte Froese Fischer
! Gediminas Gaigalas 10/05/17
SUBROUTINE setcsh (NFILE, NAME, NCORE)
INTEGER, INTENT(IN) :: NFILE
CHARACTER (LEN = *), INTENT(IN) :: NAME
INTEGER :: NCORE
!VAST.../IOUNIT/ ISTDE(IN)
!VAST...Calls: LODCSH
!...This routine performs I/O.
END SUBROUTINE
END INTERFACE
END MODULE
| src/lib/lib9290/setcsh_I.f90 |
!>------------------------------------------------------------
!! Module to test the calendar routines
!!
!! Loops through 2100? years checking that conversions two and from an
!! internal date-time (e.g. Modified Julian Day) and YMD hms are consistent
!! test multiple calendars
!!
!! @author
!! Ethan Gutmann (gutmann@ucar.edu)
!!
!!------------------------------------------------------------
module calendar_test_module
use time
integer, parameter :: STRING_LENGTH = 255
real, parameter :: MAX_ERROR = 1e-5 ! allow less than 1 second error (over a 2100 yr period)
contains
logical function calendar_test(calendar_name,error)
character(len=STRING_LENGTH), intent(in) :: calendar_name
character(len=STRING_LENGTH), intent(out) :: error
double precision :: mjd_input, mjd_output
double precision :: min_mjd, max_mjd, mjd_step
integer :: year, month, day, hour, minute, second
error=""
calendar_test=.True.
call time_init(calendar_name)
min_mjd=365.0*1.d0
max_mjd=365.0*2100.d0
mjd_step=0.1
MJDLOOP: do mjd_input = min_mjd, max_mjd, mjd_step
! test that input and output Modified Julian Days stay the same
call calendar_date(mjd_input, year, month, day, hour, minute, second)
mjd_output=date_to_mjd(year, month, day, hour, minute, second)
! test that month and day values are at least realistic (rare to fail)
if ((day<1).or.(day>31)) then
calendar_test=.False.
write(error,'(6I6, " Error:",f10.6)') year, month, day, hour, minute, second, (mjd_output-mjd_input)
print*, "Testing range:"
print*, " min_mjd, max_mjd, mjd_step"
print*, min_mjd, max_mjd, mjd_step
print*, " Corresponding First Date"
call calendar_date(min_mjd, year, month, day, hour, minute, second)
print*, year, month, day, hour, minute, second
print*, " Corresponding Last Date"
call calendar_date(max_mjd, year, month, day, hour, minute, second)
print*, year, month, day, hour, minute, second
print*, " "
EXIT MJDLOOP
endif
if ((month<1).or.(month>12)) then
calendar_test=.False.
write(error,'(6I6, " Error:",f10.6)') year, month, day, hour, minute, second, (mjd_output-mjd_input)
print*, "Testing range:"
print*, " min_mjd, max_mjd, mjd_step"
print*, min_mjd, max_mjd, mjd_step
print*, " Corresponding First Date"
call calendar_date(min_mjd, year, month, day, hour, minute, second)
print*, year, month, day, hour, minute, second
print*, " Corresponding Last Date"
call calendar_date(max_mjd, year, month, day, hour, minute, second)
print*, year, month, day, hour, minute, second
print*, " "
EXIT MJDLOOP
endif
! this is the main test it is likely to fail
if (abs(mjd_output-mjd_input)>MAX_ERROR) then
calendar_test=.False.
write(error,'(6I6, " Error:",f10.6)') year, month, day, hour, minute, second, (mjd_output-mjd_input)
print*, "Testing range:"
print*, " min_mjd, max_mjd, mjd_step"
print*, min_mjd, max_mjd, mjd_step
print*, " Corresponding First Date"
call calendar_date(min_mjd, year, month, day, hour, minute, second)
print*, year, month, day, hour, minute, second
print*, " Corresponding Last Date"
call calendar_date(max_mjd, year, month, day, hour, minute, second)
print*, year, month, day, hour, minute, second
print*, " "
EXIT MJDLOOP
endif
end do MJDLOOP
end function calendar_test
subroutine detailed_tests(calendar_name)
character(len=STRING_LENGTH), intent(in) :: calendar_name
double precision :: mjd_input, mjd_output
double precision :: min_mjd, max_mjd, mjd_step
integer :: year, month, day, hour, minute, second
call time_init(calendar_name)
min_mjd=365.0*1.d0
max_mjd=365.0*2.d0
mjd_step=1
print*, "Detailed testoutput:"
print*, "Testing range:"
print*, " min_mjd, max_mjd, mjd_step"
print*, min_mjd, max_mjd, mjd_step
print*, " Corresponding First Date"
call calendar_date(min_mjd, year, month, day, hour, minute, second)
print*, year, month, day, hour, minute, second
print*, " Corresponding Last Date"
call calendar_date(max_mjd, year, month, day, hour, minute, second)
print*, year, month, day, hour, minute, second
MJDLOOP: do mjd_input = min_mjd, max_mjd, mjd_step
! test that input and output Modified Julian Days stay the same
call calendar_date(mjd_input, year, month, day, hour, minute, second)
mjd_output=date_to_mjd(year, month, day, hour, minute, second)
print*, mjd_input, mjd_output, mjd_output - mjd_input
print*, year, month, day, hour, minute, second
end do MJDLOOP
end subroutine
end module calendar_test_module
program test_calendar
use calendar_test_module
integer, parameter :: NCALENDARS=5
character(len=STRING_LENGTH),dimension(NCALENDARS) :: calendars_to_test
character(len=STRING_LENGTH) :: calendar_error
character(len=STRING_LENGTH) :: options
integer :: current_calendar
integer :: error
logical :: file_exists
calendars_to_test=[character(len=STRING_LENGTH) :: "gregorian","standard","365-day","noleap","360-day"]
options=""
if (command_argument_count()>0) then
call get_command_argument(1,options, status=error)
endif
if (trim(options)=="help") then
print*, "calendar_test [detailed] [help]"
print*, " detailed: print an entire year of dates for visual inspection"
print*, " help: print this message"
stop
endif
do current_calendar=1,NCALENDARS
print*, "Testing : ", trim(calendars_to_test(current_calendar))
if (calendar_test(calendars_to_test(current_calendar),error=calendar_error)) then
print*, " PASSED "
if (trim(options)=="detailed") then
call detailed_tests(calendars_to_test(current_calendar))
endif
else
print*, " FAILED ", trim(calendars_to_test(current_calendar))
print*, trim(calendar_error)
call detailed_tests(calendars_to_test(current_calendar))
endif
end do
end program test_calendar
| src/tests/test_calendar.f90 |
!
! CRTM_RTSolution
!
! Module containing the CRTM radiative transfer solution routines.
!
!
! CREATION HISTORY:
! Written by: Quanhua Liu, QSS at JCSDA; Quanhua.Liu@noaa.gov
! Yong Han, NOAA/NESDIS; Yong.Han@noaa.gov
! Paul van Delst, CIMSS/SSEC; paul.vandelst@ssec.wisc.edu
! 08-Jun-2004
MODULE CRTM_RTSolution
! ------------------
! Environment set up
! ------------------
! Module use statements
USE Type_Kinds , ONLY: fp
USE Message_Handler , ONLY: SUCCESS, FAILURE, Display_Message
USE CRTM_Parameters , ONLY: ZERO, ONE, TWO, PI, &
MAX_N_ANGLES, &
RT_ADA, RT_SOI
USE Common_RTSolution , ONLY: Assign_Common_Input, &
Assign_Common_Output, &
Assign_Common_Input_TL, &
Assign_Common_Output_TL, &
Assign_Common_Input_AD, &
Assign_Common_Output_AD
USE CRTM_SpcCoeff , ONLY: SC
USE CRTM_Atmosphere_Define , ONLY: CRTM_Atmosphere_type
USE CRTM_Surface_Define , ONLY: CRTM_Surface_type
USE CRTM_GeometryInfo_Define, ONLY: CRTM_GeometryInfo_type
USE CRTM_AtmOptics_Define , ONLY: CRTM_AtmOptics_type
USE CRTM_SfcOptics_Define , ONLY: CRTM_SfcOptics_type
USE CRTM_RTSolution_Define , ONLY: CRTM_RTSolution_type
USE CRTM_Utility
USE RTV_Define
! RT modules
USE SOI_Module
USE ADA_Module
USE Emission_Module
! Disable all implicit typing
IMPLICIT NONE
! --------------------
! Default visibilities
! --------------------
! Everything private by default
PRIVATE
! RTSolution structure entities
! ...Datatypes
PUBLIC :: CRTM_RTSolution_type
! RTV structure entities
! ...Datatypes
PUBLIC :: RTV_type
! Module procedures
PUBLIC :: CRTM_Compute_RTSolution
PUBLIC :: CRTM_Compute_RTSolution_TL
PUBLIC :: CRTM_Compute_RTSolution_AD
PUBLIC :: CRTM_Compute_nStreams
PUBLIC :: CRTM_RTSolution_Version
! -----------------
! Module parameters
! -----------------
! Version Id for the module
CHARACTER(*), PARAMETER :: MODULE_VERSION_ID = &
'$Id$'
CONTAINS
!################################################################################
!################################################################################
!## ##
!## ## PUBLIC MODULE ROUTINES ## ##
!## ##
!################################################################################
!################################################################################
!--------------------------------------------------------------------------------
!
! NAME:
! CRTM_Compute_RTSolution
!
! PURPOSE:
! Function to solve the radiative transfer equation.
!
! CALLING SEQUENCE:
! Error_Status = CRTM_Compute_RTSolution( Atmosphere , & ! Input
! Surface , & ! Input
! AtmOptics , & ! Input
! SfcOptics , & ! Input
! GeometryInfo, & ! Input
! SensorIndex , & ! Input
! ChannelIndex, & ! Input
! RTSolution , & ! Output
! RTV ) ! Internal variable output
!
! INPUT ARGUMENTS:
! Atmosphere: Structure containing the atmospheric state data.
! UNITS: N/A
! TYPE: CRTM_Atmosphere_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! Surface: Structure containing the surface state data.
! UNITS: N/A
! TYPE: CRTM_Surface_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! AtmOptics: Structure containing the combined atmospheric
! optical properties for gaseous absorption, clouds,
! and aerosols.
! UNITS: N/A
! TYPE: CRTM_AtmOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! SfcOptics: Structure containing the surface optical properties
! data. Argument is defined as INTENT (IN OUT ) as
! different RT algorithms may compute the surface
! optics properties before this routine is called.
! UNITS: N/A
! TYPE: CRTM_SfcOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN OUT)
!
! GeometryInfo: Structure containing the view geometry data.
! UNITS: N/A
! TYPE: CRTM_GeometryInfo_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! SensorIndex: Sensor index id. This is a unique index associated
! with a (supported) sensor used to access the
! shared coefficient data for a particular sensor.
! See the ChannelIndex argument.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! ChannelIndex: Channel index id. This is a unique index associated
! with a (supported) sensor channel used to access the
! shared coefficient data for a particular sensor's
! channel.
! See the SensorIndex argument.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! OUTPUT ARGUMENTS:
! RTSolution: Structure containing the soluition to the RT equation
! for the given inputs.
! UNITS: N/A
! TYPE: CRTM_RTSolution_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN OUT)
!
! RTV: Structure containing internal variables required for
! subsequent tangent-linear or adjoint model calls.
! The contents of this structure are NOT accessible
! outside of the CRTM_RTSolution module.
! UNITS: N/A
! TYPE: RTV_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(OUT)
!
! FUNCTION RESULT:
! Error_Status: The return value is an integer defining the error status.
! The error codes are defined in the Message_Handler module.
! If == SUCCESS the computation was sucessful
! == FAILURE an unrecoverable error occurred
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
!
! COMMENTS:
! Note the INTENT on the output RTSolution argument is IN OUT rather than
! just OUT. This is necessary because the argument is defined upon
! input. To prevent memory leaks, the IN OUT INTENT is a must.
!
!--------------------------------------------------------------------------------
FUNCTION CRTM_Compute_RTSolution( &
Atmosphere , & ! Input
Surface , & ! Input
AtmOptics , & ! Input
SfcOptics , & ! Input
GeometryInfo, & ! Input
SensorIndex , & ! Input
ChannelIndex, & ! Input
RTSolution , & ! Output
RTV ) & ! Internal variable output
RESULT( Error_Status )
! Arguments
TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atmosphere
TYPE(CRTM_Surface_type), INTENT(IN) :: Surface
TYPE(CRTM_AtmOptics_type), INTENT(IN) :: AtmOptics
TYPE(CRTM_SfcOptics_type), INTENT(IN OUT) :: SfcOptics
TYPE(CRTM_GeometryInfo_type), INTENT(IN OUT) :: GeometryInfo
INTEGER, INTENT(IN) :: SensorIndex
INTEGER, INTENT(IN) :: ChannelIndex
TYPE(CRTM_RTSolution_type), INTENT(IN OUT) :: RTSolution
TYPE(RTV_type), INTENT(IN OUT) :: RTV
! Function result
INTEGER :: Error_Status
! Local parameters
CHARACTER(*), PARAMETER :: ROUTINE_NAME = 'CRTM_Compute_RTSolution'
! Local variables
CHARACTER(256) :: Message
INTEGER :: i, nZ
Error_Status = SUCCESS
! Populate the RTV structure
Error_Status = Assign_Common_Input( Atmosphere , &
Surface , &
AtmOptics , &
SfcOptics , &
GeometryInfo, &
SensorIndex , &
ChannelIndex, &
RTSolution , &
nz , &
RTV )
IF ( Error_Status /= SUCCESS ) THEN
Message = 'Error assigning input for RTSolution algorithms'
CALL Display_Message( ROUTINE_NAME, TRIM(Message), Error_Status )
RETURN
END IF
! Direct reflectivity normalisation fix for visible sensors
IF( RTV%Visible_Flag_true ) THEN
DO i = 1, nZ
SfcOptics%Direct_Reflectivity(i,1) = SfcOptics%Direct_Reflectivity(i,1) * PI
! ...Apply the UW limiter
IF (SfcOptics%Direct_Reflectivity(i,1) > ONE) THEN
SfcOptics%Direct_Reflectivity(i,1) = ONE
END IF
END DO
END IF
! ------------------------------
! Perform the radiative transfer
! ------------------------------
! Select the RT model
IF( RTV%Scattering_RT ) THEN
! Select the scattering RT model
SELECT CASE(RTV%RT_Algorithm_Id)
CASE (RT_ADA) ;
RTSolution%RT_Algorithm_Name = 'ADA'
! NESDIS advanced adding-doubling method
CALL CRTM_ADA( &
Atmosphere%n_Layers , & ! Input, number of atmospheric layers
AtmOptics%Single_Scatter_Albedo , & ! Input, layer single scattering albedo
AtmOptics%Optical_Depth , & ! Input, layer optical depth
RTV%Cosmic_Background_Radiance , & ! Input, cosmic background radiation
SfcOptics%Emissivity( 1:nZ, 1 ) , & ! Input, surface emissivity
SfcOptics%Reflectivity( 1:nZ, 1, 1:nZ, 1 ), & ! Input, surface reflectivity
SfcOptics%Direct_Reflectivity(1:nZ,1) , & ! Input, surface reflectivity for a point source
RTV ) ! Output, Internal variables
CASE (RT_SOI) ;
RTSolution%RT_Algorithm_Name = 'SOI'
! UW SOI RT solver
CALL CRTM_SOI( &
Atmosphere%n_Layers , & ! Input, number of atmospheric layers
AtmOptics%Single_Scatter_Albedo , & ! Input, layer single scattering albedo
AtmOptics%Optical_Depth , & ! Input, layer optical depth
RTV%Cosmic_Background_Radiance , & ! Input, cosmic background radiation
SfcOptics%Emissivity( 1:nZ, 1 ) , & ! Input, surface emissivity
SfcOptics%Reflectivity( 1:nZ, 1, 1:nZ, 1 ), & ! Input, surface reflectivity
SfcOptics%Index_Sat_Ang , & ! Input, Satellite angle index
RTV ) ! Output, Internal variables
END SELECT
ELSE
! -----------------
! Emission model RT
! -----------------
RTSolution%RT_Algorithm_Name = 'Emission'
CALL CRTM_Emission( &
Atmosphere%n_Layers, & ! Input, number of atmospheric layers
RTV%n_Angles, & ! Input, number of discrete zenith angles
RTV%Diffuse_Surface, & ! Input, surface behavior
GeometryInfo%Cosine_Sensor_Zenith, & ! Input, cosine of sensor zenith angle
AtmOptics%Optical_Depth, & ! Input, layer optical depth
RTV%Planck_Atmosphere, & ! Input, layer radiances
RTV%Planck_Surface, & ! Input, surface radiance
SfcOptics%Emissivity(1:nZ,1), & ! Input, surface emissivity
SfcOptics%Reflectivity(1:nZ,1,1:nZ,1), & ! Input, surface reflectivity
SfcOptics%Direct_Reflectivity(1:nZ,1), & ! Input, surface reflectivity for a point source
RTV%Cosmic_Background_Radiance, & ! Input, cosmic background radiation
RTV%Solar_Irradiance, & ! Input, Source irradiance at TOA
RTV%Is_Solar_Channel, & ! Input, Source sensitive channel info.
GeometryInfo%Source_Zenith_Radian, & ! Input, Source zenith angle
RTV ) ! Output, Internal variables
END IF
Error_Status = Assign_Common_Output( Atmosphere, &
SfcOptics, &
GeometryInfo, &
SensorIndex, &
ChannelIndex, &
RTV, &
RTSolution )
IF ( Error_Status /= SUCCESS ) THEN
Message = 'Error assigning output for RTSolution algorithms'
CALL Display_Message( ROUTINE_NAME, TRIM(Message), Error_Status )
RETURN
END IF
END FUNCTION CRTM_Compute_RTSolution
!--------------------------------------------------------------------------------
!
! NAME:
! CRTM_Compute_RTSolution_TL
!
! PURPOSE:
! Function to solve the tangent-linear radiative transfer equation.
!
! CALLING SEQUENCE:
! Error_Status = CRTM_Compute_RTSolution_TL( Atmosphere , & ! FWD Input
! Surface , & ! FWD Input
! AtmOptics , & ! FWD Input
! SfcOptics , & ! FWD Input
! RTSolution , & ! FWD Input
! Atmosphere_TL, & ! TL Input
! Surface_TL , & ! TL Input
! AtmOptics_TL , & ! TL Input
! SfcOptics_TL , & ! TL Input
! GeometryInfo , & ! Input
! SensorIndex , & ! Input
! ChannelIndex , & ! Input
! RTSolution_TL, & ! TL Output
! RTV ) ! Internal variable input
!
! INPUT ARGUMENTS:
! Atmosphere: Structure containing the atmospheric state data.
! UNITS: N/A
! TYPE: CRTM_Atmosphere_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! Surface: Structure containing the surface state data.
! UNITS: N/A
! TYPE: CRTM_Surface_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! AtmOptics: Structure containing the combined atmospheric
! optical properties for gaseous absorption, clouds,
! and aerosols.
! UNITS: N/A
! TYPE: CRTM_AtmOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! SfcOptics: Structure containing the surface optical properties
! data.
! UNITS: N/A
! TYPE: CRTM_SfcOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! RTSolution: Structure containing the solution to the RT equation
! for the given inputs.
! UNITS: N/A
! TYPE: CRTM_RTSolution_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! Atmosphere_TL: Structure containing the tangent-linear atmospheric
! state data.
! UNITS: N/A
! TYPE: CRTM_Atmosphere_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! Surface_TL: Structure containing the tangent-linear surface state data.
! UNITS: N/A
! TYPE: CRTM_Surface_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! AtmOptics_TL: Structure containing the tangent-linear atmospheric
! optical properties.
! UNITS: N/A
! TYPE: CRTM_AtmOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! SfcOptics_TL: Structure containing the tangent-linear surface optical
! properties. Argument is defined as INTENT (IN OUT ) as
! different RT algorithms may compute the surface optics
! properties before this routine is called.
! UNITS: N/A
! TYPE: CRTM_SfcOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT( IN OUT)
!
! GeometryInfo: Structure containing the view geometry data.
! UNITS: N/A
! TYPE: CRTM_GeometryInfo_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! SensorIndex: Sensor index id. This is a unique index associated
! with a (supported) sensor used to access the
! shared coefficient data for a particular sensor.
! See the ChannelIndex argument.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! ChannelIndex: Channel index id. This is a unique index associated
! with a (supported) sensor channel used to access the
! shared coefficient data for a particular sensor's
! channel.
! See the SensorIndex argument.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! RTV: Structure containing internal forward model variables
! required for subsequent tangent-linear or adjoint model
! calls. The contents of this structure are NOT accessible
! outside of the CRTM_RTSolution module.
! UNITS: N/A
! TYPE: RTV_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(OUT)
!
! OUTPUT ARGUMENTS:
! RTSolution_TL: Structure containing the solution to the tangent-linear
! RT equation for the given inputs.
! UNITS: N/A
! TYPE: CRTM_RTSolution_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN OUT)
!
! FUNCTION RESULT:
! Error_Status: The return value is an integer defining the error status
! The error codes are defined in the Message_Handler module.
! If == SUCCESS the computation was sucessful
! == FAILURE an unrecoverable error occurred
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
!
! COMMENTS:
! Note the INTENT on the output RTSolution_TL argument is IN OUT rather
! than just OUT. This is necessary because the argument may be defined
! upon input. To prevent memory leaks, the IN OUT INTENT is a must.
!
!--------------------------------------------------------------------------------
FUNCTION CRTM_Compute_RTSolution_TL( &
Atmosphere , & ! FWD Input
Surface , & ! FWD Input
AtmOptics , & ! FWD Input
SfcOptics , & ! FWD Input
RTSolution , & ! FWD Input
Atmosphere_TL, & ! TL Input
Surface_TL , & ! TL Input
AtmOptics_TL , & ! TL Input
SfcOptics_TL , & ! TL Input
GeometryInfo , & ! Input
SensorIndex , & ! Input
ChannelIndex , & ! Input
RTSolution_TL, & ! TL Output
RTV ) & ! Internal variable input
RESULT( Error_Status )
! Arguments
TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atmosphere
TYPE(CRTM_Surface_type), INTENT(IN) :: Surface
TYPE(CRTM_AtmOptics_type), INTENT(IN) :: AtmOptics
TYPE(CRTM_SfcOptics_type), INTENT(IN) :: SfcOptics
TYPE(CRTM_RTSolution_type), INTENT(IN) :: RTSolution
TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atmosphere_TL
TYPE(CRTM_Surface_type), INTENT(IN) :: Surface_TL
TYPE(CRTM_AtmOptics_type), INTENT(IN) :: AtmOptics_TL
TYPE(CRTM_SfcOptics_type), INTENT(IN OUT) :: SfcOptics_TL
TYPE(CRTM_GeometryInfo_type), INTENT(IN) :: GeometryInfo
INTEGER, INTENT(IN) :: SensorIndex
INTEGER, INTENT(IN) :: ChannelIndex
TYPE(CRTM_RTSolution_type), INTENT(IN OUT) :: RTSolution_TL
TYPE(RTV_type), INTENT(IN) :: RTV
! Function result
INTEGER :: Error_Status
! Local parameters
CHARACTER(*), PARAMETER :: ROUTINE_NAME = 'CRTM_Compute_RTSolution_TL'
! Local variables
CHARACTER(256) :: Message
INTEGER :: nZ
REAL(fp) :: User_Emissivity_TL, Direct_Reflectivity_TL
REAL(fp) :: Planck_Surface_TL ! Surface TL radiance
REAL(fp), DIMENSION( 0:Atmosphere%n_Layers ) :: Planck_Atmosphere_TL ! *LAYER* TL radiances
! The following variables are RT model specific
REAL(fp), DIMENSION( MAX_N_ANGLES, &
MAX_N_ANGLES+1, &
Atmosphere%n_Layers ) :: Pff_TL ! Forward scattering TL phase matrix
REAL(fp), DIMENSION( MAX_N_ANGLES, &
MAX_N_ANGLES+1, &
Atmosphere%n_Layers ) :: Pbb_TL ! Backward scattering TL phase matrix
REAL(fp), DIMENSION( MAX_N_ANGLES ) :: Scattering_Radiance_TL
REAL(fp) :: Radiance_TL
! ------
! Set up
! ------
Error_Status = SUCCESS
RTSolution_TL%RT_Algorithm_Name = RTSolution%RT_Algorithm_Name
Error_Status = Assign_Common_Input_TL( Atmosphere , & ! FWD Input
Surface , & ! FWD Input
AtmOptics , & ! FWD Input
SfcOptics , & ! FWD Input
Atmosphere_TL , & ! TL Input
Surface_TL , & ! TL Input
AtmOptics_TL , & ! TL Input
SfcOptics_TL , & ! TL Input Output
GeometryInfo , & ! Input
SensorIndex , & ! Input
ChannelIndex , & ! Input
RTSolution_TL , & ! TL Output
nz , & ! Output
User_Emissivity_TL , & ! Output
Direct_Reflectivity_TL , & ! Output
Planck_Surface_TL , & ! Output
Planck_Atmosphere_TL , & ! Output
Pff_TL , & ! Output
Pbb_TL , & ! Output
RTV ) ! Internal variable input
IF ( Error_Status /= SUCCESS ) THEN
Message = 'Error assigning input for TL RTSolution algorithms'
CALL Display_Message( ROUTINE_NAME, TRIM(Message), Error_Status )
RETURN
END IF
! ---------------------------------------------
! Perform the tangent-linear radiative transfer
! ---------------------------------------------
! Select the RT model
IF( RTV%Scattering_RT ) THEN
! Select the scattering RT model
SELECT CASE(RTV%RT_Algorithm_Id)
CASE (RT_ADA)
! NESDIS advanced adding-doubling method
CALL CRTM_ADA_TL( &
Atmosphere%n_Layers, & ! Input, number of atmospheric layers
AtmOptics%Single_Scatter_Albedo, & ! Input, FWD layer single scattering albedo
AtmOptics%Optical_Depth, & ! Input, FWD layer optical depth
RTV%Cosmic_Background_Radiance, & ! cosmic background radiation
SfcOptics%Emissivity(1:nZ,1), & ! Input, FWD surface emissivity
SfcOptics%Direct_Reflectivity(1:nZ,1), & ! Input, surface direct reflectivity
RTV, & ! Input, structure containing forward results
Planck_Atmosphere_TL, & ! Input, TL layer radiances
Planck_Surface_TL, & ! Input, TL surface radiance
AtmOptics_TL%Single_Scatter_Albedo, & ! Input, TL layer single scattering albedo
AtmOptics_TL%Optical_Depth, & ! Input, TL layer optical depth
SfcOptics_TL%Emissivity(1:nZ,1), & ! Input, TL surface emissivity
SfcOptics_TL%Reflectivity(1:nZ,1,1:nZ,1), & ! Input, TL surface reflectivity
SfcOptics_TL%Direct_Reflectivity(1:nZ,1), & ! Input, TL surface direct reflectivity
Pff_TL(1:nZ,1:(nZ+1),:), & ! Input, TL layer forward phase matrix
Pbb_TL(1:nZ,1:(nZ+1),:), & ! Input, TL layer backward phase matrix
Scattering_Radiance_TL(1:nZ) ) ! Output, TL radiances
CASE (RT_SOI)
! UW SOI RT solver
CALL CRTM_SOI_TL( &
Atmosphere%n_Layers, & ! Input, number of atmospheric layers
AtmOptics%Single_Scatter_Albedo, & ! Input, FWD layer single scattering albedo
AtmOptics%Optical_Depth, & ! Input, FWD layer optical depth
SfcOptics%Emissivity(1:nZ,1), & ! Input, FWD surface emissivity
SfcOptics%Reflectivity(1:nZ,1,1:nZ,1), & ! Input, surface reflectivity
SfcOptics%Index_Sat_Ang, & ! Input, Satellite angle index
RTV, & ! Input, structure containing forward results
Planck_Atmosphere_TL, & ! Input, TL layer radiances
Planck_Surface_TL, & ! Input, TL surface radiance
AtmOptics_TL%Single_Scatter_Albedo, & ! Input, TL layer single scattering albedo
AtmOptics_TL%Optical_Depth, & ! Input, TL layer optical depth
SfcOptics_TL%Emissivity(1:nZ,1), & ! Input, TL surface emissivity
SfcOptics_TL%Reflectivity(1:nZ,1,1:nZ,1), & ! Input, TL surface reflectivity
Pff_TL(1:nZ,1:nZ,:), & ! Input, TL layer forward phase matrix
Pbb_TL(1:nZ,1:nZ,:), & ! Input, TL layer backward phase matrix
Scattering_Radiance_TL(1:nZ) ) ! Output, TL radiances
END SELECT
ELSE
! -----------------
! Emission model RT
! -----------------
CALL CRTM_Emission_TL( &
Atmosphere%n_Layers, & ! Input, number of atmospheric layers
RTV%n_Angles, & ! Input, number of discrete zenith angles
GeometryInfo%Cosine_Sensor_Zenith, & ! Input, cosine of sensor zenith angle
RTV%Planck_Atmosphere, & ! Input, FWD layer radiances
RTV%Planck_Surface, & ! Input, FWD surface radiance
SfcOptics%Emissivity(1:nZ,1), & ! Input, FWD surface emissivity
SfcOptics%Reflectivity(1:nZ,1,1:nZ,1), & ! Input, FWD surface reflectivity
SfcOptics%Direct_Reflectivity(1:nZ,1), & ! Input, FWD surface reflectivity for a point source
RTV%Solar_Irradiance, & ! Input, Source irradiance at TOA
RTV%Is_Solar_Channel, & ! Input, Source sensitive channel info.
GeometryInfo%Source_Zenith_Radian, & ! Input, Source zenith angle
RTV, & ! Input, internal variables
AtmOptics_TL%Optical_Depth, & ! Input, TL layer optical depth
Planck_Atmosphere_TL, & ! Input, TL layer radiances
Planck_Surface_TL, & ! Input, TL surface radiance
SfcOptics_TL%Emissivity(1:nZ,1), & ! Input, TL surface emissivity
SfcOptics_TL%Reflectivity(1:nZ,1,1:nZ,1), & ! Input, TL surface reflectivity
SfcOptics_TL%Direct_Reflectivity(1:nZ,1), & ! Input, TL surface reflectivity for a point source
Radiance_TL ) ! Output, TL radiances
END IF
Error_Status = Assign_Common_Output_TL( SfcOptics , &
RTSolution , &
GeometryInfo , &
Radiance_TL , &
Scattering_Radiance_TL, &
SensorIndex , &
ChannelIndex , &
RTV , &
RTSolution_TL )
IF ( Error_Status /= SUCCESS ) THEN
Message = 'Error assigning output for TL RTSolution algorithms'
CALL Display_Message( ROUTINE_NAME, TRIM(Message), Error_Status )
RETURN
END IF
END FUNCTION CRTM_Compute_RTSolution_TL
!--------------------------------------------------------------------------------
!
! NAME:
! CRTM_Compute_RTSolution_AD
!
! PURPOSE:
! Function to solve the adjoint radiative transfer equation.
!
! CALLING SEQUENCE:
! Error_Status = CRTM_Compute_RTSolution_AD( Atmosphere , & ! FWD Input
! Surface , & ! FWD Input
! AtmOptics , & ! FWD Input
! SfcOptics , & ! FWD Input
! RTSolution , & ! FWD Input
! RTSolution_AD, & ! AD Input
! GeometryInfo , & ! Input
! SensorIndex , & ! Input
! ChannelIndex , & ! Input
! Atmosphere_AD, & ! AD Output
! Surface_AD , & ! AD Output
! AtmOptics_AD , & ! AD Output
! SfcOptics_AD , & ! AD Output
! RTV ) ! Internal variable input
!
! INPUT ARGUMENTS:
! Atmosphere: Structure containing the atmospheric state data.
! UNITS: N/A
! TYPE: CRTM_Atmosphere_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! Surface: Structure containing the surface state data.
! UNITS: N/A
! TYPE: CRTM_Surface_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! AtmOptics: Structure containing the combined atmospheric
! optical properties for gaseous absorption, clouds,
! and aerosols.
! UNITS: N/A
! TYPE: CRTM_AtmOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! SfcOptics: Structure containing the surface optical properties
! data.
! UNITS: N/A
! TYPE: CRTM_SfcOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! RTSolution: Structure containing the solution to the RT equation
! for the given inputs.
! UNITS: N/A
! TYPE: CRTM_RTSolution_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! RTSolution_AD: Structure containing the RT solution adjoint inputs.
! UNITS: N/A
! TYPE: CRTM_RTSolution_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN OUT)
!
! GeometryInfo: Structure containing the view geometry data.
! UNITS: N/A
! TYPE: CRTM_GeometryInfo_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! SensorIndex: Sensor index id. This is a unique index associated
! with a (supported) sensor used to access the
! shared coefficient data for a particular sensor.
! See the ChannelIndex argument.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! ChannelIndex: Channel index id. This is a unique index associated
! with a (supported) sensor channel used to access the
! shared coefficient data for a particular sensor's
! channel.
! See the SensorIndex argument.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! RTV: Structure containing internal forward model variables
! required for subsequent tangent-linear or adjoint model
! calls. The contents of this structure are NOT accessible
! outside of the CRTM_RTSolution module.
! UNITS: N/A
! TYPE: RTV_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! OUTPUT ARGUMENTS:
! Atmosphere_AD: Structure containing the adjoint atmospheric
! state data.
! UNITS: N/A
! TYPE: CRTM_Atmosphere_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN OUT)
!
! Surface_AD: Structure containing the adjoint surface state data.
! UNITS: N/A
! TYPE: CRTM_Surface_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN OUT)
!
! AtmOptics_AD: Structure containing the adjoint combined atmospheric
! optical properties for gaseous absorption, clouds,
! and aerosols.
! UNITS: N/A
! TYPE: CRTM_AtmOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN OUT)
!
! SfcOptics_AD: Structure containing the adjoint surface optical
! properties data.
! UNITS: N/A
! TYPE: CRTM_SfcOptics_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT( IN OUT)
!
! FUNCTION RESULT:
! Error_Status: The return value is an integer defining the error status
! The error codes are defined in the Message_Handler module.
! If == SUCCESS the computation was sucessful
! == FAILURE an unrecoverable error occurred
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
!
! COMMENTS:
! Note the INTENT on all of the adjoint arguments (whether input or output)
! is IN OUT rather than just OUT. This is necessary because the Input
! adjoint arguments are modified, and the Output adjoint arguments must
! be defined prior to entry to this routine. So, anytime a structure is
! to be output, to prevent memory leaks the IN OUT INTENT is a must.
!
!--------------------------------------------------------------------------------
FUNCTION CRTM_Compute_RTSolution_AD( &
Atmosphere , & ! FWD Input
Surface , & ! FWD Input
AtmOptics , & ! FWD Input
SfcOptics , & ! FWD Input
RTSolution , & ! FWD Input
RTSolution_AD, & ! AD Input
GeometryInfo , & ! Input
SensorIndex , & ! Input
ChannelIndex , & ! Input
Atmosphere_AD, & ! AD Output
Surface_AD , & ! AD Output
AtmOptics_AD , & ! AD Output
SfcOptics_AD , & ! AD Output
RTV ) & ! Internal variable input
RESULT( Error_Status )
! Arguments
TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atmosphere
TYPE(CRTM_Surface_type), INTENT(IN) :: Surface
TYPE(CRTM_AtmOptics_type), INTENT(IN) :: AtmOptics
TYPE(CRTM_SfcOptics_type), INTENT(IN) :: SfcOptics
TYPE(CRTM_RTSolution_type), INTENT(IN) :: RTSolution
TYPE(CRTM_RTSolution_type), INTENT(IN OUT) :: RTSolution_AD
TYPE(CRTM_GeometryInfo_type), INTENT(IN) :: GeometryInfo
INTEGER, INTENT(IN) :: SensorIndex
INTEGER, INTENT(IN) :: ChannelIndex
TYPE(CRTM_Atmosphere_type), INTENT(IN OUT) :: Atmosphere_AD
TYPE(CRTM_Surface_type), INTENT(IN OUT) :: Surface_AD
TYPE(CRTM_AtmOptics_type), INTENT(IN OUT) :: AtmOptics_AD
TYPE(CRTM_SfcOptics_type), INTENT(IN OUT) :: SfcOptics_AD
TYPE(RTV_type), INTENT(IN) :: RTV
! Function result
INTEGER :: Error_Status
! Local parameters
CHARACTER(*), PARAMETER :: ROUTINE_NAME = 'CRTM_Compute_RTSolution_AD'
! Local variables
CHARACTER(256) :: Message
INTEGER :: nz
REAL(fp) :: Planck_Surface_AD ! Surface AD radiance
REAL(fp), DIMENSION( 0:Atmosphere%n_Layers ) :: Planck_Atmosphere_AD ! *LAYER* AD radiances
REAL(fp) :: User_Emissivity_AD ! Temporary adjoint variable for SfcOptics calcs.
! The following variables are RT model specific
REAL(fp), DIMENSION( MAX_N_ANGLES, &
MAX_N_ANGLES+1, &
Atmosphere%n_Layers ) :: Pff_AD ! Forward scattering AD phase matrix
REAL(fp), DIMENSION( MAX_N_ANGLES, &
MAX_N_ANGLES+1, &
Atmosphere%n_Layers ) :: Pbb_AD ! Backward scattering AD phase matrix
REAL (fp),DIMENSION( MAX_N_ANGLES ) :: Scattering_Radiance_AD
REAL (fp) :: Radiance_AD
! -----
! Setup
! -----
Error_Status = SUCCESS
RTSolution_AD%RT_Algorithm_Name = RTSolution%RT_Algorithm_Name
Error_Status = Assign_Common_Input_AD( SfcOptics , & ! FWD Input
RTSolution , & ! FWD Input
GeometryInfo , & ! Input
SensorIndex , & ! Input
ChannelIndex , & ! Input
RTSolution_AD , & ! AD Output/Input
SfcOptics_AD , & ! AD Output
Planck_Surface_AD , & ! AD Output
Planck_Atmosphere_AD , & ! AD Output
Radiance_AD , & ! AD Output
nz , & ! Output
RTV ) ! Internal variable input
IF ( Error_Status /= SUCCESS ) THEN
Message = 'Error assigning input for AD RTSolution algorithms'
CALL Display_Message( ROUTINE_NAME, TRIM(Message), Error_Status )
RETURN
END IF
! --------------------------------------
! Perform the adjoint radiative transfer
! --------------------------------------
! Select the RT model
IF( RTV%Scattering_RT ) THEN
! Initialise the input adjoint radiance
Scattering_Radiance_AD = ZERO
Scattering_Radiance_AD( SfcOptics%Index_Sat_Ang ) = Radiance_AD
!! RTSolution_AD%Radiance = ZERO
! Select the scattering RT model
IF ( RTV%RT_Algorithm_Id == RT_ADA ) THEN
! NESDIS advanced adding-doubling method
CALL CRTM_ADA_AD( &
Atmosphere%n_Layers, & ! Input, number of atmospheric layers
AtmOptics%Single_Scatter_Albedo, & ! Input, FWD layer single scattering albedo
AtmOptics%Optical_Depth, & ! Input, FWD layer optical depth
RTV%Cosmic_Background_Radiance, & ! Input, cosmic background radiation
SfcOptics%Emissivity(1:nZ,1), & ! Input, FWD surface emissivity
SfcOptics%Direct_Reflectivity(1:nZ,1), & ! Input, FWD surface reflectivity for a point source
RTV, & ! In/Output, internal variables
Scattering_Radiance_AD(1:nZ), & ! Input, AD radiances
Planck_Atmosphere_AD, & ! Output, AD layer radiances
Planck_Surface_AD, & ! Output, AD surface radiance
AtmOptics_AD%Single_Scatter_Albedo, & ! Output, AD layer single scattering albedo
AtmOptics_AD%Optical_Depth, & ! Output, AD layer optical depth
SfcOptics_AD%Emissivity(1:nZ,1), & ! Output, AD surface emissivity
SfcOptics_AD%Reflectivity(1:nZ,1,1:nZ,1), & ! Output, AD surface reflectivity
SfcOptics_AD%Direct_Reflectivity(1:nZ,1), & ! Output, AD surface reflectivity for a point source
Pff_AD(1:nZ,1:(nZ+1),:), & ! Output, AD layer forward phase matrix
Pbb_AD(1:nZ,1:(nZ+1),:) ) ! Output, AD layer backward phase matrix
ELSE
! UW SOI RT solver
CALL CRTM_SOI_AD( &
Atmosphere%n_Layers, & ! Input, number of atmospheric layers
AtmOptics%Single_Scatter_Albedo, & ! Input, FWD layer single scattering albedo
AtmOptics%Optical_Depth, & ! Input, FWD layer optical depth
SfcOptics%Emissivity(1:nZ,1), & ! Input, FWD surface emissivity
SfcOptics%Reflectivity(1:nZ,1,1:nZ,1), & ! Input, FWD surface reflectivity
SfcOptics%Index_Sat_Ang, & ! Input, Satellite angle index
RTV, & ! In/Output, internal variables
Scattering_Radiance_AD(1:nZ), & ! Input, AD radiances
Planck_Atmosphere_AD, & ! Output AD atmospheric layer Planck radiance
Planck_Surface_AD, & ! Output AD surface Planck radiance
AtmOptics_AD%Single_Scatter_Albedo, & ! Output, AD layer single scattering albedo
AtmOptics_AD%Optical_Depth, & ! Output, AD layer optical depth
SfcOptics_AD%Emissivity(1:nZ,1), & ! Output, AD surface emissivity
SfcOptics_AD%Reflectivity(1:nZ,1,1:nZ,1), & ! Output, AD surface reflectivity
Pff_AD(1:nZ,1:(nZ+1),:), & ! Output, AD layer forward phase matrix
Pbb_AD(1:nZ,1:(nZ+1),:) ) ! Output, AD layer backward phase matrix
END IF
ELSE
! -----------------
! Emission model RT
! -----------------
CALL CRTM_Emission_AD( &
Atmosphere%n_Layers, & ! Input, number of atmospheric layers
RTV%n_Angles, & ! Input, number of discrete zenith angles
GeometryInfo%Cosine_Sensor_Zenith, & ! Input, cosine of sensor zenith angle
RTV%Planck_Atmosphere, & ! Input, FWD layer radiances
RTV%Planck_Surface, & ! Input, FWD surface radiance
SfcOptics%Emissivity(1:nZ,1), & ! Input, FWD surface emissivity
SfcOptics%Reflectivity(1:nZ,1,1:nZ,1), & ! Input, FWD surface reflectivity
SfcOptics%Direct_Reflectivity(1:nZ,1), & ! Input, FWD surface reflectivity for a point source
RTV%Solar_Irradiance, & ! Input, Source irradiance at TOA
RTV%Is_Solar_Channel, & ! Input, Source sensitive channel info.
GeometryInfo%Source_Zenith_Radian, & ! Input, Source zenith angle
RTV, & ! Input, internal variables
Radiance_AD, & ! Input, AD radiance
AtmOptics_AD%Optical_Depth, & ! Output, AD layer optical depth
Planck_Atmosphere_AD, & ! Output, AD layer radiances
Planck_Surface_AD, & ! Output, AD surface radiance
SfcOptics_AD%Emissivity(1:nZ,1), & ! Output, AD surface emissivity
SfcOptics_AD%Reflectivity(1:nZ,1,1:nZ,1), & ! Output, AD surface reflectivity
SfcOptics_AD%Direct_Reflectivity(1:nZ,1) ) ! Output, AD surface reflectivity for a point source
END IF
Error_Status = Assign_Common_Output_AD( Atmosphere , & ! Input
Surface , & ! Input
AtmOptics , & ! Input
SfcOptics , & ! Input
Pff_AD , & ! Input
Pbb_AD , & ! Input
GeometryInfo , & ! Input
SensorIndex , & ! Input
ChannelIndex , & ! Input
nZ , & ! Input
AtmOptics_AD , & ! Output
SfcOptics_AD , & ! Output
Planck_Surface_AD , & ! Output
Planck_Atmosphere_AD , & ! Output
User_Emissivity_AD , & ! Output
Atmosphere_AD , & ! Output
Surface_AD , & ! Output
RTSolution_AD , & ! Output
RTV ) ! Input
IF ( Error_Status /= SUCCESS ) THEN
Message = 'Error assigning output for AD RTSolution algorithms'
CALL Display_Message( ROUTINE_NAME, TRIM(Message), Error_Status )
RETURN
END IF
END FUNCTION CRTM_Compute_RTSolution_AD
!--------------------------------------------------------------------------------
!
! NAME:
! CRTM_Compute_n_Streams
!
! PURPOSE:
! Function to compute the number of streams required for subsequent
! radiative transfer calculations
!
! CALLING SEQUENCE:
! nStreams = CRTM_Compute_n_Streams( Atmosphere, & ! Input
! SensorIndex, & ! Input
! ChannelIndex, & ! Input
! RTSolution ) ! Output
!
! INPUT ARGUMENTS:
! Atmosphere: Structure containing the atmospheric state data.
! UNITS: N/A
! TYPE: CRTM_Atmosphere_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! SensorIndex: Sensor index id. This is a unique index associated
! with a (supported) sensor used to access the
! shared coefficient data for a particular sensor.
! See the ChannelIndex argument.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! ChannelIndex: Channel index id. This is a unique index associated
! with a (supported) sensor channel used to access the
! shared coefficient data for a particular sensor's
! channel.
! See the SensorIndex argument.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN)
!
! OUTPUT ARGUMENTS:
! RTSolution: Structure containing the scattering flag to be set
! for the RT calcs.
! UNITS: N/A
! TYPE: CRTM_RTSolution_type
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(IN OUT)
!
! FUNCTION RESULT:
! nStreams: The number of RT streams required to perform radiative
! transfer in a scattering atmosphere.
! UNITS: N/A
! TYPE: INTEGER
! DIMENSION: Scalar
!
!--------------------------------------------------------------------------------
FUNCTION CRTM_Compute_nStreams( &
Atmosphere , & ! Input
SensorIndex , & ! Input
ChannelIndex, & ! Input
RTSolution ) & ! Output
RESULT( nStreams )
! Arguments
TYPE(CRTM_Atmosphere_type), INTENT(IN) :: Atmosphere
INTEGER, INTENT(IN) :: SensorIndex
INTEGER, INTENT(IN) :: ChannelIndex
TYPE(CRTM_RTSolution_type), INTENT(IN OUT) :: RTSolution
! Function result
INTEGER :: nStreams
! Local variables
REAL(fp) :: maxReff, Reff, MieParameter
INTEGER :: n
! Set up
nStreams = 0
RTSolution%n_full_Streams = nStreams
RTSolution%Scattering_FLAG = .FALSE.
! If no clouds and no aerosols, no scattering, so return
IF ( Atmosphere%n_Clouds == 0 .AND. &
Atmosphere%n_Aerosols == 0 ) RETURN
! Determine the maximum cloud particle size
maxReff = ZERO
DO n = 1, Atmosphere%n_Clouds
Reff = MAXVAL(Atmosphere%Cloud(n)%Effective_Radius)
IF( Reff > maxReff) maxReff = Reff
END DO
DO n = 1, Atmosphere%n_Aerosols
Reff = MAXVAL(Atmosphere%Aerosol(n)%Effective_Radius)
IF( Reff > maxReff) maxReff = Reff
END DO
! Compute the Mie parameter, 2.pi.Reff/lambda
MieParameter = TWO * PI * maxReff * SC(SensorIndex)%Wavenumber(ChannelIndex)/10000.0_fp
! Determine the number of streams based on Mie parameter
IF ( MieParameter < 0.01_fp ) THEN
nStreams = 2
ELSE IF( MieParameter < ONE ) THEN
nStreams = 4
ELSE
nStreams = 6
END IF
! Hardcode number of streams for testing purposes
! nStreams = 6
! Set RTSolution scattering info
RTSolution%Scattering_Flag = .TRUE.
RTSolution%n_full_Streams = nStreams + 2
END FUNCTION CRTM_Compute_nStreams
!--------------------------------------------------------------------------------
!:sdoc+:
!
! NAME:
! CRTM_RTSolution_Version
!
! PURPOSE:
! Subroutine to return the module version information.
!
! CALLING SEQUENCE:
! CALL CRTM_RTSolution_Version( Id )
!
! OUTPUT ARGUMENTS:
! Id: Character string containing the version Id information
! for the module.
! UNITS: N/A
! TYPE: CHARACTER(*)
! DIMENSION: Scalar
! ATTRIBUTES: INTENT(OUT)
!
!:sdoc-:
!--------------------------------------------------------------------------------
SUBROUTINE CRTM_RTSolution_Version( Id )
CHARACTER(*), INTENT(OUT) :: Id
Id = MODULE_VERSION_ID
END SUBROUTINE CRTM_RTSolution_Version
END MODULE CRTM_RTSolution
| src/Components/rtms/crtm/CRTM_RTSolution.f90 |
cdis Forecast Systems Laboratory
cdis NOAA/OAR/ERL/FSL
cdis 325 Broadway
cdis Boulder, CO 80303
cdis
cdis Forecast Research Division
cdis Local Analysis and Prediction Branch
cdis LAPS
cdis
cdis This software and its documentation are in the public domain and
cdis are furnished "as is." The United States government, its
cdis instrumentalities, officers, employees, and agents make no
cdis warranty, express or implied, as to the usefulness of the software
cdis and documentation for any purpose. They assume no responsibility
cdis (1) for the use of the software and documentation; or (2) to provide
cdis technical support to users.
cdis
cdis Permission to use, copy, modify, and distribute this software is
cdis hereby granted, provided that the entire disclaimer notice appears
cdis in all copies. All modifications to this software must be clearly
cdis documented, and are solely the responsibility of the agent making
cdis the modifications. If significant modifications or enhancements
cdis are made to this software, the FSL Software Policy Manager
cdis (softwaremgr@fsl.noaa.gov) should be notified.
cdis
cdis
cdis
cdis
cdis
cdis
cdis
program diff_test
integer imax,jmax,kmax,nlvl
include 'lapsparms.cmn'
c
parameter (imax=125)
parameter (jmax=105)
c parameter (imax=NX_L_MAX)
c parameter (jmax=NY_L_MAX)
parameter (kmax=200)
parameter (nlvl=200)
INTEGER I4TIME, !I4time of data
1 KDIM, !K dimension of DATA array
1 LVL(nlvl), !Level of each field (4 digit max)
1 LVL_AVAIL(nlvl), !Level of each field (4 digit max)
1 FLAG,
1 ERROR(2),
1 INDX,
1 I,J,K,start,
1 ISTATUS
C
REAL DATA1(imax,jmax,kmax) !Raw data to be written
REAL DATA2(imax,jmax,kmax) !Raw data to be written
C
CHARACTER*200 DIR_in !Directory to be written to
CHARACTER*200 DIR_out !Directory to be written to
CHARACTER*31 EXT !File name ext (up to 31 chars)
CHARACTER*3 VAR(nlvl) !3 letter ID of each field
CHARACTER*3 LAPS_VAR_AVAIL(nlvl) !3 letter ID of each field
character*19 VAR_AVAIL(nlvl)
CHARACTER*4 LVL_COORD(nlvl) !Vertical coordinate for each field
CHARACTER*10 UNITS(nlvl) !units of each field
CHARACTER*125 COMMENT1(nlvl) !Comments for each field
CHARACTER*125 COMMENT2(nlvl) !Comments for each field
CHARACTER*9 GTIME
CHARACTER*91 FILE_NAME
CHARACTER*17 ASCTIME
CHARACTER*4 VERSION
CHARACTER*131 MODEL !Meteorological model in file
CHARACTER*131 ORIGIN !Location where file was created
CHARACTER*11 LAPS_DOM_FILE !Name of domain file e.g. NEST7GRID
LOGICAL l_packed_data
logical l_pass
character*20 filename
character*9 a9_time
character*3 var_last
var_last = ' '
idiff_msg_flag = 0
diff_max_all = 0.
diff_max_all_rel = 0.
n_files = 0
ndiff_all = 0
l_pass = .true.
write(6,*)' Enter 1 if comparing different machines, 0 if same'
read(5,*)machine_factor
write(6,*)' filename?'
5 read(5,1)filename
1 format(a)
if(filename(1:3) .eq. 'end')then
! write(6,*)' end'
goto 999
endif
read(5,1,err=999)dir_in
read(5,1,err=999)dir_out
if(filename(1:6) .eq. 'static')then
khmax = 4
var(1) = 'LAT'
var(2) = 'LON'
var(3) = 'AVG'
var(4) = 'LDF'
ext = 'nest7grid'
call rd_laps_static(dir_in,ext,imax,jmax,khmax,var,units
1 ,comment,data1,grid_spacing_m,istatus)
if(istatus .ne. 1)then
write(6,*)' Bad status reading 1st static file'
stop
endif
call rd_laps_static(dir_out,ext,imax,jmax,khmax,var,units
1 ,comment,data2,grid_spacing_m,istatus)
if(istatus .ne. 1)then
write(6,*)' Bad status reading 2nd static file'
stop
endif
thresh_write_pair = .01
thresh_count_diff = .01
ihmax = imax
jhmax = jmax
else
n1 = index(filename,'.')
n2 = index(filename,' ')
a9_time = filename(1:9)
ext = filename(n1+1:n2-1)
call downcase(ext,ext)
call cv_asc_i4time(a9_time,i4time)
if(dir_in(1:3) .eq. 'end')then
! write(6,*)' end'
goto 999
endif
do i = 1,nlvl
var(i) = ' '
enddo
call READ_LAPS_HEADER(I4TIME,DIR_IN,EXT,IHMAX,JHMAX,KHMAX,
1 LAPS_DOM_FILE,ASCTIME,VERSION,
1 MODEL,ORIGIN,VAR,LVL,NUM_VARIABLES,
1 VAR_AVAIL,LAPS_VAR_AVAIL,NUM_LEVELS,
1 LVL_AVAIL,LVL_COORD,UNITS,
1 COMMENT1,L_PACKED_DATA,ISTATUS)
! For this extension, set default values of:
! thresh_write_pair, thresh_count_diff, or num_diff_field_thresh
thresh_write_pair = 1e-05
thresh_count_diff = 0.
num_diff_field_thresh = 10
! For this particular extension, set values of:
! thresh_write_pair, thresh_count_diff, or num_diff_field_thresh
if(ext(1:3) .eq. 'lc3')then
do i = 1,42
var(i) = 'LC3'
lvl(i) = i
enddo
thresh_write_pair = .01
thresh_count_diff = .01
elseif(ext(1:3) .eq. 'lcp')then
thresh_write_pair = .01
thresh_count_diff = .01
elseif(ext(1:3) .eq. 'lcv')then
thresh_write_pair = .01
thresh_count_diff = .01
elseif(ext(1:3) .eq. 'lwc')then
thresh_write_pair = .01
thresh_count_diff = .01
elseif(ext(1:3) .eq. 'lw3')then
thresh_write_pair = .01
thresh_count_diff = .1
elseif(ext(1:3) .eq. 'lwm')then
thresh_write_pair = .01
thresh_count_diff = .1
elseif(ext(1:3) .eq. 'lps')then
thresh_write_pair = .01
thresh_count_diff = .1
elseif(ext(1:3) .eq. 'lvd')then
thresh_write_pair = 1.
thresh_count_diff = 1.
elseif(ext(1:3) .eq. 'vrc')then
thresh_write_pair = 0.1
thresh_count_diff = 0.1
elseif(ext(1:3) .eq. 'l1s')then
do i = 1,4
lvl(i) = 0
enddo
var(1) = 'R01'
var(2) = 'RTO'
var(3) = 'S01'
var(4) = 'STO'
thresh_write_pair = .0001
thresh_count_diff = .0001
elseif(ext(1:3) .eq. 'lps')then
do i = 1,21
lvl(i) = 1150 - 50 * i
enddo
elseif(ext(1:3) .eq. 'lsx')then
thresh_write_pair = .01
thresh_count_diff = .01
num_diff_field_thresh = imax * jmax
endif
! Adjust values for this extension (dependent on machine) of:
! thresh_count_diff and num_diff_field_thresh
if(machine_factor .eq. 0)then
thresh_count_diff = 0
num_diff_field_thresh = 0
endif
if(var(1) .eq. 'RH')var(1) = 'LHE'
write(6,*)' Reading: ',dir_in,a9_time,'.',ext(1:3)
call read_laps_data(i4time,dir_in,ext,ihmax,jhmax,khmax,
1 khmax,var,lvl,lvl_coord,units,comment1,data1,
1 istatus)
if(istatus .ne. 1)then
if(ext(1:3) .ne. 'lsx' .and. ext(1:3) .ne. 'liw')then
if(l_pass)then
write(6,*)' READ ERROR: OVERALL CRITERIA FAILURE'
l_pass = .false.
endif
endif
endif
write(6,*)' Reading: ',dir_out,a9_time,'.',ext(1:3)
call read_laps_data(i4time,dir_out,ext,ihmax,jhmax,khmax,
1 khmax,var,lvl,lvl_coord,units,comment2,data2,
1 istatus)
if(istatus .ne. 1)then
if(ext(1:3) .ne. 'lsx' .and. ext(1:3) .ne. 'liw')then
if(l_pass)then
write(6,*)' READ ERROR: OVERALL CRITERIA FAILURE'
l_pass = .false.
endif
endif
endif
endif ! static file
! write(6,*)' Hit RETURN to CONTINUE'
! read(5,*)
thresh_write_pair = thresh_write_pair * machine_factor
diff_max_file_rel = 0.
diff_max_file = 0.
diff_max_var = 0.
ndiff_file = 0
nvar = 1
n_levels = 0
do k = 1,khmax
! Test whether we should switch variables within this file
if(k .gt. 1)then
if(var(k) .ne. var(k-1))then
if(n_levels .gt. 1)then
write(6,*)' Max diff for variable ',var(k-1)(1:3)
1 ,' =',diff_max_var
write(6,*)
diff_max_var = 0.
nvar = nvar + 1
endif
n_levels = 0
endif
endif
! Test if new variable
if(var(k)(1:3) .ne. var_last)then
write(6,*)
write(6,*)' New var = ',var(k)(1:3)
! For this variable, set values of:
! thresh_write_pair, thresh_count_diff, or num_diff_field_thresh
if (ext(1:3) .eq. 'lvd')thresh_write_pair = 1.0
if (ext(1:3) .eq. 'lt1' .and. var(k)(1:2) .eq. 'HT')then
thresh_count_diff = 2.0 * machine_factor
elseif(ext(1:3) .eq. 'lt1' .and. var(k)(1:2) .eq. 'T3')then
thresh_count_diff = .01 * machine_factor
elseif(ext(1:3) .eq. 'lmt' .and. var(k)(1:3) .eq. 'LMT')then
thresh_count_diff = 2.0 * machine_factor
elseif(ext(1:3) .eq. 'lmt' .and. var(k)(1:3) .eq. 'LLR')then
thresh_count_diff = 2.0 * machine_factor
elseif(ext(1:3) .eq. 'lvd' .and. var(k)(1:3) .eq. 'SVN')then
thresh_count_diff = 10.0 * machine_factor
elseif(ext(1:3) .eq. 'lvd' .and. var(k)(1:3) .eq. 'ALB')then
thresh_count_diff = 0.1 * machine_factor
thresh_write_pair = 0.1 !JSmart addition 11-1-96
! elseif(ext(1:3) .eq. 'lw3' .and. var(k)(1:2) .ne. 'OM')then
! thresh_count_diff = .1 * machine_factor
endif
write(6,*)
1 ' Threshold to write (first ten) grid point pairs = '
1 ,thresh_write_pair
write(6,*)
1 ' Threshold to count lvl grid point differences = '
1 ,thresh_count_diff
write(6,*)
1 ' Max allowed count of lvl grid point differences = '
1 ,num_diff_field_thresh
write(6,*)
endif
n_levels = n_levels + 1
diff_max_field = 0.
diff_max_field_rel = 0.
abs_value_max = 0.
imaxd = 0
jmaxd = 0
iwrite = 0
ndiff = 0
inan = 0
ndiff_msg = 0
do i = 1,ihmax
do j = 1,jhmax
c if(
c! 1 data1(i,j,k) .le. r_min_normal() .or.
c 1 data1(i,j,k) .ge. r_max_normal() .or.
c! 1 data2(i,j,k) .le. r_min_normal() .or.
c 1 data2(i,j,k) .ge. r_max_normal()
c 1 )then
if(isnan(data1(i,j,k)).ne.0 .or. isnan(data2(i,j,k)).ne.0)
+ then
iwrite = iwrite + 1
if(iwrite .le. 10)then
write(6,21)i,j,k,' Nan'
endif
inan = inan + 1
else
diff = abs(data1(i,j,k)-data2(i,j,k))
! Test if one of the points is missing and the other isn't
if( (data1(i,j,k) .eq. r_missing_data .or.
1 data2(i,j,k) .eq. r_missing_data )
1 .AND.
1 diff .gt. 0. )then
ndiff_msg = ndiff_msg + 1
idiff_msg_flag = 1
else ! Both data points are non-missing
diff_max_file = max(diff_max_file,diff)
diff_max_var = max(diff_max_var,diff)
if(diff .gt. diff_max_field)then
diff_max_field = diff
imaxd = i
jmaxd = j
endif
endif
if(data1(i,j,k) .ne. r_missing_data)then
abs_value_max = max(abs_value_max,abs(data1(i,j,k)))
endif
if(data2(i,j,k) .ne. r_missing_data)then
abs_value_max = max(abs_value_max,abs(data2(i,j,k)))
endif
if(diff .gt. thresh_count_diff)then
ndiff = ndiff + 1
ndiff_file = ndiff_file + 1
ndiff_all = ndiff_all + 1
endif
if(diff .gt. thresh_write_pair)then
iwrite = iwrite + 1
if(iwrite .le. 10)then
write(6,21,err=22)i,j,k,data1(i,j,k),data2(i,j,k)
1 ,diff
21 format(1x,3i5,2f12.6,f12.6)
22 endif
endif
endif ! Nan test
enddo ! j
enddo ! i
if(comment1(k) .ne. comment2(k))then
write(6,*)comment1(k)(1:80)
write(6,*)comment2(k)(1:80)
endif
if(inan .gt. 0)write(6,*)' # of Nans = ',inan
if(abs_value_max .gt. 0.)then
! if(ndiff_msg .eq. 0)then
diff_max_field_rel = diff_max_field / abs_value_max
! endif
else
diff_max_field_rel = 0.
endif
diff_max_file_rel = max(diff_max_file_rel,diff_max_field_rel)
write(6,*)' df_mx - fld #',k,' ',var(k)
1 ,lvl(k),' abs/rel/#',diff_max_field,diff_max_field_rel
1 ,ndiff,imaxd,jmaxd
if(k .eq. khmax .and. nvar .gt. 1
1 .and. n_levels .gt. 1)then
write(6,*)
write(6,*)' Max diff for variable ',var(k)(1:3),' ='
1 ,diff_max_var
nvar = nvar + 1
endif
if(ndiff_msg .gt. 0)then
write(6,*)
write(6,*)' WARNING: # OF POINTS DIFFERING '
1 ,'WRT MISSING DATA = ',
1 ndiff_msg
endif
if(ndiff + ndiff_msg .gt. num_diff_field_thresh)then
if(l_pass)then
write(6,*)' OVERALL CRITERIA FAILURE'
1 ,ndiff,ndiff_msg,num_diff_field_thresh
l_pass = .false.
endif
endif
write(6,*)
var_last = var(k)(1:3)
enddo ! k
if (istatus .ne. 1) write (6,*)'Error in readlapsdata'
write(6,*)' OVERALL FILE diff_max (',ext(1:3)
1 ,') [abs/rel/#] = ',diff_max_file,diff_max_file_rel
1 ,ndiff_file
write(6,*)
n_files = n_files + 1
diff_max_all = max(diff_max_all,diff_max_file)
diff_max_all_rel = max(diff_max_all_rel,diff_max_file_rel)
c goto 5
999 continue
if(n_files .gt. 1)then
if(l_pass)then
write(6,*)' MAX difference (all files) [abs/rel/#] = '
1 ,diff_max_all,diff_max_all_rel
1 ,ndiff_all,' PASSED'
else
write(6,*)' MAX difference (all files) [abs/rel/#] = '
1 ,diff_max_all,diff_max_all_rel
1 ,ndiff_all,' FAILED'
endif
write(6,*)
else
if(l_pass)then
write(6,*)' PASSED'
write(6,*)
else
write(6,*)' FAILED'
write(6,*)
endif
endif
if(idiff_msg_flag .eq. 1)then
write(6,*)
write(6,*)' WARNING: DIFFERENCES WRT MISSING DATA DETECTED'
write(6,*)
endif
stop
end
| src/compare/compare.f |
! @@name: SIMD.5f
! @@type: F-free
! @@compilable: yes
! @@linkable: no
! @@expect: success
subroutine work( a, b, c, n )
implicit none
integer :: i,j,n
double precision :: a(n,n), b(n,n), c(n,n), tmp
!$omp do simd collapse(2) private(tmp)
do j = 1,n
do i = 1,n
tmp = a(i,j) + b(i,j)
c(i,j) = tmp
end do
end do
end subroutine work
| test/openmp_examples/sources/Example_SIMD.5f.f |
subroutine courant(iyd,tu,kp,lon,lat,Jsup)
implicit none
integer,parameter :: npt=10000
integer :: iyd,ndeg,mdeg,ierr
real*8 :: tu,lon,lat
real :: kp,Jsup
real*8 :: phicourant(npt),psi
real*8 :: latequi,Lmin,Lmax
save ierr
interface
subroutine val_fit(lon,lat,ndeg,mdeg,coef_psi,latmin,latmax,latequi,psi,psi_est,psi_nord)
Integer :: ndeg,mdeg
Real*8 :: latmin,latmax,latequi
Real*8 :: lon,lat,coef_psi(:)
Real*8 :: psi
Real*8, optional :: psi_est,psi_nord
end subroutine val_fit
end interface
call coef_cour(iyd,tu,kp,ndeg,mdeg,phicourant, &
Lmin,Lmax,latequi,ierr)
Lmin=0.d0
Lmax=0.d0
!call IMM_COUR(ndeg,mdeg,phicourant,Lmin,Lmax,latequi)
if (Lmin.lt.Lmax) then
ierr=0
else
ierr=1
endif
Jsup=0.
if (ierr.eq.0) then
call val_fit(lon,lat,ndeg,mdeg,phicourant,Lmin,Lmax,latequi,psi)
Jsup=psi
! dans le fichier initial le courant est en 10^-7 A/m2
Jsup=Jsup/10.
endif
return
end subroutine courant
| dir.source/dir.projection/courant.f90 |
! $UWHPSC/codes/fortran/arraypassing3.f90
program arraypassing3
implicit none
real(kind=8) :: x,y
integer :: i,j
x = 1.
y = 2.
i = 3
j = 4
call setvals(x)
print *, "x = ",x
print *, "y = ",y
print *, "i = ",i
print *, "j = ",j
contains
subroutine setvals(a)
! subroutine that sets values in an array a of length 3.
implicit none
real(kind=8), intent(inout) :: a(3)
integer i
do i = 1,3
a(i) = 5.
enddo
end subroutine setvals
end program arraypassing3
| uwhpsc/codes/fortran/arraypassing3.f90 |
subroutine dbeskg (x1, alpha, kode, n, y, nz,ierr)
c Author Serge Steer, Copyright INRIA, 2005
c extends dbesk for the case where alpha is negative
c x is supposed to be positive (besselk,with x<0 is complex)
double precision x1,alpha,y(n)
integer kode,n,nz,ierr
c
double precision inf,x,dlamch,a1,temp
inf=dlamch('o')*2.0d0
x=x1
ierr=0
if (x.ne.x.or.alpha.ne.alpha) then
c . NaN case
call dset(n,inf-inf,y,1)
ierr=4
elseif (x .eq. 0.0d0) then
call dset(n,-inf,y,1)
ierr=2
elseif (alpha.ge.0.0d0) then
call dbesk(x,alpha,kode,n,y,nz,ierr)
if (ierr.eq.2) call dset(n,inf,y,1)
else
if(alpha-1.0d0+n.ge.0.0d0) then
c . 0 is between alpha and alpha+n
nn=int(-alpha)+1
else
nn=n
endif
a1=-(alpha-1.0d0+nn)
call dbesk(x,a1,kode,nn,y,nz,ierr)
if (ierr.eq.2) call dset(nn,inf,y,1)
c . swap the result to have it in correct order
if (nn.ge.2) then
do i=1,nn/2
temp=y(i)
y(i)=y(nn+1-i)
y(nn+1-i)=temp
enddo
endif
if (n.gt.nn) then
call dbesk(x,1.0d0-a1,kode,n-nn,y(nn+1),nz,ier)
if (ier.eq.2) call dset(n-nn,inf,y(nn+1),1)
ierr=max(ierr,ier)
endif
endif
end
subroutine dbeskv (x,nx,alpha,na, kode,y,w,ierr)
c Author Serge Steer, Copyright INRIA, 2005
c compute besseli function for x and alpha given by vectors
c w : working array of size 2*na (used only if nz>0 and alpha contains negative
C values
double precision x(nx),alpha(na),y(*),w(*)
integer kode,nx,na,ier
double precision e,dlamch,eps
eps=dlamch('p')
ierr=0
if (na.lt.0) then
c . element wise case x and alpha are supposed to have the same size
do i=1,nx
call dbeskg (abs(x(i)), alpha(i),kode,1,y(i), nz,ier)
ierr=max(ierr,ier)
enddo
elseif (na.eq.1) then
do i=1,nx
call dbeskg (abs(x(i)), alpha(1),kode,1,y(i), nz,ier)
ierr=max(ierr,ier)
enddo
else
c . compute besseli(x(i),y(j)), i=1,nx,j=1,na
j0=1
05 n=0
10 n=n+1
j=j0+n
if (j.le.na.and.abs((1+alpha(j-1))-alpha(j)).le.eps) then
goto 10
endif
do i=1,nx
call dbeskg(abs(x(i)),alpha(j0),kode,n, w, nz,ier)
ierr=max(ierr,ier)
call dcopy(n,w,1,y(i+(j0-1)*nx),nx)
enddo
j0=j
if (j0.le.na) goto 05
endif
end
| src/math/calelm/dbeskg.f |
! -*- Mode: Fortran90; -*-
!-----------------------------------------------------------------
! Daniel R. Reynolds
! SMU, Mathematics
! Math 6370
! 7 January 2009
!=================================================================
program MatVec
!-----------------------------------------------------------------
! Description:
! Computes the product of an m*n matrix and an n-vector.
!-----------------------------------------------------------------
!======= Inclusions ===========
!======= Declarations =========
implicit none
integer :: m, n, i, j
double precision, allocatable :: A(:,:), x(:), b(:)
double precision :: norm2, stime, ftime
!======= Internals ============
! input the size of the system
write(*,*) 'We will multiply an m*n matrix by an n-vector'
write(*,*) ' enter m'
read(*,*) m
write(*,*) ' enter n'
read(*,*) n
if ((m < 1) .or. (n < 1)) then
write(*,*) ' illegal input, m =',m,' and n =',n,&
' must both be >= 1'
stop
endif
! initialize the matrix and vectors
allocate(A(m,n),x(n),b(m))
do j=1,n
do i=1,m
A(i,j) = 1.d0/(1.d0 + (i - j)**2)
enddo
x(j) = 1.d0
enddo
! start timer
call get_time(stime)
! compute matrix-vector product (row-based version)
b = 0.d0
do i=1,m
do j=1,n
b(i) = b(i) + A(i,j)*x(j)
enddo
enddo
! stop timer
call get_time(ftime)
! output 2-norm of product and runtime to screen
norm2 = 0.d0
do i=1,m,1
norm2 = norm2 + b(i)**2
enddo
write(*,*) ' matrix size =',m,' x ',n
write(*,*) ' 2-norm of product =',sqrt(norm2)
write(*,*) ' runtime =',ftime-stime
! output product to file
open(101,file='b.txt',form='formatted')
do i=1,m,1
write(101,'(es22.15)') b(i)
enddo
close(101)
! free vectors
deallocate(A,x,b)
end program MatVec
!=================================================================
| matvec/matvec_row.f90 |
! { dg-do compile }
! Tests the fix for 20871, in which elemental non-intrinsic procedures were
! permitted to be dummy arguments.
!
! Contributed by Joost VandeVondele <jv244@cam.ac.uk>
!
MODULE TT
CONTAINS
ELEMENTAL INTEGER FUNCTION two(N)
INTEGER, INTENT(IN) :: N
two=2**N
END FUNCTION
END MODULE
USE TT
INTEGER, EXTERNAL :: SUB
write(6,*) SUB(two) ! { dg-error "not allowed as an actual argument " }
END
INTEGER FUNCTION SUB(XX)
INTEGER :: XX
SUB=XX()
END
! { dg-final { cleanup-modules "TT" } }
| tests/CompileTests/Fortran_tests/gfortranTestSuite/gfortran.dg/elemental_non_intrinsic_dummy_1.f90 |
!
!*** $Revision: 1.3.2.4 $
!*** $Date: 2007/03/22 20:40:24 $
!***
!*** Copyright 1985-2007 Intel Corporation. All Rights Reserved.
!***
!*** The source code contained or described herein and all documents related
!*** to the source code ("Material") are owned by Intel Corporation or its
!*** suppliers or licensors. Title to the Material remains with Intel
!*** Corporation or its suppliers and licensors. The Material is protected
!*** by worldwide copyright laws and treaty provisions. No part of the
!*** Material may be used, copied, reproduced, modified, published, uploaded,
!*** posted, transmitted, distributed, or disclosed in any way without
!*** Intel's prior express written permission.
!***
!*** No license under any patent, copyright, trade secret or other
!*** intellectual property right is granted to or conferred upon you by
!*** disclosure or delivery of the Materials, either expressly, by
!*** implication, inducement, estoppel or otherwise. Any license under such
!*** intellectual property rights must be express and approved by Intel in
!*** writing.
!***
!*** Portions of this software are protected under the following patents:
!*** U.S. Patent 5,812,852
!*** U.S. Patent 6,792,599
!***
!***
!*** Some of the directives for the following routine extend past column 72,
!*** so process this file in 132-column mode.
!***
!dec$ fixedformlinesize:132
module omp_lib_kinds
integer omp_integer_kind
integer omp_logical_kind
integer omp_real_kind
integer omp_lock_kind
integer omp_nest_lock_kind
integer openmp_version
integer kmp_pointer_kind
integer kmp_size_t_kind
parameter (omp_integer_kind = 4)
parameter (omp_logical_kind = 4)
parameter (omp_real_kind = 4)
parameter (omp_lock_kind = int_ptr_kind())
parameter (omp_nest_lock_kind = int_ptr_kind())
parameter (openmp_version = 200505)
parameter (kmp_pointer_kind = int_ptr_kind())
parameter (kmp_size_t_kind = int_ptr_kind())
end module omp_lib_kinds
module omp_lib
use omp_lib_kinds
!***
!*** omp_* entry points
!***
interface
subroutine omp_set_num_threads(nthreads)
use omp_lib_kinds
integer (kind=omp_integer_kind) nthreads
end subroutine omp_set_num_threads
end interface
interface
subroutine omp_set_dynamic(enable)
use omp_lib_kinds
logical (kind=omp_logical_kind) enable
end subroutine omp_set_dynamic
end interface
interface
subroutine omp_set_nested(enable)
use omp_lib_kinds
logical (kind=omp_logical_kind) enable
end subroutine omp_set_nested
end interface
interface
function omp_get_num_threads()
use omp_lib_kinds
integer (kind=omp_integer_kind) omp_get_num_threads
end function omp_get_num_threads
end interface
interface
function omp_get_max_threads()
use omp_lib_kinds
integer (kind=omp_integer_kind) omp_get_max_threads
end function omp_get_max_threads
end interface
interface
function omp_get_thread_num()
use omp_lib_kinds
integer (kind=omp_integer_kind) omp_get_thread_num
end function omp_get_thread_num
end interface
interface
function omp_get_num_procs()
use omp_lib_kinds
integer (kind=omp_integer_kind) omp_get_num_procs
end function omp_get_num_procs
end interface
interface
function omp_in_parallel()
use omp_lib_kinds
logical (kind=omp_logical_kind) omp_in_parallel
end function omp_in_parallel
end interface
interface
function omp_get_dynamic()
use omp_lib_kinds
logical (kind=omp_logical_kind) omp_get_dynamic
end function omp_get_dynamic
end interface
interface
function omp_get_nested()
use omp_lib_kinds
logical (kind=omp_logical_kind) omp_get_nested
end function omp_get_nested
end interface
interface
function omp_get_wtime()
use omp_lib_kinds
double precision omp_get_wtime
end function omp_get_wtime
end interface
interface
function omp_get_wtick ()
use omp_lib_kinds
double precision omp_get_wtick
end function omp_get_wtick
end interface
interface
subroutine omp_init_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_lock_kind) lockvar
end subroutine omp_init_lock
end interface
interface
subroutine omp_destroy_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_lock_kind) lockvar
end subroutine omp_destroy_lock
end interface
interface
subroutine omp_set_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_lock_kind) lockvar
end subroutine omp_set_lock
end interface
interface
subroutine omp_unset_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_lock_kind) lockvar
end subroutine omp_unset_lock
end interface
interface
function omp_test_lock(lockvar)
use omp_lib_kinds
logical (kind=omp_logical_kind) omp_test_lock
integer (kind=omp_lock_kind) lockvar
end function omp_test_lock
end interface
interface
subroutine omp_init_nest_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) lockvar
end subroutine omp_init_nest_lock
end interface
interface
subroutine omp_destroy_nest_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) lockvar
end subroutine omp_destroy_nest_lock
end interface
interface
subroutine omp_set_nest_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) lockvar
end subroutine omp_set_nest_lock
end interface
interface
subroutine omp_unset_nest_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) lockvar
end subroutine omp_unset_nest_lock
end interface
interface
function omp_test_nest_lock(lockvar)
use omp_lib_kinds
integer (kind=omp_integer_kind) omp_test_nest_lock
integer (kind=omp_nest_lock_kind) lockvar
end function omp_test_nest_lock
end interface
!***
!*** kmp_* entry points
!***
interface
subroutine kmp_set_parallel_name(name)
use omp_lib_kinds
character*(*) name
end subroutine kmp_set_parallel_name
end interface
interface
subroutine kmp_set_stacksize(size)
use omp_lib_kinds
integer (kind=omp_integer_kind) size
end subroutine kmp_set_stacksize
end interface
interface
subroutine kmp_set_stacksize_s(size)
use omp_lib_kinds
integer (kind=kmp_size_t_kind) size
end subroutine kmp_set_stacksize_s
end interface
interface
subroutine kmp_set_blocktime(msec)
use omp_lib_kinds
integer (kind=omp_integer_kind) msec
end subroutine kmp_set_blocktime
end interface
interface
subroutine kmp_set_library_serial()
use omp_lib_kinds
end subroutine kmp_set_library_serial
end interface
interface
subroutine kmp_set_library_turnaround()
use omp_lib_kinds
end subroutine kmp_set_library_turnaround
end interface
interface
subroutine kmp_set_library_throughput()
use omp_lib_kinds
end subroutine kmp_set_library_throughput
end interface
interface
subroutine kmp_set_library(libnum)
use omp_lib_kinds
integer (kind=omp_integer_kind) libnum
end subroutine kmp_set_library
end interface
interface
subroutine kmp_set_stats(enable)
use omp_lib_kinds
logical (kind=omp_logical_kind) enable
end subroutine kmp_set_stats
end interface
interface
function kmp_get_stacksize()
use omp_lib_kinds
integer (kind=omp_integer_kind) kmp_get_stacksize
end function kmp_get_stacksize
end interface
interface
function kmp_get_stacksize_s()
use omp_lib_kinds
integer (kind=kmp_size_t_kind) kmp_get_stacksize_s
end function kmp_get_stacksize_s
end interface
interface
function kmp_get_blocktime()
use omp_lib_kinds
integer (kind=omp_integer_kind) kmp_get_blocktime
end function kmp_get_blocktime
end interface
interface
function kmp_get_library()
use omp_lib_kinds
integer (kind=omp_integer_kind) kmp_get_library
end function kmp_get_library
end interface
interface
function kmp_malloc(size)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) kmp_malloc
integer (kind=kmp_size_t_kind) size
end function kmp_malloc
end interface
interface
function kmp_calloc(nelem, elsize)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) kmp_calloc
integer (kind=kmp_size_t_kind) nelem
integer (kind=kmp_size_t_kind) elsize
end function kmp_calloc
end interface
interface
function kmp_realloc(ptr, size)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) kmp_realloc
integer (kind=kmp_pointer_kind) ptr
integer (kind=kmp_size_t_kind) size
end function kmp_realloc
end interface
interface
subroutine kmp_free(ptr)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) ptr
end subroutine kmp_free
end interface
!***
!*** kmp_* entry points for Cluster OpenMP
!***
interface
function kmp_sharable_malloc(size)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) kmp_sharable_malloc
integer (kind=kmp_size_t_kind) size
end function kmp_sharable_malloc
end interface
interface
function kmp_aligned_sharable_malloc(size)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) kmp_aligned_sharable_malloc
integer (kind=kmp_size_t_kind) size
end function kmp_aligned_sharable_malloc
end interface
interface
function kmp_sharable_calloc(nelem, elsize)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) kmp_sharable_calloc
integer (kind=kmp_size_t_kind) nelem
integer (kind=kmp_size_t_kind) elsize
end function kmp_sharable_calloc
end interface
interface
function kmp_sharable_realloc(ptr, size)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) kmp_sharable_realloc
integer (kind=kmp_pointer_kind) ptr
integer (kind=kmp_size_t_kind) size
end function kmp_sharable_realloc
end interface
interface
subroutine kmp_sharable_free(ptr)
use omp_lib_kinds
integer (kind=kmp_pointer_kind) ptr
end subroutine kmp_sharable_free
end interface
interface
subroutine kmp_lock_cond_wait(lockvar)
use omp_lib_kinds
integer (kind=omp_lock_kind) lockvar
end subroutine kmp_lock_cond_wait
end interface
interface
subroutine kmp_lock_cond_signal(lockvar)
use omp_lib_kinds
integer (kind=omp_lock_kind) lockvar
end subroutine kmp_lock_cond_signal
end interface
interface
subroutine kmp_lock_cond_broadcast(lockvar)
use omp_lib_kinds
integer (kind=omp_lock_kind) lockvar
end subroutine kmp_lock_cond_broadcast
end interface
interface
subroutine kmp_nest_lock_cond_wait(lockvar)
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) lockvar
end subroutine kmp_nest_lock_cond_wait
end interface
interface
subroutine kmp_nest_lock_cond_signal(lockvar)
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) lockvar
end subroutine kmp_nest_lock_cond_signal
end interface
interface
subroutine kmp_nest_lock_cond_broadcast(lockvar)
use omp_lib_kinds
integer (kind=omp_nest_lock_kind) lockvar
end subroutine kmp_nest_lock_cond_broadcast
end interface
interface
function kmp_get_num_processes()
use omp_lib_kinds
integer (kind=omp_integer_kind) kmp_get_num_processes
end function kmp_get_num_processes
end interface
interface
function kmp_get_process_num()
use omp_lib_kinds
integer (kind=omp_integer_kind) kmp_get_process_num
end function kmp_get_process_num
end interface
interface
function kmp_get_process_thread_num()
use omp_lib_kinds
integer (kind=omp_integer_kind) kmp_get_process_thread_num
end function kmp_get_process_thread_num
end interface
interface
subroutine kmp_set_warnings_on()
use omp_lib_kinds
end subroutine kmp_set_warnings_on
end interface
interface
subroutine kmp_set_warnings_off()
use omp_lib_kinds
end subroutine kmp_set_warnings_off
end interface
interface
function kmp_is_sharable(ptr)
use omp_lib_kinds
logical (kind=omp_logical_kind) kmp_is_sharable
integer (kind=kmp_pointer_kind) ptr
end function kmp_is_sharable
end interface
interface
subroutine kmp_deferred_atomic_add_i4(addr, val)
integer(kind=4) addr
integer(kind=4) val
end subroutine kmp_deferred_atomic_add_i4
end interface
interface
subroutine kmp_deferred_atomic_add_i8(addr, val)
integer(kind=8) addr
integer(kind=8) val
end subroutine kmp_deferred_atomic_add_i8
end interface
interface
subroutine kmp_deferred_atomic_add_r4(addr, val)
real(kind=4) addr
real(kind=4) val
end subroutine kmp_deferred_atomic_add_r4
end interface
interface
subroutine kmp_deferred_atomic_add_r8(addr, val)
real(kind=8) addr
real(kind=8) val
end subroutine kmp_deferred_atomic_add_r8
end interface
!dec$ if defined(_WIN32)
!dec$ if defined(_WIN64) .or. defined(_M_IA64) .or. defined(_M_AMD64)
!***
!*** The Fortran entry points must be in uppercase, even if the /Qlowercase
!*** option is specified. The alias attribute ensures that the specified
!*** string is used as the entry point.
!***
!*** On the Windows IA-32 architecture, the Fortran entry points have an
!*** underscore prepended. On the Windows Intel(R) 64 and Intel(R) Itanium(R)
!*** architectures, no underscore is prepended.
!***
!dec$ attributes alias:'OMP_SET_NUM_THREADS' :: omp_set_num_threads
!dec$ attributes alias:'OMP_SET_DYNAMIC' :: omp_set_dynamic
!dec$ attributes alias:'OMP_SET_NESTED' :: omp_set_nested
!dec$ attributes alias:'OMP_GET_NUM_THREADS' :: omp_get_num_threads
!dec$ attributes alias:'OMP_GET_MAX_THREADS' :: omp_get_max_threads
!dec$ attributes alias:'OMP_GET_THREAD_NUM' :: omp_get_thread_num
!dec$ attributes alias:'OMP_GET_NUM_PROCS' :: omp_get_num_procs
!dec$ attributes alias:'OMP_IN_PARALLEL' :: omp_in_parallel
!dec$ attributes alias:'OMP_GET_DYNAMIC' :: omp_get_dynamic
!dec$ attributes alias:'OMP_GET_NESTED' :: omp_get_nested
!dec$ attributes alias:'OMP_GET_WTIME' :: omp_get_wtime
!dec$ attributes alias:'OMP_GET_WTICK' :: omp_get_wtick
!dec$ attributes alias:'omp_init_lock' :: omp_init_lock
!dec$ attributes alias:'omp_destroy_lock' :: omp_destroy_lock
!dec$ attributes alias:'omp_set_lock' :: omp_set_lock
!dec$ attributes alias:'omp_unset_lock' :: omp_unset_lock
!dec$ attributes alias:'omp_test_lock' :: omp_test_lock
!dec$ attributes alias:'omp_init_nest_lock' :: omp_init_nest_lock
!dec$ attributes alias:'omp_destroy_nest_lock' :: omp_destroy_nest_lock
!dec$ attributes alias:'omp_set_nest_lock' :: omp_set_nest_lock
!dec$ attributes alias:'omp_unset_nest_lock' :: omp_unset_nest_lock
!dec$ attributes alias:'omp_test_nest_lock' :: omp_test_nest_lock
!dec$ attributes alias:'KMP_SET_PARALLEL_NAME'::kmp_set_parallel_name
!dec$ attributes alias:'KMP_SET_STACKSIZE'::kmp_set_stacksize
!dec$ attributes alias:'KMP_SET_STACKSIZE_S'::kmp_set_stacksize_s
!dec$ attributes alias:'KMP_SET_BLOCKTIME'::kmp_set_blocktime
!dec$ attributes alias:'KMP_SET_LIBRARY_SERIAL'::kmp_set_library_serial
!dec$ attributes alias:'KMP_SET_LIBRARY_TURNAROUND'::kmp_set_library_turnaround
!dec$ attributes alias:'KMP_SET_LIBRARY_THROUGHPUT'::kmp_set_library_throughput
!dec$ attributes alias:'KMP_SET_LIBRARY'::kmp_set_library
!dec$ attributes alias:'KMP_SET_STATS'::kmp_set_stats
!dec$ attributes alias:'KMP_GET_STACKSIZE'::kmp_get_stacksize
!dec$ attributes alias:'KMP_GET_STACKSIZE_S'::kmp_get_stacksize_s
!dec$ attributes alias:'KMP_GET_BLOCKTIME'::kmp_get_blocktime
!dec$ attributes alias:'KMP_GET_LIBRARY'::kmp_get_library
!dec$ attributes alias:'KMP_MALLOC'::kmp_malloc
!dec$ attributes alias:'KMP_CALLOC'::kmp_calloc
!dec$ attributes alias:'KMP_REALLOC'::kmp_realloc
!dec$ attributes alias:'KMP_FREE'::kmp_free
!dec$ attributes alias:'KMP_SHARABLE_MALLOC'::kmp_sharable_malloc
!dec$ attributes alias:'KMP_ALIGNED_SHARABLE_MALLOC'::kmp_aligned_sharable_malloc
!dec$ attributes alias:'KMP_SHARABLE_CALLOC'::kmp_sharable_calloc
!dec$ attributes alias:'KMP_SHARABLE_REALLOC'::kmp_sharable_realloc
!dec$ attributes alias:'KMP_SHARABLE_FREE'::kmp_sharable_free
!dec$ attributes alias:'KMP_LOCK_COND_WAIT'::kmp_lock_cond_wait
!dec$ attributes alias:'KMP_LOCK_COND_SIGNAL'::kmp_lock_cond_signal
!dec$ attributes alias:'KMP_LOCK_COND_BROADCAST'::kmp_lock_cond_broadcast
!dec$ attributes alias:'KMP_NEST_LOCK_COND_WAIT'::kmp_nest_lock_cond_wait
!dec$ attributes alias:'KMP_NEST_LOCK_COND_SIGNAL'::kmp_nest_lock_cond_signal
!dec$ attributes alias:'KMP_NEST_LOCK_COND_BROADCAST'::kmp_nest_lock_cond_broadcast
!dec$ attributes alias:'KMP_GET_NUM_PROCESSES'::kmp_get_num_processes
!dec$ attributes alias:'KMP_GET_PROCESS_NUM'::kmp_get_process_num
!dec$ attributes alias:'KMP_GET_PROCESS_THREAD_NUM'::kmp_get_process_thread_num
!dec$ attributes alias:'KMP_SET_WARNINGS_ON'::kmp_set_warnings_on
!dec$ attributes alias:'KMP_SET_WARNINGS_OFF'::kmp_set_warnings_off
!dec$ attributes alias:'KMP_IS_SHARABLE'::kmp_is_sharable
!dec$ attributes alias:'KMP_DEFERRED_ATOMIC_ADD_I4'::kmp_deferred_atomic_add_i4
!dec$ attributes alias:'KMP_DEFERRED_ATOMIC_ADD_I8'::kmp_deferred_atomic_add_i8
!dec$ attributes alias:'KMP_DEFERRED_ATOMIC_ADD_R4'::kmp_deferred_atomic_add_r4
!dec$ attributes alias:'KMP_DEFERRED_ATOMIC_ADD_R8'::kmp_deferred_atomic_add_r8
!dec$ else
!***
!*** On Windows IA32, the Fortran entry points have an underscore prepended.
!***
!dec$ attributes alias:'_OMP_SET_NUM_THREADS' :: omp_set_num_threads
!dec$ attributes alias:'_OMP_SET_DYNAMIC' :: omp_set_dynamic
!dec$ attributes alias:'_OMP_SET_NESTED' :: omp_set_nested
!dec$ attributes alias:'_OMP_GET_NUM_THREADS' :: omp_get_num_threads
!dec$ attributes alias:'_OMP_GET_MAX_THREADS' :: omp_get_max_threads
!dec$ attributes alias:'_OMP_GET_THREAD_NUM' :: omp_get_thread_num
!dec$ attributes alias:'_OMP_GET_NUM_PROCS' :: omp_get_num_procs
!dec$ attributes alias:'_OMP_IN_PARALLEL' :: omp_in_parallel
!dec$ attributes alias:'_OMP_GET_DYNAMIC' :: omp_get_dynamic
!dec$ attributes alias:'_OMP_GET_NESTED' :: omp_get_nested
!dec$ attributes alias:'_OMP_GET_WTIME' :: omp_get_wtime
!dec$ attributes alias:'_OMP_GET_WTICK' :: omp_get_wtick
!dec$ attributes alias:'_omp_init_lock' :: omp_init_lock
!dec$ attributes alias:'_omp_destroy_lock' :: omp_destroy_lock
!dec$ attributes alias:'_omp_set_lock' :: omp_set_lock
!dec$ attributes alias:'_omp_unset_lock' :: omp_unset_lock
!dec$ attributes alias:'_omp_test_lock' :: omp_test_lock
!dec$ attributes alias:'_omp_init_nest_lock' :: omp_init_nest_lock
!dec$ attributes alias:'_omp_destroy_nest_lock' :: omp_destroy_nest_lock
!dec$ attributes alias:'_omp_set_nest_lock' :: omp_set_nest_lock
!dec$ attributes alias:'_omp_unset_nest_lock' :: omp_unset_nest_lock
!dec$ attributes alias:'_omp_test_nest_lock' :: omp_test_nest_lock
!dec$ attributes alias:'_KMP_SET_PARALLEL_NAME'::kmp_set_parallel_name
!dec$ attributes alias:'_KMP_SET_STACKSIZE'::kmp_set_stacksize
!dec$ attributes alias:'_KMP_SET_STACKSIZE_S'::kmp_set_stacksize_s
!dec$ attributes alias:'_KMP_SET_BLOCKTIME'::kmp_set_blocktime
!dec$ attributes alias:'_KMP_SET_LIBRARY_SERIAL'::kmp_set_library_serial
!dec$ attributes alias:'_KMP_SET_LIBRARY_TURNAROUND'::kmp_set_library_turnaround
!dec$ attributes alias:'_KMP_SET_LIBRARY_THROUGHPUT'::kmp_set_library_throughput
!dec$ attributes alias:'_KMP_SET_LIBRARY'::kmp_set_library
!dec$ attributes alias:'_KMP_SET_STATS'::kmp_set_stats
!dec$ attributes alias:'_KMP_GET_STACKSIZE'::kmp_get_stacksize
!dec$ attributes alias:'_KMP_GET_STACKSIZE_S'::kmp_get_stacksize_s
!dec$ attributes alias:'_KMP_GET_BLOCKTIME'::kmp_get_blocktime
!dec$ attributes alias:'_KMP_GET_LIBRARY'::kmp_get_library
!dec$ attributes alias:'_KMP_MALLOC'::kmp_malloc
!dec$ attributes alias:'_KMP_CALLOC'::kmp_calloc
!dec$ attributes alias:'_KMP_REALLOC'::kmp_realloc
!dec$ attributes alias:'_KMP_FREE'::kmp_free
!dec$ attributes alias:'_KMP_SHARABLE_MALLOC'::kmp_sharable_malloc
!dec$ attributes alias:'_KMP_ALIGNED_SHARABLE_MALLOC'::kmp_aligned_sharable_malloc
!dec$ attributes alias:'_KMP_SHARABLE_CALLOC'::kmp_sharable_calloc
!dec$ attributes alias:'_KMP_SHARABLE_REALLOC'::kmp_sharable_realloc
!dec$ attributes alias:'_KMP_SHARABLE_FREE'::kmp_sharable_free
!dec$ attributes alias:'_KMP_LOCK_COND_WAIT'::kmp_lock_cond_wait
!dec$ attributes alias:'_KMP_LOCK_COND_SIGNAL'::kmp_lock_cond_signal
!dec$ attributes alias:'_KMP_LOCK_COND_BROADCAST'::kmp_lock_cond_broadcast
!dec$ attributes alias:'_KMP_NEST_LOCK_COND_WAIT'::kmp_nest_lock_cond_wait
!dec$ attributes alias:'_KMP_NEST_LOCK_COND_SIGNAL'::kmp_nest_lock_cond_signal
!dec$ attributes alias:'_KMP_NEST_LOCK_COND_BROADCAST'::kmp_nest_lock_cond_broadcast
!dec$ attributes alias:'_KMP_GET_NUM_PROCESSES'::kmp_get_num_processes
!dec$ attributes alias:'_KMP_GET_PROCESS_NUM'::kmp_get_process_num
!dec$ attributes alias:'_KMP_GET_PROCESS_THREAD_NUM'::kmp_get_process_thread_num
!dec$ attributes alias:'_KMP_SET_WARNINGS_ON'::kmp_set_warnings_on
!dec$ attributes alias:'_KMP_SET_WARNINGS_OFF'::kmp_set_warnings_off
!dec$ attributes alias:'_KMP_IS_SHARABLE'::kmp_is_sharable
!dec$ attributes alias:'_KMP_DEFERRED_ATOMIC_ADD_I4'::kmp_deferred_atomic_add_i4
!dec$ attributes alias:'_KMP_DEFERRED_ATOMIC_ADD_I8'::kmp_deferred_atomic_add_i8
!dec$ attributes alias:'_KMP_DEFERRED_ATOMIC_ADD_R4'::kmp_deferred_atomic_add_r4
!dec$ attributes alias:'_KMP_DEFERRED_ATOMIC_ADD_R8'::kmp_deferred_atomic_add_r8
!dec$ endif
!dec$ endif
!dec$ if defined(__linux)
!***
!*** The Linux entry points are in lowercase, with an underscore appended.
!***
!dec$ attributes alias:'omp_set_num_threads_'::omp_set_num_threads
!dec$ attributes alias:'omp_set_dynamic_'::omp_set_dynamic
!dec$ attributes alias:'omp_set_nested_'::omp_set_nested
!dec$ attributes alias:'omp_get_num_threads_'::omp_get_num_threads
!dec$ attributes alias:'omp_get_max_threads_'::omp_get_max_threads
!dec$ attributes alias:'omp_get_thread_num_'::omp_get_thread_num
!dec$ attributes alias:'omp_get_num_procs_'::omp_get_num_procs
!dec$ attributes alias:'omp_in_parallel_'::omp_in_parallel
!dec$ attributes alias:'omp_get_dynamic_'::omp_get_dynamic
!dec$ attributes alias:'omp_get_nested_'::omp_get_nested
!dec$ attributes alias:'omp_get_wtime_'::omp_get_wtime
!dec$ attributes alias:'omp_get_wtick_'::omp_get_wtick
!dec$ attributes alias:'omp_init_lock_'::omp_init_lock
!dec$ attributes alias:'omp_destroy_lock_'::omp_destroy_lock
!dec$ attributes alias:'omp_set_lock_'::omp_set_lock
!dec$ attributes alias:'omp_unset_lock_'::omp_unset_lock
!dec$ attributes alias:'omp_test_lock_'::omp_test_lock
!dec$ attributes alias:'omp_init_nest_lock_'::omp_init_nest_lock
!dec$ attributes alias:'omp_destroy_nest_lock_'::omp_destroy_nest_lock
!dec$ attributes alias:'omp_set_nest_lock_'::omp_set_nest_lock
!dec$ attributes alias:'omp_unset_nest_lock_'::omp_unset_nest_lock
!dec$ attributes alias:'omp_test_nest_lock_'::omp_test_nest_lock
!dec$ attributes alias:'kmp_set_parallel_name_'::kmp_set_parallel_name
!dec$ attributes alias:'kmp_set_stacksize_'::kmp_set_stacksize
!dec$ attributes alias:'kmp_set_stacksize_s_'::kmp_set_stacksize_s
!dec$ attributes alias:'kmp_set_blocktime_'::kmp_set_blocktime
!dec$ attributes alias:'kmp_set_library_serial_'::kmp_set_library_serial
!dec$ attributes alias:'kmp_set_library_turnaround_'::kmp_set_library_turnaround
!dec$ attributes alias:'kmp_set_library_throughput_'::kmp_set_library_throughput
!dec$ attributes alias:'kmp_set_library_'::kmp_set_library
!dec$ attributes alias:'kmp_set_stats_'::kmp_set_stats
!dec$ attributes alias:'kmp_get_stacksize_'::kmp_get_stacksize
!dec$ attributes alias:'kmp_get_stacksize_s_'::kmp_get_stacksize_s
!dec$ attributes alias:'kmp_get_blocktime_'::kmp_get_blocktime
!dec$ attributes alias:'kmp_get_library_'::kmp_get_library
!dec$ attributes alias:'kmp_malloc_'::kmp_malloc
!dec$ attributes alias:'kmp_calloc_'::kmp_calloc
!dec$ attributes alias:'kmp_realloc_'::kmp_realloc
!dec$ attributes alias:'kmp_free_'::kmp_free
!dec$ attributes alias:'kmp_sharable_malloc_'::kmp_sharable_malloc
!dec$ attributes alias:'kmp_aligned_sharable_malloc_'::kmp_aligned_sharable_malloc
!dec$ attributes alias:'kmp_sharable_calloc_'::kmp_sharable_calloc
!dec$ attributes alias:'kmp_sharable_realloc_'::kmp_sharable_realloc
!dec$ attributes alias:'kmp_sharable_free_'::kmp_sharable_free
!dec$ attributes alias:'kmp_lock_cond_wait_'::kmp_lock_cond_wait
!dec$ attributes alias:'kmp_lock_cond_signal_'::kmp_lock_cond_signal
!dec$ attributes alias:'kmp_lock_cond_broadcast_'::kmp_lock_cond_broadcast
!dec$ attributes alias:'kmp_nest_lock_cond_wait_'::kmp_nest_lock_cond_wait
!dec$ attributes alias:'kmp_nest_lock_cond_signal_'::kmp_nest_lock_cond_signal
!dec$ attributes alias:'kmp_nest_lock_cond_broadcast_'::kmp_nest_lock_cond_broadcast
!dec$ attributes alias:'kmp_get_num_processes_'::kmp_get_num_processes
!dec$ attributes alias:'kmp_get_process_num_'::kmp_get_process_num
!dec$ attributes alias:'kmp_get_process_thread_num_'::kmp_get_process_thread_num
!dec$ attributes alias:'kmp_set_warnings_on_'::kmp_set_warnings_on
!dec$ attributes alias:'kmp_set_warnings_off_'::kmp_set_warnings_off
!dec$ attributes alias:'kmp_is_sharable_'::kmp_is_sharable
!dec$ attributes alias:'kmp_deferred_atomic_add_i4_'::kmp_deferred_atomic_add_i4
!dec$ attributes alias:'kmp_deferred_atomic_add_i8_'::kmp_deferred_atomic_add_i8
!dec$ attributes alias:'kmp_deferred_atomic_add_r4_'::kmp_deferred_atomic_add_r4
!dec$ attributes alias:'kmp_deferred_atomic_add_r8_'::kmp_deferred_atomic_add_r8
!dec$ endif
!dec$ if defined(__APPLE__)
!***
!*** The Mac entry points are in lowercase, with an both an underscore
!*** appended and an underscore prepended.
!***
!dec$ attributes alias:'_omp_set_num_threads_'::omp_set_num_threads
!dec$ attributes alias:'_omp_set_dynamic_'::omp_set_dynamic
!dec$ attributes alias:'_omp_set_nested_'::omp_set_nested
!dec$ attributes alias:'_omp_get_num_threads_'::omp_get_num_threads
!dec$ attributes alias:'_omp_get_max_threads_'::omp_get_max_threads
!dec$ attributes alias:'_omp_get_thread_num_'::omp_get_thread_num
!dec$ attributes alias:'_omp_get_num_procs_'::omp_get_num_procs
!dec$ attributes alias:'_omp_in_parallel_'::omp_in_parallel
!dec$ attributes alias:'_omp_get_dynamic_'::omp_get_dynamic
!dec$ attributes alias:'_omp_get_nested_'::omp_get_nested
!dec$ attributes alias:'_omp_get_wtime_'::omp_get_wtime
!dec$ attributes alias:'_omp_get_wtick_'::omp_get_wtick
!dec$ attributes alias:'_omp_init_lock_'::omp_init_lock
!dec$ attributes alias:'_omp_destroy_lock_'::omp_destroy_lock
!dec$ attributes alias:'_omp_set_lock_'::omp_set_lock
!dec$ attributes alias:'_omp_unset_lock_'::omp_unset_lock
!dec$ attributes alias:'_omp_test_lock_'::omp_test_lock
!dec$ attributes alias:'_omp_init_nest_lock_'::omp_init_nest_lock
!dec$ attributes alias:'_omp_destroy_nest_lock_'::omp_destroy_nest_lock
!dec$ attributes alias:'_omp_set_nest_lock_'::omp_set_nest_lock
!dec$ attributes alias:'_omp_unset_nest_lock_'::omp_unset_nest_lock
!dec$ attributes alias:'_omp_test_nest_lock_'::omp_test_nest_lock
!dec$ attributes alias:'_kmp_set_parallel_name_'::kmp_set_parallel_name
!dec$ attributes alias:'_kmp_set_stacksize_'::kmp_set_stacksize
!dec$ attributes alias:'_kmp_set_stacksize_s_'::kmp_set_stacksize_s
!dec$ attributes alias:'_kmp_set_blocktime_'::kmp_set_blocktime
!dec$ attributes alias:'_kmp_set_library_serial_'::kmp_set_library_serial
!dec$ attributes alias:'_kmp_set_library_turnaround_'::kmp_set_library_turnaround
!dec$ attributes alias:'_kmp_set_library_throughput_'::kmp_set_library_throughput
!dec$ attributes alias:'_kmp_set_library_'::kmp_set_library
!dec$ attributes alias:'_kmp_set_stats_'::kmp_set_stats
!dec$ attributes alias:'_kmp_get_stacksize_'::kmp_get_stacksize
!dec$ attributes alias:'_kmp_get_stacksize_s_'::kmp_get_stacksize_s
!dec$ attributes alias:'_kmp_get_blocktime_'::kmp_get_blocktime
!dec$ attributes alias:'_kmp_get_library_'::kmp_get_library
!dec$ attributes alias:'_kmp_malloc_'::kmp_malloc
!dec$ attributes alias:'_kmp_calloc_'::kmp_calloc
!dec$ attributes alias:'_kmp_realloc_'::kmp_realloc
!dec$ attributes alias:'_kmp_free_'::kmp_free
!dec$ attributes alias:'_kmp_sharable_malloc_'::kmp_sharable_malloc
!dec$ attributes alias:'_kmp_aligned_sharable_malloc_'::kmp_aligned_sharable_malloc
!dec$ attributes alias:'_kmp_sharable_calloc_'::kmp_sharable_calloc
!dec$ attributes alias:'_kmp_sharable_realloc_'::kmp_sharable_realloc
!dec$ attributes alias:'_kmp_sharable_free_'::kmp_sharable_free
!dec$ attributes alias:'_kmp_lock_cond_wait_'::kmp_lock_cond_wait
!dec$ attributes alias:'_kmp_lock_cond_signal_'::kmp_lock_cond_signal
!dec$ attributes alias:'_kmp_lock_cond_broadcast_'::kmp_lock_cond_broadcast
!dec$ attributes alias:'_kmp_nest_lock_cond_wait_'::kmp_nest_lock_cond_wait
!dec$ attributes alias:'_kmp_nest_lock_cond_signal_'::kmp_nest_lock_cond_signal
!dec$ attributes alias:'_kmp_nest_lock_cond_broadcast_'::kmp_nest_lock_cond_broadcast
!dec$ attributes alias:'_kmp_get_num_processes_'::kmp_get_num_processes
!dec$ attributes alias:'_kmp_get_process_num_'::kmp_get_process_num
!dec$ attributes alias:'_kmp_get_process_thread_num_'::kmp_get_process_thread_num
!dec$ attributes alias:'_kmp_set_warnings_on_'::kmp_set_warnings_on
!dec$ attributes alias:'_kmp_set_warnings_off_'::kmp_set_warnings_off
!dec$ attributes alias:'_kmp_is_sharable_'::kmp_is_sharable
!dec$ attributes alias:'_kmp_deferred_atomic_add_i4_'::kmp_deferred_atomic_add_i4
!dec$ attributes alias:'_kmp_deferred_atomic_add_i8_'::kmp_deferred_atomic_add_i8
!dec$ attributes alias:'_kmp_deferred_atomic_add_r4_'::kmp_deferred_atomic_add_r4
!dec$ attributes alias:'_kmp_deferred_atomic_add_r8_'::kmp_deferred_atomic_add_r8
!dec$ endif
end module omp_lib
| code/trap_analysis/omp_lib.f |
!! https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82996
!!
!! The original example gave an error when automatically applying the
!! elemental final procedure to the B array component of the BAR object.
!! So let's add a final procedure to the BAR type (not necessary) that
!! explicitly calls FOO_DESTROY on the B array component. Here's what
!! happens:
!!
!! $ gfortran -g gfortran-bug-20171114b.f90
!! f951: internal compiler error: in generate_finalization_wrapper, at fortran/class.c:1975
!! Please submit a full bug report,
!! with preprocessed source if appropriate.
!! See <http://bugzilla.redhat.com/bugzilla> for instructions.
module mod
type foo
integer, pointer :: f(:) => null()
contains
final :: foo_destroy
end type
type bar
type(foo) :: b(2)
contains
final :: bar_destroy
end type
contains
elemental subroutine foo_destroy(this)
type(foo), intent(inout) :: this
if (associated(this%f)) deallocate(this%f)
end subroutine
subroutine bar_destroy(this)
type(bar), intent(inout) :: this
call foo_destroy(this%b)
end subroutine
end module
program main
use mod
type(bar) :: x
call sub(x)
contains
subroutine sub(x)
type(bar), intent(out) :: x
end subroutine
end program
| gfortran-bugs/gfortran-20171114b.f90 |
! { dg-do compile }
!
! PR 46067: [F03] invalid procedure pointer assignment not detected
!
! Contributed by Stephen J. Bespalko <sjbespa@comcast.net>
implicit none
type test_type
integer :: id = 1
end type
abstract interface
real function fun_interface(t,x)
import :: test_type
real, intent(in) :: x
class(test_type) :: t
end function
end interface
type(test_type) :: funs
real :: r
procedure(fun_interface), pointer :: pp
pp => fun1 ! { dg-error "Interface mismatch in procedure pointer assignment" }
r = pp(funs,0.)
print *, " pp(0) ", r
contains
real function fun1 (t,x)
real, intent(in) :: x
type(test_type) :: t
print *," id = ", t%id
fun1 = cos(x)
end function
end
| validation_tests/llvm/f18/gfortran.dg/proc_ptr_30.f90 |
SUBROUTINE KELBOW
C
C THIS ROUTINE COMPUTES THE TWO 6 X 6 MATRICES K(NPVT,NPVT) AND
C K(NPVT,J) FOR A CURVED BAR ELEMENT HAVING END POINTS NUMBERED
C NPVT AND J
C
C ECPT FOR THE ELBOW
C
C ECPT( 1) - IELID ELEMENT ID. NUMBER
C ECPT( 2) - ISILNO(2) * SCALAR INDEX NOS. OF THE GRID POINTS
C ECPT( 3) - ... *
C ECPT( 4) - SMALLV(3) $ REFERENCE VECTOR
C ECPT( 5) - ... $
C ECPT( 6) - ... $
C ECPT( 7) - ICSSV COOR. SYS. ID FOR SMALLV VECTOR
C ECPT( 8) - IMATID MATERIAL ID.
C ECPT( 9) - A CROSS-SECTIONAL AREA
C ECPT(10) - I1 $ AREA MOMENTS OF INERTIA
C ECPT(11) - I2 $
C ECPT(12) - FJ TORSIONAL CONSTANT
C ECPT(13) - NSM NON-STRUCTURAL MASS
C ECPT(14) - FE FORCE ELEM. DESCRIPTIONS, FORCE METHOD
C ECPT(15) - R1 *STRESS RECOVERY COEFFICIENTS
C ECPT(16) - T1 * RI = RADIAL LOCATION
C ECPT(17) - R2 * TI = ANGULAR LOCATION
C ECPT(18) - T2 * OF STRESS RECOVERY POINTS
C ECPT(19) - R3 *
C ECPT(20) - T3 *
C ECPT(21) - R4 *
C ECPT(22) - T4 *
C ECPT(23) - K1 $ AREA FACTOR FOR SHEAR
C ECPT(24) - K2 $
C ECPT(25) - C STRESS INTENSIFICATION FACTOR
C ECPT(26) - KX * FLEXIBILITY CORRECTION FACTORS
C ECPT(27) - KY *
C ECPT(28) - KZ *
C ECPT(29) - R RADIUS OF CURVATURE
C ECPT(30) - BETAR ANGLE FROM GA TO GB
C ECPT(31) - MCSIDA COORD. SYS. ID. FOR GRID POINT A
C ECPT(32) - GPA(3) * BASIC COORD. FOR GRID POINT A
C ECPT(33) - ... *
C ECPT(34) - ... *
C ECPT(35) - MCSIDB COORD. SYS. ID. FOR GRID POINT B
C ECPT(36) - GPB(3) * BASIC COORD. FOR GRID POINT B
C ECPT(37) - ... *
C ECPT(38) - ... *
C ECPT(39) - ELTEMP AVG. ELEMENT TEMPERATURE
C
C COMMENTS FROM G.CHAN/UNISYS 7/91
C ABOUT K1 AND K2, THE AREA FACTORS FOR SHEAR
C
C THE K1,K2 FOR BAR ARE 0. TO 1.0, AND ARE USED IN K1*G*A AND K2*G*A
C THE K1,K2 ARE THEREFORE CORRECTION FACTORS FOR STIFFNESS
C THE K1,K2 ARE USED IN ELBOW IN K1/G*A AND K2/G*A. AND THEREFORE
C THE K1,K2 ARE COORECTION FACTORS FOR FLEXIBILITY. THE K1,K2
C IN ELBOW ARE EQUIVALENT TO 1./K1 AND 1./K2 IN BAR ELEMENT.
C THE PROPER VALUE FOR K1 AND K2 SHOULD BE INFINITY TO 1.0
C
C IN 1992 COSMIC/NASTRAN, THE USE OF K1 AND K2 IN ELBOW AND BAR
C ELMENTS ARE SYMCHRONIZED, WITH PROPER VALUES FROM 0. TO 1.0
C THE K1 AND K2 ARE CHANGED TO 1./K1 AND 1./K2 IN ELBOW ELEMENT
C SHEAR COMPUTATION. THAT IS, CORRECTION FACTORS FOR STIFFNESS IS
C USED.
C
C REFERENCE - R.J. ROARK: FORMULAS FOR STRESS AND STRAIN,
C SECTION 35, 'BEAMS FOR RELATIVELY GREAT DEPTH',
C FOR BEAMS OF SAMLL SPAN/DEPTH RATIO
C
C K = 1/F = 5/6 FOR RECTANGULAR SECTION
C = 0.9 FOR SOLID CIRCULAR
C = 0.5 FOR THIN-WALLED HOOLOW CIRCULAR SECTION
C = 1.0 CAN BE USED FOR I-BEAM
C
C
C
LOGICAL HEAT,ABASIC,BBASIC,BASIC
REAL K1,K2,I1,I2,NSM,KX,KY,KZ
DOUBLE PRECISION TA(18),TB(9),SMALV0(6),DELA,DELB,KE,KEP,VECI,
1 VECJ,VECK,FL,FLL,DF(6,6),DETERM,H(6,6),DP(16),
2 S(12,12),DAMPC,KEE(12,12)
DIMENSION VECI(3),VECJ(3),VECK(3),ECPT(100),IECPT(100),
1 IZ(1),IWORK(6,3),F(6,6)
COMMON /SMA1IO/ IFCSTM,IFMPT,IFDIT,IDUM1,IFECPT,IGECPT,IFGPCT,
1 IGGPCT,IFGEI,IGGEI,IFKGG,IGKGG,IF4GG,IG4GG,
2 IFGPST,IGGPST,INRW,OUTRW,CLSNRW,CLSRW,NEOR,
3 EOR,MCBKGG(7),MCB4GG(7)
COMMON /ZZZZZZ/ Z(1)
COMMON /SMA1BK/ ICSTM,NCSTM,IGPCT,NGPCT,IPOINT,NPOINT,I6X6K,
1 N6X6K,I6X64,N6X64
COMMON /SMA1CL/ IOPT4,K4GGSW,NPVT,LEFT,FROWIC,LROWIC,NROWSC,
1 TNROWS,JMAX,NLINKS,LINK(10),IDETCK,DODET,NOGO
COMMON /SMA1HT/ HEAT
COMMON /SMA1ET/ IELID,ISILNO(2),SMALLV(3),ICSSV,IMATID,A,I1,I2,
1 FJ,NSM,FE,C1,C2,D1,D2,F1,F2,G1,G2,K1,K2,C,KX,KY,
2 KZ,R,BETAR,MCSIDA,GPA(3),MCSIDB,GPB(3),TEMPEL
COMMON /SMA1DP/ KE(144),KEP(144),DELA(6),DELB(6)
COMMON /MATIN / MATIDC,MATFLG,ELTEMP,STRESS,SINTH,COSTH
COMMON /MATOUT/ E,G,NU,RHO,ALPHA,TSUBO,GSUBE,SIGT,SIGC,SIGS
COMMON /HMTOUT/ FK
COMMON /SYSTEM/ SYSBUF,NOUT
EQUIVALENCE (IELID,ECPT(1),IECPT(1)),(IZ(1),Z(1)),
1 (TA(10),TB(1)),(ECPT(71),DP(1)),
2 (KEE(1,1),KE(1),S(1,1))
DATA DCR / .017453292 /
C
SID(X) = SIN(X*DCR)
COD(X) = COS(X*DCR)
DTR(X) = X*DCR
C
C DETERMINE WHICH POINT IS THE PIVOT POINT.
C
X = 1.
IPVT = 1
IF (ISILNO(1) .EQ. NPVT) GO TO 20
IPVT = 2
IF (ISILNO(2) .NE. NPVT) CALL MESAGE (-30,34,IECPT(1))
C
C SET UP POINTERS TO COORD. SYSTEM IDS
C
20 JCSIDA = 31
JCSIDB = 35
ICSIDA = IECPT(31)
ICSIDB = IECPT(35)
C
C DEFINE LOCATION OF END A, END B IN TERMS OF DP(1) THRU DP(6)
C
DP(1) = ECPT(JCSIDA+1)
DP(2) = ECPT(JCSIDA+2)
DP(3) = ECPT(JCSIDA+3)
DP(4) = ECPT(JCSIDB+1)
DP(5) = ECPT(JCSIDB+2)
DP(6) = ECPT(JCSIDB+3)
C
C DEFINE COMPONENTS OF VECTOR FROM END A TO CENTER OF CURVATURE,C
C
DP(7) = ECPT(4)
DP(8) = ECPT(5)
DP(9) = ECPT(6)
FLD = DSQRT(DP(7)**2 + DP(8)**2 + DP(9)**2)
IF (FLD .LE. 0.000) GO TO 1010
DP(7) = DP(7)/FLD
DP(8) = DP(8)/FLD
DP(9) = DP(9)/FLD
C
C DETERMINE IF POINT A AND B ARE IN BASIC COORDINATES
C
ABASIC =.TRUE.
BBASIC =.TRUE.
IF (ICSIDA .NE. 0) ABASIC =.FALSE.
IF (ICSIDB .NE. 0) BBASIC =.FALSE.
C
C COMPUTE THE TRANSFORMATION MATRICES TA AND TB IF NECESSARY
C
IF (ABASIC) GO TO 30
CALL TRANSD (ECPT(JCSIDA),TA)
CALL GMMATD (TA,3,3,0, DP(7),3,1,0, VECJ)
CALL GMMATD (TA,3,3,0, DP(1),3,1,0, DP(14))
DP(1) = DP(14)
DP(2) = DP(15)
DP(3) = DP(16)
GO TO 35
30 CONTINUE
VECJ(1) = DP(7)
VECJ(2) = DP(8)
VECJ(3) = DP(9)
35 IF (BBASIC) GO TO 40
CALL TRANSD (ECPT(JCSIDB),TB)
CALL GMMATD (TB,3,3,0, DP(4),3,1,0, DP(14))
DP(4) = DP(14)
DP(5) = DP(15)
DP(6) = DP(16)
40 CONTINUE
C
C CALCULATE TRUE LENGTH OF ELBOW
C
FL = DBLE(R*DTR(BETAR))
IF (FL .EQ. 0.0D0) GO TO 1010
C
C NOW THAT LENGTH HAS BEEN COMPUTED, BRANCH IF THIS IS A -HEAT-
C FORMULATION.
C
IF (HEAT) GO TO 2000
C
C CONSTRUCT VECTOR FROM A TO B
C
SMALV0(1) = DP(4) - DP(1)
SMALV0(2) = DP(5) - DP(2)
SMALV0(3) = DP(6) - DP(3)
FLL = DSQRT(SMALV0(1)**2 + SMALV0(2)**2 + SMALV0(3)**2)
IF (FLL .EQ. 0.0D0) GO TO 1010
SMALV0(1) = SMALV0(1)/FLL
SMALV0(2) = SMALV0(2)/FLL
SMALV0(3) = SMALV0(3)/FLL
C
C COMPUTE THE K VECTOR VECK = SMALV0 X VECJ
C
VECK(1) = SMALV0(2)*VECJ(3) - SMALV0(3)*VECJ(2)
VECK(2) = SMALV0(3)*VECJ(1) - SMALV0(1)*VECJ(3)
VECK(3) = SMALV0(1)*VECJ(2) - SMALV0(2)*VECJ(1)
FLL = DSQRT(VECK(1)**2 + VECK(2)**2 + VECK(3)**2)
IF (FLL .EQ. 0.0D0) GOTO 1010
VECK(1) = VECK(1)/FLL
VECK(2) = VECK(2)/FLL
VECK(3) = VECK(3)/FLL
C
C COMPUTE THE I VECTOR VECI = VECJ X VECK
C
VECI(1) = VECJ(2)*VECK(3) - VECJ(3)*VECK(2)
VECI(2) = VECJ(3)*VECK(1) - VECJ(1)*VECK(3)
VECI(3) = VECJ(1)*VECK(2) - VECJ(2)*VECK(1)
FLL = DSQRT(VECI(1)**2 + VECI(2)**2 + VECI(3)**2)
IF (FLL .EQ. 0.0D0) GO TO 1010
VECI(1) = VECI(1)/FLL
VECI(2) = VECI(2)/FLL
VECI(3) = VECI(3)/FLL
C
C SEARCH THE MATERIAL PROPERTIES TABLE FOR E,G AND THE DAMPING
C CONSTANT.
C
MATIDC = IMATID
MATFLG = 1
ELTEMP = TEMPEL
CALL MAT (IECPT(1))
DAMPC = G SUB E
C
C SET UP INTERMEDIATE VARIABLES FOR ELEMENT STIFFNESS MATRIX
C CALCULATION
C
IF (KX .LT. 1.0E-8) KX = 1.0
IF (KY .LT. 1.0E-8) KY = 1.0
IF (KZ .LT. 1.0E-8) KZ = 1.0
FI1 = I1/KZ
FI2 = I2/KY
FJK = FJ/KX
C
C AREA FACTORS FOR SHEAR ARE FROM NEAR ZERO TO ONE
C
IF (K1 .LT. 1.0E-8) K1 = 1.0
IF (K2 .LT. 1.0E-8) K2 = 1.0
IF (K1 .GT. 1.0) K1 = 1.0/K1
IF (K2 .GT. 1.0) K2 = 1.0/K2
C
C THE FOLLOWING CODE WAS TAKEN FROM SAP4 BENDKS ROUTINE
C FOR A CURVED PIPE ELEMENT
C
C COMPUTE SECTION PROPERTY CONSTANTS
C
T = DTR(BETAR)
RA = R/(A*E)
RV1 = R/(2.*K1*G*A)
RV2 = K1/K2*RV1
RT = R/(G*FJK*2.)
RB0 = R/(E*FI2*2.)
RB1 = R/(E*FI1)
R2 = R**2
C
C COMPUTE COMMON TRIGONOMETRIC CONSTANTS
C
ST = SID(BETAR)
CT = COD(BETAR)
S2T = SID(2.0*BETAR)
C2T = COD(2.0*BETAR)
C
C FORM THE NODE FLEXIBILITY MATRIX AT NODE J REFERENCED TO THE
C LOCAL (X,Y,Z) COORDINATE SYSTEM AT NODE I.
C
C X - DIRECTION... IN-PLANE TANGENT TO THE BEND AT NODE I AND
C DIRECTED TOWARD NODE J
C Y - DIRECTION... IN-PLANE AND DIRECTED RADIALLY INWARD TO THE
C CENTER OF CURVATURE
C Z - DIRECTION... OUT OF PLANE AND ORTHOGONAL TO X AND Y
C
DO 50 I = 1,6
DO 50 K = I,6
F(I,K) = 0.0
50 CONTINUE
C
C A X I A L
C
F(1,1) = F(1,1) + 0.25*RA*(2.0*T+S2T)
F(2,2) = F(2,2) + 0.25*RA*(2.0*T-S2T)
C
C N O T E (COEFFICIENT CHANGE)
C
F(1,2) = F(1,2) + 0.50*RA*ST**2
C
C S H E A R
C
F(1,1) = F(1,1) + 0.5*RV1*(2.0*T-S2T)
F(2,2) = F(2,2) + 0.5*RV1*(2.0*T+S2T)
F(3,3) = F(3,3) + 2.0*RV2* T
C
C N O T E (SIGN CHANGE)
C
F(1,2) = F(1,2) - RV1*ST**2
C
C T O R S I O N
C
F(3,3) = F(3,3) + 0.5*RT*R2*(6.0*T+S2T-8.0*ST)
F(4,4) = F(4,4) + 0.5*RT* (2.0*T+S2T)
F(5,5) = F(5,5) + 0.5*RT* (2.0*T-S2T)
F(3,4) = F(3,4) + RT*R *(ST-T*CT)
F(3,5) = F(3,5) + RT*R *(2.0-2.0*CT-T*ST)
F(4,5) = F(4,5) + 0.5*RT* (1.0-C2T)
C
C B E N D I N G
C
F(1,1) = F(1,1) + 0.25*RB1*R2*(2.0*T*(2.0+C2T)-3.0*S2T)
F(2,2) = F(2,2) + 0.25*RB1*R2*(2.0*T*(2.0-C2T)+3.0*S2T-8.0*ST)
F(3,3) = F(3,3) + 0.50*RB0*R2*(2.0*T-S2T)
F(4,4) = F(4,4) + 0.50*RB0* (2.0*T-S2T)
F(5,5) = F(5,5) + 0.50*RB0* (2.0*T+S2T)
F(6,6) = F(6,6) + RB1*T
F(1,2) = F(1,2) + 0.25*RB1*R2*(1.0+3.0*C2T+2.0*T*S2T-4.0*CT)
F(1,6) = F(1,6) - RB1*R *(ST-T*CT)
F(2,6) = F(2,6) + RB1*R *(T*ST+CT-1.0)
F(3,4) = F(3,4) + RB0*R *(ST-T*CT)
F(3,5) = F(3,5) - RB0*R *T*ST
F(4,5) = F(4,5) - 0.50*RB0* (1.0-C2T)
C
C
C FORM SYMMETRICAL UPPER PART OF FLEX MATRIX
C
DO 65 I = 1,6
DO 65 K = I,6
DF(K,I) = DBLE(F(I,K))
DF(I,K) = DF(K,I)
65 CONTINUE
C
C WRITE (6,4005) DF
C
C INVERT FLEX TO FORM STIFFNESS
C
CALL INVERD (6,DF,6,DUM,0,DETERM,ISING,IWORK)
IF (ISING .EQ. 2) WRITE (6,4002) F
IF (ISING .EQ. 2) CALL MESAGE (-30,38,ECPT(1))
4002 FORMAT (1X,34HELBOW STIFFNESS MATRIX IS SINGULAR, /,(5X,6E13.5))
C
C
C SET UP THE FORCE TRANSFORMATION RELATING REACTIONS AT NODE I
C ACTING ON THE MEMBER END DUE TO UNIT LOADS APPLIED TO THE MEMBER
C END AT NODE J.
C
DO 100 I = 1,6
DO 100 K = 1,6
H(I,K) = 0.0D0
100 CONTINUE
C
DO 105 K = 1,6
H(K,K) =-1.0D0
105 CONTINUE
C
H(4,3) =-DBLE(R*(1.0-CT))
H(5,3) = DBLE(R*ST)
H(6,1) =-H(4,3)
H(6,2) =-H(5,3)
C
C FORM THE UPPER TRIANGULAR PORTION OF THE LOCAL ELEMENT STIFFNESS
C MATRIX FOR THE BEND
C
DO 110 K = 1,6
DO 110 I = K,6
S(K+6,I+6) = DF(K,I)
110 CONTINUE
C
DO 130 IR = 1,6
DO 130 IC = 1,6
S(IR,IC+6) = 0.0D0
DO 120 IN = 1,6
S(IR,IC+6) = S(IR,IC+6) + H(IR,IN)*DF(IN,IC)
120 CONTINUE
130 CONTINUE
C
DO 150 IR = 1,6
DO 150 IC = IR,6
S(IR,IC) = 0.0D0
DO 140 IN = 1,6
S(IR,IC) = S(IR,IC) + S(IR,IN+6)*H(IC,IN)
140 CONTINUE
150 CONTINUE
C
C REFLECT FOR SYMMETRY
C
DO 165 I = 1,12
DO 165 K = I,12
S(K,I) = S(I,K)
165 CONTINUE
C
J = 0
IF (IPVT .EQ. 2) GO TO 327
ILOW = 1
ILIM = 72
GO TO 329
327 ILOW = 73
ILIM = 144
329 DO 340 I = ILOW,ILIM,12
LOW = I
LIM = LOW + 5
DO 330 K = LOW,LIM
J = J + 1
KEP(J) = KE(K)
330 KEP(J+36) = KE(K+6)
340 CONTINUE
C
C T
C STORE VECI, VECJ, VECK IN KE(1),...,KE(9) FORMING THE A MATRIX.
C
KE(1) = VECI(1)
KE(2) = VECI(2)
KE(3) = VECI(3)
KE(4) = VECJ(1)
KE(5) = VECJ(2)
KE(6) = VECJ(3)
KE(7) = VECK(1)
KE(8) = VECK(2)
KE(9) = VECK(3)
C
C ZERO OUT THE ARRAY WHERE THE 3 X 3 MATRIX H AND THE W AND W
C 6 X 6 MATRICES WILL RESIDE. A B
C
DO 350 I = 28,108
350 KE(I) = 0.0D0
IPASS = 1
IWBEG = 0
C
C SET UP POINTERS
C
IF (IPVT-1) 365,360,365
360 BASIC = ABASIC
JCSID = JCSIDA
IKEL = 1
INDEX = ISILNO(1)
GO TO 368
365 BASIC = BBASIC
JCSID = JCSIDB
IKEL = 37
INDEX = ISILNO(2)
C
C SET UP THE -G- MATRIX. IG POINTS TO THE BEGINNING OF THE G
C MATRIX. G = AT X TI
C
368 IG = 1
IF (BASIC) GO TO 380
CALL TRANSD (ECPT(JCSID),KE(10))
CALL GMMATD (KE(1),3,3,0, KE(10),3,3,0, KE(19))
IG = 19
C
C FORM THE W MATRIX OR THE W MATRIX IN KE(37) OR KE(73) DEPENDING
C A B
C UPON WHICH POINT - A OR B - IS UNDER CONSIDERATION. G WILL BE
C STORED IN THE UPPER LEFT AND LOWER RIGHT CORNERS. H, IF NON-ZERO,
C WILL BE STORED IN THE UPPER RIGHT CORNER.
C
380 KE(IWBEG+37) = KE(IG )
KE(IWBEG+38) = KE(IG+1)
KE(IWBEG+39) = KE(IG+2)
KE(IWBEG+43) = KE(IG+3)
KE(IWBEG+44) = KE(IG+4)
KE(IWBEG+45) = KE(IG+5)
KE(IWBEG+49) = KE(IG+6)
KE(IWBEG+50) = KE(IG+7)
KE(IWBEG+51) = KE(IG+8)
KE(IWBEG+58) = KE(IG )
KE(IWBEG+59) = KE(IG+1)
KE(IWBEG+60) = KE(IG+2)
KE(IWBEG+64) = KE(IG+3)
KE(IWBEG+65) = KE(IG+4)
KE(IWBEG+66) = KE(IG+5)
KE(IWBEG+70) = KE(IG+6)
KE(IWBEG+71) = KE(IG+7)
KE(IWBEG+72) = KE(IG+8)
C
C T E
C FORM THE PRODUCT W X K AND STORE IN KEP(73)
C NPVT
C
CALL GMMATD (KE(37),6,6,1, KEP(IKEL),6,6,0, KEP(73))
C
C COMPUTE THE FINAL ANSWER AND STORE IN KEP(109)
C
CALL GMMATD (KEP(73),6,6,0, KE(IWBEG+37),6,6,0, KEP(109))
C
C INSERT THIS 6 X 6
C
CALL SMA1B (KEP(109),INDEX,-1,IFKGG,0.0D0)
IF (IOPT4.EQ.0 .OR. GSUBE.EQ.0.0) GO TO 400
K4GGSW = 1
CALL SMA1B (KEP(109),INDEX,-1,IF4GG,DAMPC)
C
C IF IPASS = 2, WE ARE DONE. OTHERWISE COMPUTE THE OFF-DIAGONAL
C 6 X 6.
C
400 IF (IPASS .EQ. 2) GO TO 500
IWBEG = 36
IPASS = 2
DO 410 I = 28,36
410 KE(I) = 0.0D0
IF (IPVT-1) 360,365,360
500 RETURN
C
1010 CALL MESAGE (30,26,IECPT(1))
C
C SET FLAG FOR FATAL ERROR WHILE ALLOWING ERROR MESSAGES TO
C ACCUMULATE
C
NOGO = 1
RETURN
C
C
C HEAT FORMULATION CONTINUES HERE. GET MATERIAL PROPERTY -K- FROM
C HMAT
C
2000 MATFLG = 1
MATIDC = IECPT( 8)
ELTEMP = ECPT(39)
CALL HMAT (IELID)
C
FL = DBLE(FK)*DBLE(ECPT(9))/(DP(9)*DP(10)*DBLE(DCR))
IF (NPVT .EQ. IECPT(3)) FL = -FL
DO 2020 I = 1,2
CALL SMA1B (FL,IECPT(I+1),NPVT,IFKGG,0.0D0)
FL = -FL
2020 CONTINUE
RETURN
END
| mis/kelbow.f |
SUBROUTINE AB07MD( JOBD, N, M, P, A, LDA, B, LDB, C, LDC, D, LDD,
$ INFO )
C
C SLICOT RELEASE 5.5.
C
C Copyright (c) 2002-2012 NICONET e.V.
C
C PURPOSE
C
C To find the dual of a given state-space representation.
C
C ARGUMENTS
C
C Mode Parameters
C
C JOBD CHARACTER*1
C Specifies whether or not a non-zero matrix D appears in
C the given state space model:
C = 'D': D is present;
C = 'Z': D is assumed a zero matrix.
C
C Input/Output Parameters
C
C N (input) INTEGER
C The order of the state-space representation. N >= 0.
C
C M (input) INTEGER
C The number of system inputs. M >= 0.
C
C P (input) INTEGER
C The number of system outputs. P >= 0.
C
C A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
C On entry, the leading N-by-N part of this array must
C contain the original state dynamics matrix A.
C On exit, the leading N-by-N part of this array contains
C the dual state dynamics matrix A'.
C
C LDA INTEGER
C The leading dimension of array A. LDA >= MAX(1,N).
C
C B (input/output) DOUBLE PRECISION array, dimension
C (LDB,MAX(M,P))
C On entry, the leading N-by-M part of this array must
C contain the original input/state matrix B.
C On exit, the leading N-by-P part of this array contains
C the dual input/state matrix C'.
C
C LDB INTEGER
C The leading dimension of array B. LDB >= MAX(1,N).
C
C C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
C On entry, the leading P-by-N part of this array must
C contain the original state/output matrix C.
C On exit, the leading M-by-N part of this array contains
C the dual state/output matrix B'.
C
C LDC INTEGER
C The leading dimension of array C.
C LDC >= MAX(1,M,P) if N > 0.
C LDC >= 1 if N = 0.
C
C D (input/output) DOUBLE PRECISION array, dimension
C (LDD,MAX(M,P))
C On entry, if JOBD = 'D', the leading P-by-M part of this
C array must contain the original direct transmission
C matrix D.
C On exit, if JOBD = 'D', the leading M-by-P part of this
C array contains the dual direct transmission matrix D'.
C The array D is not referenced if JOBD = 'Z'.
C
C LDD INTEGER
C The leading dimension of array D.
C LDD >= MAX(1,M,P) if JOBD = 'D'.
C LDD >= 1 if JOBD = 'Z'.
C
C Error Indicator
C
C INFO INTEGER
C = 0: successful exit;
C < 0: if INFO = -i, the i-th argument had an illegal
C value.
C
C METHOD
C
C If the given state-space representation is the M-input/P-output
C (A,B,C,D), its dual is simply the P-input/M-output (A',C',B',D').
C
C REFERENCES
C
C None
C
C NUMERICAL ASPECTS
C
C None
C
C CONTRIBUTOR
C
C Release 3.0: V. Sima, Katholieke Univ. Leuven, Belgium, Dec. 1996.
C Supersedes Release 2.0 routine AB07AD by T.W.C.Williams, Kingston
C Polytechnic, United Kingdom, March 1982.
C
C REVISIONS
C
C V. Sima, Research Institute for Informatics, Bucharest, Feb. 2004.
C
C KEYWORDS
C
C Dual system, state-space model, state-space representation.
C
C ******************************************************************
C
C .. Scalar Arguments ..
CHARACTER JOBD
INTEGER INFO, LDA, LDB, LDC, LDD, M, N, P
C .. Array Arguments ..
DOUBLE PRECISION A(LDA,*), B(LDB,*), C(LDC,*), D(LDD,*)
C .. Local Scalars ..
LOGICAL LJOBD
INTEGER J, MINMP, MPLIM
C .. External functions ..
LOGICAL LSAME
EXTERNAL LSAME
C .. External subroutines ..
EXTERNAL DCOPY, DSWAP, XERBLA
C .. Intrinsic Functions ..
INTRINSIC MAX, MIN
C .. Executable Statements ..
C
INFO = 0
LJOBD = LSAME( JOBD, 'D' )
MPLIM = MAX( M, P )
MINMP = MIN( M, P )
C
C Test the input scalar arguments.
C
IF( .NOT.LJOBD .AND. .NOT.LSAME( JOBD, 'Z' ) ) THEN
INFO = -1
ELSE IF( N.LT.0 ) THEN
INFO = -2
ELSE IF( M.LT.0 ) THEN
INFO = -3
ELSE IF( P.LT.0 ) THEN
INFO = -4
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
INFO = -6
ELSE IF( LDB.LT.MAX( 1, N ) ) THEN
INFO = -8
ELSE IF( ( N.GT.0 .AND. LDC.LT.MAX( 1, MPLIM ) ) .OR.
$ ( N.EQ.0 .AND. LDC.LT.1 ) ) THEN
INFO = -10
ELSE IF( ( LJOBD .AND. LDD.LT.MAX( 1, MPLIM ) ) .OR.
$ ( .NOT.LJOBD .AND. LDD.LT.1 ) ) THEN
INFO = -12
END IF
C
IF ( INFO.NE.0 ) THEN
C
C Error return.
C
CALL XERBLA( 'AB07MD', -INFO )
RETURN
END IF
C
C Quick return if possible.
C
IF ( MAX( N, MINMP ).EQ.0 )
$ RETURN
C
IF ( N.GT.0 ) THEN
C
C Transpose A, if non-scalar.
C
DO 10 J = 1, N - 1
CALL DSWAP( N-J, A(J+1,J), 1, A(J,J+1), LDA )
10 CONTINUE
C
C Replace B by C' and C by B'.
C
DO 20 J = 1, MPLIM
IF ( J.LE.MINMP ) THEN
CALL DSWAP( N, B(1,J), 1, C(J,1), LDC )
ELSE IF ( J.GT.P ) THEN
CALL DCOPY( N, B(1,J), 1, C(J,1), LDC )
ELSE
CALL DCOPY( N, C(J,1), LDC, B(1,J), 1 )
END IF
20 CONTINUE
C
END IF
C
IF ( LJOBD .AND. MINMP.GT.0 ) THEN
C
C Transpose D, if non-scalar.
C
DO 30 J = 1, MPLIM
IF ( J.LT.MINMP ) THEN
CALL DSWAP( MINMP-J, D(J+1,J), 1, D(J,J+1), LDD )
ELSE IF ( J.GT.P ) THEN
CALL DCOPY( P, D(1,J), 1, D(J,1), LDD )
ELSE IF ( J.GT.M ) THEN
CALL DCOPY( M, D(J,1), LDD, D(1,J), 1 )
END IF
30 CONTINUE
C
END IF
C
RETURN
C *** Last line of AB07MD ***
END
| External/SLICOT/AB07MD.f |
#INCLUDE 'MR_H_ALIGN_PADDING.H'
!***********************************************************************************************************************************
! UNIT:
!
! (MODULE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
MODULE MR_MOD_READ_FIELD_VARS_N_ACTIVITY
USE XMDF
USE MR_KINDS
IMPLICIT NONE
PRIVATE
PUBLIC :: MR_READ_UV
PUBLIC :: MR_READ_SS
!***********************************************************************************************************************************
CONTAINS
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_ACTIVITY( DSET_ACTIVITY_ID , ITS , NEM , NI , NJ , EMIDW , ACTIVITY , ERROR , ERRMSG )
IMPLICIT NONE
INTEGER , INTENT(IN ) :: DSET_ACTIVITY_ID
INTEGER(TSID_KIND) , INTENT(IN ) :: ITS
INTEGER(EMID_KIND) , INTENT(IN ) :: NEM
INTEGER(IJID_KIND) , INTENT(IN ) :: NI , NJ
INTEGER(EMID_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,EMID_KIND),1:NJ) :: EMIDW
INTEGER(ACID_KIND) , INTENT(OUT) , DIMENSION(1:NI1(NI,ACID_KIND),1:NJ) :: ACTIVITY
INTEGER , DIMENSION(1:NEM) :: ACTIVITY_ARRAY
INTEGER , INTENT(OUT) :: ERROR
CHARACTER( * ) , INTENT(OUT) :: ERRMSG
ERRMSG = ""
CALL XF_READ_ACTIVITY_TIMESTEP( DSET_ACTIVITY_ID , INT(ITS+1,4) , NEM , ACTIVITY_ARRAY , ERROR )
IF( ERROR < 0 ) THEN
ERRMSG = "Error in reading activity"
RETURN
END IF
!DIR$ FORCEINLINE
CALL MR_READ_ACTIVITY_UNPACK_FOR_ELEMS
!END$ FORCEINLINE
!***********************************************************************************************************************************
CONTAINS
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_ACTIVITY_UNPACK_FOR_ELEMS
IMPLICIT NONE
INTEGER(IJID_KIND) :: I , J
DO J = 1 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 1 , NI
ACTIVITY( I , J ) = ACTIVITY_ARRAY( EMIDW( I , J ) )
END DO
END DO
END SUBROUTINE MR_READ_ACTIVITY_UNPACK_FOR_ELEMS
END SUBROUTINE MR_READ_ACTIVITY
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_UV( MULTI_DSETS_ID , PATH_UV_IN_MULTI_DSETS , ITS , &
& NND , NEM , NI , NJ , EMIDW , NDIDW , NDIDU , NDIDV , NDIDO , IUV , IUU , IVV , IOO , &
& UV_BASE , UV_REF , UV , U , UU , V , VV , UVO , &
& ACTIVITY , ERROR , ERRMSG )
USE MR_MOD_OPERATOR_UV
IMPLICIT NONE
INTEGER , INTENT(IN ) :: MULTI_DSETS_ID
CHARACTER( * ) , INTENT(IN ) :: PATH_UV_IN_MULTI_DSETS
INTEGER(TSID_KIND) , INTENT(IN ) :: ITS
INTEGER(NDID_KIND) , INTENT(IN ) :: NND
INTEGER(EMID_KIND) , INTENT(IN ) :: NEM
INTEGER(IJID_KIND) , INTENT(IN ) :: NI , NJ
INTEGER(EMID_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,EMID_KIND),1:NJ ) :: EMIDW
INTEGER(NDID_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,NDID_KIND),1:NJ ) :: NDIDW
INTEGER(NDID_KIND) , INTENT(IN ) , DIMENSION(0:NI0(NI,NDID_KIND),1:NJ ) :: NDIDU
INTEGER(NDID_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,NDID_KIND),0:NJ ) :: NDIDV
INTEGER(NDID_KIND) , INTENT(IN ) , DIMENSION(0:NI0(NI,NDID_KIND),0:NJ ) :: NDIDO
REAL (GJRD_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,GJRD_KIND),1:NJ,1:2,1:2) :: IUV
REAL (GJRD_KIND) , INTENT(IN ) , DIMENSION(0:NI0(NI,GJRD_KIND),1:NJ,1:2,1:2) :: IUU
REAL (GJRD_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,GJRD_KIND),0:NJ,1:2,1:2) :: IVV
REAL (GJRD_KIND) , INTENT(IN ) , DIMENSION(0:NI0(NI,GJRD_KIND),0:NJ,1:2,1:2) :: IOO
REAL (PARD_KIND) , INTENT(IN ) :: UV_BASE
REAL (PARD_KIND) , INTENT(IN ) :: UV_REF
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(1:NI1(NI,FDRD_KIND),1:NJ,1:2 ) , OPTIONAL :: UV
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(0:NI0(NI,FDRD_KIND),1:NJ ) , OPTIONAL :: U
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(0:NI0(NI,FDRD_KIND),1:NJ,1:2 ) , OPTIONAL :: UU
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(1:NI1(NI,FDRD_KIND),0:NJ ) , OPTIONAL :: V
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(1:NI1(NI,FDRD_KIND),0:NJ,1:2 ) , OPTIONAL :: VV
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(0:NI0(NI,FDRD_KIND),0:NJ,1:2 ) , OPTIONAL :: UVO
INTEGER(ACID_KIND) , INTENT(OUT) , DIMENSION(1:NI1(NI,ACID_KIND),1:NJ ) , OPTIONAL :: ACTIVITY
REAL (4) , DIMENSION(1:2,1:NND) :: UV_ARRAY
INTEGER :: DSET_UV_ID
INTEGER , INTENT(OUT) :: ERROR
CHARACTER( * ) , INTENT(OUT) :: ERRMSG
INTEGER :: ERROR_DUMMY
ERRMSG = ""
CALL XF_OPEN_GROUP( MULTI_DSETS_ID , TRIM(PATH_UV_IN_MULTI_DSETS) , DSET_UV_ID , ERROR )
IF( ERROR < 0 ) THEN
ERRMSG = "Error in openning vector dataset group"
ELSE
CALL XF_READ_VECTOR_VALUES_TIMESTEP( DSET_UV_ID , INT(ITS+1,4) , NND , 2 , UV_ARRAY , ERROR )
IF( ERROR < 0 ) THEN
ERRMSG = "Error in reading vector values from dataset group"
ELSE
IF( PRESENT( ACTIVITY ) ) THEN
CALL MR_READ_ACTIVITY( DSET_UV_ID , ITS , NEM , NI , NJ , EMIDW , ACTIVITY , ERROR , ERRMSG )
IF( ERROR < 0 ) THEN
ERRMSG = TRIM(ERRMSG)//" from vector dataset group"
END IF
END IF
END IF
CALL XF_CLOSE_GROUP( DSET_UV_ID , ERROR_DUMMY )
IF( ERROR_DUMMY < 0 .AND. ERROR >= 0 ) THEN
ERROR = ERROR_DUMMY
ERRMSG = "Error in closing vector dataset group"
END IF
END IF
IF( ERROR < 0 ) THEN
ERRMSG = TRIM(ERRMSG)//" /"//TRIM(PATH_UV_IN_MULTI_DSETS)//" in multiple datasets"
RETURN
END IF
UV_ARRAY = ( UV_ARRAY - UV_BASE ) / ( UV_REF - UV_BASE )
!DIR$ FORCEINLINE
CALL MR_READ_UV_UNPACK_FOR_W_NODES
!DIR$ FORCEINLINE
CALL MR_READ_UV_UNPACK_FOR_U_NODES
!DIR$ FORCEINLINE
CALL MR_READ_UV_UNPACK_FOR_V_NODES
!DIR$ FORCEINLINE
CALL MR_READ_UV_UNPACK_FOR_O_NODES
!END$ FORCEINLINE
!***********************************************************************************************************************************
CONTAINS
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_UV_UNPACK_FOR_W_NODES
IMPLICIT NONE
INTEGER(IJID_KIND) :: I , J
INTEGER :: DIM
IF( PRESENT( UV ) ) THEN
DO DIM = 1 , 2
DO J = 1 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 1 , NI
UV( I , J ,DIM) = UV_ARRAY(DIM, NDIDW( I , J ) )
END DO
END DO
END DO
UV = IUV .MRUVTFM. UV
END IF
END SUBROUTINE MR_READ_UV_UNPACK_FOR_W_NODES
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_UV_UNPACK_FOR_U_NODES
IMPLICIT NONE
REAL (FDRD_KIND) , ALLOCATABLE , DIMENSION( : , : , : ) :: UT
INTEGER(IJID_KIND) :: I , J
INTEGER :: DIM
IF( PRESENT( UU ) ) THEN
DO DIM = 1 , 2
DO J = 1 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 0 , NI
UU( I , J ,DIM) = UV_ARRAY(DIM, NDIDU( I , J ) )
END DO
END DO
END DO
UU = IUU .MRUVTFM. UU
IF( PRESENT( U ) ) THEN
DO J = 1 , NJ
!DIR$ VECTOR ALIGNED
DO I = 0 , NI
U( I , J ) = UU( I , J ,1)
END DO
END DO
END IF
ELSE IF( PRESENT( U ) ) THEN
ALLOCATE( UT(0:NI0(NI,FDRD_KIND),1:NJ,1:2) )
DO DIM = 1 , 2
DO J = 1 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 0 , NI
UT( I , J ,DIM) = UV_ARRAY(DIM, NDIDU( I , J ) )
END DO
END DO
END DO
UT = IUU .MRUVTFM. UT
DO J = 1 , NJ
!DIR$ VECTOR ALIGNED
DO I = 0 , NI
U( I , J ) = UT( I , J ,1)
END DO
END DO
DEALLOCATE( UT )
END IF
END SUBROUTINE MR_READ_UV_UNPACK_FOR_U_NODES
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_UV_UNPACK_FOR_V_NODES
IMPLICIT NONE
REAL (FDRD_KIND) , ALLOCATABLE , DIMENSION( : , : , : ) :: VT
INTEGER(IJID_KIND) :: I , J
INTEGER :: DIM
IF( PRESENT( VV ) ) THEN
DO DIM = 1 , 2
DO J = 0 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 1 , NI
VV( I , J ,DIM) = UV_ARRAY(DIM, NDIDV( I , J ) )
END DO
END DO
END DO
VV = IVV .MRUVTFM. VV
IF( PRESENT( V ) ) THEN
DO J = 0 , NJ
!DIR$ VECTOR ALIGNED
DO I = 1 , NI
V( I , J ) = VV( I , J ,2)
END DO
END DO
END IF
ELSE IF( PRESENT( V ) ) THEN
ALLOCATE( VT(1:NI1(NI,FDRD_KIND),0:NJ,1:2) )
DO DIM = 1 , 2
DO J = 0 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 1 , NI
VT( I , J ,DIM) = UV_ARRAY(DIM, NDIDV( I , J ) )
END DO
END DO
END DO
VT = IVV .MRUVTFM. VT
DO J = 0 , NJ
!DIR$ VECTOR ALIGNED
DO I = 1 , NI
V( I , J ) = VT( I , J ,2)
END DO
END DO
DEALLOCATE( VT )
END IF
END SUBROUTINE MR_READ_UV_UNPACK_FOR_V_NODES
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_UV_UNPACK_FOR_O_NODES
IMPLICIT NONE
INTEGER(IJID_KIND) :: I , J
INTEGER :: DIM
IF( PRESENT( UVO ) ) THEN
DO DIM = 1 , 2
DO J = 0 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 0 , NI
UVO( I , J ,DIM) = UV_ARRAY(DIM, NDIDO( I , J ) )
END DO
END DO
END DO
UVO = IOO .MRUVTFM. UVO
END IF
END SUBROUTINE MR_READ_UV_UNPACK_FOR_O_NODES
END SUBROUTINE MR_READ_UV
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_SS( MULTI_DSETS_ID , PATH_SS_IN_MULTI_DSETS , ITS , &
& NND , NEM , NI , NJ , EMIDW , NDIDW , NDIDU , NDIDV , NDIDO , &
& SS_BASE , SS_REF , SS , SU , SV , SO , &
& ACTIVITY , ERROR , ERRMSG )
IMPLICIT NONE
INTEGER , INTENT(IN ) :: MULTI_DSETS_ID
CHARACTER( * ) , INTENT(IN ) :: PATH_SS_IN_MULTI_DSETS
INTEGER(TSID_KIND) , INTENT(IN ) :: ITS
INTEGER(NDID_KIND) , INTENT(IN ) :: NND
INTEGER(EMID_KIND) , INTENT(IN ) :: NEM
INTEGER(IJID_KIND) , INTENT(IN ) :: NI , NJ
INTEGER(EMID_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,EMID_KIND),1:NJ) :: EMIDW
INTEGER(NDID_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,NDID_KIND),1:NJ) :: NDIDW
INTEGER(NDID_KIND) , INTENT(IN ) , DIMENSION(0:NI0(NI,NDID_KIND),1:NJ) :: NDIDU
INTEGER(NDID_KIND) , INTENT(IN ) , DIMENSION(1:NI1(NI,NDID_KIND),0:NJ) :: NDIDV
INTEGER(NDID_KIND) , INTENT(IN ) , DIMENSION(0:NI0(NI,NDID_KIND),0:NJ) :: NDIDO
REAL (PARD_KIND) , INTENT(IN ) :: SS_BASE
REAL (PARD_KIND) , INTENT(IN ) :: SS_REF
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(1:NI1(NI,FDRD_KIND),1:NJ) , OPTIONAL :: SS
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(0:NI0(NI,FDRD_KIND),1:NJ) , OPTIONAL :: SU
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(1:NI1(NI,FDRD_KIND),0:NJ) , OPTIONAL :: SV
REAL (FDRD_KIND) , INTENT(OUT) , DIMENSION(0:NI0(NI,FDRD_KIND),0:NJ) , OPTIONAL :: SO
INTEGER(ACID_KIND) , INTENT(OUT) , DIMENSION(1:NI1(NI,ACID_KIND),1:NJ) , OPTIONAL :: ACTIVITY
REAL (4) , DIMENSION(1:NND) :: SS_ARRAY
INTEGER :: DSET_SS_ID
INTEGER , INTENT(OUT) :: ERROR
CHARACTER( * ) , INTENT(OUT) :: ERRMSG
INTEGER :: ERROR_DUMMY
ERRMSG = ""
CALL XF_OPEN_GROUP( MULTI_DSETS_ID , TRIM(PATH_SS_IN_MULTI_DSETS) , DSET_SS_ID , ERROR )
IF( ERROR < 0 ) THEN
ERRMSG = "Error in openning scalar dataset group"
ELSE
CALL XF_READ_SCALAR_VALUES_TIMESTEP( DSET_SS_ID , INT(ITS+1,4) , NND , SS_ARRAY , ERROR )
IF( ERROR < 0 ) THEN
ERRMSG = "Error in reading scalar values from dataset group"
ELSE
IF( PRESENT( ACTIVITY ) ) THEN
CALL MR_READ_ACTIVITY( DSET_SS_ID , ITS , NEM , NI , NJ , EMIDW , ACTIVITY , ERROR , ERRMSG )
IF( ERROR < 0 ) THEN
ERRMSG = TRIM(ERRMSG)//" from scalar dataset group"
END IF
END IF
END IF
CALL XF_CLOSE_GROUP( DSET_SS_ID , ERROR_DUMMY )
IF( ERROR_DUMMY < 0 .AND. ERROR >= 0 ) THEN
ERROR = ERROR_DUMMY
ERRMSG = "Error in closing scalar dataset group"
END IF
END IF
IF( ERROR < 0 ) THEN
ERRMSG = TRIM(ERRMSG)//" /"//TRIM(PATH_SS_IN_MULTI_DSETS)//" in multiple datasets"
RETURN
END IF
SS_ARRAY = ( SS_ARRAY - SS_BASE ) / ( SS_REF - SS_BASE )
!DIR$ FORCEINLINE
CALL MR_READ_SS_UNPACK_FOR_W_NODES
!DIR$ FORCEINLINE
CALL MR_READ_SS_UNPACK_FOR_U_NODES
!DIR$ FORCEINLINE
CALL MR_READ_SS_UNPACK_FOR_V_NODES
!DIR$ FORCEINLINE
CALL MR_READ_SS_UNPACK_FOR_O_NODES
!END$ FORCEINLINE
!***********************************************************************************************************************************
CONTAINS
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_SS_UNPACK_FOR_W_NODES
IMPLICIT NONE
INTEGER(IJID_KIND) :: I , J
IF( PRESENT( SS ) ) THEN
DO J = 1 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 1 , NI
SS( I , J ) = SS_ARRAY( NDIDW( I , J ) )
END DO
END DO
END IF
END SUBROUTINE MR_READ_SS_UNPACK_FOR_W_NODES
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_SS_UNPACK_FOR_U_NODES
IMPLICIT NONE
INTEGER(IJID_KIND) :: I , J
IF( PRESENT( SU ) ) THEN
DO J = 1 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 0 , NI
SU( I , J ) = SS_ARRAY( NDIDU( I , J ) )
END DO
END DO
END IF
END SUBROUTINE MR_READ_SS_UNPACK_FOR_U_NODES
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_SS_UNPACK_FOR_V_NODES
IMPLICIT NONE
INTEGER(IJID_KIND) :: I , J
IF( PRESENT( SV ) ) THEN
DO J = 0 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 1 , NI
SV( I , J ) = SS_ARRAY( NDIDV( I , J ) )
END DO
END DO
END IF
END SUBROUTINE MR_READ_SS_UNPACK_FOR_V_NODES
!***********************************************************************************************************************************
! UNIT:
!
! (SUBROUTINE)
!
! PURPOSE:
!
!
!
! DEFINITION OF VARIABLES:
!
!
!
! RECORD OF REVISIONS:
!
! DATE | PROGRAMMER | DESCRIPTION OF CHANGE
! ==== | ========== | =====================
! 20XX-XX-XX | DR. HYDE | ORIGINAL CODE.
!
!***********************************************************************************************************************************
SUBROUTINE MR_READ_SS_UNPACK_FOR_O_NODES
IMPLICIT NONE
INTEGER(IJID_KIND) :: I , J
IF( PRESENT( SO ) ) THEN
DO J = 0 , NJ
!DIR$ VECTOR ALIGNED, ALWAYS
DO I = 0 , NI
SO( I , J ) = SS_ARRAY( NDIDO( I , J ) )
END DO
END DO
END IF
END SUBROUTINE MR_READ_SS_UNPACK_FOR_O_NODES
END SUBROUTINE MR_READ_SS
END MODULE MR_MOD_READ_FIELD_VARS_N_ACTIVITY | __Sources/MR_MOD_FILE_MANIPULATIONS/MR_MOD_FILE_XMDF_MANIPULATIONS/MR_MOD_MULTI_DSETS_FROM_READ_FIELD_VARS_N_ACTIVITY.f90 |
The Magic Unicorn Rider rides one of Daviss unique vehicles and can be seen zipping along streets and sidewalks all over downtown and on the UCD campus. Hell even go inside of places, such as the UCD MU Coffee House, cafes, restaurants, and bars. The Magic Unicorn Ride is a small electric vehicle equipped with a high fidelity music system, rainbow chasing lights, powerful electric motors, independent differential drive, and a highspeed precision motion control system that allows the vehicle to spin around on its center axis, stop on a dime, dance around, and is capable of rearing up like a real unicorn due to its rapid acceleration. Its battery system has a range of approximately 18 miles on a charge and powers the sound system and special effects lighting using high efficiency DCDC converters. It is designed and built by its rider, artist/engineer/music composer/technology historian Mark Chang, a UCD graduate and local resident. Construction was complete in August 2011.
If you have pictures to share or would just like to get to know the Magic Unicorn Rider, please send him an email (with pictures if you have them), facebook tag him, etc. at MagicUnicornRider@gmail.com
Video Footage
http://www.youtube.com/watch?vJatYCjvPcfk
http://www.youtube.com/watch?vqehZL2BhsgM
http://www.youtube.com/watch?vctD5B641X9c
20120421 10:57:39 nbsp I would totally ride that magical unicorn. Users/jefftolentino
20120421 14:59:14 nbsp I need to build one so we can have races. Users/JimStewart
20120421 15:59:11 nbsp Do you have any build notes or anything of the sort? Id like a peek under the hood! Users/WilliamLewis
20120421 18:57:47 nbsp That is awesome. Users/jsbmeb
20120421 23:40:44 nbsp I saw this zipping around in downtown during picnic day. A lot of people were talking photos with the unicorn. Users/SimonFung
20120423 01:04:50 nbsp My friend rode the magical unicorn at picnic day!! http://www.youtube.com/watch?vC5sIliL7id4 Users/MichellePacheco
20120423 17:13:06 nbsp what is the top speed? It looks like it books Users/StevenDaubert
20120424 05:03:35 nbsp Will, hopefully, be more mindful of the public, the law, and the safety of others along with his own in the future. Weaving in and out of traffic on G St., a rider fell off, was nearly hit by an oncoming car and then he just takes off... quirky, semigenius aside, seems to have no regard for others or for the law. Users/WesP
20120425 04:59:46 nbsp WesP, thank you for your concerns. I have a perfect safety record riding the magic unicorn out of approximately 60 hours total run time. The incident you mentioned on G Street involved a person who had been drinking alcohol and attempted to sit on the rear of the unicorn without my permission. The added weight caused the ride to tip rearward thus dumping the passenger. This occurred to the side of the road where bicycles normally ride, and I did turn around immediately to make sure that the passenger was OK (she was laughing). She was not nearly hit by an oncoming car. Rather, a car passed us slowly. I do not weave in and out of traffic when riding the unicorn. I follow all traffic rules, stopping at stop signs and signal lights, looking in all directions. I slow down considerably when giving rides to a few approved, sober passengers. The whole purpose of riding the unicorn is to share a magical experience with other people. They frequently tell me that Ive made their day or cheered them up. I am always completely sober and alert when riding it and have extremely accurate control of its motion at all times. The unicorn is meticulously maintained and safety checked before every ride. I just want to set the record straight that in no way am I simply gallavanting around with no regard for others or for the law. Users/MarkChang
& Wes gets served Daubert
20120816 17:34:41 nbsp The Magic Unicorn Rider is awesome, some day I hope to take a spin on it. Also, it is the featured picture for the Aug 16th caption contest on Dlisted: http://www.dlisted.com/2012/08/16/captioncontestaugust16th I hope they are kind and make it all the more magical (though it is dlisted so probably not). LUpton Users/LUpton
20121119 07:42:03 nbsp After having seen this unicorn rider several more times, in addition to speaking with the driver (unbeknownst.to him), I have found my earlier comment to be a one time fluke and applaud him for attempting to bring a small amount of joy to those he encounters. Users/WesP
20121119 17:14:40 nbsp An internet argument, resolved peacefully and cheerfully by happy agreement on all sides? Hooray; its a Thanksgiving miracle! Pumpkin pie and tiny trophies for everyone! Users/BarnabasTruman
20130921 14:20:23 nbsp It cracks me up how this thing can rear up on its hind legs like a real unicorn. Users/GenevaDuren
20131012 13:26:49 nbsp Just saw the magic pink unicorn in all its glory near the Domes Users/StevenDaubert
| lab/davisWiki/Magic_Unicorn_Rider.f |
! ------------------------------------------------------------------------------
! COMP_SEMI_IMPLICIT_QUANTITIES
! computes the values of quantities that are updated in between
! iterations of the solver (hence semi-implicit).
! ------------------------------------------------------------------------------
! Input:
! // - H and DH
! Output:
! ddXn - Second order corrections to diffusion equation of species n
! Returns:
! true if the implicit quantities were updated and the iteration can be
! considered "converged", or "false" if more iterations are needed (for
! instance because the change in implicit functions is still large)
! ------------------------------------------------------------------------------
logical function comp_semi_implicit_quantities()
use real_kind
use mesh
use semi_implicit_variables
use control
use interpolate
use distortion
use constants
use settings
use indices
use roche
use structure_functions
use eostate_types
implicit none
! Local variables:
type(eostate) :: eos
real(double) :: var(Nvar)
real(double) :: rho(KH, 2), p(KH, 2), rr(KH, 2), m(KH, 2), cs(KH, 2)
real(double) :: r0(KH), sigma_rot(KH), mu_rot(KH), sigma(KH,2:4), mu(KH,2:4)
real(double) :: avgg(KH), invg(KH), spsi(KH)
real(double) :: fu2(2,KH), fv(2, KH), omega(KH, 2)
real(double) :: fn(NFUNC)
real(double) :: a_orb, oa, mp(2), phi_l1, phi_l2, RL, RL2, phi_scale, po, q, rossby, thetaf
real(double) :: delta_phi(2)
integer :: k, kk, Jstar
real(double) :: old_fp_star(NM, 2)
real(double) :: old_ft_star(NM, 2)
real(double) :: old_Vmc2_star(NM, 2)
real(double) :: old_diff_omega(NM, 2)
real(double) :: max_Vmc2, max_domega, epsilon
logical, parameter :: monitor_convergence = .false.
real(double) :: phi(NM, 2), ent(KH, 2), hp(KH, 2)
real(double) :: mdot(2), old_mdot(2)
real(double) :: ent_l1(2), cs_l1(2), vm, xx, fac, fac1, fac2, rrho, oenth, ell
real(double) :: m1, m2
type(interpolate_t) :: enthalpy(2), sound_speed, pressure(2), density(2)
comp_semi_implicit_quantities = .true.
var(:) = H(:, 1) + dh(:, 1)
oa = var(VAR_HORB)
mp(1) = var(VAR_PMASS)
mp(2) = var(VAR_BMASS) - mp(1)
a_orb = oa*oa*(mp(1) + mp(2))/(mp(1)*mp(2)*cg1)**2
! Potential at L1, L2
m1 = max(mp(1), mp(2))
m2 = min(mp(1), mp(2))
phi_l1 = calc_scaled_potential(m1, m2, calc_scaled_xl1(m1, m2), 0.0d0, 0.0d0)
phi_l2 = calc_scaled_potential(m1, m2, calc_scaled_xl2(m1, m2), 0.0d0, 0.0d0)
!if (ktw == 1) mp(2) = 0.0d0
!print *, calc_scaled_xl1(mp(1), mp(2)), calc_scaled_xl1(mp(2), mp(1))
!print *, calc_scaled_potential(mp(1), mp(2), calc_scaled_xl1(mp(1), mp(2)), 0.0d0, 0.0d0)
!print *, calc_scaled_potential(mp(2), mp(1), calc_scaled_xl1(mp(2), mp(1)), 0.0d0, 0.0d0)
!print *, phi_l1
!stop
old_mdot = mdot_rlof
if (monitor_convergence) then
old_fp_star = fp_star
old_ft_star = ft_star
old_Vmc2_star = Vmc2_star
old_diff_omega = diff_omega
max_Vmc2 = 1.0d0
max_domega = 1.0d0
end if
! Break out now if we don't need to calculate detailed properties at each grid point
if (.not. use_contact_flow .and. .not. use_clairaut_distortion) return
! Stellar properties at each gridpoint
do k=1, kh
var(:) = H(:, k) + dh(:, k)
call funcs1(k, 0, var(:), DH(:, k), fn, eos)
!print *, k, (fn(FN_PHI_ROCHE) - phi_l1) * CG*(mp(1)+mp(2))/a_orb*1.0d22, fn(FN_ENT)
do Jstar = 1, ktw
phi(k, Jstar) = fn(fn_idx_for_star(FN_PHI_ROCHE, Jstar))
ent(k, Jstar) = fn(fn_idx_for_star(FN_ENT, Jstar))
fv(Jstar, k) = fn(fn_idx_for_star(FN_FV, Jstar))
fu2(Jstar, k) = fn(fn_idx_for_star(FN_FU2K, Jstar))
rho(k, Jstar) = fn(fn_idx_for_star(FN_RHO, Jstar))
p(k, Jstar) = fn(fn_idx_for_star(FN_P, Jstar))
cs(k, Jstar) = eos%gamma1 * eos%p / eos%rho
omega(k, Jstar) = H(idx_for_star(VAR_OMEGA, Jstar), k)
m(k, Jstar) = H(idx_for_star(VAR_MASS, Jstar), k)
rr(k, Jstar) = sqrt(max(exp(2.0d0 * H(idx_for_star(VAR_LNR, Jstar), k)) - CT(8), 0.0d0))
hp(k, Jstar) = fn(fn_idx_for_star(FN_HP, Jstar))
end do
end do
! Horizontal component of meridional circulation
do k=2, kh-1
do Jstar=1, ktw
Vmc2_star(k, Jstar) = fv(Jstar,k) * (fu2(Jstar, k) - fu2(Jstar, k+1))
diff_omega(k, Jstar) = 0.5d0 * (omega(k+1, Jstar) - omega(k-1, Jstar))
end do
end do
Vmc2_star(1, :) = 0.0d0
Vmc2_star(kh, :) = 0.0d0
diff_omega(1, Jstar) = (omega(2, Jstar) - omega(1, Jstar))
diff_omega(kh, Jstar) = (omega(kh, Jstar) - omega(kh-1, Jstar))
! Calculate the shape of the stars, from the multipole expansion of the gravitational potential.
if (use_clairaut_distortion) then
ft_star(1:kh,1:KTW) = 1.0
fp_star(1:kh,1:KTW) = 1.0
do Jstar=1, ktw
m(kh, Jstar) = m(kh-1, Jstar) ! Avoid singularity at m = 0
rr(kh, Jstar) = rr(kh-1, Jstar) ! Avoid singularity at r = 0
call calculate_distortion_coefficients(kh, rho(:,Jstar), rr(:,Jstar), m(:,Jstar), omega(:,Jstar), mp(3-Jstar), a_orb,&
r0, a_rot2(1:kh,Jstar), a_tide(1:kh,2:4,Jstar), &
sigma_rot, mu_rot, sigma, mu)
call calculate_effective_gravity(kh, rr(:,Jstar), m(:,Jstar), omega(:,Jstar), mp(3-Jstar), a_orb, &
r0, a_rot2(1:kh,Jstar), a_tide(1:kh,2:4,Jstar), &
sigma_rot, mu_rot, sigma, mu, &
avgg, invg, spsi, fp_star(1:kh,Jstar), ft_star(1:kh,Jstar))
r0_over_rv(1:KH-1, Jstar) = r0(1:KH-1) / rr(1:KH-1, Jstar)
r0_over_rv(KH, Jstar) = 1.0d0
end do
else
r0_over_rv = 1.0d0
a_rot2 = 0.0d0
a_tide = 0.0d0
end if
! Calculate mass transfer, both semi-detached and in contact
! We obviously need to be doing a binary in TWIN mode for this to make sense
mdot_rlof = 0.0d0
if (ktw == 2 .and. use_contact_flow .and. (phi(1,1) <= phi_l1 .or. phi(1,2) <= phi_l1)) then
call make_interpolation_table(kh, phi(:, 1), ent(:, 1), enthalpy(1))
call make_interpolation_table(kh, phi(:, 2), ent(:, 2), enthalpy(2))
call make_interpolation_table(kh, phi(:, 1), cs(:, 1), sound_speed)
call make_interpolation_table(kh, phi(:, 1), p(:, 1), pressure(1))
call make_interpolation_table(kh, phi(:, 2), p(:, 2), pressure(2))
call make_interpolation_table(kh, phi(:, 1), rho(:, 1), density(1))
call make_interpolation_table(kh, phi(:, 2), rho(:, 2), density(2))
ent_l1 = 0.0d0
cs_l1 = 0.0d0
! Calculate sound speed and enthalpy in L1
if (phi(1, 1) <= phi_l1) then
ent_l1(1) = evaluate_interpolation_table(phi_l1, enthalpy(1))
cs_l1(1) = evaluate_interpolation_table(phi_l1, sound_speed)
end if
if (phi(1, 2) <= phi_l1) then
call update_interpolation_table(kh, phi(:, 2), cs(:, 2), sound_speed)
ent_l1(2) = evaluate_interpolation_table(phi_l1, enthalpy(2))
cs_l1(2) = evaluate_interpolation_table(phi_l1, sound_speed)
end if
! The scale factor for the potential function, give results in CGS units (erg/g)
phi_scale = CG*(mp(1)+mp(2))/a_orb*1.0d22
! Mass ratio, in the sense of (least massive) / (most massive)
q = mp(2) / mp(1)
if (q > 1.0d0) q = mp(1) / mp(2)
! Calculate the mass and energy flows in both components
mdot = 0.0d0
do Jstar=1, ktw
do k=1, kh
! Test whether this grid point overflows the critical lobe
if (phi(k, Jstar) <= phi_l1) then
! Test whether we are within the shared envelope or not. This changes the calculation of the flow velocity:
! if we are not in the shared envelope, then we have a free expansion through the surface through L1 and L1 is a sonic
! point in the flow. If we are in the shared envelope the velocity field is determined by the continuity equation.
! The direction of the flow is determined by the horizontal pressure gradient.
! In either case we use Bernoulli's equation to calculate the velocity at the current point.
po = 0.0d0
vm = 0.0d0
if (phi(k, Jstar) >= phi(1, 3-Jstar)) then ! Contact
po = evaluate_interpolation_table(phi(k,Jstar), pressure(3-Jstar))
rrho = evaluate_interpolation_table(phi(k,Jstar), density(3-Jstar))
oenth = evaluate_interpolation_table(phi(k,Jstar), enthalpy(3-Jstar))
vm = rrho**2 * 2.d0 * abs((ent(k, Jstar) - oenth) / (rrho**2 - rho(k, Jstar)**2))
else ! No contact
vm = cs(k, Jstar)
end if
! Because of the distortion near L1, the density at the isobars is different (much lower) than the density far from
! L1. The following is an approximation to the expansion factor based on fits to Roche geometry; this depends on the
! mass ratio and the (dimensionless) value of the potential excess.
! Because we use different fits for the primary (most massive) and secondary (least massive) component that are not
! exactly equal at q=1 we do a smooth interpolation between the two near q=1.
xx = (phi(k,Jstar) - phi_l1) / (phi_l2 - phi_l1) ! Dimensionless coordinate of potential
if (mp(Jstar) > mp(3-Jstar)) then ! Currently most massive component
if (q > 0.95) then ! Nearly equal masses, do a smooth transition between the two interpolations
fac1 = stream_cross_section_primary(q, xx)
fac2 = 0.5d0 * (fac1 + stream_cross_section_secondary(q, xx))
fac = fac1 + (q - 0.95) * (fac2 - fac1) / 0.05
!fac = 0.5 * ((2.0d0 - q) * stream_cross_section_primary(q, xx) + q * stream_cross_section_secondary(q, xx))
else
fac = stream_cross_section_primary(q, xx)
end if
else
if (q > 0.95) then ! Nearly equal masses, do a smooth transition between the two interpolations
fac1 = stream_cross_section_secondary(q, xx)
fac2 = 0.5d0 * (stream_cross_section_primary(q, xx) + fac1)
fac = fac1 + (q - 0.95) * (fac2 - fac1) / 0.05
!fac = 0.5 * (q * stream_cross_section_primary(q, xx) + (2.0d0 - q) * stream_cross_section_secondary(q, xx))
else
fac = stream_cross_section_secondary(q, xx)
end if
end if
! Mass flow follows the pressure gradient
Rossby = 0.0d0
thetaf = 0.0d0
if (vm > 0.0d0 .and. p(k,Jstar) > po) then
vm = sqrt(vm)
mdot(Jstar) = mdot(Jstar) + fac*rho(k, Jstar) * vm * a_orb**2 * (phi(k, Jstar) - phi(k+1, Jstar)) * 1.0d-11
! Calculate the Rosby number associated with the flow; this determines the opening angle of the tidal stream
! The scale-height is set to the pressure scale hight here. An alternative is the size of the star, which is
! typically much larger and so produces a much smaller Rossby number.
ell = hp(k, Jstar)
!ell = 1.0d11 * rr(k, Jstar)
Rossby = vm / (2.d0 * omega(k, Jstar) * ell)
! Width (in radians) of the geostrophic flow in a contact system
thetaf = acos(Rossby / (Rossby + 1.0d0))
! Calculate coefficients in the energy transport equation
end if
!write (*, '(1x,1p,I3,I3,10E18.10)') Jstar, k, xx, sqrt(vm), sqrt(cs(k, Jstar)), sqrt(vm/cs(k, Jstar)), p(k, Jstar), &
! po, rho(k, Jstar), mdot(Jstar) * CSY/CMSN, Rossby, thetaf
end if
end do
end do
! Translate the energy flow in a sequence of source/sink terms
! Calculate the with and temperature of the tidal stream
!RL = a_orb * rlobe((mp(1)/mp(2))**(1./3.))
!RL2 = a_orb * rlobe((mp(2)/mp(1))**(1./3.))
!print *, sqrt(cs_l1(1)), sqrt(cs_l1(2))
!print *, mp(1)/ mp(2), RL, rr(1,1)
!print *, mp(1)/ mp(2), RL2, rr(1,2)
!RL = (max(rr(1,1)-RL, 0.0d0)/RL)**3
!print *, mdot(1) * CSY / CMSN,&
! RL * rho(1,1) / (5./3. * p(1, 1) / rho(1, 1))**1.5*(CG*1.0d33*(mp(1)+mp(2)))**2 / (CMSN*1.0d33)*CSY,&
! RL*mp(1)/sqrt(CG * rho(1,1)) * CSY / CMSN*1.0d-11, RL
!print *, 1, phi_l1, phi(1, 1)!, phi_l2
!print *, 2, phi_l1, phi(1, 2)!, phi_l2
!if (phi(1, 1) <= phi_l1 .and. phi(1, 2) <= phi_l1) print *, 'Contact'
!print *, ''
if (monitor_convergence) then
do k=1, kh
do Jstar=1, ktw
if (abs(diff_omega(k, Jstar)) > max_domega) max_domega = abs(diff_omega(k, Jstar))
if (abs(Vmc2_star(k, Jstar)) > max_Vmc2) max_Vmc2 = abs(Vmc2_star(k, Jstar))
end do
end do
do k=1, kh
do Jstar=1, ktw
epsilon = epsilon + abs(diff_omega(k, Jstar) - old_diff_omega(k, Jstar)) / max_domega
epsilon = epsilon + abs(Vmc2_star(k, Jstar) - Vmc2_star(k, Jstar)) / max_Vmc2
epsilon = epsilon + abs(fp_star(k, Jstar) - old_fp_star(k, Jstar))
epsilon = epsilon + abs(ft_star(k, Jstar) - old_ft_star(k, Jstar))
end do
end do
epsilon = epsilon / (ktw * kh * 4)
write (1, *) 'Explicit epsilon = ', log10(epsilon + 1.0d-16)
end if
! Store actual mass loss rate
mdot_rlof0 = mdot
! Extract coefficient for scaling relation
delta_phi(1) = max(phi_l1 - phi(1, 1), 0.d0)
delta_phi(2) = max(phi_l1 - phi(1, 2), 0.d0)
where (delta_phi > 0.0d0) mdot = mdot / delta_phi**2.5
epsilon = abs(mdot(1) - old_mdot(1))/(abs(old_mdot(1))+1.0d-32) + abs(mdot(2) - old_mdot(2))/(abs(old_mdot(2))+1.0d-32)
write (1, *) 'Explicit epsilon = ', log10(epsilon + 1.0d-16)
write (1, '(1x,1p,4e12.4)') mdot(1) * CSY / CMSN, mdot(2) * CSY / CMSN, old_mdot(1) * CSY / CMSN, old_mdot(2) * CSY / CMSN
!if (abs(mdot(1) - mdot_rlof(1)) > 0.05d0 * mdot_rlof(1)) then
if (epsilon > 1.0d-2 .and. abs(mdot(1)) > abs(old_mdot(1))) then
if (abs(old_mdot(1)) > 0.0d0) mdot = 0.5d0 * mdot + 0.5 * old_mdot
comp_semi_implicit_quantities = .false.
end if
if (epsilon < 1.0d-4) mdot = old_mdot ! Hack: don't update if accurate enough
write (1, *) comp_semi_implicit_quantities
call destroy_interpolation_table(sound_speed)
call destroy_interpolation_table(enthalpy(1))
call destroy_interpolation_table(enthalpy(2))
call destroy_interpolation_table(density(1))
call destroy_interpolation_table(density(2))
call destroy_interpolation_table(pressure(1))
call destroy_interpolation_table(pressure(2))
mdot_rlof = mdot
end if
contains
! ------------------------------------------------------------------------------
! FRACSTEP
! ------------------------------------------------------------------------------
! Input:
! F - Numerator of fraction to be caculated
! G - Denominator of fraction to be calculated
! Returns:
! F/G if F>0, 0 otherwise
! ------------------------------------------------------------------------------
pure function fracstep (f, g)
use real_kind
implicit none
real(double), intent(in) :: f, g
real(double) :: fracstep
fracstep = 0.0d0
if (f > 0.0d0) fracstep = f / g
end function fracstep
end function comp_semi_implicit_quantities
| src/amuse/community/evtwin/src/trunk/code/semi_implicit.f90 |
*DECK DBSI0E
DOUBLE PRECISION FUNCTION DBSI0E (X)
C***BEGIN PROLOGUE DBSI0E
C***PURPOSE Compute the exponentially scaled modified (hyperbolic)
C Bessel function of the first kind of order zero.
C***LIBRARY SLATEC (FNLIB)
C***CATEGORY C10B1
C***TYPE DOUBLE PRECISION (BESI0E-S, DBSI0E-D)
C***KEYWORDS EXPONENTIALLY SCALED, FIRST KIND, FNLIB,
C HYPERBOLIC BESSEL FUNCTION, MODIFIED BESSEL FUNCTION,
C ORDER ZERO, SPECIAL FUNCTIONS
C***AUTHOR Fullerton, W., (LANL)
C***DESCRIPTION
C
C DBSI0E(X) calculates the double precision exponentially scaled
C modified (hyperbolic) Bessel function of the first kind of order
C zero for double precision argument X. The result is the Bessel
C function I0(X) multiplied by EXP(-ABS(X)).
C
C Series for BI0 on the interval 0. to 9.00000E+00
C with weighted error 9.51E-34
C log weighted error 33.02
C significant figures required 33.31
C decimal places required 33.65
C
C Series for AI0 on the interval 1.25000E-01 to 3.33333E-01
C with weighted error 2.74E-32
C log weighted error 31.56
C significant figures required 30.15
C decimal places required 32.39
C
C Series for AI02 on the interval 0. to 1.25000E-01
C with weighted error 1.97E-32
C log weighted error 31.71
C significant figures required 30.15
C decimal places required 32.63
C
C***REFERENCES (NONE)
C***ROUTINES CALLED D1MACH, DCSEVL, INITDS
C***REVISION HISTORY (YYMMDD)
C 770701 DATE WRITTEN
C 890531 Changed all specific intrinsics to generic. (WRB)
C 890531 REVISION DATE from Version 3.2
C 891214 Prologue converted to Version 4.0 format. (BAB)
C***END PROLOGUE DBSI0E
DOUBLE PRECISION X, BI0CS(18), AI0CS(46), AI02CS(69),
1 XSML, Y, D1MACH, DCSEVL
LOGICAL FIRST
SAVE BI0CS, AI0CS, AI02CS, NTI0, NTAI0, NTAI02, XSML, FIRST
DATA BI0CS( 1) / -.7660547252 8391449510 8189497624 3285 D-1 /
DATA BI0CS( 2) / +.1927337953 9938082699 5240875088 1196 D+1 /
DATA BI0CS( 3) / +.2282644586 9203013389 3702929233 0415 D+0 /
DATA BI0CS( 4) / +.1304891466 7072904280 7933421069 1888 D-1 /
DATA BI0CS( 5) / +.4344270900 8164874513 7868268102 6107 D-3 /
DATA BI0CS( 6) / +.9422657686 0019346639 2317174411 8766 D-5 /
DATA BI0CS( 7) / +.1434006289 5106910799 6209187817 9957 D-6 /
DATA BI0CS( 8) / +.1613849069 6617490699 1541971999 4611 D-8 /
DATA BI0CS( 9) / +.1396650044 5356696994 9509270814 2522 D-10 /
DATA BI0CS( 10) / +.9579451725 5054453446 2752317189 3333 D-13 /
DATA BI0CS( 11) / +.5333981859 8625021310 1510774400 0000 D-15 /
DATA BI0CS( 12) / +.2458716088 4374707746 9678591999 9999 D-17 /
DATA BI0CS( 13) / +.9535680890 2487700269 4434133333 3333 D-20 /
DATA BI0CS( 14) / +.3154382039 7214273367 8933333333 3333 D-22 /
DATA BI0CS( 15) / +.9004564101 0946374314 6666666666 6666 D-25 /
DATA BI0CS( 16) / +.2240647369 1236700160 0000000000 0000 D-27 /
DATA BI0CS( 17) / +.4903034603 2428373333 3333333333 3333 D-30 /
DATA BI0CS( 18) / +.9508172606 1226666666 6666666666 6666 D-33 /
DATA AI0CS( 1) / +.7575994494 0237959427 2987203743 8 D-1 /
DATA AI0CS( 2) / +.7591380810 8233455072 9297873320 4 D-2 /
DATA AI0CS( 3) / +.4153131338 9237505018 6319749138 2 D-3 /
DATA AI0CS( 4) / +.1070076463 4390730735 8242970217 0 D-4 /
DATA AI0CS( 5) / -.7901179979 2128946607 5031948573 0 D-5 /
DATA AI0CS( 6) / -.7826143501 4387522697 8898980690 9 D-6 /
DATA AI0CS( 7) / +.2783849942 9488708063 8118538985 7 D-6 /
DATA AI0CS( 8) / +.8252472600 6120271919 6682913319 8 D-8 /
DATA AI0CS( 9) / -.1204463945 5201991790 5496089110 3 D-7 /
DATA AI0CS( 10) / +.1559648598 5060764436 1228752792 8 D-8 /
DATA AI0CS( 11) / +.2292556367 1033165434 7725480285 7 D-9 /
DATA AI0CS( 12) / -.1191622884 2790646036 7777423447 8 D-9 /
DATA AI0CS( 13) / +.1757854916 0324098302 1833124774 3 D-10 /
DATA AI0CS( 14) / +.1128224463 2189005171 4441135682 4 D-11 /
DATA AI0CS( 15) / -.1146848625 9272988777 2963387698 2 D-11 /
DATA AI0CS( 16) / +.2715592054 8036628726 4365192160 6 D-12 /
DATA AI0CS( 17) / -.2415874666 5626878384 4247572028 1 D-13 /
DATA AI0CS( 18) / -.6084469888 2551250646 0609963922 4 D-14 /
DATA AI0CS( 19) / +.3145705077 1754772937 0836026730 3 D-14 /
DATA AI0CS( 20) / -.7172212924 8711877179 6217505917 6 D-15 /
DATA AI0CS( 21) / +.7874493403 4541033960 8390960332 7 D-16 /
DATA AI0CS( 22) / +.1004802753 0094624023 4524457183 9 D-16 /
DATA AI0CS( 23) / -.7566895365 3505348534 2843588881 0 D-17 /
DATA AI0CS( 24) / +.2150380106 8761198878 1205128784 5 D-17 /
DATA AI0CS( 25) / -.3754858341 8308744291 5158445260 8 D-18 /
DATA AI0CS( 26) / +.2354065842 2269925769 0075710532 2 D-19 /
DATA AI0CS( 27) / +.1114667612 0479285302 2637335511 0 D-19 /
DATA AI0CS( 28) / -.5398891884 3969903786 9677932270 9 D-20 /
DATA AI0CS( 29) / +.1439598792 2407526770 4285840452 2 D-20 /
DATA AI0CS( 30) / -.2591916360 1110934064 6081840196 2 D-21 /
DATA AI0CS( 31) / +.2238133183 9985839074 3409229824 0 D-22 /
DATA AI0CS( 32) / +.5250672575 3647711727 7221683199 9 D-23 /
DATA AI0CS( 33) / -.3249904138 5332307841 7343228586 6 D-23 /
DATA AI0CS( 34) / +.9924214103 2050379278 5728471040 0 D-24 /
DATA AI0CS( 35) / -.2164992254 2446695231 4655429973 3 D-24 /
DATA AI0CS( 36) / +.3233609471 9435940839 7333299199 9 D-25 /
DATA AI0CS( 37) / -.1184620207 3967424898 2473386666 6 D-26 /
DATA AI0CS( 38) / -.1281671853 9504986505 4833868799 9 D-26 /
DATA AI0CS( 39) / +.5827015182 2793905116 0556885333 3 D-27 /
DATA AI0CS( 40) / -.1668222326 0261097193 6450150399 9 D-27 /
DATA AI0CS( 41) / +.3625309510 5415699757 0068480000 0 D-28 /
DATA AI0CS( 42) / -.5733627999 0557135899 4595839999 9 D-29 /
DATA AI0CS( 43) / +.3736796722 0630982296 4258133333 3 D-30 /
DATA AI0CS( 44) / +.1602073983 1568519633 6551253333 3 D-30 /
DATA AI0CS( 45) / -.8700424864 0572298845 2249599999 9 D-31 /
DATA AI0CS( 46) / +.2741320937 9374811456 0341333333 3 D-31 /
DATA AI02CS( 1) / +.5449041101 4108831607 8960962268 0 D-1 /
DATA AI02CS( 2) / +.3369116478 2556940898 9785662979 9 D-2 /
DATA AI02CS( 3) / +.6889758346 9168239842 6263914301 1 D-4 /
DATA AI02CS( 4) / +.2891370520 8347564829 6692402323 2 D-5 /
DATA AI02CS( 5) / +.2048918589 4690637418 2760534093 1 D-6 /
DATA AI02CS( 6) / +.2266668990 4981780645 9327743136 1 D-7 /
DATA AI02CS( 7) / +.3396232025 7083863451 5084396952 3 D-8 /
DATA AI02CS( 8) / +.4940602388 2249695891 0482449783 5 D-9 /
DATA AI02CS( 9) / +.1188914710 7846438342 4084525196 3 D-10 /
DATA AI02CS( 10) / -.3149916527 9632413645 3864862961 9 D-10 /
DATA AI02CS( 11) / -.1321581184 0447713118 7540739926 7 D-10 /
DATA AI02CS( 12) / -.1794178531 5068061177 7943574026 9 D-11 /
DATA AI02CS( 13) / +.7180124451 3836662336 7106429346 9 D-12 /
DATA AI02CS( 14) / +.3852778382 7421427011 4089801777 6 D-12 /
DATA AI02CS( 15) / +.1540086217 5214098269 1325823339 7 D-13 /
DATA AI02CS( 16) / -.4150569347 2872220866 2689972015 6 D-13 /
DATA AI02CS( 17) / -.9554846698 8283076487 0214494312 5 D-14 /
DATA AI02CS( 18) / +.3811680669 3526224207 4605535511 8 D-14 /
DATA AI02CS( 19) / +.1772560133 0565263836 0493266675 8 D-14 /
DATA AI02CS( 20) / -.3425485619 6772191346 1924790328 2 D-15 /
DATA AI02CS( 21) / -.2827623980 5165834849 4205593759 4 D-15 /
DATA AI02CS( 22) / +.3461222867 6974610930 9706250813 4 D-16 /
DATA AI02CS( 23) / +.4465621420 2967599990 1042054284 3 D-16 /
DATA AI02CS( 24) / -.4830504485 9441820712 5525403795 4 D-17 /
DATA AI02CS( 25) / -.7233180487 8747539545 6227240924 5 D-17 /
DATA AI02CS( 26) / +.9921475412 1736985988 8046093981 0 D-18 /
DATA AI02CS( 27) / +.1193650890 8459820855 0439949924 2 D-17 /
DATA AI02CS( 28) / -.2488709837 1508072357 2054491660 2 D-18 /
DATA AI02CS( 29) / -.1938426454 1609059289 8469781132 6 D-18 /
DATA AI02CS( 30) / +.6444656697 3734438687 8301949394 9 D-19 /
DATA AI02CS( 31) / +.2886051596 2892243264 8171383073 4 D-19 /
DATA AI02CS( 32) / -.1601954907 1749718070 6167156200 7 D-19 /
DATA AI02CS( 33) / -.3270815010 5923147208 9193567485 9 D-20 /
DATA AI02CS( 34) / +.3686932283 8264091811 4600723939 3 D-20 /
DATA AI02CS( 35) / +.1268297648 0309501530 1359529710 9 D-22 /
DATA AI02CS( 36) / -.7549825019 3772739076 9636664410 1 D-21 /
DATA AI02CS( 37) / +.1502133571 3778353496 3712789053 4 D-21 /
DATA AI02CS( 38) / +.1265195883 5096485349 3208799248 3 D-21 /
DATA AI02CS( 39) / -.6100998370 0836807086 2940891600 2 D-22 /
DATA AI02CS( 40) / -.1268809629 2601282643 6872095924 2 D-22 /
DATA AI02CS( 41) / +.1661016099 8907414578 4038487490 5 D-22 /
DATA AI02CS( 42) / -.1585194335 7658855793 7970504881 4 D-23 /
DATA AI02CS( 43) / -.3302645405 9682178009 5381766755 6 D-23 /
DATA AI02CS( 44) / +.1313580902 8392397817 4039623117 4 D-23 /
DATA AI02CS( 45) / +.3689040246 6711567933 1425637280 4 D-24 /
DATA AI02CS( 46) / -.4210141910 4616891492 1978247249 9 D-24 /
DATA AI02CS( 47) / +.4791954591 0828657806 3171401373 0 D-25 /
DATA AI02CS( 48) / +.8459470390 2218217952 9971707412 4 D-25 /
DATA AI02CS( 49) / -.4039800940 8728324931 4607937181 0 D-25 /
DATA AI02CS( 50) / -.6434714653 6504313473 0100850469 5 D-26 /
DATA AI02CS( 51) / +.1225743398 8756659903 4464736990 5 D-25 /
DATA AI02CS( 52) / -.2934391316 0257089231 9879821175 4 D-26 /
DATA AI02CS( 53) / -.1961311309 1949829262 0371205728 9 D-26 /
DATA AI02CS( 54) / +.1503520374 8221934241 6229900309 8 D-26 /
DATA AI02CS( 55) / -.9588720515 7448265520 3386388206 9 D-28 /
DATA AI02CS( 56) / -.3483339380 8170454863 9441108511 4 D-27 /
DATA AI02CS( 57) / +.1690903610 2630436730 6244960725 6 D-27 /
DATA AI02CS( 58) / +.1982866538 7356030438 9400115718 8 D-28 /
DATA AI02CS( 59) / -.5317498081 4918162145 7583002528 4 D-28 /
DATA AI02CS( 60) / +.1803306629 8883929462 3501450390 1 D-28 /
DATA AI02CS( 61) / +.6213093341 4548931758 8405311242 2 D-29 /
DATA AI02CS( 62) / -.7692189292 7721618632 0072806673 0 D-29 /
DATA AI02CS( 63) / +.1858252826 1117025426 2556016596 3 D-29 /
DATA AI02CS( 64) / +.1237585142 2813957248 9927154554 1 D-29 /
DATA AI02CS( 65) / -.1102259120 4092238032 1779478779 2 D-29 /
DATA AI02CS( 66) / +.1886287118 0397044900 7787447943 1 D-30 /
DATA AI02CS( 67) / +.2160196872 2436589131 4903141406 0 D-30 /
DATA AI02CS( 68) / -.1605454124 9197432005 8446594965 5 D-30 /
DATA AI02CS( 69) / +.1965352984 5942906039 3884807331 8 D-31 /
DATA FIRST /.TRUE./
C***FIRST EXECUTABLE STATEMENT DBSI0E
IF (FIRST) THEN
ETA = 0.1*REAL(D1MACH(3))
NTI0 = INITDS (BI0CS, 18, ETA)
NTAI0 = INITDS (AI0CS, 46, ETA)
NTAI02 = INITDS (AI02CS, 69, ETA)
XSML = SQRT(4.5D0*D1MACH(3))
ENDIF
FIRST = .FALSE.
C
Y = ABS(X)
IF (Y.GT.3.0D0) GO TO 20
C
DBSI0E = 1.0D0 - X
IF (Y.GT.XSML) DBSI0E = EXP(-Y) * (2.75D0 +
1 DCSEVL (Y*Y/4.5D0-1.D0, BI0CS, NTI0) )
RETURN
C
20 IF (Y.LE.8.D0) DBSI0E = (0.375D0 + DCSEVL ((48.D0/Y-11.D0)/5.D0,
1 AI0CS, NTAI0))/SQRT(Y)
IF (Y.GT.8.D0) DBSI0E = (0.375D0 + DCSEVL (16.D0/Y-1.D0, AI02CS,
1 NTAI02))/SQRT(Y)
C
RETURN
END
| external/SLATEC/src/dbsi0e.f |
1270667131374493697
1083735455944900608
2923018990
122253091
742233590575079424
169019487
930743766855700481
487737027
1563045781
748427645373845504
411801905
16383142
218799653
1257964760500404224
2400052052
1225850128164106240
121878964
18451788
241067840
48757348
2800040452
50104859
858370734460162050
33879843
499328045
122470058
1307367956
414042228
2325327416
1259130980
987215343285391360
1168426548
82968388
288163843
1179742071286054912
51534469
925629775
388981507
2625045199
367802395
194114947
1628028361
110191018
417770202
520259649
19438626
177662118
2967511534
205030260
773531305
464093369
24946457
1342179422
873486998467727360
998940937668714497
361900959
1044939754930884608
553936525
569206063
199792746
942481866145304576
2809912682
4481334808
2309946813
24538142
1030419913683464192
854928402
69673957
1059778551237484546
935625241988157442
1155466651
954825806915821568
436908758
3040857561
14550908
63601156
872728604
117123984
3972026776
1063938944444915722
280617172
17335354
2912784123
87156428
387290553
1935083905
57931951
340197698
195889647
12804862
352359359
811440067
302113354
234360541
415824268
14304714
2461075736
107029948
144658847
57602189
823818349016649728
732461928
747708529
340517586
1033984048056729600
529499961
2597903210
94135531
306673171
218274158
286074326
400189987
438576888
77664629
199263810
925454971356794880
2365378849
382071084
23623562
367186655
330597630
2775090345
3012235893
1427709133
925767139
2435325433
305655418
998156310
718821545716621312
384380303
112754792
1444276819
73383656
388369747
559489142
112696560
2607136226
2499962160
482880878
1053958770580172800
460396715
353732330
364922014
59063574
360648233
68522976
114481620
361303331
956899428471894017
38402979
706873962060455936
34998436
89681473
2860389435
1909216753
1222348645
88232157
2787550434
37883630
459232332
3832713568
1046345519042351104
902251275756216320
937565124646367233
101664219
369914677
87886754
1134643441
276934698
408398312
2248684005
261860968
3551537533
2306797104
13436192
1030721808
923111633785950210
2459760080
104862780
1667304961
3863860156
112186705
1900094730
367962011
50998101
213949952
703939404692373504
2985641675
386664666
3091046513
4833626154
37918511
15440334
801820077200965633
866944650
453385454
23342797
34570323
20884910
30748051
214461167
64424172
64979762
781464025414729728
825321975530811394
446346572
104926858
451375228
480704495
90891428
3560045421
4427102902
4873923539
752755781884383232
2493916777
386263630
3770938396
814795239965790210
458400180
813112197589192704
467938232
805854458659934209
711519541290004480
118628488
506147444
1091723425
788744123108982785
706545289520406529
577410327
706506401330372608
375117489
1900026654
1382864456
74974747
1916522756
3402943743
782912059730173953
1389342378
780120493949059073
3308416575
132093245
561491826
66140425
161691990
3817246822
269363619
1060790946
1051624514
533158912
56072705
23335036
101600098
336109220
115030642
1967454302
1003965264
2715052786
198898732
3290038797
612355472
3307904531
572829457
738012017487941633
624502192
3420398793
2763920913
968244900
189545993
628532155
2468751831
4845908974
753770874491338754
546770228
2548764336
791653182
623880848
3049042558
2815010455
29061823
1231950168
1213379917
2359340832
1265530849
44371270
2991883180
707147456304259073
705787712314413057
735574277634838528
1409458147
283524731
935171605
2281155569
93950151
725057948121202688
724001658611609600
454600916
720053937143947264
1151962057
574881792
1617731736
4195499633
17442991
1240869600
933354198
554608196
4536380255
2423855568
12186112
305486866
1083623718
87735527
4776911963
2749134371
55372477
574858073
90894097
3433727055
424225530
14865723
751553545
1099211335
30252981
562475929
2544371154
4484117927
777968166
4458383499
4551884292
4267173916
4208782127
55506256
2213993214
2266029559
2613969246
98608490
49446769
323183021
1537420770
791221941176770561
98139168
29184910
150426122
159426410
2905295349
553943439
4752391
803937818020036608
731126594371244033
803018812903788546
303606068
713724358691332096
1904828864
986691378
800044589646249984
121201514
321977097
816247525464219648
816701699977052161
818765819324809216
820224790111932416
777770150250569728
563614256
820906864594526208
992653747
388705859
793620638
190619373
482111048
301416352
137253079
308092719
35713433
2540280492
47914065
1449193838
900265968
430525028
327428505
4832646197
898610947
278510541
466718156
712211490
242793977
3311871323
1635912097
2709433202
60784269
48921383
550484057
42060596
14472715
2320463938
4747855275
2414815533
600294854
2903577748
126089751
796156836
943797684
1259475739
557795946
356242750
356820490
2831796584
4868976849
4876609925
470077617
480377384
4823285908
3586864697
3360458561
608538042
3136787441
3062658621
2604691714
3478029617
49487170
392768819
326677349
67682229
327400296
110409218
490602645
3105364077
4343694868
123829240
3037263665
20222688
125051597
143882873
2829534846
4626459862
1172409558
2757188999
16663526
30071147
3320573735
1384309656
547039454
3187771487
163122896
440384529
463204215
3686114836
4132707184
2285361236
17593806
214805618
4030187667
621515936
16467567
15450996
826637311
172665401
1283588581
120478723
231484761
169017279
407213004
18588936
3091430482
330613793
257867744
205293340
259839979
2304599143
2391536672
425068677
3438067589
3393418847
866338741
3834281962
5988062
376774755
2445592215
41643059
17448148
293378775
257428058
376679830
384315532
44070455
363567337
167720933
101515843
210129280
546704966
340372406
16601363
285085617
106456093
15051439
16896057
92564226
601409889
133663801
24744541
8350912
305238889
465993271
185167847
19044686
123942210
180623634
432806159
| originalCode_JMG/data/twecoll/20200723Twecoll/fdat/3608876063.f |
subroutine LegendreSP(Plm,x)
*************************************************************************
** Written by Lin-Wang Wang, 2003
*************************************************************************
** copyright (c) 2003, The Regents of the University of California,
** through Lawrence Berkeley National Laboratory (subject to receipt of any
** required approvals from the U.S. Dept. of Energy). All rights reserved.
*************************************************************************
cccc Plm(m,l)[x]=sqrt[(2*l+1)/4pi*(l-m)!/(l+m)!] P_l^m(x)
cccc here, P_l^m(x) is the Lengendre function
cccc Note the normalized spherical harmonic function is:
cccc Y_lm(th,phi)=Plm(m,l)[costh]*exp(i*m*phi)
implicit double precision(a-h,o-z)
parameter (pi=3.14159265358979312d0)
real*8 plm(-6:6,0:6),F(-6:6,0:6)
ccccccc F(m,l)=d^(l+m)/dx^(l+m) (x^2-1)^l
x2=x**2
x3=x2*x
x4=x3*x
x5=x4*x
x6=x5*x
x7=x6*x
x8=x7*x
x9=x8*x
x10=x9*x
x11=x10*x
x12=x11*x
F(0,0)=1.d0
F(-1,1)=x2-1
F(0,1)=2*x
F(1,1)=2
F(-2,2)=x4-2*x2+1
F(-1,2)=4*x3-4*x
F(0,2)=12*x2-4
F(1,2)=24*x
F(2,2)=24
F(-3,3)=x6-3*x4+3*x2-1
F(-2,3)=6*x5-12*x3+6*x
F(-1,3)=30*x4-36*x2+6
F(0,3)=120*x3-72*x
F(1,3)=360*x2-72
F(2,3)=720*x
F(3,3)=720
F(-4,4)=x8-4*x6+6*x4-4*x2+1
F(-3,4)=8*x7-24*x5+24*x3-8*x
F(-2,4)=56*x6-120*x4+72*x2-8
F(-1,4)=336*x5-480*x3+144*x
F(0,4)=1680*x4-1440*x2+144
F(1,4)=6720*x3-2880*x
F(2,4)=20160*x2-2880
F(3,4)=40320*x
F(4,4)=40320
F(-5,5)=x10-5*x8+10*x6-10*x4+5*x2-1
F(-4,5)=10*x9-40*x7+60*x5-40*x3+10*x
F(-3,5)=90*x8-280*x6+300*x4-120*x2+10
F(-2,5)=720*x7-1680*x5+1200*x3-240*x
F(-1,5)=5040*x6-8400*x4+3600*x2-240
F(0,5)=30240*x5-33600*x3+7200*x
F(1,5)=151200*x4-100800*x2+7200
F(2,5)=604800*x3-201600*x
F(3,5)=1814400*x2-201600
F(4,5)=3628800*x
F(5,5)=3628800
F(-6,6)=x12-6*x10+15*x8-20*x6+15*x4-6*x2+1
F(-5,6)=12*x11-60*x9+120*x7-120*x5+60*x3-12*x
F(-4,6)=132*x10-540*x8+840*x6-600*x4+180*x2-12
F(-3,6)=1320*x9-4320*x7+5040*x5-2400*x3+360*x
F(-2,6)=11880*x8-30240*x6+25200*x4-7200*x2+360
F(-1,6)=95040*x7-181440*x5+100800*x3-14400*x
F(0,6)=665280*x6-907200*x4+302400*x2-14400
F(1,6)=3991680*x5-3628800*x3+604800*x
F(2,6)=19958400*x4-10886400*x2+604800
F(3,6)=79833600*x3-21772800*x
F(4,6)=239500800*x2-21772800
F(5,6)=479001600*x
F(6,6)=479001600
Plm(0,0)=1.d0/dsqrt(4*pi)
do l=1,6
call factorial(ifact,l)
Plm(0,l)=1.d0/2.d0**l/ifact*F(0,l)
do m=1,l
isign=-1
if(mod(m,2).eq.0) isign=1
Plm(m,l)=isign/2.d0**l/ifact*
& (1-x**2)**(m/2.d0)*F(m,l) ! this is the Legendre func.
call factorial(ifact1,l-m)
call factorial(ifact2,l+m)
Plm(m,l)=dsqrt((2*l+1.d0)*ifact1/(4*pi*ifact2))*
& Plm(m,l)
Plm(-m,l)=isign*Plm(m,l)
enddo
enddo
return
contains
subroutine factorial(ifact_tmp,ii)
implicit double precision (a-h,o-z)
integer ifact_tmp,ii
if(ii.eq.0) then
ifact_tmp=1
endif
if(ii.gt.0) then
ifact_tmp=1
do i=1,ii
ifact_tmp=ifact_tmp*i
enddo
endif
return
end subroutine factorial
end
| lsda_p/LegendreSP.f |
SUBROUTINE G5LODI
C
C ------------------------------------------------
C ROUTINE NO. (5015) VERSION (A7.4) 11:FEB:85
C ------------------------------------------------
C
C THIS FETCHES A GRID-80 INSTRUCTION FROM THE TRANGRID
C FILE, TOGETHER WITH ANY ASSOCIATED DATA. THE VALUES
C ARE STORED IN THE BUFFER [IFUNIB] AS UNDECODED TRIPLETS.
C
C
LOGICAL TEROUT
C
COMMON /T5TBUF/ IFUNIB(257)
COMMON /T5TERR/ INERR,TEROUT
C
C
C THE INSTRUCTION CODE AND DATA LENGTH ARE FIRST
C FETCHED. IF THE LATTER IS ZERO, NO DATA IS SAVED.
C
C
CALL G5TRIN(2,1)
LENGTH= IFUNIB(2)
IF (LENGTH.GE.256) LENGTH= LENGTH-256
IF (LENGTH.EQ.0) RETURN
C
C OTHERWISE THE DATA TRIPLETS ARE ALSO FETCHED. (AN
C OUT-OF-RANGE LENGTH CAUSES A SHUT-DOWN TO OCCUR).
C
IF (LENGTH.LT.0.OR.LENGTH.GT.256) GO TO 901
C
CALL G5TRIN(LENGTH,3)
RETURN
C
C THE ERROR CODE IS SET (CAUSING A SHUT-DOWN) AND A MESSAGE
C IS ALSO (OPTIONALLY) WRITTEN, IF THE ERROR HAS JUST OCCURRED.
C
901 IF (INERR.NE.0) RETURN
INERR= 3
IF (TEROUT) CALL G5ERMS
C
RETURN
END
| src/lib/g5lodi.f |
! { dg-do compile }
! { dg-options "-Wline-truncation" }
!
! By default, for free-form source code: Error out
! Even with -Wline-truncation, we still get an error
!
print *, 1 + 2 ! { dg-error "Line truncated at .1." }
end
! { dg-excess-errors "some warnings being treated as errors" }
| validation_tests/llvm/f18/gfortran.dg/line_length_8.f90 |
module dStar_atm_lib
use dStar_atm_def
contains
subroutine dStar_atm_startup(datadir, ierr)
use exceptions_lib
character(len=*), intent(in) :: datadir
integer, intent(out) :: ierr
type(alert) :: already_initialized=alert(level=1,scope='dStar_atm_startup', &
& message='module already initialized')
if (atm_is_initialized) then
ierr = 1
call already_initialized% report
return
end if
atm_datadir = trim(datadir)//'/atm_data'
atm_is_initialized = .TRUE.
ierr = 0
end subroutine dStar_atm_startup
subroutine dStar_atm_shutdown()
use dStar_atm_mod, only : do_free_atm_table
type(atm_table_type), pointer :: tab
tab => atm_table
call do_free_atm_table(tab)
atm_is_initialized = .FALSE.
end subroutine dStar_atm_shutdown
subroutine dStar_atm_free_table()
use dStar_atm_mod, only : do_free_atm_table
type(atm_table_type), pointer :: tab
tab => atm_table
call do_free_atm_table(tab)
end subroutine dStar_atm_free_table
subroutine dStar_atm_load_table(prefix,grav,Plight,Pb,ierr)
use exceptions_lib
use dStar_atm_mod, only : do_load_atm_table
character(len=*), intent(in) :: prefix
real(dp), intent(in) :: grav,Plight,Pb
integer, intent(out) :: ierr
type(failure) :: load_atm_failure=failure(scope='dStar_atm_load_table')
type(alert) :: status=alert(scope='dStar_atm_load_table')
call status% report('loading atmosphere model '//prefix)
call do_load_atm_table(prefix, grav, Plight, Pb, ierr)
if (load_atm_failure% raised(ierr)) return
end subroutine dStar_atm_load_table
subroutine dStar_atm_get_results(lgTb,lgTeff,dlgTeff,lgflux,dlgflux,ierr)
use exceptions_lib
use interp_1d_lib, only : interp_value_and_slope
real(dp), intent(in) :: lgTb
real(dp), intent(out) :: lgTeff,lgflux,dlgTeff,dlgflux
integer, intent(out) :: ierr
real(dp) :: lgT
type(atm_table_type), pointer :: tab
character(len=*), parameter :: routine_name = 'dStar_atm_get_results'
type(assertion) :: table_loaded=assertion(scope='dStar_atm_get_results', &
& message='table is loaded')
type(alert) :: status=alert(scope='dStar_atm_get_results',level=0)
tab => atm_table
call table_loaded% assert(tab% is_loaded)
! clip lgTb to table
lgT = min(max(lgTb,tab% lgTb_min),tab% lgTb_max)
call interp_value_and_slope(tab% lgTb, tab% nv, tab% lgTeff, lgT, lgTeff, dlgTeff, ierr)
if (ierr /= 0) call status% report('unable to interpolate lgTeff')
call interp_value_and_slope(tab% lgTb, tab% nv, tab% lgflux, lgT, lgflux, dlgflux, ierr)
if (ierr /= 0) call status% report('unable to interpolate flux')
end subroutine dStar_atm_get_results
end module dStar_atm_lib
| dStar_atm/public/dStar_atm_lib.f |
C=======================================================================
C CALSHK, Subroutine
C
C Determines rice shock period
C-----------------------------------------------------------------------
C Revision history
C
C 04/01/1996 MUS Written
C 08/29/2002 CHP/MUS Converted to modular format for inclusion in CSM.
C 02/19/2003 CHP Converted dates to YRDOY format
C=======================================================================
SUBROUTINE CALCSHK (DYNAMIC,
& DTT, ISTAGE, ISWWAT, ITRANS, LTRANS, !Input
& MODELVER, P1, P1T, SHOCKFAC, TAGE, TMAX, !Input
& TMIN, YRDOY, YRSOW, !Input
& CARBO, CUMDTT, !I/O
& TSHOCK) !Output
!-----------------------------------------------------------------------
USE ModuleDefs !Definitions of constructed variable types,
! which contain control information, soil
! parameters, hourly weather data.
IMPLICIT NONE
SAVE
REAL TSHOCK,TSHOCK1,TMAX,TMIN,TAGE,DTT,CUMDTT,CARBO
REAL P1, P1T
REAL SHOCKAGE, SHOCK, SHOCKFAC, SHOCKD, SHOCKLAI, DSHOCK
INTEGER DYNAMIC, ISTAGE, ITRANS
INTEGER MODELVER
INTEGER INCDAT, TIMDIF, LYRDOY, YRDOY, YRSOW
LOGICAL LTRANS, SHKINIT
CHARACTER ISWWAT*1
!***********************************************************************
!***********************************************************************
! Seasonal Initialization - Called once per season
!***********************************************************************
IF (DYNAMIC .EQ. SEASINIT) THEN
!-----------------------------------------------------------------------
!
! Any further initializtion of shock should go here. The shock
! submodel and value of SHOCKFAC is specified in the RICER960.SPE
! species file
IF (ITRANS .EQ. 2 .OR. ITRANS .EQ. 3) THEN
SHKINIT = .TRUE.
ELSE
SHKINIT = .FALSE.
ENDIF
TSHOCK = 1.0
!***********************************************************************
!***********************************************************************
! Daily rate / integration calculations
!***********************************************************************
ELSEIF (DYNAMIC .EQ. INTEGR) THEN
!-----------------------------------------------------------------------
IF (ISWWAT .NE. 'Y') THEN
TSHOCK = 1.0
RETURN
ENDIF
SELECT CASE (MODELVER)
CASE (1)
IF (ISTAGE .NE. 5) THEN
!
! Allow 7-14 day sliding scale effect on partitioning
! for transplanting
!
TSHOCK = 1.0
TSHOCK1 = 1.0
IF (LTRANS) THEN
DSHOCK = 7.0*(P1/P1T)
! LDATE = ISOW + DSHOCK
LYRDOY = INCDAT(YRSOW, INT(DSHOCK))
! IF (DOY .GE. ISOW .AND. DOY .LE. LDATE) THEN
IF (YRDOY .GE. YRSOW .AND. YRDOY .LE. LYRDOY) THEN
! TSHOCK = 1.0-(LDATE-DOY)/DSHOCK
TSHOCK = 1.0 - TIMDIF(YRDOY, LYRDOY) / DSHOCK
IF (TMAX .GE. 32.0) THEN
TSHOCK = TSHOCK*0.05*(45.0-TMAX)
ENDIF
IF (TMIN .GE. 28.0) THEN
TSHOCK1 = TSHOCK*0.05*(40.0-TMIN)
ENDIF
TSHOCK = AMIN1 (TSHOCK,TSHOCK1)
TSHOCK = AMAX1 (TSHOCK,0.0)
ENDIF
ENDIF
END IF
IF (TAGE .LE. 10.0) THEN
TSHOCK = 1.0
ENDIF
CASE (2)
!
! MUS shock calculations
!
IF (SHKINIT) THEN
!
! Calculate shock period in DTT
!
! Function derived from unpublished data of MUS
!
! Calculate CUMDTT from XFILE data and estimate DTT
! accumulated during nursery development (for ITRANS = 2).
! For ITRANS = 3, model simulation of nursery growth, DTTSUM
! is accumulated from actual weather
!
SHOCKAGE = -0.62695 + 0.105389*CUMDTT + 0.000263*CUMDTT**2-
& 0.00000015*CUMDTT**3
!
! Shock calculated as a function of SHOCKAGE and SHOCKFAC
!
! SHOCKFAC = 0.00, no damage on seedlings
! 1.00, moderate damage on seedlings
! 1.41, severe damage on seedlings
!
SHOCK = SHOCKAGE*SHOCKFAC
!
! Decrement shock by the DTT for today (todays heatsum)
!
SHOCK = SHOCK - DTT
!
! Flag inidcating that shock has been initialized
! Only initialize once, on day of transplanting
!
SHKINIT = .FALSE.
!
! Calculate approximate days of shock based on today
!
SHOCKD = SHOCK/(((TMAX+TMIN)/2)-8.0)
!
! Estimate the Last DATE of shock effect
!
! LDATE = ISOW + INT (SHOCKD + 0.5)
LYRDOY = INCDAT(YRSOW, INT(SHOCKD + 0.5))
!
! Determining the stopage period (SHOCKLAID) of LAI during TS period
!
SHOCKLAI = 0.25*SHOCKAGE
C SHOCKLAID = SHOCKLAI/(((TMAX+TMIN)/2)-8.0)
TSHOCK = 1.0
CUMDTT = CUMDTT - SHOCK
ELSE
!
! Decrement shock value by todays DTT
!
SHOCK = AMAX1 (SHOCK - DTT, 0.0)
TSHOCK = 1.0
!
! Decrement LAI shock value by todays DTT
!
SHOCKLAI = AMAX1 (SHOCKLAI - DTT, 0.0)
ENDIF
IF (SHOCK .GT. 0.0) THEN
TSHOCK = 1.0
TSHOCK1 = 1.0
!
! Calculate TSHOCK factor for today, on a sliding scale
!
! TSHOCK = 1.0-(LDATE-DOY)/SHOCKD
TSHOCK = 1.0 - TIMDIF(YRDOY, LYRDOY) / SHOCKD
IF (TMAX .GE. 32.0) THEN
TSHOCK = TSHOCK*0.05*(45.0-TMAX)
ENDIF
IF (TMIN .GE. 28.0) THEN
TSHOCK1 = TSHOCK*0.05*(40.0-TMIN)
ENDIF
TSHOCK = AMIN1 (TSHOCK,TSHOCK1)
TSHOCK = AMAX1 (TSHOCK,0.0)
ENDIF
!
! If during LAI shock period, set CARBO for today = 0.0
!
IF (SHOCKLAI .GT. 0.0) THEN
CARBO = 0.0
ENDIF
END SELECT
!***********************************************************************
!***********************************************************************
! END OF DYNAMIC IF CONSTRUCT
!***********************************************************************
ENDIF
!***********************************************************************
RETURN
END SUBROUTINE CALCSHK
| tests/data/program_analysis/DSSAT/CSM/RI_Calcshk.for |
!RUN: %f18 -fdebug-dump-symbols -fparse-only %s | FileCheck %s
! Size and alignment with EQUIVALENCE and COMMON
! a1 depends on a2 depends on a3
module ma
real :: a1(10), a2(10), a3(10)
equivalence(a1, a2(3)) !CHECK: a1, PUBLIC size=40 offset=20:
equivalence(a2, a3(4)) !CHECK: a2, PUBLIC size=40 offset=12:
!CHECK: a3, PUBLIC size=40 offset=0:
end
! equivalence and 2-dimensional array
module mb
real :: b1(4), b2, b3, b4
real :: b(-1:1,2:6) !CHECK: b, PUBLIC size=60 offset=0:
equivalence(b(1,6), b1) !CHECK: b1, PUBLIC size=16 offset=56:
equivalence(b(1,5), b2) !CHECK: b2, PUBLIC size=4 offset=44:
equivalence(b(0,6), b3) !CHECK: b3, PUBLIC size=4 offset=52:
equivalence(b(0,4), b4) !CHECK: b4, PUBLIC size=4 offset=28:
end
! equivalence and substring
subroutine mc !CHECK: Subprogram scope: mc size=12 alignment=1
character(10) :: c1 !CHECK: c1 size=10 offset=0:
character(5) :: c2 !CHECK: c2 size=5 offset=7:
equivalence(c1(9:), c2(2:4))
end
! Common block: objects are in order from COMMON statement and not part of module
module md !CHECK: Module scope: md size=1 alignment=1
integer(1) :: i
integer(2) :: d1 !CHECK: d1, PUBLIC size=2 offset=8:
integer(4) :: d2 !CHECK: d2, PUBLIC size=4 offset=4:
integer(1) :: d3 !CHECK: d3, PUBLIC size=1 offset=0:
real(2) :: d4 !CHECK: d4, PUBLIC size=2 offset=0:
common /common1/ d3,d2,d1 !CHECK: common1 size=10 offset=0: CommonBlockDetails alignment=4:
common /common2/ d4 !CHECK: common2 size=2 offset=0: CommonBlockDetails alignment=2:
end
| flang/test/Semantics/offsets03.f90 |
module constants_rrkm
implicit none
save
! Definition of the constants
real, parameter :: pi=3.14159265359d0
real, parameter :: h=0.333566d-10
real, parameter :: cmtokcal=349.76d0
end module constants_rrkm
| src/constants_rrkm.f90 |
SUBROUTINE MOVIE(AZIM, ELEV, TILT, RINV, KEIG, IR)
C
C----Plotting module for AVL vortex lattice program
C
C Plots geometry and loading results for vortex lattice
C Geometry plots:
C Surfaces (straight tapered panels of chordwise strips of vortices)
C Strips (chordwise strips of vortices)
C Vortex legs (bound vortex legs)
C Control pts (vortex element control points)
C Camber slope (camber of each strip - used for establishing BC's)
C Hinge lines (surface deflection axis and deflected surface outline)
C Strip loading (chordwise plot of vortex loading on each strip)
C
INCLUDE 'AVL.INC'
INCLUDE 'AVLPLT.INC'
C
LOGICAL LKEYS, LEVIEW, LCPAN
LOGICAL ERROR
LOGICAL LINITVIEW, LFIRST
SAVE LINITVIEW
CHARACTER*4 OPT
CHARACTER*1 CHKEY, ANS
C
REAL ANGE(3), POSE(3)
REAL ANG(3), POS(3), ANGP(3),DANG(3)
REAL TT(3,3), TT_ANG(3,3,3),
& RT(3,3), RT_ANG(3,3,3)
C
REAL EVR(JEMAX)
C
REAL RINP(10)
C
C---- viewpoint changes (deg), zoom/unzoom, perspective scale factors
DATA DAZIM, DELEV, ZUFAC, PRAT / 5.0 , 5.0 , 1.5 , 1.1 /
C
C---- phase step and scale factor step for interactive phase plots
DATA DPHASE, SCALEF / 5.0 , 1.25 /
C
C
C---- Initialization for plot program variables
IF(LPLTNEW .OR. (.NOT.LPLOT)) THEN
LPLTNEW = .FALSE.
LINITVIEW = .FALSE.
ENDIF
C
LFIRST = .TRUE.
C
C---- default is camera pans with aircraft
LCPAN = .TRUE.
C
C---- initial phase and eigenvector scale
EPHASE = 0.
EIGENF = 1.
C
C---- find geometry limits
CALL GLIMS(GMIN,GMAX,.FALSE.)
C
C***************************************************
C---- Setup view transformation
4 CALL VIEWINIT(AZIM, ELEV, TILT, RINV)
CALL VIEWPROJ(UNT,3,ORG)
C
C***************************************************
C
SIGMA = REAL(EVAL(KEIG,IR))
OMEGA = IMAG(EVAL(KEIG,IR))
EVMAG = ABS( EVAL(KEIG,IR) )
C
DAMP = -SIGMA / EVMAG
C
C---- set reasonable plot time interval, cycle it only once
TPLOT = 1.0 / MAX( SLOMOF*ABS(SIGMA)/(2.0*PI) ,
& SLOMOF*ABS(OMEGA)/(8.0*PI) ,
& 1.0/TMOVIE )
C
write(*,*) 's', ABS(SIGMA)/(2.0*PI)
write(*,*) 'w', ABS(OMEGA)/(8.0*PI)
write(*,*) 'T', 1.0/TMOVIE
C
c 53 RINPUT(1) = TMOVIE
c WRITE(*,1163) RINPUT(1), UNCHT(1:NUT)
c 1163 FORMAT(/' Enter play time of movie:', F10.3,' (',A,')')
c CALL READR(1,RINPUT,ERROR)
c IF(ERROR) GO TO 53
c TMOVIE = RINPUT(1)
C-----------------------------------------------------------
C---- make sure we don't get trapped in very long movie
REALT = TPLOT/SLOMOF
IF(REALT .GT. 20.0) THEN
WRITE(*,*) 'Movie will require real time =', REALT
WRITE(*,*) 'Continue with new slo-mo factor? Y'
READ (*,1000) ANS
1000 FORMAT(A)
IF(INDEX('Nn',ANS).NE.0) RETURN
C
WRITE(*,*) 'Enter slow-motion factor (bigger = faster):', SLOMOF
CALL READR(1,SLOMOF,ERROR)
ENDIF
C-----------------------------------------------------------
C
C***************************************************
C---- compute perturbed position at current phase angle
6 CONTINUE
C
VEE = PARVAL(IPVEE,IR)
REFL = BREF*UNITL
REFV = VEE
C
EVMIN = (REFV/REFL) * 1.0E-5
C
SIGMA = REAL(EVAL)
OMEGA = IMAG(EVAL)
EVMAG = SQRT(SIGMA**2 + OMEGA**2)
C
CALL EVNORM(EVEC,ESF,REFL,REFV)
EFAC = ESF*EIGENF
C
C---- set time using specified phase
IF(EVMAG .LT. EVMIN) THEN
TIMED = EPHASE*DTR / EVMIN
C
ELSE
TIMED = EPHASE*DTR / MAX( ABS(OMEGA) , ABS(SIGMA) )
C
ENDIF
C
CALL EVREAL(EVEC(1,KEIG,IR),EVAL(KEIG,IR), EFAC,TIMED, EVR)
C
C
C---- scale from standard (SI or English) to AVL units
TIME = TIMED*VEE/UNITL
C
EVR(JEX) = EVR(JEX)/UNITL
EVR(JEY) = EVR(JEY)/UNITL
EVR(JEZ) = EVR(JEZ)/UNITL
C
EVR(JEU) = EVR(JEU)/VEE
EVR(JEV) = EVR(JEV)/VEE
EVR(JEW) = EVR(JEW)/VEE
C
EVR(JEP) = EVR(JEP)*UNITL/VEE
EVR(JEQ) = EVR(JEQ)*UNITL/VEE
EVR(JER) = EVR(JER)*UNITL/VEE
C
CCC EVR(JEPH) = EVR(JEPH)
CCC EVR(JETH) = EVR(JETH)
CCC EVR(JEPS) = EVR(JEPS)
C
C
C
c write(*,*)
c write(*,*) 'xyz', evr(jex),evr(jey),evr(jez)
c write(*,*) 'uvw', evr(jeu),evr(jev),evr(jew)
c write(*,*) 'pqr', evr(jep),evr(jeq),evr(jer)
c write(*,*) 'reh', evr(jeph),evr(jeth),evr(jeps)
C
C---- set perturbed Earth-coordinate position
IF(LCPAN) THEN
C----- camera panning... no baseline movement
POS(1) = 0.
POS(2) = 0.
POS(3) = 0.
C
ANG(1) = PARVAL(IPPHI,IR)*DTR
ANG(2) = PARVAL(IPTHE,IR)*DTR
ANG(3) = PARVAL(IPPSI,IR)*DTR
C
ELSE
C----- camera is fixed... include aicraft motion, integrated up to present time
C
C----- sat baseline velocities and rotation rates
ALFA = PARVAL(IPALFA,IR)*DTR
BETA = PARVAL(IPBETA,IR)*DTR
CALL VINFAB
WROT(1) = PARVAL(IPROTX,IR)*2.0/BREF
WROT(2) = PARVAL(IPROTY,IR)*2.0/CREF
WROT(3) = PARVAL(IPROTZ,IR)*2.0/BREF
C
C----- set time step based on max Euler angle change
RMAX = MAX( ABS(WROT(1)) , ABS(WROT(2)) , ABS(WROT(3)) )
DAMAX = RMAX*ABS(TIME)
NTIME = INT( DAMAX / 0.025 )
C
C----- set initial position,angles at t=0
POS(1) = 0.
POS(2) = 0.
POS(3) = 0.
ANG(1) = PARVAL(IPPHI,IR)*DTR
ANG(2) = PARVAL(IPTHE,IR)*DTR
ANG(3) = PARVAL(IPPSI,IR)*DTR
CALL RATEKI3(ANG,RT,RT_ANG)
C
C----- integrate over time interval t = 0..TIME
DO ITIME = 1, NTIME
DT = TIME/FLOAT(NTIME)
C
C------- predictor step, slopes evaluated at t
DO K = 1, 3
DANG(K) = DT*( RT(K,1)*WROT(1)
& + RT(K,2)*WROT(2)
& + RT(K,3)*WROT(3) )
ANGP(K) = ANG(K) + DANG(K)
ENDDO
CALL RATEKI3(ANGP,RT,RT_ANG)
C
C------- corrector step, slopes evaluated at t + dt
DO K = 1, 3
DANGP = DT*( RT(K,1)*WROT(1)
& + RT(K,2)*WROT(2)
& + RT(K,3)*WROT(3) )
C--------- midpoint angles at t + dt/2
ANGP(K) = ANG(K) + 0.25*(DANG(K) + DANGP)
ENDDO
C
C------- use midpoint-angle matrices
CALL RATEKI3(ANGP,RT,RT_ANG)
CALL ROTENS3(ANGP,TT,TT_ANG)
C
C------- final integration step, using midpoint slopes
DO K = 1, 3
POS(K) = POS(K) - DT*( TT(K,1)*VINF(1)
& + TT(K,2)*VINF(2)
& + TT(K,3)*VINF(3) )
ANG(K) = ANG(K) + DT*( RT(K,1)*WROT(1)
& + RT(K,2)*WROT(2)
& + RT(K,3)*WROT(3) )
ENDDO
ENDDO
C
ENDIF
C
C---- set final position, including eigenvector perturbation
POSE(1) = POS(1) + EVR(JEX)
POSE(2) = POS(2) + EVR(JEY)
POSE(3) = POS(3) + EVR(JEZ)
C
C---- set final angles, including eigenvector perturbation
ANGE(1) = ANG(1) + EVR(JEPH)
ANGE(2) = ANG(2) + EVR(JETH)
ANGE(3) = ANG(3) + EVR(JEPS)
C
C
c CALL RATEKI3(ANG,RT,RT_ANG)
c DO K = 1, 3
c DANG(K) = RT(K,1)*WROT(1)
c & + RT(K,2)*WROT(2)
c & + RT(K,3)*WROT(3)
c ENDDO
c write(1,1234) ( pos(k)/12.0, k=1, 3),
c & ( ang(k)/dtr , k=1, 3),
c & ( dang(k)*bref/dtr , k=1, 3)
c write(2,1234) (pose(k)/12.0, k=1, 3), (ange(k)/dtr, k=1, 3)
c 1234 format(1x,9f10.3)
C
C
C
XYZREF(1) = PARVAL(IPXCG,IR)
XYZREF(2) = PARVAL(IPYCG,IR)
XYZREF(3) = PARVAL(IPZCG,IR)
C
C---- set limits for baseline position
CALL ROTENS3(ANG,TT,TT_ANG)
CALL GRLIMS(VMINP,VMAXP,.TRUE. ,TT ,XYZREF,POS )
IF(LFIRST) THEN
C----- first frame... set plot limits directly
XMIN = VMINP(1)
YMIN = VMINP(2)
XMAX = VMAXP(1)
YMAX = VMAXP(2)
ELSE
C----- clip to new limits
XMIN = MIN(XMIN,VMINP(1))
YMIN = MIN(YMIN,VMINP(2))
XMAX = MAX(XMAX,VMAXP(1))
YMAX = MAX(YMAX,VMAXP(2))
ENDIF
LFIRST = .FALSE.
C
C
C---- also enforce limits for perturbed position
CALL ROTENS3(ANGE,TT,TT_ANG)
CALL GRLIMS(VMINP,VMAXP,.TRUE. ,TT ,XYZREF,POSE)
XMIN = MIN(XMIN,VMINP(1))
YMIN = MIN(YMIN,VMINP(2))
XMAX = MAX(XMAX,VMAXP(1))
YMAX = MAX(YMAX,VMAXP(2))
C
CALL OFFINI
C
C***************************************************
C---- plot the baseline and displaced geometry
8 CONTINUE
CALL PVLINI(TITLE,AZIM,ELEV,TILT,VERSION,LSVMOV)
C
CALL GETWINSIZE(XWIND,YWIND)
C
CCH = 0.8*CH
XPLT = XABS2USR(PMARG)
YPLT = YABS2USR(YWIND-PMARG) - 1.2*CCH
C
CALL PLCHAR(XPLT,YPLT,CCH,'Run ',0.0,5)
CALL PLNUMB(999.,YPLT,CCH,FLOAT(IR),0.0,-1)
C
YPLT = YPLT - 2.2*CCH
CALL PLCHAR(XPLT,YPLT,CCH,'Mode ',0.0,5)
CALL PLNUMB(999.,YPLT,CCH,FLOAT(KEIG),0.0,-1)
C
YPLT = YPLT - 2.2*CCH
FRQ = OMEGA / (2.0*PI)
CALL PLCHAR(XPLT,YPLT,CCH,'f = ',0.0,4)
CALL PLNUMB(999.,YPLT,CCH,FRQ,0.0,4)
CALL PLCHAR(999.,YPLT,CCH,' cycles/' ,0.0,8)
CALL PLCHAR(999.,YPLT,CCH,UNCHT(1:NUT),0.0,NUT)
C
YPLT = YPLT - 2.2*CCH
IF(SIGMA .EQ. 0.0) THEN
DAMPR = 0.
ELSE
DAMPR = -SIGMA / SQRT(SIGMA**2 + OMEGA**2)
ENDIF
CALL PLMATH(XPLT,YPLT,CCH,'z = ',0.0,4)
CALL PLNUMB(999.,YPLT,CCH,DAMPR,0.0,6)
C
YPLT = YPLT - 2.2*CCH
CALL PLMATH(XPLT,YPLT,CCH,'f = ',0.0, 4)
CALL PLNUMB(999.,YPLT,CCH,EPHASE,0.0,-1)
CALL PLMATH(999.,YPLT,CCH, '"',0.0, 1)
C
C---- Setup hidden line data
CALL HIDINITE(.TRUE., ANGE,POSE,XYZREF)
C
CALL PLOTMODE(ANG ,POS ,XYZREF,0)
CALL PLOTMODE(ANGE,POSE,XYZREF,1)
CALL PLFLUSH
C
ccc CALL DRAWTOSCREEN
| third_party/avl/src/movie.f |
! DQ (11/10/2008): Note module names use file name prefix to for use of
! unique names and avoid race conditions in mod file generation.
module module_B_file_module_B
use module_A_file_module_A
implicit none
private
save
! This means build a real type like "r8" defined in module "module_A"
! Note: it is a current bug that the initializer is unparsed as "0.0" instead of "0.0_r8"
! real (r8), parameter, public :: c0 = 0.0_r8
integer y
end module module_B_file_module_B
| tests/CompileTests/Fortran_tests/module_B_file.f90 |
program test_get_grid_type
use bmif_2_0, only: BMI_FAILURE, BMI_MAX_TYPE_NAME
use bmiprmsstreamflow
use fixtures, only: config_file, status
implicit none
integer, parameter :: grid_id = 0
character (len=*), parameter :: &
expected_type = "vector"
type (bmi_prms_streamflow) :: m
character (len=BMI_MAX_TYPE_NAME) :: grid_type
status = m%initialize(config_file)
status = m%get_grid_type(grid_id, grid_type)
status = m%finalize()
if (grid_type /= expected_type) then
write(*,*) grid_type
stop BMI_FAILURE
end if
end program test_get_grid_type
| tests/test_get_grid_type.f90 |
subroutine reg_read_elements
use input_file_module
use maximum_data_module
use calibration_data_module
use landuse_data_module
use hydrograph_module
use hru_module, only : hru, ihru
use output_landscape_module
implicit none
character (len=80) :: titldum ! |title of file
character (len=80) :: header ! |header of file
integer :: eof ! |end of file
logical :: i_exist !none |check to determine if file exists
integer :: imax ! |determine max number for array (imax) and total number in file
integer :: mcal ! |
integer :: mreg ! |
integer :: mlug
integer :: ireg
integer :: i !none |counter
integer :: k ! |
integer :: ilum
integer :: nspu ! |
integer :: isp ! |
integer :: ielem1 !none |counter
integer :: ii !none |counter
integer :: iihru !none |counter
integer :: ihru_tot ! |
integer :: ilsu ! |
imax = 0
mcal = 0
mreg = 0
!! setting up regions for landscape soft cal and/or output by landuse
inquire (file=in_regs%def_reg, exist=i_exist)
if (i_exist .or. in_regs%def_reg /= "null") then
do
open (107,file=in_regs%def_reg)
read (107,*,iostat=eof) titldum
if (eof < 0) exit
read (107,*,iostat=eof) mreg, mlug
if (eof < 0) exit
!! allocate regional output files
allocate (lsu_reg(0:mreg))
allocate (region(0:mreg))
allocate (rwb_d(mreg)); allocate (rwb_m(mreg)); allocate (rwb_y(mreg)); allocate (rwb_a(mreg))
allocate (rnb_d(mreg)); allocate (rnb_m(mreg)); allocate (rnb_y(mreg)); allocate (rnb_a(mreg))
allocate (rls_d(mreg)); allocate (rls_m(mreg)); allocate (rls_y(mreg)); allocate (rls_a(mreg))
allocate (rpw_d(mreg)); allocate (rpw_m(mreg)); allocate (rpw_y(mreg)); allocate (rpw_a(mreg))
db_mx%landuse = mlug
!read the land use groups within each region
allocate (region(ireg)%lumc(mlug))
allocate (lum_grp%name(mlug))
if (mlug > 0) then
backspace (107)
read (107,*,iostat=eof) i, lum_grp%num, (lum_grp%name(ilum), ilum = 1, mlug)
if (eof < 0) exit
end if
read (107,*,iostat=eof) header
if (eof < 0) exit
!! if no regions are input, don"t need elements
if (mreg > 0) then
!! allocate land use within each region for soft cal and output
do ireg = 1, mreg
allocate (region(ireg)%lum_ha_tot(mlug))
allocate (region(ireg)%lum_num_tot(mlug))
region(ireg)%lum_ha_tot = 0.
region(ireg)%lum_num_tot = 0
region(ireg)%lum_ha_tot = 0.
allocate (rwb_a(ireg)%lum(mlug))
allocate (rnb_a(ireg)%lum(mlug))
allocate (rls_a(ireg)%lum(mlug))
allocate (rpw_a(ireg)%lum(mlug))
end do
end if ! mreg > 0
db_mx%lsu_reg = mreg
do i = 1, mreg
read (107,*,iostat=eof) k, lsu_reg(i)%name, lsu_reg(i)%area_ha, nspu
if (eof < 0) exit
if (nspu > 0) then
allocate (elem_cnt(nspu))
backspace (107)
read (107,*,iostat=eof) k, lsu_reg(i)%name, lsu_reg(i)%area_ha, nspu, (elem_cnt(isp), isp = 1, nspu)
if (eof < 0) exit
call define_unit_elements (nspu, ielem1)
allocate (lsu_reg(i)%num(ielem1))
lsu_reg(i)%num = defunit_num
lsu_reg(i)%num_tot = ielem1
deallocate (defunit_num)
else
!!all hrus are in region
allocate (lsu_reg(i)%num(sp_ob%hru))
lsu_reg(i)%num_tot = sp_ob%hru
do ihru = 1, sp_ob%hru
lsu_reg(i)%num(ihru) = ihru
end do
end if
end do ! i = 1, mreg
end do
end if
!!read data for each element in all landscape cataloging units
inquire (file=in_regs%ele_reg, exist=i_exist)
if (i_exist .or. in_regs%ele_reg /= "null") then
do
open (107,file=in_regs%ele_reg)
read (107,*,iostat=eof) titldum
if (eof < 0) exit
read (107,*,iostat=eof) header
if (eof < 0) exit
imax = 0
do while (eof == 0)
read (107,*,iostat=eof) i
if (eof < 0) exit
imax = Max(i,imax)
end do
allocate (reg_elem(imax))
rewind (107)
read (107,*,iostat=eof) titldum
if (eof < 0) exit
read (107,*,iostat=eof) header
if (eof < 0) exit
db_mx%reg_elem = imax
do isp = 1, imax
read (107,*,iostat=eof) i
backspace (107)
read (107,*,iostat=eof) k, reg_elem(i)%name, reg_elem(i)%ha, reg_elem(i)%obtyp, reg_elem(i)%obtypno
if (eof < 0) exit
end do
exit
end do
end if
! set hru number from element number and set hru areas in the region
do ireg = 1, mreg
ihru_tot = 0
do ielem1 = 1, db_mx%lsu_reg !lsu_reg(ireg)%num_tot !elements - lsu, hru or hru_lte
select case (reg_elem(ielem1)%obtyp)
case ("hru")
ihru_tot = ihru_tot + 1
case ("lsu")
ilsu = reg_elem(ielem1)%obtypno
ihru_tot = ihru_tot + lsu_out(ilsu)%num_tot
end select
end do
end do
! set hru number from element number and set hru areas in the region
do ireg = 1, mreg
ihru = 0
region(ireg)%num_tot = ihru_tot
allocate (region(ireg)%num(ihru_tot))
allocate (region(ireg)%hru_ha(ihru_tot))
do ielem1 = 1, db_mx%lsu_reg !lsu_reg(ireg)%num_tot !elements - lsu, hru or hru_lte
select case (reg_elem(ireg)%obtyp)
case ("hru")
! xwalk lum groups
ihru = ihru + 1
region(ireg)%num(ihru) = reg_elem(ielem1)%obtypno
region(ireg)%hru_ha(ihru) = hru(ihru)%area_ha
case ("lsu")
ilsu = reg_elem(ielem1)%obtypno
do iihru = 1, lsu_out(ilsu)%num_tot
ihru = ihru + 1
region(ireg)%num(ihru) = lsu_elem(iihru)%obtypno
region(ireg)%hru_ha(ihru) = lsu_elem(iihru)%ru_frac * lsu_out(ilsu)%area_ha
end do
end select
end do
end do
close (107)
return
end subroutine reg_read_elements | source_codes_60.5/reg_read_elements.f90 |
program main
call learning_objs()
end program main
subroutine learning_objs
use iso_fortran_env
use learning_fortran_objs
implicit none
real(real64) :: r, m, q, x
type(Particle) :: p
type(Electron) :: e
r = 2.4e-10
m = 9.109e-31
q = 1.602e-19
x = 4
p = Particle(r, m)
e = Electron(r, m, q)
! print *, p%radius, p%mass
! print *, e%radius, e%mass, e%charge
! call p%cross_area()
! call e%cross_area()
! print *, p%electric_potential(x)
end subroutine learning_objs
| fortran-learning-src/learning-fortran/app/main.f90 |
module mymodule
type pocketdimension
integer,dimension(-100:100, -100:100, -100:100) :: values
end type
contains
end module
program main
use mymodule
implicit none
type(pocketdimension) :: pd
integer :: n
call load(pd)
do n=1,6
call iterate(pd)
end do
call num_active_cubes(pd, n)
print *, "Num. active after boot:", n
! call show(pd)
end
subroutine num_active_neighbours(pd, x, y, z, n)
use mymodule
implicit none
type(pocketdimension), intent(in) :: pd
integer, intent(in) :: x, y, z
integer, intent(out) :: n
integer :: i, j, k
n = 0
do k = -1,1
do j = -1,1
do i = -1,1
if (k == 0 .and. j == 0 .and. i == 0) then
! Skip the current cell
else if (pd%values(x+i, y+j, z+k) == 1) then
n = n + 1
end if
end do
end do
end do
return
end
subroutine num_active_cubes(pd, n)
use mymodule
implicit none
type(pocketdimension), intent(in) :: pd
integer, intent(out) :: n
n = sum(pd%values)
end
subroutine iterate(pd)
use mymodule
implicit none
type(pocketdimension), intent(inout) :: pd
type(pocketdimension) :: tmp
integer :: x, y, z
integer :: n
integer :: here
tmp = pd
do z = lbound(pd%values,3)+1, ubound(pd%values,3)-1
do y = lbound(pd%values,2)+1, ubound(pd%values,2)-1
do x = lbound(pd%values,1)+1, ubound(pd%values,1)-1
here = pd%values(x, y, z)
call num_active_neighbours(pd, x, y, z, n)
if (here == 1) then
if (n == 2 .or. n == 3) then
! Remain active
else
tmp%values(x, y, z) = 0
end if
else if (here == 0) then
if (n == 3) then
tmp%values(x, y, z) = 1
else
! Remain inactive
end if
end if
end do
end do
end do
pd = tmp
end
subroutine show(pd)
use mymodule
implicit none
type(pocketdimension), intent(in) :: pd
integer :: x, y, z
integer :: here
do z = lbound(pd%values,3), ubound(pd%values,3)
print *, "z = ", z
do y = lbound(pd%values,2), ubound(pd%values,2)
do x = lbound(pd%values,1), ubound(pd%values,1)
here = pd%values(x, y, z)
if (here == 1) then
write (*, "(A)", advance="no") "#"
else if (here == 2) then
write (*, "(A)", advance="no") "O"
else
write (*, "(A)", advance="no") "."
end if
! write (*, "(I1)", advance="no") pd%values(x, y, z)
! print *,
end do
print *, ""
end do
end do
end
subroutine load(output)
use mymodule
implicit none
! character(len = *), parameter :: filename = "../test_input1.txt"
! integer, parameter :: num_rows = 3, num_cols = 3
character(len = *), parameter :: filename = "../puzzle_input.txt"
integer, parameter :: num_rows = 8, num_cols = 8
type(pocketdimension), intent(out) :: output
integer :: x, y, z, row, col
character :: c
character(len = 80) :: line
output%values = 0
open(1, file = filename, status = "old")
z = 0
do row = 1,num_rows
read (1,*) line
do col = 1,num_cols
c = line(col:col)
x = col - 1
y = row - 1
z = 0
if (c .eq. "#") then
output%values(x, y, z) = 1
else if (c .eq. ".") then
output%values(x, y, z) = 0
end if
end do
end do
close(1)
return
end
| day17/exercise1/main.f90 |
program LZ2
call sub2(7)
end
c
subroutine sub2(m)
integer m, ii, i, j, jj
do 10 i = 1, m
ii = i + 1
do 20 j = ii, m + 2
jj = i + j - 2
do 30 k = jj + 10, 100
t = t + 1.0
u = u + 1.0
30 continue
20 continue
10 continue
return
end
| packages/PIPS/validation/Complexity/lz2.f |
! ##################################################################################################################################
! Begin MIT license text.
! _______________________________________________________________________________________________________
! Copyright 2019 Dr William R Case, Jr (dbcase29@gmail.com)
! Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
! associated documentation files (the "Software"), to deal in the Software without restriction, including
! without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
! copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to
! the following conditions:
! The above copyright notice and this permission notice shall be included in all copies or substantial
! portions of the Software and documentation.
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
! OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
! THE SOFTWARE.
! _______________________________________________________________________________________________________
! End MIT license text.
BLOCK DATA BANDIT_BLOCK_DATA
! BANDIT file unit nos: IOU6,IOU7,IOU8,IOU9,IOU10,IOU11,IOU12,IOU13,IOU14,IOU15,IOU16,IOU17,IOU18,IOU19,IOU20 defined in DATA stmt
! **********************************************************************************************************************************
COMMON /ALPHA/ MA(26),NUM(10),MB(4)
INTEGER MA ,NUM ,MB
! 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
!xx DATA MA/'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'/
DATA MA/1HA,1HB,1HC,1HD,1HE,1HF,1HG,1HH,1HI,1HJ,1HK,1HL,1HM,1HN,1HO,1HP,1HQ,1HR,1HS,1HT,1HU,1HV,1HW,1HX,1HY,1HZ/
! Alphabet key for MA array - - -
! A - 1 N - 14
! B - 2 O - 15
! C - 3 P - 16
! D - 4 Q - 17
! E - 5 R - 18
! F - 6 S - 19
! G - 7 T - 20
! H - 8 U - 21
! I - 9 V - 22
! J - 10 W - 23
! K - 11 X - 24
! L - 12 Y - 25
! M - 13 Z - 26
!xx DATA NUM/'0','1','2','3','4','5','6','7','8','9'/
DATA NUM/1H0,1H1,1H2,1H3,1H4,1H5,1H6,1H7,1H8,1H9/
!xx DATA MB/'$',' ','+','*'/
DATA MB/1H$,1H ,1H+,1H*/
! **********************************************************************************************************************************
! I/O files
COMMON /IOUNIT/IOU5 ,IOU6 , IOU7 ,IOU8 ,IOU9 ,IOU10, IOU11, IOU12, IOU13, IOU14, IOU15, IOU16, IOU17, IOU18, IOU19, IOU20
INTEGER IOU5 ,IOU6 , IOU7 ,IOU8 ,IOU9 ,IOU10, IOU11, IOU12, IOU13, IOU14, IOU15, IOU16, IOU17, IOU18, IOU19, IOU20
! Do not set unit for input file (IOU5) - this is MYSTRAN IN1 file
DATA IOU6 , IOU7 ,IOU8 , IOU9 ,IOU10, IOU11, IOU12, IOU13, IOU14, IOU15, IOU16, IOU17, IOU18, IOU19, IOU20 &
/1006 , 1007 ,1008 , 1009 , 1010, 1011, 1012, 1013, 1014, 1015, 1016, 1017, 1018, 1019, 1020/
! **********************************************************************************************************************************
COMMON /A/ MAXGRD,MAXDEG,KMOD
INTEGER MAXGRD ,MAXDEG ,KMOD
! **********************************************************************************************************************************
! To add new B.D. element connection entries to the Bandit library, the only code changes required occur in this section of code
! by noting the following. The 4 DATA statements, VYPE, TYPE, WYPE and ME below define the BD entry and are dimensioned large enough
! for up to 160 BD entry types. Using CQUAD4K as an example:
! (1) VYPE has the 1st letter for the BD entry (e.g. for CQUAD4K this would be 'C' )
! (2) TYPE has the 2nd through 5th letters (e.g. for CQUAD4K this would be 'QUAD')
! (3) WYPE has the 6th through 8th letters (e.g. for CQUAD4K this would be '4K ' )
! (4) ME is an integer that is: ME = [10*(number of elem grids) + (number of the 1st field where an elem grid is located)].
! For example for CQUAD4K there are 4 grids and the 1st grid is in field 4 so ME = 44
! (5) NTYPE is the actual number of BD elem connection entries (which currently is 139; see below) and must be less than the
! dimension af arrays VYPE, TYPE, WYPE and ME (160, see below)
! For the VYPE, TYPE, WYPE and ME array DATA statements below, the values for the 1st NTYPE = 139 entries are shown and the
! 21 (for a total of 160) are blank or zero remaining. To add a new element, merely fill in the next available slot in VYPE, TYPE,
! WYPE and ME with the appropriate data as described above. At the current time the next available slot is 139+1 = 140.
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! MAKE SURE NTYPE IS INCREASED IF ANY MORE VALUES ARE ADDED TO VYPE, TYPE, WYPE, ME
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! For elements which need not have all grid connections present
! (e.g., CELAS1 or CPENTA), set LESSOK=.TRUE. in subroutine ELTYPE.
! For long-field cards, set LEN=2 in ELTYPE.
COMMON /ELEM/ NTYPE, VYPE(160), TYPE(160), WYPE(160), ME(160), NELEM(160),MDIM
INTEGER vype, TYPE, WYPE
INTEGER NTYPE ,ME ,NELEM ,MDIM
DATA MDIM/160/
! MDIM=Dimension of TYPE, WYPE, etc. Used in DOLLAR to add user-defined elements with $APPEND card.
! MDIM must exceed NTYPE to allow for the definition of new elements at execution time using $APPEND card.
DATA NTYPE/139/
! NTYPE = Number of elements in library. Since dimension of TYPE, WYPE, and ME is larger, future expansion is provided for.
! DATA VYPE &
! / 'E' , 'M' , 'M' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 1 - 10
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 11 - 20
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 21 - 30
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 31 - 40
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 41 - 50
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 51 - 60
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 61 - 70
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 71 - 80
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' ,' C' , 'C' , & ! 81 - 90
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 91 - 100
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 101 - 110
! 'C' , 'M' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , & ! 111 - 120
! 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'C' , 'R' , 'C' , & ! 121 - 130
! 'R' , 'C' , 'R' , 'C' , 'R' , 'C' , 'R' , 'C' , 'C' , ' ' , & ! 131 - 140
! ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , & ! 141 - 150
! ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' / ! 151 - 160
!xx DATA TYPE &
!xx / 'NDDA' , 'PC ' , 'PC* ' , 'ELAS' , 'ELAS' , 'DAMP' , 'DAMP' , 'MASS' , 'MASS' , 'ROD ' , & ! 1 - 10
!xx 'TUBE' , 'VISC' , 'DAMP' , 'DAMP' , 'ELAS' , 'ELAS' , 'MASS' , 'MASS' , 'AXIF' , 'AXIF' , & ! 11 - 20
!xx 'AXIF' , 'BAR ' , 'CONE' , 'FLUI' , 'FLUI' , 'FLUI' , 'HBDY' , 'HEXA' , 'HEXA' , 'HTTR' , & ! 21 - 30
!xx 'IS2D' , 'IS2D' , 'IS3D' , 'IS3D' , 'ONM1' , 'ONM2' , 'ONRO' , 'QDME' , 'QDME' , 'QDME' , & ! 31 - 40
!xx 'QDPL' , 'QUAD' , 'QUAD' , 'SHEA' , 'SLOT' , 'SLOT' , 'TETR' , 'TORD' , 'TRAP' , 'TRBS' , & ! 41 - 50
!xx 'TRIA' , 'TRIA' , 'TRIA' , 'TRME' , 'TRPL' , 'TWIS' , 'WEDG' , 'DUMM' , 'DUM1' , 'DUM2' , & ! 51 - 60
!xx 'DUM3' , 'DUM4' , 'DUM5' , 'DUM6' , 'DUM7' , 'DUM8' , 'DUM9' , 'TRIA' , 'TRIM' , 'DAMP' , & ! 61 - 70
!xx 'ELAS' , 'MASS' , 'DAMP' , 'ELAS' , 'MASS' , 'ONM1' , 'ONM2' , 'ONRO' , 'IHEX' , 'IHEX' , & ! 71 - 80
!xx 'IHEX' , 'TRAP' , 'TRIA' , 'QUAD' , 'TRIA' , 'QDME' , 'HEX8' , 'HEX2' , 'TRPL' , 'TRSH' , & ! 81 - 90
!xx 'RIGD' , 'RIGD' , 'RIGD' , 'BEAM' , 'FTUB' , 'HEXA' , 'PENT' , 'QUAD' , 'TRIA' , 'LOOF' , & ! 91 - 100
!xx 'LOOF' , 'LOOF' , 'BEND' , 'GAP ' , 'QUAD' , 'TRIA' , 'ELBO' , 'FHEX' , 'FHEX' , 'FTET' , & ! 101 - 110
!xx 'FWED' , 'PCAX' , 'AABS' , 'BUSH' , 'BUSH' , 'DAMP' , 'HBDY' , 'QUAD' , 'TRIA' , 'WELD' , & ! 111 - 120
!xx 'HACA' , 'HACB' , 'QUAD' , 'QUAD' , 'RAC2' , 'RAC3' , 'TRIA' , 'RBAR' , 'BAR ' , 'RBE1' , & ! 121 - 130
!xx 'BE1 ' , 'RBE2' , 'BE2 ' , 'RROD' , 'ROD ' , 'RTRP' , 'TRPL' , 'QUAD' , 'TRIA' , ' ' , & ! 131 - 140
!xx ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , & ! 141 - 150
!xx ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' / ! 151 - 160
DATA TYPE &
/ 4HNDDA , 4HPC , 4HPC* , 4HELAS , 4HELAS , 4HDAMP , 4HDAMP , 4HMASS , 4HMASS , 4HROD , & ! 1 - 10
4HTUBE , 4HVISC , 4HDAMP , 4HDAMP , 4HELAS , 4HELAS , 4HMASS , 4HMASS , 4HAXIF , 4HAXIF , & ! 11 - 20
4HAXIF , 4HBAR , 4HCONE , 4HFLUI , 4HFLUI , 4HFLUI , 4HHBDY , 4HHEXA , 4HHEXA , 4HHTTR , & ! 21 - 30
4HIS2D , 4HIS2D , 4HIS3D , 4HIS3D , 4HONM1 , 4HONM2 , 4HONRO , 4HQDME , 4HQDME , 4HQDME , & ! 31 - 40
4HQDPL , 4HQUAD , 4HQUAD , 4HSHEA , 4HSLOT , 4HSLOT , 4HTETR , 4HTORD , 4HTRAP , 4HTRBS , & ! 41 - 50
4HTRIA , 4HTRIA , 4HTRIA , 4HTRME , 4HTRPL , 4HTWIS , 4HWEDG , 4HDUMM , 4HDUM1 , 4HDUM2 , & ! 51 - 60
4HDUM3 , 4HDUM4 , 4HDUM5 , 4HDUM6 , 4HDUM7 , 4HDUM8 , 4HDUM9 , 4HTRIA , 4HTRIM , 4HDAMP , & ! 61 - 70
4HELAS , 4HMASS , 4HDAMP , 4HELAS , 4HMASS , 4HONM1 , 4HONM2 , 4HONRO , 4HIHEX , 4HIHEX , & ! 71 - 80
4HIHEX , 4HTRAP , 4HTRIA , 4HQUAD , 4HTRIA , 4HQDME , 4HHEX8 , 4HHEX2 , 4HTRPL , 4HTRSH , & ! 81 - 90
4HRIGD , 4HRIGD , 4HRIGD , 4HBEAM , 4HFTUB , 4HHEXA , 4HPENT , 4HQUAD , 4HTRIA , 4HLOOF , & ! 91 - 100
4HLOOF , 4HLOOF , 4HBEND , 4HGAP , 4HQUAD , 4HTRIA , 4HELBO , 4HFHEX , 4HFHEX , 4HFTET , & ! 101 - 110
4HFWED , 4HPCAX , 4HAABS , 4HBUSH , 4HBUSH , 4HDAMP , 4HHBDY , 4HQUAD , 4HTRIA , 4HWELD , & ! 111 - 120
4HHACA , 4HHACB , 4HQUAD , 4HQUAD , 4HRAC2 , 4HRAC3 , 4HTRIA , 4HRBAR , 4HBAR , 4HRBE1 , & ! 121 - 130
4HBE1 , 4HRBE2 , 4HBE2 , 4HRROD , 4HROD , 4HRTRP , 4HTRPL , 4HQUAD , 4HTRIA , 4H , & ! 131 - 140
4H , 4H , 4H , 4H , 4H , 4H , 4H , 4H , 4H , 4H , & ! 141 - 150
4H , 4H , 4H , 4H , 4H , 4H , 4H , 4H , 4H , 4H / ! 151 - 160
! CWELD probably should not be in this list, but it was retained rather than deal with correcting all the places in the code which
! reference elements by number (e.g., rigid elements).
!xx DATA WYPE &
!xx / 'TA ' , ' ' , ' ' , '1 ' , '2 ' , '1 ' , '2 ' , '1 ' , '2 ' , ' ' , & ! 1 - 10
!xx ' ' , ' ' , '3 ' , '4 ' , '3 ' , '4 ' , '3 ' , '4 ' , '2 ' , '3 ' , & ! 11 - 20
!xx '4 ' , ' ' , 'AX ' , 'D2 ' , 'D3 ' , 'D4 ' , ' ' , '1 ' , '2 ' , 'I2 ' , & ! 21 - 30
!xx '4 ' , '8 ' , '8 ' , '20 ' , ' ' , ' ' , 'D ' , 'M ' , 'M1 ' , 'M2 ' , & ! 31 - 40
!xx 'T ' , '1 ' , '2 ' , 'R ' , '3 ' , '4 ' , 'A ' , 'RG ' , 'RG ' , 'C ' , & ! 41 - 50
!xx '1 ' , '2 ' , 'RG ' , 'M ' , 'T ' , 'T ' , 'E ' , 'Y ' , ' ' , ' ' , & ! 51 - 60
!xx ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , 'X6 ' , '6 ' , '4* ' , & ! 61 - 70
!xx '4* ' , '4* ' , '2* ' , '2* ' , '2* ' , '* ' , '* ' , 'D* ' , '1 ' , '2 ' , & ! 71 - 80
!xx '3 ' , 'AX ' , 'AX ' , 'TS ' , 'TS ' , 'M3 ' , ' ' , '0 ' , 'T1 ' , 'L ' , & ! 81 - 90
!xx '1 ' , '2 ' , 'R ' , ' ' , 'E ' , ' ' , 'A ' , '4 ' , '3 ' , '3 ' , & ! 91 - 100
!xx '6 ' , '8 ' , ' ' , ' ' , '8 ' , '6 ' , 'W ' , '1 ' , '2 ' , 'RA ' , & ! 101 - 110
!xx 'GE ' , ' ' , 'F ' , ' ' , '1D ' , '5 ' , 'P ' , 'R ' , 'R ' , ' ' , & ! 111 - 120
!xx 'B ' , 'R ' , ' ' , 'X ' , 'D ' , 'D ' , 'X ' , ' ' , ' ' , ' ' , & ! 121 - 130
!xx ' ' , ' ' , ' ' , ' ' , ' ' , 'LT ' , 'T ' , '4K ' , '3K ' , ' ' , & ! 131 - 140
!xx ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , & ! 141 - 150
!xx ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' , ' ' / ! 151 - 160
DATA WYPE &
/ 3HTA , 3H , 3H , 3H1 , 3H2 , 3H1 , 3H2 , 3H1 , 3H2 , 3H , & ! 1 - 10
3H , 3H , 3H3 , 3H4 , 3H3 , 3H4 , 3H3 , 3H4 , 3H2 , 3H3 , & ! 11 - 20
3H4 , 3H , 3HAX , 3HD2 , 3HD3 , 3HD4 , 3H , 3H1 , 3H2 , 3HI2 , & ! 21 - 30
3H4 , 3H8 , 3H8 , 3H20 , 3H , 3H , 3HD , 3HM , 3HM1 , 3HM2 , & ! 31 - 40
3HT , 3H1 , 3H2 , 3HR , 3H3 , 3H4 , 3HA , 3HRG , 3HRG , 3HC , & ! 41 - 50
3H1 , 3H2 , 3HRG , 3HM , 3HT , 3HT , 3HE , 3HY , 3H , 3H , & ! 51 - 60
3H , 3H , 3H , 3H , 3H , 3H , 3H , 3HX6 , 3H6 , 3H4* , & ! 61 - 70
3H4* , 3H4* , 3H2* , 3H2* , 3H2* , 3H* , 3H* , 3HD* , 3H1 , 3H2 , & ! 71 - 80
3H3 , 3HAX , 3HAX , 3HTS , 3HTS , 3HM3 , 3H , 3H0 , 3HT1 , 3HL , & ! 81 - 90
3H1 , 3H2 , 3HR , 3H , 3HE , 3H , 3HA , 3H4 , 3H3 , 3H3 , & ! 91 - 100
3H6 , 3H8 , 3H , 3H , 3H8 , 3H6 , 3HW , 3H1 , 3H2 , 3HRA , & ! 101 - 110
3HGE , 3H , 3HF , 3H , 3H1D , 3H5 , 3HP , 3HR , 3HR , 3H , & ! 111 - 120
3HB , 3HR , 3H , 3HX , 3HD , 3HD , 3HX , 3H , 3H , 3H , & ! 121 - 130
3H , 3H , 3H , 3H , 3H , 3HLT , 3HT , 3H4K , 3H3K , 3H , & ! 131 - 140
3H , 3H , 3H , 3H , 3H , 3H , 3H , 3H , 3H , 3H , & ! 141 - 150
3H , 3H , 3H , 3H , 3H , 3H , 3H , 3H , 3H , 3H / ! 151 - 160
DATA ME/ &
0 , 0 , 0 , 34 , 34 , 34 , 34 , 34 , 34 , 24 , & ! 1 - 10
24 , 24 , 24 , 24 , 24 , 24 , 24 , 24 , 23 , 33 , & ! 11 - 20
43 , 24 , 24 , 23 , 33 , 43 , 45 , 84 , 84 , 34 , & ! 21 - 30
44 , 84 , 83 , 203 , 13 , 13 , 23 , 44 , 44 , 44 , & ! 31 - 40
44 , 44 , 44 , 44 , 33 , 43 , 44 , 24 , 43 , 34 , & ! 41 - 50
34 , 34 , 33 , 34 , 34 , 44 , 64 , 402 , 4 , 4 , & ! 51 - 60
4 , 4 , 4 , 4 , 4 , 4 , 4 , 64 , 64 , 24 , & ! 61 - 70
24 , 24 , 34 , 34 , 34 , 13 , 13 , 23 , 84 , 204 , & ! 71 - 80
324 , 44 , 34 , 44 , 34 , 44 , 84 , 204 , 64 , 64 , & ! 81 - 90
10 , 10 , 23 , 24 , 24 , 204 , 154 , 44 , 34 , 34 , & ! 91 - 100
64 , 84 , 24 , 24 , 84 , 64 , 24 , 84 , 84 , 44 , & ! 101 - 110
64 , 0 , 44 , 24 , 24 , 24 , 27 , 44 , 34 , 14 , & ! 111 - 120
204 , 204 , 94 , 94 , 184 , 644 , 64 , 23 , 23 , 10 , & ! 121 - 130
10 , 10 , 10 , 23 , 23 , 33 , 33 , 44 , 34 , 0 , & ! 131 - 140
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , & ! 141 - 150
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 / ! 151 - 160
! ME(I)=10*NCON+IFLD (for element type I) where
! NCON = Number of connections per element (see subroutine ELTYPE)
! IFLD = Field number of first connection.
END BLOCK DATA BANDIT_BLOCK_DATA
| Source/BANDIT/BANDIT_BLOCK_DATA.f90 |
Davis soils vary from moderately sandy (http://ortho.ftw.nrcs.usda.gov/osd/dat/R/REIFF.html Reiff Series) in South Davis south and East Davis, through loamy soils (http://ortho.ftw.nrcs.usda.gov/osd/dat/Y/YOLO.html Yolo Series) in Central Davis, to heavy clay soils (http://ortho.ftw.nrcs.usda.gov/osd/dat/C/CAPAY.html Caypay Series) in West Davis west and North Davis. The spatial variation of soil properties in Davis is directly related to the fluvial deposition histories of the nearby streams. The heavy soils are found where low velocity waters of Putah Creek deposited material from the Coast Range. This material is notorious for having high concentrations of exotic elements; however the local high concentration of the element wiki:WikiPedia:Boron is most likely from ground water. Sandier soils are found in locations where depositional energies were higher, or where material from the Sierra Nevada was incorporated. For specifics on the type of soil at your address, check out the http://casoilresource.lawr.ucdavis.edu/drupal/node/902 UC Davis Soil Resource Labs Online Soil Survey.
Use as a growth media
The soils found in and around Davis are often thought of as a poor growth medium. While this may be true for an wiki:WikiPedia:Cultivate uncultivated parcel of land where one attempts to plant seedlings by hand, but in terms of water storage capacity and nutrient storage the soils found here are some of the most productive in the world. The surface cracking observed in the summer is a result of the high content of wiki:WikiPedia:Smectite smectitic wiki:WikiPedia:Clay clays, derived from weathered Coast Range rocks. The shrinking and swelling effects of these heavy clay soils (http://ortho.ftw.nrcs.usda.gov/osd/dat/C/CAPAY.html Capay Series) not only make it difficult to plant a vegetable garden, but also wreak havoc on houses or permanent structures. By incorporating copious amounts of mulch it is possible to create a rooting environment hospitable for seedlings, while retaining the high water holding capacity and nutrient store that the local soils offer. Similarly, you can lower the rate at which house plants dry out by incorporating a small amount of local soil into existing potting mix.
pH issues
The pH of soils found in and around the city of Davis range from neutral (7) to alkaline (> 8.5). While this condition does not affect plants native to this region, many plants may not be able to readily access several key micronutrients at this pH. As a general rule of thumb, a pH near 8.2 suggests that CaCO,,3,, is the main buffering agent, and at pH near 8.5 Na,,2,,CO,,3,, is the main buffering agent. It is very common in this region for soils with a high pH to also have a high sodium content as well. The sodium is usually more toxic than the high pH, although at higher pH values important micro nutrients such as Iron are less available to plants.
If you were to draw a rectangle around all of Davis and surrounding sprawl you would find that on a perarea basis only about 16% of the land has a http://soils.usda.gov/technical/handbook/contents/part618.html#48 moderately alkaline pH value (Yolo County Soil Survey).
Expected ShrinkSwell by Map Unit
Soils in Yolo County, as tabulated by expected http://soils.usda.gov/technical/handbook/contents/part618.html#38 Linear Extensibility Percent (lep).
{{{
musym | name | acres | lep | lep_class
++++
Ya | Yolo silt loam | 39698 | 2.52 | Low
Sc | Sacramento clay | 34886 | 7.50 | High
Ca | Capay silty clay | 33465 | 7.50 | High
MrG2 | Millsholm rocky loam, 15 to 75 percent slopes, eroded | 30118 | 1.50 | Low
Rg | Rincon silty clay loam | 24580 | 6.36 | High
BrA | Brentwood silty clay loam, 0 to 2 percent slopes | 23045 | 7.50 | High
CtD2 | Corning gravelly loam, 2 to 15 percent slopes, eroded | 22080 | 5.34 | Moderate
Mf | Marvin silty clay loam | 20970 | 6.60 | High
DaF2 | Dibble clay loam, 30 to 50 percent slopes, eroded | 18612 | 7.11 | High
SmE2 | SehornBalcom complex, 15 to 30 percent slopes, eroded | 17794 | 6.17 | High
TaA | Tehama loam, 0 to 2 percent slopes | 16622 | 3.75 | Moderate
BdF2 | BalcomDibble complex, 30 to 50 percent slopes, eroded | 16405 | 5.73 | Moderate
SmD | SehornBalcom complex, 2 to 15 percent slopes | 16117 | 6.50 | High
BaF2 | Balcom silty clay loam, 30 to 50 percent slopes, eroded | 12637 | 4.50 | Moderate
Sg | Sacramento soils, flooded | 12258 | 6.27 | High
Cn | Clear Lake soils, flooded | 11666 | 6.92 | High
SmF2 | SehornBalcom complex, 30 to 50 percent slopes, eroded | 11226 | 6.33 | High
Cc | Capay soils, flooded | 11030 | 7.50 | High
Sv | Sycamore complex, drained | 9241 | 4.18 | Moderate
Ms | Myers clay | 8938 | 7.50 | High
PfF2 | Positas gravelly loam, 30 to 50 percent slopes, eroded | 7920 | 5.34 | Moderate
St | Sycamore silty clay loam, drained | 7839 | 4.50 | Moderate
Ck | Clear Lake clay | 6946 | 7.50 | High
Ra | Reiff very fine sandy loam | 6847 | 1.50 | Low
SkD | Sehorn clay, 2 to 15 percent slopes | 6069 | 7.50 | High
Sp | Sycamore silt loam, drained | 6054 | 3.42 | Moderate
Sa | Sacramento silty clay loam | 6023 | 6.27 | High
DbG2 | DibbleMillsholm complex, 50 to 75 percent slopes, eroded | 5846 | 5.24 | Moderate
Wb | Willows clay | 5624 | 7.50 | High
Sw | Sycamore complex, flooded | 5517 | 4.18 | Moderate
Ss | Sycamore silty clay loam | 5489 | 4.50 | Moderate
Pb | Pescadero silty clay, salinealkali | 5281 | 7.50 | High
BaE2 | Balcom silty clay loam, 15 to 30 percent slopes, eroded | 5192 | 4.50 | Moderate
Yb | Yolo silty clay loam | 5040 | 4.50 | Moderate
PfF3 | Positas gravelly loam, 30 to 50 percent slopes, severely eroded | 4584 | 6.00 | High
So | Sycamore silt loam | 4474 | 3.42 | Moderate
Rh | Riverwash | 4369 | 1.50 | Low
Sh | San Ysidro loam | 4289 | 4.44 | Moderate
HcA | Hillgate loam, 0 to 2 percent slopes | 4029 | 5.19 | Moderate
Tb | Tyndall very fine sandy loam | 3726 | 1.50 | Low
Pc | Pescadero soils, flooded | 3589 | 5.22 | Moderate
Za | Zamora loam | 3466 | 3.75 | Moderate
Ob | Omni silty clay | 3342 | 7.50 | High
Su | Sycamore complex | 3206 | 4.14 | Moderate
La | Lang sandy loam | 3001 | 1.50 | Low
Wc | Willows clay, alkali | 2929 | 7.50 | High
DaG2 | Dibble clay loam, 50 to 75 percent slopes, eroded | 2874 | 7.11 | High
Wf | Willows clay, alkali, flooded | 2816 | 7.50 | High
Te | Tyndall very fine sandy loam, deep | 2709 | 1.50 | Low
Sb | Sacramento silty clay loam, drained | 2663 | 6.27 | High
Cb | Capay silty clay, flooded | 2410 | 7.50 | High
AaA | Arbuckle gravelly loam, 0 to 2 percent slopes | 2391 | 3.48 | Moderate
Sd | Sacramento clay, drained | 2384 | 7.50 | High
HdA | Hillgate loam, moderately deep, 0 to 2 percent slopes | 2367 | 3.63 | Moderate
Mk | Merritt silty clay loam | 2289 | 3.57 | Moderate
Sr | Sycamore silt loam, flooded | 2256 | 3.42 | Moderate
Vb | Valdez silt loam, deep | 2222 | 3.42 | Moderate
Sn | Soboba gravelly sandy loam | 2205 | 1.50 | Low
Lg | Laugenour very fine sandy loam | 2202 | 1.50 | Low
SlD | Sehorn cobbly clay, 2 to 15 percent slopes | 2163 | 7.50 | High
SkF2 | Sehorn clay, 30 to 50 percent slopes, eroded | 2155 | 7.50 | High
Lb | Lang sandy loam, deep | 2123 | 1.50 | Low
Mn | Merritt silty clay loam, deep | 2112 | 3.57 | Moderate
163n | MaymenMillsholmLodo association, 3075 percent slopes | 2092 | 2.25 | Low
PfE2 | Positas gravelly loam, 15 to 30 percent slopes, eroded | 2072 | 5.34 | Moderate
Tc | Tyndall very fine sandy loam, drained | 1989 | 1.50 | Low
Rb | Reiff gravelly loam | 1914 | 1.50 | Low
Mo | Merritt silty clay loam, deep, drained | 1858 | 3.57 | Moderate
DbF2 | DibbleMillsholm complex, 30 to 50 percent slopes, eroded | 1788 | 4.47 | Moderate
SkE2 | Sehorn clay, 15 to 30 percent slopes, eroded | 1775 | 7.50 | High
Lm | Loamy alluvial land | 1708 | 1.50 | Low
Md | Maria silt loam, deep | 1661 | 3.51 | Moderate
Mb | Maria silt loam | 1644 | 3.51 | Moderate
Wa | Willows silty clay loam | 1458 | 6.36 | High
Wm | Willows clay, marly variant | 1420 | 7.50 | High
HcC2 | Hillgate loam, 2 to 9 percent slopes, eroded | 1385 | 5.10 | Moderate
Wg | Willows soils, flooded | 1331 | 5.97 | Moderate
AaB | Arbuckle gravelly loam, 2 to 5 percent slopes | 1326 | 3.48 | Moderate
TaB | Tehama loam, 2 to 5 percent slopes | 1242 | 3.75 | Moderate
Lk | Laugenour very fine sandy loam, deep, flooded | 1180 | 1.50 | Low
Lh | Laugenour very fine sandy loam, flooded | 1172 | 1.50 | Low
Rk | Riz loam | 1166 | 6.00 | High
CtE2 | Corning gravelly loam, 15 to 30 percent slopes, eroded | 1063 | 5.34 | Moderate
HdC | Hillgate loam, moderately deep, 2 to 9 percent slopes | 1060 | 3.63 | Moderate
Mp | Merritt complex, salinealkali | 897 | 3.57 | Moderate
DbE2 | DibbleMillsholm complex, 9 to 30 percent slopes, eroded | 804 | 5.13 | Moderate
Mc | Maria silt loam, flooded | 793 | 3.51 | Moderate
Rn | Riz loam, flooded | 787 | 6.00 | High
Ld | Lang silt loam | 744 | 1.50 | Low
Tf | Tyndall silty clay loam | 741 | 2.25 | Low
Pa | Pescadero silty clay | 727 | 7.50 | High
Td | Tyndall very fine sandy loam, flooded | 684 | 1.50 | Low
114n | BressaDibble complex, 30 to 50 percent slopes | 666 | 4.15 | Moderate
Sf | Sacramento clay, deep | 645 | 7.50 | High
Vc | Valdez complex, flooded | 645 | 3.42 | Moderate
Va | Valdez silt loam | 581 | 3.42 | Moderate
Wd | Willows clay, alkali, drained | 566 | 7.50 | High
Wn | Willows clay, marly variant, salinealkali | 553 | 7.50 | High
Se | Sacramento clay, flooded | 544 | 7.50 | High
Oa | Omni silty clay loam | 523 | 6.60 | High
Ch | Clear Lake silty clay loam | 402 | 5.97 | Moderate
142l | HennekeMontaraRock outcrop complex, 15 to 50 percent slopes | 366 | 4.50 | Moderate
CrE2 | Climara clay, 2 to 30 percent slopes, eroded | 333 | 7.50 | High
BaD3 | Balcom silty clay loam, 5 to 15 percent slopes, severely eroded | 312 | 4.50 | Moderate
154n | Henneke gravelly loam, 30 to 75 percent slopes | 303 | 3.08 | Moderate
Lc | Lang sandy loam, deep, flooded | 280 | 1.50 | Low
BaG3 | Balcom silty clay loam, 50 to 75 percent slopes, severely eroded | 264 | 4.50 | Moderate
112c | Westfan loam, 0 to 2 percent slopes | 260 | 3.42 | Moderate
115c | Clear Lake clay, 0 to 1 percent slopes,occasionally flooded | 160 | 9.59 | Very High
166n | Montara clay loam, 5 to 30 percent slopes | 145 | 4.50 | Moderate
115n | BressaDibble complex, 50 to 75 percent slopes | 142 | 4.12 | Moderate
320c | Millsholm loam, 5 to 30 percent slopes | 113 | 1.92 | Low
160c | Grandbend loam, 0 to 2 percent slopes | 107 | 4.27 | Moderate
127c | Mallard clay loam, 0 to 1 percent slopes | 100 | 5.93 | Moderate
174l | MaymenHoplandMayacama association, 50 to 75 percent slopes | 66 | 2.75 | Low
GP | Gravel pits | 61 | 1.50 | Low
114c | Westfan clay loam, 0 to 1 percent slopes | 59 | 4.58 | Moderate
188c | Westfan loam, clay substratum, 0 to 2 percent slopes | 58 | 4.32 | Moderate
173l | MaymenHoplandMayacama association, 30 to 50 percent slopes | 42 | 2.75 | Low
280c | SkyhighMillsholm complex, 15 to 50 percent slopes | 24 | 3.59 | Moderate
171l | MaymenHoplandEtsel association, 15 to 50 percent slopes | 24 | 2.43 | Low
129c | Mallard clay loam, 0 to 1 percent slopes, occasionally flooded | 21 | 5.80 | Moderate
108c | Scribner silt loam, 0 to 1 percent slopes | 20 | 2.86 | Low
129n | Diablo clay, 30 to 50 percent slopes | 7 | 7.50 | High
165n | Millsholm loam, 30 to 75 percent slopes | 7 | 1.50 | Low
}}}
| lab/davisWiki/Soil.f |
I am Cristina Deptula, and Ive just graduated from UCD with a degree in Comparative Literature and a minor in Biology. Im now back in the Bay Area with family, helping out and hoping to have a place of my own in the near future. I currently do a lot of http://ladycatherina.livejournal.com/ blogging.
I formerly worked at the UC Davis Annual Fund, raising money from alumni, and also did science reporting for the California Aggie. I also put in some hours doing data entry for theJohn Natsoulas Art Gallery downtown.
I encourage everyone to visit the site http://www.freebatteredwomen.org freebatteredwomen.org they work with women in prison who have committed crimes as a result of domestic abuse they faced i.e. selfdefense, writing bad checks to survive, not reporting certain crimes to the cops quickly enough because of threats to their children, etc. The founders of this group are leaders in the Habeas Project a group of lawyers trying to get the psychological effects of domestic violence to be taken into account when these women are being sentenced in court, often by giving already incarcerated women new trials. They also have a pen pal project, where women can make friends and develop an outside support system to help them better return to normal society when they do get released. There are also plenty of quick and easy online petitions and actions to take on the site as well as info about trying to deal with the root causes of social problems rather than criminalize particular people.
I am involved in various campus organizations thanks to all of you who attended the Valentines Day benefit concert for refugees in Sudan organized by Students Taking Action Now on Darfur.
I also volunteered with children in Sacramento every Tuesday afternoon from three to six thats a whole lot of fun, we are always desperately seeking mentors, especially guys. Contact Kirsten at klepfer@cahouse.org for more information you get 2 units of credit.
And I helped put on the Whole Earth Festival every year, as well as showing up to haunt various meetings of Students for an Orwellian Society SOS, the English Country Dancers, and a lot of the art gallery openings and free classical concerts and poetry readings on campus and around town. I was also involved with Food Not Bombs which takes extra food from the Delta of Venus and the Food CoOp that might otherwise be thrown away and distributes it to people for free in Central Park. If youre interested in helping out, we meet at the Agrarian Effort Coop House at 10 am every Sunday.
In my spare time, I enjoy reading favorite novels of mine include Peace like a River by Leif Enger, Wuthering Heights by Emily Bronte, and A Wrinkle in Time by Madeleine LEngle (yes its a kids book but its still very good.) I enjoy poetry by Robert Frost, Elizabeth Barrett Browning, Sylvia Plath, and Jack Kerouac, as well as reading the BhagavadGita and Anne Lamotts Traveling Mercies. Ive also just finished Alice Sebolds Lovely Bones quirky, interesting read.
Favorite movies include Chocolat, the Matrix, the Lord of the Rings and Star Wars trilogies, Under the Tuscan Sun, and the Phantom of the Opera. And I like all kinds of music, everything from Sarah Brightman opera stuff to rock to classical. I have just about all kinds of CDs except for rap and hip hop because I get to hear that in everyones car and at work.
Favorite restaurants I am vegetarian/vegan so this is a bit of a challenge for me, but there are some great places around. I love the Delta of Venus, Chipotle, Kathmandu Kitchen, El Mariachi, and Quiznos and Fuzio Fuzios and Caffe Italia and the Pita Pit are ok too. The Bean and Rice burritos on campus arent too bad either.
Favorite websites check out the cute kids at www.annegeddes.com, play the game Text Twist, under Word Games at www.yahoo.com, and make a difference in the world for free at www.thehungersite.com
If you have poetry or artwork to submit, then please check out Muse Matrix this is a somewhat hippieish counterculture magazine put out by my friend Yasa. Past issues are available online, and she also holds quarterly Muse Faires at the Delta of Venus in the afternoon the next one is July 23rd. If you would like to submit anything, then please contact her at tmm@omsoft.org
Id also encourage everyone to buy a copy of The Spare Changer when you see the homeless selling it downtown it represents legitimate work and an honest living for them, as well as a way for voices and perspectives to get out that arent normally heard. Ive been through plenty of hard times and struggles to get the rent paid that I can empathize with the lessthanhoused especially with housing costs the way they are now. Please also contact me if theres anything you think the city or other groups could do about the housing problem I am thinking of writing a resolution for the ASUCD Senate and trying to get a senator to introduce it this fall.
I also like to be out in nature hiking, swimming, etc. Also I love creative writing, have some poems and two short novellas and a short story written but am not sure where to go with them. Also I love babies and little children, and will often wave and smile at them.
A fun weird fact about me: when I was about six I was at a science museum with my family that was built on the top of a large hill. As we were walking out towards our car, I decided to try an experiment of my own and see what would happen if I took my shoes off and threw them down all the way to the lower parking levels. Turned out my parents werent too happy as they had to carry my barefoot self down at least a mile so I could find the shoes again. Now every time we go there everyone points out where I threw down my shoes!
Contact info MailTo(cedeptula AT ucdavis DOT edu), MailTo(starbaby5 AT hotmail DOT com), 5105898252 I am also LadyCatherina on Live Journal.
20050806 14:15:27 nbsp Hi, Im Derek. I live at Davis Student Coop and do Food Not Bombs nowadays. How long ago did you leave UCD? Users/DerekDowney
20050806 16:18:54 nbsp It was a little under two months ago that she left. Users/BrentLaabs
20060312 15:25:52 nbsp Oh, I remember this Cristina Deptula. She was completely selfabsorbed. She was a hardcore Reborn Christian, and antichoice activist. I was in a class with her, and she brought huge posters of bloody fetuses to our class! Unbelieveable. She had been in a rally on the Quad. Throughout that class, she was annoying to all of us. No one would ever want to be partnered with her. And the professor would bring food, and she would hog it! Instead of passing it, she would sit with the chips & dip on her desk & eat & eat! She was simply oblivious. Very poor social skills. Users/IsabelleSandoval
20060312 15:42:19 nbsp Ill balance out that negativity with some good things to say, because I thought Cristina was a great person. I first met her in 2004 at an open mic at Espresso Roma at which I played music and she read poetry. I made her acquaintance that night because I was quite impressed by her poetry. After that I ended up running into her at many other events including the Beat Generation conference, a Bach concert by the Music department, a poetry reading by Dr. Andy Jones Andy Jones, the Whole Earth Festival, and rallies in the Quad. Through our conversations at each of these encounters, she struck me as a very kind person and a true artist who was passionate about her work and artistic expression in general. Users/BrianAng
20060314 00:26:39 nbsp I.S. comment is unbelievable. Cristina was the most socially involved person Ive met in Davis. She donated her time to Food Not Bombs, wrote for the Muse Matrix, was a great lover of the arts, went to music events, she was The Aggie CA science writer, and is technically highly knowlegable. Actually, she is greatly missed. Why I.S. would want to go out of her way to bash her a year after shes been here is itself revealing. Users/SteveDavison
Hi everyone, its been a long time since I saw this page, been working in our family business (electrical testing) but just drove through Davis on the way to a family vacation in Tahoe and it brought back old memories.
I have to admit, I am fairly socially progressive and do not remember ever being involved with an militant religious or antichoice group, perhaps the author of one of the comments above meant someone else by mistake?? I mentored children through the Cal Aggie Christian Association and attended some Belfry dinners. I admit I can be and have been socially oblivious at times and regret ever offending anyone, though.
Im still working on revising the novel, and am now involved with a friendshippartner group for local Bay Area international students. Also I serve as an Exhibit Explorer (docent) for the Chabot Space and Science Museum in the Oakland hills, where we have planetarium shows and some of Californias largest telescopes. I encourage people to check us out online at www.chabotspace.org.
Cristina Deptula
| lab/davisWiki/CristinaDeptula.f |
program ch0808
! Initialising a Rank 2 Array
implicit none
integer, dimension(1:2,1:4) :: x
integer, dimension(1:8) :: y = [ 1,2,3,4,5,6,7,8 ]
integer, dimension(1:6) :: z = [ 1,2,3,4,5,6 ]
integer :: r, c
print *, ' Source array y'
print *, y
print *, ' Source array z'
print *, z
print *, ' Simple reshape sizes match'
x = reshape(y, [2,4])
do r = 1, 2
print *, (x(r,c), c=1,4)
end do
print *, &
' Source 2 elements smaller pad with 0'
x = reshape(z, [2,4], [0,0])
do r = 1, 2
print *, (x(r,c), c=1,4)
end do
print *, &
' As previous now specify order as 1*2'
x = reshape(z, [2,4], [0,0], [1,2])
do r = 1, 2
print *, x(r, 1:4)
end do
print *, &
' As previous now specify order as 2*1'
x = reshape(z, [2,4], [0,0], [2,1])
do r = 1, 2
print *, x(r, 1:4)
end do
end program
| ch08/ch0808.f90 |
c--- This is just a wrapping routine that calls ovBtensor or pvBtensor
subroutine doBtensor(q1,m1s,m2s,FB0,FB1,FB2,FB3,FB4,FB5,FB6)
implicit none
C q1 is the momentum in the loop = p1 the external momenta
C m1s,m2s are the squares of the internal masses
include 'TRconstants.f'
include 'TRydef.f'
include 'TRtensorcontrol.f'
double complex FB0(-2:0),FB1(y1max,-2:0),
. FB2(y2max,-2:0),FB3(y3max,-2:0),FB4(y4max,-2:0),FB5(y5max,-2:0)
. ,FB6(y6max,-2:0),B00(-2:0)
double precision q1(4),m1s,m2s
if (doovred) then
call ovBtensor(q1,m1s,m2s,FB0,FB1,FB2,B00)
FB3=czip
FB4=czip
FB5=czip
FB6=czip
endif
if (dopvred) then
call pvBtensor(q1,m1s,m2s,FB0,FB1,FB2,FB3,FB4,FB5,FB6)
endif
return
end
| MCFM-JHUGen/TensorReduction/ov/doBtensor.f |
23199714
1621271
138818744
834609484781723648
1017362388
136929871
2481903636
354407387
2906848635
540674893
186128496
507198975
295026514
558588624
1569924396
35454045
43950975
1634030149
998222186
2605875176
96820315
2662980740
2789895130
633606034
481811490
560403290
324819266
3405780953
340769958
341559520
1281661724
110435946
2291248569
496403271
1080541916
4442353348
24530838
434275546
1928227544
366816895
580560991
2945669807
557087377
2874213784
388461970
2549466132
574580616
4357240872
486425813
724917795079741440
1247091241
3111515590
45590414
1298730000
2939650787
330831354
2442280965
3136965616
2699099287
2599730384
3682704437
725927791967903744
725998491735101440
724937676412080129
2250034670
727867248782790657
4734166335
27122856
2659485470
2830073170
1262961152
2440899441
92694730
2789564389
608941888
703874334
82045152
697454264730447873
723683524180643840
723136945031782400
103094352
733259961531289600
3090253113
65563900
509077455
3494654667
729212183603712000
481207181
547777665
360191670
3353009285
104591849
3743821876
952022059
2651183126
462997522
1105742726
1917406862
2943823095
61296702
3320471614
1311985584
1250247966
249080709
4895140055
715100122531627008
732487610518503424
721317224942845952
2383664988
4189024169
1140053167
230125834
541235793
729468843903623168
3110465819
302207777
36078924
1896818304
64773612
2917859649
724358936699252737
455901680
2990545335
1880135312
731582593519501312
2835153977
55980494
1318312459
712556493799825408
4857479320
723633582133108736
2900935736
290498830
4578788357
4590449476
731092131012595712
604758453
4651142057
224640169
252988992
1477854732
2987353259
23499057
518607352
21810293
3665825115
1092357295
154889213
2631156946
1656776797
519677161
1136321126
1017185306
226367207
557015313
2943017996
2587052148
2306645190
963918698
3305914769
2435122554
2776994453
553354571
381552452
17807002
4147833796
2285079270
397280720
729990129683681281
2903017780
434814092
1161465204
2246192806
15443070
2417180088
3070698035
2573077267
371169541
2687892719
723163282031267842
401901128
4502026649
711606768888094722
3417809535
2897135325
717282861674586112
23187691
140063693
833104045
2978039710
550209018
110787643
3357243197
2527498520
1057809715
97640047
469744669
708632877848797184
195276491
245566968
3114476074
45922480
482179923
4149372401
391387874
376047382
718752587
947326166
3501937937
2951942165
108364911
590257191
4894508489
97033937
325549412
281987691
708799861
708039868438417409
2841132815
885512732
2340548316
1381371001
2206955611
375128860
4327313001
185563312
718163229688639489
1193730649
122128248
4177684457
637049129
168570446
2463014612
217142700
726738643684069376
720903795014766597
2240797032
2716708047
192845217
993431221
193862917
165498315
2524929121
531479393
2870308797
510739322
2687653093
3092790016
727056717285101568
1499125435
726137471961014272
723875794284584960
3467766861
4856711350
3804110415
370278086
4830241017
1131173179
716563983399002113
121042690
377273564
710909960
702393392110690304
2859084035
1298472422
702845397392355328
272390806
1192699213
718490589130399745
3201165424
808951104
2326784240
35850952
466661397
120398378
2318656670
114802583
395580395
2709894298
978320862
420701443
457499537
102415892
4402839862
94127456
206775475
4150051835
471858391
3363724689
3342384603
2893880289
4842891305
3512513001
3242432224
695323168400109569
4639399997
371893588
4867181962
78146318
469614995
4803599249
2226110531
3088470959
701314647799021568
2355126027
1366200404
286346321
103262082
710050794859589633
2591422526
96946954
2350528788
400666620
1951629301
66360423
36032460
3720477143
1222997371
21194982
3413680606
47934798
899816647
74502363
1694769276
42112994
273040550
1946632910
1966438748
1552568982
563532844
1071244484
3333456653
81080023
538938732
3613939035
4481554947
472868123
311061882
40842078
897133830
724331910470766592
45432933
3042532013
2978275281
2799939672
435695595
562039811
551613937
2716494901
338903391
599953870
204812101
18603001
3388967278
2834867639
187282332
839740902
2390389853
516341995
2829618368
607107715
2359705716
423362657
999470034
2320944697
276621160
548773433
4534179982
2508451480
361360337
14830116
111581885
305011616
260217605
374147701
1449213326
2342217391
577992705
23420768
1579742012
2362417084
273881493
1732018182
3306794361
29342747
3351667792
3374276099
158685917
2986582977
168661474
1251124050
3873853319
111247931
4012235722
2858829037
210783848
3334181171
2989804341
937302973
2353166147
2827874671
2803439756
823964372
2816954922
2331570992
2726483630
2813284346
2330559823
442652589
1965565525
486072501
2815050169
296951260
1865715685
2794648805
2437516058
226870124
310329175
30895508
2799538401
567258445
125702902
2796409414
2804553551
1188052748
2476672210
2831814234
2810405561
42929061
39850194
1447125212
2813257011
14450467
2436581974
1527288114
428282693
1948864974
2425990424
255427084
1392591199
2615657196
1489084716
2829219203
58154152
2812825285
2814314386
2821240817
2832493978
2821192042
471512705
1066745029
2601219439
2789725820
2294568511
2682003570
2846478070
893751926
2809708096
2880498901
2848444414
2792068602
2251558206
2211198257
2834854959
1396644828
2855114147
2870712034
256487850
2826899198
157056600
2875358007
538497558
2341246383
2879837063
28107289
396755414
460534132
1156739112
2841137915
373956829
2828195439
2885633223
2889318363
2878164633
2501236123
2858489327
2245753379
2865399741
1673957107
2873175588
2889368151
304484211
2893886025
2915828567
2576481896
135184026
2953034021
1586026098
1966680140
2910923794
2776002479
389608050
2173044989
213626342
2993999584
1968422762
2528054670
2972749161
1510666562
3000478199
2540901324
102677328
2979698181
2155107440
2312208282
15982316
443776185
2923912390
2376928496
2315775726
535548148
3036227021
234680634
3044642236
388859934
1897297830
331022787
3049244879
3025519599
707393258
273480450
3002922849
3065626967
2163711380
3074963392
1922788352
419042816
1399041906
401957643
2396019564
2881101106
584177512
2949529870
1224837032
366593244
300257837
3099436989
135481986
1306970119
2478215227
2317390682
3094888983
2427751415
3067488669
3129272014
3124633521
627481225
2583738175
728274398
2560039330
124959572
3144528834
3131230065
73154581
2985520720
300181424
2870620977
2672637889
575533621
2912658015
374191149
41453771
2151029990
1454072988
3177939609
2702643219
560253134
2798777409
23502107
1617805693
2894321705
1322689734
3131307064
439159564
526653360
3203996237
428844269
174252433
3207430588
2816624072
2932607526
497172053
3217079043
581548403
2829185309
163925799
2953537841
3058742693
3211754097
361094608
808324592
2999734294
3228584285
2998107110
522313162
2252887360
2915184286
2865871647
3226400865
1622918796
104254081
2831993650
124160245
2816617092
2153090960
3246477682
163892292
1254767342
1055075563
590118345
3247329219
3219358004
3240595846
2869645126
2178256927
1474477441
3288503627
1591183538
2778742493
2232839750
3248016831
3290132536
3114081101
3257080649
3289932345
1166128405
3096827699
3290276801
2578400401
3295062009
361765395
3236979857
236755994
510453383
3099565996
33667403
2284930554
2835808283
1205321624
3141787912
2888207283
3306457894
3292716609
2871400947
3311626635
33498479
3112949466
373381866
1977747816
1087118377
2915714073
2417691860
1243503188
2827549157
3251061183
3279289197
2578936784
149098393
60966523
3107684139
3247336089
17673164
3332380503
403586493
1366319701
3331534773
130612438
2315584370
1484592206
3055847227
3344072807
2870333375
3343927283
1412920974
2865341729
2847987797
1089505536
3309064253
3347869245
299738494
2508463058
471784474
79413136
339645292
3315026530
18578222
3356788247
121744246
3327977501
462371873
3353039495
3088947209
59208749
101697079
3347377181
2594569079
3306295443
2964874157
3369648657
108029747
2494094640
415360003
3025371657
3363056296
281551418
127885771
3369195591
3319516727
1006248313
3351535983
2251036310
124044927
1563301260
3074361399
3243101023
767955972
3308253941
2343388849
285652503
3123450121
1186560870
3288695209
3370530035
3197448293
1604201894
2451714978
3360505269
5817212
3342736072
3395157317
1895444035
81652787
3387067859
2280660745
3356936751
3399096201
16109690
537256149
3410083535
443595767
3043477487
33916153
227613855
191594936
2601391856
3420859137
3029998619
2561654266
3425746955
3364519637
1969155896
96157172
3429953451
3436573583
2983024653
3036482788
496221738
375696581
120179947
2773389254
2863155382
3491239528
1217784188
3431664478
2769510565
1542951048
3658530316
3098934268
1951371852
3575553976
3667844357
399474634
2767103446
3677644096
3294818469
3315041679
3361636757
1907452297
193815375
3617409205
3362289555
2215337846
1920229874
3288984712
2951047935
3340897979
2901207701
3747767309
2363053140
81707846
56756648
270923510
1689008989
3387152740
2545676994
3497006300
88095733
3473375242
3770063596
720262568
3163589807
80579809
2151648536
3184885378
349155748
3827145497
515192747
2664141010
403571698
3772830736
2422579426
3448940740
3310926629
3759431183
2188432938
821038076
206112761
3092153902
157627079
3238901039
134954561
2158890419
2581885310
3936452321
1003857536
1243768705
557672906
339745837
3912188613
3356797330
187447837
165877795
318374087
2683852301
3654226949
4045129072
59749610
4053772455
3233104449
4097508208
2564195291
3422534434
1329667098
2480042162
388783559
3236090853
3063512674
3322746657
1456823034
3334508626
1042705189
2560410172
934285622
1894443266
4187660595
1527945654
428036353
116535904
4197076187
592680320
563116992
3289792881
2908427063
3099683013
595315490
44301317
352480182
3759660023
126693392
4060401376
154434457
3351672850
299891313
2601512912
314195763
2869466882
565717251
908268282
2766420978
4264774293
18952887
3045516591
407222207
2886308164
4327825588
4340163915
532146739
4352441542
4374189868
3433966588
4385207301
4236118756
3345302547
2463724730
175419546
299856769
586113631
1687866091
444922668
4125835763
384879752
4305693675
66121745
3403887771
4053900263
281003023
4724829616
92713062
229909540
2848686154
43159134
3003020261
250122266
4439128654
3346450571
2306576246
4125533320
4846056719
1352990030
369535133
223793502
292800140
3954342563
3221012705
4832699320
3871747001
701494123761639424
2274505314
2965904590
551977734
4896062084
704375395756457984
4274532257
3091351420
706169146199805952
1451808908
93651454
476292713
2306836854
1385302692
3233862245
4860670649
709692899538112512
20908375
204967813
800738948
4902083283
2397611510
254567503
1427627245
1432470283
2591579065
2347646468
2529865890
3650965156
4414353555
1467706777
2462982360
572646487
2570534684
1247285755
117219836
985206985
1583007884
3043900294
724953820267188224
3299100448
1459210008
4418937028
394756344
897852660
430528494
2312004307
3067966737
1016191976
3510313343
4514151323
2414613061
1106273834
4838881996
4795362559
1552348932
4829200299
119209362
4877726386
4893136852
4892225841
475747679
103053609
4886250016
127671232
347209220
1586888335
702093781584191489
4242558185
113652310
242755399
331951152
486876487
122337112
1288395715
1951659482
561030618
708155373363044352
743813203
76599557
2717450628
705063431746019328
709097327261306884
47301205
256586381
4924448325
699891685417832448
169944984
1470608617
344099574
712230557334294529
460297543
3234261468
3294349793
2841943269
526240920
969155258
979001443
101781053
742087112
81138712
717830427654885376
4857692751
46782559
4834620815
2769353145
419672561
3424252895
1566494089
722085911622717440
349721791
2266321814
914404728
724571714378670080
1174522231
710938543481360385
322007943
2868931205
3151650502
713293557566730240
1962610909
2653265111
3065950217
207032654
2328980665
715897209619922944
2766603588
717436082363699200
2895897599
534682703
71764782
704298544413417476
716676808004001792
717649540610916353
293385750
2685242778
2427018324
1200331980
976649340
2231204868
3393554183
105440205
1282999224
87699003
47611921
72258470
3164570914
1283188854
3297883587
3654139048
430549591
278479456
3554877857
529187641
160980846
3306699340
80863241
550088885
3387193750
2294389640
3988683737
394086942
58469224
3971040563
419020185
1461860179
718233281259577344
4872014001
253281401
722436594326745088
262782004
723183315159674880
316358854
717986349450715136
702250952464719876
1304185848
715477042255400960
2229540944
108312826
589220202
57934572
456509238
236944651
17577792
3044565827
707869861310021632
22906888
1435098324
718124504900321280
1336565875
258322916
703279891630977024
2340642181
871791074
4798076242
2972891242
636127969
1402416842
107120063
1626327912
154232612
875202511
27035692
1710558248
2421090461
3084065524
92498437
3068578408
19902747
19157601
3228560890
87968932
2917829986
14830878
3096503151
2963777423
704296200443453441
553903430
215253835
121179819
615439384
2835318018
937137786
912703093
144205762
2663021922
583743690
2679621258
2849717279
46188069
2762877947
454482575
2948912655
3044902438
2994945904
3297413893
1131275454
2609572253
585634830
8124692
1307238847
2255061517
2942420908
398313179
2236551919
1224891349
1113991915
399113202
362115507
2274388309
70386170
2166326432
231792522
110425971
2221738014
2236696129
2473765933
20608825
575526974
29279887
2656625779
2443965462
108268878
2937121618
48471536
571160718
720955234529447936
3084591458
3182688916
2780628995
2495912898
17151836
2831248925
2194369747
326275791
18396319
540867812
90367209
110385030
1241478848
549988185
1095394501
194209753
132887265
1431091280
122728088
601723089
1000416649
882589668
2287504329
874018718
1726915862
2331445776
1381447261
228181115
21304596
2578389024
1628483762
1637806470
289842978
239771598
2206861105
327281002
214219175
180272447
1960169276
1285798891
2260418391
2365609884
634456867
2239492459
2340211267
268376525
169115150
609052966
2365739546
418837315
1707669199
244150878
17508660
194038681
143764572
1961132515
268267143
125735734
382736141
35031894
974230464
1603242613
29409989
35699413
253457416
258837682
1346477851
117752415
611205732
477884091
33243958
93710153
368980703
464695627
16929949
196587011
962698134
294069933
858697915
381424778
1291106736
185179142
102418097
370067918
1057468057
19025517
246120800
33484246
1136448840
1085763829
1005107882
50623553
307760775
516666837
109288576
20332679
239789789
152182188
85792815
68637990
68144153
32469366
20702279
53005756
704686519
19702911
44122682
5056421
93089783
234435877
579449079
91096410
81869480
117030305
326804018
17918561
47331384
86322463
58478416
19731386
97501035
15714547
133264049
479547103
206114546
462807837
341964732
33959668
284945599
555996011
68828140
323351632
190970677
18173885
32627006
18834709
85740646
68694892
15263607
373888796
71489670
83193528
276981595
456493298
17514448
381012883
30418171
105799293
247313134
270275452
448810521
420922312
340396112
69251679
183604007
442888384
430623637
295763445
267813068
437645640
93434871
296885557
19062473
421104220
22483923
289958588
394804529
426786313
96580814
357929055
360494924
382630007
417821958
122495814
285632932
398711039
180963759
282102925
17929117
97666275
174371784
15345794
281543465
398586805
392255589
75066258
15278752
50034788
31957731
64263673
216622677
373226986
214131724
15143590
97642278
105152641
46340068
17526629
38321097
54915254
333020446
359898548
362940847
364860260
364377946
295015930
230208727
83599236
22001225
130420847
317633692
327294878
324974206
216665247
333395905
234928299
207422237
17809315
92728993
19815593
51431609
159418453
260278496
103435620
55216228
107744094
149405584
301536104
68440549
120032979
110484396
199612420
83042948
96556759
19109031
7368172
193079658
96584904
85523787
233889509
102315712
328348926
323810837
201304479
252642679
88467267
287910005
22372197
26783441
122065950
47949526
111656390
257056780
17462818
35071240
273330480
187046546
297483999
201244328
226761828
188774936
294059559
307562250
280606847
19017598
27635314
22686020
278410208
102659157
294271697
249076432
194570153
15915148
148445419
45526537
183558597
296817115
135180821
234275325
169317229
43306320
26508357
240359731
32386128
126739364
35774397
242654132
224770553
52771080
17299145
265910284
122759601
264467584
93943023
177857849
188031911
252501716
132890378
228056808
102407808
128165750
196957204
245756196
90361845
71539905
73134348
14785784
36490390
20004168
89978446
251709906
21761836
96940759
56245012
189528205
111986673
216647771
233967577
123907350
40020957
242341620
157945879
187561556
21980830
237494109
115997742
17517077
79235322
158316733
31698734
22660726
91324102
19238269
76135466
15370860
121812725
45589568
192663480
128912066
17647060
40030200
117105325
43362116
154531152
222750728
146130786
49936912
111330619
191817397
134764295
19057203
100502050
100495159
15022212
121798055
28771286
28612619
24182453
20166212
194582046
39093474
45792481
117489449
48460844
68575283
94303608
121651528
21076982
98856445
49876216
64796545
40280801
139586670
8428332
22127667
24153592
11400402
24162617
70757699
38146999
129803936
74404241
5893522
106178597
77737504
15414807
83549185
18759944
84558438
15376805
59142336
18723072
14650248
116514146
91305909
47589047
197094054
26574530
198112073
19427523
178246193
125689800
35467719
19638115
126402574
42596648
15796976
37786072
104423786
71522256
22968845
21305282
74177722
21661279
80815034
37714075
169152646
2057421
19448989
65239488
15057943
20252523
19963158
23605171
22009731
12804422
53480473
58737910
20144759
75253999
97171003
110140871
16266811
36095792
120045168
43323244
18833378
19225495
120098753
25269083
87389293
19794253
107223122
28990873
35184171
48880794
24215600
86573349
20652237
62527273
107959549
37879992
26033900
122036476
139571504
146434781
38418492
176071808
148683521
113395771
144102984
79123110
26576457
109839427
165900750
185234973
142663302
6629022
15867365
33612959
32600737
972651
22164556
55822947
17574752
187789899
140079968
15907720
14150661
53006664
57657808
51615984
20674829
23442241
14340187
27571356
17676539
72835716
187608976
147937366
76946799
110468470
24860017
24706309
8223872
7422382
30934331
14634720
24674497
16426039
14112296
11512342
17288873
15446126
18201801
51040617
20460547
22649558
78647372
174856305
41423495
17093617
26012202
21675775
17599655
25745605
162189629
118046102
173847081
13058232
163013420
25496451
25482145
27404263
21307750
40505931
14282132
32012825
19639085
26875700
21238039
17623957
37689619
87355074
62816265
14362241
60783334
40158353
14798905
154587106
83388570
183966773
177912493
39376074
52009045
77540977
122061533
38591651
27460003
19211048
18014805
10944002
4969501
108407045
| originalCode_JMG/data/twecoll/20200723Twecoll/fdat/185282251.f |
module ocean_recenter_utils
implicit none
type ModelGrid
character (len = 400) :: fname
integer :: Nx, Ny, Nz, Ncat
real, dimension(:,:), allocatable :: x, y, wet, depth
real, dimension(:), allocatable :: z
end type ModelGrid
type obs_space
integer :: No
real, dimension(:), allocatable :: lon, lat, HXe, Yo
end type obs_space
contains
!-----------------------
subroutine check(status)
!-----------------------
use netcdf
integer, intent (in) :: status
if(status /= nf90_noerr) then
print *, trim(nf90_strerror(status))
stop "Stopped"
end if
end subroutine check
!-----------------------
subroutine init_grid(grid)
!-----------------------
use netcdf
type (ModelGrid), intent(inout) :: grid
integer :: varid, ncid
integer :: Nx, Ny, Nz, Ncat
character (len = 400) :: grid_fname, lon_name, lat_name, lev_name, mask_name, topo_name
namelist /recenter_grid_size/Nx, Ny, Nz, Ncat, grid_fname, lon_name, lat_name, lev_name, mask_name, topo_name
open(7,file='recenter.nml')
read(7,NML=recenter_grid_size)
close(7)
grid%Nx=Nx
grid%Ny=Ny
grid%Nz=Nz
grid%Ncat=Ncat
grid%fname=trim(grid_fname)
allocate( grid%x(grid%Nx, grid%Ny), grid%y(grid%Nx, grid%Ny), grid%wet(grid%Nx, grid%Ny), grid%depth(grid%Nx, grid%Ny), grid%z(grid%Nz) )
print *,'grid%fname:',grid%fname
call check(nf90_open(grid%fname, nf90_nowrite,ncid))
call check(nf90_inq_varid(ncid,trim(lon_name),varid))
call check(nf90_get_var(ncid,varid,grid%x))
call check(nf90_inq_varid(ncid,trim(lat_name),varid))
call check(nf90_get_var(ncid,varid,grid%y))
call check(nf90_close(ncid))
end subroutine init_grid
!-----------------------
subroutine get_Xe(Xe,myrank,yyyymmdd,Nx,Ny,num_levels,Xe_path, X_varname, X_varshape)
!-----------------------
use netcdf
implicit none
!integer, parameter :: r_size=kind(0.0)
!real, allocatable, dimension(:,:,:), intent(out) :: Xe !Allocated before call
real, allocatable, dimension(:), intent(inout) :: Xe !Allocated before call
real*8, allocatable, dimension(:,:,:) :: Xe_d !Allocated before call
integer, intent(in) :: myrank
character (len=8), intent(in) :: yyyymmdd
character (len = 400), intent(in) :: Xe_path
character (len = 400), intent(in) :: X_varname, X_varshape
!real, allocatable, dimension(:,:,:,:) :: VAR
integer :: varid
integer :: ncid
character (len = 400) :: fname
integer :: Nx, Ny, Nz, Ncat, num_levels, lev_index
integer,parameter :: single = selected_real_kind(p=6,r=37)
!select case(X_varname)
!case('T','S')
! print *,'var shape:',Nx, Ny, 40,1
! allocate(VAR(Nx, Ny, num_levels,1))
!case default
! print *,'var shape:',Nx, Ny, num_levels,1
! allocate(VAR(Nx, Ny, num_levels,1))
!end select
!allocate(VAR(Nx, Ny, num_levels,1))
!allocate(Xe(Nx, Ny, num_levels),Xe_d(Nx, Ny, num_levels))
!allocate(Xe(1:Nx*Ny*num_levels),Xe_d(1:Nx, 1:Ny, 1:num_levels))
allocate(Xe_d(1:Nx, 1:Ny, 1:num_levels))
fname=trim(Xe_path)//'state.'
fname=trim(fname)//int2str(myrank+1)
fname=trim(fname)//'.'
fname=trim(fname)//yyyymmdd
fname=trim(fname)//'.nc'
!print *,'cpu#', myrank, fname, shape(Xe), fname
!print *,Nx,Ny,num_levels
call check(nf90_open(fname,nf90_nowrite,ncid))
call check(nf90_inq_varid(ncid,X_varname,varid))
call check(nf90_get_var(ncid,varid,Xe_d))
Xe=reshape(real(Xe_d),(/Nx*Ny*num_levels/))
call check(nf90_close(ncid))
!Xe(:,:,1)=VAR(:,:,1)
!Xe=VAR(:,:,:,1)
!print *,'cpu#',myrank,' getting out of get_Xe'
!do lev_index = 1, num_levels
! Xe(:,:,lev_index)=VAR(:,:,lev_index)
!end do
deallocate(Xe_d)
end subroutine get_Xe
function int2str(int) result(str)
implicit none
integer :: int
character (len = 200) :: str
open(572,status='scratch')
write(572,*)int
rewind(572)
read(572,*)str
close(572)
end function int2str
end module ocean_recenter_utils
| UMD_utils/ocean_recenter_utils.f90 |
SUBROUTINE GH_WWVC ( ibeg, iend, clist, zlist, bkpstr, ivtec,
+ iret )
C************************************************************************
C* GH_WWVC *
C* *
C* This subroutine looks for segments with the same UGC lists and the *
C* same breakpoint text strings, but different VTECS, and merges them *
C* into a single segment. *
C* *
C* GH_WWVC ( IBEG, IEND, CLIST, ZLIST, BKPSTR, IVTEC, IRET ) *
C* *
C* Input parameters: *
C* IBEG INTEGER Beginning segment index *
C* IEND INTEGER Ending segment index *
C* CLIST(NSEG) CHAR* Lists of county UGCs by segment *
C* ZLIST(NSEG) CHAR* Lists of marine zone UGCs by segment *
C* BKPSTR(NSEG) CHAR* Breakpoint text strings by segment *
C* *
C* Input and output parameters: *
C* IVTEC(3,NSEG) INTEGER VTEC action and watch/warning code *
C* values by segment *
C* *
C* Output parameters: *
C* IRET INTEGER Return code *
C* 0 = normal return *
C** *
C* Log: *
C* D. Kidwell/NCEP 9/05 *
C************************************************************************
INCLUDE 'GEMPRM.PRM'
INCLUDE 'ghcmn.cmn'
C*
PARAMETER ( MAXSEG = 50 )
C*
CHARACTER*(*) clist (*), zlist (*), bkpstr (*)
INTEGER ivtec (3,*)
C*
INTEGER lenc (MAXSEG), lenz (MAXSEG), lenb (MAXSEG)
LOGICAL match
C-----------------------------------------------------------------------
iret = 0
C
C* Get the string lengths.
C
DO ii = ibeg, iend
CALL ST_LSTR ( clist ( ii ), lenc ( ii ), ier )
CALL ST_LSTR ( zlist ( ii ), lenz ( ii ), ier )
IF ( ( lenc ( ii ) .lt. 6 ) .and. ( lenz ( ii ) .lt. 6 ) )
+ ivtec ( 1, ii ) = 0
CALL ST_LSTR ( bkpstr ( ii ), lenb ( ii ), ier )
END DO
C
C* Loop over segments with non-zero VTEC values.
C
DO ii = ibeg, iend - 1
IF ( ivtec ( 1, ii ) .gt. 0 ) THEN
DO jj = ii + 1, iend
IF ( ivtec ( 1, jj ) .gt. 0 ) THEN
match = .true.
IF ( ( lenc ( ii ) .gt. 0 ) .and.
+ ( lenc ( jj ) .gt. 0 ) ) THEN
IF ( ( clist ( ii ) ( :lenc (ii) ) ) .ne.
+ ( clist ( jj ) ( :lenc (jj) ) ) ) THEN
match = .false.
END IF
END IF
IF ( ( lenz ( ii ) .gt. 0 ) .and.
+ ( lenz ( jj ) .gt. 0 ) ) THEN
IF ( ( zlist ( ii ) ( :lenz (ii) ) ) .ne.
+ ( zlist ( jj ) ( :lenz (jj) ) ) ) THEN
match = .false.
END IF
END IF
IF ( ( lenb ( ii ) .gt. 0 ) .and.
+ ( lenb ( jj ) .gt. 0 ) ) THEN
IF ( ( bkpstr ( ii ) ( :lenb (ii) ) ) .ne.
+ ( bkpstr ( jj ) ( :lenb (jj) ) ) ) THEN
match = .false.
END IF
END IF
IF ( match ) THEN
C
C* A match was found on counties, marine zones,
C* and breakpoint text strings. Make sure
C* there is room to merge the VTECs.
C
icount = 2
DO kk = 2, 3
IF ( ivtec ( kk, ii ) .gt. 0 )
+ icount = icount + 1
IF ( ivtec ( kk, jj ) .gt. 0 )
+ icount = icount + 1
END DO
IF ( icount .le. 3 ) THEN
C
C* Merge the VTECs and zero out the second
C* one.
C
IF ( ivtec ( 2, ii ) .eq. 0 ) THEN
DO kk = 2, 3
ivtec ( kk, ii ) =
+ ivtec ( kk - 1, jj )
END DO
ELSE
ivtec ( 3, ii ) = ivtec ( 1, jj )
END IF
DO kk = 1, 3
ivtec ( kk, jj ) = 0
END DO
END IF
END IF
END IF
END DO
END IF
END DO
C*
RETURN
END
| gempak/source/cgemlib/gh/ghwwvc.f |
*
* $Id$
*
SUBROUTINE DCMPGAMMA( LAMBDA, DELTA, N, B1, BN, L, D,
$ LD, LLD, LPLUS, DPLUS, UMINUS, DMINUS, T,
$ P, K, GAMMA )
*
* -- LAPACK routine (version 0.0) -- in progress --
* September 1995
*
* .. Scalar Arguments ..
implicit none
INTEGER N, B1, BN, K
DOUBLE PRECISION DELTA, LAMBDA
* ..
* .. Array Arguments ..
DOUBLE PRECISION D( * ), L( * ), P( * ), GAMMA( * ),
$ DMINUS( * ), LPLUS( * ), T( * ), UMINUS( * ),
$ DPLUS( * ), LD( * ), LLD( * )
* ..
*
* Purpose
* =======
*
* DCMPGAMMA computes the GAMMA array, where GAMMA(I) is the
* reciprocal of the I^{th} diagonal element of the inverse of
* (L*D*L^T - (LAMBDA+DELTA)*I)
*
* Arguments
* =========
*
* LAMBDA (input) DOUBLE PRECISION
* The shift.
*
* DELTA (input) DOUBLE PRECISION
* Lower order bits of the shift.
*
* N (input) INTEGER
* The order of the matrix L * D * L^T.
*
* B1 (input) INTEGER
* Starting index of the submatrix (of L * D * L^T).
*
* BN (input) INTEGER
* Last index of the submatrix (of L * D * L^T).
*
* L (input) DOUBLE PRECISION array, dimension (N-1)
* The (n-1) subdiagonal elements of the bidiagonal matrix
* L, in elements 1 to N-1. L(N) need not be set.
*
* D (input) DOUBLE PRECISION array, dimension (N)
* The n diagonal elements of the diagonal matrix D.
*
* LD (input) DOUBLE PRECISION array, dimension (N-1)
* The n-1 elements L(i)*D(i).
*
* LLD (input) DOUBLE PRECISION array, dimension (N-1)
* The n-1 elements L(i)*L(i)*D(i).
*
* LPLUS (output) DOUBLE PRECISION array, dimension (N-1)
* The (n-1) diagonal elements of L+.
*
* DPLUS (output) DOUBLE PRECISION array, dimension (N)
* The n diagonal elements of D+.
*
* UMINUS (output) DOUBLE PRECISION array, dimension (N-1)
* The (n-1) diagonal elements of U-.
*
* DMINUS (output) DOUBLE PRECISION array, dimension (N)
* The n diagonal elements of D-.
*
* T (output) DOUBLE PRECISION array, dimension (N)
* Intermediate results of the dstqds algorithm.
*
* P (output) DOUBLE PRECISION array, dimension (N)
* Intermediate results of the dqds algorithm.
*
* K (output) INTEGER
* The k^{th} column of the inverse of (L*D*L^T - (LAMBDA+DELTA)*I).
*
* GAMMA (output) DOUBLE PRECISION array, dimension (N)
* GAMMA(i) is the reciprocal of the i^{th} diagonal element
* of the inverse of (L*D*L^T - (LAMBDA+DELTA)*I).
*
* =====================================================================
*
* .. Parameters ..
DOUBLE PRECISION ZERO, ONE
PARAMETER ( ZERO = 0.0d+0, ONE = 1.0d+0 )
* ..
* .. Local Scalars ..
INTEGER I
DOUBLE PRECISION DIF, EPS, MINDIF
* ..
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS
integer doprnt1,doprnt2
common doprnt1,doprnt2
* ..
* .. Executable Statements ..
*
EPS = 0.111022302462515654E-15
K = B1
IF( B1.EQ.1 ) THEN
MINDIF = P( B1 ) - DELTA
ELSE
MINDIF = ( LLD( B1-1 ) + P( B1 ) ) - DELTA
END IF
IF( MINDIF.EQ.ZERO ) THEN
MINDIF = EPS * P( B1 )
END IF
GAMMA( B1 ) = MINDIF
DIF = ( D( BN ) + T( BN ) ) - DELTA
IF( DIF.EQ.ZERO ) THEN
DIF = EPS * T( BN )
END IF
GAMMA( BN ) = DIF
IF( ABS( DIF ).LT.ABS( MINDIF ) ) THEN
MINDIF = DIF
K = BN
END IF
DO I = B1+1, BN-1
DIF = ( ( P( I ) + T( I ) ) + LAMBDA ) - DELTA
IF( DIF.EQ.ZERO ) THEN
DIF = EPS * P( I )
END IF
GAMMA( I ) = DIF
IF( ABS( DIF ).LT.ABS( MINDIF ) ) THEN
MINDIF = DIF
K = I
END IF
END DO
RETURN
101 format (E22.14)
102 format (E22.14,E22.14)
103 format (E22.14,E22.14,E22.14)
*
* End of DCMPGAMMA
*
END
| src/peigs/src/f77/dcmpgamma.f |
!===-- module/ieee_arithmetic.f90 ------------------------------------------===!
!
! Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
! See https://llvm.org/LICENSE.txt for license information.
! SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
!
!===------------------------------------------------------------------------===!
! See Fortran 2018, clause 17.2
module ieee_arithmetic
use __Fortran_builtins, only: &
ieee_is_nan => __builtin_ieee_is_nan, &
ieee_next_after => __builtin_ieee_next_after, &
ieee_next_down => __builtin_ieee_next_down, &
ieee_next_up => __builtin_ieee_next_up, &
ieee_scalb => scale, &
ieee_selected_real_kind => __builtin_ieee_selected_real_kind, &
ieee_support_datatype => __builtin_ieee_support_datatype, &
ieee_support_denormal => __builtin_ieee_support_denormal, &
ieee_support_divide => __builtin_ieee_support_divide, &
ieee_support_inf => __builtin_ieee_support_inf, &
ieee_support_io => __builtin_ieee_support_io, &
ieee_support_nan => __builtin_ieee_support_nan, &
ieee_support_sqrt => __builtin_ieee_support_sqrt, &
ieee_support_standard => __builtin_ieee_support_standard, &
ieee_support_subnormal => __builtin_ieee_support_subnormal, &
ieee_support_underflow_control => __builtin_ieee_support_underflow_control
implicit none
type :: ieee_class_type
private
integer(kind=1) :: which = 0
end type ieee_class_type
type(ieee_class_type), parameter :: &
ieee_signaling_nan = ieee_class_type(1), &
ieee_quiet_nan = ieee_class_type(2), &
ieee_negative_inf = ieee_class_type(3), &
ieee_negative_normal = ieee_class_type(4), &
ieee_negative_denormal = ieee_class_type(5), &
ieee_negative_zero = ieee_class_type(6), &
ieee_positive_zero = ieee_class_type(7), &
ieee_positive_subnormal = ieee_class_type(8), &
ieee_positive_normal = ieee_class_type(9), &
ieee_positive_inf = ieee_class_type(10), &
ieee_other_value = ieee_class_type(11)
type(ieee_class_type), parameter :: &
ieee_negative_subnormal = ieee_negative_denormal, &
ieee_positive_denormal = ieee_negative_subnormal
type :: ieee_round_type
private
integer(kind=1) :: mode = 0
end type ieee_round_type
type(ieee_round_type), parameter :: &
ieee_nearest = ieee_round_type(1), &
ieee_to_zero = ieee_round_type(2), &
ieee_up = ieee_round_type(3), &
ieee_down = ieee_round_type(4), &
ieee_away = ieee_round_type(5), &
ieee_other = ieee_round_type(6)
interface operator(==)
module procedure class_eq
module procedure round_eq
end interface operator(==)
interface operator(/=)
module procedure class_ne
module procedure round_ne
end interface operator(/=)
private :: class_eq, class_ne, round_eq, round_ne
! See Fortran 2018, 17.10 & 17.11
generic :: ieee_class => ieee_class_a2, ieee_class_a3, ieee_class_a4, ieee_class_a8, ieee_class_a10, ieee_class_a16
private :: ieee_class_a2, ieee_class_a3, ieee_class_a4, ieee_class_a8, ieee_class_a10, ieee_class_a16
generic :: ieee_copy_sign => ieee_copy_sign_a2, ieee_copy_sign_a3, ieee_copy_sign_a4, ieee_copy_sign_a8, ieee_copy_sign_a10, ieee_copy_sign_a16
private :: ieee_copy_sign_a2, ieee_copy_sign_a3, ieee_copy_sign_a4, ieee_copy_sign_a8, ieee_copy_sign_a10, ieee_copy_sign_a16
generic :: ieee_is_finite => ieee_is_finite_a2, ieee_is_finite_a3, ieee_is_finite_a4, ieee_is_finite_a8, ieee_is_finite_a10, ieee_is_finite_a16
private :: ieee_is_finite_a2, ieee_is_finite_a3, ieee_is_finite_a4, ieee_is_finite_a8, ieee_is_finite_a10, ieee_is_finite_a16
generic :: ieee_rem => &
ieee_rem_a2_a2, ieee_rem_a2_a3, ieee_rem_a2_a4, ieee_rem_a2_a8, ieee_rem_a2_a10, ieee_rem_a2_a16, &
ieee_rem_a3_a2, ieee_rem_a3_a3, ieee_rem_a3_a4, ieee_rem_a3_a8, ieee_rem_a3_a10, ieee_rem_a3_a16, &
ieee_rem_a4_a2, ieee_rem_a4_a3, ieee_rem_a4_a4, ieee_rem_a4_a8, ieee_rem_a4_a10, ieee_rem_a4_a16, &
ieee_rem_a8_a2, ieee_rem_a8_a3, ieee_rem_a8_a4, ieee_rem_a8_a8, ieee_rem_a8_a10, ieee_rem_a8_a16, &
ieee_rem_a10_a2, ieee_rem_a10_a3, ieee_rem_a10_a4, ieee_rem_a10_a8, ieee_rem_a10_a10, ieee_rem_a10_a16, &
ieee_rem_a16_a2, ieee_rem_a16_a3, ieee_rem_a16_a4, ieee_rem_a16_a8, ieee_rem_a16_a10, ieee_rem_a16_a16
private :: &
ieee_rem_a2_a2, ieee_rem_a2_a3, ieee_rem_a2_a4, ieee_rem_a2_a8, ieee_rem_a2_a10, ieee_rem_a2_a16, &
ieee_rem_a3_a2, ieee_rem_a3_a3, ieee_rem_a3_a4, ieee_rem_a3_a8, ieee_rem_a3_a10, ieee_rem_a3_a16, &
ieee_rem_a4_a2, ieee_rem_a4_a3, ieee_rem_a4_a4, ieee_rem_a4_a8, ieee_rem_a4_a10, ieee_rem_a4_a16, &
ieee_rem_a8_a2, ieee_rem_a8_a3, ieee_rem_a8_a4, ieee_rem_a8_a8, ieee_rem_a8_a10, ieee_rem_a8_a16, &
ieee_rem_a10_a2, ieee_rem_a10_a3, ieee_rem_a10_a4, ieee_rem_a10_a8, ieee_rem_a10_a10, ieee_rem_a10_a16, &
ieee_rem_a16_a2, ieee_rem_a16_a3, ieee_rem_a16_a4, ieee_rem_a16_a8, ieee_rem_a16_a10, ieee_rem_a16_a16
generic :: ieee_support_rounding => ieee_support_rounding_, &
ieee_support_rounding_2, ieee_support_rounding_3, &
ieee_support_rounding_4, ieee_support_rounding_8, &
ieee_support_rounding_10, ieee_support_rounding_16
private :: ieee_support_rounding_, &
ieee_support_rounding_2, ieee_support_rounding_3, &
ieee_support_rounding_4, ieee_support_rounding_8, &
ieee_support_rounding_10, ieee_support_rounding_16
! TODO: more interfaces (_fma, &c.)
private :: classify
contains
elemental logical function class_eq(x,y)
type(ieee_class_type), intent(in) :: x, y
class_eq = x%which == y%which
end function class_eq
elemental logical function class_ne(x,y)
type(ieee_class_type), intent(in) :: x, y
class_ne = x%which /= y%which
end function class_ne
elemental logical function round_eq(x,y)
type(ieee_round_type), intent(in) :: x, y
round_eq = x%mode == y%mode
end function round_eq
elemental logical function round_ne(x,y)
type(ieee_round_type), intent(in) :: x, y
round_ne = x%mode /= y%mode
end function round_ne
elemental type(ieee_class_type) function classify( &
expo,maxExpo,negative,significandNZ,quietBit)
integer, intent(in) :: expo, maxExpo
logical, intent(in) :: negative, significandNZ, quietBit
if (expo == 0) then
if (significandNZ) then
if (negative) then
classify = ieee_negative_denormal
else
classify = ieee_positive_denormal
end if
else
if (negative) then
classify = ieee_negative_zero
else
classify = ieee_positive_zero
end if
end if
else if (expo == maxExpo) then
if (significandNZ) then
if (quietBit) then
classify = ieee_quiet_nan
else
classify = ieee_signaling_nan
end if
else
if (negative) then
classify = ieee_negative_inf
else
classify = ieee_positive_inf
end if
end if
else
if (negative) then
classify = ieee_negative_normal
else
classify = ieee_positive_normal
end if
end if
end function classify
#define _CLASSIFY(RKIND,IKIND,TOTALBITS,PREC,IMPLICIT) \
type(ieee_class_type) elemental function ieee_class_a##RKIND(x); \
real(kind=RKIND), intent(in) :: x; \
integer(kind=IKIND) :: raw; \
integer, parameter :: significand = PREC - IMPLICIT; \
integer, parameter :: exponentBits = TOTALBITS - 1 - significand; \
integer, parameter :: maxExpo = shiftl(1, exponentBits) - 1; \
integer :: exponent, sign; \
logical :: negative, nzSignificand, quiet; \
raw = transfer(x, raw); \
exponent = ibits(raw, significand, exponentBits); \
negative = btest(raw, TOTALBITS - 1); \
nzSignificand = ibits(raw, 0, significand) /= 0; \
quiet = btest(raw, significand - 1); \
ieee_class_a##RKIND = classify(exponent, maxExpo, negative, nzSignificand, quiet); \
end function ieee_class_a##RKIND
_CLASSIFY(2,2,16,11,1)
_CLASSIFY(3,2,16,8,1)
_CLASSIFY(4,4,32,24,1)
_CLASSIFY(8,8,64,53,1)
_CLASSIFY(10,16,80,64,0)
_CLASSIFY(16,16,128,112,1)
#undef _CLASSIFY
! TODO: This might need to be an actual Operation instead
#define _COPYSIGN(RKIND,IKIND,BITS) \
real(kind=RKIND) elemental function ieee_copy_sign_a##RKIND(x,y); \
real(kind=RKIND), intent(in) :: x, y; \
integer(kind=IKIND) :: xbits, ybits; \
xbits = transfer(x, xbits); \
ybits = transfer(y, ybits); \
xbits = ior(ibclr(xbits, BITS-1), iand(ybits, shiftl(1_##IKIND, BITS-1))); \
ieee_copy_sign_a##RKIND = transfer(xbits, x); \
end function ieee_copy_sign_a##RKIND
_COPYSIGN(2,2,16)
_COPYSIGN(3,2,16)
_COPYSIGN(4,4,32)
_COPYSIGN(8,8,64)
_COPYSIGN(10,16,80)
_COPYSIGN(16,16,128)
#undef _COPYSIGN
#define _IS_FINITE(KIND) \
elemental function ieee_is_finite_a##KIND(x) result(res); \
real(kind=KIND), intent(in) :: x; \
logical :: res; \
type(ieee_class_type) :: classification; \
classification = ieee_class(x); \
res = classification == ieee_negative_zero .or. classification == ieee_positive_zero \
.or. classification == ieee_negative_denormal .or. classification == ieee_positive_denormal \
.or. classification == ieee_negative_normal .or. classification == ieee_positive_normal; \
end function
_IS_FINITE(2)
_IS_FINITE(3)
_IS_FINITE(4)
_IS_FINITE(8)
_IS_FINITE(10)
_IS_FINITE(16)
#undef _IS_FINITE
! TODO: handle edge cases from 17.11.31
#define _REM(XKIND,YKIND) \
elemental function ieee_rem_a##XKIND##_a##YKIND(x, y) result(res); \
real(kind=XKIND), intent(in) :: x; \
real(kind=YKIND), intent(in) :: y; \
integer, parameter :: rkind = max(XKIND, YKIND); \
real(kind=rkind) :: res, tmp; \
tmp = anint(real(x, kind=rkind) / y); \
res = x - y * tmp; \
end function
_REM(2,2)
_REM(2,3)
_REM(2,4)
_REM(2,8)
_REM(2,10)
_REM(2,16)
_REM(3,2)
_REM(3,3)
_REM(3,4)
_REM(3,8)
_REM(3,10)
_REM(3,16)
_REM(4,2)
_REM(4,3)
_REM(4,4)
_REM(4,8)
_REM(4,10)
_REM(4,16)
_REM(8,2)
_REM(8,3)
_REM(8,4)
_REM(8,8)
_REM(8,10)
_REM(8,16)
_REM(10,2)
_REM(10,3)
_REM(10,4)
_REM(10,8)
_REM(10,10)
_REM(10,16)
_REM(16,2)
_REM(16,3)
_REM(16,4)
_REM(16,8)
_REM(16,10)
_REM(16,16)
#undef _REM
pure logical function ieee_support_rounding_(round_type)
type(ieee_round_type), intent(in) :: round_type
ieee_support_rounding_ = .true.
end function
pure logical function ieee_support_rounding_2(round_type,x)
type(ieee_round_type), intent(in) :: round_type
real(kind=2), intent(in) :: x
ieee_support_rounding_2 = .true.
end function
pure logical function ieee_support_rounding_3(round_type,x)
type(ieee_round_type), intent(in) :: round_type
real(kind=3), intent(in) :: x
ieee_support_rounding_3 = .true.
end function
pure logical function ieee_support_rounding_4(round_type,x)
type(ieee_round_type), intent(in) :: round_type
real(kind=4), intent(in) :: x
ieee_support_rounding_4 = .true.
end function
pure logical function ieee_support_rounding_8(round_type,x)
type(ieee_round_type), intent(in) :: round_type
real(kind=8), intent(in) :: x
ieee_support_rounding_8 = .true.
end function
pure logical function ieee_support_rounding_10(round_type,x)
type(ieee_round_type), intent(in) :: round_type
real(kind=10), intent(in) :: x
ieee_support_rounding_10 = .true.
end function
pure logical function ieee_support_rounding_16(round_type,x)
type(ieee_round_type), intent(in) :: round_type
real(kind=16), intent(in) :: x
ieee_support_rounding_16 = .true.
end function
end module ieee_arithmetic
| flang/module/ieee_arithmetic.f90 |
The Diabetes Advocacy & Awareness Group, or DAAG, is a UC Davis students student student organizations organization united in combating diabetes, which is one of the fastest growing diseases around the world. Members take an active role in spreading knowledge and awareness of the global epidemic, fund raising for research and relief programs, educating youth and fostering healthy lifestyles, serving underresourced populations in need of proper care, and working to lower diabetes incidence world wide and ultimately find a cure.
For more information join their Facebook group (account required).
See: Support Groups
| lab/davisWiki/Diabetes_Advocacy_%26_Awareness_Group.f |
! { dg-options "-O2 -floop-nest-optimize" }
SUBROUTINE BUG(A,B,X,Y,Z,N)
IMPLICIT NONE
DOUBLE PRECISION A(*),B(*),X(*),Y(*),Z(*)
INTEGER N,J,K
K = 0
DO J = 1,N
K = K+1
X(K) = B(J+N*7)
Y(K) = B(J+N*8)
Z(K) = B(J+N*2) + A(J+N*2)
K = K+1
X(K) = B(J+N*3) + A(J+N*3)
Y(K) = B(J+N*9) + A(J)
Z(K) = B(J+N*15)
K = K+1
X(K) = B(J+N*4) + A(J+N*4)
Y(K) = B(J+N*15)
Z(K) = B(J+N*10) + A(J)
K = K+1
X(K) = B(J+N*11) + A(J+N)
Y(K) = B(J+N*5) + A(J+N*5)
Z(K) = B(J+N*16)
K = K+1
X(K) = B(J+N*16)
Y(K) = B(J+N*6) + A(J+N*6)
Z(K) = B(J+N*12) + A(J+N)
K = K+1
X(K) = B(J+N*13) + A(J+N*2)
Y(K) = B(J+N*17)
Z(K) = B(J+N*7) + A(J+N*7)
ENDDO
RETURN
END
| validation_tests/llvm/f18/gfortran.dg/graphite/pr43349.f |
!=====================================================================
SUBROUTINE mkgrid(z)
!=====================================================================
! Computes the the knots for spline calculation in the Rho =Zr
! variable convenient for scaling.
!---------------------------------------------------------------------
USE spline_param
USE spline_grid
IMPLICIT NONE
REAL(kind=8), INTENT(IN) :: z
!INTEGER, INTRINSIC:: NINT
INTEGER:: i, nt
REAL(KIND=8):: hp1
! .. determine ml, the number of equally spaced steps
ml = NINT(1.d0/h)
nt = ns + ks
nv = ns - ks + 1
me = nv - ml
hp1 = 1.d0 + h
! .. establish the grid for z*r
If (Allocated(t)) Deallocate (t)
ALLOCATE (t(nt))
! the multiple knots at the origin
t(1:ks) = 0.d0
! the equally spaced points
DO i = ks + 1, ks + ml
t(i) = t(i - 1) + h
END DO
! the exponentially spaced points
DO i = ks + ml + 1, ns + 1
t(i) = t(i - 1)*hp1
END DO
t(ns + 2:nt) = t(ns + 1)
! final knots for r variable
t = t/z
rmax = t(ns + 1)
hmax = rmax - t(ns)
END SUBROUTINE mkgrid
| src/mkgrid.f90 |
SUBROUTINE TTUVER (xMIN_V,xCUR_V)
IMPLICIT NONE
* FORMAL_PARAMETERS:
REAL xMIN_V,xCUR_V
** Local variables
LOGICAL TOSCR, TOLOG
INTEGER UNLOG
REAL CUR_V
PARAMETER (CUR_V=4.27)
* desired output
CALL MESSINQ (TOSCR, TOLOG, UNLOG)
IF (xMIN_V.GT.CUR_V) THEN
IF (TOSCR) WRITE (*,'(1X,A,/,1X,A,F5.2,/,1X,A,F5.2,A)')
& 'This program is not linked with the minimal TTUTIL version',
& 'This is TTUTIL version:',CUR_V,
& 'At least version :',xMIN_V,' is required'
IF (TOLOG) WRITE (UNLOG,'(1X,A,/,1X,A,F5.2,/,1X,A,F5.2,A)')
& 'This program is not linked with the minimal TTUTIL version',
& 'This is TTUTIL version:',CUR_V,
& 'At least version :',xMIN_V,' is required'
CALL FATALERR ('TTUVER',' ')
END IF
xCUR_V = CUR_V
RETURN
END
| SRC/TTUTIL/ttuver.for |
program onesea_fill
use mod_za ! HYCOM array I/O interface
implicit none
c
logical larctic,lfirst
integer i,ii,minsea,isea,j,jj,k,nsea
real hmaxa,hmaxb,hmina,hminb
character preambl(5)*79,cline*80
c
c --- read in a hycom topography file,
c --- identify all "seas" not connected to the largest "sea".
c --- fill all those smaller than an input number of points,
c --- and write it out.
c
c --- stdin (unit 5) should have:
c sea size to fill
c
integer, allocatable :: ip(:,:),jp(:)
real, allocatable :: dh(:,:)
c
call xcspmd !input idm,jdm
allocate( jp( jdm) )
allocate( ip(idm,jdm) )
allocate( dh(idm,jdm) )
c
read(5,*) minsea
c
c --- read in a hycom topography file,
c
call zhopen(51, 'formatted', 'old', 0)
read (51,'(a79)') preambl
read (51,'(a)') cline
close(unit=51)
write(6,'(a/(a))') 'HEADER:',
& preambl,cline(1:len_trim(cline)),' '
c
i = index(cline,'=')
read (cline(i+1:),*) hminb,hmaxb
c
call zaiost
call zaiopn('old', 51)
call zaiord(dh,ip,.false., hmina,hmaxa, 51)
call zaiocl(51)
c
if (abs(hmina-hminb).gt.abs(hminb)*1.e-4 .or.
& abs(hmaxa-hmaxb).gt.abs(hmaxb)*1.e-4 ) then
write(6,'(/ a / a,1p3e14.6 / a,1p3e14.6 /)')
& 'error - .a and .b topography files not consistent:',
& '.a,.b min = ',hmina,hminb,hmina-hminb,
& '.a,.b max = ',hmaxa,hmaxb,hmaxa-hmaxb
call zhflsh(6)
stop
endif
c
c --- modified preambl.
c
write(cline,'(a,i12)')
& ' Filled all seas smaller than',minsea
preambl(5) = trim(preambl(5)) // trim(cline)
c
write(6, *)
write(6, *) 'new header:'
write(6, '(A79)') preambl
call zhflsh(6)
c
call zhopen(61, 'formatted', 'new', 0)
write(61,'(A79)') preambl
c
c --- create a land/sea mask.
c
do j= 1,jdm
jp(j) = 0
do i= 1,idm
if (dh(i,j).lt.2.0**99) then
ip(i,j) = 1
jp(j) = jp(j) + 1
else
ip(i,j) = 0
endif
enddo
enddo
c
larctic = maxval(ip(1:idm,jdm)).eq.1 ! sea at j=jdm
write(6,*)
write(6,*) 'larctic = ',larctic
write(6,*)
c
c color fill the sea points, one color per sea.
c
do k= 2,99999
c
c find an unfilled sea point
c
ii = 0
do j= 1,jdm
if (jp(j).gt.0) then
do i= 1,idm
if (ip(i,j).eq.1) then
ii = i
jj = j
exit
endif
enddo !i
if (ii.eq.0) then
jp(j) = 0 !no original sea points left in this row
else
exit
endif
endif
enddo !j
if (ii.eq.0) then
exit !no original sea points left in array
endif
c
c flood-fill the sea that is connected to this point.
c
call fill(ii,jj, k, ip,idm,jdm)
enddo !k
if (larctic) then
do i= 1,idm
ii = idm-mod(i-1,idm)
ip(i,jdm) = ip(ii,jdm-1)
enddo
endif !arctic
c
c how may seas?
c
nsea = k-2
if (nsea.eq.0) then !all-land
write(6,'(/a/)') 'region is all land'
elseif (nsea.eq.1) then !one-sea
write(6,'(/a/)') 'one connected sea only'
else !multiple seas
write(6,'(/i6,a/)') nsea,' seas identified'
do k= 2,nsea+1
isea = 0
do j= 1,jdm
do i= 1,idm
if (ip(i,j).eq.k) then
isea = isea + 1
endif
enddo !i
enddo !j
if (isea.le.minsea) then !filled sea
write(6,'(i9,a,f7.2,a)')
& isea,' point sea (',
& (isea*100.0)/real(idm*jdm),'% of points) FILLED'
else
write(6,'(i9,a,f7.2,a)')
& isea,' point sea (',
& (isea*100.0)/real(idm*jdm),'% of points)'
endif
if (isea.le.minsea) then !filled sea
lfirst = .true.
do j= 1,jdm
do i= 1,idm
if (ip(i,j).eq.k) then
if (lfirst) then
write(6,'(a,2i5)') ' at i,j =',i,j
lfirst = .false.
endif
ip(i,j)=0 !landfill
dh(i,j)=0.0 !landfill
endif
enddo !i
enddo !j
elseif (isea.lt.(idm*jdm)/3) then !non-primary sea
lfirst = .true.
do j= 1,jdm
do i= 1,idm
if (ip(i,j).eq.k) then
if (lfirst) then
write(6,'(a,2i5)') ' at i,j =',i,j
lfirst = .false.
endif
endif
enddo !i
enddo !j
endif
enddo !k
endif
c
c --- write out the land-filled hycom topography file,
c
call zaiopn('new', 61)
call zaiowr(dh, ip,.true., hmina,hmaxa, 61, .false.)
write(61,6100) hmina,hmaxa
write(6, 6100) hmina,hmaxa
write(6, *)
6100 format('min,max depth = ',2f12.5)
end
recursive subroutine fill(i,j,k, ip,idm,jdm)
implicit none
c
integer i,j,k,idm,jdm
integer ip(idm,jdm)
c
c fill this point, if necessary, and then extend search n,s,e,w
c
integer ii
c
if (ip(i,j).eq.1) then
* write(6,*) 'fill - i,j = ',i,j
* call flush(6)
ip(i,j) = k
if (i.ne. 1) then
call fill(i-1,j, k, ip,idm,jdm)
else
call fill(idm,j, k, ip,idm,jdm) !must be periodic, i-1 for i=1
endif
if (j.ne. 1) then
call fill(i, j-1,k, ip,idm,jdm)
endif
if (i.ne.idm) then
call fill(i+1,j, k, ip,idm,jdm)
else
call fill( 1,j, k, ip,idm,jdm) !must be periodic, i+1 for i=idm
endif
if (j.lt.jdm-1) then
call fill(i, j+1,k, ip,idm,jdm)
elseif (j.eq.jdm-1) then
call fill(i, j+1,k, ip,idm,jdm)
ii = idm-mod(i-1,idm)
call fill(ii, j+1,k, ip,idm,jdm) !might be arctic, same point
else !j.eq.jdm
ii = idm-mod(i-1,idm)
call fill(ii, j-1,k, ip,idm,jdm) !must be arctic, same point
endif
elseif (ip(i,j).ne.0 .and. ip(i,j).ne.k) then
write(6,*) 'error in fill, point in two seas: i,j =',i,j
write(6,*) 'sea ',ip(i,j),', and sea ',k
stop
endif
end
| topo/src/topo_onesea_fill.f |
!
! Copyright 2016 ARTED developers
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
subroutine current_stencil_LBLK(E, ikb_s,ikb_e)
use global_variables, only: ik_table,ib_table,NBoccmax,NK_s,NK_e,NLx,NLy,NLz, &
& nabx,naby,nabz,zI
use opt_variables
implicit none
complex(8), intent(in) :: E(0:NLz-1,0:NLy-1,0:NLx-1, NBoccmax, NK_s:NK_e)
integer :: ikb_s,ikb_e
real(8) :: F,G,H
integer :: ix,iy,iz
complex(8) :: v,w
integer :: ikb,ik,ib
#undef IDX
#undef IDY
#undef IDZ
#ifdef ARTED_DOMAIN_POWER_OF_TWO
# define IDX(dt) iz,iy,and(ix+(dt)+NLx,NLx-1),ib,ik
# define IDY(dt) iz,and(iy+(dt)+NLy,NLy-1),ix,ib,ik
# define IDZ(dt) and(iz+(dt)+NLz,NLz-1),iy,ix,ib,ik
#else
# define IDX(dt) iz,iy,modx(ix+(dt)+NLx),ib,ik
# define IDY(dt) iz,mody(iy+(dt)+NLy),ix,ib,ik
# define IDZ(dt) modz(iz+(dt)+NLz),iy,ix,ib,ik
#endif
!$acc kernels pcopy(zcx,zcy,zcz) &
#ifndef ARTED_DOMAIN_POWER_OF_TWO
!$acc pcopyin(modx,mody,modz) &
#endif
!$acc pcopyin(E,ib_table,ik_table,nabx,naby,nabz)
!$acc loop independent gang private(H,G,F)
do ikb=ikb_s,ikb_e
ik=ik_table(ikb)
ib=ib_table(ikb)
F = 0
!$acc loop collapse(3) vector(128) reduction(+:F)
do iy=0,NLy-1
do ix=0,NLx-1
do iz=0,NLz-1
w = conjg(E(iz,iy,ix, ib,ik))
v=(nabx(1)*(E(IDX(1))) &
& +nabx(2)*(E(IDX(2))) &
& +nabx(3)*(E(IDX(3))) &
& +nabx(4)*(E(IDX(4))))
F = F + imag(w * v)
end do
end do
end do
zcx(ib,ik)=F * 2.d0
G = 0
!$acc loop collapse(3) vector(128) reduction(+:G)
do ix=0,NLx-1
do iy=0,NLy-1
do iz=0,NLz-1
w = conjg(E(iz,iy,ix, ib,ik))
v=(naby(1)*(E(IDY(1))) &
& +naby(2)*(E(IDY(2))) &
& +naby(3)*(E(IDY(3))) &
& +naby(4)*(E(IDY(4))))
G = G + imag(w * v)
end do
end do
end do
zcy(ib,ik)=G * 2.d0
H = 0
!$acc loop collapse(3) vector(128) reduction(+:H)
do ix=0,NLx-1
do iy=0,NLy-1
do iz=0,NLz-1
w = conjg(E(iz,iy,ix, ib,ik))
v=(nabz(1)*(E(IDZ(1))) &
& +nabz(2)*(E(IDZ(2))) &
& +nabz(3)*(E(IDZ(3))) &
& +nabz(4)*(E(IDZ(4))))
H = H + imag(w * v)
end do
end do
end do
zcz(ib,ik)=H * 2.d0
end do
!$acc end kernels
end subroutine
| stencil/F90/acc/current.f90 |
*DK extrude
subroutine extrude(imsgin,xmsgin,cmsgin,msgtype,nwds,ierror)
C
C#######################################################################
C
C PURPOSE -
C
C This subroutine extrudes a pseudo-2D polyline (normals of the
C curve pointing in more or less the same direction) into three
C dimensions along either the normal to the curve (default) or a
C user entered value.
C
C NOTES -
C
C Currently only for xyz coordinate system.
C Syntax for this command:
C extrude/sink_mesh_object/source_mesh_object/
C const|min/
C real|integer/
C volume|bubble/ Note: Currently only supports volume
C [norm|x1,y1,z1]
C
C if argument 4 is const, argument 5 is considered to be a
C constant offset from the surface; min, it is the minimum
C distance from the surface to a reference plane. The extruding
C vector is normal to the reference plane.
C
C if argument 6 is volume, the extrusion will create volumes
C from 2D shapes; if it is bubble, the extrusion will run
C hextotet and extract on the resulting volume to create a shell
C around the volume that was created. This argument is ignored
C if the initial MO passed to extrude is made up of line
C segments or points (i.e., if it is 1D topologically).
C
C argument 7 states whether or not the extruding vector will be
C the average normal to the surface, or a user specified vector.
C This argument is optional, norm is the default. If the user
C specifies a vector, the vector will be normalized (i.e., only
C the directionality will be used)
C
C
C
C INPUT ARGUMENTS -
C
C xmsgin() - REAL ARRAY OF COMMAND INPUT VALUES
C cmsgin() - CHARACTER ARRAY OF COMMAND INPUT VALUES
C imsgin() - INTEGER ARRAY OF COMMAND INPUT VALUES
C msgtype() - INTEGER ARRAY OF COMMAND INPUT TYPE
C nwds - NO. OF WORDS OF COMMAND INPUT VALUES
C
C CHANGE HISTORY -
C$Log: extrude.f,v $
CRevision 2.00 2007/11/05 19:45:54 spchu
CImport to CVS
C
CPVCS
CPVCS Rev 1.6 30 Sep 2004 11:15:10 dcg
CPVCS make epsln double precision
CPVCS
CPVCS Rev 1.5 22 Oct 2003 08:04:10 gable
CPVCS ndimensions_geom of new MO was not being set correctly
CPVCS which resulted in problems in other modules.
CPVCS
CPVCS Rev 1.4 20 Jul 2000 14:02:44 bap
CPVCS change call from interp to interp_lg
CPVCS
CPVCS Rev 1.3 29 Jun 2000 10:54:48 bap
CPVCS Incorporated bubble and interp into extrude.
CPVCS
CPVCS Rev 1.2 07 Feb 2000 17:41:54 dcg
CPVCS remove comdict.h
CPVCS
CPVCS Rev 1.1 02 Feb 2000 07:27:50 gable
CPVCS Added call to set_jtetoff to fill jtetoff array
CPVCS just before geneii call.
CPVCS
CPVCS Rev 1.0 Fri Aug 07 13:27:32 1998 dcg
CPVCS Initial revision.
C
C
C#######################################################################
C
implicit none
C
include "local_element.h"
C
C General global Parameters
integer lenptr
parameter (lenptr=1000000)
real epsln
parameter (epsln=1.0d-10)
C
C Subroutine Input Parameters
C
C#######################################################################
C
C Variable Declarations
C
C#######################################################################
C
C Subroutine Input Variables
C
integer nwds
character*(*) cmsgin(nwds)
integer imsgin(nwds), msgtype(nwds)
real*8 xmsgin(nwds)
C
C
C Bubble specific Variables
logical isbubble
integer httopt
C Integer error variables
integer ierror
C
C Name Variables and Message Variables
C
character*32 isubname, cmoin, cmoout, cmoout2, cmofinal
character*132 logmess, cmdmess
C
C Variables used to store temporary data for normal calculations
C
real*8 xnorm_curr, ynorm_curr, znorm_curr
real*8 xnorm_ref, ynorm_ref, znorm_ref
real*8 xvect, yvect, zvect
real*8 anorm, d
real*8 refptx, refpty, refptz
real*8 dotproduct
integer id1, id2, id3
integer pclose
C
C Variables that do not serve any purpose but are required for
C backward compatibility.
integer iout, lout
C
C
C Variables for Number of nodes, elements, nodes/element, etc.
C (i.e., MO defining variables)
integer nnodes, nelements, nsdtopo, nsdgeom, nen, nef
integer neno
C Counters
integer i, itri, idx
C
C Pointers used to store node info for various reasons
C
pointer (ipnodeidx, nodeidx)
C
integer nodeidx(lenptr)
C
C Pointers for incoming CMO
C Node Based Attributes
pointer (ipimt1, imt1)
pointer (ipitp1, itp1)
pointer (ipisn1, isn1)
pointer (ipxic, xic)
pointer (ipyic, yic)
pointer (ipzic, zic)
C
C Element Based Attributes
pointer (ipitetclr, itetclr)
pointer (ipitettyp, itettyp)
pointer (ipitetoff, itetoff)
C
C Array of No. of Elements*No. of Nodes per Element
pointer (ipitet, itet)
C
real*8 xic(lenptr), yic(lenptr), zic(lenptr)
integer imt1(lenptr), itp1(lenptr), isn1(lenptr)
integer itetclr(lenptr), itettyp(lenptr)
integer itet(4*lenptr), itetoff(lenptr)
C The 4 is used to ensure that the pointer is large enough to handle
C any surface.
C
C Pointers for outgoing CMO
C
C Node Based Attributes
pointer (ipimt1o, imt1o)
pointer (ipitp1o, itp1o)
pointer (ipisn1o, isn1o)
pointer (ipxico, xico)
pointer (ipyico, yico)
pointer (ipzico, zico)
C
C Element Based Attributes
pointer (ipitetclro, itetclro)
pointer (ipitettypo, itettypo)
pointer (ipitetoffo, itetoffo)
C
C Array of No. of Elements*No. of Nodes per Element
pointer (ipiteto, iteto)
C
real*8 xico(lenptr), yico(lenptr), zico(lenptr)
integer imt1o(lenptr), itp1o(lenptr), isn1o(lenptr)
integer itetclro(lenptr), itettypo(lenptr)
integer iteto(8*lenptr), itetoffo(lenptr)
C The 8 is used to ensure that the pointer is large enough to handle
C any surface.
C
real*8 dbarea
C
C#######################################################################
C
C Initialize Error Flag and other assorted goodies
C
ierror = 0
cmoin = '-cmo-'
cmoout = '-none-'
cmoout2 = '-none-'
cmofinal = '-none-'
isubname = 'extrude'
isbubble = .FALSE.
C
C#######################################################################
C
C Check the gross syntax of the command entered
C
if ((nwds.eq.11).AND.(cmsgin(4).eq.'interp')) then
call interp_lg(imsgin,xmsgin,cmsgin,msgtype,nwds,ierror)
return
elseif(.NOT.(((nwds.eq.6).OR.(nwds.eq.7).OR.(nwds.eq.9)).AND.
& ((cmsgin(4).eq.'min').OR.(cmsgin(4).eq.'const')))) then
write(logmess,'(a)')
& 'Error in subroutine extrude: The proper Syntax is:'
call writloga('default',0,logmess,0,ierror)
write(logmess,'(a)')
& 'extrude/cmoout/cmoin/min|const/offset/'
& // 'volume|bubble/[norm|x1,y1,z1] OR'
call writloga('default',0,logmess,0,ierror)
write(logmess,'(a)')
$ 'extrude/cmoout/cmoin/interp/layers/range1/range2'
call writloga('default',0,logmess,0,ierror)
write(logmess,'(a)')
$ 'Where range1 and range2 are of the form: '
$ // 'pset,get,<name> or ifirst,ilast,istride'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
C
C
C#######################################################################
C
C Check for old version of input stack
C
if((cmsgin(6).eq.'p').OR.(cmsgin(6).eq.'s')) then
write(logmess,'(a)')
& 'Warning: This syntax is obsolete. The new syntax is:'
call writloga('default',0,logmess,0,ierror)
write(logmess,'(a)')
& 'extrude/cmoout/cmoin/min|const/offset/'
& // 'volume|bubble/[norm|x1,y1,z1]'
call writloga('default',0,logmess,0,ierror)
write(logmess,'(a)')
& 'Continuing using a volume extrusion.'
call writloga('default',0,logmess,0,ierror)
endif
C
C#######################################################################
C
C Initialize the Mesh Objects (Harder than it sounds)
C
C ******************************************************************
C Check if the incoming MO exists
C
cmoin=cmsgin(3)
call cmo_exist(cmoin,ierror)
if(ierror.ne.0) then
write(logmess,'(a)')
& 'Error in subroutine extrude: input MO does not exist'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
C
C ******************************************************************
C Get incoming MO information
C
call cmo_get_info('nnodes',cmoin,nnodes,iout,lout,ierror)
call cmo_get_info('nelements',cmoin,nelements,iout,lout,ierror)
call cmo_get_info('ndimensions_topo',cmoin,nsdtopo,iout,lout,
& ierror)
call cmo_get_info('ndimensions_geom',cmoin,nsdgeom,iout,lout,
& ierror)
call cmo_get_info('nodes_per_element',cmoin,nen,iout,lout,ierror)
call cmo_get_info('faces_per_element',cmoin,nef,iout,lout,ierror)
call cmo_get_info('itp1',cmoin,ipitp1,iout,lout,ierror)
call cmo_get_info('imt1',cmoin,ipimt1,iout,lout,ierror)
call cmo_get_info('isn1',cmoin,ipisn1,iout,lout,ierror)
call cmo_get_info('xic',cmoin,ipxic,iout,lout,ierror)
call cmo_get_info('yic',cmoin,ipyic,iout,lout,ierror)
call cmo_get_info('zic',cmoin,ipzic,iout,lout,ierror)
call cmo_get_info('itetclr',cmoin,ipitetclr,iout,lout,ierror)
call cmo_get_info('itettyp',cmoin,ipitettyp,iout,lout,ierror)
call cmo_get_info('itet',cmoin,ipitet,iout,lout,ierror)
call cmo_get_info('itetoff',cmoin,ipitetoff,iout,lout,ierror)
C
C ******************************************************************
C Check & see if the incoming MO is eligible for this transformation
C (i.e., is it topologically <= 2D, and if it is points, lines, or
C hybrid elements, that a normal vector is supplied)
C
if((nsdtopo.gt.2).AND.(nen.ne.10)) then
write(logmess,'(a)')
& 'Error in subroutine extrude: cmoin is not <= 2D!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
if(((nen.le.2).OR.(nen.eq.10)).AND.(nwds.ne.9)) then
write(logmess,'(a)')
& 'Error in subroutine extrude: You must specify a normal!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
C
C ******************************************************************
C Figure out what kind of extrusion we are doing (volume or bubble)
C and set up the cmoout accordingly...
C
cmofinal = cmsgin(2)
if(cmsgin(6).eq.'bubble') then
C We are doing a bubble extrusion, make sure that the incoming
C MO is eligible.
isbubble = .TRUE.
if((nen.ne.3).AND.(nen.ne.4).AND.(nen.lt.9)) then
write(logmess,'(a)')
& 'Error: Option bubble requires input MO to be made up'
call writloga('default',0,logmess,0,ierror)
write(logmess,'(a)')
& ' of triangles, quads, or hybrid elements!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
C
C Set up temporary names.
C Part 1:
cmoout = 'cmotmp1'
C The length of 'cmotmp1' is 7 chars... (magic number)
C The length of cmoout is 32 chars... (magic number)
i=7
call cmo_exist(cmoout,ierror)
do while (ierror.eq.0)
if(i.gt.32) then
write(logmess, '(a)')
& 'Error! All temporary mo names are in use!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
cmoout(i:i)='%'
i=i+1
call cmo_exist(cmoout,ierror)
enddo
C
C Part 2
cmoout2 = 'cmotmp2'
C The length of 'cmotmp2' is 7 chars... (magic number)
C The length of cmoout2 is 32 chars... (magic number)
i=7
call cmo_exist(cmoout2,ierror)
do while (ierror.eq.0)
if(i.gt.32) then
write(logmess, '(a)')
& 'Error! All temporary mo names are in use!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
cmoout2(i:i)='%'
i=i+1
call cmo_exist(cmoout2,ierror)
enddo
C
C Figure out the proper hextotet conversion option.
if(nen.eq.3) then
httopt=3
elseif(nen.eq.4) then
httopt=5
elseif(nen.ge.9) then
write(logmess,'(a)')
& 'Warning: hextotet may get confused, '
& // 'output may be garbled.'
call writloga('default',0,logmess,0,ierror)
httopt=5
endif
elseif((cmsgin(6).eq.'volume').OR.(cmsgin(6).eq.'p')
& .OR.(cmsgin(6).eq.'s')) then
cmoout = cmofinal
else
write(logmess, '(a)')
& 'Error! You must specify a volume or bubble extrusion!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
goto 9999
endif
C
C ******************************************************************
C Begin setting up the output MO: topology and geometry
C
if(nsdtopo.lt.3) then
nsdtopo = nsdtopo+1
endif
if(nsdgeom.lt.3) then
nsdgeom=nsdgeom+1
endif
C
C ******************************************************************
C Create the output MO
C
C Check if the output MO exists, if it does, remove it.
call cmo_exist(cmoout,ierror)
if(ierror.eq.0) call cmo_release(cmoout,ierror)
C
call cmo_create(cmoout,ierror)
C
C Set the information for the type of mesh object this happens to be
C
call cmo_set_info('nnodes',cmoout,2*nnodes,1,1,ierror)
call cmo_set_info('nelements',cmoout,nelements,1,1,ierror)
call cmo_set_info('ndimensions_topo',cmoout,nsdtopo,1,1,ierror)
call cmo_set_info('ndimensions_geom',cmoout,nsdgeom,1,1,ierror)
C
C Differentiate between two groups:
C hybrids vs. points, lines, triangles, and quads.
C
C Hybrids
if((nen.eq.10)) then
neno=nen
call cmo_set_info('nodes_per_element',cmoout,nen,1,1,ierror)
call cmo_set_info('faces_per_element',cmoout,nef,1,1,ierror)
C points, quads, triangles, and lines
else
neno=2*nen
call cmo_set_info('nodes_per_element',cmoout,2*nen,1,1,ierror)
call cmo_set_info('faces_per_element',cmoout,2+nef,1,1,ierror)
endif
C
if(nen.le.3) then
call cmo_set_info('edges_per_element',cmoout,nen**2,1,1,ierror)
else
call cmo_set_info('edges_per_element',cmoout,12,1,1,ierror)
endif
C
C Reallocate memory.
call cmo_newlen(cmoout,ierror)
C
C ******************************************************************
C Get output MO information
C
call cmo_get_info('imt1',cmoout,ipimt1o,iout,lout,ierror)
call cmo_get_info('itp1',cmoout,ipitp1o,iout,lout,ierror)
call cmo_get_info('isn1',cmoout,ipisn1o,iout,lout,ierror)
call cmo_get_info('xic',cmoout,ipxico,iout,lout,ierror)
call cmo_get_info('yic',cmoout,ipyico,iout,lout,ierror)
call cmo_get_info('zic',cmoout,ipzico,iout,lout,ierror)
call cmo_get_info('itetclr',cmoout,ipitetclro,iout,lout,ierror)
call cmo_get_info('itettyp',cmoout,ipitettypo,iout,lout,ierror)
call cmo_get_info('itet',cmoout,ipiteto,iout,lout,ierror)
call cmo_get_info('itetoff',cmoout,ipitetoffo,iout,lout,ierror)
C
C#######################################################################
C
C Initialize local arrays
C
C ******************************************************************
C Allocate and Initialize memory for node information
C
call mmgetblk('nodeidx',isubname,ipnodeidx,nen,1,ierror)
if(ierror.ne.0) call x3d_error(isubname,'mmgetblk')
C
do i=1,nen
nodeidx(i)=0
enddo
C
C#######################################################################
C
C If the user wants to check for a planar surface, or the average
C normal is to be used, check if that is feasiblie, and if so,
C calculate the normal for each element.
C
if((nwds.eq.6).OR.(cmsgin(7).eq.'norm'))then
C
if((nen.ne.3).AND.(nen.ne.4)) then
write(logmess,'(a)')
& 'Error in subroutine extrude: cmoin must be tri or quad!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
C
C Initialize the Normal variables.
xvect=0.0
yvect=0.0
zvect=0.0
C
do itri=1,nelements
C
C Get the number of nodes, indicies, etc...
do i=1,nelmnen(itettyp(itri))
nodeidx(i)=itet(itetoff(itri)+i)
enddo
C
do i=1,nelmnen(itettyp(itri))
id1=nodeidx(mod(i,nelmnen(itettyp(itri)))+1)
id2=nodeidx(mod((i+1),nelmnen(itettyp(itri)))+1)
id3=nodeidx(mod((i+2),nelmnen(itettyp(itri)))+1)
C
C Calculate out the normals, and make sure they point in
C the same direction.
xnorm_curr=dbarea(yic(id1),zic(id1),
& yic(id2),zic(id2),yic(id3),zic(id3))
ynorm_curr=dbarea(zic(id1),xic(id1),
& zic(id2),xic(id2),zic(id3),xic(id3))
znorm_curr=dbarea(xic(id1),yic(id1),
& xic(id2),yic(id2),xic(id3),yic(id3))
anorm=sqrt(xnorm_curr*xnorm_curr+
& ynorm_curr*ynorm_curr+
& znorm_curr*znorm_curr)
C
C If average was selected, go for it...
if((nwds.eq.6).OR.(cmsgin(7).eq.'norm')) then
xvect = xvect+xnorm_curr
yvect = yvect+ynorm_curr
zvect = zvect+znorm_curr
endif
enddo
enddo
endif
C
C#######################################################################
C
C Now that all the loop-based pre-processing is done, get info
C needed to create the new MO
C
C ******************************************************************
C Get the direction and magnitude of the extruding vector
C
C Magnitude...
if(msgtype(5).eq.1) then
d=imsgin(5)
elseif(msgtype(5).eq.2) then
d=xmsgin(5)
else
write(logmess,'(a)')
& 'Error in subroutine extrude: offset is not a number!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
C
C Direction...
if((nwds.ne.6).AND.(cmsgin(7).ne.'norm').AND.(nwds.ne.9)) then
write(logmess,'(a)')
& 'Error in subroutine extrude: invalid extruding vector!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
elseif(nwds.eq.9) then
C GET THE X PART OF THE EXTRUDING VECTOR
if(msgtype(7).eq.1) then
xvect=imsgin(7)
elseif(msgtype(7).eq.2) then
xvect=xmsgin(7)
else
write(logmess,'(a)')
& 'Error in subroutine extrude: x vector is not a number!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
C GET THE Y PART OF THE EXTRUDING VECTOR
if(msgtype(8).eq.1) then
yvect=imsgin(8)
elseif(msgtype(8).eq.2) then
yvect=xmsgin(8)
else
write(logmess,'(a)')
& 'Error in subroutine extrude: y vector is not a number!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
C GET THE Z PART OF THE EXTRUDING VECTOR
if(msgtype(9).eq.1) then
zvect=imsgin(9)
elseif(msgtype(9).eq.2) then
zvect=xmsgin(9)
else
write(logmess,'(a)')
& 'Error in subroutine extrude: z vector is not a number!'
call writloga('default',0,logmess,0,ierror)
ierror = 1
go to 9999
endif
endif
C
C ******************************************************************
C Normalize the direction
C
anorm=sqrt(xvect*xvect+
& yvect*yvect+
& zvect*zvect)
xvect = xvect/anorm
yvect = yvect/anorm
zvect = zvect/anorm
C
C ******************************************************************
C Figure out if the offset will be minimum or constant and react
C accordingly
C
if(cmsgin(4).eq.'min') then
call minpt(xic,yic,zic,nnodes,xvect,yvect,zvect,d,pclose)
refptx=xic(pclose)+d*xvect
refpty=yic(pclose)+d*yvect
refptz=zic(pclose)+d*zvect
elseif(cmsgin(4).ne.'const') then
write(logmess,'(a)')
& 'Warning: argument 4 is not min or const, assuming const!'
call writloga('default',0,logmess,0,ierror)
endif
C
C#######################################################################
C
C All the pre-processing is done...Start the process of creating the
C new MO
C
C ******************************************************************
C Make copies of the nodes the appropriate distance away.
C
do i=1,nnodes
if(cmsgin(4).eq.'min') then
d=(refptx-xic(i))*(xvect)+
& (refpty-yic(i))*(yvect)+
& (refptz-zic(i))*(zvect)
endif
xico(i)=xic(i)
yico(i)=yic(i)
zico(i)=zic(i)
xico(i+nnodes)=xic(i)+d*xvect
yico(i+nnodes)=yic(i)+d*yvect
zico(i+nnodes)=zic(i)+d*zvect
imt1o(i)=imt1(i)
imt1o(i+nnodes)=imt1(i)
if(isn1(i).ne.0) then
isn1o(i)=isn1(i)
isn1o(i+nnodes)=isn1(i)+nnodes
endif
enddo
C
C ******************************************************************
C Set up the attributes of the new MO
C
do itri=1,nelements
C
C ItetColor
itetclro(itri)=itetclr(itri)
C
C ItetOffset
if(nen.gt.4) then
itetoffo(itri)=itetoff(itri)
else
itetoffo(itri)=2*itetoff(itri)
endif
C
C ItetType
if((itettyp(itri).le.2).OR.(itettyp(itri).eq.4)) then
itettypo(itri)=2*itettyp(itri)
elseif(itettyp(itri).eq.3) then
itettypo(itri)=4+itettyp(itri)
elseif(itettyp(itri).ge.9) then
itettypo(itri)=10
endif
C
if(nen.gt.2) then
xnorm_ref=0.0
ynorm_ref=0.0
znorm_ref=0.0
C
do i=1,nelmnen(itettyp(itri))
nodeidx(i)=itet(itetoff(itri)+i)
enddo
C
do i=1,nelmnen(itettyp(itri))
id1=nodeidx(mod(i,nelmnen(itettyp(itri)))+1)
id2=nodeidx(mod((i+1),nelmnen(itettyp(itri)))+1)
id3=nodeidx(mod((i+2),nelmnen(itettyp(itri)))+1)
C
C Calculate out the normals, and their magnitudes.
xnorm_curr=dbarea(yic(id1),zic(id1),
& yic(id2),zic(id2),yic(id3),zic(id3))
ynorm_curr=dbarea(zic(id1),xic(id1),
& zic(id2),xic(id2),zic(id3),xic(id3))
znorm_curr=dbarea(xic(id1),yic(id1),
& xic(id2),yic(id2),xic(id3),yic(id3))
anorm=sqrt(xnorm_curr*xnorm_curr+
& ynorm_curr*ynorm_curr+
& znorm_curr*znorm_curr)
C
C Normalize and add the normalized normals together, giving
C an idea of where the normals point
xnorm_curr=xnorm_curr/anorm
ynorm_curr=ynorm_curr/anorm
znorm_curr=znorm_curr/anorm
xnorm_ref=xnorm_ref+xnorm_curr
ynorm_ref=ynorm_ref+ynorm_curr
znorm_ref=znorm_ref+znorm_curr
enddo
C
C Normalize the reference normals.
anorm=sqrt(xnorm_ref*xnorm_ref+
& ynorm_ref*ynorm_ref+
& znorm_ref*znorm_ref)
xnorm_ref=xnorm_ref/anorm
ynorm_ref=ynorm_ref/anorm
znorm_ref=znorm_ref/anorm
C
C Check the dotproduct of the elements pseudo normal vector
C and the extruding vector direction if it's >= 0, react
C accordingly.
dotproduct=xnorm_ref*xvect+
& ynorm_ref*yvect+
& znorm_ref*zvect
C
if(dotproduct.gt.0) then
do idx=1,nelmnen(itettyp(itri))
iteto(2*itetoff(itri)+idx)=itet(itetoff(itri)+idx)
iteto(2*itetoff(itri)+idx+nelmnen(itettyp(itri)))=
& itet(itetoff(itri)+idx)+nnodes
enddo
else
do idx=1,nelmnen(itettyp(itri))
iteto(2*itetoff(itri)+idx)=
& itet(itetoff(itri)+idx)+nnodes
iteto(2*itetoff(itri)+idx+nelmnen(itettyp(itri)))=
& itet(itetoff(itri)+idx)
enddo
endif
elseif(nen.eq.2) then
iteto(2*itetoff(itri)+1)=itet(itetoff(itri)+1)
iteto(2*itetoff(itri)+1+nelmnen(itettyp(itri)))=
& itet(itetoff(itri)+2)+nnodes
iteto(2*itetoff(itri)+2)=itet(itetoff(itri)+1)+nnodes
iteto(2*itetoff(itri)+2+nelmnen(itettyp(itri)))=
& itet(itetoff(itri)+2)
elseif(nen.eq.1) then
iteto(2*itetoff(itri)+1)=itet(itetoff(itri)+1)
iteto(2*itetoff(itri)+1+nelmnen(itettyp(itri)))=
& itet(itetoff(itri)+1)+nnodes
endif
enddo
C
C ****************************************************************
C Set up the connectivity of the new MO and fill the jtetoff array.
C
call set_jtetoff()
call dotaskx3d('resetpts itp; finish',ierror)
C
C ******************************************************************
C See if we need to make the resulting MO a bubble.
if (isbubble) then
C
C HextoTet and Extract commands create the bubble
C
write(cmdmess,35) httopt,cmoout2,cmoout
35 format('hextotet/',I1,'/',A,'/',A,'; finish')
call dotaskx3d(cmdmess,ierror)
if(ierror.ne.0) then
goto 9998
endif
C
write(cmdmess,40) cmofinal,cmoout2
40 format('extract/intrface/-all-/1 0 0/',A,'/',A,'; finish')
call dotaskx3d(cmdmess,ierror)
if(ierror.ne.0) then
goto 9998
endif
C Release Temporary cmos
C
9998 continue
call cmo_exist(cmoout,ierror)
if(ierror.eq.0) call cmo_release(cmoout,ierror)
call cmo_exist(cmoout2,ierror)
if(ierror.eq.0) call cmo_release(cmoout2,ierror)
endif
C
C ******************************************************************
C Release temporary memory and be done with it
C
9999 continue
9995 call mmrelprt(isubname,ierror)
return
end
C
C#####################################################################
C
C Subroutine to calculate the closest point to the reference plane
C
C#####################################################################
C
subroutine minpt(xin,yin,zin,nnodes,xvect,yvect,
& zvect,d,pout)
implicit none
integer nnodes, p1, p2
integer pout
real*8 xin(nnodes), yin(nnodes), zin(nnodes)
real*8 xvect,yvect,zvect,d,d1
real*8 dotproduct,p3x,p3y,p3z
if(d.eq.0) then
d1=.1
else
d1=d
endif
p1=1
p3x=xin(p1)+d1*xvect
p3y=yin(p1)+d1*yvect
p3z=zin(p1)+d1*zvect
do p2=2,nnodes
dotproduct=(p3x-xin(p1))*(xin(p2)-xin(p1))+
& (p3y-yin(p1))*(yin(p2)-yin(p1))+
& (p3z-zin(p1))*(zin(p2)-zin(p1))
if(dotproduct.gt.0) then
p1=p2
p3x=xin(p2)+d1*xvect
p3y=yin(p2)+d1*yvect
p3z=zin(p2)+d1*zvect
endif
enddo
pout = p1
return
end
C
C#######################################################################
C
C Function DBArea:
C
C Returns double the area of a triangle ordered (counterclockwise)
C 1,2,3 in the u-v plane. This means that for a triangle ordered
C 1,2,3 in x-y-z space, the (r.h. rule) vector normal to this
C triangle
C with magnitude equal to double the area is given by:
C < dbarea(y1,z1,y2,z2,y3,z3),
C dbarea(z1,x1,z2,x2,z3,x3),
C dbarea(x1,y1,x2,y2,x3,y3) >.
C
C#######################################################################
C
real*8 function dbarea(u1,v1,u2,v2,u3,v3)
implicit none
real*8 u1,v1,u2,v2,u3,v3
dbarea = (u2-u1)*(v3-v1)-(v2-v1)*(u3-u1)
return
end
| src/extrude.f |
SUBROUTINE HENDD ( ieop, iret )
C************************************************************************
C* HENDD - XW *
C* *
C* This subroutine must be the last subroutine called by any program *
C* that uses GEMPLT. It will flush internal buffers if necessary in *
C* the device driver. The DEVICE subprocess may be retained so that *
C* the current definitions are available in later programs. *
C* *
C* HENDD ( IEOP, IRET ) *
C* *
C* Input parameters: *
C* IEOP INTEGER End plotting flag *
C* 0 = retain subprocess *
C* 1 = stop subprocess *
C* *
C* Output parameters: *
C* IRET INTEGER Return code *
C** *
C* Log: *
C* M. desJardins/NMC 01/92 Close window when plotting is done *
C* S. Jacobs/NMC 7/94 General clean up *
C* S. Maxwell/GSC 6/97 Documentation changes *
C************************************************************************
C------------------------------------------------------------------------
C* Check for plotting done.
C
IF ( ieop .eq. 1 ) CALL XENDD ( iret )
C*
RETURN
END
| gempak/source/driver/active/xw/hendd.f |
C Copyright(C) 1999-2020 National Technology & Engineering Solutions
C of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
C NTESS, the U.S. Government retains certain rights in this software.
C
C See packages/seacas/LICENSE for details
C=======================================================================
SUBROUTINE PLTRSC
REAL DEVCAP(23)
REAL DEFOUT(7)
COMMON /STATUS/DEVCAP,DEFOUT
REAL DEVP(5)
COMMON /DEVICE/DEVP
REAL COLP(3)
REAL PALETT(3,16)
COMMON /COLOR/COLP,PALETT
REAL TEXTP(40)
COMMON /TEXT/TEXTP
REAL VECTP(5)
REAL XCUR
REAL YCUR
COMMON /VECTRC/VECTP,XCUR,YCUR
INTEGER IDEX(200,2)
INTEGER NVECT(200,2)
REAL XSIZE(200,2)
REAL YSIZE(200,2)
REAL X0(2300,2)
REAL Y0(2300,2)
REAL X1(2300,2)
REAL Y1(2300,2)
COMMON /FONT/IDEX,NVECT,XSIZE,YSIZE,X0,Y0,X1,Y1
REAL GRAPHP(100)
COMMON /GRAPH/GRAPHP
COMMON /MAPPAR/MAPP(11)
REAL MAPP
COMMON /STORAG/MEMORY(1000)
COLP(2) = MIN(16.,DEVCAP(4))
COLP(3) = DEVCAP(4) - COLP(2)
PALETT(1,1) = 0.
PALETT(2,1) = 0.
PALETT(3,1) = 0.
CALL VDSTCO(1,0,PALETT(1,1),0)
PALETT(1,2) = 1.
PALETT(2,2) = 0.
PALETT(2,3) = 0.
CALL VDSTCO(1,1,PALETT(1,2),0)
PALETT(1,3) = 0.
PALETT(2,3) = 1.
PALETT(3,3) = 0.
CALL VDSTCO(1,2,PALETT(1,3),0)
PALETT(1,4) = 1.
PALETT(2,4) = 1.
PALETT(3,4) = 0.
CALL VDSTCO(1,3,PALETT(1,4),0)
PALETT(1,5) = 0.
PALETT(2,5) = 0.
PALETT(3,5) = 1.
CALL VDSTCO(1,4,PALETT(1,5),0)
PALETT(1,6) = 1.
PALETT(2,6) = 0.
PALETT(3,6) = 1.
CALL VDSTCO(1,5,PALETT(1,6),0)
PALETT(1,7) = 0.
PALETT(2,7) = 1.
PALETT(3,7) = 1.
CALL VDSTCO(1,6,PALETT(1,7),0)
PALETT(1,8) = 1.
PALETT(2,8) = 1.
PALETT(3,8) = 1.
CALL VDSTCO(1,7,PALETT(1,8),0)
PALETT(1,9) = .4
PALETT(2,9) = .4
PALETT(3,9) = .4
CALL VDSTCO(1,8,PALETT(1,9),0)
PALETT(1,10) = .7
PALETT(2,10) = .7
PALETT(3,10) = .7
CALL VDSTCO(1,9,PALETT(1,10),0)
PALETT(1,11) = .225
PALETT(2,11) = .225
PALETT(3,11) = .225
CALL VDSTCO(1,10,PALETT(1,11),0)
PALETT(1,12) = 1.
PALETT(2,12) = .35
PALETT(3,12) = .45
CALL VDSTCO(1,11,PALETT(1,12),0)
PALETT(1,13) = .5
PALETT(2,13) = 1.
PALETT(3,13) = .8
CALL VDSTCO(1,12,PALETT(1,13),0)
PALETT(1,14) = .4
PALETT(2,14) = .7
PALETT(3,14) = 1.
CALL VDSTCO(1,13,PALETT(1,14),0)
PALETT(1,15) = .706
PALETT(2,15) = 0.
PALETT(3,15) = .706
CALL VDSTCO(1,14,PALETT(1,15),0)
PALETT(1,16) = 1.
PALETT(2,16) = .659
PALETT(3,16) = 0.
CALL VDSTCO(1,15,PALETT(1,16),0)
CALL PLTSTC(1,0.)
RETURN
END
| packages/seacas/libraries/plt/pltrsc.f |
program test_hash
Use hash
Use, intrinsic :: iso_fortran_env, only : wp => real64
Implicit None
Type( hash_table ) :: table
Real(kind = wp) :: test_float
Integer :: test_int
Complex(kind = wp) :: test_comp
open(unit=50, file="test_new_control")
call table%init(30)
call table%set('float', 3.1415926535897931_wp)
call table%set('int', 42)
call table%set('complex', (1.0_wp, 1.0_wp))
call table%get('float', test_float)
call table%get('int', test_int)
call table%get('complex', test_comp)
print*, test_float
print*, test_int
print*, test_comp
if (abs(test_float - 4.0_wp*atan(1.0_wp)) > 1e-12_wp) print*, "Float retrieval failed"
if (test_int /= 42) print*, "Int retrieval failed"
if (abs(test_comp - (1.0_wp, 1.0_wp)) > 1e-12_wp) print*, "Complex retrieval failed"
end program test_hash
| Hash/test_hash.f90 |
Daryl Suyat is a double major in Political Science and Asian American Studies from Oceanside, California. He is a cofounder and currently the editor in chief of Vent Magazine.
He was an Internal Affairs Commission ASUCD Internal Affairs Commissioner, was an intern for the 20052006 Student Assistants to the Chancellor, a board member for Mga Kapatid and a former intern for Congressman http://issa.house.gov/ Darrell Issa.
Daryl was a Fall 2006 ASUCD Election/Senate Candidates candidate for ASUCD ASUCD Senate Senate in the Fall 2006 ASUCD Election, running on the L.E.A.D. slate. His bid was unsuccessful. His bid was unsuccessful, but only barely so. He came a handful of votes away from getting into office.
| lab/davisWiki/Daryl_Suyat.f |
C................................................................ GSU 10
SUBROUTINE GSUB(I, Z, G) GSU 20
REAL*8 Z(4), G
GO TO (10, 20, 10, 20), I
10 G = Z(1) - 0.
RETURN
20 G = Z(3) - 0.
RETURN
END
| src/f2cl/packages/colnew/problem-1/gsub.f |
subroutine wave2com (fof,sr)
!
! Head routine for calling hiscom
!
use swan_flow_grid_maps
use swan_input
implicit none
type (output_fields) :: fof
type (swan) :: sr
call hiscom(fof%hs ,fof%dir ,fof%period ,fof%depth , &
& fof%fx ,fof%fy ,fof%mx ,fof%my , &
& fof%dissip(:,:,1) ,fof%dissip(:,:,2) ,fof%dissip(:,:,3) ,fof%dissip(:,:,4) , &
& fof%mmax ,fof%nmax ,fof%hrms ,fof%tp , &
& sr%grav ,sr%swflux ,sr%swdis ,sr%rho , &
& sr%gamma0 ,fof%wsbodyu ,fof%wsbodyv )
end subroutine wave2com
subroutine hiscom(hs ,dir ,period ,depth , &
& fx ,fy ,mx ,my , &
& distot ,dissurf ,diswcap ,disbot , &
& m ,n ,hrms ,tp , &
& grav ,swflux ,swdis ,rho , &
& gamma0 ,wsbodyu ,wsbodyv )
!----- GPL ---------------------------------------------------------------------
!
! Copyright (C) Stichting Deltares, 2011-2016.
!
! This program is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation version 3.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <http://www.gnu.org/licenses/>.
!
! contact: delft3d.support@deltares.nl
! Stichting Deltares
! P.O. Box 177
! 2600 MH Delft, The Netherlands
!
! All indications and logos of, and references to, "Delft3D" and "Deltares"
! are registered trademarks of Stichting Deltares, and remain the property of
! Stichting Deltares. All rights reserved.
!
!-------------------------------------------------------------------------------
! $Id: wave2com.f90 5717 2016-01-12 11:35:24Z mourits $
! $HeadURL: https://svn.oss.deltares.nl/repos/delft3d/tags/6686/src/engines_gpl/wave/packages/kernel/src/wave2com.f90 $
!!--description-----------------------------------------------------------------
! NONE
!!--pseudo code and references--------------------------------------------------
! NONE
!!--declarations----------------------------------------------------------------
implicit none
!
! Common variables
real :: pi, twopi, wort2, gamma
common /const / pi, twopi, wort2, gamma
!
! Global variables
!
integer , intent(in) :: m
integer , intent(in) :: n
integer :: swdis
real , dimension(m*n) :: depth
real , dimension(m*n) :: dir
real , dimension(m*n) :: distot
real , dimension(m*n) :: dissurf
real , dimension(m*n) :: diswcap
real , dimension(m*n) :: disbot
real , dimension(m*n) :: fx
real , dimension(m*n) :: fy
real , intent(in) :: gamma0 ! JONSWAP peak enhancement factor
real :: grav
real , dimension(m*n), intent(out) :: hrms
real , dimension(m*n), intent(in) :: hs
real , dimension(m*n), intent(out) :: mx
real , dimension(m*n), intent(out) :: my
real , dimension(m*n), intent(in) :: period
real :: rho
real , dimension(m*n), intent(out) :: tp
real , dimension(m*n) :: wsbodyu
real , dimension(m*n) :: wsbodyv
logical :: swflux
!
! Local variables
!
integer :: ierr
integer :: l
integer :: npnt
logical :: corht
logical :: ldep
real :: deph
real :: dirh
real :: dish
real :: diss
real :: dismax
real :: dr
real :: fxhis
real :: fxx
real :: fyhis
real :: fyy
real :: hrm
real :: perfac
real :: qbsli
real :: tpp
real :: wavek
real :: wavel
real :: wsbodyuu
real :: wsbodyvv
!
!! executable statements -------------------------------------------------------
!
corht = .false.
pi = 4.0*atan(1.0E0)
dr = pi/180.
twopi = 2.0*pi
wort2 = sqrt(2.0E0)
gamma = 0.8
perfac = 1.
call perpar(gamma0, perfac, ierr)
if (ierr < 0) then
write(*,'(a,f10.5)') 'ERROR: gamma0 = ',gamma0,' lies outside allowed range [1,20]'
stop
endif
!
! Start loop
!
npnt = m*n
l = 0
1000 continue
l = l + 1
hrm = hs(l)/wort2
dirh = dir(l)
deph = depth(l)
tpp = period(l)*perfac
fxhis = fx(l)
fyhis = fy(l)
dish = distot(l)
diss = dissurf(l) + diswcap(l)
!
call corrht(hrm ,deph ,tpp ,wavel ,wavek , &
& ldep ,dish ,dismax ,corht ,rho , &
& grav )
!
! If .not. swdis use fx, fy from SWAN
! else compute forces based on dissipation and celerity
!
wsbodyuu = 0.0
wsbodyvv = 0.0
call wapar(hrm ,dirh ,deph ,tpp ,fxhis , &
& fyhis ,dish ,diss ,wavel ,wavek , &
& ldep ,fxx ,fyy ,qbsli ,dismax , &
& corht ,swdis ,grav ,wsbodyuu ,wsbodyvv )
hrms(l) = hrm
dir(l) = dirh
depth(l) = deph
tp(l) = tpp
fx(l) = fxx
fy(l) = fyy
wsbodyu(l) = wsbodyuu
wsbodyv(l) = wsbodyvv
distot(l) = dish
if (.not.ldep) then
if (wavel>1.0E-6 .and. swflux) then
mx(l) = .125*grav*hrm*hrm*tpp/wavel*cos(dirh*dr)
my(l) = .125*grav*hrm*hrm*tpp/wavel*sin(dirh*dr)
else
mx(l) = 0.
my(l) = 0.
endif
else
mx(l) = 0.
my(l) = 0.
endif
!
! End loop
!
if (l<npnt) goto 1000
end subroutine hiscom
| docker/water/delft3d/tags/v6686/src/engines_gpl/wave/packages/kernel/src/wave2com.f90 |
Subroutine luprep(ip)
Implicit Double Precision (D)
Common /lujets/n, k(9000, 5), p(9000, 5), v(9000, 5)
Save /lujets/
Common /ludat1/mstu(200), paru(200), mstj(200), parj(200)
Save /ludat1/
Common /ludat2/kchg(500, 3), pmas(500, 4), parf(2000), vckm(4, 4)
Save /ludat2/
Common /ludat3/mdcy(500, 3), mdme(2000, 2), brat(2000), kfdp(2000, 5)
Save /ludat3/
Dimension dps(5), dpc(5), ue(3)
i1 = n
Do mqgst = 1, 2
Do i = max(1, ip), n
If (k(i,1)/=3) Goto 120
kc = lucomp(k(i,2))
If (kc==0) Goto 120
kq = kchg(kc, 2)
If (kq==0 .Or. (mqgst==1 .And. kq==2)) Goto 120
kcs = 4
If (kq*isign(1,k(i,2))<0) kcs = 5
ia = i
nstp = 0
100 nstp = nstp + 1
If (nstp>4*n) Then
Call luerrm(14, '(LUPREP:) caught in infinite loop')
Return
End If
If (k(ia,1)==3) Then
If (i1>=mstu(4)-mstu(32)-5) Then
Call luerrm(11, '(LUPREP:) no more memory left in LUJETS')
Return
End If
i1 = i1 + 1
k(i1, 1) = 2
If (nstp>=2 .And. iabs(k(ia,2))/=21) k(i1, 1) = 1
k(i1, 2) = k(ia, 2)
k(i1, 3) = ia
k(i1, 4) = 0
k(i1, 5) = 0
Do j = 1, 5
p(i1, j) = p(ia, j)
v(i1, j) = v(ia, j)
End Do
k(ia, 1) = k(ia, 1) + 10
If (k(i1,1)==1) Goto 120
End If
ib = ia
If (mod(k(ib,kcs)/mstu(5)**2,2)==0 .And. mod(k(ib,kcs),mstu(5))/=0) Then
ia = mod(k(ib,kcs), mstu(5))
k(ib, kcs) = k(ib, kcs) + mstu(5)**2
mrev = 0
Else
If (k(ib,kcs)>=2*mstu(5)**2 .Or. mod(k(ib,kcs)/mstu(5),mstu(5))==0) kcs = 9 - kcs
ia = mod(k(ib,kcs)/mstu(5), mstu(5))
k(ib, kcs) = k(ib, kcs) + 2*mstu(5)**2
mrev = 1
End If
If (ia<=0 .Or. ia>n) Then
Call luerrm(12, '(LUPREP:) colour rearrangement failed')
Return
End If
If (mod(k(ia,4)/mstu(5),mstu(5))==ib .Or. mod(k(ia,5)/mstu(5),mstu(5))==ib) Then
If (mrev==1) kcs = 9 - kcs
If (mod(k(ia,kcs)/mstu(5),mstu(5))/=ib) kcs = 9 - kcs
k(ia, kcs) = k(ia, kcs) + 2*mstu(5)**2
Else
If (mrev==0) kcs = 9 - kcs
If (mod(k(ia,kcs),mstu(5))/=ib) kcs = 9 - kcs
k(ia, kcs) = k(ia, kcs) + mstu(5)**2
End If
If (ia/=i) Goto 100
k(i1, 1) = 1
120 End Do
End Do
n = i1
If (mstj(14)<=0) Goto 320
ns = n
140 nsin = n - ns
pdm = 1. + parj(32)
ic = 0
Do i = max(1, ip), ns
If (k(i,1)/=1 .And. k(i,1)/=2) Then
Else If (k(i,1)==2 .And. ic==0) Then
nsin = nsin + 1
ic = i
Do j = 1, 4
dps(j) = dble(p(i,j))
End Do
mstj(93) = 1
dps(5) = dble(ulmass(k(i,2)))
Else If (k(i,1)==2) Then
Do j = 1, 4
dps(j) = dps(j) + dble(p(i,j))
End Do
Else If (ic/=0 .And. kchg(lucomp(k(i,2)),2)/=0) Then
Do j = 1, 4
dps(j) = dps(j) + dble(p(i,j))
End Do
mstj(93) = 1
dps(5) = dps(5) + dble(ulmass(k(i,2)))
pd = sngl(sqrt(max(0D0,dps(4)**2-dps(1)**2-dps(2)**2-dps(3)**2))-dps(5))
If (pd<pdm) Then
pdm = pd
Do j = 1, 5
dpc(j) = dps(j)
End Do
ic1 = ic
ic2 = i
End If
ic = 0
Else
nsin = nsin + 1
End If
End Do
If (pdm>=parj(32)) Goto 320
nsav = n
pecm = sngl(sqrt(max(0D0,dpc(4)**2-dpc(1)**2-dpc(2)**2-dpc(3)**2)))
k(n+1, 1) = 11
k(n+1, 2) = 91
k(n+1, 3) = ic1
k(n+1, 4) = n + 2
k(n+1, 5) = n + 3
p(n+1, 1) = sngl(dpc(1))
p(n+1, 2) = sngl(dpc(2))
p(n+1, 3) = sngl(dpc(3))
p(n+1, 4) = sngl(dpc(4))
p(n+1, 5) = pecm
k(n+2, 1) = 1
k(n+3, 1) = 1
If (mstu(16)/=2) Then
k(n+2, 3) = n + 1
k(n+3, 3) = n + 1
Else
k(n+2, 3) = ic1
k(n+3, 3) = ic2
End If
k(n+2, 4) = 0
k(n+3, 4) = 0
k(n+2, 5) = 0
k(n+3, 5) = 0
If (iabs(k(ic1,2))/=21) Then
kc1 = lucomp(k(ic1,2))
kc2 = lucomp(k(ic2,2))
If (kc1==0 .Or. kc2==0) Goto 320
kq1 = kchg(kc1, 2)*isign(1, k(ic1,2))
kq2 = kchg(kc2, 2)*isign(1, k(ic2,2))
If (kq1+kq2/=0) Goto 320
200 Call lukfdi(k(ic1,2), 0, kfln, k(n+2,2))
Call lukfdi(k(ic2,2), -kfln, kfldmp, k(n+3,2))
If (k(n+2,2)==0 .Or. k(n+3,2)==0) Goto 200
Else
If (iabs(k(ic2,2))/=21) Goto 320
210 Call lukfdi(1+int((2.+parj(2))*rlu(0)), 0, kfln, kfdmp)
Call lukfdi(kfln, 0, kflm, k(n+2,2))
Call lukfdi(-kfln, -kflm, kfldmp, k(n+3,2))
If (k(n+2,2)==0 .Or. k(n+3,2)==0) Goto 210
End If
p(n+2, 5) = ulmass(k(n+2,2))
p(n+3, 5) = ulmass(k(n+3,2))
If (p(n+2,5)+p(n+3,5)+parj(64)>=pecm .And. nsin==1) Goto 320
If (p(n+2,5)+p(n+3,5)+parj(64)>=pecm) Goto 260
If (dble(pecm)>=0.02D0*dpc(4)) Then
pa = sqrt((pecm**2-(p(n+2,5)+p(n+3,5))**2)*(pecm**2-(p(n+2,5)-p(n+3,5))**2))/(2.*pecm)
ue(3) = 2.*rlu(0) - 1.
phi = paru(2)*rlu(0)
ue(1) = sqrt(1.-ue(3)**2)*cos(phi)
ue(2) = sqrt(1.-ue(3)**2)*sin(phi)
Do j = 1, 3
p(n+2, j) = pa*ue(j)
p(n+3, j) = -pa*ue(j)
End Do
p(n+2, 4) = sqrt(pa**2+p(n+2,5)**2)
p(n+3, 4) = sqrt(pa**2+p(n+3,5)**2)
Call ludbrb(n+2, n+3, 0., 0., dpc(1)/dpc(4), dpc(2)/dpc(4), dpc(3)/dpc(4))
Else
np = 0
Do i = ic1, ic2
If (k(i,1)==1 .Or. k(i,1)==2) np = np + 1
End Do
ha = p(ic1, 4)*p(ic2, 4) - p(ic1, 1)*p(ic2, 1) - p(ic1, 2)*p(ic2, 2) - p(ic1, 3)*p(ic2, 3)
If (np>=3 .Or. ha<=1.25*p(ic1,5)*p(ic2,5)) Goto 260
hd1 = 0.5*(p(n+2,5)**2-p(ic1,5)**2)
hd2 = 0.5*(p(n+3,5)**2-p(ic2,5)**2)
hr = sqrt(max(0.,((ha-hd1-hd2)**2-(p(n+2,5)*p(n+3,5))**2)/(ha**2-(p(ic1,5)*p(ic2,5))**2))) - 1.
hc = p(ic1, 5)**2 + 2.*ha + p(ic2, 5)**2
hk1 = ((p(ic2,5)**2+ha)*hr+hd1-hd2)/hc
hk2 = ((p(ic1,5)**2+ha)*hr+hd2-hd1)/hc
Do j = 1, 4
p(n+2, j) = (1.+hk1)*p(ic1, j) - hk2*p(ic2, j)
p(n+3, j) = (1.+hk2)*p(ic2, j) - hk1*p(ic1, j)
End Do
End If
Do j = 1, 4
v(n+1, j) = v(ic1, j)
v(n+2, j) = v(ic1, j)
v(n+3, j) = v(ic2, j)
End Do
v(n+1, 5) = 0.
v(n+2, 5) = 0.
v(n+3, 5) = 0.
n = n + 3
Goto 300
260 k(n+1, 5) = n + 2
If (iabs(k(ic1,2))>100 .And. iabs(k(ic2,2))>100) Then
Goto 320
Else If (iabs(k(ic1,2))/=21) Then
Call lukfdi(k(ic1,2), k(ic2,2), kfldmp, k(n+2,2))
Else
kfln = 1 + int((2.+parj(2))*rlu(0))
Call lukfdi(kfln, -kfln, kfldmp, k(n+2,2))
End If
If (k(n+2,2)==0) Goto 260
p(n+2, 5) = ulmass(k(n+2,2))
ir = 0
ha = 0.
Do mcomb = 1, 3
If (ir/=0) Goto 280
Do i = max(1, ip), n
If (k(i,1)<=0 .Or. k(i,1)>10 .Or. (i>=ic1 .And. i<=ic2 .And. k(i,1)>=1 .And. k(i,1)<=2)) Goto 270
If (mcomb==1) kci = lucomp(k(i,2))
If (mcomb==1 .And. kci==0) Goto 270
If (mcomb==1 .And. kchg(kci,2)==0 .And. i<=ns) Goto 270
If (mcomb==2 .And. iabs(k(i,2))>10 .And. iabs(k(i,2))<=100) Goto 270
hcr = sngl(dpc(4))*p(i, 4) - sngl(dpc(1))*p(i, 1) - sngl(dpc(2))*p(i, 2) - sngl(dpc(3))*p(i, 3)
If (hcr>ha) Then
ir = i
ha = hcr
End If
270 End Do
280 End Do
hb = pecm**2 + ha
hc = p(n+2, 5)**2 + ha
hd = p(ir, 5)**2 + ha
hk2 = 0.0
If (ha**2-(pecm*p(ir,5))**2==0.0 .Or. hb+hd==0.0) Goto 285
hk2 = 0.5*(hb*sqrt(((hb+hc)**2-4.*(hb+hd)*p(n+2,5)**2)/(ha**2-(pecm*p(ir,5))**2))-(hb+hc))/(hb+hd)
285 hk1 = (0.5*(p(n+2,5)**2-pecm**2)+hd*hk2)/hb
Do j = 1, 4
p(n+2, j) = (1.+hk1)*sngl(dpc(j)) - hk2*p(ir, j)
p(ir, j) = (1.+hk2)*p(ir, j) - hk1*sngl(dpc(j))
v(n+1, j) = v(ic1, j)
v(n+2, j) = v(ic1, j)
End Do
v(n+1, 5) = 0.
v(n+2, 5) = 0.
n = n + 2
300 Do i = ic1, ic2
If ((k(i,1)==1 .Or. k(i,1)==2) .And. kchg(lucomp(k(i,2)),2)/=0) Then
k(i, 1) = k(i, 1) + 10
If (mstu(16)/=2) Then
k(i, 4) = nsav + 1
k(i, 5) = nsav + 1
Else
k(i, 4) = nsav + 2
k(i, 5) = n
End If
End If
End Do
If (n<mstu(4)-mstu(32)-5) Goto 140
320 np = 0
kfn = 0
kqs = 0
Do j = 1, 5
dps(j) = 0D0
End Do
Do i = max(1, ip), n
If (k(i,1)<=0 .Or. k(i,1)>10) Goto 360
kc = lucomp(k(i,2))
If (kc==0) Goto 360
kq = kchg(kc, 2)*isign(1, k(i,2))
If (kq==0) Goto 360
np = np + 1
If (kq/=2) Then
kfn = kfn + 1
kqs = kqs + kq
mstj(93) = 1
dps(5) = dps(5) + dble(ulmass(k(i,2)))
End If
Do j = 1, 4
dps(j) = dps(j) + dble(p(i,j))
End Do
If (k(i,1)==1) Then
If (np/=1 .And. (kfn==1 .Or. kfn>=3 .Or. kqs/=0)) Call luerrm(2, '(LUPREP:) unphysical flavour combination')
If (np/=2 .And. dps(4)**2-dps(1)**2-dps(2)**2-dps(3)**2<(0.9D0*dble(parj(32))+dps(5))**2) Then
Call luerrm(3, '(LUPREP:) too small mass in jet system')
Write (6, *) 'DPS(1-5),KI1-5=', dps(1), dps(2), dps(3), dps(4), dps(5), '*', k(i, 1), k(i, 2), k(i, 3), k(i, 4), k(i, 5)
End If
np = 0
kfn = 0
kqs = 0
Do j = 1, 5
dps(j) = 0D0
End Do
End If
360 End Do
Return
End Subroutine luprep
| src/luprep.f90 |
c$Id: to_711-2B.f,v 1.2 2007/04/29 05:14:20 avi Exp $
c$Log: to_711-2B.f,v $
c Revision 1.2 2007/04/29 05:14:20 avi
c gcc v3 compliant
c
c Revision 1.1 1997/10/11 07:02:48 avi
c Initial revision
c
subroutine to_711_2b(t4)
c convert atlas transform from target 711-2A to 711-2B
real*4 t4(4,4)
real*4 bt(4,4)/
& 1.051053, -0.002200, 0.018579, -0.4981,
& 0.000148, 1.040993, 0.105308, 5.5848,
& -0.019619, -0.108215, 1.004962, 0.9322,
& 0.000000, 0.000000, 0.000000, 1.0000/
real*4 b(4,4),a(4,4)
external transpos,matmul,matcop
call transpos(bt,b,4)
call matmul(t4,b,a,4)
call matcop(a,t4,4)
return
end
| 4dfp/t4imgs_4dfp/to_711-2B.f |
SUBROUTINE STPPHI(CA,BLOC,PM,NS)
C PHI-FUNCTIONS FOR EACH STRIP (NACA TM 991, PG 19).
C THE FOLLOWING FUNCTIONS ARE NOT COMPUTED, THEY ARE LEFT ZEROED
C - NUMBERS 20, 22-30, 33, 34
DIMENSION CA(1),BLOC(1),PM(37,NS)
DIMENSION P(37)
PI=3.141593
DO 100 N=1,NS
DO 10 I=1,37
10 P(I)=0.0
CT=CA(N)/BLOC(N)
IF(CT.LE.1.0E-03) GO TO 50
C=CT-1.0
C2=C*C
S2=1.0-C2
S =SQRT(S2)
X=ATAN2(S,C)
C WATCH THIS TRIG
PMX=PI-X
P(1) = PMX + S
P(2) = PMX*(1.+2.*C) + S*(2.+C)
P(3) = PMX + S*C
P(4) = PMX*2.*C + S*2.*(2.+C2)/3.
P(5) = S*(1.-C)
P(6) = 2.*PMX + S*2.*(2.-C)*(1.+2.*C)/3.
P(7) = PMX*(0.5+2.*C) + S*(8.+5.*C+4.*C2-2.*C2*C)/6.
P(8) = PMX*(-1.+2.*C) + S*(2.-C)
P(9) = PMX*(1.+2.*C) + S*(2.+3.*C+4.*C2)/3.
P(11) = P(2)*P(3)
P(12) = PMX*PMX*(0.5+4.*C2) + PMX*S*C*(7.+2.*C2) + S2*(2.+2.5*C2)
P(13) = SIN(0.5*X)/COS(0.5*X)
P(14) = 2.*S
P(15) = P(13)-P(14)
P(16) = P(1)*P(14)
P(17) = P(3)**2 +S2*S2
P(18) = -P(13)*(PMX*(1.+2.*C)-S*C)
P(19) = P(3)*S
P(21) = -2.*(C + ALOG(S2) )
P(31) = PMX - S
P(32) = PMX + S*(1.+2.*C)
P(35) = 2.*S2
P(36) = P(32)*P(3) + 2.*S2*S2
P(37) = P(3)*( P(2) - P(3) )
P(10) = P(31)*P(5)
50 DO 60 I=1,37
60 PM(I,N)= P(I)
100 CONTINUE
RETURN
END
| mis/stpphi.f |
!> IMPACT
!! \author Rolf Henniger, Institute of Fluid Dynamics, ETH Zurich (henniger@ifd.mavt.ethz.ch)
!! \date Mai 2005 - Dec 2011
module cmod_GradOp
use iso_c_binding
implicit none
contains
!> \brief sets non block boundary conditions to zero(not joust corners)
!!
!! should be obsolete by now
!! \param[in] N local grid size
!! \param[in] bl lower storage offset
!! \param[in] bu upper storage offset
!! \param[in] BC_L lower boundary conditions
!! \param[in] BC_U upper boundary condtions
!! \param[in] SB start index including boundaries
!! \param[in] NB end index including boundaries
!! \param[out] phi field
subroutine OP_SetBCZero( &
N, &
bL, &
bU, &
BC_L, &
BC_U, &
SB, &
NB, &
phi ) bind ( c, name='OP_SetBCZero' )
implicit none
integer(c_int), intent(in) :: N(3)
integer(c_int), intent(in) :: bL(3)
integer(c_int), intent(in) :: bU(3)
integer(c_int), intent(in) :: BC_L(3)
integer(c_int), intent(in) :: BC_U(3)
integer(c_int), intent(in) :: SB(3)
integer(c_int), intent(in) :: NB(3)
real(c_double), intent(inout) :: phi(bL(1):(N(1)+bU(1)),bL(2):(N(2)+bU(2)),bL(3):(N(3)+bU(3)))
!--- Boundary conditions --------------------------------------------------------------------
if (BC_L(1) > 0) phi(SB(1) ,SB(2):NB(2),SB(3):NB(3)) = 0.
if (BC_U(1) > 0) phi( NB(1),SB(2):NB(2),SB(3):NB(3)) = 0.
if (BC_L(2) > 0) phi(SB(1):NB(1),SB(2) ,SB(3):NB(3)) = 0.
if (BC_U(2) > 0) phi(SB(1):NB(1), NB(2),SB(3):NB(3)) = 0.
if (BC_L(3) > 0) phi(SB(1):NB(1),SB(2):NB(2),SB(3) ) = 0.
if (BC_U(3) > 0) phi(SB(1):NB(1),SB(2):NB(2), NB(3)) = 0.
end subroutine OP_SetBCZero
!> \brief extrapolates for non-block BC outside value continously
!!
!! using Neville-Aitken scheme
subroutine OP_extrapolateBC2( &
m, &
N, &
bL, &
bU, &
dL, &
dU, &
BCL, &
BCU, &
SB, &
NB, &
xu, &
phi ) bind (c,name='OP_extrapolateBC2')
implicit none
integer(c_int), intent(in) :: m
integer(c_int), intent(in) :: N(3)
integer(c_int), intent(in) :: bL(3)
integer(c_int), intent(in) :: bU(3)
integer(c_int), intent(in) :: dL
integer(c_int), intent(in) :: dU
integer(c_int), intent(in) :: BCL
integer(c_int), intent(in) :: BCU
integer(c_int), intent(in) :: SB(3)
integer(c_int), intent(in) :: NB(3)
!real(c_double), intent(in) :: c(dL:dU,0:N(m))
real(c_double), intent(in) :: xu(bl(m):N(m)+bu(m))
real(c_double), intent(inout) :: phi(bL(1):(N(1)+bU(1)),bL(2):(N(2)+bU(2)),bL(3):(N(3)+bU(3)) )
real(c_double) :: y(1:dU)
real(c_double) :: t(1:dU)
real(c_double) :: x
integer(c_int) :: i, j, k
integer(c_int) :: ii, kk
!--------------------------------------------------------------------------------------------
!write(*,*) dl
!write(*,*) dU
if( m == 1 ) then
if( BCL > 0 ) then
i = SB(1)
DO k = SB(3), NB(3)
DO j = SB(2), NB(2)
! load data
y(1:dU) = phi(i+1:i+dU,j,k)
t(1:dU) = xu (i+1:i+dU)
x = xu(i)
! Lagrange extrapolation
do ii = 1, dU
do kk = ii-1, 1, -1
y(kk) = y(kk+1)+(y(kk+1)-y(kk)) * (x-t(ii))/(t(ii)-t(kk));
end do
end do
phi(i,j,k) = y(1);
END DO
END DO
end if
IF( BCU > 0 ) THEN
i = NB(1)
DO k = SB(3), NB(3)
DO j = SB(2), NB(2)
! load data
y(1:dL) = phi(i-dL:i-1,j,k)
t(1:dL) = xu (i-dL:i-1)
x = xu(i)
! Lagrange extrapolation
do ii = 1, dL
do kk=ii-1,1,-1
y(kk) = y(kk+1)+(y(kk+1)-y(kk)) * (x-t(ii))/(t(ii)-t(kk));
end do
end do
phi(i,j,k) = y(1);
END DO
END DO
end if
end if
!--------------------------------------------------------------------------------------------
if( m == 2 ) then
if( BCL > 0 ) then
j = SB(2)
DO k = SB(3), NB(3)
DO i = SB(1), NB(1)
! load data
y(1:dU) = phi(i,j+1:j+dU,k)
t(1:dU) = xu (j+1:j+dU)
x = xu(j)
! Lagrange extrapolation
do ii = 1, dU
do kk = ii-1, 1, -1
y(kk) = y(kk+1)+(y(kk+1)-y(kk)) * (x-t(ii))/(t(ii)-t(kk));
end do
end do
phi(i,j,k) = y(1);
END DO
END DO
end if
if( BCU > 0 ) then
j = NB(2)
DO k = SB(3), NB(3)
DO i = SB(1), NB(1)
! load data
y(1:dL) = phi(i,j-dL:j-1,k)
t(1:dL) = xu (j-dL:j-1)
x = xu(j)
! Lagrange extrapolation
do ii = 1, dL
do kk=ii-1,1,-1
y(kk) = y(kk+1)+(y(kk+1)-y(kk)) * (x-t(ii))/(t(ii)-t(kk));
end do
end do
phi(i,j,k) = y(1);
END DO
END DO
end if
end if
!--------------------------------------------------------------------------------------------
if( m == 3 ) then
if( BCL > 0 ) THEN
k = SB(3)
DO j = SB(2), NB(2)
DO i = SB(1), NB(1)
! load data
y(1:dU) = phi(i,j,k+1:k+dU)
t(1:dU) = xu (k+1:k+dU)
x = xu(k)
! Lagrange extrapolation
do ii = 1, dU
do kk = ii-1, 1, -1
y(kk) = y(kk+1)+(y(kk+1)-y(kk)) * (x-t(ii))/(t(ii)-t(kk));
end do
end do
phi(i,j,k) = y(1);
END DO
END DO
end if
if( BCU > 0 ) then
k = NB(3)
DO j = SB(2), NB(2)
DO i = SB(1), NB(1)
! load data
y(1:dL) = phi(i,j,k-dL:k-1)
t(1:dL) = xu (k-dL:k-1)
x = xu(k)
! Lagrange extrapolation
do ii = 1, dL
do kk=ii-1,1,-1
y(kk) = y(kk+1)+(y(kk+1)-y(kk)) * (x-t(ii))/(t(ii)-t(kk));
end do
end do
phi(i,j,k) = y(1);
END DO
END DO
end if
end if
!--------------------------------------------------------------------------------------------
end subroutine OP_extrapolateBC2
end module cmod_GradOp
| src/src_f/cmod_GradOp.f90 |
C
C $Id: slubkg.f,v 1.6 2008-07-27 00:17:27 haley Exp $
C
C Copyright (C) 2000
C University Corporation for Atmospheric Research
C All Rights Reserved
C
C The use of this Software is governed by a License Agreement.
C
SUBROUTINE SLUBKG (IPOC)
C
C This routine may be replaced by the user with code to add graphics to
C the background over which the titles are being scrolled. Care should
C be taken when altering the state of GKS or SPPS.
C
C IPOC says what is going on in STITLE at the time that SLUBKG is
C called, as follows:
C
C IPOC Position of call to SLUBKG
C ---- ---------------------------------------------------------------
C -1 Just before drawing titles on a "fade-in" frame.
C +1 Just after drawing titles on a "fade-in" frame.
C -2 Just before drawing titles on a "start" frame.
C +2 Just after drawing titles on a "start" frame.
C -3 Just before drawing titles on a "move" frame.
C +3 Just after drawing titles on a "move" frame.
C -4 Just before drawing titles on an "end" frame.
C +4 Just after drawing titles on an "end" frame.
C -5 Just before drawing titles on a "fade-out" frame.
C +5 Just after drawing titles on a "fade-out" frame.
C
C The default version of the routine does nothing.
C
RETURN
C
END
| ncarg2d/src/libncarg/stitle/slubkg.f |
*DECK FPPPP
SUBROUTINE FPPPP
IMPLICIT REAL*8(A-H,O-Z)
DIMENSION E(256)
COMMON /FFQ/ FQ0,FQ1,FQ2,FQ3,FQ4,FQ5
COMMON /FP4/ QA,QA1,QA2,A12I,A34I,A1234I
COMMON /FP4/ A1,A2,A3,A4,A12,A34,A1234,PQX,PQY,PQZ,
* PQXX,PQYY,PQZZ,PQXY,PQXZ,PQYZ,
*V0000,V0010,V0020,V0030,V0100,V0200,V0300,
*V0110,V0120,V0130,V0210,V0220,V0230,V0310,V0320,V0330,
*V1010,V1020,V1030,V2010,V2020,V2030,V3010,V3020,V3030,
*V1000,V2000,V3000,V1100,V2100,V3100,V1200,V2200,V3200,
*V1300,V2300,V3300,V1110,V2110,V3110,V1210,V2210,V3210,
*V1310,V2310,V3310,V1120,V2120,V3120,V1220,V2220,V3220,
*V1320,V2320,V3320,V1130,V2130,V3130,V1230,V2230,V3230,
*V1330,V2330,V3330
COMMON /FP4/C1110,C2110,C3110,C1210,C2210,C3210,
*C1320,C2320,C3320,C1130,C2130,C3130,C1230,C2230,C3230,
*C1310,C2310,C3310,C1120,C2120,C3120,C1220,C2220,C3220,
*C1330,C2330,C3330,OPXO,OPYO,OPZO,OPOX,OPOY,OPOZ,OPXOX,OPYOY,OPZOZ,
*OPXX,OPXY,OPXZ,OPYX,OPYY,OPYZ,OPZX,OPZY,OPZZ,OQXO,OQYO,OQZO,
*OQOX,OQOY,OQOZ,OQXOX,OQYOY,OQZOZ,OQXX,OQXY,OQXZ,OQYX,OQYY,OQYZ,
*OQZX,OQZY,OQZZ,S1,S2,S3,S4,S12,S34
COMMON /FP4/ E,
*GOOOO,GOOXO,GOOYO,GOOZO,GXOOO,GXOXO,GXOYO,GXOZO,GXXOO,GXXXO,GXXYO,
*GXXZO,GXYOO,GXYZO,GXZOO,GYOOO,GYOYO,GYOZO,GYYOO,GYYXO,GYYYO,
*GYYZO,GYZOO,GZOOO,GZOZO,GZZOO,GZZXO,GZZYO,GZZZO,
*VE00,VE11,VE12,VE13,VE14,VE21,VE22,VE23,VE24,VE31,VE32,VE33,VE34,
*CSSSP,CSSPP,CSPSP,CPSSP,CSPPP,CPSPP,CPPSP,CPPPP
EQUIVALENCE (GXYOO,GYXOO)
EQUIVALENCE (GXZOO,GZXOO)
EQUIVALENCE (GYZOO,GZYOO)
EQUIVALENCE (GYXXO,GXYXO,GXXYO)
EQUIVALENCE (GZXXO,GXZXO,GXXZO)
EQUIVALENCE (GZYYO,GYZYO,GYYZO)
EQUIVALENCE (GXYYO,GYXYO,GYYXO)
EQUIVALENCE (GXZZO,GZXZO,GZZXO)
EQUIVALENCE (GYZZO,GZYZO,GZZYO)
EQUIVALENCE (GXYZO,GYZXO,GZXYO,GZYXO,GYXZO,GXZYO)
EQUIVALENCE (GYYXX,GYXYX,GYXXY,GXYYX,GXYXY,GXXYY)
EQUIVALENCE (GZZXX,GZXZX,GZXXZ,GXZZX,GXZXZ,GXXZZ)
EQUIVALENCE (GZZYY,GZYZY,GZYYZ,GYZZY,GYZYZ,GYYZZ)
EQUIVALENCE (GYXXX,GXYXX,GXXYX,GXXXY)
EQUIVALENCE (GZXXX,GXZXX,GXXZX,GXXXZ)
EQUIVALENCE (GXYYY,GYXYY,GYYXY,GYYYX)
EQUIVALENCE (GZYYY,GYZYY,GYYZY,GYYYZ)
EQUIVALENCE (GXZZZ,GZXZZ,GZZXZ,GZZZX)
EQUIVALENCE (GYZZZ,GZYZZ,GZZYZ,GZZZY)
EQUIVALENCE (GXYZZ,GXZYZ,GXZZY,GYXZZ,GYZXZ,GYZZX,
* GZXYZ,GZXZY,GZYXZ,GZYZX,GZZXY,GZZYX)
EQUIVALENCE (GYZXX,GYXZX,GYXXZ,GZYXX,GZXYX,GZXXY,
* GXYZX,GXYXZ,GXZYX,GXZXY,GXXYZ,GXXZY)
EQUIVALENCE (GZXYY,GZYXY,GZYYX,GXZYY,GXYZY,GXYYZ,
* GYZXY,GYZYX,GYXZY,GYXYZ,GYYZX,GYYXZ)
C
DATA THREE, P25, H
$ / 3.D0,.25D0,0.5D0/
C
C
V0001=OQOX*GOOOO+GOOXO
V0002=OQOY*GOOOO+GOOYO
V0003=OQOZ*GOOOO+GOOZO
VE00=VE00+(V0001*E( 2)+V0002*E( 3)+V0003*E( 4))*CSSSP
TEMP=V0000*CSSSP
VE14=TEMP*E(2)
VE24=TEMP*E(3)
VE34=TEMP*E(4)
PTOQ=-A12*A34I
PTOQS=PTOQ**2
GOOXX=GXXOO*PTOQS
GOOYY=GYYOO*PTOQS
GOOZZ=GZZOO*PTOQS
GOOXY=GXYOO*PTOQS
GOOXZ=GXZOO*PTOQS
GOOYZ=GYZOO*PTOQS
V0011=OQXX*GOOOO+OQXOX*GOOXO+GOOXX
V0022=OQYY*GOOOO+OQYOY*GOOYO+GOOYY
V0033=OQZZ*GOOOO+OQZOZ*GOOZO+GOOZZ
V0012=OQXO*V0002+OQOY*GOOXO+GOOXY
V0013=OQXO*V0003+OQOZ*GOOXO+GOOXZ
V0021=OQYO*V0001+OQOX*GOOYO+GOOXY
V0023=OQYO*V0003+OQOZ*GOOYO+GOOYZ
V0031=OQZO*V0001+OQOX*GOOZO+GOOXZ
V0032=OQZO*V0002+OQOY*GOOZO+GOOYZ
VE00=VE00+(V0011*E( 6)+V0012*E( 7)+V0013*E( 8)
* +V0021*E( 10)+V0022*E( 11)+V0023*E( 12)
* +V0031*E( 14)+V0032*E( 15)+V0033*E( 16))*CSSPP
VE14=VE14+(V0010*E(6)+V0020*E(10)+V0030*E(14))*CSSPP
VE24=VE24+(V0010*E(7)+V0020*E(11)+V0030*E(15))*CSSPP
VE34=VE34+(V0010*E(8)+V0020*E(12)+V0030*E(16))*CSSPP
VE13=VE13+(V0001*E(6)+V0002*E(7)+V0003*E(8))*CSSPP
VE23=VE23+(V0001*E(10)+V0002*E(11)+V0003*E(12))*CSSPP
VE33=VE33+(V0001*E(14)+V0002*E(15)+V0003*E(16))*CSSPP
V0101=OQOX*V0100+OPOX*GOOXO+GXOXO
V0102=OQOY*V0100+OPOX*GOOYO+GXOYO
V0103=OQOZ*V0100+OPOX*GOOZO+GXOZO
V0201=OQOX*V0200+OPOY*GOOXO+GXOYO
V0202=OQOY*V0200+OPOY*GOOYO+GYOYO
V0203=OQOZ*V0200+OPOY*GOOZO+GYOZO
V0301=OQOX*V0300+OPOZ*GOOXO+GXOZO
V0302=OQOY*V0300+OPOZ*GOOYO+GYOZO
V0303=OQOZ*V0300+OPOZ*GOOZO+GZOZO
VE00=VE00+(V0101*E( 18)+V0102*E( 19)+V0103*E( 20)
* +V0201*E( 34)+V0202*E( 35)+V0203*E( 36)
* +V0301*E( 50)+V0302*E( 51)+V0303*E( 52))*CSPSP
VE14=VE14+(V0100*E(18)+V0200*E(34)+V0300*E(50))*CSPSP
VE24=VE24+(V0100*E(19)+V0200*E(35)+V0300*E(51))*CSPSP
VE34=VE34+(V0100*E(20)+V0200*E(36)+V0300*E(52))*CSPSP
VE12=VE12+(V0001*E(18)+V0002*E(19)+V0003*E(20))*CSPSP
VE22=VE22+(V0001*E(34)+V0002*E(35)+V0003*E(36))*CSPSP
VE32=VE32+(V0001*E(50)+V0002*E(51)+V0003*E(52))*CSPSP
V1001=OQOX*V1000+OPXO*GOOXO+GXOXO
V1002=OQOY*V1000+OPXO*GOOYO+GXOYO
V1003=OQOZ*V1000+OPXO*GOOZO+GXOZO
V2001=OQOX*V2000+OPYO*GOOXO+GXOYO
V2002=OQOY*V2000+OPYO*GOOYO+GYOYO
V2003=OQOZ*V2000+OPYO*GOOZO+GYOZO
V3001=OQOX*V3000+OPZO*GOOXO+GXOZO
V3002=OQOY*V3000+OPZO*GOOYO+GYOZO
V3003=OQOZ*V3000+OPZO*GOOZO+GZOZO
VE00=VE00+(V1001*E( 66)+V1002*E( 67)+V1003*E( 68)
* +V2001*E(130)+V2002*E(131)+V2003*E(132)
* +V3001*E(194)+V3002*E(195)+V3003*E(196))*CPSSP
VE14=VE14+(V1000*E(66)+V2000*E(130)+V3000*E(194))*CPSSP
VE24=VE24+(V1000*E(67)+V2000*E(131)+V3000*E(195))*CPSSP
VE34=VE34+(V1000*E(68)+V2000*E(132)+V3000*E(196))*CPSSP
VE11=VE11+(V0001*E(66)+V0002*E(67)+V0003*E(68))*CPSSP
VE21=VE21+(V0001*E(130)+V0002*E(131)+V0003*E(132))*CPSSP
VE31=VE31+(V0001*E(194)+V0002*E(195)+V0003*E(196))*CPSSP
V1101=OQOX*V1100+C1110
V1102=OQOY*V1100+C1120
V1103=OQOZ*V1100+C1130
V1201=OQOX*V1200+C1210
V1202=OQOY*V1200+C1220
V1203=OQOZ*V1200+C1230
V1301=OQOX*V1300+C1310
V1302=OQOY*V1300+C1320
V1303=OQOZ*V1300+C1330
V2101=OQOX*V2100+C2110
V2102=OQOY*V2100+C2120
V2103=OQOZ*V2100+C2130
V2201=OQOX*V2200+C2210
V2202=OQOY*V2200+C2220
V2203=OQOZ*V2200+C2230
V2301=OQOX*V2300+C2310
V2302=OQOY*V2300+C2320
V2303=OQOZ*V2300+C2330
V3101=OQOX*V3100+C3110
V3102=OQOY*V3100+C3120
V3103=OQOZ*V3100+C3130
V3201=OQOX*V3200+C3210
V3202=OQOY*V3200+C3220
V3203=OQOZ*V3200+C3230
V3301=OQOX*V3300+C3310
V3302=OQOY*V3300+C3320
V3303=OQOZ*V3300+C3330
VE00=VE00+(V1101*E( 82)+V1102*E( 83)+V1103*E( 84)
* +V1201*E( 98)+V1202*E( 99)+V1203*E(100)
* +V1301*E(114)+V1302*E(115)+V1303*E(116)
* +V2101*E(146)+V2102*E(147)+V2103*E(148)
* +V2201*E(162)+V2202*E(163)+V2203*E(164)
* +V2301*E(178)+V2302*E(179)+V2303*E(180)
* +V3101*E(210)+V3102*E(211)+V3103*E(212)
* +V3201*E(226)+V3202*E(227)+V3203*E(228)
* +V3301*E(242)+V3302*E(243)+V3303*E(244))*CPPSP
VE14=VE14+(V1100*E( 82)+V1200*E( 98)+V1300*E(114)
* +V2100*E(146)+V2200*E(162)+V2300*E(178)
* +V3100*E(210)+V3200*E(226)+V3300*E(242))*CPPSP
VE24=VE24+(V1100*E( 83)+V1200*E( 99)+V1300*E(115)
* +V2100*E(147)+V2200*E(163)+V2300*E(179)
* +V3100*E(211)+V3200*E(227)+V3300*E(243))*CPPSP
VE34=VE34+(V1100*E( 84)+V1200*E(100)+V1300*E(116)
* +V2100*E(148)+V2200*E(164)+V2300*E(180)
* +V3100*E(212)+V3200*E(228)+V3300*E(244))*CPPSP
VE12=VE12+(V1001*E( 82)+V1002*E( 83)+V1003*E( 84)
* +V2001*E(146)+V2002*E(147)+V2003*E(148)
* +V3001*E(210)+V3002*E(211)+V3003*E(212))*CPPSP
VE22=VE22+(V1001*E( 98)+V1002*E( 99)+V1003*E(100)
* +V2001*E(162)+V2002*E(163)+V2003*E(164)
* +V3001*E(226)+V3002*E(227)+V3003*E(228))*CPPSP
VE32=VE32+(V1001*E(114)+V1002*E(115)+V1003*E(116)
* +V2001*E(178)+V2002*E(179)+V2003*E(180)
* +V3001*E(242)+V3002*E(243)+V3003*E(244))*CPPSP
VE11=VE11+(V0101*E( 82)+V0102*E( 83)+V0103*E( 84)
* +V0201*E( 98)+V0202*E( 99)+V0203*E(100)
* +V0301*E(114)+V0302*E(115)+V0303*E(116))*CPPSP
VE21=VE21+(V0101*E(146)+V0102*E(147)+V0103*E(148)
* +V0201*E(162)+V0202*E(163)+V0203*E(164)
* +V0301*E(178)+V0302*E(179)+V0303*E(180))*CPPSP
VE31=VE31+(V0101*E(210)+V0102*E(211)+V0103*E(212)
* +V0201*E(226)+V0202*E(227)+V0203*E(228)
* +V0301*E(242)+V0302*E(243)+V0303*E(244))*CPPSP
GXOYZ=GXYZO*PTOQ
GXOXX=GXXXO*PTOQ
GYOYY=GYYYO*PTOQ
GZOZZ=GZZZO*PTOQ
GYOXX=GXXYO*PTOQ
GZOXX=GXXZO*PTOQ
GXOYY=GYYXO*PTOQ
GZOYY=GYYZO*PTOQ
GXOZZ=GZZXO*PTOQ
GYOZZ=GZZYO*PTOQ
C1011=OQXX*GXOOO+OQXOX*GXOXO+GXOXX
C1022=OQYY*GXOOO+OQYOY*GXOYO+GXOYY
C1033=OQZZ*GXOOO+OQZOZ*GXOZO+GXOZZ
C2011=OQXX*GYOOO+OQXOX*GXOYO+GYOXX
C2022=OQYY*GYOOO+OQYOY*GYOYO+GYOYY
C2033=OQZZ*GYOOO+OQZOZ*GYOZO+GYOZZ
C3011=OQXX*GZOOO+OQXOX*GXOZO+GZOXX
C3022=OQYY*GZOOO+OQYOY*GYOZO+GZOYY
C3033=OQZZ*GZOOO+OQZOZ*GZOZO+GZOZZ
C1012=OQXY*GXOOO+OQXO*GXOYO+OQOY*GXOXO+GYOXX
C1013=OQXZ*GXOOO+OQXO*GXOZO+OQOZ*GXOXO+GZOXX
C1021=OQYX*GXOOO+OQYO*GXOXO+OQOX*GXOYO+GYOXX
C1023=OQYZ*GXOOO+OQYO*GXOZO+OQOZ*GXOYO+GXOYZ
C1031=OQZX*GXOOO+OQZO*GXOXO+OQOX*GXOZO+GZOXX
C1032=OQZY*GXOOO+OQZO*GXOYO+OQOY*GXOZO+GXOYZ
C2012=OQXY*GYOOO+OQXO*GYOYO+OQOY*GXOYO+GXOYY
C2013=OQXZ*GYOOO+OQXO*GYOZO+OQOZ*GXOYO+GXOYZ
C2021=OQYX*GYOOO+OQYO*GXOYO+OQOX*GYOYO+GXOYY
C2023=OQYZ*GYOOO+OQYO*GYOZO+OQOZ*GYOYO+GZOYY
C2031=OQZX*GYOOO+OQZO*GXOYO+OQOX*GYOZO+GXOYZ
C2032=OQZY*GYOOO+OQZO*GYOYO+OQOY*GYOZO+GZOYY
C3012=OQXY*GZOOO+OQXO*GYOZO+OQOY*GXOZO+GXOYZ
C3013=OQXZ*GZOOO+OQXO*GZOZO+OQOZ*GXOZO+GXOZZ
C3021=OQYX*GZOOO+OQYO*GXOZO+OQOX*GYOZO+GXOYZ
C3023=OQYZ*GZOOO+OQYO*GZOZO+OQOZ*GYOZO+GYOZZ
C3031=OQZX*GZOOO+OQZO*GXOZO+OQOX*GZOZO+GXOZZ
C3032=OQZY*GZOOO+OQZO*GYOZO+OQOY*GZOZO+GYOZZ
V0111=OPOX*V0011+C1011
V0112=OPOX*V0012+C1012
V0113=OPOX*V0013+C1013
V0121=OPOX*V0021+C1021
V0122=OPOX*V0022+C1022
V0123=OPOX*V0023+C1023
V0131=OPOX*V0031+C1031
V0132=OPOX*V0032+C1032
V0133=OPOX*V0033+C1033
V0211=OPOY*V0011+C2011
V0212=OPOY*V0012+C2012
V0213=OPOY*V0013+C2013
V0221=OPOY*V0021+C2021
V0222=OPOY*V0022+C2022
V0223=OPOY*V0023+C2023
V0231=OPOY*V0031+C2031
V0232=OPOY*V0032+C2032
V0233=OPOY*V0033+C2033
V0311=OPOZ*V0011+C3011
V0312=OPOZ*V0012+C3012
V0313=OPOZ*V0013+C3013
V0321=OPOZ*V0021+C3021
V0322=OPOZ*V0022+C3022
V0323=OPOZ*V0023+C3023
V0331=OPOZ*V0031+C3031
V0332=OPOZ*V0032+C3032
V0333=OPOZ*V0033+C3033
VE00=VE00+(V0111*E( 22)+V0112*E( 23)+V0113*E( 24)
* +V0121*E( 26)+V0122*E( 27)+V0123*E( 28)
* +V0131*E( 30)+V0132*E( 31)+V0133*E( 32)
* +V0211*E( 38)+V0212*E( 39)+V0213*E( 40)
* +V0221*E( 42)+V0222*E( 43)+V0223*E( 44)
* +V0231*E( 46)+V0232*E( 47)+V0233*E( 48)
* +V0311*E( 54)+V0312*E( 55)+V0313*E( 56)
* +V0321*E( 58)+V0322*E( 59)+V0323*E( 60)
* +V0331*E( 62)+V0332*E( 63)+V0333*E( 64))*CSPPP
VE14=VE14+(V0110*E( 22)+V0120*E( 26)+V0130*E( 30)
* +V0210*E( 38)+V0220*E( 42)+V0230*E( 46)
* +V0310*E( 54)+V0320*E( 58)+V0330*E( 62))*CSPPP
VE24=VE24+(V0110*E( 23)+V0120*E( 27)+V0130*E( 31)
* +V0210*E( 39)+V0220*E( 43)+V0230*E( 47)
* +V0310*E( 55)+V0320*E( 59)+V0330*E( 63))*CSPPP
VE34=VE34+(V0110*E( 24)+V0120*E( 28)+V0130*E( 32)
* +V0210*E( 40)+V0220*E( 44)+V0230*E( 48)
* +V0310*E( 56)+V0320*E( 60)+V0330*E( 64))*CSPPP
VE13=VE13+(V0101*E( 22)+V0102*E( 23)+V0103*E( 24)
* +V0201*E( 38)+V0202*E( 39)+V0203*E( 40)
* +V0301*E( 54)+V0302*E( 55)+V0303*E( 56))*CSPPP
VE23=VE23+(V0101*E( 26)+V0102*E( 27)+V0103*E( 28)
* +V0201*E( 42)+V0202*E( 43)+V0203*E( 44)
* +V0301*E( 58)+V0302*E( 59)+V0303*E( 60))*CSPPP
VE33=VE33+(V0101*E( 30)+V0102*E( 31)+V0103*E( 32)
* +V0201*E( 46)+V0202*E( 47)+V0203*E( 48)
* +V0301*E( 62)+V0302*E( 63)+V0303*E( 64))*CSPPP
VE12=VE12+(V0011*E( 22)+V0012*E( 23)+V0013*E( 24)
* +V0021*E( 26)+V0022*E( 27)+V0023*E( 28)
* +V0031*E( 30)+V0032*E( 31)+V0033*E( 32))*CSPPP
VE22=VE22+(V0011*E( 38)+V0012*E( 39)+V0013*E( 40)
* +V0021*E( 42)+V0022*E( 43)+V0023*E( 44)
* +V0031*E( 46)+V0032*E( 47)+V0033*E( 48))*CSPPP
VE32=VE32+(V0011*E( 54)+V0012*E( 55)+V0013*E( 56)
* +V0021*E( 58)+V0022*E( 59)+V0023*E( 60)
* +V0031*E( 62)+V0032*E( 63)+V0033*E( 64))*CSPPP
V1011=OPXO*V0011+C1011
V1012=OPXO*V0012+C1012
V1013=OPXO*V0013+C1013
V1021=OPXO*V0021+C1021
V1022=OPXO*V0022+C1022
V1023=OPXO*V0023+C1023
V1031=OPXO*V0031+C1031
V1032=OPXO*V0032+C1032
V1033=OPXO*V0033+C1033
V2011=OPYO*V0011+C2011
V2012=OPYO*V0012+C2012
V2013=OPYO*V0013+C2013
V2021=OPYO*V0021+C2021
V2022=OPYO*V0022+C2022
V2023=OPYO*V0023+C2023
V2031=OPYO*V0031+C2031
V2032=OPYO*V0032+C2032
V2033=OPYO*V0033+C2033
V3011=OPZO*V0011+C3011
V3012=OPZO*V0012+C3012
V3013=OPZO*V0013+C3013
V3021=OPZO*V0021+C3021
V3022=OPZO*V0022+C3022
V3023=OPZO*V0023+C3023
V3031=OPZO*V0031+C3031
V3032=OPZO*V0032+C3032
V3033=OPZO*V0033+C3033
VE00=VE00+(V1011*E( 70)+V1012*E( 71)+V1013*E( 72)
* +V1021*E( 74)+V1022*E( 75)+V1023*E( 76)
* +V1031*E( 78)+V1032*E( 79)+V1033*E( 80)
* +V2011*E(134)+V2012*E(135)+V2013*E(136)
* +V2021*E(138)+V2022*E(139)+V2023*E(140)
* +V2031*E(142)+V2032*E(143)+V2033*E(144)
* +V3011*E(198)+V3012*E(199)+V3013*E(200)
* +V3021*E(202)+V3022*E(203)+V3023*E(204)
* +V3031*E(206)+V3032*E(207)+V3033*E(208))*CPSPP
VE14=VE14+(V1010*E( 70)+V1020*E( 74)+V1030*E( 78)
* +V2010*E(134)+V2020*E(138)+V2030*E(142)
* +V3010*E(198)+V3020*E(202)+V3030*E(206))*CPSPP
VE24=VE24+(V1010*E( 71)+V1020*E( 75)+V1030*E( 79)
* +V2010*E(135)+V2020*E(139)+V2030*E(143)
* +V3010*E(199)+V3020*E(203)+V3030*E(207))*CPSPP
VE34=VE34+(V1010*E( 72)+V1020*E( 76)+V1030*E( 80)
* +V2010*E(136)+V2020*E(140)+V2030*E(144)
* +V3010*E(200)+V3020*E(204)+V3030*E(208))*CPSPP
VE13=VE13+(V1001*E( 70)+V1002*E( 71)+V1003*E( 72)
* +V2001*E(134)+V2002*E(135)+V2003*E(136)
* +V3001*E(198)+V3002*E(199)+V3003*E(200))*CPSPP
VE23=VE23+(V1001*E( 74)+V1002*E( 75)+V1003*E( 76)
* +V2001*E(138)+V2002*E(139)+V2003*E(140)
* +V3001*E(202)+V3002*E(203)+V3003*E(204))*CPSPP
VE33=VE33+(V1001*E( 78)+V1002*E( 79)+V1003*E( 80)
* +V2001*E(142)+V2002*E(143)+V2003*E(144)
* +V3001*E(206)+V3002*E(207)+V3003*E(208))*CPSPP
VE11=VE11+(V0011*E( 70)+V0012*E( 71)+V0013*E( 72)
* +V0021*E( 74)+V0022*E( 75)+V0023*E( 76)
* +V0031*E( 78)+V0032*E( 79)+V0033*E( 80))*CPSPP
VE21=VE21+(V0011*E(134)+V0012*E(135)+V0013*E(136)
* +V0021*E(138)+V0022*E(139)+V0023*E(140)
* +V0031*E(142)+V0032*E(143)+V0033*E(144))*CPSPP
VE31=VE31+(V0011*E(198)+V0012*E(199)+V0013*E(200)
* +V0021*E(202)+V0022*E(203)+V0023*E(204)
* +V0031*E(206)+V0032*E(207)+V0033*E(208))*CPSPP
QFQ4=(QA1*QA2)**2*FQ4
TEMP=A1234I**2
HFQ3=H*QA*FQ3*TEMP
TFQ3=THREE*HFQ3
SFQ3=TFQ3+TFQ3
P25FQ2=P25*FQ2*TEMP
P75FQ2=THREE*P25FQ2
TEMP=PQXX*QFQ4
GXXXX=PQXX*(TEMP-SFQ3)+P75FQ2
GYXXX=PQXY*(TEMP-TFQ3)
GZXXX=PQXZ*(TEMP-TFQ3)
GZYXX=PQYZ*(TEMP-HFQ3)
GYYXX=PQYY*(TEMP-HFQ3)-PQXX*HFQ3+P25FQ2
TEMP=PQYY*QFQ4
GYYYY=PQYY*(TEMP-SFQ3)+P75FQ2
GXYYY=PQXY*(TEMP-TFQ3)
GZXYY=PQXZ*(TEMP-HFQ3)
GZYYY=PQYZ*(TEMP-TFQ3)
GZZYY=PQZZ*(TEMP-HFQ3)-PQYY*HFQ3+P25FQ2
TEMP=PQZZ*QFQ4
GZZZZ=PQZZ*(TEMP-SFQ3)+P75FQ2
GXYZZ=PQXY*(TEMP-HFQ3)
GXZZZ=PQXZ*(TEMP-TFQ3)
GYZZZ=PQYZ*(TEMP-TFQ3)
GXXZZ=PQXX*(TEMP-HFQ3)-PQZZ*HFQ3+P25FQ2
C 1111
VP4=(OPXX*V0011+OPXOX*C1011+OQXX*GXXOO
1+OQXOX*GXXXO+GXXXX)*E( 86)
C 1112
VP4=(OPXX*V0012+OPXOX*C1012+OQXY*GXXOO
1+OQXO*GXXYO+OQOY*GXXXO+GXXXY)*E( 87)+VP4
C 1113
VP4=(OPXX*V0013+OPXOX*C1013+OQXZ*GXXOO
1+OQXO*GXXZO+OQOZ*GXXXO+GXXXZ)*E( 88)+VP4
C 1121
VP4=(OPXX*V0021+OPXOX*C1021+OQYX*GXXOO
1+OQYO*GXXXO+OQOX*GXXYO+GXXYX)*E( 90)+VP4
C 1122
VP4=(OPXX*V0022+OPXOX*C1022+OQYY*GXXOO
1+OQYOY*GXXYO+GXXYY)*E( 91)+VP4
C 1123
VP4=(OPXX*V0023+OPXOX*C1023+OQYZ*GXXOO
1+OQYO*GXXZO+OQOZ*GXXYO+GXXYZ)*E( 92)+VP4
C 1131
VP4=(OPXX*V0031+OPXOX*C1031+OQZX*GXXOO
1+OQZO*GXXXO+OQOX*GXXZO+GXXZX)*E( 94)+VP4
C 1132
VP4=(OPXX*V0032+OPXOX*C1032+OQZY*GXXOO
1+OQZO*GXXYO+OQOY*GXXZO+GXXZY)*E( 95)+VP4
C 1133
VP4=(OPXX*V0033+OPXOX*C1033+OQZZ*GXXOO
1+OQZOZ*GXXZO+GXXZZ)*E( 96)+VP4
C 1211
VP4=(OPXY*V0011+OPXO*C2011+OPOY*C1011+OQXX*GXYOO
1+OQXOX*GXYXO+GXYXX)*E(102)+VP4
C 1212
VP4=(OPXY*V0012+OPXO*C2012+OPOY*C1012+OQXY*GXYOO
1+OQXO*GXYYO+OQOY*GXYXO+GXYXY)*E(103)+VP4
C 1213
VP4=(OPXY*V0013+OPXO*C2013+OPOY*C1013+OQXZ*GXYOO
1+OQXO*GXYZO+OQOZ*GXYXO+GXYXZ)*E(104)+VP4
C 1221
VP4=(OPXY*V0021+OPXO*C2021+OPOY*C1021+OQYX*GXYOO
1+OQYO*GXYXO+OQOX*GXYYO+GXYYX)*E(106)+VP4
C 1222
VP4=(OPXY*V0022+OPXO*C2022+OPOY*C1022+OQYY*GXYOO
1+OQYOY*GXYYO+GXYYY)*E(107)+VP4
C 1223
VP4=(OPXY*V0023+OPXO*C2023+OPOY*C1023+OQYZ*GXYOO
1+OQYO*GXYZO+OQOZ*GXYYO+GXYYZ)*E(108)+VP4
C 1231
VP4=(OPXY*V0031+OPXO*C2031+OPOY*C1031+OQZX*GXYOO
1+OQZO*GXYXO+OQOX*GXYZO+GXYZX)*E(110)+VP4
C 1232
VP4=(OPXY*V0032+OPXO*C2032+OPOY*C1032+OQZY*GXYOO
1+OQZO*GXYYO+OQOY*GXYZO+GXYZY)*E(111)+VP4
C 1233
VP4=(OPXY*V0033+OPXO*C2033+OPOY*C1033+OQZZ*GXYOO
1+OQZOZ*GXYZO+GXYZZ)*E(112)+VP4
C 1311
VP4=(OPXZ*V0011+OPXO*C3011+OPOZ*C1011+OQXX*GXZOO
1+OQXOX*GXZXO+GXZXX)*E(118)+VP4
C 1312
VP4=(OPXZ*V0012+OPXO*C3012+OPOZ*C1012+OQXY*GXZOO
1+OQXO*GXZYO+OQOY*GXZXO+GXZXY)*E(119)+VP4
C 1313
VP4=(OPXZ*V0013+OPXO*C3013+OPOZ*C1013+OQXZ*GXZOO
1+OQXO*GXZZO+OQOZ*GXZXO+GXZXZ)*E(120)+VP4
C 1321
VP4=(OPXZ*V0021+OPXO*C3021+OPOZ*C1021+OQYX*GXZOO
1+OQYO*GXZXO+OQOX*GXZYO+GXZYX)*E(122)+VP4
C 1322
VP4=(OPXZ*V0022+OPXO*C3022+OPOZ*C1022+OQYY*GXZOO
1+OQYOY*GXZYO+GXZYY)*E(123)+VP4
C 1323
VP4=(OPXZ*V0023+OPXO*C3023+OPOZ*C1023+OQYZ*GXZOO
1+OQYO*GXZZO+OQOZ*GXZYO+GXZYZ)*E(124)+VP4
C 1331
VP4=(OPXZ*V0031+OPXO*C3031+OPOZ*C1031+OQZX*GXZOO
1+OQZO*GXZXO+OQOX*GXZZO+GXZZX)*E(126)+VP4
C 1332
VP4=(OPXZ*V0032+OPXO*C3032+OPOZ*C1032+OQZY*GXZOO
1+OQZO*GXZYO+OQOY*GXZZO+GXZZY)*E(127)+VP4
C 1333
VP4=(OPXZ*V0033+OPXO*C3033+OPOZ*C1033+OQZZ*GXZOO
1+OQZOZ*GXZZO+GXZZZ)*E(128)+VP4
C 2111
VP4=(OPYX*V0011+OPYO*C1011+OPOX*C2011+OQXX*GYXOO
1+OQXOX*GYXXO+GYXXX)*E(150)+VP4
C 2112
VP4=(OPYX*V0012+OPYO*C1012+OPOX*C2012+OQXY*GYXOO
1+OQXO*GYXYO+OQOY*GYXXO+GYXXY)*E(151)+VP4
C 2113
VP4=(OPYX*V0013+OPYO*C1013+OPOX*C2013+OQXZ*GYXOO
1+OQXO*GYXZO+OQOZ*GYXXO+GYXXZ)*E(152)+VP4
C 2121
VP4=(OPYX*V0021+OPYO*C1021+OPOX*C2021+OQYX*GYXOO
1+OQYO*GYXXO+OQOX*GYXYO+GYXYX)*E(154)+VP4
C 2122
VP4=(OPYX*V0022+OPYO*C1022+OPOX*C2022+OQYY*GYXOO
1+OQYOY*GYXYO+GYXYY)*E(155)+VP4
C 2123
VP4=(OPYX*V0023+OPYO*C1023+OPOX*C2023+OQYZ*GYXOO
1+OQYO*GYXZO+OQOZ*GYXYO+GYXYZ)*E(156)+VP4
C 2131
VP4=(OPYX*V0031+OPYO*C1031+OPOX*C2031+OQZX*GYXOO
1+OQZO*GYXXO+OQOX*GYXZO+GYXZX)*E(158)+VP4
C 2132
VP4=(OPYX*V0032+OPYO*C1032+OPOX*C2032+OQZY*GYXOO
1+OQZO*GYXYO+OQOY*GYXZO+GYXZY)*E(159)+VP4
C 2133
VP4=(OPYX*V0033+OPYO*C1033+OPOX*C2033+OQZZ*GYXOO
1+OQZOZ*GYXZO+GYXZZ)*E(160)+VP4
C 2211
VP4=(OPYY*V0011+OPYOY*C2011+OQXX*GYYOO
1+OQXOX*GYYXO+GYYXX)*E(166)+VP4
C 2212
VP4=(OPYY*V0012+OPYOY*C2012+OQXY*GYYOO
1+OQXO*GYYYO+OQOY*GYYXO+GYYXY)*E(167)+VP4
C 2213
VP4=(OPYY*V0013+OPYOY*C2013+OQXZ*GYYOO
1+OQXO*GYYZO+OQOZ*GYYXO+GYYXZ)*E(168)+VP4
C 2221
VP4=(OPYY*V0021+OPYOY*C2021+OQYX*GYYOO
1+OQYO*GYYXO+OQOX*GYYYO+GYYYX)*E(170)+VP4
C 2222
VP4=(OPYY*V0022+OPYOY*C2022+OQYY*GYYOO
1+OQYOY*GYYYO+GYYYY)*E(171)+VP4
C 2223
VP4=(OPYY*V0023+OPYOY*C2023+OQYZ*GYYOO
1+OQYO*GYYZO+OQOZ*GYYYO+GYYYZ)*E(172)+VP4
C 2231
VP4=(OPYY*V0031+OPYOY*C2031+OQZX*GYYOO
1+OQZO*GYYXO+OQOX*GYYZO+GYYZX)*E(174)+VP4
C 2232
VP4=(OPYY*V0032+OPYOY*C2032+OQZY*GYYOO
1+OQZO*GYYYO+OQOY*GYYZO+GYYZY)*E(175)+VP4
C 2233
VP4=(OPYY*V0033+OPYOY*C2033+OQZZ*GYYOO
1+OQZOZ*GYYZO+GYYZZ)*E(176)+VP4
C 2311
VP4=(OPYZ*V0011+OPYO*C3011+OPOZ*C2011+OQXX*GYZOO
1+OQXOX*GYZXO+GYZXX)*E(182)+VP4
C 2312
VP4=(OPYZ*V0012+OPYO*C3012+OPOZ*C2012+OQXY*GYZOO
1+OQXO*GYZYO+OQOY*GYZXO+GYZXY)*E(183)+VP4
C 2313
VP4=(OPYZ*V0013+OPYO*C3013+OPOZ*C2013+OQXZ*GYZOO
1+OQXO*GYZZO+OQOZ*GYZXO+GYZXZ)*E(184)+VP4
C 2321
VP4=(OPYZ*V0021+OPYO*C3021+OPOZ*C2021+OQYX*GYZOO
1+OQYO*GYZXO+OQOX*GYZYO+GYZYX)*E(186)+VP4
C 2322
VP4=(OPYZ*V0022+OPYO*C3022+OPOZ*C2022+OQYY*GYZOO
1+OQYOY*GYZYO+GYZYY)*E(187)+VP4
C 2323
VP4=(OPYZ*V0023+OPYO*C3023+OPOZ*C2023+OQYZ*GYZOO
1+OQYO*GYZZO+OQOZ*GYZYO+GYZYZ)*E(188)+VP4
C 2331
VP4=(OPYZ*V0031+OPYO*C3031+OPOZ*C2031+OQZX*GYZOO
1+OQZO*GYZXO+OQOX*GYZZO+GYZZX)*E(190)+VP4
C 2332
VP4=(OPYZ*V0032+OPYO*C3032+OPOZ*C2032+OQZY*GYZOO
1+OQZO*GYZYO+OQOY*GYZZO+GYZZY)*E(191)+VP4
C 2333
VP4=(OPYZ*V0033+OPYO*C3033+OPOZ*C2033+OQZZ*GYZOO
1+OQZOZ*GYZZO+GYZZZ)*E(192)+VP4
C 3111
VP4=(OPZX*V0011+OPZO*C1011+OPOX*C3011+OQXX*GZXOO
1+OQXOX*GZXXO+GZXXX)*E(214)+VP4
C 3112
VP4=(OPZX*V0012+OPZO*C1012+OPOX*C3012+OQXY*GZXOO
1+OQXO*GZXYO+OQOY*GZXXO+GZXXY)*E(215)+VP4
C 3113
VP4=(OPZX*V0013+OPZO*C1013+OPOX*C3013+OQXZ*GZXOO
1+OQXO*GZXZO+OQOZ*GZXXO+GZXXZ)*E(216)+VP4
C 3121
VP4=(OPZX*V0021+OPZO*C1021+OPOX*C3021+OQYX*GZXOO
1+OQYO*GZXXO+OQOX*GZXYO+GZXYX)*E(218)+VP4
C 3122
VP4=(OPZX*V0022+OPZO*C1022+OPOX*C3022+OQYY*GZXOO
1+OQYOY*GZXYO+GZXYY)*E(219)+VP4
C 3123
VP4=(OPZX*V0023+OPZO*C1023+OPOX*C3023+OQYZ*GZXOO
1+OQYO*GZXZO+OQOZ*GZXYO+GZXYZ)*E(220)+VP4
C 3131
VP4=(OPZX*V0031+OPZO*C1031+OPOX*C3031+OQZX*GZXOO
1+OQZO*GZXXO+OQOX*GZXZO+GZXZX)*E(222)+VP4
C 3132
VP4=(OPZX*V0032+OPZO*C1032+OPOX*C3032+OQZY*GZXOO
1+OQZO*GZXYO+OQOY*GZXZO+GZXZY)*E(223)+VP4
C 3133
VP4=(OPZX*V0033+OPZO*C1033+OPOX*C3033+OQZZ*GZXOO
1+OQZOZ*GZXZO+GZXZZ)*E(224)+VP4
C 3211
VP4=(OPZY*V0011+OPZO*C2011+OPOY*C3011+OQXX*GZYOO
1+OQXOX*GZYXO+GZYXX)*E(230)+VP4
C 3212
VP4=(OPZY*V0012+OPZO*C2012+OPOY*C3012+OQXY*GZYOO
1+OQXO*GZYYO+OQOY*GZYXO+GZYXY)*E(231)+VP4
C 3213
VP4=(OPZY*V0013+OPZO*C2013+OPOY*C3013+OQXZ*GZYOO
1+OQXO*GZYZO+OQOZ*GZYXO+GZYXZ)*E(232)+VP4
C 3221
VP4=(OPZY*V0021+OPZO*C2021+OPOY*C3021+OQYX*GZYOO
1+OQYO*GZYXO+OQOX*GZYYO+GZYYX)*E(234)+VP4
C 3222
VP4=(OPZY*V0022+OPZO*C2022+OPOY*C3022+OQYY*GZYOO
1+OQYOY*GZYYO+GZYYY)*E(235)+VP4
C 3223
VP4=(OPZY*V0023+OPZO*C2023+OPOY*C3023+OQYZ*GZYOO
1+OQYO*GZYZO+OQOZ*GZYYO+GZYYZ)*E(236)+VP4
C 3231
VP4=(OPZY*V0031+OPZO*C2031+OPOY*C3031+OQZX*GZYOO
1+OQZO*GZYXO+OQOX*GZYZO+GZYZX)*E(238)+VP4
C 3232
VP4=(OPZY*V0032+OPZO*C2032+OPOY*C3032+OQZY*GZYOO
1+OQZO*GZYYO+OQOY*GZYZO+GZYZY)*E(239)+VP4
C 3233
VP4=(OPZY*V0033+OPZO*C2033+OPOY*C3033+OQZZ*GZYOO
1+OQZOZ*GZYZO+GZYZZ)*E(240)+VP4
C 3311
VP4=(OPZZ*V0011+OPZOZ*C3011+OQXX*GZZOO
1+OQXOX*GZZXO+GZZXX)*E(246)+VP4
C 3312
VP4=(OPZZ*V0012+OPZOZ*C3012+OQXY*GZZOO
1+OQXO*GZZYO+OQOY*GZZXO+GZZXY)*E(247)+VP4
C 3313
VP4=(OPZZ*V0013+OPZOZ*C3013+OQXZ*GZZOO
1+OQXO*GZZZO+OQOZ*GZZXO+GZZXZ)*E(248)+VP4
C 3321
VP4=(OPZZ*V0021+OPZOZ*C3021+OQYX*GZZOO
1+OQYO*GZZXO+OQOX*GZZYO+GZZYX)*E(250)+VP4
C 3322
VP4=(OPZZ*V0022+OPZOZ*C3022+OQYY*GZZOO
1+OQYOY*GZZYO+GZZYY)*E(251)+VP4
C 3323
VP4=(OPZZ*V0023+OPZOZ*C3023+OQYZ*GZZOO
1+OQYO*GZZZO+OQOZ*GZZYO+GZZYZ)*E(252)+VP4
C 3331
VP4=(OPZZ*V0031+OPZOZ*C3031+OQZX*GZZOO
1+OQZO*GZZXO+OQOX*GZZZO+GZZZX)*E(254)+VP4
C 3332
VP4=(OPZZ*V0032+OPZOZ*C3032+OQZY*GZZOO
1+OQZO*GZZYO+OQOY*GZZZO+GZZZY)*E(255)+VP4
C 3333
VP4=(OPZZ*V0033+OPZOZ*C3033+OQZZ*GZZOO
1+OQZOZ*GZZZO+GZZZZ)*E(256)+VP4
VPPPP=VP4*CPPPP
VE00=VE00+VPPPP
VE14=VE14+(V1110*E( 86)+V1120*E( 90)+V1130*E( 94)
* +V1210*E(102)+V1220*E(106)+V1230*E(110)
* +V1310*E(118)+V1320*E(122)+V1330*E(126)
* +V2110*E(150)+V2120*E(154)+V2130*E(158)
* +V2210*E(166)+V2220*E(170)+V2230*E(174)
* +V2310*E(182)+V2320*E(186)+V2330*E(190)
* +V3110*E(214)+V3120*E(218)+V3130*E(222)
* +V3210*E(230)+V3220*E(234)+V3230*E(238)
* +V3310*E(246)+V3320*E(250)+V3330*E(254))*CPPPP
VE24=VE24+(V1110*E( 87)+V1120*E( 91)+V1130*E( 95)
* +V1210*E(103)+V1220*E(107)+V1230*E(111)
* +V1310*E(119)+V1320*E(123)+V1330*E(127)
* +V2110*E(151)+V2120*E(155)+V2130*E(159)
* +V2210*E(167)+V2220*E(171)+V2230*E(175)
* +V2310*E(183)+V2320*E(187)+V2330*E(191)
* +V3110*E(215)+V3120*E(219)+V3130*E(223)
* +V3210*E(231)+V3220*E(235)+V3230*E(239)
* +V3310*E(247)+V3320*E(251)+V3330*E(255))*CPPPP
VE34=VE34+(V1110*E( 88)+V1120*E( 92)+V1130*E( 96)
* +V1210*E(104)+V1220*E(108)+V1230*E(112)
* +V1310*E(120)+V1320*E(124)+V1330*E(128)
* +V2110*E(152)+V2120*E(156)+V2130*E(160)
* +V2210*E(168)+V2220*E(172)+V2230*E(176)
* +V2310*E(184)+V2320*E(188)+V2330*E(192)
* +V3110*E(216)+V3120*E(220)+V3130*E(224)
* +V3210*E(232)+V3220*E(236)+V3230*E(240)
* +V3310*E(248)+V3320*E(252)+V3330*E(256))*CPPPP
VE13=VE13+(V1101*E( 86)+V1102*E( 87)+V1103*E( 88)
* +V1201*E(102)+V1202*E(103)+V1203*E(104)
* +V1301*E(118)+V1302*E(119)+V1303*E(120)
* +V2101*E(150)+V2102*E(151)+V2103*E(152)
* +V2201*E(166)+V2202*E(167)+V2203*E(168)
* +V2301*E(182)+V2302*E(183)+V2303*E(184)
* +V3101*E(214)+V3102*E(215)+V3103*E(216)
* +V3201*E(230)+V3202*E(231)+V3203*E(232)
* +V3301*E(246)+V3302*E(247)+V3303*E(248))*CPPPP
VE23=VE23+(V1101*E( 90)+V1102*E( 91)+V1103*E( 92)
* +V1201*E(106)+V1202*E(107)+V1203*E(108)
* +V1301*E(122)+V1302*E(123)+V1303*E(124)
* +V2101*E(154)+V2102*E(155)+V2103*E(156)
* +V2201*E(170)+V2202*E(171)+V2203*E(172)
* +V2301*E(186)+V2302*E(187)+V2303*E(188)
* +V3101*E(218)+V3102*E(219)+V3103*E(220)
* +V3201*E(234)+V3202*E(235)+V3203*E(236)
* +V3301*E(250)+V3302*E(251)+V3303*E(252))*CPPPP
VE33=VE33+(V1101*E( 94)+V1102*E( 95)+V1103*E( 96)
* +V1201*E(110)+V1202*E(111)+V1203*E(112)
* +V1301*E(126)+V1302*E(127)+V1303*E(128)
* +V2101*E(158)+V2102*E(159)+V2103*E(160)
* +V2201*E(174)+V2202*E(175)+V2203*E(176)
* +V2301*E(190)+V2302*E(191)+V2303*E(192)
* +V3101*E(222)+V3102*E(223)+V3103*E(224)
* +V3201*E(238)+V3202*E(239)+V3203*E(240)
* +V3301*E(254)+V3302*E(255)+V3303*E(256))*CPPPP
VE12=VE12+(V1011*E( 86)+V1012*E( 87)+V1013*E( 88)
* +V1021*E( 90)+V1022*E( 91)+V1023*E( 92)
* +V1031*E( 94)+V1032*E( 95)+V1033*E( 96)
* +V2011*E(150)+V2012*E(151)+V2013*E(152)
* +V2021*E(154)+V2022*E(155)+V2023*E(156)
* +V2031*E(158)+V2032*E(159)+V2033*E(160)
* +V3011*E(214)+V3012*E(215)+V3013*E(216)
* +V3021*E(218)+V3022*E(219)+V3023*E(220)
* +V3031*E(222)+V3032*E(223)+V3033*E(224))*CPPPP
VE22=VE22+(V1011*E(102)+V1012*E(103)+V1013*E(104)
* +V1021*E(106)+V1022*E(107)+V1023*E(108)
* +V1031*E(110)+V1032*E(111)+V1033*E(112)
* +V2011*E(166)+V2012*E(167)+V2013*E(168)
* +V2021*E(170)+V2022*E(171)+V2023*E(172)
* +V2031*E(174)+V2032*E(175)+V2033*E(176)
* +V3011*E(230)+V3012*E(231)+V3013*E(232)
* +V3021*E(234)+V3022*E(235)+V3023*E(236)
* +V3031*E(238)+V3032*E(239)+V3033*E(240))*CPPPP
VE32=VE32+(V1011*E(118)+V1012*E(119)+V1013*E(120)
* +V1021*E(122)+V1022*E(123)+V1023*E(124)
* +V1031*E(126)+V1032*E(127)+V1033*E(128)
* +V2011*E(182)+V2012*E(183)+V2013*E(184)
* +V2021*E(186)+V2022*E(187)+V2023*E(188)
* +V2031*E(190)+V2032*E(191)+V2033*E(192)
* +V3011*E(246)+V3012*E(247)+V3013*E(248)
* +V3021*E(250)+V3022*E(251)+V3023*E(252)
* +V3031*E(254)+V3032*E(255)+V3033*E(256))*CPPPP
VE11=VE11+(V0111*E( 86)+V0112*E( 87)+V0113*E( 88)
* +V0121*E( 90)+V0122*E( 91)+V0123*E( 92)
* +V0131*E( 94)+V0132*E( 95)+V0133*E( 96)
* +V0211*E(102)+V0212*E(103)+V0213*E(104)
* +V0221*E(106)+V0222*E(107)+V0223*E(108)
* +V0231*E(110)+V0232*E(111)+V0233*E(112)
* +V0311*E(118)+V0312*E(119)+V0313*E(120)
* +V0321*E(122)+V0322*E(123)+V0323*E(124)
* +V0331*E(126)+V0332*E(127)+V0333*E(128))*CPPPP
VE21=VE21+(V0111*E(150)+V0112*E(151)+V0113*E(152)
* +V0121*E(154)+V0122*E(155)+V0123*E(156)
* +V0131*E(158)+V0132*E(159)+V0133*E(160)
* +V0211*E(166)+V0212*E(167)+V0213*E(168)
* +V0221*E(170)+V0222*E(171)+V0223*E(172)
* +V0231*E(174)+V0232*E(175)+V0233*E(176)
* +V0311*E(182)+V0312*E(183)+V0313*E(184)
* +V0321*E(186)+V0322*E(187)+V0323*E(188)
* +V0331*E(190)+V0332*E(191)+V0333*E(192))*CPPPP
VE31=VE31+(V0111*E(214)+V0112*E(215)+V0113*E(216)
* +V0121*E(218)+V0122*E(219)+V0123*E(220)
* +V0131*E(222)+V0132*E(223)+V0133*E(224)
* +V0211*E(230)+V0212*E(231)+V0213*E(232)
* +V0221*E(234)+V0222*E(235)+V0223*E(236)
* +V0231*E(238)+V0232*E(239)+V0233*E(240)
* +V0311*E(246)+V0312*E(247)+V0313*E(248)
* +V0321*E(250)+V0322*E(251)+V0323*E(252)
* +V0331*E(254)+V0332*E(255)+V0333*E(256))*CPPPP
RETURN
END
| packages/PIPS/validation/ArrayResizing/fpppp/fpppp.f |
program test6
#if (_DP==0)
use iso_fortran_env,only:int32,int64,wp=>real32
#else
use iso_fortran_env,only:int32,int64,wp=>real64
#endif
use modsparse
implicit none
integer(kind=int32)::nrow
integer(kind=int32)::row
integer(kind=int32)::col
integer(kind=int32)::iunit, istat
integer(kind=int32)::i,j
integer(kind=int32),allocatable::iarray(:,:)
integer(kind=int32),allocatable::perm(:)
real(kind=wp)::val
real(kind=wp),allocatable::x(:),y(:)
logical::lup=.false.
type(coosparse)::coo
type(crssparse)::crs
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!COO UPPER
open(newunit=iunit,file='matrixija.ascii',status='old',action='read')
!open(newunit=iunit,file='matkm.dat',status='old',action='read')
read(iunit,*) nrow
coo=coosparse(nrow,lupper=.true.)
do
read(iunit,*,iostat=istat) row,col,val
if(istat.ne.0)exit
call coo%add(row,col,val)
! if(row.ne.col)call coo%add(col,row,val)
end do
close(iunit)
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!CSR UPPER
crs=coo
call crs%printstats()
call crs%printsquare()
#if (_METIS==1)
call crs%setpermutation(crs%getordering(bglvl=0))
#else
call crs%setpermutation((/(i,i=1,crs%getdim(1))/))
#endif
call crs%printstats()
!!!!!!!!!!!!!!!!
write(*,*)'Matrix'
allocate(iarray(crs%getdim(1),crs%getdim(2)))
iarray=0
do i=1,crs%getdim(1)
do j=1,crs%getdim(2)
val=crs%get(i,j)
if(val.ne.0.)iarray(i,j)=1
enddo
enddo
do i=1,crs%getdim(1)
write(*,'(10000(i2))')iarray(i,:)
enddo
write(*,*)'Permuted matrix'
#if (_METIS==1)
perm=crs%getordering(bglvl=0)
#else
perm=(/(i,i=1,crs%getdim(1))/)
#endif
iarray=0
do i=1,crs%getdim(1)
do j=1,crs%getdim(2)
val=crs%get(perm(i),perm(j))
if(val.ne.0.)iarray(i,j)=1
enddo
enddo
do i=1,crs%getdim(1)
write(*,'(10000(i2))')iarray(i,:)
enddo
!!!!!!
call crs%spainv()
call crs%printsquare()
!!!!!!
crs=coo
call crs%sort()
#if (_METIS==1)
perm=crs%getordering(bglvl=0)
#else
perm=(/(i,i=1,crs%getdim(1))/)
#endif
call crs%setpermutation(perm)
call crs%printstats()
print*,'ord ',perm
allocate(x(crs%getdim(1)),y(crs%getdim(1)))
x=1.;y=1.
call crs%solve(x,y)
print*,'x ',x
print*,'y ',y
end program
| examples/test6.f90 |
subroutine WATER (TIME,BareEvapFlux)
use simsphere_mod, only: wgg, w2g, rhow, le, frveg, rnet, xleg, xlef, evap, &
delta, f, fsub, wmax, eq
implicit none
real, parameter :: CONST1 = 1
real, parameter :: CONST2 = 0.5
real, parameter :: D1P = 0.1
real, parameter :: D_INT = 0.5
real, parameter :: D2P = 0.5
real, parameter :: OMG = 24
real :: TIME, BareEvapFlux
real :: PER, C11, C22, C33, C44, EVAX, EVAS, EVAI
real :: WW1, WW2, WW3
real :: WIN
! ** WATER is based on the technique of Deardroff (1978). It uses the
! ** evaporative flux value obtained in FLUX and updates two internal
! ** variables WGG and W2G, which represent the soil moisture content
! ** of the soil close to the surface and in the first 50 cm of soil,
! ** respectively. The empirical constants can be found in the article.
! ** 1988 modifications: Substrate layer assigned moisture availability
! ** which is called FSUB (W2G/WMAX). Intermediate layer water
! ** equation for variable called (WIN). Top layer is assumed to pertain
! ** to top 2 cm (instead of top 10 cm as for intermediate layer),
! ** 20% of root evaporation is drawn from this layer. Top layer draws
! ** on all surface evaporation. Lowest (reservoir) layer on all
! ** evaporation. Note that constant CONST2 changed from earlier version.
! ** Note if you wish to supress variation in substrate water content
! ** with time, let wmax equal to a very large value, e.g. 10.
! INCLUDE 'modvars.h'
! ** Constants for the water budget equation.
! DATA CONST1 , CONST2, D1P,D_INT, D2P/1, 0.5, 0.1, 2*0.5/ OMG / 24 /
! This fixes tests, but breaks the program
IF ( eq(TIME,0.0) .or. (win < 0.001) ) THEN
WIN = ( WGG + W2G ) / 2
END IF
PER = OMG * 3600
C11 = CONST1 / ( RHOW * D1P )
C22 = CONST2 / PER
C33 = 1 / ( D2P * RHOW )
C44 = CONST1 / ( RHOW * D_INT )
EVAX = EVAP / LE
IF ( FRVEG > 0 .AND. RNET > 0 ) THEN
EVAS = (XLEG * FRVEG + ( 1 - FRVEG ) * BareEvapFlux) / LE
EVAI = ( XLEF * FRVEG ) / LE
ELSE
EVAS = EVAX
EVAI = 0
END IF
WW1 = ( C11 * EVAS + C22 * ( WGG - WIN ) ) * DELTA
WW2 = ( C44 * EVAI - C22 * ( WGG + W2G - 2 * WIN ) ) * DELTA
WW3 = EVAI * C33 * DELTA
WGG = WGG - WW1
WIN = WIN - WW2
W2G = W2G - WW3
IF ( WGG <= 0 ) WGG = 0.001
IF ( WIN <= 0 ) WIN = 0.001
IF ( W2G <= 0 ) W2G = 0.001
! ** Compute the updated version of moisture availability and substrate
! ** moisture availability.
F = ( WGG / WMAX )
FSUB = ( W2G / WMAX )
return
end
| src/water.f90 |
subroutine platfd(uplatc,uplatm)
c
c This subroutine sets the platform designator strings that are
c written on the output and screen files of various codes.
c
c This subroutine is called by:
c
c EQPT/eqpt.f
c EQ3NR/eq3nr.f
c EQ6/eq6.f
c
c-----------------------------------------------------------------------
c
c Input:
c
c None
c
c Output:
c
c uplatc = platform category (e.g., UNIX, PC, MAC)
c uplatm = platform machine (e.g., SPARC, SGI, Pentium, 486PC)
c
c-----------------------------------------------------------------------
c
implicit none
c
c-----------------------------------------------------------------------
c
c Calling sequence variable declarations.
c
character*8 uplatc,uplatm
c
c-----------------------------------------------------------------------
c
c Local variable declarations.
c
c None
c
c-----------------------------------------------------------------------
c
com BEGIN_UNIX_DEPENDENT_CODE
com
c uplatc = 'UNIX'
com
c uplatm = 'SPARC'
cxx uplatm = 'SGI'
cxx uplatm = 'HP-UX'
cxx uplatm = 'AIX'
cxx uplatm = 'Ultrix'
com
com END_UNIX_DEPENDENT_CODE
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
com BEGIN_PC_DEPENDENT_CODE
com
uplatc = 'PC'
com
cxx uplatm = 'Pentium II'
cxx uplatm = 'K6'
cxx uplatm = 'K6-2'
uplatm = 'PC'
cxx uplatm = 'Pentium Pro'
cxx uplatm = 'P5'
cxx uplatm = 'Pentium'
cxx uplatm = '486PC'
cxx uplatm = '386PC'
com
com END_PC_DEPENDENT_CODE
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
com BEGIN_MAC_DEPENDENT_CODE
com
c uplatc = 'MAC'
com
c uplatm = 'MAC'
com
com END_MAC_DEPENDENT_CODE
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
com BEGIN_VAX_DEPENDENT_CODE
com
c uplatc = 'VAX/VMS'
com
c uplatm = 'VAX'
com
com END_VAX_DEPENDENT_CODE
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
end
| src/eqlibu/src/platfd.f |
subroutine stokes(nxp,nyp,nzp,sint,cost,sinp,cosp,phi,
+ fi,fq,fu,fv,pl,pc,sc,hgg,g2,pi,twopi,iseed)
implicit none
integer iseed
real*8 nxp,nyp,nzp,sint,cost,sinp,cosp,phi,fi,fq,fu,fv
real*8 pl,pc,sc,hgg,g2,pi,twopi,wght
real*8 p1,p2,p3,p4,a11,a12,a13,a21,a22,a23,a24,a31,a32,a33,a34
real*8 a42,a43,a44,a,rprob,si,sq,su,sv
real*8 costp,sintp,phip
real*8 bmu,b,ri1,ri3,cosi3,sini3,cosb2,sinbt,sini2,bott,cosdph
real*8 cosi2,sin2i3,sin2i2,cos2i3,cos2i2,sin2,cos2,sin2cos1
real*8 cos2sin1,cosi1,sini1,sin2i1,cos2i1
real ran2
wght=fi
fi=fi/wght
fq=fq/wght
fu=fu/wght
fv=fv/wght
c***** isotropic scattering ******************************
if(hgg.eq.0.) then
cost=2.*ran2(iseed)-1.
sint=(1.-cost*cost)
if(sint.le.0.)then
sint=0.
else
sint=sqrt(sint)
endif
phi=twopi*ran2(iseed)
sinp=sin(phi)
cosp=cos(phi)
nxp=sint*cosp
nyp=sint*sinp
nzp=cost
goto 100
endif
costp=cost
sintp=sint
phip=phi
c***** electron scattering ********************************
10 continue
c bmu=1.-2.*ran2(iseed)
c cosb2=bmu*bmu
c b=cosb2-1.
c p1=1.+cosb2
c p2=b
c p3=2.*bmu
c p4=0.
c***********************************************************
c***** dust scattering ********************************
bmu=((1.+g2)-((1.-g2)/(1.-hgg+2.*hgg*ran2(iseed)))**2)/(2.*hgg)
cosb2=bmu**2
b=cosb2-1.
call dustmat(p1,p2,p3,p4,bmu,cosb2,pl,pc,sc,hgg,g2,pi)
a=p1
c***********************************************************
if(abs(bmu).gt.1.) then
if(bmu.gt.1.) then
bmu=1.
cosb2=1.
b=0.
else
bmu=-1.
cosb2=1.
b=0.
end if
end if
sinbt=sqrt(1.-cosb2)
ri1=twopi*ran2(iseed)
if(ri1.gt.pi) then
ri3=twopi-ri1
cosi3=cos(ri3)
sini3=sin(ri3)
sin2i3=2.*sini3*cosi3
cos2i3=2.*cosi3*cosi3-1.
a11=p1
a12=p2*cos2i3
a13=p2*sin2i3
c****** for electron scattering **********
c rprob=a11*fi+a12*fq+a13*fu
c if((2.*ran2(iseed)).gt.rprob) goto 10
c a=rprob
c******************************************
if(bmu.eq.1.) then
goto 100
else
if(bmu.eq.-1.) then
fu=-fu
goto 100
end if
end if
cost=costp*bmu+sintp*sinbt*cosi3
if(abs(cost).lt.1.) then
sint=abs(sqrt(1.-cost*cost))
sini2=sini3*sintp/sint
bott=sint*sinbt
cosi2=costp/bott-cost*bmu/bott
else
sint=0.
sini2=0.
if(cost.ge.1.) cosi2=-1.
if(cost.le.-1.) cosi2=1.
end if
cosdph=-cosi2*cosi3+sini2*sini3*bmu
if(abs(cosdph).gt.1.) then
if(cosdph.gt.1.) then
cosdph=1.
else
cosdph=-1.
end if
end if
phi=phip+acos(cosdph)
if(phi.gt.twopi) phi=phi-twopi
if(phi.lt.0.) phi=phi+twopi
sin2i2=2.*sini2*cosi2
cos2i2=2.*cosi2*cosi2-1.
sin2=sin2i2*sin2i3
cos2=cos2i2*cos2i3
sin2cos1=sin2i2*cos2i3
cos2sin1=cos2i2*sin2i3
a21=p2*cos2i2
a22=p1*cos2-p3*sin2
a23=p1*cos2sin1+p3*sin2cos1
a24=-p4*sin2i2
a31=-p2*sin2i2
a32=-p1*sin2cos1-p3*cos2sin1
a33=-p1*sin2+p3*cos2
a34=-p4*cos2i2
a42=-p4*sin2i3
a43=p4*cos2i3
a44=p3
c elseif(ri1.le.pi) then
else
cosi1=cos(ri1)
sini1=sin(ri1)
sin2i1=2.*sini1*cosi1
cos2i1=2.*cosi1*cosi1-1.
a11=p1
a12=p2*cos2i1
a13=-p2*sin2i1
c************* for electron scattering ****************
c rprob=a11*fi+a12*fq+a13*fu
c if((2.*ran2(iseed)).gt.rprob) goto 10
c a=rprob
c*******************************************************
if(bmu.eq.1.) then
goto 100
else
if(bmu.eq.-1.) then
fu=-fu
goto 100
end if
end if
cost=costp*bmu+sintp*sinbt*cosi1
if(abs(cost).lt.1.) then
sint=abs(sqrt(1.-cost*cost))
sini2=sini1*sintp/sint
bott=sint*sinbt
cosi2=costp/bott-cost*bmu/bott
else
sint=0.
sini2=0.
if(cost.ge.1.) cosi2=-1.
if(cost.le.-1.) cosi2=1.
end if
cosdph=-cosi1*cosi2+sini1*sini2*bmu
if(abs(cosdph).gt.1.) then
if(cosdph.gt.1.) then
cosdph=1.
else
cosdph=-1.
end if
end if
phi=phip-acos(cosdph)
if(phi.gt.twopi) phi=phi-twopi
if(phi.lt.0.) phi=phi+twopi
sin2i2=2.*sini2*cosi2
cos2i2=2.*cosi2*cosi2-1.
sin2=sin2i2*sin2i1
cos2=cos2i2*cos2i1
sin2cos1=sin2i2*cos2i1
cos2sin1=cos2i2*sin2i1
a21=p2*cos2i2
a22=p1*cos2-p3*sin2
a23=-p1*cos2sin1-p3*sin2cos1
a24=p4*sin2i2
a31=p2*sin2i2
a32=p1*sin2cos1+p3*cos2sin1
a33=-p1*sin2+p3*cos2
a34=-p4*cos2i2
a42=p4*sin2i1
a43=p4*cos2i1
a44=p3
end if
si=(a11*fi+a12*fq+a13*fu)/a
sq=(a21*fi+a22*fq+a23*fu+a24*fv)/a
su=(a31*fi+a32*fq+a33*fu+a34*fv)/a
sv=(a42*fq+a43*fu+a44*fv)/a
fi=si*wght
fq=sq*wght
fu=su*wght
fv=sv*wght
cosp=cos(phi)
sinp=sin(phi)
nxp=sint*cosp
nyp=sint*sinp
nzp=cost
100 continue
return
end
subroutine dustmat(p1,p2,p3,p4,cost,cost2,pl,pc,sc,hgg,g2,pi)
c a.d. code october 25, 1989
c revised baw apr 10, 1990
c **********************************************************************
c
c this program calculates the elements of the phase matrix for a
c simple representation of the mrn dust mixture using the algorithms
c for the ultraviolet region due to richard l. white ap.j. 229, 954,
c 1979.
c
c ***********************************************************************
c
c cost = cos(angle) of scattering (i.e. angle between incident
c photon and scattered photon)
c g = mean value of cosine of scattering angle (henyey-greenstein)
c pl = peak linear polarization
c pc = peak value of linear to circular conversion
c sc = asymmetry of the circular polarization.
c p1 = intensity phase function
c p2 = polarization function
c p3 = skew polarization
c p4 = circular polarization
c
c the scattering matrix for (i,q,u,v) is of the form
c
c p1 p2 0 0
c p2 p1 0 0
c 0 0 p3 -p4
c 0 0 p4 p3
c
c **********************************************************************
implicit none
real*8 p1,p2,p3,p4,cost,cost2,pl,pc,sc,hgg,g2,pi
real*8 phi,f,f2,c
p1 = (1 - g2)/(1+g2-2*hgg*cost)**1.5
p2 = -pl*p1*(1-cost2)/(1+cost2)
p3 = p1*2*cost/(1+cost2)
if(abs(cost).gt.1.) then
print *, 'in dustmat, cost.gt.1',cost
if(cost.gt.1) then
cost=1.
else
cost=-1.
end if
end if
c angle in degrees!
phi=acos(cost)*180./pi
f=3.13*phi*exp(-7.0*phi/180.)
c now convert to radians
f2=(phi+sc*f)*pi/180.
c fphi= (1+3.13*sc*exp(-7.0*phi/pi))*phi
c=(cos(f2))**2
p4 = -pc*p1*(1-c)/(1+c)
c******* Isotropic scattering
c p1 = 1.0
c p3 = 1.0
c p2 = 0.0
c p4 = 0.0
return
end
| MCRT_3D_Cart/stokes.f |
PROGRAM TEST_GEOPACK
IMPLICIT NONE
! PROGRAM INPUTS
REAL :: XGSWI,YGSWI,ZGSWI,BYIMF,BZIMF,PDYN,DST
INTEGER :: IYEAR,IDAY,IHOUR,IMIN,ISEC
REAL, DIMENSION(12) :: R_INPUTS
! SUBROUTINE OUTPUTS (IF YOU WANT TO CHANGE XX/YY/ZZ TO LARGER ARRAYS YOU MUST
! ALSO CHANGE THE LMAX INPUT IN THE CALL TO TRACE_08)
REAL :: XGEOF,YGEOF,ZGEOF,XGSWF,YGSWF,ZGSWF
REAL, DIMENSION(5000) :: XX,YY,ZZ
! RADIANS TO DEGREE VARIABLES
REAL :: PI,RADIUS,REI,TRADI,PRADI,REF,TRADF,PRADF
! PROGRAM OUTPUTS
REAL :: RF,THETAF,PHIF
INTEGER :: L
CHARACTER(LEN=8) :: HEMISPHERE
! SUBROUTINE CONSTANTS
REAL :: VGSEX,VGSEY,VGSEZ,DSMAX,ERR,RMAX,RMIN
REAL, DIMENSION(10) :: PARMOD
EXTERNAL :: T96_01,IGRF_GSW_08
! COMMAND LINE TEMP STRING
CHARACTER(LEN=256) :: ARGUMENTS
! LOOPING VARIABLES
INTEGER :: II
REAL :: MAPTO
! READ THE COMMAND LINE
DO II=1,12
CALL GET_COMMAND_ARGUMENT(II,ARGUMENTS)
READ(ARGUMENTS,*) R_INPUTS(II)
END DO
! ASSIGN INPUTS FROM THE COMMAND LINE
IYEAR = R_INPUTS(1)
IDAY = R_INPUTS(2)
IHOUR = R_INPUTS(3)
IMIN = R_INPUTS(4)
ISEC = R_INPUTS(5)
XGSWI = R_INPUTS(6)
YGSWI = R_INPUTS(7)
ZGSWI = R_INPUTS(8)
BYIMF = R_INPUTS(9)
BZIMF = R_INPUTS(10)
PDYN = R_INPUTS(11)
DST = R_INPUTS(12)
! DEFINE CONSTANTS USING THE SAME VALUES AS THE PYTHON DEFAULTS
VGSEX = -400.0
VGSEY = 0.0
VGSEZ = 0.0
DSMAX = 0.01
ERR = 0.000001
RMAX = 60.0
RMIN = 1.0
PARMOD = [PDYN,DST,BYIMF,BZIMF,0.0,0.0,0.0,0.0,0.0,0.0]
CALL RECALC_08(IYEAR,IDAY,IHOUR,IMIN,ISEC,VGSEX,VGSEY,VGSEZ)
DO MAPTO=-1,1,2
CALL TRACE_08(XGSWI,YGSWI,ZGSWI,MAPTO,DSMAX,ERR,RMAX,RMIN,0,PARMOD,&
T96_01,IGRF_GSW_08,XGSWF,YGSWF,ZGSWF,XX,YY,ZZ,L,5000)
CALL GEOGSW_08(XGEOF,YGEOF,ZGEOF,XGSWF,YGSWF,ZGSWF,-1)
CALL SPHCAR_08(REF,TRADF,PRADF,XGEOF,YGEOF,ZGEOF,-1)
! CONVERT OUTPUTS TO DEGREES LATITUDE AND KILOMETRES
PI = 3.1415926535
RADIUS = 6371.2
THETAF = 90.0 - (TRADF * 180.0 / PI)
PHIF = PRADF * 180.0 / PI
RF = REF * RADIUS
IF(MAPTO.EQ.-1) HEMISPHERE = "NORTHERN"
IF(MAPTO.EQ.1) HEMISPHERE = "SOUTHERN"
PRINT *,HEMISPHERE," HEMISPHERE:",THETAF,PHIF,RF
END DO
END PROGRAM | original-fortran/test_geopack.f90 |
! MIT License
!
! Copyright (c) 2020 SHEMAT-Suite
!
! Permission is hereby granted, free of charge, to any person obtaining a copy
! of this software and associated documentation files (the "Software"), to deal
! in the Software without restriction, including without limitation the rights
! to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
! copies of the Software, and to permit persons to whom the Software is
! furnished to do so, subject to the following conditions:
!
! The above copyright notice and this permission notice shall be included in all
! copies or substantial portions of the Software.
!
! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
! IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
! FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
! AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
! LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
! OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
! SOFTWARE.
!> @brief read inverse parameters and allocate fields
!> @param[in] filename
!> @param[in] ismpl local sample index
SUBROUTINE read_inverse(filename,ismpl)
use arrays
#ifdef AD
use g_arrays
#endif
#ifdef AD_RM
use arrays_ad
#endif
use mod_genrl
use mod_genrlc
use mod_flow
use mod_temp
use mod_conc
use mod_inverse
use mod_time
use mod_data
use mod_OMP_TOOLS
use mod_linfos
IMPLICIT NONE
integer i, j, k, ismpl
INCLUDE 'OMP_TOOLS.inc'
CHARACTER filename*80, line*5000, ctmp*4
CHARACTER*4 stmp(max(nprop,nbc))
INTEGER locstr, lblank, itmp, i2tmp, c1, c2, c3, c4, tmplen
INTEGER mpara_p, mpara_bc
LOGICAL found, no_ext_link, no_ext_link_int
DOUBLE PRECISION dtmp
DOUBLE PRECISION, ALLOCATABLE :: datmp(:,:)
EXTERNAL locstr, found, no_ext_link, no_ext_link_int, lblank
! not global anymore (better use opti_props or opti_bc) !
INTEGER proplevel(nprop)
INTEGER, ALLOCATABLE :: unitlevel(:)
CHARACTER*4 sll(0:2)
DATA sll/' ', ' lin', ' log'/
INTRINSIC trim
! open file
OPEN(79,file=filename,status='old')
WRITE(*,*)
WRITE(*,*) ' reading inverse parameter'
WRITE(*,*)
!
! init HDF5 support, when available
CALL open_hdf5(' ')
ALLOCATE(unitlevel(nunits))
! default init
reg_para = 1.0D0
reg_type = 1
maxiter_inv = 1
tol_inv = 1.0D0
iter_out = 1
IF (found(79,key_char//' inverse',line,.FALSE.)) THEN
WRITE(*,*) ' [R] : inversion parameters'
READ(79,*) reg_type
READ(79,*) maxiter_inv, tol_inv
READ(79,*) resmat, covar
READ(79,*) iter_out
ELSE
resmat = 0
covar = 0
END IF
#ifdef JACOBI_FREE
WRITE(*,*) ' [I] : The use of the AD reverse mode implies (Jacobi) matrix free computation!'
IF (resmat/=0.OR.covar/=0) THEN
WRITE(*,*) ' [I] : Computation of Covariances and Resolution matrix DISABLED!'
WRITE(*,*) ' Otherwise it can create too big Jacobi matrix!'
END IF
resmat = 0
covar = 0
#endif
IF (found(79,'# regular',line,.FALSE.)) THEN
READ(79,*) reg_para
WRITE(*,*) ' [R] : regularisation parameter: ', reg_para
ELSE
WRITE(*,*) ' <D> : no regularisation parameter !'
END IF
!------------------------------------------------------------------------
#ifdef head_base
nltol_g(pv_head) = nltolf
#endif
#ifdef pres_base
nltol_g(pv_pres) = nltolf
#endif
IF (head_active) THEN
IF (found(79,key_char//' grad nliterf',line,.FALSE.)) THEN
#ifdef head_base
READ(79,*,err=111,end=111) nltol_g(pv_head)
#endif
#ifdef pres_base
READ(79,*,err=111,end=111) nltol_g(pv_pres)
#endif
WRITE(*,*) ' [R] : gradient flow nonlinear iteration tolerance (rel.)'
111 CONTINUE
END IF
END IF
nltol_g(pv_temp) = nltolt
IF (temp_active) THEN
IF (found(79,key_char//' grad nlitert',line,.FALSE.)) THEN
READ(79,*,err=112,end=112) nltol_g(pv_temp)
WRITE(*,*) ' [R] : gradient temperature &
&nonlinear iteration tolerance (rel.)'
112 CONTINUE
END IF
END IF
nltol_g(pv_conc) = nltolc
IF (trans_active) THEN
IF (found(79,key_char//' grad nliterc',line,.FALSE.)) THEN
READ(79,*,err=113,end=113) nltol_g(pv_conc)
WRITE(*,*) ' [R] : gradient transport nonlinear &
&iteration tolerance (rel.)'
113 CONTINUE
END IF
END IF
!------------------------------------------------------------------------
IF (found(79,key_char//' errors',line,.FALSE.)) THEN
ALLOCATE(datmp(nprop_load,maxunits))
IF (no_ext_link(nprop_load,maxunits,1,datmp,'errors',line)) &
THEN
CALL read_array(79,nprop_load,maxunits,datmp,'# errors', &
ismpl)
END IF
IF (nprop_load==lastidx-firstidx+1) THEN
! load all, dense entries (no specific index)
DO i = 1, maxunits
DO j = 1, nprop_load
d_propunit(i,firstidx-1+j) = datmp(j,i)
END DO
END DO
ELSE
! needs to handle manual reading with specific index
WRITE(*,'(1A)') &
'error in "read_inverse.f": reading errors: specific index handling not implemented, use dense entries instead'
STOP
END IF
DO i = 1, maxunits
! because of logarithimc scale, suppress zeros
DO j = firstidx, lastidx
d_propunit(i,j) = max(1.0D-10,d_propunit(i,j))
END DO
IF (linfos(2)>=2) WRITE(*,'('//c_npropunit//'e12.4,1I8)') &
(d_propunit(i,j),j=firstidx,lastidx), i
END DO
WRITE(*,*) ' [R] : variances apriori'
DEALLOCATE(datmp)
ELSE
WRITE(*,*) ' <D> : variances apriori !'
DO i = 1, maxunits
DO j = firstidx, lastidx
d_propunit(i,j) = 1.0D0
END DO
IF (linfos(2)>=2) WRITE(*,'('//c_npropunit//'e12.4,1I8)') &
(d_propunit(i,j),j=firstidx,lastidx), i
END DO
END IF
IF (found(79,key_char//' bcerrors',line,.FALSE.)) THEN
DO i = 1, bc_maxunits
DO j = bc_firstidx, bc_lastidx
d_propunit(i,j) = 1.0D0
END DO
END DO
CALL get_arg('records',line,i,j)
IF (i<1 .OR. j<i) THEN
READ(79,*) tmplen
ELSE
READ(line(i:j),*) tmplen
END IF
DO i = 1, tmplen
READ(79,*) k, dtmp, ctmp
IF ((k>bc_maxunits) .OR. (k<1)) THEN
WRITE(*,'(A,I7,A,I7,A)') 'error: "bcerrors": &
&bc unit number out of range or not used, &
&(', k, ') at line ', i, '!'
STOP
END IF
IF ((ctmp/='head') .AND. (ctmp/='temp') .AND. &
(ctmp/='pres') .AND. (ctmp/='conc')) THEN
WRITE(*,'(A,A1,A,I3,A)') &
'error: "bcerrors": bc unit type not allowed, "', &
ctmp, '" at line ', i, '!'
STOP
END IF
IF (ctmp=='head') d_propunit(k,idx_hbc) = max(1.D-10,dtmp)
IF (ctmp=='temp') d_propunit(k,idx_tbc) = max(1.D-10,dtmp)
IF (ctmp=='conc') d_propunit(k,idx_cbc) = max(1.D-10,dtmp)
IF (ctmp=='pres') d_propunit(k,idx_hbc) = max(1.D-10,dtmp)
END DO
WRITE(*,'(A,I3)') ' [R] : bc variances apriori, records=', &
tmplen
ELSE
WRITE(*,*) ' <D> : bc variances apriori !'
DO i = 1, bc_maxunits
DO j = bc_firstidx, bc_lastidx
d_propunit(i,j) = 1.0D0
END DO
END DO
END IF
!------------------------------------------------------------------------
IF (found(79,key_char//' apriori',line,.FALSE.)) THEN
ALLOCATE(datmp(nprop_load,maxunits))
IF (no_ext_link(nprop_load,maxunits,1,datmp,'apriori',line)) &
THEN
CALL read_array(79,nprop_load,maxunits,datmp,'# apriori', &
ismpl)
END IF
IF (nprop_load==lastidx-firstidx+1) THEN
! load all, dense entries (no specific index)
DO i = 1, maxunits
DO j = 1, nprop_load
a_propunit(i,firstidx-1+j) = datmp(j,i)
END DO
END DO
ELSE
! needs to handle manual reading with specific index
WRITE(*,'(1A)') &
'error in "read_inverse.f": reading apriori: specific index handling not implemented, use dense entries instead'
STOP
END IF
DO i = 1, maxunits
! because of logarithimc scale, suppress zeros
a_propunit(i,idx_por) = max(prop_min(idx_por), &
a_propunit(i,idx_por))
a_propunit(i,idx_an_kx) = max(prop_min(idx_an_kx), &
a_propunit(i,idx_an_kx))
a_propunit(i,idx_an_ky) = max(prop_min(idx_an_ky), &
a_propunit(i,idx_an_ky))
a_propunit(i,idx_kz) = max(prop_min(idx_kz), &
a_propunit(i,idx_kz))
!? a_propunit(i,idx_Comp) = max(prop_min(idx_Comp),
!? & a_propunit(i,idx_Comp))
a_propunit(i,idx_an_lx) = max(prop_min(idx_an_lx), &
a_propunit(i,idx_an_lx))
a_propunit(i,idx_an_ly) = max(prop_min(idx_an_ly), &
a_propunit(i,idx_an_ly))
a_propunit(i,idx_lz) = max(prop_min(idx_lz), &
a_propunit(i,idx_lz))
a_propunit(i,idx_q) = max(prop_min(idx_q), &
a_propunit(i,idx_q))
a_propunit(i,idx_rc) = max(prop_min(idx_rc), &
a_propunit(i,idx_rc))
a_propunit(i,idx_df) = max(prop_min(idx_df), &
a_propunit(i,idx_df))
a_propunit(i,idx_ec) = max(prop_min(idx_ec), &
a_propunit(i,idx_ec))
!? a_propunit(i,idx_lC) = max(prop_min(idx_lC),
!? & a_propunit(i,idx_lC))
IF (linfos(2)>=2) WRITE(*,'('//c_npropunit//'e12.4,1I8)') &
(a_propunit(i,j),j=firstidx,lastidx), i
END DO
WRITE(*,*) ' [R] : unit properties apriori'
DEALLOCATE(datmp)
ELSE
WRITE(*,*) ' <D> : unit properties apriori !'
DO i = 1, maxunits
a_propunit(i,idx_por) = max(prop_min(idx_por), &
propunit(i,idx_por,ismpl))
a_propunit(i,idx_an_kx) = max(prop_min(idx_an_kx), &
propunit(i,idx_an_kx,ismpl))
a_propunit(i,idx_an_ky) = max(prop_min(idx_an_ky), &
propunit(i,idx_an_ky,ismpl))
a_propunit(i,idx_kz) = max(prop_min(idx_kz), &
propunit(i,idx_kz,ismpl))
a_propunit(i,idx_comp) = propunit(i,idx_comp,ismpl)
a_propunit(i,idx_an_lx) = max(prop_min(idx_an_lx), &
propunit(i,idx_an_lx,ismpl))
a_propunit(i,idx_an_ly) = max(prop_min(idx_an_ly), &
propunit(i,idx_an_ly,ismpl))
a_propunit(i,idx_lz) = max(prop_min(idx_lz), &
propunit(i,idx_lz,ismpl))
a_propunit(i,idx_q) = max(prop_min(idx_q), &
propunit(i,idx_q,ismpl))
a_propunit(i,idx_rc) = max(prop_min(idx_rc), &
propunit(i,idx_rc,ismpl))
a_propunit(i,idx_df) = max(prop_min(idx_df), &
propunit(i,idx_df,ismpl))
a_propunit(i,idx_ec) = max(prop_min(idx_ec), &
propunit(i,idx_ec,ismpl))
a_propunit(i,idx_lc) = propunit(i,idx_lc,ismpl)
IF (linfos(2)>=2) WRITE(*,'('//c_npropunit//'e12.4,1I8)') &
(a_propunit(i,j),j=firstidx,lastidx), i
END DO
END IF
IF (found(79,key_char//' bcapriori',line,.FALSE.)) THEN
DO i = 1, bc_maxunits
a_propunit(i,idx_hbc) = max(0.D0,propunit(i,idx_hbc,ismpl))
a_propunit(i,idx_tbc) = propunit(i,idx_tbc,ismpl)
a_propunit(i,idx_cbc) = propunit(i,idx_cbc,ismpl)
END DO
CALL get_arg('records',line,i,j)
IF (i<1 .OR. j<i) THEN
READ(79,*) tmplen
ELSE
READ(line(i:j),*) tmplen
END IF
DO i = 1, tmplen
READ(79,*) k, dtmp, ctmp
IF ((k>bc_maxunits) .OR. (k<1)) THEN
WRITE(*,'(A,I7,A,I7,A)') 'error: "bcapriori": &
&bc unit number out of range or not used, &
&(', k, ') at line ', i, ' !!!'
STOP
END IF
IF ((ctmp/='head') .AND. (ctmp/='temp') .AND. &
(ctmp/='pres') .AND. (ctmp/='conc')) THEN
WRITE(*,'(A,A1,A,I3,A)') &
'error: "bcapriori": bc unit type not allowed, "', &
ctmp, '" at line ', i, ' !!!'
STOP
END IF
IF (ctmp=='head') a_propunit(k,idx_hbc) = max(0.D0,dtmp)
IF (ctmp=='temp') a_propunit(k,idx_tbc) = dtmp
IF (ctmp=='conc') a_propunit(k,idx_cbc) = dtmp
IF (ctmp=='pres') a_propunit(k,idx_hbc) = dtmp
END DO
WRITE(*,'(A,I3)') &
' [R] : bc unit properties apriori, records=', tmplen
ELSE
WRITE(*,*) ' <D> : bc unit properties apriori !'
DO i = 1, bc_maxunits
a_propunit(i,idx_hbc) = max(0.D0,propunit(i,idx_hbc,ismpl))
a_propunit(i,idx_tbc) = propunit(i,idx_tbc,ismpl)
a_propunit(i,idx_cbc) = propunit(i,idx_cbc,ismpl)
END DO
END IF
! -----------------------------------------------------------------------
! read opt. switChes ---
IF (found(79,key_char//' enable property',line,.FALSE.)) THEN
WRITE(*,*) ' [R] : property map (on/off)'
! default - disable the property
DO i = 1, nprop_load
proplevel(i) = 0
END DO
! read level
READ(79,*,err=241,end=241) (proplevel(i),i=1,nprop_load)
GOTO 200
241 IF (i-1<nprop_load) WRITE(*,'(A,I2,A,I2,A)') &
' <D> : WARNING, to few properties specified ( read ', i-1, ' of ', nprop_load, ') !'
200 CONTINUE
ELSE
WRITE(*,*) ' <D> : transformation types for properties !'
DO i = 1, nprop_load
proplevel(i) = 0
END DO
WRITE(*,'(A,13I2)') ' #', (proplevel(i),i=1, &
nprop_load)
END IF
! --------------------
! init
DO i = 1, maxunits
unitlevel(i) = 1
END DO
! set
IF (found(79,key_char//' enable unit',line,.FALSE.)) THEN
WRITE(*,*) ' [R] : unit map (on/off)'
READ(79,*) (unitlevel(i),i=1,maxunits)
ELSE
WRITE(*,*) ' <D> : unit map (on) !'
END IF
! --------------------
! init
DO j = 1, maxunits
DO i = 1, nprop_load
IF ((proplevel(i)>0) .AND. (unitlevel(j)>0)) THEN
opti_props(i,j) = proplevel(i)
ELSE
opti_props(i,j) = 0
END IF
END DO
END DO
! set
IF (found(79,key_char//' optimize property',line,.FALSE.)) THEN
CALL get_arg('records',line,i,j)
IF (i>0 .AND. j>=i) THEN
READ(line(i:j),*) k
ELSE
READ(79,*) k
END IF
WRITE(*,'(A,I3)') &
' [R] : property optimization table, records=', k
DO i = 1, k
READ(79,'(A)') line
READ(line,*) itmp, i2tmp
IF (itmp>maxunits) THEN
WRITE(*,'(A)') 'error: "optimize property" &
&unit number out of range !!!'
STOP
END IF
IF (locstr(line,'por')>=1) opti_props(idx_por,itmp) &
= i2tmp
IF (locstr(line,'a_kx')>=1) opti_props(idx_an_kx,itmp) &
= i2tmp
IF (locstr(line,'a_ky')>=1) opti_props(idx_an_ky,itmp) &
= i2tmp
IF (locstr(line,'kz')>=1) opti_props(idx_kz,itmp) = i2tmp
IF (locstr(line,'comp')>=1) opti_props(idx_comp,itmp) &
= i2tmp
IF (locstr(line,'a_lx')>=1) opti_props(idx_an_lx,itmp) &
= i2tmp
IF (locstr(line,'a_ly')>=1) opti_props(idx_an_ly,itmp) &
= i2tmp
IF (locstr(line,'lz')>=1) opti_props(idx_lz,itmp) = i2tmp
IF (locstr(line,'q')>=1) opti_props(idx_q,itmp) = i2tmp
IF (locstr(line,'rc')>=1) opti_props(idx_rc,itmp) = i2tmp
IF (locstr(line,'df')>=1) opti_props(idx_df,itmp) = i2tmp
IF (locstr(line,'ec')>=1) opti_props(idx_ec,itmp) = i2tmp
IF (locstr(line,'lc')>=1) opti_props(idx_lc,itmp) = i2tmp
END DO
END IF
! final count
mpara_p = 0
DO j = 1, maxunits
DO i = 1, lastidx - firstidx + 1
IF (opti_props(i,j)>0) mpara_p = mpara_p + 1
END DO
END DO
! --------------------
! init
DO j = 1, bc_maxunits
DO i = 1, nbc
opti_bc(i,j) = 0
END DO
END DO
! set
IF (found(79,key_char//' optimize bc',line,.FALSE.)) THEN
CALL get_arg('records',line,i,j)
IF (i>0 .AND. j>=i) THEN
READ(line(i:j),*) k
ELSE
READ(79,*) k
END IF
WRITE(*,'(A,I3)') ' [R] : bc optimization table, records=', k
IF (k>0 .AND. transient) THEN
WRITE(*,'(1A)') 'error: bc optimization not allowed for time dependend models!'
WRITE(*,'(2A)') ' -> please, update this as tp optimization with the ', &
'simulation begin as the start time.'
STOP
END IF
!
DO i = 1, k
! avaiting: [bc-unit (1|2) (head|temp|conc)]
! == [unit-id lin/log pv-type ]
READ(79,'(A)') line
READ(line,*) itmp, i2tmp
IF (itmp>bc_maxunits) THEN
WRITE(*,'(A)') &
'error: "optimize bc" unit number out of range !!!'
STOP
END IF
IF (locstr(line,'head')>=1) opti_bc(1,itmp) = i2tmp
IF (locstr(line,'temp')>=1) opti_bc(2,itmp) = i2tmp
IF (locstr(line,'conc')>=1) opti_bc(3,itmp) = i2tmp
IF (locstr(line,'pres')>=1) opti_bc(3,itmp) = i2tmp
END DO
END IF
! final count
mpara_bc = 0
DO j = 1, bc_maxunits
DO i = 1, bc_lastidx - bc_firstidx + 1
IF (opti_bc(i,j)>0) mpara_bc = mpara_bc + 1
END DO
END DO
! --------------------
! init
CALL set_ival(3*ngsmax*mopti_tp*nbctp,0,opti_tp)
mpara_tp = 0
! set
IF (transient) THEN
IF (found(79,key_char//' optimize tp',line,.FALSE.)) THEN
CALL get_arg('records',line,i,j)
IF (i>0 .AND. j>=i) THEN
READ(line(i:j),*) c1
ELSE
READ(79,*) c1
END IF
WRITE(*,'(A,I3)') ' [R] : tp optimization table, records=', c1
DO i = 1, c1
! [tp entry index, bc index number, alpha-beta keyword]
READ(79,'(A)') line
! Here the bc-index needs to be assoziated with a unit number and
! defines this the dependency to the tp period table (where to find the tp-entry)
READ(line,*) itmp, i2tmp
! sanity check
IF (itmp>ngsmax) THEN
WRITE(*,'(A)') 'error: "optimize tp" period number out of range !!!'
STOP
END IF
IF (i2tmp>nbctp) THEN
WRITE(*,'(A)') 'error: "optimize tp" bc index out of range !!!'
STOP
END IF
! default: linear, log = disabled
!aw c2 = 1
!aw IF (locstr(line,'lin')>=1) c2 = 1
!aw IF (locstr(line,'log')>=1) c2 = 2
! al:alpha, be:beta (2 types -> mopti_tp=2)
IF (locstr(line,'al')>=1) THEN
mpara_tp = mpara_tp + 1
opti_tp(1,mpara_tp) = itmp
opti_tp(2,mpara_tp) = 1
opti_tp(3,mpara_tp) = i2tmp
!aw opti_tp(4,mpara_tp) = C2
ELSE IF (locstr(line,'be')>=1) THEN
mpara_tp = mpara_tp + 1
opti_tp(1,mpara_tp) = itmp
opti_tp(2,mpara_tp) = 2
opti_tp(3,mpara_tp) = i2tmp
!aw opti_tp(4,mpara_tp) = C2
ELSE
WRITE(*,'(1A,1I4,3A)') ' [!] : ignore ',i,'. line = "',trim(line),'"'
END IF
END DO
! sanity check
IF (mpara_tp>ngsmax*mopti_tp*max(nbctp,1)) THEN
WRITE(*,'(A)') 'error: number of time period optimisation entries greater than expected !!!'
STOP
END IF
END IF
END IF
! set "mpara" dynamic, must be done before any "inverse" allocation
mpara = mpara_p + mpara_bc + mpara_tp
IF (mpara==0) THEN
WRITE(*,'(1A)') &
'error: no optimization parameters specified!'
STOP
END IF
! --- end opt. switches ---
IF (found(79,key_char//' read output',line,.FALSE.)) THEN
lread_joutt = .TRUE.
resmat = 1
covar = 1
ALLOCATE(seed_index(nsmpl+1))
WRITE(*,*) ' [I] : READ-MODE for state variables'
! IF (mpara /= Tlevel_0) THEN
!! avoid "barrier in a loop" errors in "read_joutt_hdf"
! Tlevel_0 = 1
! WRITE(*,*) ' [I] : cutting sample parallelisation to 1, to avoid errors for READ-MODE'
! END IF
ELSE IF (found(79,key_char//' write output',line,.FALSE.)) THEN
lwrite_joutt = .TRUE.
resmat = 1
covar = 1
WRITE(*,*) ' [I] : WRITE-MODE for state variables'
END IF
! --------------------
IF ((transient) .AND. (mpara_tp>0)) THEN
! todo: read values from file
CALL set_dval(ngsmax*2*nbctp,1.D0,tpwgt)
CALL set_dval(ngsmax*2*nbctp,0.D0,e_bcperiod)
! default, when not all readed
CALL set_dval(ngsmax*2*nbctp,1.0D0,d_bcperiod)
IF (found(79,key_char//' tperrors',line,.FALSE.)) THEN
CALL get_arg('records',line,i,j)
IF (i>0 .AND. j>=i) THEN
READ(line(i:j),*) c1
ELSE
READ(79,*) c1
END IF
WRITE(*,'(A,I3)') ' [R] : tp variances apriori, records=', c1
!
DO i = 1, c1
READ(79,'(A)') line
! p-idx, bc-idx, value
READ(line,*) itmp, i2tmp, dtmp
IF (itmp>ngsmax) THEN
WRITE(*,'(A)') 'error: "tperrors" period number out of range !!!'
STOP
END IF
IF (i2tmp>nbctp) THEN
WRITE(*,'(A)') 'error: "tperrors" bc index out of range !!!'
STOP
END IF
! al:alpha, be:beta
IF (locstr(line,'al')>=1) THEN
d_bcperiod(itmp,1,i2tmp) = dtmp
ELSE IF (locstr(line,'be')>=1) THEN
d_bcperiod(itmp,2,i2tmp) = dtmp
ELSE
WRITE(*,'(A)') 'error: "tperrors", "alpha" or "beta" type must be specified !!!'
END IF
END DO
ELSE
WRITE(*,*) ' <D> : tp variances apriori !'
END IF
!
! default, when not all readed
DO k = 1, nbctp
DO j = 1, 2
DO i = 1, ngsmax
a_bcperiod(i,j,k) = bcperiod(i,j+1,k,ismpl)
END DO
END DO
END DO
IF (found(79,key_char//' tpapriori',line,.FALSE.)) THEN
CALL get_arg('records',line,i,j)
IF (i>0 .AND. j>=i) THEN
READ(line(i:j),*) c1
ELSE
READ(79,*) c1
END IF
WRITE(*,'(A,I3)') ' [R] : time periods apriori, records=', c1
!
DO i = 1, c1
READ(79,'(A)') line
! p-idx, bc-idx, value
READ(line,*) itmp, i2tmp, dtmp
IF (itmp>ngsmax) THEN
WRITE(*,'(A)') 'error: "tpapriori" period number out of range !!!'
STOP
END IF
IF (i2tmp>nbctp) THEN
WRITE(*,'(A)') 'error: "tpapriori" bc index out of range !!!'
STOP
END IF
! al:alpha, be:beta
IF (locstr(line,'al')>=1) THEN
a_bcperiod(itmp,1,i2tmp) = dtmp
ELSE IF (locstr(line,'be')>=1) THEN
a_bcperiod(itmp,2,i2tmp) = dtmp
ELSE
WRITE(*,'(A)') 'error: "tpapriori", "alpha" or "beta" type must be specified !!!'
END IF
END DO
ELSE
WRITE(*,*) ' <D> : time periods apriori !'
END IF
END IF
! read weights
! init
DO i = 1, nprop_load
propwgt(i) = 1.D0
END DO
! set
IF (found(79,key_char//' weight property',line,.FALSE.)) THEN
WRITE(*,*) ' [R] : weights for properties'
READ(79,*,err=271) (propwgt(i),i=1,nprop_load)
GO TO 272
271 WRITE(*,'(A,I2,A)') ' warning: to few weights specified (', &
nprop_load, ') ! 1.0d0 assumed'
272 CONTINUE
ELSE
WRITE(*,*) ' <D> : uniform weights for properties used !'
END IF
! init
DO i = 1, nbc
bcwgt(i) = 1.D0
END DO
! set
IF (found(79,key_char//' weight bc',line,.FALSE.)) THEN
WRITE(*,*) ' [R] : weights for boundary conditions'
READ(79,*,err=281) (bcwgt(i),i=1,nbc)
GO TO 282
281 WRITE(*,'(A,I2,A)') ' warning: to few weights specified (', &
nbc, ') ! 1.0d0 assumed'
282 CONTINUE
ELSE
WRITE(*,*) &
' <D> : uniform weights for boundary conditions !'
END IF
! init
para_weight = 0
! set
IF (.NOT. lib_override) THEN
IF (found(79,key_char//' covar prior para',line,.FALSE.)) THEN
para_weight = 1
ALLOCATE(covar_prior_p(mpara,mpara))
memory = memory + mpara*mpara
!
CALL get_arg('inverse',line,i,j)
IF (i>0 .AND. j>=i) THEN
icovarp = 1
IF (no_ext_link(mpara,mpara,1,covar_prior_p, &
'covar_prior_p',line)) THEN
DO j = 1, mpara
READ(79,*) (covar_prior_p(i,j),i=1,mpara)
END DO
END IF
WRITE(*,*) &
' [R] : prior parameter covariance matrix (inverse)'
ELSE
icovarp = 0
WRITE(*,*) ' [R] : prior parameter covariance matrix'
IF (no_ext_link(mpara,mpara,1,covar_prior_p, &
'covar_prior_p',line)) THEN
DO j = 1, mpara
READ(79,*) (covar_prior_p(i,j),i=1,mpara)
END DO
END IF
END IF
END IF
ELSE
WRITE(*,*) ' <D> : ignore section "# covar prior para" when in LIBRARY mode'
END IF
! init
data_weight = 0
! set
IF (.NOT. lib_override) THEN
IF (found(79,key_char//' covar prior data',line,.FALSE.)) THEN
data_weight = 1
ALLOCATE(covar_prior_d(ndata,ndata))
memory = memory + ndata*ndata
!
CALL get_arg('inverse',line,i,j)
IF (i>0 .AND. j>=i) THEN
icovard = 1
IF (no_ext_link(ndata,ndata,1,covar_prior_d, &
'covar_prior_p',line)) THEN
DO j = 1, ndata
READ(79,*) (covar_prior_d(i,j),i=1,ndata)
END DO
END IF
WRITE(*,*) &
' [R] : prior data covariance matrix (inverse)'
ELSE
icovard = 0
WRITE(*,*) ' [R] : prior data covariance matrix'
IF (no_ext_link(ndata,ndata,1,covar_prior_d, &
'covar_prior_p',line)) THEN
DO j = 1, ndata
READ(79,*) (covar_prior_d(i,j),i=1,ndata)
END DO
END IF
END IF
END IF
ELSE
WRITE(*,*) ' <D> : ignore section "'//key_char//' covar prior data" when in LIBRARY mode'
END IF
! print optimizations tables
IF (linfos(2)>=1) THEN
! parameter units
IF (maxunits>=1) THEN
WRITE(*,*) ' '
WRITE(*,'(6X,A)') 'optimization matrix [properties]:'
WRITE(*,'(8X,2A,'//c_npropunit//'(A4,1X),A1)') '| ', 'unit ', &
(properties(i),i=firstidx,lastidx), '|'
DO j = 1, maxunits
DO k = 1, nprop_load
stmp(k) = sll(opti_props(k,j))
END DO
WRITE(*,'(8X,A2,I4,1X,'//c_npropunit//'(A4,1X),A1)') '| ', j, &
(stmp(i),i=1,nprop_load), '|'
END DO
END IF
! bc units
IF (bc_maxunits>=1) THEN
WRITE(*,*) ' '
WRITE(*,'(6X,A)') &
'optimization matrix [boundary condition]:'
WRITE(*,'(8X,1A2,1A6,1X,'//c_nbcunit//'(A4,1X),1A1)') '| ', 'BCunit', &
'Flow', 'Temp', 'Conc', '|'
DO j = 1, bc_maxunits
DO i = 1, nbc
stmp(i) = sll(opti_bc(i,j))
END DO
WRITE(*,'(8X,1A2,1I6,1X,'//c_nbcunit//'(A4,1X),1A1)') '| ', j, &
(stmp(i),i=1,nbc), '|'
END DO
END IF
! bctp
IF (mpara_tp>=1) THEN
WRITE(*,*) ' '
WRITE(*,'(6X,A)') 'optimization matrix [time &
&depended boundary condition]:'
c1 = ibcperiod(1)
DO i = 2, nbctp
c1 = max(c1,ibcperiod(i))
END DO
WRITE(line,'(1000(I4,1X))') (i,i=1,c1)
WRITE(*,'(8X,A12,1A,A1)') '| bctp | tp:', line(1:c1*5), &
'|'
DO i = 1, nbctp
line = ' '
DO j = 1, mpara_tp
k = (opti_tp(1,j)-1)*5 + 1
c2 = opti_tp(2,j)
IF (opti_tp(3,j)==i .AND. line(k:k)==' ' .AND. c2==1) &
line(k:k+4) = 'alfa '
IF (opti_tp(3,j)==i .AND. line(k:k)==' ' .AND. c2==2) &
line(k:k+4) = 'beta '
IF (opti_tp(3,j)==i .AND. line(k:k)=='b' .AND. c2==1) &
line(k:k+4) = ' a+b '
IF (opti_tp(3,j)==i .AND. line(k:k)=='a' .AND. c2==2) &
line(k:k+4) = ' a+b '
END DO
WRITE(*,'(8X,A2,1I4,1A2,4X,1A,A1)') '| ', i, ' |', &
line(1:c1*5), '|'
END DO
END IF
! print out dependenCy between bC and bCtp
CALL show_bcdep(ismpl)
END IF
! --------------------
DEALLOCATE(unitlevel)
WRITE(*,*)
CALL alloc_inverse(ismpl)
IF (runmode>0) THEN
! memory managment (2)
WRITE(*,*) "Allocating ad arrays"
#ifdef AD
CALL g_alloc_arrays(ismpl)
#endif
#ifdef AD_RM
CALL alloc_arrays_ad(ismpl)
#endif
END IF
! finish HDF5 support, when available
CALL close_hdf5()
CLOSE(79)
RETURN
END
| inverse/read_inverse.f90 |
module prec
integer, parameter :: sp = kind(1.0)
integer, parameter :: dp = kind(1.d0)
end module prec
subroutine fMandelbrot(dat, ext, nx, ny, nmax)
use prec
implicit none
! arguments
integer, intent(in) :: nx, ny, nmax
real(kind=dp), intent(in) :: ext(4)
real(kind=dp), intent(out), dimension(nx, ny) :: dat
!f2py integer, optional, intent(in) :: nmax = 1000
! local variables
integer :: i, j, k
complex(kind=dp) :: z0, z
real(kind=dp) :: x, y
dat = nmax
!$omp parallel do private(j, x, y, z0, z, k)
do i=1, nx
do j=1, ny
x = ext(1) + (ext(2) - ext(1)) / (nx - 1.) * (i - 1.)
y = ext(3) + (ext(4) - ext(3)) / (ny - 1.) * (j - 1.)
z0 = dcmplx(x, y)
z = (0, 0)
do k=1, nmax
if (abs(z) > 2.0) then
dat(i,j) = k - 1
exit
end if
z = z**2 + z0
end do
end do
end do
!$omp end parallel do
return
end subroutine fMandelbrot
| assets/codes/post/mandelbrot/fmandelbrot.f90 |
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C Projet MICO - Riks & N.R. (ver. FORTRAN 31.03.95)
C++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
C ----Declarations--------
integer i, boucle, t, ii, type
double precision h, a, b, Vh, Vv, E, Lh, Lv, pas
double precision TOL, u, Force(1000), Du1(2), TgSwap
double precision lambda, Beta, ETA, Du(2), Du2(2)
double precision x(1000), y(1000), R(2), uu(2)
double precision norm, F(2), Kt(2,2), MAT(2)
double precision invKt(2,2), dtmKt, uut(2), lambdat, Fint(2)
double precision rac1, rac2, a1, a2, a3, test1, test2
double precision ps, ru(2), ru2(2)
C ----Donnees-------------
h = 40.
a = 24.
b = 40.
Vh = 160.
Vv = 200.
E = 70000.
Lh = 2*a
Lv = dsqrt(h**2+(b+a)**2)
TOL = 1e-3
i = 0
uu(1) = 0.
uu(2) = 0.
R(1) = 20000.
R(2) = 0.
Beta = 0.005
pas = 0.01
TgSwap = 900.
C ----Paramètres----------
write(*,*)'TOL?'
read(*,*)TOL
write(*,*)'Beta?'
read(*,*)Beta
write(*,*)'ETA max?'
read(*,*)ETAMAX
write(*,*)'pas N.R.?'
read(*,*)pas
C-------------------type=1 -> NR
C type=2 -> RC
type=1
C ----Initialisation------------------------------
t=1
x(1)=0.
y(1)=0.
Force(1)=0.
C --------------------Newton Raphson----
30 if (type.EQ.1) then
lambdat=lambda
uut(1)=uu(1)
uut(2)=uu(2)
C ----Calcul de l'incrément de Force----
if (t.GT.1) then
if ((Force(t-1)-Force(t)).LT.0) then
lambda=lambda+pas
else
lambda=lambda-pas
endif
else
lambda=lambda+pas
endif
boucle=0
ii=0
20 u=uu(1)
v=uu(2)
ii=ii+1
F(1)=(E*Vv/Lv**4)*(v*v+u*u-2*h*v+2*u*(a+b))*(v-h)
F(2)=(E*Vv/Lv**4)*(v**2+u**2-2*h*v+2*u*(a+b))*(u+a+b)
F(2)=F(2)+(8*E*Vh/Lh**4)*(u**2+2*a*u)*(u+a)
if (lambda.NE.0) then
norm=dsqrt((lambda*R(1)-F(1))**2+(lambda*R(2)-F(2))**2)
* /abs(lambda)/dsqrt(R(1)**2+R(2)**2)
else
norm=0
endif
if ((norm.GT.TOL).OR.(ii.EQ.1)) then
Kt(1,1)=E*Vv/(Lv**4)*(2*u+2*(a+b))*(v-h)
Kt(1,2)=E*Vv/(Lv**4)*((v**2+u**2-2*v*h+2*u*(a+b))
* +(v-h)*(2*v-2*h))
Kt(2,1)=E*Vv/(Lv**4)*((v**2+u**2-2*h*v+2*u*(a+b))
* +(u+a+b)*(2*u+2*(a+b)))+8*E*Vh/(Lh**4)*((2*u+2*a)
* *(u+a)+(u**2+2*a*u))
Kt(2,2)=E*Vv/(Lv**4)*(u+a+b)*(2*v-2*h)
MAT(1)=lambda*R(1)-F(1)
MAT(2)=lambda*R(2)-F(2)
dtmKt=Kt(1,1)*Kt(2,2)-Kt(1,2)*Kt(2,1)
invKt(1,1)=Kt(2,2)/dtmKt
invKt(2,2)=Kt(1,1)/dtmKt
invKt(1,2)=-1*Kt(1,2)/dtmKt
invKt(2,1)=-1*Kt(2,1)/dtmKt
Du(1)=invKt(1,1)*MAT(1)+invKt(1,2)*MAT(2)
Du(2)=invKt(2,1)*MAT(1)+invKt(2,2)*MAT(2)
if (ii.EQ.1) then
Du1(1)=Du(1)
Du1(2)=Du(2)
endif
uu(1)=uu(1)+Du(1)
uu(2)=uu(2)+Du(2)
else
boucle=1
endif
if (boucle.EQ.0) goto 20
t=t+1
Force(t)=lambda*R(1)
x(t)=uu(2)
y(t)=uu(1)
ETA=dsqrt(Du1(1)**2+Du1(2)**2)/
* dsqrt((uu(1)-uut(1))**2+(uu(2)-uut(2))**2)
else
C --------------------------Ricks Criesfield----
i=0
lambdat=lambda
uut(1)=uu(1)
uut(2)=uu(2)
lambda=(Force(t))/R(1)
boucle=0
40 u=uu(1)
v=uu(2)
Fint(1)=(E*Vv/Lv**4)*(v*v+u*u-2*h*v+2*u*(a+b))*(v-h)
Fint(2)=(E*Vv/Lv**4)*(v**2+u**2-2*h*v+2*u*(a+b))*(u+a+b)
Fint(2)=Fint(2)+(8*E*Vh/Lh**4)*(u**2+2*a*u)*(u+a)
norm=dsqrt((lambda*R(1)-Fint(1))**2+(lambda*R(2)-Fint(2))
* **2)/abs(lambda)/dsqrt(R(1)**2+R(2)**2)
if ((norm.GT.TOL).OR.(i.EQ.0)) then
i=i+1
Kt(1,1)=E*Vv/(Lv**4)*(2*u+2*(a+b))*(v-h)
Kt(1,2)=E*Vv/(Lv**4)*((v**2+u**2-2*v*h+2*u*(a+b))
* +(v-h)*(2*v-2*h))
Kt(2,1)=E*Vv/(Lv**4)*((v**2+u**2-2*h*v+2*u*(a+b))
* +(u+a+b)*(2*u+2*(a+b)))+8*E*Vh/(Lh**4)*((2*u+2*a)
* *(u+a)+(u**2+2*a*u))
Kt(2,2)=E*Vv/(Lv**4)*(u+a+b)*(2*v-2*h)
C ----Calcul de Du1-----------
MAT(1)=lambda*R(1)-Fint(1)
MAT(2)=lambda*R(2)-Fint(2)
dtmKt=Kt(1,1)*Kt(2,2)-Kt(1,2)*Kt(2,1)
invKt(1,1)=Kt(2,2)/dtmKt
invKt(2,2)=Kt(1,1)/dtmKt
invKt(1,2)=-1*Kt(1,2)/dtmKt
invKt(2,1)=-1*Kt(2,1)/dtmKt
Du1(1)=invKt(1,1)*MAT(1)+invKt(1,2)*MAT(2)
Du1(2)=invKt(2,1)*MAT(1)+invKt(2,2)*MAT(2)
C ----Calcul de Du2-----------
Du2(1)=invKt(1,1)*R(1)+invKt(1,2)*R(2)
Du2(2)=invKt(2,1)*R(1)+invKt(2,2)*R(2)
C ----Calcul de a1, a2, a3----
ru(1)=uu(1)-uut(1)
ru(2)=uu(2)-uut(2)
ru2(1)=ru(1)+Du1(1)
ru2(2)=ru(2)+Du1(2)
a1=(Beta**2)*ps(R,R)+ps(Du2,Du2)
a2=2*((lambda-lambdat)*(Beta**2)*ps(R,R)+ps(ru2,Du2))
a3=2*ps(ru,Du1)+ps(Du1,Du1)+(ps(ru,ru)+
* ((lambda-lambdat)**2)*(Beta**2)*ps(R,R)-ETA**2)
rac1=(-a2+dsqrt(a2**2-4*a1*a3))/2/a1
rac2=(-a2-dsqrt(a2**2-4*a1*a3))/2/a1
test1=uu(2)+Du1(2)+rac1*Du2(2)
test2=uu(2)+Du1(2)+rac2*Du2(2)
if ((test2-test1).GT.0) then
uu(1)=uu(1)+Du1(1)+rac2*Du2(1)
uu(2)=uu(2)+Du1(2)+rac2*Du2(2)
lambda=lambda+rac2
else
uu(1)=uu(1)+Du1(1)+rac1*Du2(1)
uu(2)=uu(2)+Du1(2)+rac1*Du2(2)
lambda=lambda+rac1
endif
else
boucle=1
endif
if (boucle.EQ.0) goto 40
ETA=ETA*dsqrt(4./i)
if (ETA.GT.ETAMAX) then
ETA=ETAMAX
endif
t=t+1
Force(t)=lambda*R(1)
x(t)=uu(2)
y(t)=uu(1)
endif
C ----Teste la tangente à la courbe:
C TG > 900 --> N.R.
C TG < 900---> R.C.
if (abs((Force(t-1)-Force(t))/(uut(2)-uu(2))).LT.TgSwap) then
type=2
else
type=1
endif
if (lambda.LT.1) goto 30
C ----Resultats-----------
open (UNIT = 1, FILE = 'rcnr_1.m', STATUS='unknown')
do 31 i=1,t
write(1,*)'x(',i,')=',x(i),';'
write(1,*)'y(',i,')=',y(i),';'
write(1,*)'P(',i,')=',Force(i),';'
31 continue
write(1,*)'figure(1), plot(x,y), grid'
write(1,*)'figure(2), plot(x,P), grid'
close (UNIT=1)
write(*,*)'t =',t
end
double precision function ps(a,b)
double precision a(2),b(2)
ps=a(1)*b(1)+a(2)*b(2)
return
end
| student/mico/orig/rc_nr.for |
!
! Copyright (C) 2007 Quantum ESPRESSO group
! This file is distributed under the terms of the
! GNU General Public License. See the file `License'
! in the root directory of the present distribution,
! or http://www.gnu.org/copyleft/gpl.txt .
!
!
!----------------------------------------------------------------------------
SUBROUTINE g2_kin ( ik )
!----------------------------------------------------------------------------
!
! ... Calculation of kinetic energy - includes the case of the modified
! ... kinetic energy functional for variable-cell calculations
!
USE kinds, ONLY : DP
USE cell_base, ONLY : tpiba2
USE klist, ONLY : xk
USE gvect, ONLY : g
USE wvfct, ONLY : g2kin, igk, npw, ecfixed, qcutz, q2sigma
!
IMPLICIT NONE
!
INTEGER, INTENT (IN) :: ik
!
! ... local variables
!
INTEGER :: ig
REAL(DP), EXTERNAL :: qe_erf
!
!
g2kin(1:npw) = ( ( xk(1,ik) + g(1,igk(1:npw)) )**2 + &
( xk(2,ik) + g(2,igk(1:npw)) )**2 + &
( xk(3,ik) + g(3,igk(1:npw)) )**2 ) * tpiba2
!
IF ( qcutz > 0.D0 ) THEN
!
DO ig = 1, npw
!
g2kin(ig) = g2kin(ig) + qcutz * &
( 1.D0 + qe_erf( ( g2kin(ig) - ecfixed ) / q2sigma ) )
!
END DO
!
END IF
!
RETURN
!
END SUBROUTINE g2_kin
| tests/apps/miniDFT/tests/src/g2_kin.f90 |
! Copyright 2015-2016 Free Software Foundation, Inc.
!
! This program is free software; you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2 of the License, or
! (at your option) any later version.
!
! This program is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
!
! You should have received a copy of the GNU General Public License
! along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
!
! Original file written by Jakub Jelinek <jakub@redhat.com> and
! Jan Kratochvil <jan.kratochvil@redhat.com>.
! Modified for the GDB testcases by Keven Boell <keven.boell@intel.com>.
subroutine foo (array1, array2)
integer :: array1 (:, :)
real :: array2 (:, :, :)
array1(:,:) = 5 ! not-filled
array1(1, 1) = 30
array2(:,:,:) = 6 ! array1-filled
array2(:,:,:) = 3
array2(1,1,1) = 30
array2(3,3,3) = 90 ! array2-almost-filled
end subroutine
subroutine bar (array1, array2)
integer :: array1 (*)
integer :: array2 (4:9, 10:*)
array1(5:10) = 1311
array1(7) = 1
array1(100) = 100
array2(4,10) = array1(7)
array2(4,100) = array1(7)
return ! end-of-bar
end subroutine
program vla_sub
interface
subroutine foo (array1, array2)
integer :: array1 (:, :)
real :: array2 (:, :, :)
end subroutine
end interface
interface
subroutine bar (array1, array2)
integer :: array1 (*)
integer :: array2 (4:9, 10:*)
end subroutine
end interface
real, allocatable :: vla1 (:, :, :)
integer, allocatable :: vla2 (:, :)
! used for subroutine
integer :: sub_arr1(42, 42)
real :: sub_arr2(42, 42, 42)
integer :: sub_arr3(42)
sub_arr1(:,:) = 1 ! vla2-deallocated
sub_arr2(:,:,:) = 2
sub_arr3(:) = 3
call foo(sub_arr1, sub_arr2)
call foo(sub_arr1(5:10, 5:10), sub_arr2(10:15,10:15,10:15))
allocate (vla1 (10,10,10))
allocate (vla2 (20,20))
vla1(:,:,:) = 1311
vla2(:,:) = 42
call foo(vla2, vla1)
call bar(sub_arr3, sub_arr1)
end program vla_sub
| src/gdb/gdb-7.11/gdb/testsuite/gdb.fortran/vla-sub.f90 |
Trudys is a Convenience Stores convenience store, part of the Tercero Dining Commons structure, in which you will find drinks, snacks, smoothies, candy, and other convenience store items, including sex condoms.
You can pay for items via cash, meal swipes (e.g. one swipe for three candy bars), or credit/debit cards.
Its a good place to go if you are too lazy to go off campus or is impractical to go off campus (such as freshmen), but a bad place to go if you actually have a car and can go to Save Mart, Safeway, or even Rite Aid or AM/PM just about anywhere is better in terms of prices, although far less convenient. Also note they charge sales tax on commercially packaged food items, so add a 7% mark up in addition to the Trudy mark up.
Trudys sister convenience stores are The Junction at Segundo and Crossroads at the Cuarto DC.
A small store (also called Trudys back then) that served sandwiches used to be located inside the DC where the computer lab is now, before the current Trudys building was built.
20080521 21:56:04 nbsp A COMMENT ABOUT TRUDYS SINCE IT LACKS A COMMENT BOX:
TRUDYS IS A FUCKING SHITHOLE.
EVERYTIME I GO THERE, I COME BACK MORE DEPRESSED AND IT DRAINS MY SOUL OF WHAT LITTLE JOY AND HAPPINESS MY INSANE CLASSES BRING ME.
Only ONE of the employees there is actually exceptional, all of the others are rude and/or utterly incompetent. Then again, anyone who willingly chooses to work at an establishment like trudys would probably intolerable to begin with. They have the worst vegetarian options IF ANY. Dont even get me started on their price markup.
If Trudys actually tried to appreciate their customers and provide a service that was genuinely interested in the well being of the students maybe I would change my opinion.
As for now and the foreseeable future, it doesnt seem like there is any chance of that happening. Users/triscuitqueen
20080607 08:56:18 nbsp Who is the exceptional employee? Users/NicholasKnoblauch
20090309 21:23:06 nbsp I bet its the tall blonde guy. Hes nice and helpful, takes the time to say hi even when hes dealing with a rush all by himself. Hes also super cool and always has KDVS on. Users/Kiki101
20100314 21:18:35 nbsp I wouldnt go to Trudys if I hadnt accidentally gotten Aggie Cash, but not that I have, I love the cookies and cream smoothie! Users/micseydel
20101002 12:20:15 nbsp Trudys is great, the people there are so friendly and polite! They explain everything you need to know about aggiecash and your swipes, and they even give you tips! Great place to get GREAT smoothies. Users/isabelnc
20101023 16:31:53 nbsp I love cookies and cream too, and the Halloween decorations! I always go to trudys when I miss lunch. Users/PrincessPeach
20120220 22:36:07 nbsp Its been a while since anyone commented about Trudys, and Im guessing it has improved because I have absolutely no complaints about it. Im in there frequently because I dont have the time to eat at the DC. Users/LilySmith
| lab/davisWiki/Trudy%27s.f |
! This file is part of flox.
! SPDX-Identifier: Apache-2.0
!> Main module of the Fortran lox interpreter
module flox
use, intrinsic :: iso_fortran_env, only : output_unit
use stdlib_io, only : getline
use stdlib_strings, only : to_string
use flox_diagnostic, only : lox_diagnostic, render, level_eof_error, operator(==)
use flox_ast, only : lox_ast
use flox_ast_printer, only : lox_ast_printer
use flox_interpreter, only : lox_interpreter, new_interpreter, lox_object, repr
use flox_resolver, only : lox_resolver, new_resolver
use flox_parser, only : lox_parser
use flox_scanner, only : lox_scanner, lox_token, check_token
use flox_terminal, only : lox_terminal
use flox_timer, only : lox_timer, format_time, tp
implicit none
private
public :: run_file, run_prompt
type :: lox
type(lox_parser) :: parser
type(lox_resolver) :: resolver
type(lox_interpreter) :: interpreter
type(lox_timer) :: timer
integer :: verbosity = 2
contains
procedure :: run
end type lox
contains
subroutine new(self)
type(lox), intent(out) :: self
call new_interpreter(self%interpreter)
call new_resolver(self%resolver, self%interpreter)
end subroutine new
!> Entry point for running a lox script from a file
subroutine run_file(filename, terminal)
!> Name of the file containing the lox script
character(len=*), intent(in) :: filename
!> Instance of the terminal output
type(lox_terminal), intent(in) :: terminal
character(len=:), allocatable :: input
type(lox_diagnostic), allocatable :: diagnostic(:)
class(lox_object), allocatable :: object
type(lox) :: instance
call new(instance)
call read_file(filename, input)
call instance%run(input, object, diagnostic)
end subroutine run_file
!> Entry point for running the lox interpreter interactively
subroutine run_prompt(terminal)
!> Instance of the terminal output
type(lox_terminal), intent(in) :: terminal
character(len=:), allocatable :: input, source, label
type(lox_diagnostic), allocatable :: diagnostic(:)
class(lox_object), allocatable :: object
type(lox) :: instance
integer :: stat, line, i
logical :: more
call new(instance)
call instance%timer%push("total")
more = .false.
source = ""
line = 0
interactive: do
if (more) then
write(output_unit, '(*(a))', advance='no') &
terminal%bold_blue // repeat(".", len(label) + 1) // &
terminal%reset // " "
else
line = line + 1
label = to_string(line)
write(output_unit, '(*(a))', advance='no') &
terminal%bold_blue // to_string(line) // &
terminal%bold // ">" // &
terminal%reset // " "
end if
call getline(input, stat)
if (stat /= 0) exit interactive
source = source // " " // input
call instance%timer%push("run")
call instance%run(source, object, diagnostic)
call instance%timer%pop
if (allocated(diagnostic)) then
more = all(diagnostic%level == level_eof_error)
if (more) cycle
do i = 1, size(diagnostic)
write(output_unit, '(a)') render(diagnostic(i), source, terminal)
end do
else if (allocated(object)) then
write(output_unit, '(a)') &
terminal%bold_green // "=>" // &
terminal%reset // " " // &
terminal%bold // repr(object) // &
terminal%reset
end if
more = .false.
source = ""
end do interactive
write(output_unit, '(a)')
call instance%timer%pop
time: block
integer :: it
real(tp) :: ttime, rtime, stime
character(len=*), parameter :: label(*) = [character(len=20):: &
& "scan", "parse", "resolve", "interpret"]
if (instance%verbosity > 0) then
ttime = instance%timer%get("total")
rtime = instance%timer%get("run")
if (rtime <= 1.0e-3_tp) exit time
write(output_unit, '(a)') "", &
& " total:"//repeat(" ", 16)//format_time(ttime), &
& " user:"//repeat(" ", 16)//format_time(ttime-rtime), &
& "system:"//repeat(" ", 16)//format_time(rtime)
end if
if (instance%verbosity > 1) then
do it = 1, size(label)
stime = instance%timer%get(label(it))
if (stime <= epsilon(0.0_tp)) cycle
write(output_unit, '(a)') &
& " - "//label(it)//format_time(stime) &
& //" ("//to_string(int(stime/rtime*100), '(i3)')//"%)"
end do
end if
end block time
end subroutine run_prompt
!> Entry point of the lox interpreter
subroutine run(self, source, object, diagnostic)
!> Instance of the lox interpreter
class(lox), intent(inout) :: self
!> Source code to interpret
character(len=*), intent(in) :: source
!> Returned object
class(lox_object), allocatable, intent(out) :: object
!> Generated diagnostic messages
type(lox_diagnostic), allocatable, intent(out) :: diagnostic(:)
type(lox_scanner) :: scanner
type(lox_ast) :: ast
type(lox_token), allocatable :: tokens(:)
integer :: i
call self%timer%push("scan")
scanner = lox_scanner()
call scanner%scan_tokens(source, tokens)
call self%timer%pop
associate(parser => self%parser)
call self%timer%push("parse")
call parser%parse(tokens, ast)
call self%timer%pop
if (allocated(parser%diag)) then
call move_alloc(parser%diag, diagnostic)
return
end if
end associate
if (self%verbosity > 1) then
block
type(lox_ast_printer) :: printer
call ast%accept(printer)
write(output_unit, '(*(a))') "AST: ", printer%string
end block
end if
associate(resolver => self%resolver)
call self%timer%push("resolve")
call ast%accept(resolver)
call self%timer%pop
if (allocated(resolver%diag)) then
call move_alloc(resolver%diag, diagnostic)
return
end if
end associate
associate(interpreter => self%interpreter)
call self%timer%push("interpret")
call ast%accept(interpreter)
call self%timer%pop
if (allocated(interpreter%diag)) then
call move_alloc(interpreter%diag, diagnostic)
return
end if
if (allocated(interpreter%local)) then
object = interpreter%local
end if
end associate
end subroutine run
!> Reads a whole file into a character string
subroutine read_file(filename, string)
!> Name of the file to read
character(len=*), intent(in) :: filename
!> Character string to store the file content
character(len=:), allocatable, intent(out) :: string
character(len=:), allocatable :: line
character(len=*), parameter :: nl = new_line('a')
integer :: io, stat
string = ""
open(file=filename, newunit=io, status='old', iostat=stat)
do while (stat == 0)
call getline(io, line, stat)
if (stat == 0) string = string // line // nl
end do
close(io)
if (is_iostat_end(stat)) stat = 0
end subroutine read_file
end module flox
| src/flox.f90 |
module SHTOOLS
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! This module contains an interface block defining all the routines
! used in the archive SHTOOLS. These are necessary in order to use
! implicitly shaped arrays with most subroutines.
!
! Copyright (c) 2005, Mark A. Wieczorek
! All rights reserved.
!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
integer, parameter :: CSPHASE_DEFAULT = 1 ! The default is to EXCLUDE the
! CONDON-SHORTLEY phase of (-1)^m
! in front of the Legendre functions.
! To use this phase function, set
! CSPHASE_DEFAULT = -1
interface
subroutine PlmBar(p, lmax, z, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:)
real*8, intent(in) :: z
integer, intent(in), optional :: csphase, cnorm
end subroutine PlmBar
subroutine PlmBar_d1(p, dp, lmax, z, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:), dp(:)
real*8, intent(in) :: z
integer, intent(in), optional :: csphase, cnorm
end subroutine PlmBar_d1
subroutine PlBar(p, lmax, z)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:)
real*8, intent(in) :: z
end subroutine PlBar
subroutine PlBar_d1(p, dp, lmax, z)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:), dp(:)
real*8, intent(in) :: z
end subroutine PlBar_d1
subroutine PlmSchmidt(p,lmax,z, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:)
real*8, intent(in) :: z
integer, intent(in), optional :: csphase, cnorm
end subroutine PlmSchmidt
subroutine PlSchmidt(p,lmax,z)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:)
real*8, intent(in) :: z
end subroutine PlSchmidt
subroutine PlmSchmidt_d1(p, dp, lmax, z, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:), dp(:)
real*8, intent(in) :: z
integer, intent(in), optional :: csphase, cnorm
end subroutine PlmSchmidt_d1
subroutine PlSchmidt_d1(p, dp, lmax, z)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:), dp(:)
real*8, intent(in) :: z
end subroutine PlSchmidt_d1
subroutine PLegendre(p,lmax,z)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:)
real*8, intent(in) :: z
end subroutine PLegendre
subroutine PLegendreA(p,lmax,z, csphase)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:)
real*8, intent(in) :: z
integer, intent(in), optional :: csphase
end subroutine PLegendreA
subroutine PLegendre_d1(p, dp, lmax, z)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:), dp(:)
real*8, intent(in) :: z
end subroutine PLegendre_d1
subroutine PLegendreA_d1(p, dp, lmax, z, csphase)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:), dp(:)
real*8, intent(in) :: z
integer, intent(in), optional :: csphase
end subroutine PLegendreA_d1
subroutine CilmPlus(cilm, gridin, lmax, nmax, mass, d, rho, gridtype, w, zero, plx, n, dref)
real*8, intent(in) :: gridin(:,:), mass, rho
real*8, intent(in), optional :: w(:), zero(:), plx(:,:), dref
real*8, intent(out) :: cilm(:,:,:), d
integer, intent(in) :: lmax, nmax, gridtype
integer, intent(in), optional :: n
end subroutine CilmPlus
subroutine Hilm(cilm, ba, gridglq, lmax, nmax, mass, r0, rho, gridtype, w, plx, zero, &
filter_type, filter_deg, lmax_calc)
real*8, intent(out) :: cilm(:,:,:)
real*8, intent(in) :: ba(:,:,:), gridglq(:,:), mass, r0, rho
real*8, intent(in), optional :: plx(:,:), zero(:), w(:)
integer, intent(in) :: lmax, nmax, gridtype
integer, intent(in), optional :: filter_type, filter_deg, lmax_calc
end subroutine Hilm
subroutine MakeGrid2d(grid, cilm, lmax, interval, nlat, nlong, norm, csphase, f, a, &
north, south, east, west)
real*8, intent(in) :: cilm(:,:,:), interval
real*8, intent(out) :: grid(:,:)
integer, intent(in) :: lmax
integer, intent(out) :: nlat, nlong
integer, intent(in), optional :: norm, csphase
real*8, intent(in), optional :: f, a, north, south, east, west
end subroutine MakeGrid2D
subroutine GLQGridCoord(latglq, longlq, lmax, nlat, nlong)
integer, intent(in) :: lmax
integer, intent(out) :: nlat, nlong
real*8, intent(out) :: latglq(:), longlq(:)
end subroutine GLQGridCoord
subroutine MakeGridGLQ(gridglq, cilm, lmax, plx, zero, norm, csphase, lmax_calc)
real*8, intent(in) :: cilm(:,:,:)
real*8, intent(in), optional :: plx(:,:), zero(:)
real*8, intent(out) :: gridglq(:,:)
integer, intent(in) :: lmax
integer, intent(in), optional :: norm, csphase, lmax_calc
end subroutine MakeGridGLQ
subroutine SHExpandGLQ(cilm, lmax, gridglq, w, plx, zero, norm, csphase, lmax_calc)
real*8, intent(in) :: w(:), gridglq(:,:)
real*8, intent(in), optional :: plx(:,:), zero(:)
real*8, intent(out) :: cilm(:,:,:)
integer, intent(in) :: lmax
integer, intent(in), optional :: norm, csphase, lmax_calc
end subroutine SHExpandGLQ
subroutine PreCompute(lmax, zero, w, plx, wisdom_file, norm, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: zero(:), w(:)
real*8, intent(out), optional :: plx(:,:)
integer, intent(in), optional :: norm, csphase, cnorm
character(*), intent(in), optional :: wisdom_file
end subroutine PreCompute
subroutine PreGLQ(x1, x2, n, zero, w)
real*8, intent(in) :: x1, x2
real*8, intent(out) :: zero(:), w(:)
integer, intent(in) :: n
end subroutine PreGLQ
integer function NGLQ(degree)
integer, intent(in) :: degree
end function NGLQ
integer function NGLQSH(degree)
integer, intent(in) :: degree
end function NGLQSH
integer function NGLQSHN(degree, n)
integer, intent(in) :: degree, n
end function NGLQSHN
subroutine SHRead(filename, cilm, lmax, skip, header, error)
character(*), intent(in) :: filename
integer, intent(out) :: lmax
real*8, intent(out) :: cilm(:,:,:)
real*8, intent(out), optional :: header(:), error(:,:,:)
integer, intent(in), optional :: skip
end subroutine SHRead
subroutine MakeMagGrid2D(rad, phi, theta, total, cilm, r0, a, f, lmax, interval, nlat, nlong, &
north, south, east, west)
real*8, intent(in) :: cilm(:,:,:), interval, r0, a, f
real*8, intent(out) :: rad(:,:), phi(:,:), theta(:,:), total(:,:)
integer, intent(in) :: lmax
integer, intent(out) :: nlat, nlong
real*8, intent(in), optional :: north, south, east, west
end subroutine MakeMagGrid2D
real*8 function SHPowerL(c, l)
real*8, intent(in) :: c(:,:,:)
integer, intent(in) :: l
end function SHPowerL
real*8 function SHPowerDensityL(c, l)
real*8, intent(in) :: c(:,:,:)
integer, intent(in) :: l
end function SHPowerDensityL
real*8 function SHCrossPowerL(c1, c2, l)
real*8, intent(in) :: c1(:,:,:), c2(:,:,:)
integer, intent(in) :: l
end function SHCrossPowerL
real*8 function SHCrossPowerDensityL(c1, c2, l)
real*8, intent(in) :: c1(:,:,:), c2(:,:,:)
integer, intent(in) :: l
end function SHCrossPowerDensityL
subroutine SHPowerSpectrum(c, lmax, spectra)
real*8, intent(in) :: c(:,:,:)
integer, intent(in) :: lmax
real*8, intent(out) :: spectra(:)
end subroutine SHPowerSpectrum
subroutine SHPowerSpectrumDensity(c, lmax, spectra)
real*8, intent(in) :: c(:,:,:)
integer, intent(in) :: lmax
real*8, intent(out) :: spectra(:)
end subroutine SHPowerSpectrumDensity
subroutine SHCrossPowerSpectrum(c1, c2, lmax, cspectra)
real*8, intent(in) :: c1(:,:,:), c2(:,:,:)
integer, intent(in) :: lmax
real*8, intent(out) :: cspectra(:)
end subroutine SHCrossPowerSpectrum
subroutine SHCrossPowerSpectrumDensity(c1, c2, lmax, cspectra)
real*8, intent(in) :: c1(:,:,:), c2(:,:,:)
integer, intent(in) :: lmax
real*8, intent(out) :: cspectra(:)
end subroutine SHCrossPowerSpectrumDensity
subroutine djpi2(dj, lmax)
integer, intent(in) :: lmax
real*8, intent(out) :: dj(:,:,:)
end subroutine djpi2
subroutine SHrtoc(rcilm, ccilm, degmax, convention, switchcs)
real*8, intent(in) :: rcilm(:,:,:)
real*8, intent(out) :: ccilm(:,:,:)
integer, intent(in), optional :: degmax, convention, switchcs
end subroutine SHrtoc
subroutine SHctor(ccilm, rcilm, degmax, convention, switchcs)
real*8, intent(in) :: ccilm(:,:,:)
real*8, intent(out) :: rcilm(:,:,:)
integer, intent(in), optional :: degmax, convention, switchcs
end subroutine SHctor
subroutine SHCilmToCindex(cilm, cindex, degmax)
real*8, intent(in) :: cilm(:,:,:)
real*8, intent(out) :: cindex(:,:)
integer, intent(in), optional :: degmax
end subroutine SHCilmToCindex
subroutine SHCindexToCilm(cindex, cilm, degmax)
real*8, intent(out) :: cilm(:,:,:)
real*8, intent(in) :: cindex(:,:)
integer, intent(in), optional :: degmax
end subroutine SHCindexToCilm
subroutine SHRotateCoef(x, cof, rcof, dj, lmax)
real*8, intent(in) :: cof(:,:), dj(:,:,:), x(3)
real*8, intent(out) :: rcof(:,:)
integer, intent(in) :: lmax
end subroutine SHRotateCoef
subroutine SHRotateRealCoef(cilmrot, cilm, lmax, x, dj)
real*8, intent(in) :: cilm(:,:,:), x(:), dj(:,:,:)
real*8, intent(out) :: cilmrot(:,:,:)
integer, intent(in) :: lmax
end subroutine SHRotateRealCoef
subroutine DHaj(n, aj)
integer, intent(in) :: n
real*8, intent(out) :: aj(:)
end subroutine DHaj
subroutine SHExpandDH(grid, n, cilm, lmax, norm, sampling, csphase, lmax_calc)
real*8, intent(in) :: grid(:,:)
real*8, intent(out) :: cilm(:,:,:)
integer, intent(in) :: n
integer, intent(out) :: lmax
integer, intent(in), optional :: norm, sampling, csphase, lmax_calc
end subroutine SHExpandDH
subroutine MakeGridDH(griddh, n, cilm, lmax, norm, sampling, csphase, lmax_calc)
real*8, intent(in) :: cilm(:,:,:)
real*8, intent(out) :: griddh(:,:)
integer, intent(in) :: lmax
integer, intent(out) :: n
integer, intent(in), optional :: norm, sampling, csphase, lmax_calc
end subroutine MakeGridDH
real*8 function MakeGridPoint(cilm, lmax, lat, longitude, norm, csphase)
real*8, intent(in) :: cilm(:,:,:), lat, longitude
integer, intent(in) :: lmax
integer, intent(in), optional :: norm, csphase
end function MakeGridPoint
real*8 function Wl(l, half, r, d)
integer, intent(in) :: l, half
real*8, intent(in) :: r, d
end function Wl
real*8 function WlCurv(l, half, r, d)
integer, intent(in) :: l, half
real*8, intent(in) :: r, d
end function WlCurv
subroutine SHExpandLSQ(cilm, d, lat, lon, nmax, lmax, norm, chi2, csphase)
real*8, intent(in) :: d(:), lat(:), lon(:)
real*8, intent(out) :: cilm(:,:,:)
integer, intent(in) :: nmax, lmax
integer, intent(in), optional :: norm, csphase
real*8, intent(out), optional :: chi2
end subroutine SHExpandLSQ
subroutine SHMultiply(shout, sh1, lmax1, sh2, lmax2, precomp, norm, csphase)
real*8, intent(out) :: shout(:,:,:)
real*8, intent(in) :: sh1(:,:,:), sh2(:,:,:)
integer, intent(in) :: lmax1, lmax2
integer, intent(in), optional :: precomp, norm, csphase
end subroutine SHMultiply
subroutine ComputeD0(D0, lmax, theta0)
real*8, intent(out) :: D0(:,:)
real*8, intent(in) :: theta0
integer, intent(in) :: lmax
end subroutine ComputeD0
subroutine ComputeDm(dllm, lmax, m, theta0)
real*8, intent(out) :: dllm(:,:)
real*8, intent(in) :: theta0
integer, intent(in) :: lmax, m
end subroutine ComputeDm
subroutine SphericalCapCoef(coef, theta, lmax)
real*8, intent(out) :: coef(:)
real*8, intent(in) :: theta
integer, intent(in), optional :: lmax
end subroutine SphericalCapCoef
real*8 function SHDeltaL(coef, lmax)
real*8, intent(in) :: coef(:)
integer, intent(in) :: lmax
end function SHDeltaL
real*8 function SHDeltaX(coef, lmax, m)
real*8, intent(in) :: coef(:)
integer, intent(in) :: lmax
integer, intent(in), optional :: m
end function SHDeltaX
subroutine EigValVecSym(ain, n, eig, evec, ul, K)
real*8, intent(in) :: ain(:,:)
integer, intent(in) :: n
real*8, intent(out) :: eig(:), evec(:,:)
character, intent(in), optional :: ul
integer, intent(in), optional :: K
end subroutine EigValVecSym
subroutine SHReturnTapersM(theta0, lmax, m, tapers, eigenvalues, shannon)
real*8, intent(in) :: theta0
integer, intent(in) :: lmax, m
real*8, intent(out) :: tapers(:,:), eigenvalues(:)
real*8, intent(out), optional :: shannon
end subroutine SHReturnTapersM
subroutine EigValSym(ain, n, eval, ul)
real*8, intent(in) :: ain(:,:)
integer, intent(in) :: n
real*8, intent(out) :: eval(:)
character, intent(in), optional :: ul
end subroutine EigValSym
integer function SHFindLWin(theta0, m, alpha, taper_number)
real*8, intent(in) :: theta0, alpha
integer, intent(in) :: m
integer, intent(in), optional :: taper_number
end function SHFindLWin
subroutine SHAdmitCorr(G, T, lmax, admit, corr, admit_error)
real*8, intent(in) :: G(:,:,:), T(:,:,:)
integer, intent(in) :: lmax
real*8, intent(out) :: admit(:), corr(:)
real*8, intent(out), optional :: admit_error(:)
end subroutine SHAdmitCorr
subroutine SHLocalizedAdmitCorr(tapers, taper_order, lwin, lat, lon, g, t, lmax, admit, corr, K, &
admit_error, corr_error, taper_wt, mtdef, k1linsig)
real*8, intent(in) :: tapers(:,:), lat, lon, g(:,:,:), t(:,:,:)
integer, intent(in) :: lwin, lmax, K, taper_order(:)
real*8, intent(out) :: admit(:), corr(:)
real*8, intent(out), optional :: admit_error(:), corr_error(:)
integer, intent(in), optional :: mtdef, k1linsig
real*8, intent(in), optional :: taper_wt(:)
end subroutine SHLocalizedAdmitCorr
subroutine EigValVecSymTri(ain, n, eig, evec, ul)
real*8, intent(in) :: ain(:,:)
integer, intent(in) :: n
real*8, intent(out) :: eig(:), evec(:,:)
character, intent(in), optional :: ul
end subroutine EigValVecSymTri
subroutine ComputeDG82(dG82, lmax, m, theta0)
real*8, intent(out) :: dG82(:,:)
real*8, intent(in) :: theta0
integer, intent(in) :: lmax, m
end subroutine ComputeDG82
integer function PlmIndex(l,m)
integer, intent(in) :: l, m
end function PlmIndex
real*8 function RandomN(idum)
integer, parameter :: K4B=selected_int_kind(9)
integer(K4B), intent(inout) :: idum
end function RandomN
real*8 function RandomGaussian(idum)
integer, parameter :: K4B=selected_int_kind(9)
integer(K4B), intent(inout) :: idum
end function RandomGaussian
subroutine Wigner3j(w3j, jmin, jmax, j2, j3, m1, m2, m3)
integer, intent(in) :: j2, j3, m1, m2, m3
integer, intent(out) :: jmin, jmax
real*8, intent(out) :: w3j(:)
end subroutine Wigner3j
subroutine SHBias(Shh, lwin, incspectra, ldata, outcspectra, save_cg)
real*8, intent(in) :: Shh(:), incspectra(:)
real*8, intent(out) :: outcspectra(:)
integer, intent(in) :: lwin, ldata
integer, intent(in), optional :: save_cg
end subroutine SHBias
subroutine SHBiasK(tapers, lwin, numk, incspectra, ldata, outcspectra, taper_wt, save_cg)
real*8, intent(in) :: tapers(:,:), incspectra(:)
real*8, intent(out) :: outcspectra(:)
integer, intent(in) :: lwin, ldata, numk
real*8, intent(in), optional :: taper_wt(:)
integer, intent(in), optional :: save_cg
end subroutine SHBiasK
real*8 function SHSjkPG0(incspectra, j, k, l, m, evec, lwin)
real*8, intent(in) :: incspectra(:), evec(:,:)
integer, intent(in) :: lwin, l, m, j, k
end function SHSjkPG0
Subroutine SHMTVarOpt0(l, tapers, lwin, kmax, Sff, var_opt, var_unit, weight_opt, unweighted_covar, nocross)
real*8, intent(in) :: tapers(:,:), Sff(:)
real*8, intent(out) :: var_opt(:), var_unit(:)
integer, intent(in) :: l, lwin, kmax
real*8, intent(out), optional :: weight_opt(:,:), unweighted_covar(:,:)
integer, intent(in), optional :: nocross
end subroutine SHMTVarOpt0
subroutine SHMultiTaperSE(mtse, sd, sh, lmax, tapers, taper_order, lmaxt, K, alpha, &
lat, lon, taper_wt, norm, csphase)
real*8, intent(out) :: mtse(:), sd(:)
real*8, intent(in) :: sh(:,:,:), tapers(:,:)
integer, intent(in) :: lmax, lmaxt, K, taper_order(:)
real*8, intent(in), optional :: alpha(:), lat, lon, taper_wt(:)
integer, intent(in), optional :: csphase, norm
end subroutine SHMultiTaperSE
subroutine SHMultiTaperCSE(mtse, sd, sh1, lmax1, sh2, lmax2, tapers, taper_order, lmaxt, K, &
alpha, lat, lon, taper_wt, norm, csphase)
real*8, intent(out) :: mtse(:), sd(:)
real*8, intent(in) :: sh1(:,:,:), sh2(:,:,:), tapers(:,:)
integer, intent(in) :: lmax1, lmax2, lmaxt, K, taper_order(:)
real*8, intent(in), optional :: alpha(:), lat, lon, taper_wt(:)
integer, intent(in), optional :: csphase, norm
end subroutine SHMultiTaperCSE
subroutine SHReadJPL(filename, cilm, lmax, error, gm, formatstring)
character(*), intent(in) :: filename
integer, intent(in) :: lmax
real*8, intent(out) :: cilm(:,:,:)
real*8, intent(out), optional :: error(:,:,:), gm(2)
character, intent(in), optional :: formatstring*6
end subroutine SHReadJPL
subroutine SHRead2(filename, cilm, lmax, gm, r0_pot, error, dot, doystart, doyend, epoch)
character(*), intent(in) :: filename
integer, intent(out) :: lmax
real*8, intent(out) :: cilm(:,:,:), gm, r0_pot
real*8, intent(out), optional :: error(:,:,:), dot(:,:,:), doystart, doyend, epoch
end subroutine SHRead2
subroutine MakeGeoidGrid(geoid, cilm, lmax, r0pot, GM, PotRef, omega, r, gridtype, &
order, nlat, nlong, interval, lmax_calc, a, f)
real*8, intent(out) :: geoid(:,:)
real*8, intent(in) :: cilm(:,:,:), r0pot, GM, r, PotRef, omega
integer, intent(in) :: lmax, order, gridtype
integer, intent(in), optional :: lmax_calc
integer, intent(out) :: nlat, nlong
real*8, intent(in), optional :: interval, a, f
end subroutine MakeGeoidGrid
subroutine PlmON(p, lmax, z, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:)
real*8, intent(in) :: z
integer, intent(in), optional :: csphase, cnorm
end subroutine PlmON
subroutine PlON(p, lmax, z)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:)
real*8, intent(in) :: z
end subroutine PlON
subroutine PlmON_d1(p, dp, lmax, z, csphase, cnorm)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:), dp(:)
real*8, intent(in) :: z
integer, intent(in), optional :: csphase, cnorm
end subroutine PlmON_d1
subroutine PlON_d1(p, dp, lmax, z)
integer, intent(in) :: lmax
real*8, intent(out) :: p(:), dp(:)
real*8, intent(in) :: z
end subroutine PlON_d1
subroutine MakeCircleCoord(coord, lat, lon, theta0, cinterval, cnum)
real*8, intent(in) :: lat, lon, theta0
real*8, intent(out) :: coord(:,:)
real*8, intent(in), optional :: cinterval
integer, intent(out), optional :: cnum
end subroutine MakeCircleCoord
subroutine SHReturnTapers(theta0, lmax, tapers, eigenvalues, taper_order)
real*8, intent(in) :: theta0
integer, intent(in) :: lmax
real*8, intent(out) :: tapers(:,:), eigenvalues(:)
integer, intent(out) :: taper_order(:)
end subroutine SHReturnTapers
complex*16 function SHSjkPG(incspectra, l, m, mprime, hj_real, hk_real, mj, mk, lwin, hkcc)
real*8, intent(in) :: incspectra(:), hj_real(:), hk_real(:)
integer, intent(in) :: lwin, l, m, mprime, mj, mk, hkcc
end function SHSjkPG
Subroutine SHMTVarOpt(l, tapers, taper_order, lwin, kmax, Sff, var_opt, var_unit, weight_opt, unweighted_covar, nocross)
real*8, intent(in) :: tapers(:,:), Sff(:)
real*8, intent(out) :: var_opt(:), var_unit(:)
integer, intent(in) :: l, lwin, kmax, taper_order(:)
real*8, intent(out), optional :: weight_opt(:,:), unweighted_covar(:,:)
integer, intent(in), optional :: nocross
end subroutine SHMTVarOpt
subroutine SHMTDebias (mtdebias, mtspectra, lmax, tapers, lwin, K, nl, lmid, n, taper_wt)
real*8, intent(out) :: mtdebias(:,:), lmid(:)
real*8, intent(in) :: mtspectra(:,:), tapers(:,:)
real*8, intent(in), optional :: taper_wt(:)
integer, intent(in) :: lmax, K, lwin, nl
integer, intent(out) :: n
end subroutine SHMTDebias
subroutine MakeGravGrid2D(rad, cilm, lmax, r0, a, f, gm, gravpot, interval, nlat, nlong, &
theta, phi, total, omega, north, south, east, west, normal_gravity)
real*8, intent(in) :: cilm(:,:,:), interval, f, r0, a, gm
real*8, intent(out) :: rad(:,:)
integer, intent(in) :: lmax
integer, intent(out) :: nlat, nlong
character*1, intent(in) :: gravpot
real*8, intent(in), optional :: omega, north, south, east, west
real*8, intent(out), optional :: theta(:,:), phi(:,:), total(:,:)
integer, intent(in), optional :: normal_gravity
end subroutine MakeGravGrid2D
real*8 function SHConfidence(l_conf, r)
real*8, intent(in) :: r
integer, intent(in) :: l_conf
end function SHConfidence
real*8 function SHMagPowerL(c, a, r, l)
real*8, intent(in) :: c(:,:,:)
real*8, intent(in) :: a, r
integer, intent(in) :: l
end function SHMagPowerL
subroutine SHMagPowerSpectrum(c, a, r, lmax, spectra)
real*8, intent(in) :: c(:,:,:)
real*8, intent(in) :: a, r
integer, intent(in) :: lmax
real*8, intent(out) :: spectra(:)
end subroutine SHMagPowerSpectrum
subroutine SHExpandDHC(grid, n, cilm, lmax, norm, sampling, csphase, lmax_calc)
complex*16, intent(in) :: grid(:,:)
complex*16, intent(out) :: cilm(:,:,:)
integer, intent(in) :: n
integer, intent(out) :: lmax
integer, intent(in), optional :: norm, sampling, csphase, lmax_calc
end subroutine SHExpandDHC
subroutine MakeGridDHC(griddh, n, cilm, lmax, norm, sampling, csphase, lmax_calc)
complex*16, intent(in) :: cilm(:,:,:)
complex*16, intent(out) :: griddh(:,:)
integer, intent(in) :: lmax
integer, intent(out) :: n
integer, intent(in), optional :: norm, sampling, csphase, lmax_calc
end subroutine MakeGridDHC
subroutine MakeGridGLQC(gridglq, cilm, lmax, plx, zero, norm, csphase, lmax_calc)
complex*16, intent(in) :: cilm(:,:,:)
real*8, intent(in), optional :: plx(:,:), zero(:)
complex*16, intent(out) :: gridglq(:,:)
integer, intent(in) :: lmax
integer, intent(in), optional :: norm, csphase, lmax_calc
end subroutine MakeGridGLQC
subroutine SHExpandGLQC(cilm, lmax, gridglq, w, plx, zero, norm, csphase, lmax_calc)
real*8, intent(in) :: w(:)
complex*16, intent(in) :: gridglq(:,:)
real*8, intent(in), optional :: plx(:,:), zero(:)
complex*16, intent(out) :: cilm(:,:,:)
integer, intent(in) :: lmax
integer, intent(in), optional :: norm, csphase, lmax_calc
end subroutine SHExpandGLQC
real*8 function SHPowerLC(c, l)
complex*16, intent(in) :: c(:,:,:)
integer, intent(in) :: l
end function SHPowerLC
real*8 function SHPowerDensityLC(c, l)
complex*16, intent(in) :: c(:,:,:)
integer, intent(in) :: l
end function SHPowerDensityLC
complex*16 function SHCrossPowerLC(c1, c2, l)
complex*16, intent(in) :: c1(:,:,:), c2(:,:,:)
integer, intent(in) :: l
end function SHCrossPowerLC
Complex*16 function SHCrossPowerDensityLC(c1, c2, l)
complex*16, intent(in) :: c1(:,:,:), c2(:,:,:)
integer, intent(in) :: l
end function SHCrossPowerDensityLC
subroutine SHPowerSpectrumC(c, lmax, spectra)
complex*16, intent(in) :: c(:,:,:)
integer, intent(in) :: lmax
real*8, intent(out) :: spectra(:)
end subroutine SHPowerSpectrumC
subroutine SHPowerSpectrumDensityC(c, lmax, spectra)
complex*16, intent(in) :: c(:,:,:)
integer, intent(in) :: lmax
real*8, intent(out) :: spectra(:)
end subroutine SHPowerSpectrumDensityC
subroutine SHCrossPowerSpectrumC(c1, c2, lmax, cspectra)
complex*16, intent(in) :: c1(:,:,:), c2(:,:,:)
integer, intent(in) :: lmax
complex*16, intent(out) :: cspectra(:)
end subroutine SHCrossPowerSpectrumC
subroutine SHCrossPowerSpectrumDensityC(c1, c2, lmax, cspectra)
complex*16, intent(in) :: c1(:,:,:), c2(:,:,:)
integer, intent(in) :: lmax
complex*16, intent(out) :: cspectra(:)
end subroutine SHCrossPowerSpectrumDensityC
subroutine SHBiasAdmitCorr(Sgt, Sgg, Stt, lmax, tapers, lwin, K, admit, corr, mtdef, taper_wt)
real*8, intent(in) :: sgt(:), sgg(:), stt(:), tapers(:,:)
integer, intent(in) :: lmax, lwin, K
real*8, intent(out) :: admit(:), corr(:)
integer, intent(in), optional :: mtdef
real*8, intent(in), optional :: taper_wt(:)
end subroutine SHBiasAdmitCorr
subroutine SHCilmToVector(cilm, vector, lmax)
real*8, intent(in) :: cilm(:,:,:)
real*8, intent(out) :: vector(:)
integer, intent(in) :: lmax
end subroutine SHCilmToVector
subroutine SHVectorToCilm(vector, cilm, lmax)
real*8, intent(out) :: cilm(:,:,:)
real*8, intent(in) :: vector(:)
integer, intent(in) :: lmax
end subroutine SHVectorToCilm
integer function YilmIndex(i, l, m)
integer, intent(in) :: i, l, m
end function YilmIndex
subroutine ComputeDMap(Dij, dh_mask, n_dh, sampling, lmax)
real*8, intent(out) :: Dij(:,:)
integer, intent(in) :: dh_mask(:,:), n_dh, sampling, lmax
end subroutine ComputeDMap
subroutine SHReturnTapersMap(tapers, eigenvalues, dh_mask, n_dh, sampling, lmax, Ntapers)
real*8, intent(out) :: tapers(:,:), eigenvalues(:)
integer, intent(in) :: dh_mask(:,:), n_dh, sampling, lmax
integer, intent(in), optional :: Ntapers
end subroutine SHReturnTapersMap
subroutine Curve2Mask(dhgrid, n, sampling, profile, nprofile, NP)
integer, intent(out) :: dhgrid(:,:)
real*8, intent(in) :: profile(:,:)
integer, intent(in) :: n, sampling, nprofile, np
end subroutine Curve2Mask
subroutine MakeEllipseCoord(coord, lat, lon, dec, A_theta, B_theta, cinterval, cnum)
real*8, intent(in) :: lat, lon, A_theta, B_theta, dec
real*8, intent(out) :: coord(:,:)
real*8, intent(in), optional :: cinterval
integer, intent(out), optional :: cnum
end subroutine MakeEllipseCoord
end interface
end module SHTOOLS
| spherical_splines/SHTOOLS/src/SHTOOLS.f95 |
Davis Municipal Code Davis Municipal Code/1 Chapter 1
GENERAL PROVISIONS
1.01.040 Provisions considered as continuations of existing ordinances.
The provisions appearing in this Code, so far as they are the same in substance as those ordinances existing at the time of the effective date of this Code, shall be considered as continuations thereof and not as new enactments. (Code 1964, § 13.02.)
| lab/davisWiki/1.01.040.f |
! PR target/65504
! { dg-do run }
program pr65504
implicit none
type :: T
character (len=256) :: a
character (len=256) :: b
end type T
type (T) :: c
type (T) :: d
c = foo ("test")
d = foo ("test")
if (trim(c%b) .ne. "foo") STOP 1
contains
type (T) function foo (x) result (v)
character(len=*), intent(in) :: x
select case (x)
case ("test")
v%b = 'foo'
case ("bazx")
v%b = 'barx'
case default
print *, "unknown"
stop
end select
end function foo
end program pr65504
| validation_tests/llvm/f18/gfortran.dg/pr65504.f90 |
! { dg-do run }
! { dg-options "-fdump-tree-original" }
! Test constructors of derived type with allocatable components (PR 20541).
!
! Contributed by Erik Edelmann <eedelmann@gcc.gnu.org>
! and Paul Thomas <pault@gcc.gnu.org>
!
Program test_constructor
implicit none
type :: thytype
integer(4) :: a(2,2)
end type thytype
type :: mytype
integer(4), allocatable :: a(:, :)
type(thytype), allocatable :: q(:)
end type mytype
type (mytype) :: x
type (thytype) :: foo = thytype(reshape ([43, 100, 54, 76], [2,2]))
integer :: y(0:1, -1:0) = reshape ([42, 99, 55, 77], [2,2])
integer, allocatable :: yy(:,:)
type (thytype), allocatable :: bar(:)
integer :: i
! Check that null() works
x = mytype(null(), null())
if (allocated(x%a) .or. allocated(x%q)) call abort()
! Check that unallocated allocatables work
x = mytype(yy, bar)
if (allocated(x%a) .or. allocated(x%q)) call abort()
! Check that non-allocatables work
x = mytype(y, [foo, foo])
if (.not.allocated(x%a) .or. .not.allocated(x%q)) call abort()
if (any(lbound(x%a) /= lbound(y))) call abort()
if (any(ubound(x%a) /= ubound(y))) call abort()
if (any(x%a /= y)) call abort()
if (size(x%q) /= 2) call abort()
do i = 1, 2
if (any(x%q(i)%a /= foo%a)) call abort()
end do
! Check that allocated allocatables work
allocate(yy(size(y,1), size(y,2)))
yy = y
allocate(bar(2))
bar = [foo, foo]
x = mytype(yy, bar)
if (.not.allocated(x%a) .or. .not.allocated(x%q)) call abort()
if (any(x%a /= y)) call abort()
if (size(x%q) /= 2) call abort()
do i = 1, 2
if (any(x%q(i)%a /= foo%a)) call abort()
end do
! Functions returning arrays
x = mytype(bluhu(), null())
if (.not.allocated(x%a) .or. allocated(x%q)) call abort()
if (any(x%a /= reshape ([41, 98, 54, 76], [2,2]))) call abort()
! Functions returning allocatable arrays
x = mytype(blaha(), null())
if (.not.allocated(x%a) .or. allocated(x%q)) call abort()
if (any(x%a /= reshape ([40, 97, 53, 75], [2,2]))) call abort()
! Check that passing the constructor to a procedure works
call check_mytype (mytype(y, [foo, foo]))
contains
subroutine check_mytype(x)
type(mytype), intent(in) :: x
integer :: i
if (.not.allocated(x%a) .or. .not.allocated(x%q)) call abort()
if (any(lbound(x%a) /= lbound(y))) call abort()
if (any(ubound(x%a) /= ubound(y))) call abort()
if (any(x%a /= y)) call abort()
if (size(x%q) /= 2) call abort()
do i = 1, 2
if (any(x%q(i)%a /= foo%a)) call abort()
end do
end subroutine check_mytype
function bluhu()
integer :: bluhu(2,2)
bluhu = reshape ([41, 98, 54, 76], [2,2])
end function bluhu
function blaha()
integer, allocatable :: blaha(:,:)
allocate(blaha(2,2))
blaha = reshape ([40, 97, 53, 75], [2,2])
end function blaha
end program test_constructor
! { dg-final { scan-tree-dump-times "deallocate" 18 "original" } }
! { dg-final { cleanup-tree-dump "original" } }
| llvm-gcc-4.2-2.9/gcc/testsuite/gfortran.dg/alloc_comp_constructor_1.f90 |
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! !
!> @brief Provide custom date type
! !
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! !
! Software context : ATMOP !
! Library Responsible : Noelia Sanchez !
!>Subroutine Author : @author Raul Dominguez
! Company : DEIMOS Space S.L. !
! Programming Language : Fortran 90 !
! Associated File Name : dtm_wrapper.f90 !
! Development Compiler and OS : Windows 7 32 bit, cygwin !
! Compiler Version : GNU gfortran 4.5.3 !
! Compiling Options : standard !
! !
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! !
! Method !
! ======
!> @details
!> This module provides the dtm_date custom type. This is required to pass
!> dates to the dtm_wrapper subroutine
! !
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! !
! !
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
! !
! Function history !
! ================ !
! !
!> @version 1.0
!> @date 15/11/2013
! Upgraded from DTM2012
! !
!++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
module t_dtm_date
!> @brief Structure to hold the date input by the user
!> @details
!>This type allows the user to enter either a MJD2000 date or a day/month/year hh:mm:sec
!>date, without the need of passing a large number of parameters.
!>The user must set a type_flag and the required variables
!>Unused variables do not need to be initialized
type dtm_date
integer :: type_flag !<1 for MJD2000 date, 2 for calendar date
real*8 :: mjd2000 !< Date in MJD2000
integer :: day !< Day
integer :: month !< Month
integer :: year !< Year
integer :: hour !< Hour
integer :: minute !< Minute
real*8 :: second !< Seconds
end type
end module
| DTM2013/lib/t_dtm_date.f90 |
module dynsoil_create_restart_mod
implicit none
contains
subroutine dynsoil_create_restart( output_path, run_name, restart_name, varname, varunits, varmissvalname, varmissval, &
xlevs,longi,latit,reg_thick,reg_x_surf,reg_tau_surf,reg_z_prof,reg_tau_prof, t,tstart )
use netcdf_io_module, only: create, close_file, def_dim, def_var, put_att_text, put_att_real, enddef, put_var_int1D, &
put_var_real1D, put_var_real3D, put_var_real4D
use netcdf
use dynsoil_physical_parameters, only: nlon, nlat, nlitho, nDSlev, scaling_factor
include 'coupler.inc'
integer, parameter:: npxl = nlon*nlat
character(len=*), intent(in):: output_path, run_name, restart_name
character(len=*), intent(in), dimension(:):: varname, varunits, varmissvalname
double precision, intent(in), dimension(:):: varmissval
double precision, intent(in), dimension(nDSlev):: xlevs
double precision, intent(in), dimension(nlon):: longi
double precision, intent(in), dimension(nlat):: latit
double precision, intent(in), dimension(nlitho,npxl):: reg_thick, reg_x_surf, reg_tau_surf
double precision, intent(in), dimension(nDSlev,nlitho,npxl):: reg_z_prof, reg_tau_prof
double precision, intent(in):: t, tstart
double precision, dimension(nlitho,npxl):: loc_reg_thick, loc_reg_tau_surf
double precision, dimension(nDSlev,nlitho,npxl):: loc_reg_z_prof, loc_reg_tau_prof
character(len=200):: fname
integer:: dimid(4), varid(15)
integer:: fid, i, j, k
!===================================== OUTPUT VARIABLES LIST: ======================================!
! OUTPUT: X, Y, litho, xlevs, t, area, litho_frac, slope, temp, runoff, h_soil, x_surf, tau_surf, !
! var #: 1 2 3 4 5 6 7 8 9 10 11 12 13 !
! z, tau, Reg_prod, Reg_eros, reg_P_diss, reg_P_eros, x_surf_eros, x_P_mean, reg_mean_age, !
! 14 15 16 17 18 19 20 21 22 !
! Li_Friv, Li_Fsp, Li_driv !
! 23 24 25 !
!===================================================================================================!
! divide variables by scaling factor (backward transformation):
where (reg_thick/=varmissval(11))
loc_reg_thick = reg_thick / scaling_factor
else where
loc_reg_thick = varmissval(11)
end where
where (reg_tau_surf/=varmissval(13))
loc_reg_tau_surf = reg_tau_surf / scaling_factor
else where
loc_reg_tau_surf = varmissval(13)
end where
! for some obscure reasons, the where loop sometimes crashes in the following cases:
do j = 1,npxl
do i = 1,nlitho
do k = 1,nDSlev
if (reg_z_prof(k,i,j) /= varmissval(14)) then
loc_reg_z_prof(k,i,j) = reg_z_prof(k,i,j) / scaling_factor
else
loc_reg_z_prof(k,i,j) = varmissval(14)
end if
if (reg_tau_prof(k,i,j) /= varmissval(15)) then
loc_reg_tau_prof(k,i,j) = reg_tau_prof(k,i,j) / scaling_factor
else
loc_reg_tau_prof(k,i,j) = varmissval(15)
end if
end do
end do
end do
! where (reg_z_prof/=varmissval(14))
! loc_reg_z_prof = reg_z_prof / scaling_factor
! else where
! loc_reg_z_prof = varmissval(14)
! end where
! where (reg_tau_prof/=varmissval(15))
! loc_reg_tau_prof = reg_tau_prof / scaling_factor
! else where
! loc_reg_tau_prof = varmissval(15)
! end where
! output (restart) file name:
fname = trim(output_path)//trim(restart_name)//trim(run_name)//'.nc'
! create output file
call create( fname , fid )
! golbal attributes
call put_att_text(fid, (/NF90_GLOBAL/), (/'title'/), (/'DynSoil initial condition (restart)'/))
call put_att_text(fid, (/NF90_GLOBAL/), (/'parent_run'/), (/trim(run_name)/))
if (use_dynsoil_steady_state) then
call put_att_text(fid, (/NF90_GLOBAL/), (/'DynSoil_mode'/), (/'steady-state'/))
else
call put_att_text(fid, (/NF90_GLOBAL/), (/'DynSoil_mode'/), (/'dynamic'/))
end if
call put_att_real(fid, (/NF90_GLOBAL/), (/'run_duration_yr'/), (/real(t)/))
call put_att_real(fid, (/NF90_GLOBAL/), (/'run_time_yr'/), (/real(t-tstart)/))
! define dimensions
call def_dim( fid , varname(1:4), (/nlon,nlat,nlitho,nDSlev/) , dimid )
! define dimension variables
call def_var( fid , varname(1:1), (/NF90_FLOAT/), dimid(1:1) , varid(1:1) )
call def_var( fid , varname(2:2), (/NF90_FLOAT/), dimid(2:2) , varid(2:2) )
call def_var( fid , varname(3:3), (/NF90_INT/), dimid(3:3) , varid(3:3) )
call def_var( fid , varname(4:4), (/NF90_FLOAT/), dimid(4:4) , varid(4:4) )
! define other variables
call def_var( fid , varname(11:13), (/NF90_FLOAT/), dimid(1:3) , varid(11:13) ) ! h_soil, x_surf, tau_surf
call def_var( fid , varname(14:15), (/NF90_FLOAT/), dimid , varid(14:15) ) ! z_prof, tau_prof
! put dimension attributes:
call put_att_text( fid, varid(1:1), (/'axis'/), (/'X'/) )
call put_att_text( fid, varid(1:1), (/'nav_model'/), (/'Default grid'/) )
call put_att_text( fid, varid(2:2), (/'axis'/), (/'Y'/) )
call put_att_text( fid, varid(2:2), (/'nav_model'/), (/'Default grid'/) )
call put_att_text( fid, varid(4:4), (/'axis'/), (/'Z'/) )
call put_att_text( fid, varid(4:4), (/'positive'/), (/'down'/) )
! put attributes
call put_att_text( fid , (/varid(1:4),varid(11:15)/) , (/'name'/) , (/varname(1:4),varname(11:15)/) )
call put_att_text( fid , (/varid(1:4),varid(11:15)/) , (/'units'/) , (/varunits(1:4),varunits(11:15)/) )
call put_att_real( fid , varid(11:15) , varmissvalname(11:15) , real(varmissval(11:15)) )
! end of definition
call enddef( fid )
! put variables
call put_var_real1D( fid, varid(1), real(longi) )
call put_var_real1D( fid, varid(2), real(latit) )
call put_var_int1D( fid, varid(3), (/(j,j=1,nlitho)/) )
call put_var_real1D( fid, varid(4), real(xlevs) )
call put_var_real3D( fid, varid(11), real(reshape(loc_reg_thick, shape=(/nlon,nlat,nlitho/), order=(/3,1,2/))) )
call put_var_real3D( fid, varid(12), real(reshape(reg_x_surf, shape=(/nlon,nlat,nlitho/), order=(/3,1,2/))) )
call put_var_real3D( fid, varid(13), real(reshape(loc_reg_tau_surf, shape=(/nlon,nlat,nlitho/), order=(/3,1,2/))) )
call put_var_real4D( fid, varid(14), real(reshape(loc_reg_z_prof, shape=(/nlon,nlat,nlitho,nDSlev/), order=(/4,3,1,2/))) )
call put_var_real4D( fid, varid(15), real(reshape(loc_reg_tau_prof, shape=(/nlon,nlat,nlitho,nDSlev/), order=(/4,3,1,2/))) )
! close output file
call close_file( fid )
end subroutine
end module
| source/dynsoil_create_restart.f90 |
subroutine submodel_bc(iflg)
!***********************************************************************
! Copyright, 2004, The Regents of the University of California.
! This program was prepared by the Regents of the University of
! California at Los Alamos National Laboratory (the University) under
! contract No. W-7405-ENG-36 with the U.S. Department of Energy (DOE).
! All rights in the program are reserved by the DOE and the University.
! Permission is granted to the public to copy and use this software
! without charge, provided that this Notice and any statement of
! authorship are reproduced on all copies. Neither the U.S. Government
! nor the University makes any warranty, express or implied, or
! assumes any liability or responsibility for the use of this software.
!!**********************************************************************
!D1
!D1 PURPOSE
!D1
!D1 To create new "flow" macro to represent boundary conditions on
!D1 extracted submodel.
!D1
!**********************************************************************
!D2
!D2 REVISION HISTORY
!D2
!D2 FEHM Version 2.20
!D2
!D2 Initial implementation: Date 9-Jan-02, Programmer: George Zyvoloski
!D2
!D2 $Log: /pvcs.config/fehm90/src/submodel_bc.f_a $
!D2
!**********************************************************************
!D3
!D3 REQUIREMENTS TRACEABILITY
!D3
!D3 2.3.7 Sources and sinks
!D3 2.6 Provide Input/Output Data Files
!D3 3.0 INPUT AND OUTPUT REQUIREMENTS
!D3
!**********************************************************************
!D4
!D4 SPECIAL COMMENTS AND REFERENCES
!D4
!D4 Requirements from SDN: 10086-RD-2.20-00
!D4 SOFTWARE REQUIREMENTS DOCUMENT (RD) for the
!D4 FEHM Application Version 2.20
!D4
!**********************************************************************
use comflow
use davidi
use comji
use comfi
use comgi
use comxi
use comei
use comdi
use comii
use comci
use combi
use comdti
use comki
use comai
implicit none
integer, allocatable :: kq_dum(:), icount(:)
integer i,j,ii,jj,kb,i1,i2,neqp1,max_subboun
integer izone1,izone2,iflg,ibnd,iroot,idsubm
integer idsubmc,isubmd,isubmodel0,open_file
integer mi,ik,ityps,itemp,ic
integer nmatavw,izik
real*8 subflux,aiped, flux_gh, tref, pres_gh
real*8 head_value, parm1, parm2, parm3
logical null1
character*4 keyword
character*9 temp_name
character*4 dsubm
character*100 submod_root
character*120 submod_name
save keyword,izone1,izone2
parameter(aiped=1.d02,max_subboun = 50)
parameter(temp_name = 'subm_temp')
c
save submod_root, iroot, icount
if(isubbc.eq.2) then
if(iflg.eq.0) then
c
c create filenamne
c
if (.not. allocated(submodfile)) then
c
c this should be the fist time called
c
allocate (submodfile(max_subboun))
allocate (isubmodelfile(max_subboun))
allocate (isubmodnamlen(max_subboun))
allocate (submod_filename(max_subboun))
allocate (izonesub1(max_subboun))
allocate (itypsd(max_subboun))
allocate (keyms1(max_subboun),keyms2(max_subboun))
allocate (keyms3(max_subboun),keyms4(max_subboun))
allocate (iflux_list(n0))
allocate (icount(max_subboun))
icount = 0
isubmodel = 0
submodfile = 0
isubmodelfile = 0
isubmodnamlen = 0
submod_filename = ''
if (null1(root_name)) then
! Use file root name
if (nmfil(9) .ne. nmfily(3) .and. nmfil(9) .ne. ' ')
& then
call file_prefix(nmfil(9), iroot)
if (iroot .gt. 100) iroot = 100
submod_root(1:iroot) = nmfil(9)(1:iroot)
else
if (nmfil(5) .ne. nmfily(3) .and. nmfil(5)
& .ne. ' ') then
call file_prefix(nmfil(5), iroot)
if (iroot .gt. 100) iroot = 100
submod_root(1:iroot) = nmfil(5)(1:iroot)
else
if (nmfil(2)(1:1) .eq. ' ' ) then
write (ierr, *) 'FILE ERROR: nmfil2 file: ',
& nmfil(2), ' unable to ',
& 'determine submod file prefix'
stop
else
call file_prefix(nmfil(2), iroot)
if (iroot .gt. 100) iroot = 100
submod_root(1:iroot) = nmfil(2)(1:iroot)
end if
end if
endif
else
iroot = len_trim (root_name)
if (iroot .gt. 100) iroot = 100
submod_root(1:iroot) = root_name(1:iroot)
end if
endif
c
c
c read input parameters
c
isubmd = 0
isubmodel0 = isubmodel
itypsd = 0
keyms1 = ''
keyms2 = ''
keyms3 = ''
keyms4 = ''
do
read(inpt,'(a80)') wdd1
if(null1(wdd1)) exit
c create a file for each submodel type
isubmd = isubmd + 1
isubmodel = isubmodel + 1
write(dsubm,'(i4.4)') isubmodel
submod_name = ''
submod_name(1:iroot) = submod_root(1:iroot)
submod_name(iroot+1:iroot+1) ='.'
submod_name(iroot+2:iroot+5) = dsubm(1:4)
submod_name(iroot+6:iroot+11) = '.wflow'
isubmodnamlen(isubmodel)= iroot+11
submod_filename(isubmodel) =
& submod_name(1:isubmodnamlen(isubmodel))
c
c complete name here
c
isubmodelfile(isubmodel) =
& open_file(submod_filename(isubmodel), 'unknown')
write(isubmodelfile(isubmodel),*) ' '
read(wdd1,*) keyms1(isubmd),keyms2(isubmd),
& keyms3(isubmd),keyms4(isubmd)
if(keyms4(isubmd).eq.'type') then
read(wdd1,*) keyms1(isubmd),keyms2(isubmd),
& keyms3(isubmd),keyms4(isubmd),itypsd(isubmd)
endif
end do
allocate (kq_dum(n0))
kq_dum = 0
igroup = 1
narrays = 1
itype(1) = 4
default(1) = 0
igroup = 1
call initdata2( inpt, ischk, n0, narrays,
& itype, default, macroread(8), macro, igroup, ireturn,
& i4_1 = kq_dum(1:n0))
c
c write out information to the opened file
c
do i = 1, n0
isubmd = kq_dum(i)
if(isubmd.ne.0) then
j = isubmodel0 + isubmd
c icount > 0 will indicate that this model has been used
icount(j) = icount(j) + 1
if(keyms4(isubmd).ne.'type') then
write(isubmodelfile(j),301) i,isubmd,keyms1(isubmd)
& ,keyms2(isubmd),keyms3(isubmd),keyms4(isubmd)
else
write(isubmodelfile(j),301) i,isubmd,
& keyms1(isubmd),keyms2(isubmd),keyms3(isubmd),
& keyms4(isubmd),itypsd(isubmd)
endif
endif
enddo
do j = isubmodel0+1,isubmodel
write(isubmodelfile(j),'(a4)') 'end '
write(isubmodelfile(j),'(8(1x,i9))') (izonef(ik),ik=1,n0)
close (isubmodelfile(j))
enddo
301 format(1x,i9,1x,i4,4(1x,a5),1x,2i5)
c close file
deallocate(kq_dum)
else if(iflg.eq.2) then
c
c read data type and printout new flow macros
c
neqp1 = neq+1
nmatavw=ldna
isubmd = 1
do mi = 1, isubmodel
isubmodelfile(mi) = open_file(submod_filename(mi), 'old')
if (icount(mi) .eq. 0) then
c The model wasn't used, close and delete file
close (isubmodelfile(mi), status = 'DELETE')
write (ierr, 320) mi
if (iout .ne. 0) write (iout, 320) mi
if (iptty .ne. 0) write (iptty, 320) mi
320 format (/, ' WARNING : wflow model ', i2,
& ' was not assigned to any nodes - file deleted')
else
c Can't use file identifiers from before
c open(isubmodelfile(mi),
c & file = subm_name(1:j),status = 'unknown')
c
c read zonefile
c
ityps = 0
j = 0
read(isubmodelfile(mi),'(a4)') keyword
read(isubmodelfile(mi),301) i,isubmd,keyms1(1),
& keyms2(1),keyms3(1),keyms4(1)
if(keyms4(1).eq.'type') then
read(isubmodelfile(mi),301) i,isubmd,keyms1(1),
& keyms2(1),keyms3(1),keyms4(1),ityps
endif
rewind isubmodelfile(mi)
do
read(isubmodelfile(mi),'(a4)') keyword
if(keyword.eq.'end ') then
read (isubmodelfile(mi),'(8(1x,i9))')
& (izonef(ik),ik=1,n0)
exit
endif
enddo
rewind isubmodelfile(mi)
itemp = open_file(temp_name, 'unknown')
read(isubmodelfile(mi),'(a4)') keyword
if(ityps.eq.0) then
write(itemp,'(a4)')'flow'
else if(ityps.ne.0) then
write(itemp,'(a4)')'flo3'
endif
ic = 1
do
read(isubmodelfile(mi),'(a4)') keyword
if(keyword.eq.'end ') then
exit
else
backspace isubmodelfile(mi)
if(ityps.eq.0) then
read(isubmodelfile(mi),301) ik,isubmd,
& keyms1(isubmd),keyms2(isubmd),
& keyms3(isubmd),keyms4(isubmd)
else
read(isubmodelfile(mi),301) ik,isubmd,
& keyms1(isubmd),keyms2(isubmd),
& keyms3(isubmd),keyms4(isubmd),ityps
endif
c Key words may be identified by a unique subset of the string
if(keyms1(isubmd)(1:1).eq.'p' .or.
& keyms1(isubmd)(1:1).eq.'P') then
c Pressure
parm1 = phi(ik)
else if(keyms1(isubmd)(1:1).eq.'h' .or.
& keyms1(isubmd)(1:1).eq.'H') then
c Head
call headctr(4,ik,phi(ik),head_value)
parm1 = head_value
else if(keyms1(isubmd)(1:1).eq.'f' .or.
& keyms1(isubmd)(1:1).eq.'F') then
c Flux
if(ka(ik).eq.0) then
izik = izonef(ik)
i1 = nelm(ik)+1
i2 = nelm(ik+1)
parm1 = 0.0
do jj = i1,i2
kb = nelm(jj)
if(izonef(kb).ne.izik) then
parm1 = parm1 +
& a_axy(jj-neqp1+nmatavw)
endif
enddo
else
parm1 = sk(ik)
endif
endif
if(keyms2(isubmd)(1:1).eq.'s' .or.
& keyms2(isubmd)(1:1).eq.'S') then
c Saturation
if(ifree.eq.0.and.irdof.eq.13) then
parm2 = 1.0
else
parm2 = s(ik)
endif
else if(keyms2(isubmd)(1:1).eq.'t' .or.
& keyms2(isubmd)(1:1).eq.'T') then
c Temperature
parm2 = -t(ik)
else if(keyms2(isubmd)(1:1).eq.'e' .or.
& keyms2(isubmd)(1:1).eq.'E') then
c Enthalpy
parm2 = enlf(ik)
else if(keyms2(isubmd)(1:1).eq.'w' .or.
& keyms2(isubmd)(1:1).eq.'W') then
c Water only source
parm2 = 1.0
else if(keyms2(isubmd)(1:1).eq.'a' .or.
& keyms2(isubmd)(1:1).eq.'A') then
c Water only source
parm2 = -1.0
else
write(ierr, 350) 2, trim(keyms2(isubmd)), mi
if (iout .ne. 0) write(iout, 350) 2,
& trim(keyms2(isubmd)), mi
if (iptty .ne. 0) write(iptty, 350) 2,
& trim(keyms2(isubmd)), mi
c The model wasn't used, close and delete file
close (isubmodelfile(mi), status = 'DELETE')
go to 399
endif
c Impedance key words need 4 characters, to identify type
if (keyms1(isubmd).eq.'flux') then
parm3 = 0.e0
else if(keyms3(isubmd).eq.'imph') then
parm3 = 1.e00
else if(keyms3(isubmd).eq.'impl') then
parm3 = 1.e-4
else if(keyms3(isubmd).eq.'impn') then
parm3 = -1.e00
else
parm3 = 1.e02
endif
ic = ic+1
write(itemp,401)ik,ik,1,parm1,parm2,parm3,ityps
endif
enddo
350 format (/, ' WARNING : Invalid Keyword ', i1, ' "',
& a, '", output not written for wflow model ', i2)
write(itemp,*)
ic = ic+1
rewind isubmodelfile(mi)
rewind itemp
do i = 1,ic
read(itemp,'(a80)') wdd1(1:80)
write(isubmodelfile(mi),'(a80)') wdd1(1:80)
enddo
close(isubmodelfile(mi))
399 close(itemp, status = 'DELETE')
endif
enddo
endif
401 format(2(1x,i8),1x,i3,1p,1x,g15.7,0p,f10.4,1p,g12.4,i5)
return
endif
c tradional submodel code
if(iflg.eq.0) then
c
c set up output files and unit numbers
c
c Assign file unit numbers and determine output filenames
isubm = nufilb(24)
if (null1(root_name)) then
if (nmfil(5) .ne. nmfily(3) .and. nmfil(5) .ne. ' ') then
c Prefix from output file name
call file_prefix(nmfil(5), iroot)
if (iroot .gt. 94) iroot = 94
nmfil(24) = nmfil(5)(1:iroot) // suffix(24)
else
c Use default filenames "fehmn.subbc"
if (nmfil(24)(1:1) .eq. ' ' ) then
write (ierr, *) 'FILE ERROR: nmfil24 file: ',
. nmfil(24),
. ' unable to determine submodel file name'
stop
end if
endif
else
iroot = len_trim (root_name)
if (iroot .gt. 94) iroot = 94
nmfil(24) = root_name(1:iroot) // suffix(24)
end if
open(isubm, file = nmfil(24), status = cstats(24))
c read input parameters
read(inpt,'(a80)') wdd1
izone1 = 0
izone2 = 0
read(wdd1,*,end=10) keyword,izone1,izone2
go to 20
10 izone2=0
20 if(keyword.ne.'flux'.and.keyword.ne.'head'
& .and.keyword.ne.'pres'.and.keyword.ne.'flow'.and.
& keyword.ne.'init'.and.keyword.ne.'flgh') then
write (ierr, *) '>>>> error in keyword for macro subm <<<<'
if (iout .ne. 0) then
write(iout,*)
write(iout,*) '>>>> error in keyword for macro subm <<<<'
end if
if(iptty.ne.0) then
write(iptty,*)'>>>> error in keyword for macro subm <<<<'
endif
stop
endif
if(keyword.eq.'init') then
write(isubm, 1000) 'pres', verno, jdate, jtime, icnl
else if(keyword.eq.'flgh') then
write(isubm, 1000) 'flow', verno, jdate, jtime, icnl
else
write(isubm, 1000) 'flow', verno, jdate, jtime, icnl
endif
1000 format (a4,' Submodel BCs ', a30, 3x, a11, 3x, a8, i4)
else if(iflg.eq.1) then
c
c save zonefile for submodel
c
allocate(izonesubm(neq))
izonesubm = 0
do i=1,neq
if(izonef(i).eq.izone1) izonesubm(i)=izone1
if(izone2.ne.0.and.izonef(i).eq.izone2) izonesubm(i)=izone2
enddo
else if(iflg.eq.2) then
c
c create flow macro for submodel
c
neqp1 = neq+1
if(keyword.eq.'flgh') then
c print out all generalized head bc
tref = crl(6,1)
do ii = 1,ngh
i = node_gh(ii)
call headctr(5,i,pres_gh,pflow_gh(ii))
flux_gh = wellim_gh(ii)*(phi(i)-pres_gh)
write(isubm,1998)
& i,i,flux_gh,tref,idir_gh(ii),cord(i,1),cord(i,2),
& cord(i,3),wellim_gh(ii)
enddo
1998 format(2i10,' 1 ',1x,1pg18.9,1x,g9.3,' 1. ',i3,' ',
& 3(g12.6,1x),' k*den/vis*(A/d) ',g10.4)
write(isubm,*)
write(isubm,'(a4)') 'stop'
else if(keyword.eq.'init') then
do i=1,neq
if(izonesubm(i).eq.izone1) then
if(ihead.ne.0) then
write(isubm,1999) i,i,head(i),t(i),
& cord(i,1),cord(i,2),cord(i,3),izone1
else
write(isubm,1999) i,i,phi(i),t(i),
& cord(i,1),cord(i,2),cord(i,3),izone1
end if
end if
enddo
1999 format(2i10,' 1 ',1x,1pg18.9,1x,g9.2,' 1 # ',
& 3(g12.6,1x),'z ',i5)
write(isubm,*)
write(isubm,'(a4)') 'stop'
elseif(keyword.eq.'flow') then
do i=1,neq
if(izonesubm(i).eq.izone1) then
if(ihead.ne.0) then
write(isubm,2000) i,i,head(i),aiped,
& cord(i,1),cord(i,2),cord(i,3),izone1
else
write(isubm,2000) i,i,phi(i),
& aiped,cord(i,1),cord(i,2),cord(i,3),izone1
end if
end if
enddo
else if(keyword.ne.'flux') then
c set pressure boundary conditions
do i=1,neq
if(izonesubm(i).eq.izone1) then
i1=nelm(i)+1
i2=nelm(i+1)
do ii=i1,i2
kb=nelm(ii)
if(izonesubm(kb).ne.izone1) then
go to 30
endif
enddo
go to 40
30 continue
if(keyword.eq.'head') then
write(isubm,2000) i,i,head(i),aiped,
& cord(i,1),cord(i,2),cord(i,3),izone1
else if(keyword.eq.'pres') then
if(ico2.lt.0) then
write(isubm,2000) i,i,phi(i),aiped,
& cord(i,1),cord(i,2),cord(i,3),izone1
else
if(itsat.le.10) then
write(isubm,2001) i,i,phi(i),-t(i),aiped,
& cord(i,1),cord(i,2),cord(i,3),izone1
else if(itsat.gt.10) then
write(isubm,2002) i,i,phi(i),t(i),aiped,
& cord(i,1),cord(i,2),cord(i,3),izone1
endif
endif
end if
2000 format(2i10,' 1 ',1x,1pg18.9,' 1. ',g9.2,' # ',
& 3(g12.6,x), 'z ',i5)
2001 format(2i10,' 1 ',1x,1pg18.9,1x,g11.4,1x,g9.2,' # ',
& 3(g12.6,x), 'z ',i5)
2002 format(2i10,' 1 ',1x,1pg18.9,1x,g11.4,1x,g9.2,' # ',
& 3(g12.6,x), 'z ',i5,' ice')
endif
40 continue
enddo
write(isubm,*)
write(isubm,'(a4)') 'stop'
else if (keyword.eq.'flux') then
c zvd 16-Mar-09 remove sum over a_axy, just want boundary source/sink
c and don't need to consider if neighbor is in excluded zone
c else if(izone2.ne.0) then
c code when submodel zone and other domain is specified
c do i=1,neq
c if(izonesubm(i).eq.izone1) then
c first add existing flux(recharge)
c gaz subflux = sk(i)
c subflux = 0.0d00
c ibnd = 0
c i1=nelm(i)+1
c i2=nelm(i+1)
c do ii=i1,i2
c kb=nelm(ii)
c if(izonesubm(kb).eq.izone2) then
c subflux = subflux+a_axy(ii-neqp1)
c ibnd = 1
c endif
c enddo
c if(ibnd.ne.0) then
c write(isubm,2000) i,i,subflux,0.0d00,
c & cord(i,1),cord(i,2),cord(i,3), izone1
c endif
c endif
c enddo
c write(isubm,*)
c write(isubm,'(a4)') 'stop'
c else if(izone2.eq.0) then
c code when only submodel zone is specified
do i=1,neq
if(izonesubm(i).eq.izone1) then
c first add existing flux(recharge)
c ibnd = 0
ibnd = 1
subflux = sk(i)
c i1=nelm(i)+1
c i2=nelm(i+1)
c do ii=i1,i2
c kb=nelm(ii)
c if(izonesubm(kb).ne.izone1) then
c subflux = subflux+a_axy(ii-neqp1)
c ibnd = 1
c endif
c enddo
if(ibnd.ne.0) then
write(isubm,2000) i,i,subflux,0.0d00,
& cord(i,1),cord(i,2),cord(i,3), izone1
endif
endif
enddo
write(isubm,*)
write(isubm,'(a4)') 'stop'
endif
c end of major if block
deallocate(izonesubm)
endif
return
end
| src/submodel_bc.f |
!
! Copyright 2019 Yuta Hirokawa (University of Tsukuba, Japan)
!
! Licensed under the Apache License, Version 2.0 (the "License");
! you may not use this file except in compliance with the License.
! You may obtain a copy of the License at
!
! http://www.apache.org/licenses/LICENSE-2.0
!
! Unless required by applicable law or agreed to in writing, software
! distributed under the License is distributed on an "AS IS" BASIS,
! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
! See the License for the specific language governing permissions and
! limitations under the License.
!
program test_fortran_bindings
use cbslf
integer, parameter :: array_size = 100000
real :: source_stack_array(array_size), dest_stack_array(array_size)
real, allocatable :: source_heap_array(:), dest_heap_array(:), dest_heap_array2(:)
character(128) :: source_string, dest_string
character(*), parameter :: cname = 'data_fortran.zst'
allocate(source_heap_array(array_size))
allocate(dest_heap_array(array_size))
call random_number(source_stack_array)
call random_number(source_heap_array)
source_string = 'abcdefgABCDEFG%'
dest_string = ''
print *, 'serialize...'
call serialize
print *, 'deserialize...'
call deserialize
print *, 'compare...'
if (.not. compare_real_array(array_size, source_stack_array, dest_stack_array)) then
print *, 'fail: compare stack array'
stop 1
end if
if (.not. compare_real_array(array_size, source_heap_array, dest_heap_array)) then
print *, 'fail: compare heap array'
stop 1
end if
if (.not. compare_real_array(array_size, source_heap_array, dest_heap_array2)) then
print *, 'fail: compare heap array'
stop 1
end if
if (trim(source_string) /= trim(dest_string)) then
print *, 'fail: compare string'
stop 1
end if
contains
subroutine serialize
implicit none
type(cbslf_context) :: ctx
integer(4) :: errcode
ctx = cbslf_open(cbslf_store_mode, cname, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_open(store)'
stop 1
end if
call cbslf_set_compression_level(ctx, 10, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_set_compression_level'
stop 1
end if
call cbslf_write(ctx, source_stack_array, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_write(stack array)'
stop 1
end if
call cbslf_write(ctx, source_heap_array, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_write(heap array)'
stop 1
end if
call cbslf_write(ctx, source_heap_array, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_write(heap array2)'
stop 1
end if
call cbslf_write(ctx, source_string, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_write(string)'
stop 1
end if
call cbslf_close(ctx)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_close'
stop 1
end if
end subroutine
subroutine deserialize
implicit none
type(cbslf_context) :: ctx
integer(4) :: errcode
ctx = cbslf_open(cbslf_load_mode, cname, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_open(load)'
stop 1
end if
call cbslf_read(ctx, dest_stack_array, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_read(stack array)'
stop 1
end if
call cbslf_read(ctx, dest_heap_array, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_read(heap array)'
stop 1
end if
call cbslf_record_heap(ctx, dest_heap_array2, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_record_heap(heap array2)'
stop 1
end if
call cbslf_read(ctx, dest_string, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_read(string)'
stop 1
end if
call cbslf_close(ctx, errcode)
if (errcode /= cbslf_success) then
print *, 'fail: cbslf_close'
stop 1
end if
end subroutine
function compare_real_array(n, a, b) result(ret)
implicit none
integer, intent(in) :: n
real, intent(in) :: a(n), b(n)
logical :: ret
integer :: i
do i=1,n
ret = (abs(a(i) - b(i)) <= epsilon(a(i)))
end do
end function
end program
| tests/fortran_bindings.f90 |
module bvp_solvers
contains
subroutine solve_bvp_direct(x, u_left, u_right, u)
use problem, only: f
implicit none
real(kind=8), intent(in) :: x(0:)
real(kind=8), intent(in) :: u_left, u_right
real(kind=8), intent(out) :: u(0:)
! decleare local variables and continue writing this code...
end subroutine solve_bvp_direct
end module bvp_solvers
| uwhpsc/homeworks/project/part1/bvp_solvers.f90 |
SUBROUTINE TRD1C(IC,PD,NGROUP,NLFTP,UDV,ILOOP,SCR1,DIT,NLFT,NOUE,
CRLBR SPR94003 9/94
CRLBR1 MODAL,PNL)
1 MODAL,PNL,ISKIP)
C
C THIS ROUTINE STEPS INTEGRATION PROCEDURE
C
C THIS ROUTINE IS SUITABLE FOR SINGLE PRECISION OPERATION
C
LOGICAL NOPD
C
INTEGER DIT1,PNL1,PNL
INTEGER PD,UDV,SCR1,DIT,SYSBUF,FILE,IZ(1),MCB(7),IPNL(7)
CRLBR SPR94003 9/94
CRLBR INTEGER SUBNAM(2)
INTEGER SUBNAM(2), MOUTPU(7)
C
COMMON /BLANK /DUMMY(4), NCOL
CRLBR SPR94003 9/94
CRLBR COMMON /SYSTEM/SYSBUF
COMMON /SYSTEM/SYSBUF, NNOUT, ISYSTM(79), ICPFLG
COMMON /ZZZZZZ/Z(1)
COMMON /PACKX /IT1,IT2,II,JJ,INCR
COMMON /TRDXX /IK(7),IDUM(14),ISCR1,ISCR2,ISCR3,ISCR4,ISCR5,ISCR6,
1 IOPEN,ISYM,TO,NOPD,ISPNL
COMMON /UNPAKX/IT3,III,JJJ,INCR1
COMMON /TRDD1 /NLFT1,DIT1,NLFTP1,NOUT,ICOUNT,ILOOP1,MODAL1,NZ,
1 ICORE,IU2,IP4,IPNL,NMODES,NSTEP,PNL1,IST,IU1,
2 DELTAT,IFRST
C
EQUIVALENCE (Z(1),IZ(1))
C
DATA SUBNAM /4HTRD1,1HC/
CRLBNB SPR94003 9/94
DATA IOUTPU, ISCR9 /203, 309/
CRLBNE
C
C ----------------------------------------------------------------------
C
C INITIALIZE
C
NROW = IK(3)
IT1 = 1
IT2 = 1
II = 1
JJ = NROW
INCR = 1
IT3 = 1
III = 1
JJJ = NROW
INCR1 = 1
NZ = KORSZ(Z)
IGROUP= NZ -3*NGROUP +1
IBUF1 = IGROUP -SYSBUF
IBUF2 = IBUF1 -SYSBUF
IBUF3 = IBUF2 -SYSBUF
IBUF4 = IBUF3-SYSBUF
IBUF5 = IBUF4-SYSBUF
IBUF6 = IBUF5-SYSBUF
IBUF7 = IBUF6-SYSBUF
IBUF8 = IBUF7 -SYSBUF
CRLBNB SPR94003 9/94
IF (NLFTP .EQ. 0) IBUF8 = IBUF7
IBUF9 = IBUF8 - SYSBUF
IBUFA = IBUF9 - SYSBUF
IF (ICPFLG .EQ. 0) IBUFA = IBUF8
IF (ICPFLG .NE. 0 .AND. ISKIP .EQ. 1) IBUFA = IBUF9
NZ = IBUFA - 1
CRLBNE
CRLBD SPR94003 9/94 NZ = IBUF7-1
CRLBD SPR94003 9/94 IF(NLFTP .NE. 0) NZ = IBUF8-1
IOPEN = 0
CRLBR SPR94003 9/94 ICRQ = 14*NROW + 1 - NZ
ICRQ = 14*(NROW+1) + 1 - NZ
IF(ICRQ.GT.0) GO TO 430
CRLBR SPR94003 9/94 IU1=0
IU1=1
CRLBR SPR94003 9/94 IU2= IU1+NROW
IU2= IU1+NROW + 1
CRLBR SPR94003 9/94 IU3= IU2+ NROW
IU3= IU2+ NROW + 1
CRLBR SPR94003 9/94 IP1= IU3+ NROW
IP1= IU3+ NROW + 1
CRLBR SPR94003 9/94 IP2= IP1+ NROW
IP2 = IP1+ NROW
IP3 = IP2+ NROW
IP4 = IP3+ NROW
NLFT1 = NLFT
DIT1 = DIT
NLFTP1= NLFTP
ILOOP1= ILOOP
MODAL1= MODAL
IST = 0
CRLBR SPR94003 9/94 NZ = NZ - 14*NROW - 1
NZ = NZ - 14*(NROW+1) - 1
ICORE = IP4 +NROW
NMODES= NROW- NOUE
PNL1 = PNL
ASSIGN 60 TO IRET1
NSTEP = IZ(IGROUP) + 1
DELTAT= Z(IGROUP+1)
NOUT = IZ(IGROUP+2)
IF( ILOOP .NE. 1) GO TO 210
C
C FIRST ENTRY INITIALIZE STUFF
C
IST =-1
FILE = PD
C
C PUT P0 IN IP2
C
IPNT = IP2
NOPD = .TRUE.
ASSIGN 5 TO IRETN
CALL OPEN(*310,PD,IZ(IBUF2),0)
CALL SKPREC(PD,1)
NOPD = .FALSE.
GO TO 290
CRLBD SPR94003 9/94 5 FILE = UDV
CRLBD SPR94003 9/94 IAPEND = 0
CRLBR SPR94003 9/94 IF (NCOL .LE. 0) GO TO 8
5 IF (NCOL .GT. 2) GO TO 325
CRLBD SPR94003 9/94 MCB(1) = UDV
CRLBD SPR94003 9/94 CALL RDTRL (MCB)
CRLBD SPR94003 9/94 IF (MCB(2) .NE. 0) GO TO 330
CRLBR SPR94003 9/94 8 CALL GOPEN (UDV,IZ(IBUF3),1)
CALL GOPEN (UDV, IZ(IBUF3), 1)
CALL MAKMCB (MCB,UDV,NROW,2,2)
CRLBNB SPR94003 9/94
8 IF (ICPFLG .EQ. 0) GO TO 10
CALL MAKMCB (MOUTPU, IOUTPU, NROW+1, ISKIP, 2)
CALL GOPEN (IOUTPU, IZ(IBUF9), 1)
IF (ISKIP .EQ. 0) CALL GOPEN (ISCR9, IZ(IBUFA), 1)
CRLBNE
10 IF (NLFTP.EQ.0) GO TO 20
C
C CHECK TO SEE IF PNL HAS BEEN PRE-PURGED.
C
IPNL(1)= PNL1
CALL RDTRL(IPNL)
ISPNL= 0
IF(IPNL(1) .LE. 0) GO TO 20
ISPNL= 1
CALL GOPEN(PNL1,IZ(IBUF8),1)
CALL MAKMCB(IPNL,PNL1,NROW,2,1)
20 CONTINUE
CRLBR SPR94003 9/94 IF (IAPEND .EQ. 1) GO TO 50
IF (NCOL .GT. 2) GO TO 50
FILE = IC
CALL GOPEN(IC,IZ(IBUF1),0)
ASSIGN 30 TO IRETN
IPNT = IU2
GO TO 290
30 ASSIGN 40 TO IRETN
IPNT = IU3
GO TO 290
40 CALL CLOSE(IC,1)
NSTEP = IZ(IGROUP)+1
DELTAT= Z(IGROUP+1)
NOUT = IZ(IGROUP+2)
C
C FORM U=1, PO, P-1
C
CALL FORM1( Z(IU2+1),Z(IU3+1),Z(IU1+1),Z(IP2+1),Z(IP1+1),DELTAT,
1 Z(IBUF1))
C
C START TIME STEP COUNT
C
50 CONTINUE
ICOUNT = 1
CRLBNB SPR94003 9/94
MCOL = 1
CRLBNE
60 CONTINUE
IF (NLFTP .EQ. 0) GO TO 62
IFRST=0
CALL TRD1D
IFRST=1
62 CONTINUE
C
C OPEN FBS FILES
C
FILE = ISCR1
CALL OPEN(*390,ISCR1,IZ(IBUF4),0)
FILE = ISCR2
CALL OPEN(*390,ISCR2,IZ(IBUF5),0)
FILE = ISCR3
CIBMR 5/95
C CALL OPEN(*390,ISCR3,IZ(IBUF6),0)
IF ( ISYM .EQ. 1 ) CALL OPEN(*390,ISCR3,IZ(IBUF6),0)
FILE = ISCR4
CALL OPEN(*390,ISCR4,IZ(IBUF7),0)
C
C ZERO P*
C
70 CALL TMTOGO(ITLEFT)
IF(ITLEFT .LE. 0) GO TO 170
DO 80 I = 1,NROW
K = IP4 +I
Z(K) =0.0
80 CONTINUE
IF(NLFTP .EQ. 0) GO TO 90
C
C FORM NON-LINEAR LOADS
C
CALL TRD1D
IF(ICOUNT.EQ. 1 .OR. ICOUNT .EQ. NSTEP .OR. MOD(ICOUNT+IST,NOUT)
1 .EQ. 0) GO TO 85
GO TO 90
85 IF (ISPNL.GT.0) CALL PACK (Z(IP4+1), PNL, IPNL)
C
C BRING IN NEXT P
C
90 IPNT = IP3
FILE = PD
ASSIGN 100 TO IRETN
IF ( NOPD ) GO TO 310
GO TO 290
C
C ADD P-S TO FORM P*
C
100 DO 110 I=1,NROW
K = IP4 + I
L = IP1 + I
M = IP2 + I
J = IP3 + I
Z(K) = Z(K) +(Z(L) + Z(M) + Z(J))/3.0
110 CONTINUE
IF (ILOOP.NE.1.OR.ICOUNT.NE.1) GO TO 115
CRLBR SPR94003 9/94 IF (IAPEND .EQ. 1) GO TO 115
IF (NCOL .GT. 2) GO TO 113
C
C OUTPUT INITIAL DISPLACEMENT
C
CALL PACK (Z(IU2 + 1), UDV, MCB(1))
C
C OUTPUT INITIAL VELOCITY
C
CALL PACK (Z(IU3 + 1), UDV, MCB(1))
CRLBNB SPR94003 9/94
113 IF (ICPFLG .EQ. 0) GO TO 115
IF (ISKIP .EQ. 0) CALL WRITE (ISCR9, MCOL, 1, 0)
CRLBNE
C
C SOLVE FOR NEXT SOLUTION
C
115 CALL STEP (Z(IU3 + 1), Z(IU2 + 1), Z(IU1 + 1), Z(IP4 + 1),
1 IZ(IBUF1))
CRLBNB SPR94003 9/94
IF (ICPFLG .EQ. 0) GO TO 118
JJ = NROW + 1
Z(IP2) = DELTAT
IF (ILOOP.NE.1 .AND. ICOUNT.EQ.0) Z(IP2) = DELTA1
CALL PACK (Z(IP2), IOUTPU, MOUTPU)
IF (ISKIP .EQ. 1) GO TO 117
Z(IU2) = MCOL + 0.1
CALL PACK (Z(IU2), IOUTPU, MOUTPU)
117 JJ = NROW
118 CONTINUE
CRLBNE
IF (ILOOP.EQ.1.AND.ICOUNT.EQ.1) GO TO 145
IF (ICOUNT.EQ.NSTEP.OR.MOD(ICOUNT+IST, NOUT).EQ.0) GO TO 130
IF (ICOUNT.EQ.1) GO TO 130
C
C ROTATE P POINTERS
C
120 J = IP1
IP1= IP2
IP2= IP3
IP3= J
C
C ROTATE U POINTERS
C
J = IU1
IU1= IU2
IU2= IU3
IU3= J
ICOUNT = ICOUNT +1
CRLBNB SPR94003 9/94
MCOL = MCOL + 1
CRLBNE
IF(ICOUNT-NSTEP) 70,160,170
C
C IT-S OUTPUT TIME -- LUCKY FELLOW
C
130 CALL PACK( Z(IU2+1), UDV, MCB(1) )
C
C COMPUTE U DOT
C
H = 1.0/(2.0*DELTAT)
DO 140 I=1,NROW
K = IP4 +I
L = IU3+I
M = IU1 + I
Z(K) = (Z(L)-Z(M))*H
140 CONTINUE
CALL PACK( Z(IP4+1), UDV, MCB(1) )
CRLBNB SPR94003 9/94
IF (ICPFLG .EQ. 0) GO TO 145
IF (ISKIP .EQ. 0) CALL WRITE (ISCR9, MCOL, 1, 0)
CRLBNE
C
C COMPUTE U DOT DOT
C
145 H = 1.0/(DELTAT*DELTAT)
DO 150 I=1,NROW
K = IP4+I
L = IU3+I
M = IU1+I
J = IU2 +I
Z(K) = (Z(L)+Z(M)- 2.0*Z(J))*H
150 CONTINUE
CALL PACK( Z(IP4+1), UDV, MCB(1) )
GO TO 120
C
C END OF 1 GROUP
C
160 IF(ILOOP .NE. NGROUP) GO TO 200
GO TO 70
170 J = 1
180 CALL CLOSE(UDV,J)
CALL CLOSE(PD, J)
CRLBNB SPR94003 9/94
IF (ICPFLG .EQ. 0) GO TO 188
IF (J.NE.1 .OR. ISKIP.EQ.1) GO TO 186
CALL CLOSE (ISCR9, 1)
C
C COPY THE SINGLE RECORD IN FILE ISCR9 AS THE
C LAST RECORD IN FILE IOUTPU
C
CALL GOPEN (ISCR9, IZ(IBUFA), 0)
FILE = ISCR9
183 CALL READ (*410, *184, ISCR9, Z(IU2+1), NROW, 0, IFLAG)
CALL WRITE (IOUTPU, Z(IU2+1), NROW, 0)
GO TO 183
184 CALL WRITE (IOUTPU, Z(IU2+1), IFLAG, 1)
CALL CLOSE (ISCR9, 1)
186 CALL CLOSE (IOUTPU, J)
CALL WRTTRL (MOUTPU)
188 CONTINUE
CRLBNE
CALL CLOSE(ISCR1,1)
CALL CLOSE(ISCR2,1)
CIBMR 5/95
C CALL CLOSE(ISCR3,1)
IF ( ISYM .EQ. 1 ) CALL CLOSE(ISCR3,1)
CALL CLOSE(ISCR4,1)
CALL WRTTRL(MCB)
IF( NLFTP .EQ. 0) GO TO 190
IF (ISPNL.EQ.0) GO TO 190
CALL CLOSE(PNL,J)
CALL WRTTRL(IPNL)
190 RETURN
C
C MORE GROUPS TO COME SAVE STUFF
C
200 J = 2
FILE = SCR1
CALL OPEN(*390,SCR1,IZ(IBUF1),1)
CALL WRITE(SCR1,Z(IU3+1),NROW,1)
CALL WRITE(SCR1,Z(IU1+1),NROW,1)
CALL WRITE(SCR1,Z(IU2+1),NROW,1)
CRLBR SPR94003 9/94
CRLBR CALL WRITE (SCR1,Z(IP1+1),NROW,1)
CALL WRITE (SCR1,Z(IP2+1),NROW,1)
CALL CLOSE(SCR1,1)
GO TO 180
C
C CHANGE OF TIME STEP--RESTORE POINTERS ETC
C
210 IGROUP = IGROUP +(ILOOP-1)*3
DELTA1 = Z(IGROUP-2)
NSTEP = IZ(IGROUP)
DELTAT = Z(IGROUP+1)
NOUT = IZ(IGROUP+2)
IF (.NOT.NOPD) CALL GOPEN (PD, IZ(IBUF2), 2)
CALL GOPEN(UDV,IZ(IBUF3),3)
MCB(1)= UDV
CALL RDTRL(MCB)
CRLBNB SPR94003 9/94
IF (ICPFLG .EQ. 0) GO TO 217
CALL GOPEN (IOUTPU, IZ(IBUF9), 3)
MOUTPU(1) = IOUTPU
CALL RDTRL (MOUTPU)
217 CONTINUE
CRLBNE
IF(NLFTP .EQ. 0) GO TO 220
IF (ISPNL.GT.0) CALL GOPEN (PNL1, IZ(IBUF8), 3)
220 CONTINUE
C
C RESTORE STUFF SAVED
C
FILE = SCR1
CALL OPEN(*390,SCR1,IZ(IBUF1),0)
CALL FREAD(SCR1,Z(IU1+1),NROW,1)
CALL FREAD(SCR1,Z(IU3+1),NROW,1)
CALL FREAD(SCR1,Z(IU2+1),NROW,1)
CALL FREAD(SCR1,Z(IP2+1),NROW,1)
CALL CLOSE(SCR1,1)
C
C COMPUTE U DOT
C
CRLBR SPR94003 9/94 H = 1.0D0/DELTA1
225 H = 1.0D0/DELTA1
DO 230 I=1,NROW
K = IP1 +I
L = IU2 +I
M = IU3 +I
Z(K) = (Z(L)-Z(M))*H
230 CONTINUE
C
C COMPUTE U DOT DOT
C
H = 1.0/(DELTA1*DELTA1)
DO 240 I=1,NROW
K = IP4+ I
L = IU2+ I
M = IU3+ I
J = IU1+ I
Z(K) = (Z(L)- 2.0*Z(M) +Z(J))*H
240 CONTINUE
CRLBD SPR94003 9/94 250 CONTINUE
C
C COMPUTE UI PRIME
C
H = DELTAT*DELTAT/2.0
DO 260 I=1,NROW
K =IU1 +I
L = IU2 +I
M = IP1+I
J = IP4 +I
Z(K) = Z(L) -DELTAT*Z(M)+ H*Z(J)
260 CONTINUE
C
C COMPUTE U DOT PRIME
C
DO 270 I=1,NROW
K = IU3 + I
L = IP1+I
M = IP4 + I
Z(K) = Z(L) -DELTAT*Z(M)
270 CONTINUE
C
C COMPUTE PI PRIME
C
DO 280 I=1,NROW
K = IP1+I
Z(K) = 0.0
280 CONTINUE
CALL FORM2(Z(IP4+1),Z(IU3+1),Z(IU1+1),Z(IP1+1),Z(IBUF1))
ICOUNT = 0
CRLBR SPR94003 9/94 GO TO IRET1, (60,10)
GO TO IRET1, (60,8)
C
C INTERNAL ROUTINE TO UNPACK VECTORS
C
290 CALL UNPACK(*310,FILE,Z(IPNT+1))
CRLBR SPR94003 9/94 300 GO TO IRETN, (5,30,40,100,350,360,370)
300 GO TO IRETN, (5,30,40,100,340,350,360,370,385,387)
CRLBR SPR94003 9/94 310 DO 320 INL = 1,NROW
310 DO 320 INL = III, JJJ
K = IPNT +INL
Z(K) = 0.0
320 CONTINUE
GO TO 300
CRLBNB SPR94003 9/94
C THE FOLLOWING LINES (UNTIL CRPKNE) REPRESENT
C REPLACEMENTS FOR THE OLD CODE WHICH HAS BEEN
C DELETED BELOW
C
C RETRIEVE REQUIRED INFORMATION FROM
C THE CHECKPOINT RUN
C
325 MCOL = NCOL
CALL GOPEN (IOUTPU, IZ(IBUF4), 0)
MOUTPU(1) = IOUTPU
CALL RDTRL (MOUTPU)
JSKIP = 1
IF (MOUTPU(4) .EQ. 1) GO TO 335
JSKIP = 2
CALL SKPREC (IOUTPU, MOUTPU(2))
FILE = IOUTPU
NWDS = NCOL - 1
327 CALL READ (*410, *330, IOUTPU, MCOL, -NWDS, 0, IFLAG)
GO TO 333
330 NWDS = NWDS - IFLAG
GO TO 327
333 CALL READ (*410, *333, IOUTPU, MCOL, 1, 0, IFLAG)
CALL REWIND (IOUTPU)
CALL SKPREC (IOUTPU, 1)
C
335 CALL SKPREC (IOUTPU, JSKIP*(MCOL-1))
FILE = IOUTPU
JJJ = NROW + 1
C
C GET P SUB I+1
C
IPNT = IP2 - 1
ASSIGN 340 TO IRETN
GO TO 290
340 ITYPE = 1
DELTA1 = Z(IP2)
IF (DELTA1 .EQ. DELTAT) GO TO 345
ITYPE = 2
GO TO 350
345 CALL SKPREC (IOUTPU, -(JSKIP+1))
C
C GET P SUB I
C
IPNT = IP1 - 1
ASSIGN 350 TO IRETN
GO TO 290
350 CALL CLOSE (IOUTPU, 1)
C
FILE = UDV
CALL GOPEN (UDV, IZ(IBUF3), 0)
K = 3*(NCOL - 1)
KK = 5
KKK = 4
KKP = 0
JJJ = NROW
CALL SKPREC (UDV, K)
C
C GET U SUB I+1
C
IPNT = IU2
ASSIGN 360 TO IRETN
GO TO 290
C
C GET U DOT SUB I+1
C
360 IPNT = IP3
ASSIGN 370 TO IRETN
GO TO 290
C
370 IF (MCOL .EQ. NCOL) GO TO 380
CALL CLOSE (UDV, 1)
FILE = IOUTPU
CALL GOPEN (IOUTPU, IZ(IBUF4), 0)
K = 2*MCOL - 3
KK = 0
KKK = 3
KKP = 1
JJJ = NROW + 1
CALL SKPREC (IOUTPU, K)
C
C GET U SUB I
C
380 IPNT = IU1 - KKP
IF (ITYPE .EQ. 2) IPNT = IU3 - KKP
CALL SKPREC (FILE, -KK)
ASSIGN 385 TO IRETN
GO TO 290
385 IF (ITYPE .EQ. 1) GO TO 388
IF (MCOL .EQ. NCOL) GO TO 386
ITEST = Z(IPNT+1)
IF (MCOL .EQ. ITEST+1) GO TO 386
WRITE (NNOUT, 500)
CALL MESAGE (-61, 0, 0)
386 CALL SKPREC (FILE, -KKK)
C
C GET U SUB I-1
C
IPNT = IU1 - KKP
ASSIGN 387 TO IRETN
GO TO 290
387 IF (MCOL .EQ. NCOL) GO TO 388
ITEST = Z(IPNT+1)
IF (MCOL .EQ. ITEST+2) GO TO 388
WRITE (NNOUT, 600)
CALL MESAGE (-61, 0, 0)
388 CALL CLOSE (FILE, 1)
JJJ = NROW
CALL GOPEN (UDV, IZ(IBUF3), 1)
CALL MAKMCB(MCB,UDV,NROW,2,1)
C
C OUTPUT INITIAL DISPLACEMENT
C
CALL PACK (Z(IU2 + 1), UDV, MCB(1))
C
C OUTPUT INITIAL VELOCITY
C
CALL PACK (Z(IP3 + 1), UDV, MCB(1))
IF (ITYPE .EQ. 1) GO TO 8
ASSIGN 8 TO IRET1
GO TO 225
CRLBNE
CRLBDB SPR94003 9/94
CRLBD C
CRLBD C RETRIEVE LAST VECTOR
CRLBD C
CRLBD 330 CALL GOPEN(UDV,IZ(IBUF3),0)
CRLBD K = 3*(NCOL - 1)
CRLBD IAPEND = 1
CRLBD CALL SKPREC(UDV,K)
CRLBD C
CRLBD C GET U SUB I+1
CRLBD C
CRLBD IPNT = IU2
CRLBD ASSIGN 350 TO IRETN
CRLBD GO TO 290
CRLBD CP
CRLBD C GET U SUB I+1 DOT
CRLBD C
CRLBD 350 IPNT = IP1
CRLBD ASSIGN 360 TO IRETN
CRLBD GO TO 290
CRLBD C
CRLBD C GET U SUB I+1 DOT DOT
CRLBD C
CRLBD 360 IPNT = IP4
CRLBD ASSIGN 370 TO IRETN
CRLBD GO TO 290
CRLBD 370 CONTINUE
CRLBD CALL CLOSE(UDV,1)
CRLBD CALL GOPEN (UDV, IZ(IBUF3), 1)
CRLBD CALL MAKMCB (MCB, UDV, NROW, 2, 1)
CRLBD C
CRLBD C OUTPUT INITIAL DISPLACEMENT
CRLBD C
CRLBD CALL PACK (Z(IU2+1), UDV, MCB(1))
CRLBD C
CRLBD C OUTPUT INITIAL VELOCITY
CRLBD C
CRLBD CALL PACK (Z(IP1+1), UDV, MCB(1))
CRLBD C
CRLBD C FORM P SUB I+1
CRLBD C
CRLBD DO 380 I =1,NROW
CRLBD K = IP2+I
CRLBD Z(K) = 0.0
CRLBD 380 CONTINUE
CRLBD CALL FORM2(Z(IP4+1),Z(IP1+1),Z(IU2+1),Z(IP2+1),Z(IBUF1))
CRLBD ASSIGN 10 TO IRET1
CRLBD GO TO 250
CRLBDE
C
C ERROR MESAGES
C
390 IP1 = -1
400 CALL MESAGE(IP1,FILE,SUBNAM)
RETURN
CRLBNB SPR94003 9/94
410 IP1 = -2
GO TO 400
CRLBNE
430 IP1 = -8
FILE= ICRQ
GO TO 400
CRLBNB SPR94003 9/94
500 FORMAT ('0*** SYSTEM FATAL MESSAGE, LOGIC ERROR 1 IN ',
* 'SUBROUTINE TRD1C2 WHILE PROCESSING THE RESTART ',
* 'INFORMATION')
600 FORMAT ('0*** SYSTEM FATAL MESSAGE, LOGIC ERROR 2 IN ',
* 'SUBROUTINE TRD1C2 WHILE PROCESSING THE RESTART ',
* 'INFORMATION')
CRLBNE
END
| mis/trd1c.f |
** Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
** See https://llvm.org/LICENSE.txt for license information.
** SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
* Data initialization of character scalars and substrings.
common /character2/ rslts
character * 4 rslts(11), expect(11)
integer * 4 irslts(11), iexpect(11)
equivalence (irslts, rslts)
equivalence (iexpect, expect)
data expect / 'a''\01z', ' wxy',
+ 'stuv', 'lmno',
+ 'pa ', 'bc ',
+ ' ', ' ',
+ 'defc', 'zwab',
+ 'xm j' /
call check(irslts, iexpect, 11)
end
block data character
character * 3 c1 *1, d1 *1, d3, c3, e3, f3
character e1, c2 * 2, f1, e4*4, f5*5
character f12*12, a8*(8)
common /character2/ c1, d1, e1, c2, d3, e4, f5, c3, f12, e3, f1
common /character2/ a8
data c1/'a'/ d1/''''/, e1/'\01'/
data c2, d3, e4, f5 / 'z ', 'wxy', 'stuv', 'lmnop' /
c initializations which require padding of character strings:
data c3, f12 / 'a', 'bc' /
c initializations which require truncation of character strings:
data e3, f1 / 'def ', 'cowpie' /
c initialization of substrings: set a8 to 'zwabxm j':
data a8(:1), a8(2:2), a8(5:5), a8(3:4), a8(6:7), a8(8:) /
- 'z', 'wy', 'x', 'ab', 'm', 'j' /
end
| test/f90_correct/src/ec00.f |
!
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
! * *
! * copyright (c) 2005 by UCAR *
! * *
! * University Corporation for Atmospheric Research *
! * *
! * all rights reserved *
! * *
! * Fishpack *
! * *
! * A Package of Fortran *
! * *
! * Subroutines and Example Programs *
! * *
! * for Modeling Geophysical Processes *
! * *
! * by *
! * *
! * John Adams, Paul Swarztrauber and Roland Sweet *
! * *
! * of *
! * *
! * the National Center for Atmospheric Research *
! * *
! * Boulder, Colorado (80307) U.S.A. *
! * *
! * which is sponsored by *
! * *
! * the National Science Foundation *
! * *
! * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
!
!
program test_cblktri
use, intrinsic :: ISO_Fortran_env, only: &
stdout => OUTPUT_UNIT
use fishpack
! Explicit typing only
implicit none
! Dictionary
type(FishpackWorkspace) :: workspace
integer(ip), parameter :: N = 63, M = 50
integer(ip), parameter :: IDIMY = 75, NT = 105
integer(ip) :: iflg, np, mp, i, j, ierror
real(wp), dimension(NT) :: an, bn, cn, t
real(wp), dimension(IDIMY) :: s
real(wp) :: ds, dt
real(wp), parameter :: ZERO = 0.0_wp, ONE = 1.0_wp, TWO = 2.0_wp
complex(wp) :: y(IDIMY,NT)
complex(wp), dimension(IDIMY) :: am, bm, cm
complex(wp), parameter :: IMAGINARY_UNIT = cmplx(ZERO, ONE, kind=wp)
! Set boundary conditions
np = 1
mp = 1
! Set mesh sizes
ds = ONE/(M + 1)
dt = ONE/(N + 1)
! Generate and store grid points for the purpose of computing the
! coefficients and the array y.
do i = 1, M
s(i) = real(i, kind=wp) * ds
end do
do j = 1, N
t(j) = real(j, kind=wp) * dt
end do
! Compute the coefficients am, bm, cm corresponding to the s direction
block
real(wp) :: half_ds, two_ds
real(wp) :: temp1, temp2, temp3
half_ds = ds/2
two_ds = TWO * ds
do i = 1, M
temp1 = ONE /(s(i)*two_ds)
temp2 = ONE /((s(i)-half_ds) * two_ds)
temp3 = ONE /((s(i)+half_ds) * two_ds)
am(i) = cmplx(temp1*temp2, ZERO, kind=wp)
cm(i) = cmplx(temp1*temp3, ZERO, kind=wp)
bm(i) = (-(am(i)+cm(i))) - IMAGINARY_UNIT
end do
end block
! Compute the coefficients an, bn, cn corresponding to the t direction
block
real(wp) :: half_dt, two_dt
real(wp) :: temp1, temp2, temp3
half_dt = dt/2
two_dt = TWO * dt
do j = 1, N
temp1 = ONE/(t(j) * two_dt)
temp2 = ONE/((t(j) - half_dt) * two_dt)
temp3 = ONE/((t(j) + half_dt) * two_dt)
an(j) = temp1 * temp2
cn(j) = temp1 * temp3
bn(j) = -(an(j) + cn(j))
end do
end block
! Compute right side of equation
do j = 1, N
y(:M, j) = 3.75_wp * s(:M) * t(j) * (s(:M)**4 + t(j)**4) &
- IMAGINARY_UNIT * (s(:M)*t(j))**5
end do
! The nonzero boundary conditions enter the linear system via
! the right side y(i, j). if the equations (3) given above
! are evaluated at i=m and j=1, ..., n then the term cm(m)*u(m+1, j)
! is known from the boundary condition to be cm(m)*t(j)**5.
! therefore this term can be included in the right side y(m, j).
! the same analysis applies at j=n and i=1, .., m. note that the
! corner at j=n, i=m includes contributions from both boundaries.
y(M,:N) = y(M,:N) - cm(M) * (t(:N)**5)
y(:M,N) = y(:M,N) - cn(N) * (s(:M)**5)
! Initialize workspace and lower solver routines
iflg = 0
call cblktri(iflg, np, N, an, bn, cn, mp, M, am, bm, cm, IDIMY, y, ierror, workspace)
! Solve complex block tridiagonal linear system
iflg = iflg + 1
do while(iflg <= 1)
call cblktri(iflg, np, N, an, bn, cn, mp, M, am, bm, cm, IDIMY, y, ierror, workspace)
iflg = iflg + 1
end do
! Compute discretization error. The exact solution is
! u(s,t) = (st)**5
block
real(wp), parameter :: KNOWN_ERROR = 0.164571992877414e-004_wp
real(wp) :: discretization_error
real(wp) :: exact_solution(M, N)
do j = 1, N
do i = 1, M
exact_solution(i,j) = (s(i)*t(j))**5
end do
end do
! Set discretization error
discretization_error = maxval(abs(exact_solution-y(:M,:N)))
call check_output('cblktri', ierror, KNOWN_ERROR, discretization_error)
end block
! Release memory
call workspace%destroy()
end program test_cblktri
| examples/tcblktri.f90 |
program compute_factorial
implicit none
integer :: n
n = 5
print *, factorial(n)
contains
recursive function factorial(n) result(fac)
implicit none
integer, intent(in) :: n
integer :: fac
if (n >= 2) then
fac = n*factorial(n - 1)
else
fac = 1
end if
end function factorial
end program
| source_code/recursion/factorial.f90 |
subroutine intexi(al10,axhfs,axlks,axvfs,cegexs,cess,cdrs,
$ cgexj,cpgexs,egexjf,iern1,iern2,ietmax,jern1,jern2,jetmax,
$ jflag,jgext,jpflag,jsflag,jsitex,kern1,kern2,ketmax,kgexsa,
$ mwtges,mwtsp,narn1,narn2,narxmx,narxt,nbasp,nbt,nbtmax,ncmpr,
$ ndrs,ndrsmx,ndrsr,ness,nessmx,nessr,netmax,net,nern1,nern2,
$ ngexro,ngexrt,ngexsa,ngexso,ngext,noutpt,nphasx,npt,nptmax,
$ nst,nstmax,ntprt,ntprmx,nttyo,nvetmx,rconst,tgexp,ugexj,
$ ugexmo,ugexmv,ugexp,ugexr,ugexs,ugexsr,uhfgex,uphase,uspec,
$ uvfgex,uxkgex,xhfgex,xlkgex,xvfgex,zchar,zgexj)
c
c This subroutine inteprets data read from the input file for the
c generic ion exchange model. It composes the necessary generic
c exchange phases and species and sets up the associated reactions
c and thermodynamic properties.
c
c "Ion exchange" may be strictly or loosely interpreted here,
c depending on the models chosen. In the case of the Gapon and
c Vanselow models, the interpretation is strict. For example, a
c site must be negatively or positively charged, only ions of
c the opposite sign may occupy it, and the formal exchange
c capacity is exactly 100% utilized, save for a negligible
c trace of unfilled positions. The end-member exchanger species
c are electrically neutral, save for the trace unfilled site
c species. In contrast, the "Site-mixing" model allows more
c flexibility, including charged exchanger end-members, and
c overloading or underloading of the formal exchange capacities.
c
c Each exchanger species is specific to a given site (type of
c site), and these species are organized in the species list such
c that those belonging to a given site are listed contiguously.
c An exchanger with only one site is treated in the same manner
c as a phase composed of constituent species. In the case of an
c exchanger with more than one site, each site is treated as a
c kind of subphase, composed of its own constituent species.
c
c To illustrate, an exchange phase with substrate Z and two exchange
c sites is represented by:
c
c (Na+,K+)3(Fe+++,Al+++)2(Z)
c
c Here a pair of parentheses represents a site. Z represents the
c substrate. The site it occupies is not an exchange site. There is
c always one mole of substrate occupying this site. The first
c exchange site, here called site A, contains a mixture of Na+
c and K+ ions. There are 3 moles of this site per mole of substrate.
c This site has an intrinsic charge (charge when the site is not
c occupied) of -1. Thus, 3 moles of monovalent cations per mole of
c substrate are required to attain electrical neutrality on this
c site. The second exchange site, here called site B, contains a
c mixture of Fe+++ and Al+++ ions. There are 2 moles of this site
c per mole of substrate, and it has an intrinsic charge of -3.
c
c The species for this example may be written as:
c
c site A:
c
c (Na+)3()2()
c (K+)3()2()
c
c site B:
c
c ()3(Fe+++)2()
c ()3(Al+++)2()
c
c substrate site:
c
c ()3()2(Z)
c
c Here an empty pair of parentheses denotes an empty site.
c However, an empty site is a definite part of the species.
c An empty site makes no contribution to the molecular weight of
c of such a species. Thus, the molecular weight of (Na+)3()2()
c is 3 times the atomic weight of Na. The mass in grams of the
c complete exchanger phase is the sum of the masses of all of
c the constitutent species. The number of moles of the exchanger
c phase is equal to the number of moles of the substrate.
c
c One could conceivably define an exchanger with a non-unit
c stoichiometry for the substrate component; e.g., something
c like:
c
c (Na+,K+)3(Fe+++,Al+++)2(Z')2
c
c where Z' is a redefined substrate for the previous example.
c However, there do not seem to be any advantages to introducing
c or even allowing such a complexity. One can always define a
c stoichiometric with unit substrate, in this example by taking
c Z = 2*Z'.
c
c The activity of such a species in the ideal case (implicitly in
c the site mixing sense) is the mole fraction on the site for which
c the species is defined, raised to the power equal to the
c stoichiometric factor for the site. In the case of (Na+)3()2(),
c the relation is:
c
c a{(Na+)3()2()} = x{(Na+)3()2()}**3.
c
c The origin of this relationship is as follows. Write a pseudo-
c reaction in which the (Na+)3()2() species goes to a form of
c itself, but with the stoichiometry redefined so that there is
c one mole of the site of interest per mole of the exchanger
c species:
c
c (Na+)3()2() = 3(Na+)()[2/3]()[1/3]
c
c Because this is a pseudo-reaction, reflecting only a change
c in components, there is no change in the Gibbs energy, enthalpy,
c or entropy. Alternatively, the equilibrium constant is unity.
c Thus,
c
c a{(Na+)3()2()} = a{(Na+)()[2/3]()[1/3]}**3
c
c In the ideal case, it is clear that:
c
c a{(Na+)()[2/3]()[1/3]} = x{(Na+)()[2/3]()[1/3]}
c
c Thus,
c
c a{(Na+)3()2()} = x{(Na+)()[2/3]()[1/3]}**3
c
c The mole fractions of the Na+ species are not affected by the
c stoichiometric arbitrariness in how the species are defined.
c Hence:
c
c x{(Na+)3()2()} = x{(Na+)()[2/3]()[1/3]}
c
c Subsitution of this into the equaiton immediately above then
c yields:
c
c a{(Na+)3()2()} = x{(Na+)3()2()}**3.
c
c This explains the origin of the site number appearing as an
c exponent in the calculation of the activity of a component.
c
c The above kinds of species are not end-members. End-members for
c the above exchanger phase would be:
c
c (Na+)3(Fe+++)2(Z)
c (Na+)3(Al+++)2(Z)
c (K+)3(Fe+++)2(Z)
c (K+)3(Al+++)2(Z)
c
c Note that for example:
c
c a((Na+)3(Fe+++)2(Z)) = a((Na+)3()2())**3 a(()3(Fe+++)2())**2
c
c Note that a factor of a(Z)**1 is missing from the right hand
c side. This is because this factor has a fixed value of 1 by
c definition. This would be true even if we allowed for the
c formal possibility of an arbitrary number of moles of substrate
c in the exchanger phase, because there is no mixing on the
c substrate site. Thus, a(Z) = 1.
c
c This subroutine is called by:
c
c EQ3NR/eq3nr.f
c EQ6/eq6.f
c
c-----------------------------------------------------------------------
c
c Principal input:
c
c ugexj = array of exchanger site names
c ugexmo = array of strings identifying exchange models, which
c are used for composing ion exchange species and
c corresponding reactions; examples include:
c 'Gapon' = Gapon model
c 'Vanselow' = Vanselow model
c 'Site-mixing' = the general site-mixing model
c ugexmv = array of valid strings identifying exchange models
c ugexp = array of exchanger phase names
c ugexr = array of strings containing compact representations
c of the exchange reactions; e.g., 'Na+ = Ca++' for a
c reaction in which Na+ on the exchanger is replaced
c by Ca++. One may make specifications such as
c 'Na+ = ' in which case the ion goes into solution
c leaving a bare substrate. All reactions are
c normalized to the exchange (or loss) of one
c equivalent. The exact form of the reaction is
c otherwise dependent on the mixing law specifed in
c the element of the ugexmo array for the current
c exchanger.
c ugexs = array of exchange ions names
c ugexsr = array of exchange ions names extracted from the
c ugexr array
c
c Principal input/output:
c
c uphase = array of phase names (extended to include the names
c of generic exchange phases)
c uspec = array of species names (extended to include the names
c of species belonging to generic exchange phases)
c
c Principal output:
c
c cegexs = array of coefficients giving the number of equivalents
c per mole of each exchanger species.
c cpgexs = array of coefficients giving the number of moles of
c exchanger substrate per mole of each exchanger
c species.
c egexjf = array of formal exchange capacities of the sites of
c the exchangers, defined in terms of equivalents per
c mole of exchanger substrate. The formal exchange
c capacity of an exchanger phase is the sum of these
c for all its exchange sites.
c jern1 = array giving the start of the range in the species
c list corresponding to species in the je-th site
c of the ne-th exchanger.
c jern2 = array giving the end of the range in the species
c list corresponding to species in the je-th site
c of the ne-th exchanger.
c jgext = array giving the number of exchange sites in each of
c the ion exchange phases
c
c-----------------------------------------------------------------------
c
implicit none
c
c-----------------------------------------------------------------------
c
c Calling sequence variable declarations.
c
integer ietmax,jetmax,ketmax,narxmx,nbtmax,ndrsmx,nessmx,netmax,
$ nptmax,nstmax,ntprmx,nvetmx
c
integer noutpt,nttyo
c
integer jern1(jetmax,netmax),jern2(jetmax,netmax),jflag(nstmax),
$ jgext(netmax),jpflag(nptmax),jsflag(nstmax),jsitex(nstmax),
$ kern1(netmax),kern2(netmax),kgexsa(ketmax,netmax),narxt(ntprmx),
$ nbasp(nbtmax),ncmpr(2,nptmax),ndrs(ndrsmx),ndrsr(2,nstmax),
$ ness(nessmx),nessr(2,nstmax),ngexro(ietmax,jetmax,netmax),
$ ngexrt(jetmax,netmax),ngext(jetmax,netmax),
$ ngexsa(ietmax,jetmax,netmax),ngexso(ietmax,jetmax,netmax),
$ nphasx(nstmax)
c
integer iern1,iern2,narn1,narn2,nbt,net,nern1,nern2,npt,nst,ntprt
c
character*56 ugexr(ietmax,jetmax,netmax)
character*48 uspec(nstmax)
character*24 ugexmo(netmax),ugexmv(nvetmx),ugexp(netmax),
$ ugexs(ietmax,jetmax,netmax),ugexsr(2,ietmax,jetmax,netmax),
$ uphase(nptmax)
character*8 ugexj(jetmax,netmax),uhfgex(ietmax,jetmax,netmax),
$ uvfgex(ietmax,jetmax,netmax),uxkgex(ietmax,jetmax,netmax)
c
real*8 axhfs(narxmx,ntprmx,nstmax),axlks(narxmx,ntprmx,nstmax),
$ axvfs(narxmx,ntprmx,nstmax),cegexs(ietmax,jetmax,netmax),
$ cess(nessmx),cdrs(ndrsmx),cgexj(jetmax,netmax),
$ cpgexs(ietmax,jetmax,netmax),egexjf(jetmax,netmax),
$ mwtges(netmax),mwtsp(nstmax),tgexp(netmax),xhfgex(ietmax,
$ jetmax,netmax),xlkgex(ietmax,jetmax,netmax),
$ xvfgex(ietmax,jetmax,netmax),zchar(nstmax),zgexj(jetmax,netmax)
c
real*8 al10,rconst
c
c-----------------------------------------------------------------------
c
c Local variable declarations.
c
integer i,ie,iee,iej,ieo,itot,j,je,jee,jj,jj2,jj3,j2,j3,j4,j5,j6,
$ k,ke,kee,ke1,n,nb,nd2,ne,nee,nerr,nn,np,nrf1,nrf2,nr1,nr2,ns,
$ nsba,nse,nsl,nspect,nss,nsse,nve,nvet
c
integer ilnobl,nbasis
c
logical qmoerr,qsperr
c
character*56 ustr56
character*24 ugexpd,ustr1,ustr1e,ustr2
character*8 ugexjd
c
real afhx,afvx,afxb,afx0,arcnst,bfx,cfactr,cgx,cfxi,cfxz,cx,
$ efx,tfxb,tfx0,xx,zprod,zpx,zsi,zxj,zxjt
c
c-----------------------------------------------------------------------
c
c Initialize some constants.
c
nerr = 0
arcnst = -al10*0.001*rconst
tfx0 = 273.15
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
c Count the number of valid exchange model options.
c
nvet = 0
do nve = 1,nvetmx
if (ugexmv(nve)(1:6) .ne. 'ERROR ') nvet = nvet + 1
enddo
c
if (net.gt.0 .and. nvet.le.0) then
write (noutpt,1000)
write (nttyo,1000)
1000 format (/' * Error - (EQLIB/intexi) Programming error trap:',
$ /7x,'There are no programmed valid strings representing',
$ /7x,'exchange models for the generic ion phases. Check the',
$ /7x,'data statement which initializes the ugexmv array. This',
$ /7x,'is located in the EQLIB INCLUDE file eqlo8d.h. If the',
$ /7x,'INCLUDE files have been "pre-stuffed" in your source',
$ /7x,'code, this data statement may be found in the main',
$ /7x,'programs for EQ3NR and EQ6.')
stop
endif
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
c Pass 1. Loop on exchanger phases. Check the input. Provide
c defaults as necessary. build a list of exchanger species, and
c map exchange ions to their aqueous species counterparts.
c The exchange phases and species will be created (in the
c sense of being added to the general lists of phases and species)
c below in pass 2.
c
do ne = 1,net
call lejust(ugexp(ne))
j4 = ilnobl(ugexp(ne))
c
if (j4 .le. 0) then
c
c Have a blank exchanger name. Assign a default name.
c
call adgexp(ne,noutpt,nttyo,ugexpd)
ugexp(ne) = ugexpd
j4 = ilnobl(ugexp(ne))
endif
c
c Make sure that the phase name is unique among all exchangers.
c
do nee = 1,ne - 1
if (ugexp(ne)(1:24) .eq. ugexp(nee)(1:24)) then
write (noutpt,1010) ugexp(ne)(1:j4),ne,nee
write (nttyo,1010) ugexp(ne)(1:j4),ne,nee
1010 format (/' * Error - (EQLIB/intexi) "',a,'" is the name',
$ ' specified',/7x,'for exchanger phases ',i3,' and ',i3,
$ '. Exchanger phase names,',/7x,'including any assigned',
$ ' defaults, must be unique.')
nerr = nerr + 1
endif
enddo
c
c Check the prescribed exchange model.
c
call lejust(ugexmo(ne))
c
c Provide a default.
c
if (ugexmo(ne)(1:3) .eq. ' ') then
ugexmo(ne) = ugexmv(1)
write (noutpt,1012) ugexp(ne)(1:j4),ugexmo(ne)(1:j2)
write (nttyo,1012) ugexp(ne)(1:j4),ugexmo(ne)(1:j2)
1012 format (/' * Warning - (EQLIB/intexi) No exchange model',
$ ' was species for',/7x,'the exchanger phase ',a,'. The ',a,
$ ' model has been',/7x,'assigned as a default.')
endif
c
j5 = ilnobl(ugexmo(ne))
do nve = 1,nvetmx
j6 = ilnobl(ugexmv(nve))
if (ugexmo(ne)(1:j5) .eq. ugexmv(nve)(1:j6)) go to 130
enddo
c
write (noutpt,1020) ugexmo(ne)(1:j2),ugexp(ne)(1:j4)
write (nttyo,1020) ugexmo(ne)(1:j2),ugexp(ne)(1:j4)
1020 format (/" * Error - (EQLIB/intexi) Don't recognize the",
$ ' exchange model type',/7x,'"',a,'" specified for the',
$ ' generic exchanger phase ',a,'.',/7x,'Valid choices',
$ ' include the following:',/)
c
do nve = 1,nvetmx
if (ugexmv(nve)(1:6) .ne. 'ERROR ') then
j6 = ilnobl(ugexmv(nve))
write (noutpt,1022) ugexmv(nve)(1:j6)
write (nttyo,1022) ugexmv(nve)(1:j6)
1022 format(9x,a)
endif
enddo
c
j6 = ilnobl(ugexmv(1))
write (noutpt,1024) ugexmv(1)(1:j6)
write (nttyo,1024) ugexmv(1)(1:j6)
1024 format(/7x,'A blank input defaults to "',a,'".')
nerr = nerr + 1
c
130 if (mwtges(ne) .le. 0) then
mwtges(ne) = 100.
write (noutpt,1030) ugexp(ne)(1:j4)
write (nttyo,1030) ugexp(ne)(1:j4)
1030 format (/" * Warning - (EQLIB/intexi) Don't have a valid",
$ ' input for the',/7x,'molecular weight of the substrate for',
$ ' exchange phase'/7x,a,'. Assigning a default value of',
$ ' 100 grams/mol.')
endif
c
if (tgexp(ne) .eq. 0.) then
tgexp(ne) = 25.0
write (noutpt,1040) ugexp(ne)(1:j4)
write (nttyo,1040) ugexp(ne)(1:j4)
1040 format (/" * Warning - (EQLIB/intexi) Don't have a valid",
$ ' input for the',/7x,'temperature reference required for',
$ ' the thermodynamic data for',/7x,'exchange phase ',a,
$ '. Assigning a default value of 25C.')
endif
cfactr = 1./(arcnst*(tgexp(ne) + 273.15))
c
c Loop on sites.
c
do je = 1,jgext(ne)
call lejust(ugexj(je,ne))
j3 = ilnobl(ugexj(je,ne))
c
c Calculate the formally declared exchange capacity (in
c equivalents per mole of exchanger substrate) of the
c current site. The sign of this is opposite to that of the
c charge on the site itself.
c
egexjf(je,ne) = -cgexj(je,ne)*zgexj(je,ne)
c
c Check the name of the current site.
c
if (j3 .eq. 0) then
c
c No name was given. Assign one (e.g., "S(1)" to site 1,
c "S(2)" to site 2).
c
call adgexj(je,noutpt,nttyo,ugexjd)
ugexj(je,ne) = ugexjd
j3 = ilnobl(ugexj(je,ne))
endif
c
c Make sure that the site name is unique among all sites for
c the current exchanger phase.
c
do jee = 1,je - 1
if (ugexj(je,ne)(1:8) .eq. ugexj(jee,nee)(1:8)) then
write (noutpt,1060) ugexj(je,ne)(1:j3),je,jee,
$ ugexp(ne)(1:j4)
write (nttyo,1060) ugexj(je,ne)(1:j3),je,jee,
$ ugexp(ne)(1:j4)
1060 format (/' * Error - (EQLIB/intexi) "',a,'" is the name',
$ ' of',/7x,'sites ',i3,' and ',i3,' of exchanger phase ',
$ a,'.',/7x,'Site names, including any assigned',
$ ' defaults, must be unique',/7x,'for a given',
$ ' exchanger phase.')
nerr = nerr + 1
endif
enddo
c
c Check the electrical charge of the site against the specified
c exchange model.
c
if (ugexmo(ne)(1:5).eq.'Gapon' .or.
$ ugexmo(ne)(1:6).eq.'Gapon-' .or.
$ ugexmo(ne)(1:8).eq.'Vanselow' .or.
$ ugexmo(ne)(1:9).eq.'Vanselow-') then
if (zgexj(je,ne) .eq. 0.) then
write (noutpt,1070) ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),
$ ugexmo(ne)(1:j5)
write (nttyo,1070) ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),
$ ugexmo(ne)(1:j5)
1070 format (/' * Error - (EQLIB/intexi) The electrical',
$ ' charge of site ',a,''/7x,'of exchanger phase ',
$ a,' is zero. This is not valid',/7x,'for the ',a,
$ ' exchange model.')
nerr = nerr + 1
endif
endif
c
c Loop on condensed reactions read from the input file. Map
c these to species corresponding to ions on the sites.
c
qsperr = .false.
do n = 1,ngexrt(je,ne)
k = index(ugexr(n,je,ne),' == ')
if (k .gt. 0) then
ustr56 = ugexr(n,je,ne)(1:k - 1)
call lejust(ustr56)
ustr1 = ustr56(1:24)
ustr56 = ugexr(n,je,ne)(k + 4:56)
call lejust(ustr56)
ustr2 = ustr56(1:24)
else
k = index(ugexr(n,je,ne),' = ')
if (k .gt. 0) then
ustr56 = ugexr(n,je,ne)(1:k - 1)
call lejust(ustr56)
ustr1 = ustr56(1:24)
ustr56 = ugexr(n,je,ne)(k + 3:56)
call lejust(ustr56)
ustr2 = ustr56(1:24)
else
k = index(ugexr(n,je,ne),'==')
if (k .gt. 0) then
ustr56 = ugexr(n,je,ne)(1:k - 1)
call lejust(ustr56)
ustr1 = ustr56(1:24)
ustr56 = ugexr(n,je,ne)(k + 2:56)
call lejust(ustr56)
ustr2 = ustr56(1:24)
else
k = index(ugexr(n,je,ne),'=')
if (k .gt. 0) then
ustr56 = ugexr(n,je,ne)(1:k - 1)
call lejust(ustr56)
ustr1 = ustr56(1:24)
ustr56 = ugexr(n,je,ne)(k + 1:56)
call lejust(ustr56)
ustr2 = ustr56(1:24)
else
j2 = ilnobl(ugexr(n,je,ne))
write (noutpt,1080) ugexr(n,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1080) ugexr(n,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1080 format (/" * Error - (EQLIB/intexi) Can't decode",
$ ' the condensed reaction string',/7x,'"',a,'",',
$ ' which is given for site ',a,' of exchange',
$ /7x,'phase ',a,'. The two species in the string',
$ ' must be',/7x,'separated by " == ", " = ", "==",',
$ ' or "=".')
ustr1 = 'Error'
ustr2 = 'Error'
nerr = nerr + 1
qsperr = .true.
endif
endif
endif
endif
c
c Prettify the strings in the ugexr array. Use "__" to
c indicate a bare exchange site.
c
if (ustr1(1:3) .eq. ' ') ustr1 = '__'
if (ustr1(1:3) .eq. '_ ') ustr1 = '__'
if (ustr2(1:3) .eq. ' ') ustr2 = '__'
if (ustr2(1:3) .eq. '_ ') ustr2 = '__'
ugexsr(1,n,je,ne) = ustr1
ugexsr(2,n,je,ne) = ustr2
j2 = ilnobl(ustr1)
ugexr(n,je,ne)(j2 + 1:j2 + 3) = ' = '
ugexr(n,je,ne)(j2 + 4:56) = ustr2
c
c Make sure the two species in the reaction are not identical.
c
if (ustr1(1:6) .ne. 'Error ') then
if (ustr1(1:24) .eq. ustr2(1:24)) then
j2 = ilnobl(ugexr(n,je,ne))
if (ustr1(1:3) .eq. '__ ') then
write (noutpt,1090) ugexr(n,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1090) ugexr(n,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1090 format (/' * Error - (EQLIB/intexi) The condensed',
$ ' exchange reaction "',a,'"',/7x,'for site ',a,
$ ' of exchange phase ',a,' is an',/7x,'identity',
$ " reaction. Such a reaction shouldn't appear on the",
$ /7x,'input file.')
else
write (noutpt,1100) ugexr(n,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1100) ugexr(n,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1100 format (/' * Error - (EQLIB/intexi) The condensed',
$ ' exchange reaction "',a,'"',/7x,'for site ',a,
$ ' of exchange phase ',a,' is invalid.',/7x,'The two',
$ " species in the reaction can't be identical.")
endif
nerr = nerr + 1
qsperr = .true.
endif
endif
enddo
c
if (qsperr) go to 200
c
c Add a condensed reaction which involves one of the
c exchangeable species and the bare site species, if none
c such was included on the input.
c
do n = 1,ngexrt(je,ne)
ustr1 = ugexsr(1,n,je,ne)
ustr2 = ugexsr(2,n,je,ne)
if (ustr1(1:3) .eq. '__ ') go to 140
if (ustr2(1:3) .eq. '__ ') go to 140
enddo
c
n = ngexrt(je,ne) + 1
ngexrt(je,ne) = n
ustr1 = ugexsr(1,1,je,ne)
ustr2 = '__'
ugexsr(1,n,je,ne) = ustr1
ugexsr(2,n,je,ne) = ustr2
j2 = ilnobl(ustr1)
ugexr(n,je,ne) = ustr1
ugexr(n,je,ne)(j2 + 1:j2 + 3) = ' = '
ugexr(n,je,ne)(j2 + 4:56) = ustr2
xlkgex(n,je,ne) = -12.0
xhfgex(n,je,ne) = 0.
xvfgex(n,je,ne) = 0.
uxkgex(n,je,ne) = 'LogK/eq'
uhfgex(n,je,ne) = 'kcal/eq'
uvfgex(n,je,ne) = 'cm3/eq'
140 continue
c
c Add an identity reaction for the bare site species.
c This is done to simplify the indexing relations between
c exchanger species and corresponding reactions by making
c them one to one. This simplification is important, because
c the species must be created in a special order so that the
c corresponding reaction properties for dissocation to the
c bare site species can be calculated from the specified
c exchange data without having to resort to matrix equations.
c
n = ngexrt(je,ne) + 1
ngexrt(je,ne) = n
ustr1 = '__'
ustr2 = '__'
ugexsr(1,n,je,ne) = ustr1
ugexsr(2,n,je,ne) = ustr2
j2 = ilnobl(ustr1)
ugexr(n,je,ne) = ustr1
ugexr(n,je,ne)(j2 + 1:j2 + 3) = ' = '
ugexr(n,je,ne)(j2 + 4:56) = ustr2
xlkgex(n,je,ne) = 0.
xhfgex(n,je,ne) = 0.
xvfgex(n,je,ne) = 0.
uxkgex(n,je,ne) = 'LogK/eq'
uhfgex(n,je,ne) = 'kcal/eq'
uvfgex(n,je,ne) = 'cm3/eq'
c
c Put the names of the ions on the current site
c in the ugexs array.
c
nspect = 2
ustr1 = ugexsr(1,1,je,ne)
ustr2 = ugexsr(2,1,je,ne)
ugexs(1,je,ne) = ustr1
ugexs(2,je,ne) = ustr2
c
c The last reaction is the identity reaction for the bare site
c species, and it is guaranteed that a previous reaction
c involves this species, so looping from 2,ngexrt(je,ne) - 1
c is sufficient.
c
do n = 2,ngexrt(je,ne) - 1
do i = 1,2
ustr1 = ugexsr(i,n,je,ne)
do nn = 1,nspect
if (ustr1(1:24) .eq. ugexs(nn,je,ne)) go to 150
enddo
nspect = nspect + 1
ugexs(nspect,je,ne) = ustr1
150 continue
enddo
enddo
c
if (nspect .ne. ngexrt(je,ne)) then
write (noutpt,1110) nspect,ngexrt(je,ne),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1110) nspect,ngexrt(je,ne),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1110 format (/' * Error - (EQLIB/intexi) Have ',i3,' species',
$ ' and ',i3,' reactions for',/7x,'site ',a,' of exchange',
$ ' phase ',a,' after automatic',/7x,'additions to deal with',
$ ' the bare site species. The number',/7x,'of species',
$ ' (including the bare site species) must be equal to',
$ /7x,'the number of reactions. Check the input. If you have',
$ ' listed for',/7x,'a site for example two exchange',
$ ' reactions such as "Na+ = K+" and',/7x,'"Rb+ = Cs+,"',
$ ' you must include a third one to complete the linkage,',
$ /7x,'such as "Na+ = Rb+".')
nerr = nerr + 1
endif
c
c Map each exchange species to its aqueous species counterpart
c (the exchangeable species).
c
do ie = 1,nspect
if (ugexs(ie,je,ne)(1:3) .eq. '__ ') then
ngexsa(ie,je,ne) = 0
go to 170
endif
j2 = ilnobl(ugexs(ie,je,ne))
c
do nss = narn1,narn2
if (ugexs(ie,je,ne)(1:24) .eq. uspec(nss)(1:24)) then
ngexsa(ie,je,ne) = nss
go to 170
endif
enddo
c
write (noutpt,1130) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1130) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1130 format (/' * Error - (EQLIB/intexi) The exchange species ',
$ a,/7x,'specified for site ',a,' of exchange phase ',a,
$ /7x,'does not correspond to any aqueous species read from',
$ ' the data file.')
nerr = nerr + 1
qsperr = .true.
c
170 continue
enddo
c
if (qsperr) go to 200
c
c Test the electrical charges of the exchangeable species
c and the charge of the site against the exchanger model.
c
if (ugexmo(ne)(1:5).eq.'Gapon' .or.
$ ugexmo(ne)(1:6).eq.'Gapon-' .or.
$ ugexmo(ne)(1:8).eq.'Vanselow' .or.
$ ugexmo(ne)(1:9).eq.'Vanselow-') then
do ie = 1,nspect
nss = ngexsa(ie,je,ne)
if (nss .gt. 0) then
zpx = zchar(nss)*zgexj(je,ne)
if (zpx .ge. 0.) then
write (noutpt,1150) ugexs(ie,je,ne)(1:j2),
$ zchar(nss),ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),
$ ugexmo(ne)(1:j5)
write (nttyo,1150) ugexs(ie,je,ne)(1:j2),
$ zchar(nss),ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),
$ ugexmo(ne)(1:j5)
1150 format (/' * Error - (EQLIB/intexi) The electrical',
$ ' charge of ',a,/7x,'is ',f5.1,'. This species',
$ " can't be exchanged onto site ",a,/7x,'of exchanger',
$ ' phase ',a,' because the site',/7x,'has the same',
$ ' charge sign or zero charge. Opposite charge',
$ /7x,'signs are required for the ',a,' exchange',
$ ' model.')
nerr = nerr + 1
endif
endif
enddo
endif
c
c Convert the input thermodynamic parameters for exchange or
c dissociation reactions to standard units.
c
do ie = 1,nspect
call lejust(uxkgex(ie,je,ne))
if (uxkgex(ie,je,ne)(1:3) .eq. ' ') then
uxkgex(ie,je,ne) = 'LogK/eq'
elseif (uxkgex(ie,je,ne)(1:8) .eq. 'kcal/eq ') then
xlkgex(ie,je,ne) = cfactr*xlkgex(ie,je,ne)
uxkgex(ie,je,ne) = 'LogK/eq'
elseif (uxkgex(ie,je,ne)(1:8) .eq. 'kJ/eq ') then
xlkgex(ie,je,ne) = xlkgex(ie,je,ne)/4.184
xlkgex(ie,je,ne) = cfactr*xlkgex(ie,je,ne)
uxkgex(ie,je,ne) = 'LogK/eq'
elseif (uxkgex(ie,je,ne)(1:8) .ne. 'LogK/eq ') then
j2 = ilnobl(ugexr(ie,je,ne))
j5 = ilnobl(uxkgex(ie,je,ne))
write (noutpt,1170) uxkgex(ie,je,ne)(1:j5),
$ ugexr(ie,je,ne)(1:j2),ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1170) uxkgex(ie,je,ne)(1:j5),
$ ugexr(ie,je,ne)(1:j2),ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1170 format (/" * Error - (EQLIB/intexi) Don't recognize the",
$ ' string "',a,'", which is',/7x,'given to define the',
$ ' units for the xlkgex (log K) input for the',
$ /7x,'reaction "',a,'" on site ',a,' of exchanger phase',
$ /7x,a,'. The string must be blank (defaults to',
$ ' "LogK/eq"),',/7x,'"LogK/eq", "kcal/eq", or "kJ/eq".')
nerr = nerr + 1
endif
c
call lejust(uhfgex(ie,je,ne))
if (uhfgex(ie,je,ne)(1:3) .eq. ' ') then
uhfgex(ie,je,ne) = 'kcal/eq'
elseif (uhfgex(ie,je,ne)(1:8) .eq. 'kJ/eq ') then
xhfgex(ie,je,ne) = xhfgex(ie,je,ne)/4.184
uhfgex(ie,je,ne) = 'kcal/eq'
elseif (uhfgex(ie,je,ne)(1:8) .ne. 'kcal/eq ') then
j2 = ilnobl(ugexr(ie,je,ne))
j5 = ilnobl(uhfgex(ie,je,ne))
write (noutpt,1180) uhfgex(ie,je,ne)(1:j5),
$ ugexr(ie,je,ne)(1:j2),ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1180) uhfgex(ie,je,ne)(1:j5),
$ ugexr(ie,je,ne)(1:j2),ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1180 format (/" * Error - (EQLIB/intexi) Don't recognize the",
$ ' string "',a,'", which is',/7x,'given to define the',
$ ' units for the xhfgex (enthalpy) input for the',
$ /7x,'reaction "',a,'" on site ',a,' of exchanger phase',
$ /7x,a,'. The string must be blank (defaults to',
$ ' "kcal/eq"),',/7x,'"kcal/eq", or "kJ/eq".')
nerr = nerr + 1
endif
c
call lejust(uvfgex(ie,je,ne))
if (uvfgex(ie,je,ne)(1:3) .eq. ' ') then
uvfgex(ie,je,ne) = 'cm3/eq'
elseif (uvfgex(ie,je,ne)(1:8) .ne. 'cm3/eq ') then
j2 = ilnobl(ugexr(ie,je,ne))
j5 = ilnobl(uvfgex(ie,je,ne))
write (noutpt,1190) uvfgex(ie,je,ne)(1:j5),
$ ugexr(ie,je,ne)(1:j2),ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1190) uvfgex(ie,je,ne)(1:j5),
$ ugexr(ie,je,ne)(1:j2),ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1190 format (/" * Error - (EQLIB/intexi) Don't recognize the",
$ ' string "',a,'", which is',/7x,'given to define the',
$ ' units for the xvfgex (volume) input for the',
$ /7x,'reaction "',a,' on site ',a,' of exchanger phase',
$ /7x,a,'. The string must be blank (defaults to',
$ ' "cm3/eq")',/7x,'or "cm3/eq".')
nerr = nerr + 1
endif
enddo
c
200 continue
enddo
enddo
c
if (nerr .gt. 0) stop
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
np = npt
ns = nst
nern1 = nst + 1
iern1 = npt + 1
c
c Pass 2. Loop on exchanger phases. Formally create exchanger phases
c and species, and comute the corresponding reactions and
c thermodynamic data for such species.
c
do ne = 1,net
j4 = ilnobl(ugexp(ne))
c
if (npt .ge. nptmax) then
write (noutpt,1240) nptmax,ugexp(ne)(1:j2)
write (nttyo,1240) nptmax,ugexp(ne)(1:j2)
1240 format (/' * Error - (EQLIB/intexi) The maximum ',i3,
$ ' phases would be',/7x,'exceeded by creating the exchange',
$ ' phase ',a,'. Increase',/7x,'the dimensioning parameter',
$ ' nptpar.')
stop
endif
c
c Add the current exchange phase to the list of phases.
c
np = np + 1
npt = np
jpflag(np) = 0
uphase(np) = ugexp(ne)
ncmpr(1,np) = ns + 1
tfxb = tgexp(ne)
c
c Loop on sites.
c
nsba = 0
do je = 1,jgext(ne)
j3 = ilnobl(ugexj(je,ne))
c
nspect = ngexrt(je,ne)
c
c Change the condensed reactions if necessary so that any
c association reactions are converted to dissociation
c reactions (e.g., for Na+, from "__ = Na+" to "Na+ = __").
c Do not modify the last reaction, which is the identity
c reaction for the bare site species.
c
do ie = 1,nspect - 1
if (ugexsr(1,ie,je,ne)(1:3) .eq. '__ ') then
xlkgex(ie,je,ne) = -xlkgex(ie,je,ne)
xhfgex(ie,je,ne) = -xhfgex(ie,je,ne)
xvfgex(ie,je,ne) = -xvfgex(ie,je,ne)
ugexsr(1,ie,je,ne)(1:24) = ugexsr(2,ie,je,ne)(1:24)
ugexsr(2,ie,je,ne)(1:24) = '__ '
endif
enddo
c
c Now convert all exchange reactions in this set to
c dissociation reactions. To give an idea of what is happening,
c a single exchange reaction "Ca++ = Na+" read from the input
c file would now be expanded to the following condensed
c reaction set:
c
c 1. Ca++ = Na+
c 2. Ca++ = __
c 3. __ = __
c
c The corresponding species (corresponding in the set of having
c matching indices) would be:
c
c 1. Ca++
c 2. Na+
c 3. __
c
c Note that there is no formal correspondence in that species 2
c (Na+) does not appear in reaction 2 (Ca++ = __). Also, the
c base site species ("__") need not appear last, depending
c on what condensed reactions were read from the input file.
c The identity reaction for this species is guaranteed to
c appear last, as it can't be read from the input file, and
c is created in this position by the current subroutine in the
c "Pass 1" section above.
c
c The first step is to convert the set of existing condensed
c reactions into a set of linearly independent dissociation
c reactions. In the example, the set of reactions becomes:
c
c 1. Na+ = __
c 2. Ca++ = __
c 3. __ = __
c
c Note that it is guaranteed that the last reaction is the
c identity reaction for the bare site species and that at
c least one of the remaining reactions is a dissociation
c reaction. Tests performed above also guarantee that the
c desired conversion is possible. Basically, the process
c requires going through the reactions in an order which
c insures that for each exchange reaction there currently
c exists a dissociation reaction for one of the two species.
c
c First, loop through the reactions, and mark all those which
c are in the desired form (the identity reaction for the bare
c site species and all reactions in dissociation format) by
c setting a value of 1 in the corresponding element of the
c ngexro array. It is guaranteed that there is at least one
c reaction in dissociation format. Then repeatedly loop
c through the remaining reactions, each time finding one to
c transform from exchange to dissociation format by combining
c it with a reaction in the processed set. Mark it as
c transformed using the ngexro array. Repeated looping
c is required to insure that all such reactions can be
c transformed. Stop when no reactions remain in exchange
c format.
c
c The ngexro array will later be used to create a mapping
c between the species and the reactions.
c
do iee = 1,nspect
ngexro(iee,je,ne) = 0
enddo
c
itot = 1
ngexro(nspect,je,ne) = 1
c
do ie = 1,nspect - 1
ustr1 = ugexsr(1,ie,je,ne)
ustr2 = ugexsr(2,ie,je,ne)
if (ustr2(1:3) .eq. '__ ') then
itot = itot + 1
ngexro(ie,je,ne) = 1
endif
enddo
c
210 if (itot .eq. nspect) go to 220
do ie = 1,nspect - 1
if (ngexro(ie,je,ne) .eq. 0) then
ustr1 = ugexsr(1,ie,je,ne)
ustr2 = ugexsr(2,ie,je,ne)
do iee = 1,nspect - 1
if (ngexro(iee,je,ne) .eq. 1) then
ustr1e = ugexsr(1,iee,je,ne)
if (ustr1e(1:24) .eq. ustr2(1:24)) then
itot = itot + 1
ngexro(ie,je,ne) = 1
ugexsr(1,ie,je,ne) = ustr1
ugexsr(2,ie,je,ne) = '__'
j2 = ilnobl(ustr1)
ugexr(ie,je,ne) = ustr1
ugexr(ie,je,ne)(j2 + 1:j2 + 3) = ' = '
ugexr(ie,je,ne)(j2 + 4:56) = '__'
xx = xlkgex(ie,je,ne) + xlkgex(iee,je,ne)
xlkgex(ie,je,ne) = xx
xx = xhfgex(ie,je,ne) + xhfgex(iee,je,ne)
xhfgex(ie,je,ne) = xx
xx = xvfgex(ie,je,ne) + xvfgex(iee,je,ne)
xvfgex(ie,je,ne) = xx
go to 210
elseif (ustr1e(1:24) .eq. ustr1(1:24)) then
itot = itot + 1
ngexro(ie,je,ne) = 1
ugexsr(1,ie,je,ne) = ustr2
ugexsr(2,ie,je,ne) = '__'
j2 = ilnobl(ustr2)
ugexr(ie,je,ne) = ustr2
ugexr(ie,je,ne)(j2 + 1:j2 + 3) = ' = '
ugexr(ie,je,ne)(j2 + 4:56) = '__'
xx = -xlkgex(ie,je,ne) + xlkgex(iee,je,ne)
xlkgex(ie,je,ne) = xx
xx = -xhfgex(ie,je,ne) + xhfgex(iee,je,ne)
xhfgex(ie,je,ne) = xx
xx = -xvfgex(ie,je,ne) + xvfgex(iee,je,ne)
xvfgex(ie,je,ne) = xx
go to 210
endif
endif
enddo
endif
enddo
c
write (noutpt,1250) ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1250) ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1250 format(/' * Error - (EQLIB/intexi) Programming error trap:',
$ " Couldn't transform",/7x,'one or more condensed reactions',
$ ' for site ',a,' of exchange',/7x,'phase ',a,' from',
$ ' exchange format to dissociation',/7x,'format. Check the',
$ ' responsible coding.')
stop
c
220 continue
c
c Now set up the ngexro array as a pointer array giving the
c index of the reaction corresponding to a given species.
c
itot = 0
do ie = 1,nspect
ngexro(ie,je,ne) = 0
ustr1 = ugexs(ie,je,ne)
do iee = 1,nspect
if (ustr1(1:24) .eq. ugexsr(1,iee,je,ne)(1:24)) then
itot = itot + 1
ngexro(ie,je,ne) = iee
go to 230
endif
enddo
c
write (noutpt,1260) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1260) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1260 format(/' * Error - (EQLIB/intexi) Programming error trap:',
$ " Couldn't find",/7x,'a condensed identity or dissociation',
$ ' reaction for ',a,/7x,'on site ',a,' of exchange phase ',
$ a,'. Check the',/7x,'responsible coding.')
stop
c
230 continue
enddo
c
c Order the species for creation, using the ngexso array.
c Use the existing order, except that the bare site species
c is created first.
c
itot = 0
do ie = 1,nspect
if (ugexs(ie,je,ne)(1:3) .eq. '__ ') then
itot = itot + 1
ngexso(itot,je,ne) = ie
go to 240
endif
enddo
240 continue
do ie = 1,nspect
if (ugexs(ie,je,ne)(1:3) .ne. '__ ') then
itot = itot + 1
ngexso(itot,je,ne) = ie
endif
enddo
c
c Create the species for the current site.
c
jern1(je,ne) = ns + 1
c
c Loop on ions on sites. Note that the bare exchanger species
c will be created first.
c
do ieo = 1,nspect
ie = ngexso(ieo,je,ne)
j2 = ilnobl(ugexs(ie,je,ne))
c
if (nst .ge. nstmax) then
write (noutpt,1290) nstmax,ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1290) nstmax,ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1290 format (/' * Error - (EQLIB/intexi) The maximum ',i4,
$ ' species would be',/7x,'exceeded by creating an',
$ ' exchange species for ',a,/7x,'on site ',a,
$ ' of exchange phase ',a,'. Increase the',
$ /7x,'dimensioning parameter nstpar.')
stop
endif
c
ns = ns + 1
nsl = nst
nst = ns
jsflag(ns) = 0
c
jsitex(ns) = je
nphasx(ns) = np
c
c If the current species is the bare one for the current
c site, add it to the set of strict basis species.
c
nss = ngexsa(ie,je,ne)
if (nss .eq. 0) then
nbt = nbt + 1
if (nbt .gt. nbtmax) then
write (noutpt,1300) nbtmax,ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1300) nbtmax,ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1300 format (/' * Error - (EQLIB/intexi) The maximum,',
$ i3,' basis species would be',/7x,'exceeded by',
$ ' adding a species for ',a,' on site ',a,/7x,'of',
$ ' exchange phase ',a,'. Increase the dimensioning',
$ /7x,'parameter nbtpar.')
stop
else
nbasp(nbt) = ns
jflag(ns) = 0
nsba = ns
endif
endif
c
c Get the index of the corresponding aqueous species
c (the exchangeable species). Compute the stoichiometric
c relationship between the exchanger species and the
c corresponding aqueous species. This relationship depends
c on the specified exchange model.
c
nss = ngexsa(ie,je,ne)
if (nss .gt. 0) then
zsi = zchar(nss)
else
zsi = 0.
endif
zxj = zgexj(je,ne)
zprod = zsi*zxj
c
c Note: cfxi below is the reaction coefficient for the
c exchangeable ion in the dissociation reaction for the
c corresponding exchanger species. The dissociation reaction
c is always written such that one mole of exchanger species
c is dissociated.
c
j5 = ilnobl(ugexmo(ne))
c
if (nss .gt. 0) then
if (ugexmo(ne)(1:5).eq.'Gapon' .or.
$ ugexmo(ne)(1:6).eq.'Gapon-' .or.
$ ugexmo(ne)(1:8).eq.'Vanselow' .or.
$ ugexmo(ne)(1:9).eq.'Vanselow-') then
c
c Check electrical charges of the exchangeable ion and
c the exchange site.
c
qmoerr = .false.
if (zsi .eq. 0.) then
write (noutpt,1320) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),ugexmo(ne)(1:j5)
write (nttyo,1320) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),ugexmo(ne)(1:j5)
1320 format (/" * Error - (EQLIB/intexi) Can't create",
$ ' a generic ion exchange species',/7x,'for ',a,
$ ' on site ',a,' of exchange phase',/7x,a,
$ ' for the ',a,' model because',/7x,'the',
$ ' exchangeable ion has no electrical charge.')
nerr = nerr + 1
qmoerr = .true.
endif
c
if (zxj .eq. 0.) then
write (noutpt,1330) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),ugexmo(ne)(1:j5)
write (nttyo,1330) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),ugexmo(ne)(1:j5)
1330 format (/" * Error - (EQLIB/intexi) Can't create",
$ ' a generic ion exchange species',/7x,'for ',a,
$ ' on site ',a,' of exchange phase',/7x,a,
$ ' for the ',a,' model because',/7x,'the',
$ ' the exchange site has no electrical charge.')
nerr = nerr + 1
qmoerr = .true.
endif
c
if (qmoerr) go to 270
c
if (zprod .gt. 0.) then
write (noutpt,1340) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),ugexmo(ne)(1:j5)
write (nttyo,1340) ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4),ugexmo(ne)(1:j5)
1340 format (/" * Error - (EQLIB/intexi) Can't create",
$ ' a generic ion exchange species',/7x,'for ',a,
$ ' on site ',a,' of exchange phase',/7x,a,' for the ',
$ a,' model because the exchangeable',/7x,'ion and',
$ ' the exchange site have the same electrical',
$ ' charge sign.')
nerr = nerr + 1
go to 270
endif
endif
endif
c
cgx = cgexj(je,ne)
zxjt = cgx*zxj
c
c cfxi = the number of moles of exchangeable ion per
c mole of the exchanger species
c cfxz = the number of moles of exchanger substrate per
c mole of exchanger species
c
if (nss .gt. 0) then
c
c Have other than the bare site species.
c
if (ugexmo(ne)(1:j5).eq.'Gapon' .or.
$ ugexmo(ne)(1:6).eq.'Gapon-') then
c
c Gapon (Gapon-?) model.
c
c For:
c
c cgexj(je,ne) = 1
c zgexj(je,ne) = -1
c "Na+ = Ca++"
c
c the species are:
c
c Na-Z and Ca[1/2]-Z
c
cfxi = -cgx*zxj/zsi
cfxz = -cfxi*zsi/zxjt
c
elseif (ugexmo(ne)(1:j5).eq.'Vanselow' .or.
$ ugexmo(ne)(1:9).eq.'Vanselow-') then
c
c Vanselow (Vanselow-?) model.
c
c For:
c
c cgexj(je,ne) = 1
c zgexj(je,ne) = -1
c "Na+ = Ca++"
c
c the species are:
c
c Na-Z and Ca-Z2
c
cfxi = -cgx*zxj*abs(zsi)/zsi
cfxz = -cfxi*zsi/zxjt
c
elseif (ugexmo(ne)(1:j5) .eq. 'Site-mixing') then
c
c Site-mixing model.
c
cfxi = cgx
cfxz = 1.0
c
else
write (noutpt,1350) ugexmo(ne)(1:j5),ugexp(ne)(1:j4)
write (nttyo,1350) ugexmo(ne)(1:j5),ugexp(ne)(1:j4)
1350 format (/' * Error - (EQLIB/intexi.f) Programming',
$ " error trap: Don't recognize the",/7x,'exchange',
$ ' model type"',a,'" specified for the exchanger phase',
$ /7x,a,'. Valid choices include "Gapon" and "Vanselow".',
$ /7x,'Invalid choices should have been trapped above in',
$ ' this subroutine.',/7x,'Check the coding at the',
$ ' present point. Now trying to compute',/7x,'factors',
$ ' for the compositions and reactions of species',
$ ' belonging',/7x,'to this exchanger phase.')
stop
endif
else
c
c Have the bare site species.
c
cfxi = cgx
cfxz = 1.0
endif
c
c Here efx is the number of equivalents of exchangeable
c ion appearing in the dissociation reaction.
c
if (nss .gt. 0) then
c
c Have other than the bare site species.
c
zchar(ns) = cfxi*zsi - zxjt
mwtsp(ns) = cfxi*mwtsp(nss)
efx = abs(cfxi*zsi)
else
c
c Have the bare site species.
c
zchar(ns) = zxjt
mwtsp(ns) = 0.
efx = 0.
endif
c
c Compose the full name of the exchanger species. The phase
c part of the name is the exchange phase name. The species
c part is a concatenation of the species part of the name of
c the ion released in an exchange reaction (the aqueous
c ion) and the site name. A blank space is included in the
c concatenation between the two parts. The concatenation is
c trimmed as necessary to fit into 24 characters.
c Approximately two characters of the exchange ion name are
c trimmed for each character of the site name. The full name
c of the species should should then look like
c "Na+ S(1) Exchanger(A)". This algorithm
c matches that in EQLIB/intgex.f. As formatted by
c EQLIBU/fmspnm.f or EQLIBU/fmspnx.f, the name in this
c example would appear as "Na+ S(1) Exchanger(A)".
c
c Warning: the stoichiometry of the species can't be deduced
c from the name alone. The the number of formula units of
c exchangeable Na+ in site S(1) in the above example could be
c 1.0, 2.0, or some other number. The same is true for the
c number of moles of the site itself per mole of exchanger.
c Thus, "Na+ S(1) Exchanger(A)" has one stoichiometry for
c the Vanselow model, but a different one for the Gapon model.
c
jj2 = j2
jj3 = j3
nd2 = 0
250 jj = jj2 + jj3 + 1
if (jj .gt. 24) then
if (nd2 .lt. 2) then
jj2 = jj2 - 1
nd2 = nd2 + 1
go to 250
else
jj3 = jj3 - 1
nd2 = 0
go to 250
endif
endif
uspec(ns) = ' '
uspec(ns)(1:jj2) = ugexs(ie,je,ne)(1:jj2)
uspec(ns)(jj2 + 1:jj2 + 1) = ' '
uspec(ns)(jj2 + 2:jj) = ugexj(je,ne)(1:jj3)
uspec(ns)(25:48) = ugexp(ne)(1:24)
c
c Set up the elemental composition.
c
nrf1 = nessr(2,nsl) + 1
if (nss .gt. 0) then
nr1 = nessr(1,nss)
nr2 = nessr(2,nss)
nrf2 = nrf1 + nr2 - nr1
else
nrf2 = nrf1
endif
c
if (nrf2 .gt. nessmx) then
write (noutpt,1380) nessmx,ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1380) nessmx,ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1380 format (/' * Error - (EQLIB/intexi) The maximum ',i5,
$ ' entries in the',/7x,'cess/ness arrays would be',
$ ' exceeded by creating the',/7x,'exchange species',
$ ' for ',a,' on site',/7x,a,' of exchange phase ',a,'.',
$ ' Increase the',/7x,'dimensioning parameter nesspa.')
stop
endif
c
nessr(1,ns) = nrf1
nessr(2,ns) = nrf2
if (nss .gt. 0) then
k = nr1 - 1
do n = nrf1,nrf2
k = k + 1
cess(n) = cfxi*cess(k)
ness(n) = ness(k)
enddo
else
n = nrf1
cess(n) = 0.
ness(n) = 0
endif
c
c Set up the corresponding reaction.
c
nrf1 = ndrsr(2,nsl) + 1
if (nss .gt. 0) then
c
c Case of a non-bare site species.
c
nrf2 = nrf1 + 2
else
c
c Case of the bare site species.
c
nrf2 = nrf1
endif
c
if (nrf2 .gt. ndrsmx) then
write (noutpt,1390) ndrsmx,ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
write (nttyo,1390) ndrsmx,ugexs(ie,je,ne)(1:j2),
$ ugexj(je,ne)(1:j3),ugexp(ne)(1:j4)
1390 format (/' * Error - (EQLIB/intexi) The maximum ',i5,
$ ' entries in the',/7x,'cdrs/ndrs arrays would be',
$ ' exceeded by creating the',/7x,'exchange species',
$ ' for ',a,'on site',/7x,a,' of exchange phase ',a,'.',
$ ' Increase the',/7x,'dimensioning parameter ndrspa.')
stop
endif
c
ndrsr(1,ns) = nrf1
ndrsr(2,ns) = nrf2
if (nss .gt. 0) then
c
c Case of a non-bare site species. Create a reaction in
c which the species dissociates to the bare site species.
c
n = nrf1
cdrs(n) = -1.0
ndrs(n) = ns
n = n + 1
cdrs(n) = cfxi
ndrs(n) = nss
n = n + 1
cdrs(n) = cfxz
ndrs(n) = nsba
else
c
c Case of the bare site species. Create a null reaction.
c The bare site species then becomes a strict basis
c species, though it doesn't actually formally correspond
c to a chemical element.
c
n = nrf1
cdrs(n) = 0.
ndrs(n) = 0
endif
c
if (nss .eq. 0) go to 270
c
c Set up to the thermodynamic properties of the reaction
c just created. This reaction should match one of the
c existing condensed reactions.
c
iee = ngexro(ie,je,ne)
c
c Calculate the thermodynamic properties of the reaction.
c
do j = 1,ntprt
if (efx .ne. 0.) then
afxb = efx*xlkgex(iee,je,ne)
afhx = efx*xhfgex(iee,je,ne)
afvx = efx*xvfgex(iee,je,ne)
else
afxb = xlkgex(iee,je,ne)
afhx = xhfgex(iee,je,ne)
afvx = xvfgex(iee,je,ne)
endif
c
c Here afxb is the log K value and tfxb the temperature (C)
c at the base temperature. Use the van't Hoff relation to
c find afx0, the log K at 0C. Approximate the van't Hoff
c relation across the total temperature range using the
c standard power series.
c
bfx = -afhx/(arcnst*tfx0)
afx0 = afxb + bfx*(tfxb/(tfxb + tfx0))
axlks(1,j,ns) = afx0
xx = -bfx
do i = 2,narxt(j)
xx = -xx/tfx0
axlks(i,j,ns) = xx
enddo
c
axhfs(1,j,ns) = afhx
axvfs(1,j,ns) = afvx
do i = 2,narxt(j)
axhfs(i,j,ns) = 0.
axvfs(i,j,ns) = 0.
enddo
enddo
c
c Is the aqueous species which goes onto the substrate a
c basis species? If not, the reaction must be rewritten
c in terms of equivalent basis species.
c
nrf1 = ndrsr(1,ns)
nrf2 = ndrsr(2,ns)
do n = nrf1 + 1,nrf2
nse = ndrs(n)
if (nse.ge.narn1 .and. nse.le.narn2) then
c
c Calling sequence substitutions:
c nse for ns
c
nb = nbasis(nbasp,nbt,nbtmax,nse)
if (nb .eq. 0) then
nbt = nbt + 1
if (nbt .gt. nbtmax) then
j6 = ilnobl(uspec(nse))
write (noutpt,1400) nbtmax,uspec(nse)(1:j6),
$ ugexs(ie,je,ne)(1:j2),ugexj(je,ne)(1:j3),
$ ugexp(ne)(1:j4)
write (nttyo,1400) nbtmax,uspec(nse)(1:j6),
$ ugexs(ie,je,ne)(1:j2),ugexj(je,ne)(1:j3),
$ ugexp(ne)(1:j4)
1400 format (/' * Error - (EQLIB/intexi) The maximum,',
$ i3,' basis species would be',/7x,'exceeded by',
$ ' adding ',a,' in order to',/7x,'accomodate the',
$ ' required setup for species ',a,/7x,'on site ',a,
$ ' of exchange phase ',a,'.',/7x,'Increase the',
$ ' dimensioning parameter nbtpar.')
stop
else
nbasp(nbt) = nse
jflag(nse) = 30
endif
endif
endif
enddo
c
270 continue
enddo
c
c Modify the ngexsa array if necessary so that the species
c index of the bare site species appears in the first position
c for the current site of the current exchange phase.
c
do ie = 1,nspect
nss = ngexsa(ie,je,ne)
if (nss .eq. 0) then
do i = 1,ie - 1
iee = ie - i
ngexsa(iee + 1,je,ne) = ngexsa(iee,je,ne)
enddo
ngexsa(1,je,ne) = 0
go to 280
endif
enddo
280 continue
c
jern2(je,ne) = nst
ngext(je,ne) = jern2(je,ne) - jern1(je,ne) + 1
enddo
ncmpr(2,np) = nst
enddo
c
nern2 = nst
iern2 = npt
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
c Pass 3. Loop on exchanger phases. Change the ordering of the
c condensed reactions and associated data to match that of the
c corresponding created species. Then eliminate the identity
c reaction for the bare site species. This puts these data
c in the desired form for writing on a pickup file.
c
c In the example discussed above (input of a single exchange
c reaction, Ca++ = Na+), the expanded set of condensed reactions
c was:
c
c 1. Na+ = __
c 2. Ca++ = __
c 3. __ = __
c
c The actual species created were processed in the order
c __, Ca++, Na+. The bare site species is always processed first.
c The other species are processed in order of appearance in the
c condensed reactions read from the input file. Thus, the order of
c creation of the corresponding reactions from the condensed
c counterparts was:
c
c 1. (3. __ = __)
c 2. (2. Ca++ = __)
c 3. (1. Na+ = __)
c
c Here the set of condensed reactions is changed to:
c
c 1. Ca++ = __
c 2. Na+ = __
c
c As input, this is expanded to:
c
c 1. Ca++ = __
c 2. Na+ = __
c 3. __ = __
c
c The actual species are then created in the same order as before,
c (__, Ca++, Na+).
c
c Note that less setup work is required for the case of the input
c of two dissociation reactions than for the case of the input of
c the single equivalent exchange reaction.
c
do ne = 1,net
c
c Loop on sites.
c
do je = 1,jgext(ne)
nspect = ngexrt(je,ne)
c
c Re-arrange the condensed reactions so that their order
c matches that of the local species list. This eliminates
c the need for the ngexro pointer array to find the
c condensed reaction for a given species in the local
c species list.
c
do ie = 1,nspect
iee = ngexro(ie,je,ne)
if (iee .ne. ie) then
c
c Exchange positions.
c
ustr56 = ugexr(iee,je,ne)
ugexr(iee,je,ne) = ugexr(ie,je,ne)
ugexr(ie,je,ne) = ustr56
xx = xlkgex(iee,je,ne)
xlkgex(iee,je,ne) = xlkgex(ie,je,ne)
xlkgex(ie,je,ne) = xx
xx = xhfgex(iee,je,ne)
xhfgex(iee,je,ne) = xhfgex(ie,je,ne)
xhfgex(ie,je,ne) = xx
xx = xvfgex(iee,je,ne)
xvfgex(iee,je,ne) = xvfgex(ie,je,ne)
xvfgex(ie,je,ne) = xx
do iej = 1,nspect
if (ngexro(iej,je,ne) .eq. ie) go to 310
enddo
310 ngexro(iej,je,ne) = iee
ngexro(ie,je,ne) = ie
endif
enddo
c
do ie = 1,nspect
iee = ngexso(ie,je,ne)
if (iee .ne. ie) then
c
c Exchange positions.
c
ustr56 = ugexr(iee,je,ne)
ugexr(iee,je,ne) = ugexr(ie,je,ne)
ugexr(ie,je,ne) = ustr56
xx = xlkgex(iee,je,ne)
xlkgex(iee,je,ne) = xlkgex(ie,je,ne)
xlkgex(ie,je,ne) = xx
xx = xhfgex(iee,je,ne)
xhfgex(iee,je,ne) = xhfgex(ie,je,ne)
xhfgex(ie,je,ne) = xx
xx = xvfgex(iee,je,ne)
xvfgex(iee,je,ne) = xvfgex(ie,je,ne)
xvfgex(ie,je,ne) = xx
do iej = 1,nspect
if (ngexso(iej,je,ne) .eq. ie) go to 320
enddo
320 ngexso(iej,je,ne) = iee
ngexso(ie,je,ne) = ie
endif
enddo
c
c Remove the identity reaction from the set of condensed
c reactions.
c
do ie = 1,nspect - 1
iee = ie + 1
ugexr(ie,je,ne) = ugexr(iee,je,ne)
xlkgex(ie,je,ne) = xlkgex(iee,je,ne)
xhfgex(ie,je,ne) = xhfgex(iee,je,ne)
xvfgex(ie,je,ne) = xvfgex(iee,je,ne)
enddo
ie = nspect
ugexr(ie,je,ne) = '__ = __ '
xlkgex(ie,je,ne) = 0.
xhfgex(ie,je,ne) = 0.
xvfgex(ie,je,ne) = 0.
nspect = nspect - 1
ngexrt(je,ne) = nspect
enddo
enddo
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
c Calculate the cegexs array. This is an array of coefficients
c giving the number of equivalents per mole of each exchanger
c species. This supports the calculation of equivalent fractions.
c
do ne = 1,net
do je = 1,jgext(ne)
ns = jern1(je,ne) - 1
do ie = 1,ngext(je,ne)
ns = ns + 1
if (uspec(ns)(1:3) .eq. '__ ') then
else
c
c Have the bare site species.
c
cegexs(ie,je,ne) = 0.
c
c Have other than the bare site species.
c
nr1 = ndrsr(1,ns)
nr2 = ndrsr(2,ns)
cx = 0.
do n = nr1 + 1,nr2
nse = ndrs(n)
c
c There are contributions only from the aqueous
c species. There is none from the bare site species,
c which also appears in the reaction.
c
if (nse.ge.narn1 .and. nse.le.narn2) then
cx = cx + cdrs(n)*zchar(nse)
endif
enddo
cegexs(ie,je,ne) = cx
endif
enddo
enddo
enddo
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
c Calculate the cpgexs array. This is an array of coefficients
c giving the number of moles of exchanger substrate (Z) per mole of
c exchanger species (e.g., Na-Z, Ca-Z2). This supports the
c calculation of the number of moles of the exchanger phase.
c
do ne = 1,net
j5 = ilnobl(ugexmo(ne))
if (ugexmo(ne)(1:j5).eq.'Gapon' .or.
$ ugexmo(ne)(1:6).eq.'Gapon-' .or.
$ ugexmo(ne)(1:j5) .eq. 'Site-mixing') then
c
c Gapon (Gapon-?) or Site-mixing model.
c
do je = 1,jgext(ne)
do ie = 1,ngext(je,ne)
cpgexs(ie,je,ne) = 1.0
enddo
enddo
c
elseif (ugexmo(ne)(1:j5).eq.'Vanselow' .or.
$ ugexmo(ne)(1:9).eq.'Vanselow-') then
c
c Vanselow (Vanselow-?) model.
c
do je = 1,jgext(ne)
do ie = 1,ngext(je,ne)
cpgexs(ie,je,ne) = cegexs(ie,je,ne)/egexjf(je,ne)
enddo
enddo
endif
enddo
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
c Set up the kgexsa, kern1, and kern2 pointer arrays. The kgexsa
c array contains the indices of the exchange species (e.g., Na+).
c The latter two arrays point to the start and end of the range
c in kgexsa corresponding to a given generic ion exchanger phase.
c Here kgexsa(ke,ne) is the index of the ke-th species exchanging
c on the ne-th generic ion exchanger phase.
c
ke = 0
do ne = 1,net
ke1 = ke + 1
kern1(ne) = ke1
c
do je = 1,jgext(ne)
do ie = 1,ngext(je,ne)
nss = ngexsa(ie,je,ne)
c
c Has this exchange species already been loaded because
c because it appears in another site?
c
do kee = ke1,ke
nsse = kgexsa(kee,ne)
if (nsse .eq. nss) go to 400
enddo
c
c Have an exchange species which has not already been
c loaded. Load it.
c
ke = ke + 1
kgexsa(ke,ne) = nss
400 continue
enddo
enddo
c
kern2(ne) = ke
enddo
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
990 if (nerr .gt. 0) stop
c
c* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
c
end
| src/eqlib/src/intexi.f |
Subsets and Splits