![File: ~mech403/public_html/optdes/OnebarM.f90] (Revised 10/16/03) ! SAMPLE OPTDES APPLICATION SUBROUTINES, F90 version ! metric units SUBROUTINE anapre (model_Name) !================================================================== !...subroutine ANAPRE ! preprocessing routine, called only once to set title, etc !------------------------------------------------------------------ IMPLICIT NONE ! be safe CHARACTER(17), intent (out) :: model_Name DOUBLE PRECISION :: height, diameter, volume ! create a "named" common to access input or output, if needed COMMON / My_Out / height, diameter, volume ! name "12345678901234567" of the model (17 char) model_Name = "Vertical_Bar" ! open the post processing output, if needed OPEN (unit = 10, file = "post_process.out", status = "unknown") ! call any code needed to start the process END SUBROUTINE anapre SUBROUTINE anafun !================================================================== !...subroutine ANAFUN, called for every trial vector (each iteration) ! sample analysis routine for a vertical bar !------------------------------------------------------------------ IMPLICIT NONE ! safe style ! set problem constants DOUBLE PRECISION, PARAMETER :: pi = 3.141593d0, pi_sq = pi*pi, & g = 9.8066d0 DOUBLE PRECISION :: height, diameter, volume ! for common DOUBLE PRECISION :: density, modulus, axial_load, area, & i_over_a, mass, axial_stress, euler_buckling, axial_defl ! create a "named" common to access input or output, if needed COMMON / My_Out / height, diameter, volume !...input scalar analysis variables (AV) values for this iteration. ! For starting a problem subroutine avdsca gathers numerical ! values from the X-windows interface in a "New" Set Up window ! or from a stored "Anaylsis" file. ! Arguments: name, '123456789012345' 15 character display CALL avdsca (height, 'height, m ') CALL avdsca (diameter, 'diameter, m ') CALL avdsca (density, 'density, kg/m^3') CALL avdsca (modulus, 'modulus, N/m^2 ') CALL avdsca (axial_load, 'load, N ') ! remember to add thickness as a variable !...compute scalar analysis function (AF) values !...intermediate constants, area, radius of gyration area = pi * diameter**2 / 4.d0 i_over_a = diameter**2 / 8.d0 !...compute functions, mass, axial stress, Euler stress, ! mechanical axial_deflection mass = density * area * height axial_stress = axial_load / area euler_buckling = pi_sq * modulus * i_over_a / height**2 axial_defl = axial_load * height / (modulus * area) ! ? Factor of Safety: stress, buckling, local buckling, deflection ? !...output scalar analysis functions (AF) values [to X-windows] ! Subroutine afdsca scatters the local analysis functions for ! display in X-windows where they can be interactively "mapped". ! Arguments: name, '123456789012345' 15 character display CALL afdsca (mass, 'Mass, kg ') CALL afdsca (axial_stress, 'Stress, N/m^2 ') CALL afdsca (euler_buckling, 'Buckling, N/m^2') CALL afdsca (axial_defl, 'Deflection, m ') ! add other column bucking eqs, & local buckling END SUBROUTINE anafun SUBROUTINE anapos !================================================================== !...subroutine ANAPOS, only called if "Postprocess" button is hit. ! postprocessing routine, if needed !------------------------------------------------------------------ IMPLICIT NONE ! safe style INTEGER, SAVE :: count = 0 ! save counts between calls DOUBLE PRECISION :: height, diameter, volume DOUBLE PRECISION, PARAMETER :: pi = 3.141593d0 ! create a "named" common to access input or output, if needed COMMON / My_Out / height, diameter, volume ! carry out post-processing count = count + 1 volume = height * pi * diameter**2 / 4.d0 ! save to my post-processing file WRITE (10, * ) ' ' WRITE (10, * ) 'Design number = ', count WRITE (10, * ) 'height, diameter (m) = ', height, diameter WRITE (10, * ) 'enclosed volume (m^3) = ', volume END SUBROUTINE anapos ! check syntax with f95 compiler: f95 -c OnebarM.f90 ! create executable file named "try": ! f95 -o try OnebarM.o /usr/site/OptdesX/lib/supportF.o -lnsl -lsocket ! then execute: OptdesX try